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.
|
|
|
|
|
|
|
|
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
|
2016-04-20 14:42:13 -04:00
|
|
|
//~| expected type `*mut isize`
|
|
|
|
//~| found type `*const isize`
|
2016-08-19 16:05:37 -07:00
|
|
|
//~| 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
|
2016-04-20 14:42:13 -04:00
|
|
|
//~| expected type `*mut isize`
|
|
|
|
//~| found type `&isize`
|
2016-08-19 16:05:37 -07:00
|
|
|
//~| 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
|
2016-04-20 14:42:13 -04:00
|
|
|
//~| expected type `*mut isize`
|
|
|
|
//~| found type `*const isize`
|
2016-08-19 16:05:37 -07:00
|
|
|
//~| types differ in mutability
|
2014-12-12 16:54:57 +13:00
|
|
|
}
|