diff options
| author | bors <bors@rust-lang.org> | 2022-01-01 02:03:23 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-01-01 02:03:23 +0000 |
| commit | c9cf9c65072a35585f9521ab95044f32d5fcb9ec (patch) | |
| tree | da4d7b058007b67b96335ce0a9720758f99b45a8 /compiler/rustc_interface/src | |
| parent | 4d2e0fd96ccbb9ade41f1a3f07b14b7437f8e4ef (diff) | |
| parent | 047275a68266033b2d7646e5380d8491ec550677 (diff) | |
| download | rust-c9cf9c65072a35585f9521ab95044f32d5fcb9ec.tar.gz rust-c9cf9c65072a35585f9521ab95044f32d5fcb9ec.zip | |
Auto merge of #92294 - Kobzol:rustdoc-meta-kind, r=GuillaumeGomez
Add Attribute::meta_kind The `AttrItem::meta` function is being called on a lot of places, however almost always the caller is only interested in the `kind` of the result `MetaItem`. Before, the `path` had to be cloned in order to get the kind, now it does not have to be. There is a larger related "problem". In a lot of places, something wants to know contents of attributes. This is accessed through `Attribute::meta_item_list`, which calls `AttrItem::meta` (now `AttrItem::meta_kind`), among other methods. When this function is called, the meta item list has to be recreated from scratch. Everytime something asks a simple question (like is this item/list of attributes `#[doc(hidden)]`?), the tokens of the attribute(s) are cloned, parsed and the results are allocated on the heap. That seems really unnecessary. What would be the best way to cache this? Turn `meta_item_list` into a query perhaps? Related PR: https://github.com/rust-lang/rust/pull/92227 r? rust-lang/rustdoc
Diffstat (limited to 'compiler/rustc_interface/src')
| -rw-r--r-- | compiler/rustc_interface/src/util.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index b04f91634cc..cb51555f5ca 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -484,7 +484,7 @@ pub(crate) fn check_attr_crate_type( return; } - if let ast::MetaItemKind::NameValue(spanned) = a.meta().unwrap().kind { + if let ast::MetaItemKind::NameValue(spanned) = a.meta_kind().unwrap() { let span = spanned.span; let lev_candidate = find_best_match_for_name( &CRATE_TYPES.iter().map(|(k, _)| *k).collect::<Vec<_>>(), |
