diff options
Diffstat (limited to 'tests')
5 files changed, 53 insertions, 0 deletions
diff --git a/tests/ui/rfc-2632-const-trait-impl/call.rs b/tests/ui/rfc-2632-const-trait-impl/call.rs new file mode 100644 index 00000000000..5f48c235373 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/call.rs @@ -0,0 +1,10 @@ +// check-pass + +#![feature(const_closures, const_trait_impl)] +#![allow(incomplete_features)] + +pub const _: () = { + assert!((const || true)()); +}; + +fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/gate.rs b/tests/ui/rfc-2632-const-trait-impl/gate.rs new file mode 100644 index 00000000000..f2cd26c91b6 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/gate.rs @@ -0,0 +1,5 @@ +// gate-test-const_closures +fn main() { + (const || {})(); + //~^ ERROR: const closures are experimental +} diff --git a/tests/ui/rfc-2632-const-trait-impl/gate.stderr b/tests/ui/rfc-2632-const-trait-impl/gate.stderr new file mode 100644 index 00000000000..30edc4127e1 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/gate.stderr @@ -0,0 +1,12 @@ +error[E0658]: const closures are experimental + --> $DIR/gate.rs:3:6 + | +LL | (const || {})(); + | ^^^^^^^^^^^ + | + = note: see issue #106003 <https://github.com/rust-lang/rust/issues/106003> for more information + = help: add `#![feature(const_closures)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.rs b/tests/ui/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.rs new file mode 100644 index 00000000000..cd8bb5963ad --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.rs @@ -0,0 +1,15 @@ +#![feature(const_closures, const_trait_impl)] +#![allow(incomplete_features)] + +trait Foo { + fn foo(&self); +} + +impl Foo for () { + fn foo(&self) {} +} + +fn main() { + (const || { (()).foo() })(); + //~^ ERROR: cannot call non-const fn +} diff --git a/tests/ui/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr b/tests/ui/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr new file mode 100644 index 00000000000..979d7febbca --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr @@ -0,0 +1,11 @@ +error[E0015]: cannot call non-const fn `<() as Foo>::foo` in constant functions + --> $DIR/non-const-op-const-closure-non-const-outer.rs:13:22 + | +LL | (const || { (()).foo() })(); + | ^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0015`. |
