2014-12-12 16:54:57 +13:00
|
|
|
// Test coercions between pointers which don't do anything fancy like unsizing.
|
|
|
|
|
// These are testing that we don't lose mutability when converting to raw pointers.
|
|
|
|
|
|
2025-04-05 19:19:56 +03:00
|
|
|
//@ dont-require-annotations: NOTE
|
|
|
|
|
|
2014-12-12 16:54:57 +13:00
|
|
|
pub fn main() {
|
|
|
|
|
// *const -> *mut
|
2015-01-31 17:23:42 +01:00
|
|
|
let x: *const isize = &42;
|
2015-01-12 01:01:44 -05:00
|
|
|
let x: *mut isize = x; //~ ERROR mismatched types
|
2025-04-05 19:19:56 +03:00
|
|
|
//~| NOTE expected raw pointer `*mut isize`
|
|
|
|
|
//~| NOTE found raw pointer `*const isize`
|
|
|
|
|
//~| NOTE types differ in mutability
|
2014-12-12 16:54:57 +13:00
|
|
|
|
|
|
|
|
// & -> *mut
|
2015-01-12 01:01:44 -05:00
|
|
|
let x: *mut isize = &42; //~ ERROR mismatched types
|
2025-04-05 19:19:56 +03:00
|
|
|
//~| NOTE expected raw pointer `*mut isize`
|
|
|
|
|
//~| NOTE found reference `&isize`
|
|
|
|
|
//~| NOTE types differ in mutability
|
2014-12-12 16:54:57 +13:00
|
|
|
|
2015-01-08 21:54:35 +11:00
|
|
|
let x: *const isize = &42;
|
2015-01-12 01:01:44 -05:00
|
|
|
let x: *mut isize = x; //~ ERROR mismatched types
|
2025-04-05 19:19:56 +03:00
|
|
|
//~| NOTE expected raw pointer `*mut isize`
|
|
|
|
|
//~| NOTE found raw pointer `*const isize`
|
|
|
|
|
//~| NOTE types differ in mutability
|
2014-12-12 16:54:57 +13:00
|
|
|
}
|