diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-19 18:03:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-19 18:03:52 +0100 |
| commit | ea7ea2df86533dd8cb8561b69f5142d650a23539 (patch) | |
| tree | a7a8dfa30a41936c71a6048471b0d38a049843ef /compiler/rustc_middle/src | |
| parent | 2ad2492b7b5b0e368b196eff3572bdb556bb2862 (diff) | |
| parent | db48dfcd03ec039eb1741becf7f445a66af6761b (diff) | |
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`
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 8565f90957f..6632d980bff 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -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`. |
