]> git.lizzy.rs Git - rust.git/blob - tests/ui/const-generics/types-mismatch-const-args.rs
Rollup merge of #106979 - Nilstrieb:type-of-default-assoc-type, r=petrochenkov
[rust.git] / tests / ui / const-generics / types-mismatch-const-args.rs
1 // revisions: full min
2 #![cfg_attr(full, feature(generic_const_exprs))]
3 #![cfg_attr(full, allow(incomplete_features))]
4
5 // tests the diagnostic output of type mismatches for types that have const generics arguments.
6
7 use std::marker::PhantomData;
8
9 struct A<'a, T, const X: u32, const Y: u32> {
10     data: PhantomData<&'a T>
11 }
12
13 fn a<'a, 'b>() {
14     let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {2u32 + 2u32}, {3u32}> { data: PhantomData };
15     //~^ ERROR mismatched types
16     let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
17     //~^ ERROR mismatched types
18     let _: A<'a, u16, {4u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
19     //~^ ERROR mismatched types
20 }
21
22 pub fn main() {}