-
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.
- Loading branch information
1 parent
7116bb5
commit 33370fd
Showing
3 changed files
with
85 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#![feature(const_generics)] | ||
#![feature(const_generics_defaults)] | ||
#![allow(incomplete_features)] | ||
|
||
pub struct Example<const N: usize=13>; | ||
pub struct Example2<T=u32, const N: usize=13>(T); | ||
pub struct Example3<const N: usize=13, T=u32>(T); | ||
pub struct Example4<const N: usize=13, const M: usize=4>; | ||
|
||
fn main() { | ||
let e: Example::<13> = (); | ||
//~^ Error: mismatched types | ||
let e: Example2::<u32, 13> = (); | ||
//~^ Error: mismatched types | ||
let e: Example3::<13, u32> = (); | ||
//~^ Error: mismatched types | ||
let e: Example3::<7> = (); | ||
//~^ Error: mismatched types | ||
// FIXME(const_generics_defaults): There should be a note for the error below, but it is | ||
// missing. | ||
let e: Example4::<7> = (); | ||
//~^ Error: mismatched types | ||
} |
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,52 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/mismatch.rs:11:26 | ||
| | ||
LL | let e: Example::<13> = (); | ||
| ------------- ^^ expected struct `Example`, found `()` | ||
| | | ||
| expected due to this | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/mismatch.rs:13:32 | ||
| | ||
LL | let e: Example2::<u32, 13> = (); | ||
| ------------------- ^^ expected struct `Example2`, found `()` | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected struct `Example2` | ||
found unit type `()` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/mismatch.rs:15:32 | ||
| | ||
LL | let e: Example3::<13, u32> = (); | ||
| ------------------- ^^ expected struct `Example3`, found `()` | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected struct `Example3` | ||
found unit type `()` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/mismatch.rs:17:26 | ||
| | ||
LL | let e: Example3::<7> = (); | ||
| ------------- ^^ expected struct `Example3`, found `()` | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected struct `Example3<7_usize>` | ||
found unit type `()` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/mismatch.rs:21:26 | ||
| | ||
LL | let e: Example4::<7> = (); | ||
| ------------- ^^ expected struct `Example4`, found `()` | ||
| | | ||
| expected due to this | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |