-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #135380 - compiler-errors:mismatch-valtree, r=lcnr
Make sure we can produce `ConstArgHasWrongType` errors for valtree consts I forgot about `ty::ConstKind::Value` in #134771. The error message here could use some work -- both in the new trait solver and the old trait solver. But unrelated to the issue here. Fixes #135361 -- this was only ICEing in coherence because coherence uses the new trait solver, but I don't think the minimization is worth committing compared to the test I added. r? ```@lcnr``` or ```@BoxyUwU```
- Loading branch information
Showing
4 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
tests/ui/const-generics/type-mismatch-in-nested-goal.current.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
error: the constant `N` is not of type `bool` | ||
--> $DIR/type-mismatch-in-nested-goal.rs:9:50 | ||
| | ||
LL | fn needs_a<const N: usize>(_: [u8; N]) where (): A<N> {} | ||
| ^^^^ expected `bool`, found `usize` | ||
| | ||
note: required by a const generic parameter in `A` | ||
--> $DIR/type-mismatch-in-nested-goal.rs:5:9 | ||
| | ||
LL | trait A<const B: bool> {} | ||
| ^^^^^^^^^^^^^ required by this const generic parameter in `A` | ||
|
||
error: the constant `true` is not of type `usize` | ||
--> $DIR/type-mismatch-in-nested-goal.rs:13:13 | ||
| | ||
LL | needs_a([]); | ||
| ------- ^^ expected `usize`, found `bool` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
note: required by a const generic parameter in `needs_a` | ||
--> $DIR/type-mismatch-in-nested-goal.rs:9:12 | ||
| | ||
LL | fn needs_a<const N: usize>(_: [u8; N]) where (): A<N> {} | ||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `needs_a` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/type-mismatch-in-nested-goal.rs:13:13 | ||
| | ||
LL | needs_a([]); | ||
| ------- ^^ expected an array with a size of true, found one with a size of 0 | ||
| | | ||
| arguments to this function are incorrect | ||
| | ||
= note: expected array `[u8; true]` | ||
found array `[_; 0]` | ||
note: function defined here | ||
--> $DIR/type-mismatch-in-nested-goal.rs:9:4 | ||
| | ||
LL | fn needs_a<const N: usize>(_: [u8; N]) where (): A<N> {} | ||
| ^^^^^^^ ---------- | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
45 changes: 45 additions & 0 deletions
45
tests/ui/const-generics/type-mismatch-in-nested-goal.next.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
error: the constant `N` is not of type `bool` | ||
--> $DIR/type-mismatch-in-nested-goal.rs:9:50 | ||
| | ||
LL | fn needs_a<const N: usize>(_: [u8; N]) where (): A<N> {} | ||
| ^^^^ expected `bool`, found `usize` | ||
| | ||
note: required by a const generic parameter in `A` | ||
--> $DIR/type-mismatch-in-nested-goal.rs:5:9 | ||
| | ||
LL | trait A<const B: bool> {} | ||
| ^^^^^^^^^^^^^ required by this const generic parameter in `A` | ||
|
||
error: the constant `true` is not of type `usize` | ||
--> $DIR/type-mismatch-in-nested-goal.rs:13:13 | ||
| | ||
LL | needs_a([]); | ||
| ------- ^^ expected `usize`, found `bool` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
note: required by a const generic parameter in `needs_a` | ||
--> $DIR/type-mismatch-in-nested-goal.rs:9:12 | ||
| | ||
LL | fn needs_a<const N: usize>(_: [u8; N]) where (): A<N> {} | ||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `needs_a` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/type-mismatch-in-nested-goal.rs:13:13 | ||
| | ||
LL | needs_a([]); | ||
| ------- ^^ expected an array with a size of true, found one with a size of 0 | ||
| | | ||
| arguments to this function are incorrect | ||
| | ||
= note: expected array `[u8; true]` | ||
found array `[_; 0]` | ||
note: function defined here | ||
--> $DIR/type-mismatch-in-nested-goal.rs:9:4 | ||
| | ||
LL | fn needs_a<const N: usize>(_: [u8; N]) where (): A<N> {} | ||
| ^^^^^^^ ---------- | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//@ revisions: current next | ||
//@[next] compile-flags: -Znext-solver | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
|
||
trait A<const B: bool> {} | ||
|
||
impl A<true> for () {} | ||
|
||
fn needs_a<const N: usize>(_: [u8; N]) where (): A<N> {} | ||
//~^ ERROR the constant `N` is not of type `bool` | ||
|
||
pub fn main() { | ||
needs_a([]); | ||
//~^ ERROR the constant `true` is not of type `usize` | ||
//~| ERROR mismatched types | ||
// FIXME(const_generics): we should hide this error as we've already errored above | ||
} |