Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a1e7f6d

Browse files
authored
Rollup merge of rust-lang#95654 - notriddle:notriddle/issue-95616, r=davidtwco
diagnostics: use correct span for const generics Fixes rust-lang#95616
2 parents 661b0e5 + 6ece80f commit a1e7f6d

32 files changed

+91
-56
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2068,7 +2068,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20682068
hir::GenericParam {
20692069
hir_id,
20702070
name,
2071-
span: self.lower_span(param.ident.span),
2071+
span: self.lower_span(param.span()),
20722072
pure_wrt_drop: self.sess.contains_name(&param.attrs, sym::may_dangle),
20732073
bounds: self.arena.alloc_from_iter(bounds),
20742074
kind,

src/test/ui/associated-types/trait-with-supertraits-needing-sized-self.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ note: required by a bound in `Add`
88
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
99
|
1010
LL | pub trait Add<Rhs = Self> {
11-
| ^^^ required by this bound in `Add`
11+
| ^^^^^^^^^^ required by this bound in `Add`
1212
help: consider further restricting `Self`
1313
|
1414
LL | trait ArithmeticOps: Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + Div<Output=Self> + Sized {}

src/test/ui/async-await/issues/issue-78654.full.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ LL | impl<const H: feature> Foo {
55
| ^^^^^^^ not a type
66

77
error[E0207]: the const parameter `H` is not constrained by the impl trait, self type, or predicates
8-
--> $DIR/issue-78654.rs:9:12
8+
--> $DIR/issue-78654.rs:9:6
99
|
1010
LL | impl<const H: feature> Foo {
11-
| ^ unconstrained const parameter
11+
| ^^^^^^^^^^^^^^^^ unconstrained const parameter
1212
|
1313
= note: expressions using a const parameter must map each value to a distinct output value
1414
= note: proving the result of expressions other than the parameter are unique is not supported

src/test/ui/async-await/issues/issue-78654.min.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ LL | impl<const H: feature> Foo {
55
| ^^^^^^^ not a type
66

77
error[E0207]: the const parameter `H` is not constrained by the impl trait, self type, or predicates
8-
--> $DIR/issue-78654.rs:9:12
8+
--> $DIR/issue-78654.rs:9:6
99
|
1010
LL | impl<const H: feature> Foo {
11-
| ^ unconstrained const parameter
11+
| ^^^^^^^^^^^^^^^^ unconstrained const parameter
1212
|
1313
= note: expressions using a const parameter must map each value to a distinct output value
1414
= note: proving the result of expressions other than the parameter are unique is not supported
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
2-
--> $DIR/default-on-impl.rs:3:12
2+
--> $DIR/default-on-impl.rs:3:6
33
|
44
LL | impl<const N: usize = 1> Foo<N> {}
5-
| ^
5+
| ^^^^^^^^^^^^^^^^^^
66

77
error: aborting due to previous error
88

src/test/ui/const-generics/generic_const_exprs/issue-76595.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: function defined here, with 2 generic parameters: `T`, `P`
1010
--> $DIR/issue-76595.rs:10:4
1111
|
1212
LL | fn test<T, const P: usize>() where Bool<{core::mem::size_of::<T>() > 4}>: True {
13-
| ^^^^ - -
13+
| ^^^^ - --------------
1414
help: add missing generic argument
1515
|
1616
LL | test::<2, P>();

src/test/ui/const-generics/incorrect-number-of-const-args.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: function defined here, with 2 generic parameters: `X`, `Y`
1010
--> $DIR/incorrect-number-of-const-args.rs:1:4
1111
|
1212
LL | fn foo<const X: usize, const Y: usize>() -> usize {
13-
| ^^^ - -
13+
| ^^^ -------------- --------------
1414
help: add missing generic argument
1515
|
1616
LL | foo::<0, Y>();
@@ -28,7 +28,7 @@ note: function defined here, with 2 generic parameters: `X`, `Y`
2828
--> $DIR/incorrect-number-of-const-args.rs:1:4
2929
|
3030
LL | fn foo<const X: usize, const Y: usize>() -> usize {
31-
| ^^^ - -
31+
| ^^^ -------------- --------------
3232

3333
error: aborting due to 2 previous errors
3434

src/test/ui/const-generics/issues/issue-68366.full.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
2-
--> $DIR/issue-68366.rs:11:13
2+
--> $DIR/issue-68366.rs:11:7
33
|
44
LL | impl <const N: usize> Collatz<{Some(N)}> {}
5-
| ^ unconstrained const parameter
5+
| ^^^^^^^^^^^^^^ unconstrained const parameter
66
|
77
= note: expressions using a const parameter must map each value to a distinct output value
88
= note: proving the result of expressions other than the parameter are unique is not supported
99

1010
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
11-
--> $DIR/issue-68366.rs:17:12
11+
--> $DIR/issue-68366.rs:17:6
1212
|
1313
LL | impl<const N: usize> Foo {}
14-
| ^ unconstrained const parameter
14+
| ^^^^^^^^^^^^^^ unconstrained const parameter
1515
|
1616
= note: expressions using a const parameter must map each value to a distinct output value
1717
= note: proving the result of expressions other than the parameter are unique is not supported

src/test/ui/const-generics/issues/issue-68366.min.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ LL | impl <const N: usize> Collatz<{Some(N)}> {}
88
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
99

1010
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
11-
--> $DIR/issue-68366.rs:11:13
11+
--> $DIR/issue-68366.rs:11:7
1212
|
1313
LL | impl <const N: usize> Collatz<{Some(N)}> {}
14-
| ^ unconstrained const parameter
14+
| ^^^^^^^^^^^^^^ unconstrained const parameter
1515
|
1616
= note: expressions using a const parameter must map each value to a distinct output value
1717
= note: proving the result of expressions other than the parameter are unique is not supported
1818

1919
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
20-
--> $DIR/issue-68366.rs:17:12
20+
--> $DIR/issue-68366.rs:17:6
2121
|
2222
LL | impl<const N: usize> Foo {}
23-
| ^ unconstrained const parameter
23+
| ^^^^^^^^^^^^^^ unconstrained const parameter
2424
|
2525
= note: expressions using a const parameter must map each value to a distinct output value
2626
= note: proving the result of expressions other than the parameter are unique is not supported

src/test/ui/const-generics/issues/issue-86820.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
error[E0053]: method `bit` has an incompatible const parameter type for trait
2-
--> $DIR/issue-86820.rs:17:18
2+
--> $DIR/issue-86820.rs:17:12
33
|
44
LL | fn bit<const I : usize>(self) -> bool {
5-
| ^
5+
| ^^^^^^^^^^^^^^^
66
|
77
note: the const parameter `I` has type `usize`, but the declaration in trait `Bits::bit` has type `u8`
8-
--> $DIR/issue-86820.rs:12:18
8+
--> $DIR/issue-86820.rs:12:12
99
|
1010
LL | fn bit<const I : u8>(self) -> bool;
11-
| ^
11+
| ^^^^^^^^^^^^
1212

1313
error: aborting due to previous error
1414

0 commit comments

Comments
 (0)