summaryrefslogtreecommitdiffstats
path: root/src/test/ui/dynamically-sized-types/dst-coercions.rs
blob: 66688e93fb80d8d00eaa1cf716f159168e65563d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// run-pass
#![allow(unused_variables)]
// Test coercions involving DST and/or raw pointers

// pretty-expanded FIXME #23616

struct S;
trait T { fn dummy(&self) { } }
impl T for S {}

pub fn main() {
    let x: &dyn T = &S;
    // Test we can convert from &-ptr to *-ptr of trait objects
    let x: *const dyn T = &S;

    // Test we can convert from &-ptr to *-ptr of struct pointer (not DST)
    let x: *const S = &S;

    // As above, but mut
    let x: &mut dyn T = &mut S;
    let x: *mut dyn T = &mut S;

    let x: *mut S = &mut S;

    // Test we can change the mutability from mut to const.
    let x: &dyn T = &mut S;
    let x: *const dyn T = &mut S;
}