diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2019-10-02 10:03:40 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2019-10-02 10:03:40 -0400 |
| commit | f7ed53c9dad467b5b9e33398e9e33f00a6724d96 (patch) | |
| tree | cf32ecf52a5b5eff49b9809e9f0a3bd833285b19 /src/test | |
| parent | c8e58512d4ad327cdc974b6bfbde62e2778f0cc3 (diff) | |
| download | rust-f7ed53c9dad467b5b9e33398e9e33f00a6724d96.tar.gz rust-f7ed53c9dad467b5b9e33398e9e33f00a6724d96.zip | |
extract expected return type from `-> impl Future` obligation
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/async-await/return-ty-raw-ptr-coercion.rs | 25 | ||||
| -rw-r--r-- | src/test/ui/async-await/return-ty-unsize-coercion.rs | 34 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/test/ui/async-await/return-ty-raw-ptr-coercion.rs b/src/test/ui/async-await/return-ty-raw-ptr-coercion.rs new file mode 100644 index 00000000000..570e745f8c7 --- /dev/null +++ b/src/test/ui/async-await/return-ty-raw-ptr-coercion.rs @@ -0,0 +1,25 @@ +// Check that we apply unsizing coercions based on the return type. +// +// Also serves as a regression test for #60424. +// +// edition:2018 +// check-pass + +#![allow(warnings)] + +use std::fmt::Debug; + +const TMP: u32 = 22; + +// Coerce from `Box<"asdf">` to `Box<dyn Debug>`. +fn raw_pointer_coercion() { + fn sync_example() -> *const u32 { + &TMP + } + + async fn async_example() -> *const u32 { + &TMP + } +} + +fn main() {} diff --git a/src/test/ui/async-await/return-ty-unsize-coercion.rs b/src/test/ui/async-await/return-ty-unsize-coercion.rs new file mode 100644 index 00000000000..4d1b87677ed --- /dev/null +++ b/src/test/ui/async-await/return-ty-unsize-coercion.rs @@ -0,0 +1,34 @@ +// Check that we apply unsizing coercions based on the return type. +// +// Also serves as a regression test for #60424. +// +// edition:2018 +// check-pass + +#![allow(warnings)] + +use std::fmt::Debug; + +// Coerce from `Box<"asdf">` to `Box<dyn Debug>`. +fn unsize_trait_coercion() { + fn sync_example() -> Box<dyn Debug> { + Box::new("asdf") + } + + async fn async_example() -> Box<dyn Debug> { + Box::new("asdf") + } +} + +// Coerce from `Box<[u32; N]>` to `Box<[32]>`. +fn unsize_slice_coercion() { + fn sync_example() -> Box<[u32]> { + Box::new([0]) + } + + async fn async_example() -> Box<[u32]> { + Box::new([0]) + } +} + +fn main() {} |
