Skip to content

Commit a479836

Browse files
skinnyBatmati865
authored andcommitted
Add lazy normalization tests
1 parent 9df3360 commit a479836

File tree

8 files changed

+204
-0
lines changed

8 files changed

+204
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// check-pass
2+
3+
#![feature(const_generics)]
4+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
5+
6+
trait Foo {}
7+
8+
impl<const N: usize> Foo for [(); N]
9+
where
10+
Self:FooImpl<{N==0}>
11+
{}
12+
13+
trait FooImpl<const IS_ZERO: bool>{}
14+
15+
impl FooImpl<true> for [(); 0] {}
16+
17+
impl<const N:usize> FooImpl<false> for [();N] {}
18+
19+
fn foo(_: impl Foo) {}
20+
21+
fn main() {
22+
foo([]);
23+
foo([()]);
24+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/issue-61935.rs:3:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// check-pass
2+
3+
#![feature(const_generics)]
4+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
5+
6+
trait Baz {
7+
type Quaks;
8+
}
9+
impl Baz for u8 {
10+
type Quaks = [u16; 3];
11+
}
12+
13+
trait Bar {}
14+
impl Bar for [u16; 3] {}
15+
impl Bar for [[u16; 3]; 2] {}
16+
17+
trait Foo
18+
where
19+
[<u8 as Baz>::Quaks; 2]: Bar,
20+
<u8 as Baz>::Quaks: Bar,
21+
{
22+
}
23+
24+
struct FooImpl;
25+
26+
impl Foo for FooImpl {}
27+
28+
fn f(_: impl Foo) {}
29+
30+
fn main() {
31+
f(FooImpl)
32+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/issue-67185-1.rs:3:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#![feature(const_generics)]
2+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
3+
4+
trait Baz {
5+
type Quaks;
6+
}
7+
impl Baz for u8 {
8+
type Quaks = [u16; 3];
9+
}
10+
11+
trait Bar {}
12+
impl Bar for [u16; 4] {}
13+
impl Bar for [[u16; 3]; 3] {}
14+
15+
trait Foo //~ ERROR mismatched types
16+
where
17+
[<u8 as Baz>::Quaks; 2]: Bar,
18+
<u8 as Baz>::Quaks: Bar,
19+
{
20+
}
21+
22+
struct FooImpl;
23+
24+
impl Foo for FooImpl {}
25+
//~^ ERROR mismatched types
26+
//~^^ ERROR mismatched types
27+
28+
fn f(_: impl Foo) {}
29+
//~^ ERROR mismatched types
30+
//~^^ ERROR mismatched types
31+
32+
fn main() {
33+
f(FooImpl)
34+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/issue-67185-2.rs:1:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
9+
error[E0308]: mismatched types
10+
--> $DIR/issue-67185-2.rs:15:1
11+
|
12+
LL | / trait Foo
13+
LL | | where
14+
LL | | [<u8 as Baz>::Quaks; 2]: Bar,
15+
LL | | <u8 as Baz>::Quaks: Bar,
16+
LL | | {
17+
LL | | }
18+
| |_^ expected `3usize`, found `4usize`
19+
|
20+
= note: expected type `3usize`
21+
found type `4usize`
22+
23+
error[E0308]: mismatched types
24+
--> $DIR/issue-67185-2.rs:24:6
25+
|
26+
LL | impl Foo for FooImpl {}
27+
| ^^^ expected `3usize`, found `4usize`
28+
|
29+
= note: expected type `3usize`
30+
found type `4usize`
31+
32+
error[E0308]: mismatched types
33+
--> $DIR/issue-67185-2.rs:24:6
34+
|
35+
LL | impl Foo for FooImpl {}
36+
| ^^^ expected `2usize`, found `3usize`
37+
|
38+
= note: expected type `2usize`
39+
found type `3usize`
40+
41+
error[E0308]: mismatched types
42+
--> $DIR/issue-67185-2.rs:28:1
43+
|
44+
LL | fn f(_: impl Foo) {}
45+
| ^^^^^^^^^^^^^^^^^^^^ expected `2usize`, found `3usize`
46+
|
47+
= note: expected type `2usize`
48+
found type `3usize`
49+
50+
error[E0308]: mismatched types
51+
--> $DIR/issue-67185-2.rs:28:1
52+
|
53+
LL | fn f(_: impl Foo) {}
54+
| ^^^^^^^^^^^^^^^^^^^^ expected `3usize`, found `4usize`
55+
|
56+
= note: expected type `3usize`
57+
found type `4usize`
58+
59+
error: aborting due to 5 previous errors
60+
61+
For more information about this error, try `rustc --explain E0308`.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// check-pass
2+
3+
#![feature(const_generics)]
4+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
5+
6+
struct Const<const N: usize>;
7+
trait Foo<const N: usize> {}
8+
9+
impl<const N: usize> Foo<{N}> for Const<{N}> {}
10+
11+
fn foo_impl(_: impl Foo<3>) {}
12+
13+
fn foo_explicit<T: Foo<3>>(_: T) {}
14+
15+
fn foo_where<T>(_: T) where T: Foo<3> {}
16+
17+
fn main() {
18+
// FIXME this causes a stack overflow in rustc
19+
// foo_impl(Const);
20+
foo_impl(Const::<3>);
21+
22+
// FIXME this causes a stack overflow in rustc
23+
// foo_explicit(Const);
24+
foo_explicit(Const::<3>);
25+
26+
// FIXME this causes a stack overflow in rustc
27+
// foo_where(Const);
28+
foo_where(Const::<3>);
29+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/trait-const-args.rs:3:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+

0 commit comments

Comments
 (0)