File tree 9 files changed +28
-33
lines changed
hir-def/src/macro_expansion_tests
9 files changed +28
-33
lines changed Original file line number Diff line number Diff line change @@ -885,7 +885,7 @@ macro_rules! m {
885
885
($t:ty) => ( fn bar() -> $ t {} )
886
886
}
887
887
888
- fn bar() -> & 'a Baz<u8> {}
888
+ fn bar() -> &'a Baz<u8> {}
889
889
890
890
fn bar() -> extern "Rust"fn() -> Ret {}
891
891
"# ] ] ,
@@ -1578,7 +1578,7 @@ macro_rules !register_methods {
1578
1578
($$($val: expr), *) = > {
1579
1579
struct Foo;
1580
1580
impl Foo {
1581
- $(fn $method()-> & 'static[u32] {
1581
+ $(fn $method()-> &'static[u32] {
1582
1582
&[$$($$val), *]
1583
1583
}
1584
1584
)*
@@ -1591,21 +1591,21 @@ macro_rules !implement_methods {
1591
1591
($($val: expr), *) = > {
1592
1592
struct Foo;
1593
1593
impl Foo {
1594
- fn alpha()-> & 'static[u32] {
1594
+ fn alpha()-> &'static[u32] {
1595
1595
&[$($val), *]
1596
1596
}
1597
- fn beta()-> & 'static[u32] {
1597
+ fn beta()-> &'static[u32] {
1598
1598
&[$($val), *]
1599
1599
}
1600
1600
}
1601
1601
}
1602
1602
}
1603
1603
struct Foo;
1604
1604
impl Foo {
1605
- fn alpha() -> & 'static[u32] {
1605
+ fn alpha() -> &'static[u32] {
1606
1606
&[1, 2, 3]
1607
1607
}
1608
- fn beta() -> & 'static[u32] {
1608
+ fn beta() -> &'static[u32] {
1609
1609
&[1, 2, 3]
1610
1610
}
1611
1611
}
Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ macro_rules! int_base {
166
166
}
167
167
}
168
168
#[stable(feature = "rust1", since = "1.0.0")] impl fmt::Binary for isize {
169
- fn fmt(&self , f: &mut fmt::Formatter< '_>) -> fmt::Result {
169
+ fn fmt(&self , f: &mut fmt::Formatter<'_>) -> fmt::Result {
170
170
Binary.fmt_int(*self as usize, f)
171
171
}
172
172
}
@@ -724,7 +724,7 @@ macro_rules! delegate_impl {
724
724
}
725
725
}
726
726
}
727
- impl <> Data for & 'amut G where G: Data {}
727
+ impl <> Data for &'amut G where G: Data {}
728
728
"## ] ] ,
729
729
) ;
730
730
}
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ m!(static bar: &'static str = "hello";);
78
78
macro_rules! m {
79
79
($($t:tt)*) => { $($t)*}
80
80
}
81
- static bar: & 'static str = "hello";
81
+ static bar: &'static str = "hello";
82
82
"# ] ] ,
83
83
) ;
84
84
}
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ fn foo() { bar.; blub }
87
87
fn foo() { bar.; blub }
88
88
89
89
fn foo() {
90
- bar. ;
90
+ bar.;
91
91
blub
92
92
}"## ] ] ,
93
93
) ;
Original file line number Diff line number Diff line change @@ -251,9 +251,13 @@ fn format_args_expand(
251
251
}
252
252
for arg in & mut args {
253
253
// Remove `key =`.
254
- if matches ! ( arg. token_trees. get( 1 ) , Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Punct ( p) ) ) if p. char == '=' && p . spacing != tt :: Spacing :: Joint )
254
+ if matches ! ( arg. token_trees. get( 1 ) , Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Punct ( p) ) ) if p. char == '=' )
255
255
{
256
- arg. token_trees . drain ( ..2 ) ;
256
+ // but not with `==`
257
+ if !matches ! ( arg. token_trees. get( 2 ) , Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Punct ( p) ) ) if p. char == '=' )
258
+ {
259
+ arg. token_trees . drain ( ..2 ) ;
260
+ }
257
261
}
258
262
}
259
263
let _format_string = args. remove ( 0 ) ;
Original file line number Diff line number Diff line change @@ -468,7 +468,7 @@ fn foo() {
468
468
}
469
469
"# ,
470
470
expect ! [ [ r#"
471
- fn foo () {a . __ra_fixup}
471
+ fn foo () {a .__ra_fixup}
472
472
"# ] ] ,
473
473
)
474
474
}
@@ -478,11 +478,11 @@ fn foo () {a . __ra_fixup}
478
478
check (
479
479
r#"
480
480
fn foo() {
481
- a. ;
481
+ a.;
482
482
}
483
483
"# ,
484
484
expect ! [ [ r#"
485
- fn foo () {a . __ra_fixup ;}
485
+ fn foo () {a .__ra_fixup ;}
486
486
"# ] ] ,
487
487
)
488
488
}
@@ -492,12 +492,12 @@ fn foo () {a . __ra_fixup ;}
492
492
check (
493
493
r#"
494
494
fn foo() {
495
- a. ;
495
+ a.;
496
496
bar();
497
497
}
498
498
"# ,
499
499
expect ! [ [ r#"
500
- fn foo () {a . __ra_fixup ; bar () ;}
500
+ fn foo () {a .__ra_fixup ; bar () ;}
501
501
"# ] ] ,
502
502
)
503
503
}
@@ -525,7 +525,7 @@ fn foo() {
525
525
}
526
526
"# ,
527
527
expect ! [ [ r#"
528
- fn foo () {let x = a . __ra_fixup ;}
528
+ fn foo () {let x = a .__ra_fixup ;}
529
529
"# ] ] ,
530
530
)
531
531
}
@@ -541,7 +541,7 @@ fn foo() {
541
541
}
542
542
"# ,
543
543
expect ! [ [ r#"
544
- fn foo () {a . b ; bar () ;}
544
+ fn foo () {a .b ; bar () ;}
545
545
"# ] ] ,
546
546
)
547
547
}
Original file line number Diff line number Diff line change @@ -944,7 +944,7 @@ foo!();
944
944
struct Foo(usize);
945
945
946
946
impl FooB for Foo {
947
- $0fn foo< 'lt>(& 'lt self){}
947
+ $0fn foo<'lt>(&'lt self){}
948
948
}
949
949
"# ,
950
950
)
Original file line number Diff line number Diff line change @@ -228,16 +228,7 @@ fn convert_tokens<C: TokenConvertor>(conv: &mut C) -> tt::Subtree {
228
228
}
229
229
230
230
let spacing = match conv. peek ( ) . map ( |next| next. kind ( conv) ) {
231
- Some ( kind)
232
- if !kind. is_trivia ( )
233
- && kind. is_punct ( )
234
- && kind != T ! [ '[' ]
235
- && kind != T ! [ '{' ]
236
- && kind != T ! [ '(' ]
237
- && kind != UNDERSCORE =>
238
- {
239
- tt:: Spacing :: Joint
240
- }
231
+ Some ( kind) if !kind. is_trivia ( ) => tt:: Spacing :: Joint ,
241
232
_ => tt:: Spacing :: Alone ,
242
233
} ;
243
234
let char = match token. to_char ( conv) {
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ fn test_derive_error() {
19
19
expect ! [ [ r##"
20
20
SUBTREE $
21
21
IDENT compile_error 4294967295
22
- PUNCH ! [alone ] 4294967295
22
+ PUNCH ! [joint ] 4294967295
23
23
SUBTREE () 4294967295
24
24
LITERAL "#[derive(DeriveError)] struct S ;" 4294967295
25
25
PUNCH ; [alone] 4294967295"## ] ] ,
@@ -109,7 +109,7 @@ fn test_fn_like_macro_clone_literals() {
109
109
PUNCH , [alone] 4294967295
110
110
LITERAL 2_u32 4294967295
111
111
PUNCH , [alone] 4294967295
112
- PUNCH - [alone ] 4294967295
112
+ PUNCH - [joint ] 4294967295
113
113
LITERAL 4i64 4294967295
114
114
PUNCH , [alone] 4294967295
115
115
LITERAL 3.14f32 4294967295
@@ -130,7 +130,7 @@ fn test_attr_macro() {
130
130
expect ! [ [ r##"
131
131
SUBTREE $
132
132
IDENT compile_error 4294967295
133
- PUNCH ! [alone ] 4294967295
133
+ PUNCH ! [joint ] 4294967295
134
134
SUBTREE () 4294967295
135
135
LITERAL "#[attr_error(some arguments)] mod m {}" 4294967295
136
136
PUNCH ; [alone] 4294967295"## ] ] ,
You can’t perform that action at this time.
0 commit comments