]> git.proxmox.com Git - rustc.git/blob - src/test/ui/ptr-coercion.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui / ptr-coercion.rs
1 // Test coercions between pointers which don't do anything fancy like unsizing.
2 // These are testing that we don't lose mutability when converting to raw pointers.
3
4 pub fn main() {
5 // *const -> *mut
6 let x: *const isize = &42;
7 let x: *mut isize = x; //~ ERROR mismatched types
8 //~| expected raw pointer `*mut isize`
9 //~| found raw pointer `*const isize`
10 //~| types differ in mutability
11
12 // & -> *mut
13 let x: *mut isize = &42; //~ ERROR mismatched types
14 //~| expected raw pointer `*mut isize`
15 //~| found reference `&isize`
16 //~| types differ in mutability
17
18 let x: *const isize = &42;
19 let x: *mut isize = x; //~ ERROR mismatched types
20 //~| expected raw pointer `*mut isize`
21 //~| found raw pointer `*const isize`
22 //~| types differ in mutability
23 }