-
Notifications
You must be signed in to change notification settings - Fork 13.8k
add transparent attribute for mod items #147709
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 compiler/rustc_hir/src/attrs Some changes occurred in compiler/rustc_attr_parsing Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
/// * A trait or an enum (it implicitly contains associated types, methods and variant | ||
/// constructors). | ||
Def(DefKind, DefId, Option<Symbol>), | ||
Def(DefKind, DefId, Option<(Symbol, bool)>), |
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 was the most obvious place to put this but it doesn't feel great, don't love all the places where I changed shit to name_and_transparent
, open to suggestions for how to better thread this information through
// Inner module is inside the macro | ||
&& module.expansion != parent.expansion | ||
// Parent module is outside of the macro | ||
&& module.expansion.is_descendant_of(parent.expansion) | ||
// The macro is a proc macro derive | ||
&& let Some(def_id) = module.expansion.expn_data().macro_def_id |
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.
ill clean this up in the next pass, formatting got fked up in a few places >:[
orig_ident.span, | ||
"ambiguous scoped macro resolutions with path-based \ | ||
scope resolution as first candidate" | ||
scope resolution as first candidate" |
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.
todo: cleanup formatting
transmute_opts, | ||
transmute_trait, | ||
transmute_unchecked, | ||
transparent, |
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 feel like I'm probably doing this part subtly wrong.
The transparent symbol already exists and I'm using it, I tried seeing if I could stay away from it and find a way to have all the compiler internal stuff talk about it with a unique symbol (transparent_modules
) but have the actual ident of the attribute be transparent
but it seemed like this was controlling that. If I got that wrong lmk.
The job Click to see the possible cause of the failure (guessed by this bot)
|
const PATH: &[Symbol] = &[sym::transparent]; | ||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error; | ||
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Mod)]); | ||
const CREATE: fn(Span) -> AttributeKind = |span| AttributeKind::Transparent(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.
No need for a closure here
With that nit, r=me for just the attributes stuff. I don't know as much about the name resolution part to sign off on that but thats for petrochenkov :) |
Addresses #79260
r? @petrochenkov