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
21 fn foo(&self) -> int {
26 struct Foo<T: ?Sized> {
33 let z: *const Trait = &x;
40 let p = Foo {f: A { f: 42 }};
41 let o: *const Foo<Trait> = &p;
48 let a: *const [_] = &[1i, 2, 3];
56 // raw slice with explicit cast
57 let a = &[1i, 2, 3] as *const [_];
65 // raw DST struct with slice
66 let c: *const Foo<[_]> = &Foo {f: [1i, 2, 3]};
70 let len = (&*c).f.len();
74 // all of the above with *mut
75 let mut x = A { f: 42 };
76 let z: *mut Trait = &mut x;
82 let mut p = Foo {f: A { f: 42 }};
83 let o: *mut Foo<Trait> = &mut p;
89 let a: *mut [_] = &mut [1i, 2, 3];
97 let a = &mut [1i, 2, 3] as *mut [_];
101 let len = (*a).len();
105 let c: *mut Foo<[_]> = &mut Foo {f: [1i, 2, 3]};
109 let len = (&*c).f.len();