-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip expected_projection if proj_ty is forbidden
- Loading branch information
Showing
3 changed files
with
56 additions
and
1 deletion.
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
19 changes: 19 additions & 0 deletions
19
tests/ui/specialization/skip-expect-proj-if-forbidden-issue-125757.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,19 @@ | ||
#![feature(specialization)] | ||
#![allow(incomplete_features)] | ||
|
||
trait Trait { | ||
type Type; | ||
} | ||
|
||
impl Trait for i32 { | ||
default type Type = i32; | ||
} | ||
|
||
struct Wrapper<const C: <i32 as Trait>::Type> {} | ||
//~^ ERROR `<i32 as Trait>::Type` is forbidden as the type of a const generic parameter | ||
|
||
impl<const C: usize> Wrapper<C> {} | ||
//~^ ERROR the constant `C` is not of type `<i32 as Trait>::Type` | ||
//~^^ ERROR mismatched types | ||
|
||
fn main() {} |
34 changes: 34 additions & 0 deletions
34
tests/ui/specialization/skip-expect-proj-if-forbidden-issue-125757.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,34 @@ | ||
error: `<i32 as Trait>::Type` is forbidden as the type of a const generic parameter | ||
--> $DIR/skip-expect-proj-if-forbidden-issue-125757.rs:12:25 | ||
| | ||
LL | struct Wrapper<const C: <i32 as Trait>::Type> {} | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: the only supported types are integers, `bool` and `char` | ||
|
||
error: the constant `C` is not of type `<i32 as Trait>::Type` | ||
--> $DIR/skip-expect-proj-if-forbidden-issue-125757.rs:15:22 | ||
| | ||
LL | impl<const C: usize> Wrapper<C> {} | ||
| ^^^^^^^^^^ expected associated type, found `usize` | ||
| | ||
note: required by a bound in `Wrapper` | ||
--> $DIR/skip-expect-proj-if-forbidden-issue-125757.rs:12:16 | ||
| | ||
LL | struct Wrapper<const C: <i32 as Trait>::Type> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Wrapper` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/skip-expect-proj-if-forbidden-issue-125757.rs:15:30 | ||
| | ||
LL | impl<const C: usize> Wrapper<C> {} | ||
| ^ expected associated type, found `usize` | ||
| | ||
= note: expected associated type `<i32 as Trait>::Type` | ||
found type `usize` | ||
= help: consider constraining the associated type `<i32 as Trait>::Type` to `usize` | ||
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |