Skip to content

Commit 74a3e99

Browse files
committed
Update some macro tests
1 parent 60dff5f commit 74a3e99

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

src/bin/cargo-fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn execute() -> i32 {
9797
}
9898

9999
macro_rules! print_usage {
100-
($print:ident, $opts:ident, $reason:expr) => ({
100+
($print: ident, $opts: ident, $reason: expr) => ({
101101
let msg = format!("{}\nusage: cargo fmt [options]", $reason);
102102
$print!(
103103
"{}\nThis utility formats all bin and lib files of the current crate using rustfmt. \

tests/target/macro_not_expr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
macro_rules! test {
2-
($($t:tt)*) => {}
2+
($($t: tt)*) => {
3+
};
34
}
45

56
fn main() {

tests/target/macros.rs

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ fn issue_1555() {
141141

142142
fn issue1178() {
143143
macro_rules! foo {
144-
(#[$attr:meta] $name:ident) => {}
144+
(#[$attr: meta] $name: ident) => {
145+
};
145146
}
146147

147148
foo!(
@@ -246,11 +247,15 @@ fn __bindgen_test_layout_HandleWithDtor_open0_int_close0_instantiation() {
246247

247248
// #878
248249
macro_rules! try_opt {
249-
($expr:expr) => (match $expr {
250-
Some(val) => val,
250+
($expr: expr) => {
251+
match $expr {
252+
Some(val) => val,
251253

252-
None => { return None; }
253-
})
254+
None => {
255+
return None;
256+
}
257+
}
258+
};
254259
}
255260

256261
// #2214
@@ -885,23 +890,28 @@ fn macro_in_pattern_position() {
885890
};
886891
}
887892

888-
macro foo() {
889-
893+
macro foo {
894+
() => {
895+
}
890896
}
891897

892-
pub macro bar($x: ident + $y: expr;) {
893-
fn foo($x: Foo) {
894-
long_function(
895-
a_long_argument_to_a_long_function_is_what_this_is(AAAAAAAAAAAAAAAAAAAAAAAAAAAA),
896-
$x.bar($y),
897-
);
898+
pub macro bar {
899+
($x: ident + $y: expr;) => {
900+
fn foo($x: Foo) {
901+
long_function(
902+
a_long_argument_to_a_long_function_is_what_this_is(AAAAAAAAAAAAAAAAAAAAAAAAAAAA),
903+
$x.bar($y),
904+
);
905+
}
898906
}
899907
}
900908

901-
macro foo() {
902-
// a comment
903-
fn foo() {
904-
// another comment
905-
bar();
909+
macro foo {
910+
() => {
911+
// a comment
912+
fn foo() {
913+
// another comment
914+
bar();
915+
}
906916
}
907917
}

0 commit comments

Comments
 (0)