1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test DST raw pointers
14 #![feature(unsized_tuple_coercion)]
17 fn foo(&self) -> isize;
24 fn foo(&self) -> isize {
29 struct Foo<T: ?Sized> {
36 let z: *const Trait = &x;
43 let p = Foo {f: A { f: 42 }};
44 let o: *const Foo<Trait> = &p;
51 let p = (A { f: 42 },);
52 let o: *const (Trait,) = &p;
59 let a: *const [_] = &[1, 2, 3];
67 // raw slice with explicit cast
68 let a = &[1, 2, 3] as *const [i32];
76 // raw DST struct with slice
77 let c: *const Foo<[_]> = &Foo {f: [1, 2, 3]};
81 let len = (&*c).f.len();
85 // raw DST tuple with slice
86 let c: *const ([_],) = &([1, 2, 3],);
90 let len = (&*c).0.len();
94 // all of the above with *mut
95 let mut x = A { f: 42 };
96 let z: *mut Trait = &mut x;
102 let mut p = Foo {f: A { f: 42 }};
103 let o: *mut Foo<Trait> = &mut p;
109 let mut p = (A { f: 42 },);
110 let o: *mut (Trait,) = &mut p;
116 let a: *mut [_] = &mut [1, 2, 3];
120 let len = (*a).len();
124 let a = &mut [1, 2, 3] as *mut [i32];
128 let len = (*a).len();
132 let c: *mut Foo<[_]> = &mut Foo {f: [1, 2, 3]};
136 let len = (&*c).f.len();
140 let c: *mut ([_],) = &mut ([1, 2, 3],);
144 let len = (&*c).0.len();