mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
Extract lower_generic_param_kind
This commit is contained in:
parent
a22aad32eb
commit
1e6ed67d37
@ -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, ¶m.attrs);
|
||||
hir::GenericParam {
|
||||
hir_id,
|
||||
name,
|
||||
span: self.lower_span(param.span()),
|
||||
pure_wrt_drop: self.sess.contains_name(¶m.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, ¶m.attrs);
|
||||
hir::GenericParam {
|
||||
hir_id,
|
||||
name,
|
||||
span: self.lower_span(param.span()),
|
||||
pure_wrt_drop: self.sess.contains_name(¶m.attrs, sym::may_dangle),
|
||||
kind,
|
||||
colon_span: param.colon_span.map(|s| self.lower_span(s)),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user