diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-12-27 21:42:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-27 21:42:27 +0100 |
| commit | a11414d62ec472f1c1cd8a5cd6e21f056fb1af0c (patch) | |
| tree | d24915201418f6181129231f94c117768d3279df | |
| parent | a7c79c08d6dea48c853f58fb2386ca4ce92054d3 (diff) | |
| parent | 13241008005f2471b3e4bae464ff81b2c2e2258f (diff) | |
| download | rust-a11414d62ec472f1c1cd8a5cd6e21f056fb1af0c.tar.gz rust-a11414d62ec472f1c1cd8a5cd6e21f056fb1af0c.zip | |
Rollup merge of #92161 - petrochenkov:misclean, r=cjgillot
resolve: Minor miscellaneous cleanups from #89059 `@bors` rollup=always
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/lib.rs | 34 |
2 files changed, 16 insertions, 26 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 72a04e7042a..b46a92e2c1b 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -415,16 +415,12 @@ impl CStore { let span = data.get_span(id.index, sess); - let attrs = data.get_item_attrs(id.index, sess).collect(); - - let ident = data.item_ident(id.index, sess); - LoadedMacro::MacroDef( ast::Item { - ident, + ident: data.item_ident(id.index, sess), id: ast::DUMMY_NODE_ID, span, - attrs, + attrs: data.get_item_attrs(id.index, sess).collect(), kind: ast::ItemKind::MacroDef(data.get_macro(id.index, sess)), vis: ast::Visibility { span: span.shrink_to_lo(), diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 84ce492ba72..26344080381 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -3419,27 +3419,21 @@ impl<'a> Resolver<'a> { return v.clone(); } - let parse_attrs = || { - let attrs = self.cstore().item_attrs(def_id, self.session); - let attr = - attrs.iter().find(|a| a.has_name(sym::rustc_legacy_const_generics))?; - let mut ret = vec![]; - for meta in attr.meta_item_list()? { - match meta.literal()?.kind { - LitKind::Int(a, _) => { - ret.push(a as usize); - } - _ => panic!("invalid arg index"), - } + let attr = self + .cstore() + .item_attrs(def_id, self.session) + .into_iter() + .find(|a| a.has_name(sym::rustc_legacy_const_generics))?; + let mut ret = Vec::new(); + for meta in attr.meta_item_list()? { + match meta.literal()?.kind { + LitKind::Int(a, _) => ret.push(a as usize), + _ => panic!("invalid arg index"), } - Some(ret) - }; - - // Cache the lookup to avoid parsing attributes for an iterm - // multiple times. - let ret = parse_attrs(); - self.legacy_const_generic_args.insert(def_id, ret.clone()); - return ret; + } + // Cache the lookup to avoid parsing attributes for an iterm multiple times. + self.legacy_const_generic_args.insert(def_id, Some(ret.clone())); + return Some(ret); } } None |
