Skip to content

Commit 831c0df

Browse files
committed
add more tests
1 parent a560a95 commit 831c0df

File tree

5 files changed

+95
-0
lines changed

5 files changed

+95
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete
2+
trait Bar<const M: usize> {}
3+
impl<const N: usize> Bar<N> for A<{ 6 + 1 }> {}
4+
5+
struct A<const N: usize>
6+
where
7+
A<N>: Bar<N>;
8+
9+
fn main() {
10+
let _ = A;
11+
//~^ ERROR mismatched types
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete
2+
3+
// The goal is is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst.
4+
//
5+
// If we are then able to infer `ty::Infer(TyVar(_#1t) := Ty<ct>` we introduced an
6+
// artificial inference cycle.
7+
struct Foo<const N: usize>;
8+
9+
trait Bind<T> {
10+
fn bind() -> (T, Self);
11+
}
12+
13+
// `N` has to be `ConstKind::Unevaluated`.
14+
impl<T> Bind<T> for Foo<{ 6 + 1 }> {
15+
fn bind() -> (T, Self) {
16+
(panic!(), Foo)
17+
}
18+
}
19+
20+
fn main() {
21+
let (mut t, foo) = Foo::bind();
22+
// `t` is `ty::Infer(TyVar(_#1t))`
23+
// `foo` contains `ty::Infer(TyVar(_#1t))` in its substs
24+
t = foo;
25+
//~^ ERROR mismatched types
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/unused-substs-2.rs:1:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
9+
10+
error[E0308]: mismatched types
11+
--> $DIR/unused-substs-2.rs:24:9
12+
|
13+
LL | t = foo;
14+
| ^^^ cyclic type of infinite size
15+
16+
error: aborting due to previous error; 1 warning emitted
17+
18+
For more information about this error, try `rustc --explain E0308`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete
3+
4+
// The goal is is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst.
5+
//
6+
// If we are then able to infer `ty::Infer(TyVar(_#1t) := Ty<ct>` we introduced an
7+
// artificial inference cycle.
8+
fn bind<T>() -> (T, [u8; 6 + 1]) {
9+
todo!()
10+
}
11+
12+
fn main() {
13+
let (mut t, foo) = bind();
14+
// `t` is `ty::Infer(TyVar(_#1t))`
15+
// `foo` contains `ty::Infer(TyVar(_#1t))` in its substs
16+
t = foo;
17+
//~^ ERROR mismatched types
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/unused-substs-3.rs:2:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
9+
10+
error[E0308]: mismatched types
11+
--> $DIR/unused-substs-3.rs:16:9
12+
|
13+
LL | t = foo;
14+
| ^^^
15+
| |
16+
| cyclic type of infinite size
17+
| help: try using a conversion method: `foo.to_vec()`
18+
19+
error: aborting due to previous error; 1 warning emitted
20+
21+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)