Extract lower_generic_param_kind

This commit is contained in:
Santiago Pastorino 2022-05-20 17:32:48 -03:00
parent a22aad32eb
commit 1e6ed67d37
No known key found for this signature in database
GPG Key ID: 8131A24E0C79EFAF

View File

@ -1874,7 +1874,25 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
#[instrument(level = "trace", skip(self))]
fn lower_generic_param(&mut self, param: &GenericParam) -> hir::GenericParam<'hir> {
let (name, kind) = match param.kind {
let (name, kind) = self.lower_generic_param_kind(param);
let hir_id = self.lower_node_id(param.id);
self.lower_attrs(hir_id, &param.attrs);
hir::GenericParam {
hir_id,
name,
span: self.lower_span(param.span()),
pure_wrt_drop: self.sess.contains_name(&param.attrs, sym::may_dangle),
kind,
colon_span: param.colon_span.map(|s| self.lower_span(s)),
}
}
fn lower_generic_param_kind(
&mut self,
param: &GenericParam,
) -> (hir::ParamName, hir::GenericParamKind<'hir>) {
match param.kind {
GenericParamKind::Lifetime => {
// AST resolution emitted an error on those parameters, so we lower them using
// `ParamName::Error`.
@ -1908,17 +1926,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
hir::GenericParamKind::Const { ty, default },
)
}
};
let hir_id = self.lower_node_id(param.id);
self.lower_attrs(hir_id, &param.attrs);
hir::GenericParam {
hir_id,
name,
span: self.lower_span(param.span()),
pure_wrt_drop: self.sess.contains_name(&param.attrs, sym::may_dangle),
kind,
colon_span: param.colon_span.map(|s| self.lower_span(s)),
}
}