- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
          macros: support invocation paths (e.g. foo::bar!()) behind #![feature(use_extern_macros)]
          #38082
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
453ae77    to
    8735337      
    Compare
  
    | 
           cc #35896  | 
    
| 
           ☔ The latest upstream changes (presumably #38014) made this pull request unmergeable. Please resolve the merge conflicts.  | 
    
| 
           Could you add an r-pass test for a successful macro use via a path please? I don't see any checks for the feature gate - is it checked implicitly somewhere? r = me with me the extra test and the feature gate checked if necessary  | 
    
        
          
                src/librustc_resolve/macros.rs
              
                Outdated
          
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: error recovery here would be trivial - just proceed further instead of returning Err.
0e60b92    to
    ed96c0b      
    Compare
  
    ed96c0b    to
    ff621ec      
    Compare
  
    | 
           I cleaned up the feature gating code, made macro invocation paths without   | 
    
| 
           Hi @jseyfried,  | 
    
| 
           @KalitaAlexey It can be any path. However, paths cannot resolve to local   | 
    
| 
           @bors r=nrc  | 
    
| 
           📌 Commit ff621ec has been approved by   | 
    
macros: support invocation paths (e.g. `foo::bar!()`) behind `#![feature(use_extern_macros)]` r? @nrc
| 
           This brings up a question with self-recursive macros, should they always call themselves using the full path, using   | 
    
| 
           @bluss In other words, a non-trivial macro invocation path must resolve to an item. Exported macros from extern crates are items and  
 I think it's best to wait for fully hygienic macros by example 2.0 (  | 
    
| 
           The limitation that they can't be called inside their own crate sounds fair and not like a too big problem.  | 
    
| 
           @bluss (cc @nrc) It turned out that we can land this (and even stabilize if we want to) before macros by example 2.0 (RFC 1584), expediting these benefits. However, since MBE 2.0 is so close, I think it would be a bad idea to land any further improvements that won't be needed with MBE 2.0. That being said, I think we should land further improvements that will be useful with MBE 2.0. For example, if an upstream crate defines a recursive  I believe we can solve this backwards compatibly by resolving a macro name from an external   | 
    
r? @nrc