rust/tests/ui/const-generics/defaults/mismatch.rs

23 lines
733 B
Rust
Raw Normal View History

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>;
2021-03-22 18:26:07 -05:00
fn main() {
let e: Example<13> = ();
2021-03-29 03:32:27 -05:00
//~^ Error: mismatched types
2021-06-07 04:09:47 -05:00
//~| expected struct `Example`
let e: Example2<u32, 13> = ();
2021-03-29 03:32:27 -05:00
//~^ Error: mismatched types
2021-06-07 04:09:47 -05:00
//~| expected struct `Example2`
let e: Example3<13, u32> = ();
2021-03-29 03:32:27 -05:00
//~^ Error: mismatched types
2021-06-07 04:09:47 -05:00
//~| expected struct `Example3`
let e: Example3<7> = ();
2021-03-29 03:32:27 -05:00
//~^ Error: mismatched types
//~| expected struct `Example3<7>`
let e: Example4<7> = ();
2021-03-29 03:32:27 -05:00
//~^ Error: mismatched types
//~| expected struct `Example4<7>`
2021-03-22 18:26:07 -05:00
}