Skip to content

Commit 41e4c4e

Browse files
Add tests
1 parent 141723f commit 41e4c4e

20 files changed

+450
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ compile-flags: -Znext-solver
2+
#![feature(const_trait_impl, effects)]
3+
//~^ WARN the feature `effects` is incomplete
4+
5+
#[const_trait] trait Foo {
6+
fn foo();
7+
}
8+
9+
const fn foo<T: ~const Foo>() {
10+
const { T::foo() }
11+
//~^ ERROR the trait bound `T: const Foo` is not satisfied
12+
}
13+
14+
fn main() {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/call-const-in-tilde-const.rs:2:30
3+
|
4+
LL | #![feature(const_trait_impl, effects)]
5+
| ^^^^^^^
6+
|
7+
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error[E0277]: the trait bound `T: const Foo` is not satisfied
11+
--> $DIR/call-const-in-tilde-const.rs:10:13
12+
|
13+
LL | const { T::foo() }
14+
| ^^^^^^^^
15+
16+
error: aborting due to 1 previous error; 1 warning emitted
17+
18+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ compile-flags: -Znext-solver
2+
//@ check-pass
3+
4+
#![feature(const_trait_impl, effects)]
5+
//~^ WARN the feature `effects` is incomplete
6+
7+
#[const_trait] trait Foo {
8+
fn foo();
9+
}
10+
11+
fn foo<T: const Foo>() {
12+
const { T::foo() }
13+
}
14+
15+
fn main() {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/const-bound-in-host.rs:4:30
3+
|
4+
LL | #![feature(const_trait_impl, effects)]
5+
| ^^^^^^^
6+
|
7+
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
warning: 1 warning emitted
11+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//@ compile-flags: -Znext-solver
2+
//@ check-pass
3+
4+
#![feature(const_trait_impl, effects)]
5+
//~^ WARN the feature `effects` is incomplete
6+
7+
#[const_trait] trait Trait {
8+
fn method();
9+
}
10+
11+
const fn foo<T: Trait>() {
12+
let _ = || {
13+
// Make sure this doesn't enforce `T: ~const Trait`
14+
T::method();
15+
};
16+
}
17+
18+
fn bar<T: const Trait>() {
19+
let _ = || {
20+
// Make sure unconditionally const bounds propagate from parent.
21+
const { T::method(); };
22+
};
23+
}
24+
25+
fn main() {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/const-in-closure.rs:4:30
3+
|
4+
LL | #![feature(const_trait_impl, effects)]
5+
| ^^^^^^^
6+
|
7+
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
warning: 1 warning emitted
11+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ compile-flags: -Znext-solver
2+
//@ check-pass
3+
4+
#![feature(const_trait_impl, effects)]
5+
//~^ WARN the feature `effects` is incomplete
6+
7+
const fn opaque() -> impl Sized {}
8+
9+
fn main() {
10+
let mut x = const { opaque() };
11+
x = opaque();
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/dont-observe-host-opaque.rs:4:30
3+
|
4+
LL | #![feature(const_trait_impl, effects)]
5+
| ^^^^^^^
6+
|
7+
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
warning: 1 warning emitted
11+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//@ compile-flags: -Znext-solver
2+
//@ check-pass
3+
4+
#![feature(const_trait_impl, effects)]
5+
//~^ WARN the feature `effects` is incomplete
6+
7+
#[const_trait]
8+
trait Trait {
9+
fn method() {}
10+
}
11+
12+
impl const Trait for () {}
13+
14+
fn main() {
15+
let mut x = const {
16+
let x = <()>::method;
17+
x();
18+
x
19+
};
20+
let y = <()>::method;
21+
y();
22+
x = y;
23+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/dont-observe-host.rs:4:30
3+
|
4+
LL | #![feature(const_trait_impl, effects)]
5+
| ^^^^^^^
6+
|
7+
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
warning: 1 warning emitted
11+

0 commit comments

Comments
 (0)