diff options
| author | bors <bors@rust-lang.org> | 2022-05-12 12:48:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-12 12:48:30 +0000 |
| commit | 481db40311cdd241ae4d33f34f2f75732e44d8e8 (patch) | |
| tree | 6c5d0ea5404f19cd916403f46a6ae2105fddd096 /compiler/rustc_trait_selection/src | |
| parent | 18bd2dd5cda08b09ace6e37c1a0312e9b2bb4beb (diff) | |
| parent | ebf95836e3cfc8c442cc71239324d947aafa3eac (diff) | |
| download | rust-481db40311cdd241ae4d33f34f2f75732e44d8e8.tar.gz rust-481db40311cdd241ae4d33f34f2f75732e44d8e8.zip | |
Auto merge of #95562 - lcnr:attr-no-encode, r=davidtwco
don't encode only locally used attrs Part of https://github.com/rust-lang/compiler-team/issues/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 https://github.com/rust-lang/rust/pull/94963#issuecomment-1082924289
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/on_unimplemented.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/mod.rs | 6 |
2 files changed, 4 insertions, 6 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs index c266eec25aa..7d418198195 100644 --- a/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs @@ -175,9 +175,7 @@ impl<'tcx> OnUnimplementedDirective { } pub fn of_item(tcx: TyCtxt<'tcx>, item_def_id: DefId) -> Result<Option<Self>, ErrorGuaranteed> { - let attrs = tcx.get_attrs(item_def_id); - - let Some(attr) = tcx.sess.find_by_name(&attrs, sym::rustc_on_unimplemented) else { + let Some(attr) = tcx.get_attr(item_def_id, sym::rustc_on_unimplemented) else { return Ok(None); }; diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 6584d33032a..3d6bcc93c97 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1156,9 +1156,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { if let ImplCandidate(def_id) = candidate { if let ty::ImplPolarity::Reservation = tcx.impl_polarity(def_id) { if let Some(intercrate_ambiguity_clauses) = &mut self.intercrate_ambiguity_causes { - let attrs = tcx.get_attrs(def_id); - let attr = tcx.sess.find_by_name(&attrs, sym::rustc_reservation_impl); - let value = attr.and_then(|a| a.value_str()); + let value = tcx + .get_attr(def_id, sym::rustc_reservation_impl) + .and_then(|a| a.value_str()); if let Some(value) = value { debug!( "filter_reservation_impls: \ |
