Skip to content

Commit a11414d

Browse files
authored
Rollup merge of #92161 - petrochenkov:misclean, r=cjgillot
resolve: Minor miscellaneous cleanups from #89059 `@bors` rollup=always
2 parents a7c79c0 + 1324100 commit a11414d

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
@@ -415,16 +415,12 @@ impl CStore {
415415

416416
let span = data.get_span(id.index, sess);
417417

418-
let attrs = data.get_item_attrs(id.index, sess).collect();
419-
420-
let ident = data.item_ident(id.index, sess);
421-
422418
LoadedMacro::MacroDef(
423419
ast::Item {
424-
ident,
420+
ident: data.item_ident(id.index, sess),
425421
id: ast::DUMMY_NODE_ID,
426422
span,
427-
attrs,
423+
attrs: data.get_item_attrs(id.index, sess).collect(),
428424
kind: ast::ItemKind::MacroDef(data.get_macro(id.index, sess)),
429425
vis: ast::Visibility {
430426
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)