]> git.lizzy.rs Git - rust.git/blob - tests/ui/nll/type-check-pointer-coercions.rs
Auto merge of #101138 - Rejyr:diagnostic-migration-rustc-lint-pt2, r=davidtwco
[rust.git] / tests / ui / nll / type-check-pointer-coercions.rs
1 fn shared_to_const<'a, 'b>(x: &&'a i32) -> *const &'b i32 {
2     x   //~ ERROR
3 }
4
5 fn unique_to_const<'a, 'b>(x: &mut &'a i32) -> *const &'b i32 {
6     x   //~ ERROR
7 }
8
9 fn unique_to_mut<'a, 'b>(x: &mut &'a i32) -> *mut &'b i32 {
10     // Two errors because *mut is invariant
11     x   //~ ERROR
12         //~| ERROR
13 }
14
15 fn mut_to_const<'a, 'b>(x: *mut &'a i32) -> *const &'b i32 {
16     x   //~ ERROR
17 }
18
19 fn array_elem<'a, 'b>(x: &'a i32) -> *const &'b i32 {
20     let z = &[x; 3];
21     let y = z as *const &i32;
22     y   //~ ERROR
23 }
24
25 fn array_coerce<'a, 'b>(x: &'a i32) -> *const [&'b i32; 3] {
26     let z = &[x; 3];
27     let y = z as *const [&i32; 3];
28     y   //~ ERROR
29 }
30
31 fn nested_array<'a, 'b>(x: &'a i32) -> *const [&'b i32; 2] {
32     let z = &[[x; 2]; 3];
33     let y = z as *const [&i32; 2];
34     y   //~ ERROR
35 }
36
37 fn main() {}