Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a0d7715

Browse files
committedMar 19, 2024
Change only_local to enum type and change the macros to always require a variant of that enum.
1 parent 3cdcdaf commit a0d7715

File tree

4 files changed

+276
-213
lines changed

4 files changed

+276
-213
lines changed
 

‎compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 271 additions & 202 deletions
Large diffs are not rendered by default.

‎compiler/rustc_feature/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub fn find_feature_issue(feature: Symbol, issue: GateIssue) -> Option<NonZero<u
124124
pub use accepted::ACCEPTED_FEATURES;
125125
pub use builtin_attrs::AttributeDuplicates;
126126
pub use builtin_attrs::{
127-
deprecated_attributes, find_gated_cfg, is_builtin_attr_name, is_builtin_only_local,
127+
deprecated_attributes, find_gated_cfg, is_builtin_attr_name, is_not_builtin_encode_cross_crate,
128128
is_valid_for_get_attr, AttributeGate, AttributeTemplate, AttributeType, BuiltinAttribute,
129129
GatedCfg, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP,
130130
};

‎compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,8 @@ struct AnalyzeAttrState {
817817
#[inline]
818818
fn analyze_attr(attr: &Attribute, state: &mut AnalyzeAttrState) -> bool {
819819
let mut should_encode = false;
820-
if rustc_feature::is_builtin_only_local(attr.name_or_empty()) {
821-
// Attributes marked local-only don't need to be encoded for downstream crates.
820+
if rustc_feature::is_not_builtin_encode_cross_crate(attr.name_or_empty()) {
821+
// Attributes not marked encode-cross-crate don't need to be encoded for downstream crates.
822822
} else if attr.doc_str().is_some() {
823823
// We keep all doc comments reachable to rustdoc because they might be "imported" into
824824
// downstream crates if they use `#[doc(inline)]` to copy an item's documentation into

‎compiler/rustc_middle/src/ty/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,9 +1752,8 @@ impl<'tcx> TyCtxt<'tcx> {
17521752
let filter_fn = move |a: &&ast::Attribute| a.has_name(attr);
17531753
if let Some(did) = did.as_local() {
17541754
self.hir().attrs(self.local_def_id_to_hir_id(did)).iter().filter(filter_fn)
1755-
} else if cfg!(debug_assertions) && rustc_feature::is_builtin_only_local(attr) {
1756-
bug!("tried to access the `only_local` attribute `{}` from an extern crate", attr);
17571755
} else {
1756+
debug_assert!(!rustc_feature::is_not_builtin_encode_cross_crate(attr));
17581757
self.item_attrs(did).iter().filter(filter_fn)
17591758
}
17601759
}
@@ -1786,12 +1785,7 @@ impl<'tcx> TyCtxt<'tcx> {
17861785

17871786
/// Determines whether an item is annotated with an attribute.
17881787
pub fn has_attr(self, did: impl Into<DefId>, attr: Symbol) -> bool {
1789-
let did: DefId = did.into();
1790-
if cfg!(debug_assertions) && !did.is_local() && rustc_feature::is_builtin_only_local(attr) {
1791-
bug!("tried to access the `only_local` attribute `{}` from an extern crate", attr);
1792-
} else {
1793-
self.get_attrs(did, attr).next().is_some()
1794-
}
1788+
self.get_attrs(did, attr).next().is_some()
17951789
}
17961790

17971791
/// Returns `true` if this is an `auto trait`.

0 commit comments

Comments
 (0)
Please sign in to comment.