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