1
Fork 0

Rollup merge of #122695 - surechen:make_only_local_explict_argument, r=lcnr

Change only_local to a enum type.

Change only_local to enum type and change the macros to always require a variant of that enum.

r? `@lcnr`
This commit is contained in:
Matthias Krüger 2024-03-19 18:03:52 +01:00 committed by GitHub
commit ea7ea2df86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 279 additions and 215 deletions

View file

@ -1752,9 +1752,8 @@ impl<'tcx> TyCtxt<'tcx> {
let filter_fn = move |a: &&ast::Attribute| a.has_name(attr);
if let Some(did) = did.as_local() {
self.hir().attrs(self.local_def_id_to_hir_id(did)).iter().filter(filter_fn)
} else if cfg!(debug_assertions) && rustc_feature::is_builtin_only_local(attr) {
bug!("tried to access the `only_local` attribute `{}` from an extern crate", attr);
} else {
debug_assert!(rustc_feature::encode_cross_crate(attr));
self.item_attrs(did).iter().filter(filter_fn)
}
}
@ -1786,12 +1785,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// Determines whether an item is annotated with an attribute.
pub fn has_attr(self, did: impl Into<DefId>, attr: Symbol) -> bool {
let did: DefId = did.into();
if cfg!(debug_assertions) && !did.is_local() && rustc_feature::is_builtin_only_local(attr) {
bug!("tried to access the `only_local` attribute `{}` from an extern crate", attr);
} else {
self.get_attrs(did, attr).next().is_some()
}
self.get_attrs(did, attr).next().is_some()
}
/// Returns `true` if this is an `auto trait`.