diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2022-12-28 08:55:01 +0000 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2022-12-28 09:06:31 +0000 |
| commit | 983606d3676c967e79a94b74b890bfb02367b608 (patch) | |
| tree | fa361866fe031452f8108169a813873f35887368 /src/test/ui/rfc-2632-const-trait-impl/const-closure-trait-method.rs | |
| parent | 6a4624d73b34153811f7642b89bd396306aa7843 (diff) | |
| download | rust-983606d3676c967e79a94b74b890bfb02367b608.tar.gz rust-983606d3676c967e79a94b74b890bfb02367b608.zip | |
Allow trait method paths to satisfy const Fn bounds
Diffstat (limited to 'src/test/ui/rfc-2632-const-trait-impl/const-closure-trait-method.rs')
| -rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/const-closure-trait-method.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-closure-trait-method.rs b/src/test/ui/rfc-2632-const-trait-impl/const-closure-trait-method.rs new file mode 100644 index 00000000000..3e6d1908848 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/const-closure-trait-method.rs @@ -0,0 +1,19 @@ +// check-pass +#![feature(const_trait_impl)] + +#[const_trait] +trait Tr { + fn a(self) -> i32; +} + +impl const Tr for () { + fn a(self) -> i32 { 42 } +} + +const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 { + x(()) +} + +const _: () = assert!(need_const_closure(Tr::a) == 42); + +fn main() {} |
