-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Port #[rustc_skip_during_method_dispatch]
to the new attribute system
#142695
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?
Port #[rustc_skip_during_method_dispatch]
to the new attribute system
#142695
Conversation
|
Some changes occurred in compiler/rustc_attr_data_structures Some changes occurred in compiler/rustc_attr_parsing Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
@@ -1093,22 +1094,11 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef { | |||
let rustc_coinductive = tcx.has_attr(def_id, sym::rustc_coinductive); | |||
let is_fundamental = tcx.has_attr(def_id, sym::fundamental); | |||
|
|||
// FIXME: We could probably do way better attribute validation 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.
Hehe, fixed the fixme :)
@@ -33,6 +33,7 @@ pub(crate) mod deprecation; | |||
pub(crate) mod inline; | |||
pub(crate) mod lint_helpers; | |||
pub(crate) mod repr; | |||
pub(crate) mod resolution; |
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 expect more parsers in this module?
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.
Probably not, but didn't know where else to put plus in the future it might get reworked a bit if rust-lang/libs-team#605 gets accepted.
pub(crate) struct SkipDuringMethodDispatchParser; | ||
|
||
impl<S: Stage> SingleAttributeParser<S> for SkipDuringMethodDispatchParser { | ||
const PATH: &'static [Symbol] = &[sym::rustc_skip_during_method_dispatch]; |
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 believe the 'static is unnecessary here
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst; | ||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error; | ||
|
||
const TEMPLATE: AttributeTemplate = template!(List: "array, boxed_slice"); |
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 wish we had a better way to say in templates that it's one or more of these. I think I'll at some point have a pass over all the templates we have tbh... Not related to your pr
error: malformed `rustc_skip_during_method_dispatch` attribute input | ||
--> $DIR/rustc_skip_during_method_dispatch.rs:3:1 | ||
| | ||
LL | #[rustc_skip_during_method_dispatch] |
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.
Error on line 3 emitted twice. You should add an exception in rustc_builtin_attrs to no longer validate this attribute. That exception will be temporary until all attrs are migrated. Take a look at what I did for the inline parser (search for sym::inline in the compiler what will also show you it).
84a4a9a
to
e015bc7
Compare
@rustbot ready |
ArgParser::NameValue(args) => Some(args.eq_span.to(args.value_span)), | ||
} { | ||
cx.unexpected_literal(span); | ||
} |
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.
U can use ArgParser::no_args
if let Some(span) = match arg.args() { | ||
ArgParser::NoArgs => None, | ||
ArgParser::List(args) => Some(args.span), | ||
ArgParser::NameValue(args) => Some(args.eq_span.to(args.value_span)), | ||
} { | ||
cx.unexpected_literal(span); | ||
} |
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.
if let Some(span) = match arg.args() { | |
ArgParser::NoArgs => None, | |
ArgParser::List(args) => Some(args.span), | |
ArgParser::NameValue(args) => Some(args.eq_span.to(args.value_span)), | |
} { | |
cx.unexpected_literal(span); | |
} | |
if !arg.args().no_args() { | |
cx.unexpected_literal(span); | |
} |
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.
This will give a less precise span. I'm planning to move this code into a helper function in a follow-up PR. Or maybe I can do it in this one.
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.
Wasn't there a .span() method to do this combining already? Saying that from memory, didn't check
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.
Wasn't there a .span() method to do this combining already? Saying that from memory, didn't check
There was, but it returns an Option<Span>
where None
<=> NoArgs
, but I didn't want to rely on that implementation detail.
This will give a less precise span. I'm planning to move this code into a helper function in a follow-up PR. Or maybe I can do it in this one.
Done.
☔ The latest upstream changes (presumably #142697) made this pull request unmergeable. Please resolve the merge conflicts. |
e015bc7
to
961a2cd
Compare
@@ -310,6 +322,24 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> { | |||
}, | |||
}) | |||
} | |||
|
|||
pub(crate) fn expect_no_args(&self, args: &ArgParser<'_>) -> Result<(), ErrorGuaranteed> { | |||
if let Some(span) = match args { |
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 think for #[cold]
I implemented this exact method. Could you rebase on that branch? Unfortunately it's taking a bit for everything to merge in. #142491
☔ The latest upstream changes (presumably #142770) made this pull request unmergeable. Please resolve the merge conflicts. |
Part of #131229
r? @jdonszelmann