-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Use AttrItem
instead of Attribute
in more places
#142552
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
Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
b6cceda
to
911245b
Compare
Attribute::Parsed(AttributeKind::AllowConstFnUnstable { .. }) => { | ||
self.check_rustc_allow_const_fn_unstable(hir_id, attr, span, target) | ||
Attribute::Parsed(AttributeKind::AllowConstFnUnstable(_)) => { | ||
// FIXME: this is incorrect |
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 actually fixes an ICE.
Repro:
#[rustc_allow_const_fn_unstable(foo)]
const A: u8 = 1;
fn main(){}
Previously it would go down that one function where trying to get a span for a parsed attr would panic.
While I wasn't able to figure out (yet?) how to do a proper span here, I think that a span that is inaccurate (too large) is still better than an ICE.
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.
It doesn't matter. Anyway, we don't care that blatant misuse of rustc attributes (and lang items etc) results in ices. It is nice but by no means required to have nice errors for these.
This comment has been minimized.
This comment has been minimized.
I'm not sure this is worth it tbh. The names of these apis match the old names in the compiler such that the original migration had the fewest possible changes. However, I intend to completely remove these apis |
The current uglyness is just temporary hack while attributes are migrated. @jdonszelmann and I were talking about having access to |
911245b
to
29b33ed
Compare
29b33ed
to
d6b1d53
Compare
The renaming of methods is probably insignificant and brings no value on its own, but I think (temporary) changing APIs to use more precise types will greatly help with the migration. And it's probably more robust to do this and bring the checks that a proper type is used into compile time, than have a bunch of (temporary, yes, but still less robust) methods that effectively do the same but at runtime and panic on mismatches.
Yes, I suppose by the end of it most type names will go back to what they were before, if that even matters that much. I think that being more certain in the correctness of the code during the migration is far more important that minimizing the surface of (simple renaming) changes. |
Changes requested in #142498 (comment) led me down a bit of a rabbit hole, from which I've emerged with this PR.
r? @jdonszelmann
I guess this is a part of #131229