diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-10-25 23:19:34 +0200 |
|---|---|---|
| committer | Matthias Krüger <matthias.krueger@famsik.de> | 2023-11-02 15:59:54 +0100 |
| commit | 384f7382ba595092169569e4e16aaeb7dbd32f7a (patch) | |
| tree | 8ee8af02ae9a3c86d8709ea2b79b5c6b28d8d105 | |
| parent | 62270fb4d674fa109148c3a2618e4db9e03cd91c (diff) | |
| download | rust-384f7382ba595092169569e4e16aaeb7dbd32f7a.tar.gz rust-384f7382ba595092169569e4e16aaeb7dbd32f7a.zip | |
add test for #113381
Fixes #113381 r? fee1-dead
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/const_closure-const_trait_impl-ice-113381.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/const_closure-const_trait_impl-ice-113381.rs new file mode 100644 index 00000000000..6598d1da0f8 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/const_closure-const_trait_impl-ice-113381.rs @@ -0,0 +1,15 @@ +#![feature(const_closures, const_trait_impl, effects)] +#![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/rfcs/rfc-2632-const-trait-impl/effects/const_closure-const_trait_impl-ice-113381.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/const_closure-const_trait_impl-ice-113381.stderr new file mode 100644 index 00000000000..002d586ac64 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/const_closure-const_trait_impl-ice-113381.stderr @@ -0,0 +1,11 @@ +error[E0015]: cannot call non-const fn `<() as Foo>::foo` in constant functions + --> $DIR/const_closure-const_trait_impl-ice-113381.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`. |
