File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -1380,4 +1380,24 @@ lib::foo!();
13801380            "# ] ] , 
13811381        ) ; 
13821382    } 
1383+ 
1384+     #[ test]  
1385+     fn  macro_doesnt_reference_attribute_on_call ( )  { 
1386+         check ( 
1387+             r#" 
1388+ macro_rules! m { 
1389+     () => {}; 
1390+ } 
1391+ 
1392+ #[proc_macro_test::attr_noop] 
1393+ m$0!(); 
1394+ 
1395+ "# , 
1396+             expect ! [ [ r#" 
1397+                 m Macro FileId(0) 0..32 13..14 
1398+ 
1399+                 FileId(0) 64..65 
1400+             "# ] ] , 
1401+         ) ; 
1402+     } 
13831403} 
Original file line number Diff line number Diff line change @@ -357,19 +357,17 @@ impl NameRefClass {
357357            } 
358358        } 
359359
360-         if  let  Some ( macro_call )  = parent . ancestors ( ) . find_map ( ast:: MacroCall :: cast)  { 
361-             if  let   Some ( path)  = macro_call . path ( )  { 
362-                 if  path. qualifier ( ) . is_none ( )  { 
360+         if  let  Some ( path )  = name_ref . syntax ( ) . ancestors ( ) . find_map ( ast:: Path :: cast)  { 
361+             if  path. qualifier ( ) . is_none ( )  { 
362+                 if  let   Some ( macro_call )  =  path. syntax ( ) . parent ( ) . and_then ( ast :: MacroCall :: cast )  { 
363363                    // Only use this to resolve single-segment macro calls like `foo!()`. Multi-segment 
364364                    // paths are handled below (allowing `log$0::info!` to resolve to the log crate). 
365365                    if  let  Some ( macro_def)  = sema. resolve_macro_call ( & macro_call)  { 
366366                        return  Some ( NameRefClass :: Definition ( Definition :: Macro ( macro_def) ) ) ; 
367367                    } 
368368                } 
369369            } 
370-         } 
371370
372-         if  let  Some ( path)  = name_ref. syntax ( ) . ancestors ( ) . find_map ( ast:: Path :: cast)  { 
373371            if  let  Some ( resolved)  = sema. resolve_path ( & path)  { 
374372                if  path. syntax ( ) . parent ( ) . and_then ( ast:: Attr :: cast) . is_some ( )  { 
375373                    if  let  PathResolution :: Def ( ModuleDef :: Function ( func) )  = resolved { 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments