about summary refs log tree commit diff
path: root/src/librustdoc/html
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-05-12 12:48:30 +0000
committerbors <bors@rust-lang.org>2022-05-12 12:48:30 +0000
commit481db40311cdd241ae4d33f34f2f75732e44d8e8 (patch)
tree6c5d0ea5404f19cd916403f46a6ae2105fddd096 /src/librustdoc/html
parent18bd2dd5cda08b09ace6e37c1a0312e9b2bb4beb (diff)
parentebf95836e3cfc8c442cc71239324d947aafa3eac (diff)
downloadrust-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 'src/librustdoc/html')
-rw-r--r--src/librustdoc/html/render/print_item.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index fbb3d3e4584..4951cd83af2 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -323,7 +323,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
 
             clean::ImportItem(ref import) => {
                 let (stab, stab_tags) = if let Some(import_def_id) = import.source.did {
-                    let ast_attrs = cx.tcx().get_attrs(import_def_id);
+                    let ast_attrs = cx.tcx().get_attrs_unchecked(import_def_id);
                     let import_attrs = Box::new(clean::Attributes::from_ast(ast_attrs, None));
 
                     // Just need an item with the correct def_id and attrs