-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/test/ui/const-generics/unused-substs/unused-substs-1.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete | ||
trait Bar<const M: usize> {} | ||
impl<const N: usize> Bar<N> for A<{ 6 + 1 }> {} | ||
|
||
struct A<const N: usize> | ||
where | ||
A<N>: Bar<N>; | ||
|
||
fn main() { | ||
let _ = A; | ||
//~^ ERROR mismatched types | ||
} |
26 changes: 26 additions & 0 deletions
26
src/test/ui/const-generics/unused-substs/unused-substs-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete | ||
|
||
// The goal is is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst. | ||
// | ||
// If we are then able to infer `ty::Infer(TyVar(_#1t) := Ty<ct>` we introduced an | ||
// artificial inference cycle. | ||
struct Foo<const N: usize>; | ||
|
||
trait Bind<T> { | ||
fn bind() -> (T, Self); | ||
} | ||
|
||
// `N` has to be `ConstKind::Unevaluated`. | ||
impl<T> Bind<T> for Foo<{ 6 + 1 }> { | ||
fn bind() -> (T, Self) { | ||
(panic!(), Foo) | ||
} | ||
} | ||
|
||
fn main() { | ||
let (mut t, foo) = Foo::bind(); | ||
// `t` is `ty::Infer(TyVar(_#1t))` | ||
// `foo` contains `ty::Infer(TyVar(_#1t))` in its substs | ||
t = foo; | ||
//~^ ERROR mismatched types | ||
} |
18 changes: 18 additions & 0 deletions
18
src/test/ui/const-generics/unused-substs/unused-substs-2.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/unused-substs-2.rs:1:12 | ||
| | ||
LL | #![feature(const_generics)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/unused-substs-2.rs:24:9 | ||
| | ||
LL | t = foo; | ||
| ^^^ cyclic type of infinite size | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
18 changes: 18 additions & 0 deletions
18
src/test/ui/const-generics/unused-substs/unused-substs-3.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete | ||
|
||
// The goal is is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst. | ||
// | ||
// If we are then able to infer `ty::Infer(TyVar(_#1t) := Ty<ct>` we introduced an | ||
// artificial inference cycle. | ||
fn bind<T>() -> (T, [u8; 6 + 1]) { | ||
todo!() | ||
} | ||
|
||
fn main() { | ||
let (mut t, foo) = bind(); | ||
// `t` is `ty::Infer(TyVar(_#1t))` | ||
// `foo` contains `ty::Infer(TyVar(_#1t))` in its substs | ||
t = foo; | ||
//~^ ERROR mismatched types | ||
} |
21 changes: 21 additions & 0 deletions
21
src/test/ui/const-generics/unused-substs/unused-substs-3.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/unused-substs-3.rs:2:12 | ||
| | ||
LL | #![feature(const_generics)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/unused-substs-3.rs:16:9 | ||
| | ||
LL | t = foo; | ||
| ^^^ | ||
| | | ||
| cyclic type of infinite size | ||
| help: try using a conversion method: `foo.to_vec()` | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0308`. |