]> git.lizzy.rs Git - rust.git/blob - src/test/ui/dynamically-sized-types/dst-coercions.rs
Auto merge of #106025 - matthiaskrgr:rollup-vz5rqah, r=matthiaskrgr
[rust.git] / src / test / ui / dynamically-sized-types / dst-coercions.rs
1 // run-pass
2 #![allow(unused_variables)]
3 // Test coercions involving DST and/or raw pointers
4
5 // pretty-expanded FIXME #23616
6
7 struct S;
8 trait T { fn dummy(&self) { } }
9 impl T for S {}
10
11 pub fn main() {
12     let x: &dyn T = &S;
13     // Test we can convert from &-ptr to *-ptr of trait objects
14     let x: *const dyn T = &S;
15
16     // Test we can convert from &-ptr to *-ptr of struct pointer (not DST)
17     let x: *const S = &S;
18
19     // As above, but mut
20     let x: &mut dyn T = &mut S;
21     let x: *mut dyn T = &mut S;
22
23     let x: *mut S = &mut S;
24
25     // Test we can change the mutability from mut to const.
26     let x: &dyn T = &mut S;
27     let x: *const dyn T = &mut S;
28 }