-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail relating constants of different types
- Loading branch information
Showing
13 changed files
with
84 additions
and
119 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 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 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
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
36 changes: 27 additions & 9 deletions
36
tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.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 |
---|---|---|
@@ -1,19 +1,37 @@ | ||
error[E0119]: conflicting implementations of trait `Copy` for type `S<_>` | ||
--> $DIR/bad-const-wf-doesnt-specialize.rs:10:1 | ||
error[E0277]: the trait bound `S<N>: Clone` is not satisfied | ||
--> $DIR/bad-const-wf-doesnt-specialize.rs:8:29 | ||
| | ||
LL | impl<const N: i32> Copy for S<N> {} | ||
| -------------------------------- first implementation here | ||
LL | | ||
LL | impl<const M: usize> Copy for S<M> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `S<_>` | ||
| ^^^^ the trait `Clone` is not implemented for `S<N>` | ||
| | ||
= help: the trait `Clone` is implemented for `S<L>` | ||
note: required by a bound in `Copy` | ||
--> $SRC_DIR/core/src/marker.rs:LL:COL | ||
help: consider annotating `S<N>` with `#[derive(Clone)]` | ||
| | ||
LL + #[derive(Clone)] | ||
LL | struct S<const L: usize>; | ||
| | ||
|
||
error: the constant `N` is not of type `usize` | ||
--> $DIR/bad-const-wf-doesnt-specialize.rs:8:29 | ||
| | ||
LL | impl<const N: i32> Copy for S<N> {} | ||
| ^^^^ expected `usize`, found `i32` | ||
| | ||
note: required by a bound in `S` | ||
--> $DIR/bad-const-wf-doesnt-specialize.rs:6:10 | ||
| | ||
LL | struct S<const L: usize>; | ||
| ^^^^^^^^^^^^^^ required by this bound in `S` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/bad-const-wf-doesnt-specialize.rs:8:31 | ||
| | ||
LL | impl<const N: i32> Copy for S<N> {} | ||
| ^ expected `usize`, found `i32` | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0119, E0308. | ||
For more information about an error, try `rustc --explain E0119`. | ||
Some errors have detailed explanations: E0277, E0308. | ||
For more information about an error, try `rustc --explain E0277`. |