Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit be55096

Browse files
Add tests
1 parent 851f58c commit be55096

24 files changed

+513
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ compile-flags: -Znext-solver
2+
//@ edition:2021
3+
4+
#![feature(const_trait_impl, effects, const_closures)]
5+
#![allow(incomplete_features)]
6+
7+
#[const_trait]
8+
trait Bar {
9+
fn foo(&self);
10+
}
11+
12+
impl Bar for () {
13+
fn foo(&self) {}
14+
}
15+
16+
const FOO: () = {
17+
(const || ().foo())();
18+
//~^ ERROR the trait bound `(): ~const Bar` is not satisfied
19+
// FIXME(effects): The constness environment for const closures is wrong.
20+
};
21+
22+
fn main() {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0277]: the trait bound `(): ~const Bar` is not satisfied
2+
--> $DIR/call-const-closure.rs:17:15
3+
|
4+
LL | (const || ().foo())();
5+
| ^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0277`.
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+

0 commit comments

Comments
 (0)