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
This commit is contained in:
Jacob Pratt
2025-07-04 05:47:27 +02:00
committed by GitHub
13 changed files with 31 additions and 23 deletions

View File

@@ -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,
}
}
}