diff options
| author | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-11-10 10:31:33 +0100 |
|---|---|---|
| committer | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-11-10 12:31:57 +0100 |
| commit | de1ebbb0a7d4c9da339e52dd439b53f3cfa883e5 (patch) | |
| tree | 4a0b320c74f10029a36576595772e9098ccf8481 | |
| parent | a30b28e8932f8eb2931d1a41bc9271961e90f1cb (diff) | |
| download | rust-de1ebbb0a7d4c9da339e52dd439b53f3cfa883e5.tar.gz rust-de1ebbb0a7d4c9da339e52dd439b53f3cfa883e5.zip | |
const param in async
| -rw-r--r-- | src/test/ui/const-generics/const-param-in-async.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/const-param-in-async.rs b/src/test/ui/const-generics/const-param-in-async.rs new file mode 100644 index 00000000000..e8601985287 --- /dev/null +++ b/src/test/ui/const-generics/const-param-in-async.rs @@ -0,0 +1,35 @@ +// edition:2018 +// check-pass +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] + +async fn foo<const N: usize>(arg: [u8; N]) -> usize { arg.len() } + +async fn bar<const N: usize>() -> [u8; N] { + [0; N] +} + +trait Trait<const N: usize> { + fn fynn(&self) -> usize; +} +impl<const N: usize> Trait<N> for [u8; N] { + fn fynn(&self) -> usize { + N + } +} +async fn baz<const N: usize>() -> impl Trait<N> { + [0; N] +} + +async fn biz<const N: usize>(v: impl Trait<N>) -> usize { + v.fynn() +} + +async fn user<const N: usize>() { + let _ = foo::<N>(bar().await).await; + let _ = biz(baz::<N>().await).await; +} + +fn main() { } |
