forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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 rust-lang#125451 - oli-obk:const_type_mismatch, r=com…
…piler-errors Fail relating constants of different types fixes rust-lang#121585 fixes rust-lang#121858 fixes rust-lang#124151 I gave this several attempts before, but we lost too many important diagnostics until I managed to make compilation never bail out early. We have reached this point, so now we can finally fix all those ICEs by bubbling up an error instead of continueing when we encounter a bug.
- Loading branch information
Showing
21 changed files
with
129 additions
and
180 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
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
tests/ui/coherence/negative-coherence/generic_const_type_mismatch.rs
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,12 @@ | ||
//! This test used to ICE (#119381), because relating the `u8` and `i8` generic | ||
//! const with the array length of the `Self` type was succeeding under the | ||
//! assumption that an error had already been reported. | ||
#![feature(with_negative_coherence)] | ||
trait Trait {} | ||
impl<const N: u8> Trait for [(); N] {} | ||
//~^ ERROR: mismatched types | ||
impl<const N: i8> Trait for [(); N] {} | ||
//~^ ERROR: mismatched types | ||
|
||
fn main() {} |
15 changes: 15 additions & 0 deletions
15
tests/ui/coherence/negative-coherence/generic_const_type_mismatch.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,15 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/generic_const_type_mismatch.rs:7:34 | ||
| | ||
LL | impl<const N: u8> Trait for [(); N] {} | ||
| ^ expected `usize`, found `u8` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/generic_const_type_mismatch.rs:9:34 | ||
| | ||
LL | impl<const N: i8> Trait for [(); N] {} | ||
| ^ expected `usize`, found `i8` | ||
|
||
error: aborting due to 2 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
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
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
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
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
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,8 @@ | ||
error: internal compiler error: compiler/rustc_borrowck/src/universal_regions.rs:LL:CC: cannot convert `'{erased}` to a region vid | ||
|
||
query stack during panic: | ||
#0 [mir_borrowck] borrow-checking `<impl at $DIR/issue-105821.rs:21:1: 23:24>::R` | ||
#1 [analysis] running analysis passes on this crate | ||
end of query stack | ||
error: aborting due to 1 previous error | ||
|
7 changes: 5 additions & 2 deletions
7
tests/crashes/121858.rs → tests/ui/consts/eval_type_mismatch.rs
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 |
---|---|---|
@@ -1,14 +1,17 @@ | ||
//@ known-bug: #121858 | ||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
struct Outer<const A: i64, const B: usize>(); | ||
impl<const A: usize, const B: usize> Outer<A, B> | ||
//~^ ERROR: `A` is not of type `i64` | ||
//~| ERROR: mismatched types | ||
where | ||
[(); A + (B * 2)]:, | ||
{ | ||
fn o() -> Union {} | ||
fn o() {} | ||
} | ||
|
||
fn main() { | ||
Outer::<1, 1>::o(); | ||
//~^ ERROR: no function or associated item named `o` found | ||
} |
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,34 @@ | ||
error: the constant `A` is not of type `i64` | ||
--> $DIR/eval_type_mismatch.rs:5:38 | ||
| | ||
LL | impl<const A: usize, const B: usize> Outer<A, B> | ||
| ^^^^^^^^^^^ expected `i64`, found `usize` | ||
| | ||
note: required by a bound in `Outer` | ||
--> $DIR/eval_type_mismatch.rs:4:14 | ||
| | ||
LL | struct Outer<const A: i64, const B: usize>(); | ||
| ^^^^^^^^^^^^ required by this bound in `Outer` | ||
|
||
error[E0599]: no function or associated item named `o` found for struct `Outer<1, 1>` in the current scope | ||
--> $DIR/eval_type_mismatch.rs:15:20 | ||
| | ||
LL | struct Outer<const A: i64, const B: usize>(); | ||
| ------------------------------------------ function or associated item `o` not found for this struct | ||
... | ||
LL | Outer::<1, 1>::o(); | ||
| ^ function or associated item not found in `Outer<1, 1>` | ||
| | ||
= note: the function or associated item was found for | ||
- `Outer<A, B>` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/eval_type_mismatch.rs:5:44 | ||
| | ||
LL | impl<const A: usize, const B: usize> Outer<A, B> | ||
| ^ expected `i64`, found `usize` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0308, E0599. | ||
For more information about an 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
Oops, something went wrong.