Improve code based on feedback.
This patch improves the readability of some of the code by using if-let-chains. Also, make use of the `add_feature_diagnostics` function.
This commit is contained in:
@@ -662,29 +662,27 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
span,
|
||||
self.allow_gen_future.clone(),
|
||||
);
|
||||
if self.tcx.features().closure_track_caller {
|
||||
let track_caller = self
|
||||
.attrs
|
||||
.get(&outer_hir_id.local_id)
|
||||
.map_or(false, |attrs| attrs.into_iter().any(|attr| attr.has_name(sym::track_caller)));
|
||||
if track_caller {
|
||||
self.lower_attrs(
|
||||
hir_id,
|
||||
&[Attribute {
|
||||
kind: AttrKind::Normal(ptr::P(NormalAttr {
|
||||
item: AttrItem {
|
||||
path: Path::from_ident(Ident::new(sym::track_caller, span)),
|
||||
args: AttrArgs::Empty,
|
||||
tokens: None,
|
||||
},
|
||||
|
||||
if self.tcx.features().closure_track_caller
|
||||
&& let Some(attrs) = self.attrs.get(&outer_hir_id.local_id)
|
||||
&& attrs.into_iter().any(|attr| attr.has_name(sym::track_caller))
|
||||
{
|
||||
self.lower_attrs(
|
||||
hir_id,
|
||||
&[Attribute {
|
||||
kind: AttrKind::Normal(ptr::P(NormalAttr {
|
||||
item: AttrItem {
|
||||
path: Path::from_ident(Ident::new(sym::track_caller, span)),
|
||||
args: AttrArgs::Empty,
|
||||
tokens: None,
|
||||
})),
|
||||
id: self.tcx.sess.parse_sess.attr_id_generator.mk_attr_id(),
|
||||
style: AttrStyle::Outer,
|
||||
span: unstable_span,
|
||||
}],
|
||||
);
|
||||
}
|
||||
},
|
||||
tokens: None,
|
||||
})),
|
||||
id: self.tcx.sess.parse_sess.attr_id_generator.mk_attr_id(),
|
||||
style: AttrStyle::Outer,
|
||||
span: unstable_span,
|
||||
}],
|
||||
);
|
||||
}
|
||||
|
||||
let generator = hir::Expr { hir_id, kind: generator_kind, span: self.lower_span(span) };
|
||||
|
||||
Reference in New Issue
Block a user