Skip to content

Commit 7dac626

Browse files
committedJan 17, 2022
add and update tests
1 parent 4c27d34 commit 7dac626

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// check-pass
2+
3+
#![feature(generic_const_exprs)]
4+
#![allow(incomplete_features)]
5+
6+
pub struct Foo<const N: usize>;
7+
pub trait Bar<T> {}
8+
9+
impl<T> Bar<T> for Foo<{ 1 }> {}
10+
impl<T> Bar<T> for Foo<{ 2 }> {}
11+
12+
fn main() {}

‎src/test/ui/const-generics/types-mismatch-const-args.full.stderr

+14-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,20 @@ LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data
1515
| |
1616
| expected due to this
1717
|
18-
= note: expected struct `A<'a, u16, {2u32}, {3u32}>`
19-
found struct `A<'b, u32, {2u32}, {3u32}>`
18+
= note: expected struct `A<'a, u16, _, _>`
19+
found struct `A<'b, u32, _, _>`
2020

21-
error: aborting due to 2 previous errors
21+
error[E0308]: mismatched types
22+
--> $DIR/types-mismatch-const-args.rs:18:41
23+
|
24+
LL | let _: A<'a, u16, {4u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
25+
| -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32`
26+
| |
27+
| expected due to this
28+
|
29+
= note: expected struct `A<'a, u16, 4_u32, _>`
30+
found struct `A<'b, u32, 2_u32, _>`
31+
32+
error: aborting due to 3 previous errors
2233

2334
For more information about this error, try `rustc --explain E0308`.

‎src/test/ui/const-generics/types-mismatch-const-args.min.stderr

+12-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data
2020
= note: expected struct `A<'a, u16, _, _>`
2121
found struct `A<'b, u32, _, _>`
2222

23-
error: aborting due to 2 previous errors
23+
error[E0308]: mismatched types
24+
--> $DIR/types-mismatch-const-args.rs:18:41
25+
|
26+
LL | let _: A<'a, u16, {4u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
27+
| -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32`
28+
| |
29+
| expected due to this
30+
|
31+
= note: expected struct `A<'a, u16, 4_u32, _>`
32+
found struct `A<'b, u32, 2_u32, _>`
33+
34+
error: aborting due to 3 previous errors
2435

2536
For more information about this error, try `rustc --explain E0308`.

‎src/test/ui/const-generics/types-mismatch-const-args.rs

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ fn a<'a, 'b>() {
1515
//~^ ERROR mismatched types
1616
let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
1717
//~^ ERROR mismatched types
18+
let _: A<'a, u16, {4u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
19+
//~^ ERROR mismatched types
1820
}
1921

2022
pub fn main() {}

0 commit comments

Comments
 (0)