about summary refs log tree commit diff
path: root/compiler/rustc_ast/src/ast.rs
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-07-04 05:47:27 +0200
committerGitHub <noreply@github.com>2025-07-04 05:47:27 +0200
commit05f5690d81ef8ea55edac774b3646daa1e3e1575 (patch)
tree9f85a7ab5db029d62955b2f71d56929c505697f7 /compiler/rustc_ast/src/ast.rs
parente55514bbbe988f387bcf16b496cc3f1112e4e3e9 (diff)
parent3380bfd1a00fe3f85e8597bfdb9ad4d65df75da9 (diff)
downloadrust-05f5690d81ef8ea55edac774b3646daa1e3e1575.tar.gz
rust-05f5690d81ef8ea55edac774b3646daa1e3e1575.zip
Rollup merge of #143380 - cjgillot:kw_span, r=compiler-errors
Replace kw_span by full span for generic const parameters.

Small simplification extracted from https://github.com/rust-lang/rust/pull/127241
Diffstat (limited to 'compiler/rustc_ast/src/ast.rs')
-rw-r--r--compiler/rustc_ast/src/ast.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs
index ac6daba3901..491a9bbda79 100644
--- a/compiler/rustc_ast/src/ast.rs
+++ b/compiler/rustc_ast/src/ast.rs
@@ -385,8 +385,8 @@ pub enum GenericParamKind {
     },
     Const {
         ty: P<Ty>,
-        /// Span of the `const` keyword.
-        kw_span: Span,
+        /// Span of the whole parameter definition, including default.
+        span: Span,
         /// Optional default value for the const generic param.
         default: Option<AnonConst>,
     },
@@ -410,10 +410,7 @@ impl GenericParam {
                 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),
+            GenericParamKind::Const { span, .. } => *span,
         }
     }
 }