diff options
| author | bors <bors@rust-lang.org> | 2025-07-04 04:21:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-07-04 04:21:14 +0000 |
| commit | c96a69059ecc618b519da385a6ccd03155aa0237 (patch) | |
| tree | 8a658b79c06f3b54d15b22c22fa7b30edd889557 /compiler/rustc_parse/src | |
| parent | 837c5dd7de03aa97190593aef4e70d53e1bb574b (diff) | |
| parent | e4e26d2acb13f42badb6e4953c7d72a001e3aed7 (diff) | |
| download | rust-c96a69059ecc618b519da385a6ccd03155aa0237.tar.gz rust-c96a69059ecc618b519da385a6ccd03155aa0237.zip | |
Auto merge of #143407 - jhpratt:rollup-ekkoubw, r=jhpratt
Rollup of 11 pull requests
Successful merges:
- rust-lang/rust#142749 (Add methods for converting bool to `Result<(), E>`)
- rust-lang/rust#143288 (Fix `x clean` with a fifo)
- rust-lang/rust#143307 (Fast path nitpicks)
- rust-lang/rust#143346 (update coherence example)
- rust-lang/rust#143356 (use unsigned_abs instead of `abs` on signed int to silence clippy)
- rust-lang/rust#143370 (remove redundant #[must_use])
- rust-lang/rust#143378 (simplify receivers for some array method calls)
- rust-lang/rust#143380 (Replace kw_span by full span for generic const parameters.)
- rust-lang/rust#143381 (rustdoc: don't treat methods under const impls or traits as const)
- rust-lang/rust#143394 (compiler: Document and reduce `fn provide`s in hir crates)
- rust-lang/rust#143395 (Always use the pure Rust fallback instead of `llvm.{maximum,minimum}`)
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/generics.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/generics.rs b/compiler/rustc_parse/src/parser/generics.rs index af1d1a1ec66..86326341a75 100644 --- a/compiler/rustc_parse/src/parser/generics.rs +++ b/compiler/rustc_parse/src/parser/generics.rs @@ -114,13 +114,18 @@ impl<'a> Parser<'a> { // Parse optional const generics default value. let default = if self.eat(exp!(Eq)) { Some(self.parse_const_arg()?) } else { None }; + let span = if let Some(ref default) = default { + const_span.to(default.value.span) + } else { + const_span.to(ty.span) + }; Ok(GenericParam { ident, id: ast::DUMMY_NODE_ID, attrs: preceding_attrs, bounds: Vec::new(), - kind: GenericParamKind::Const { ty, kw_span: const_span, default }, + kind: GenericParamKind::Const { ty, span, default }, is_placeholder: false, colon_span: None, }) @@ -137,6 +142,11 @@ impl<'a> Parser<'a> { // Parse optional const generics default value. let default = if self.eat(exp!(Eq)) { Some(self.parse_const_arg()?) } else { None }; + let span = if let Some(ref default) = default { + mistyped_const_ident.span.to(default.value.span) + } else { + mistyped_const_ident.span.to(ty.span) + }; self.dcx() .struct_span_err( @@ -156,7 +166,7 @@ impl<'a> Parser<'a> { id: ast::DUMMY_NODE_ID, attrs: preceding_attrs, bounds: Vec::new(), - kind: GenericParamKind::Const { ty, kw_span: mistyped_const_ident.span, default }, + kind: GenericParamKind::Const { ty, span, default }, is_placeholder: false, colon_span: None, }) |
