diff options
Diffstat (limited to 'src/test/ui/dynamically-sized-types/dst-coercions.rs')
-rw-r--r-- | src/test/ui/dynamically-sized-types/dst-coercions.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/dynamically-sized-types/dst-coercions.rs b/src/test/ui/dynamically-sized-types/dst-coercions.rs new file mode 100644 index 000000000..66688e93f --- /dev/null +++ b/src/test/ui/dynamically-sized-types/dst-coercions.rs @@ -0,0 +1,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; +} |