Skip to content

Commit ef026d2

Browse files
committed
ptr-coercion-rpass
1 parent dcb061a commit ef026d2

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
//@ run-pass
2-
3-
#![allow(unused_variables)]
4-
// Test coercions between pointers which don't do anything fancy like unsizing.
1+
//! Tests basic pointer coercions between:
2+
//! - `&mut T` -> `&T`
3+
//! - `&T` -> `*const T`
4+
//! - `&mut T` -> `*const T`
5+
//! - `*mut T` -> `*const T`
56
7+
//@ run-pass
68

79
pub fn main() {
810
// &mut -> &
911
let x: &mut isize = &mut 42;
10-
let x: &isize = x;
11-
12-
let x: &isize = &mut 42;
12+
let _: &isize = x;
13+
let _: &isize = &mut 42;
1314

1415
// & -> *const
1516
let x: &isize = &42;
16-
let x: *const isize = x;
17-
18-
let x: *const isize = &42;
17+
let _: *const isize = x;
18+
let _: *const isize = &42;
1919

2020
// &mut -> *const
2121
let x: &mut isize = &mut 42;
22-
let x: *const isize = x;
23-
24-
let x: *const isize = &mut 42;
22+
let _: *const isize = x;
23+
let _: *const isize = &mut 42;
2524

2625
// *mut -> *const
27-
let x: *mut isize = &mut 42;
28-
let x: *const isize = x;
26+
let _: *mut isize = &mut 42;
27+
let _: *const isize = x;
2928
}

0 commit comments

Comments
 (0)