diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2021-05-15 14:56:28 -0700 |
|---|---|---|
| committer | Esteban Kuber <esteban@kuber.com.ar> | 2021-11-24 20:02:09 +0000 |
| commit | 7190bc3097a3f84c9d0e07d149eba4b00e4f8917 (patch) | |
| tree | c3c03074b83b4ca2c87fb6622ad3c7f0fd8ff393 /compiler/rustc_ast | |
| parent | 311fa1f14dd8ffbbe83b229a94b17f7f1ecaf33b (diff) | |
| download | rust-7190bc3097a3f84c9d0e07d149eba4b00e4f8917.tar.gz rust-7190bc3097a3f84c9d0e07d149eba4b00e4f8917.zip | |
Account for incorrect `impl Foo<const N: ty> {}` syntax
Fix #84946
Diffstat (limited to 'compiler/rustc_ast')
| -rw-r--r-- | compiler/rustc_ast/src/ast.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index abfe8360987..55b243a84a9 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -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)] |
