]> git.lizzy.rs Git - rust.git/blob - tests/ui/async-await/return-ty-unsize-coercion.rs
Rollup merge of #106854 - steffahn:drop_linear_arc_rebased, r=Mark-Simulacrum
[rust.git] / tests / ui / async-await / return-ty-unsize-coercion.rs
1 // Check that we apply unsizing coercions based on the return type.
2 //
3 // Also serves as a regression test for #60424.
4 //
5 // edition:2018
6 // check-pass
7
8 #![allow(warnings)]
9
10 use std::fmt::Debug;
11
12 // Unsizing coercion from `Box<&'static str>` to `Box<dyn Debug>`.
13 fn unsize_trait_coercion() {
14     fn sync_example() -> Box<dyn Debug> {
15         Box::new("asdf")
16     }
17
18     async fn async_example() -> Box<dyn Debug> {
19         Box::new("asdf")
20     }
21 }
22
23 // Unsizing coercion from `Box<[u32; N]>` to `Box<[32]>`.
24 fn unsize_slice_coercion() {
25     fn sync_example() -> Box<[u32]> {
26         Box::new([0])
27     }
28
29     async fn async_example() -> Box<[u32]> {
30         Box::new([0])
31     }
32 }
33
34 // Unsizing coercion from `&[&str; 1]` to `&[&str]`
35 fn unsize_slice_str_coercion() {
36     fn sync_example() -> &'static [&'static str] {
37         &["hi"]
38     }
39
40     async fn async_example() -> &'static [&'static str] {
41         &["hi"]
42     }
43 }
44
45 fn main() {}