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 481db40

Browse files
committedMay 12, 2022
Auto merge of #95562 - lcnr:attr-no-encode, r=davidtwco
don't encode only locally used attrs Part of rust-lang/compiler-team#505. We now filter builtin attributes before encoding them in the crate metadata in case they should only be used in the local crate. To prevent accidental misuse `get_attrs` now requires the caller to state which attribute they are interested in. For places where that isn't trivially possible, I've added a method `fn get_attrs_unchecked` which I intend to remove in a followup PR. After this pull request landed, we can then slowly move all attributes to only be used in the local crate while being certain that we don't accidentally try to access them from extern crates. cc #94963 (comment)
2 parents 18bd2dd + ebf9583 commit 481db40

File tree

55 files changed

+453
-465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+453
-465
lines changed
 

‎compiler/rustc_attr/src/builtin.rs

Lines changed: 141 additions & 138 deletions
Large diffs are not rendered by default.

‎compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_hir::def_id::DefId;
66
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
77
use rustc_middle::ty::{self, TyCtxt};
88
use rustc_session::config::OptLevel;
9+
use rustc_span::symbol::sym;
910
use rustc_target::spec::abi::Abi;
1011
use rustc_target::spec::{FramePointer, SanitizerSet, StackProbeType, StackProtector};
1112
use smallvec::SmallVec;
@@ -329,9 +330,7 @@ pub fn from_fn_attrs<'ll, 'tcx>(
329330
) {
330331
let span = cx
331332
.tcx
332-
.get_attrs(instance.def_id())
333-
.iter()
334-
.find(|a| a.has_name(rustc_span::sym::target_feature))
333+
.get_attr(instance.def_id(), sym::target_feature)
335334
.map_or_else(|| cx.tcx.def_span(instance.def_id()), |a| a.span);
336335
let msg = format!(
337336
"the target features {} must all be either enabled or disabled together",

0 commit comments

Comments
 (0)
Please sign in to comment.