mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Add regression test
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#![feature(const_closures, const_destruct, const_trait_impl)]
|
||||
|
||||
use std::marker::Destruct;
|
||||
use std::num::NonZero;
|
||||
|
||||
const trait T {
|
||||
fn a(&mut self, f: impl [const] Fn() + [const] Destruct);
|
||||
fn b(&mut self);
|
||||
}
|
||||
|
||||
struct S;
|
||||
|
||||
impl const T for S {
|
||||
fn a(&mut self, f: impl [const] Fn() + [const] Destruct) {
|
||||
f()
|
||||
}
|
||||
|
||||
fn b(&mut self) {
|
||||
self.a(const || {});
|
||||
//~^ ERROR: cannot use `const` closures outside of const contexts
|
||||
//~| ERROR: [const] Fn()` is not satisfied
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,23 @@
|
||||
error: cannot use `const` closures outside of const contexts
|
||||
--> $DIR/const-closure-in-trait-impl.rs:19:16
|
||||
|
|
||||
LL | self.a(const || {});
|
||||
| ^^^^^
|
||||
|
||||
error[E0277]: the trait bound `{closure@$DIR/const-closure-in-trait-impl.rs:19:16: 19:24}: [const] Fn()` is not satisfied
|
||||
--> $DIR/const-closure-in-trait-impl.rs:19:16
|
||||
|
|
||||
LL | self.a(const || {});
|
||||
| - ^^^^^^^^^^^
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
note: required by a bound in `T::a`
|
||||
--> $DIR/const-closure-in-trait-impl.rs:7:29
|
||||
|
|
||||
LL | fn a(&mut self, f: impl [const] Fn() + [const] Destruct);
|
||||
| ^^^^^^^^^^^^ required by this bound in `T::a`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
Reference in New Issue
Block a user