- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.9k
Re-introduce attribute rewrite #20892
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
base: master
Are you sure you want to change the base?
Conversation
Basically, we switch to expanding cfg_attr in AST form, filter irrelevant attributes from the item tree, and move hir-def attributes (non-item-tree) to be flag-based. The main motivation is memory usage, although this also simplifies the code, and fixes some bugs around handling of `cfg_attr`s.
See the comment in the code. Previously it wasn't present because we were'nt stripping derives appearing before attribute macros, so we kept the derive and therefore the helper resolved as well. But we should strip the derives, as rustc does.
…value` attr It caused the attribute macro to not be removed, causing it to be expanded again and again. I don't know how to test this, as it's hard to test that the recursion limit was reached.
69a8e50    to
    bf0d974      
    Compare
  
    
      
        
              This comment was marked as outdated.
        
        
      
    
  This comment was marked as outdated.
And instead call `EditionedFileId::current_edition_guess_origin`, as most callers do it anyway.
52d048a    to
    b8b33ca      
    Compare
  
    | Weird, I now see on the metrics page that this regresses time and memory considerably. Don't merge this until I investigate that. | 
| .or_else(|| db.all_crates().first().copied()) | ||
| .unwrap_or_else(|| { | ||
| // What we're doing here is a bit fishy. We rely on the fact that we only need | ||
| // the crate in the item tree, and we should not create an `EditionedFileId` | ||
| // without a crate except in cases where it does not matter. The chances that | ||
| // `all_crates()` will be empty are also very slim, but it can occur during startup. | ||
| // In the very unlikely case that there is a bug and we'll use this crate, Salsa | ||
| // will panic. | ||
|  | ||
| // SAFETY: 0 is less than `Id::MAX_U32`. | ||
| salsa::plumbing::FromId::from_id(unsafe { salsa::Id::from_index(0) }) | ||
| }); | 
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.
Do we really need that previous change (making the function non-optional). Not too fond of this hack, this might populate queries that aren't necessary if this value makes it through. I am also not too happy with the sheer amount of hacks we are slowly accumulating.
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.
What do you mean by "making the function non-optional"?
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.
I meant 1671349
The first commit remains unchanged. Only the second and third commits need review.
I verified that metrics do not regress anymore, and that r-a is usable in the editor.