Skip to content

Commit 1324100

Browse files
committed
resolve: Minor miscellaneous cleanups from #89059
1 parent 3d57c61 commit 1324100

File tree

2 files changed

+16
-26
lines changed

2 files changed

+16
-26
lines changed

Diff for: compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -417,16 +417,12 @@ impl CStore {
417417

418418
let span = data.get_span(id.index, sess);
419419

420-
let attrs = data.get_item_attrs(id.index, sess).collect();
421-
422-
let ident = data.item_ident(id.index, sess);
423-
424420
LoadedMacro::MacroDef(
425421
ast::Item {
426-
ident,
422+
ident: data.item_ident(id.index, sess),
427423
id: ast::DUMMY_NODE_ID,
428424
span,
429-
attrs,
425+
attrs: data.get_item_attrs(id.index, sess).collect(),
430426
kind: ast::ItemKind::MacroDef(data.get_macro(id.index, sess)),
431427
vis: ast::Visibility {
432428
span: span.shrink_to_lo(),

Diff for: compiler/rustc_resolve/src/lib.rs

+14-20
Original file line numberDiff line numberDiff line change
@@ -3419,27 +3419,21 @@ impl<'a> Resolver<'a> {
34193419
return v.clone();
34203420
}
34213421

3422-
let parse_attrs = || {
3423-
let attrs = self.cstore().item_attrs(def_id, self.session);
3424-
let attr =
3425-
attrs.iter().find(|a| a.has_name(sym::rustc_legacy_const_generics))?;
3426-
let mut ret = vec![];
3427-
for meta in attr.meta_item_list()? {
3428-
match meta.literal()?.kind {
3429-
LitKind::Int(a, _) => {
3430-
ret.push(a as usize);
3431-
}
3432-
_ => panic!("invalid arg index"),
3433-
}
3422+
let attr = self
3423+
.cstore()
3424+
.item_attrs(def_id, self.session)
3425+
.into_iter()
3426+
.find(|a| a.has_name(sym::rustc_legacy_const_generics))?;
3427+
let mut ret = Vec::new();
3428+
for meta in attr.meta_item_list()? {
3429+
match meta.literal()?.kind {
3430+
LitKind::Int(a, _) => ret.push(a as usize),
3431+
_ => panic!("invalid arg index"),
34343432
}
3435-
Some(ret)
3436-
};
3437-
3438-
// Cache the lookup to avoid parsing attributes for an iterm
3439-
// multiple times.
3440-
let ret = parse_attrs();
3441-
self.legacy_const_generic_args.insert(def_id, ret.clone());
3442-
return ret;
3433+
}
3434+
// Cache the lookup to avoid parsing attributes for an iterm multiple times.
3435+
self.legacy_const_generic_args.insert(def_id, Some(ret.clone()));
3436+
return Some(ret);
34433437
}
34443438
}
34453439
None

0 commit comments

Comments
 (0)