-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Call features_query fewer times in smart_resolve_macro_path
#155155
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -712,35 +712,33 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { | |||||||
| feature_err(&self.tcx.sess, sym::custom_inner_attributes, path.span, msg).emit(); | ||||||||
| } | ||||||||
|
|
||||||||
| let diagnostic_attributes: &[(Symbol, bool)] = &[ | ||||||||
| (sym::on_unimplemented, true), | ||||||||
| (sym::do_not_recommend, true), | ||||||||
| (sym::on_move, true), | ||||||||
| (sym::on_const, self.tcx.features().diagnostic_on_const()), | ||||||||
| (sym::on_unknown, self.tcx.features().diagnostic_on_unknown()), | ||||||||
| ]; | ||||||||
|
|
||||||||
| if res == Res::NonMacroAttr(NonMacroAttrKind::Tool) | ||||||||
| && let [namespace, attribute, ..] = &*path.segments | ||||||||
| && namespace.ident.name == sym::diagnostic | ||||||||
| && !diagnostic_attributes | ||||||||
| .iter() | ||||||||
| .any(|(attr, stable)| *stable && attribute.ident.name == *attr) | ||||||||
| { | ||||||||
| let span = attribute.span(); | ||||||||
| let candidates = diagnostic_attributes | ||||||||
| .iter() | ||||||||
| .filter_map(|(sym, stable)| stable.then_some(*sym)) | ||||||||
| .collect::<Vec<_>>(); | ||||||||
| let typo = find_best_match_for_name(&candidates, attribute.ident.name, Some(5)) | ||||||||
| let stable_diagnostic_attributes: Vec<_> = | ||||||||
| [sym::on_unimplemented, sym::do_not_recommend, sym::on_move] | ||||||||
|
Member
Author
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. (preexisting)
Contributor
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. I remember that attribute being gated, so it's gate is probably elsewhere
Contributor
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. @fmease the gates are in attribute parsing, all three unstable diagnostic attrs have a check like
The checks in rustc_resolve here are just for typo suggestions. but on_move was merged in between the creation and merge of #152901, that's probably why it's accidentally there.
Member
Author
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. Ah, thanks, I see, obvious in hindsight
Contributor
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. Can you give |
||||||||
| .into_iter() | ||||||||
| .chain(self.tcx.features().diagnostic_on_const().then_some(sym::on_const)) | ||||||||
| .chain(self.tcx.features().diagnostic_on_unknown().then_some(sym::on_unknown)) | ||||||||
| .collect(); | ||||||||
|
|
||||||||
| if !stable_diagnostic_attributes.iter().any(|&attr| attribute.ident.name == attr) { | ||||||||
| let span = attribute.span(); | ||||||||
| let typo = find_best_match_for_name( | ||||||||
| &stable_diagnostic_attributes, | ||||||||
| attribute.ident.name, | ||||||||
| Some(5), | ||||||||
|
Contributor
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. I just realized that
Suggested change
|
||||||||
| ) | ||||||||
| .map(|typo_name| errors::UnknownDiagnosticAttributeTypoSugg { span, typo_name }); | ||||||||
|
|
||||||||
| self.tcx.sess.psess.buffer_lint( | ||||||||
| UNKNOWN_DIAGNOSTIC_ATTRIBUTES, | ||||||||
| span, | ||||||||
| node_id, | ||||||||
| errors::UnknownDiagnosticAttribute { typo }, | ||||||||
| ); | ||||||||
| self.tcx.sess.psess.buffer_lint( | ||||||||
| UNKNOWN_DIAGNOSTIC_ATTRIBUTES, | ||||||||
| span, | ||||||||
| node_id, | ||||||||
| errors::UnknownDiagnosticAttribute { typo }, | ||||||||
| ); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| Ok((ext, res)) | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
View changes since the review
(preexisting) Kinda odd that we perform this check here instead of over in
rustc_attr_parsing. Of course, this check has existed long beforerustc_attr_parsingwas introduced but now we should have better infrastructure in place.Note that I'm not super familiar with the "low-level entry point" of the new attribute parsing infrastructure, so I don't know if there's a good reason why this check happens here.
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.
Yeah I still have plans to move feature gating to the new attribute parsing Infrastructure, but that is nicer to do after the lint attributes are ported again