-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(macros): ignore ignored macros completely #15117
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -635,11 +635,11 @@ impl<'a> AssocItemCollector<'a> { | |||||||||||||||||||
| attr, | ||||||||||||||||||||
| ) { | ||||||||||||||||||||
| Ok(ResolvedAttr::Macro(call_id)) => { | ||||||||||||||||||||
| self.attr_calls.push((ast_id, call_id)); | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh ... this was the reason things broke down for tracing and the like ... |
||||||||||||||||||||
| // If proc attribute macro expansion is disabled, skip expanding it here | ||||||||||||||||||||
| if !self.db.expand_proc_attr_macros() { | ||||||||||||||||||||
| continue 'attrs; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| let loc = self.db.lookup_intern_macro_call(call_id); | ||||||||||||||||||||
| if let MacroDefKind::ProcMacro(exp, ..) = loc.def.kind { | ||||||||||||||||||||
| // If there's no expander for the proc macro (e.g. the | ||||||||||||||||||||
|
|
@@ -650,8 +650,21 @@ impl<'a> AssocItemCollector<'a> { | |||||||||||||||||||
| if exp.is_dummy() { | ||||||||||||||||||||
| continue 'attrs; | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // We check whether the proc macro is ignored, if it is, we don't expand it. | ||||||||||||||||||||
| let proc_macros = self.db.proc_macros(); | ||||||||||||||||||||
| let proc_macro = proc_macros.get(&loc.def.krate).and_then(|m| { | ||||||||||||||||||||
| m.as_ref().ok().and_then(|m| m.get(exp.proc_macro_id().0 as usize)) | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| if let Some(proc_macro) = proc_macro { | ||||||||||||||||||||
| if proc_macro.ignored { | ||||||||||||||||||||
| continue 'attrs; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| self.attr_calls.push((ast_id, call_id)); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| let res = | ||||||||||||||||||||
| self.expander.enter_expand_id::<ast::MacroItems>(self.db, call_id); | ||||||||||||||||||||
| self.collect_macro_items(res, &|| loc.kind.clone()); | ||||||||||||||||||||
|
|
||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hmm, let's do things a bit differently. Instead of encoding
ignorednessas a flag here, let's just add a second specialProcMacroExpanderfor ignored ones, samy way we hadnle the dummy expander basically. Then we don't need to fetch the loaded proc-macros everytime to check and can instead immediately check the expander at hand