1
Fork 0

Account for incorrect impl Foo<const N: ty> {} syntax

Fix #84946
This commit is contained in:
Esteban Küber 2021-05-15 14:56:28 -07:00 committed by Esteban Kuber
parent 311fa1f14d
commit 7190bc3097
9 changed files with 206 additions and 54 deletions

View file

@ -405,6 +405,21 @@ pub struct GenericParam {
pub kind: GenericParamKind,
}
impl GenericParam {
pub fn span(&self) -> Span {
match &self.kind {
GenericParamKind::Lifetime | GenericParamKind::Type { default: None } => {
self.ident.span
}
GenericParamKind::Type { default: Some(ty) } => self.ident.span.to(ty.span),
GenericParamKind::Const { kw_span, default: Some(default), .. } => {
kw_span.to(default.value.span)
}
GenericParamKind::Const { kw_span, default: None, ty } => kw_span.to(ty.span),
}
}
}
/// Represents lifetime, type and const parameters attached to a declaration of
/// a function, enum, trait, etc.
#[derive(Clone, Encodable, Decodable, Debug)]