File tree Expand file tree Collapse file tree 9 files changed +28
-33
lines changed 
hir-def/src/macro_expansion_tests Expand file tree Collapse file tree 9 files changed +28
-33
lines changed Original file line number Diff line number Diff line change @@ -885,7 +885,7 @@ macro_rules! m {
885885    ($t:ty) => ( fn bar() -> $ t {} ) 
886886} 
887887
888- fn bar() -> &  'a Baz<u8> {} 
888+ fn bar() -> &'a Baz<u8> {} 
889889
890890fn bar() -> extern "Rust"fn() -> Ret {} 
891891"# ] ] , 
@@ -1578,7 +1578,7 @@ macro_rules !register_methods {
15781578            ($$($val: expr), *) = > { 
15791579                struct Foo; 
15801580                impl Foo { 
1581-                     $(fn $method()-> &  'static[u32] { 
1581+                     $(fn $method()-> &'static[u32] { 
15821582                        &[$$($$val), *] 
15831583                    } 
15841584                    )* 
@@ -1591,21 +1591,21 @@ macro_rules !implement_methods {
15911591    ($($val: expr), *) = > { 
15921592        struct Foo; 
15931593        impl Foo { 
1594-             fn alpha()-> &  'static[u32] { 
1594+             fn alpha()-> &'static[u32] { 
15951595                &[$($val), *] 
15961596            } 
1597-             fn beta()-> &  'static[u32] { 
1597+             fn beta()-> &'static[u32] { 
15981598                &[$($val), *] 
15991599            } 
16001600        } 
16011601    } 
16021602} 
16031603struct Foo; 
16041604impl Foo { 
1605-     fn alpha() -> &  'static[u32] { 
1605+     fn alpha() -> &'static[u32] { 
16061606        &[1, 2, 3] 
16071607    } 
1608-     fn beta() -> &  'static[u32] { 
1608+     fn beta() -> &'static[u32] { 
16091609        &[1, 2, 3] 
16101610    } 
16111611} 
Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ macro_rules! int_base {
166166    } 
167167} 
168168#[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 { 
170170        Binary.fmt_int(*self as usize, f) 
171171    } 
172172} 
@@ -724,7 +724,7 @@ macro_rules! delegate_impl {
724724        } 
725725    } 
726726} 
727- impl <> Data for &  'amut G where G: Data {} 
727+ impl <> Data for &'amut G where G: Data {} 
728728"## ] ] , 
729729    ) ; 
730730} 
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ m!(static bar: &'static str = "hello";);
7878macro_rules! m { 
7979    ($($t:tt)*) => { $($t)*} 
8080} 
81- static bar: &  'static str = "hello"; 
81+ static bar: &'static str = "hello"; 
8282"# ] ] , 
8383    ) ; 
8484} 
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ fn foo() { bar.; blub }
8787fn foo() { bar.; blub } 
8888
8989fn foo() { 
90-     bar.  ; 
90+     bar.; 
9191    blub 
9292}"## ] ] , 
9393    ) ; 
Original file line number Diff line number Diff line change @@ -251,9 +251,13 @@ fn format_args_expand(
251251    } 
252252    for  arg in  & mut  args { 
253253        // 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  == '=' ) 
255255        { 
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+             } 
257261        } 
258262    } 
259263    let  _format_string = args. remove ( 0 ) ; 
Original file line number Diff line number Diff line change @@ -468,7 +468,7 @@ fn foo() {
468468} 
469469"# , 
470470            expect ! [ [ r#" 
471- fn foo () {a .  __ra_fixup} 
471+ fn foo () {a .__ra_fixup} 
472472"# ] ] , 
473473        ) 
474474    } 
@@ -478,11 +478,11 @@ fn foo () {a . __ra_fixup}
478478        check ( 
479479            r#" 
480480fn foo() { 
481-     a.  ; 
481+     a.; 
482482} 
483483"# , 
484484            expect ! [ [ r#" 
485- fn foo () {a .  __ra_fixup ;} 
485+ fn foo () {a .__ra_fixup ;} 
486486"# ] ] , 
487487        ) 
488488    } 
@@ -492,12 +492,12 @@ fn foo () {a . __ra_fixup ;}
492492        check ( 
493493            r#" 
494494fn foo() { 
495-     a.  ; 
495+     a.; 
496496    bar(); 
497497} 
498498"# , 
499499            expect ! [ [ r#" 
500- fn foo () {a .  __ra_fixup ; bar () ;} 
500+ fn foo () {a .__ra_fixup ; bar () ;} 
501501"# ] ] , 
502502        ) 
503503    } 
@@ -525,7 +525,7 @@ fn foo() {
525525} 
526526"# , 
527527            expect ! [ [ r#" 
528- fn foo () {let x = a .  __ra_fixup ;} 
528+ fn foo () {let x = a .__ra_fixup ;} 
529529"# ] ] , 
530530        ) 
531531    } 
@@ -541,7 +541,7 @@ fn foo() {
541541} 
542542"# , 
543543            expect ! [ [ r#" 
544- fn foo () {a .  b ; bar () ;} 
544+ fn foo () {a .b ; bar () ;} 
545545"# ] ] , 
546546        ) 
547547    } 
Original file line number Diff line number Diff line change @@ -944,7 +944,7 @@ foo!();
944944struct Foo(usize); 
945945
946946impl FooB for Foo { 
947-     $0fn foo<  'lt>(&  'lt self){} 
947+     $0fn foo<'lt>(&'lt self){} 
948948} 
949949"# , 
950950        ) 
Original file line number Diff line number Diff line change @@ -228,16 +228,7 @@ fn convert_tokens<C: TokenConvertor>(conv: &mut C) -> tt::Subtree {
228228            } 
229229
230230            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 , 
241232                _ => tt:: Spacing :: Alone , 
242233            } ; 
243234            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() {
1919        expect ! [ [ r##" 
2020            SUBTREE $ 
2121              IDENT   compile_error 4294967295 
22-               PUNCH   ! [alone ] 4294967295 
22+               PUNCH   ! [joint ] 4294967295 
2323              SUBTREE () 4294967295 
2424                LITERAL "#[derive(DeriveError)] struct S ;" 4294967295 
2525              PUNCH   ; [alone] 4294967295"## ] ] , 
@@ -109,7 +109,7 @@ fn test_fn_like_macro_clone_literals() {
109109              PUNCH   , [alone] 4294967295 
110110              LITERAL 2_u32 4294967295 
111111              PUNCH   , [alone] 4294967295 
112-               PUNCH   - [alone ] 4294967295 
112+               PUNCH   - [joint ] 4294967295 
113113              LITERAL 4i64 4294967295 
114114              PUNCH   , [alone] 4294967295 
115115              LITERAL 3.14f32 4294967295 
@@ -130,7 +130,7 @@ fn test_attr_macro() {
130130        expect ! [ [ r##" 
131131            SUBTREE $ 
132132              IDENT   compile_error 4294967295 
133-               PUNCH   ! [alone ] 4294967295 
133+               PUNCH   ! [joint ] 4294967295 
134134              SUBTREE () 4294967295 
135135                LITERAL "#[attr_error(some arguments)] mod m {}" 4294967295 
136136              PUNCH   ; [alone] 4294967295"## ] ] , 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments