]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/destructure-trait-ref.rs
3f455e148a09be30fb0919dfd00f1279f3b0491e
1 // Copyright 2012-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 // The regression test for #15031 to make sure destructuring trait
12 // reference work properly.
14 #![feature(box_patterns)]
15 #![feature(box_syntax)]
17 trait T { fn foo(&self) {}
}
21 // For an expression of the form:
23 // let &...&x = &..&SomeTrait;
25 // Say we have n `&` at the left hand and m `&` right hand, then:
26 // if n < m, we are golden;
27 // if n == m, it's a derefing non-derefable type error;
28 // if n > m, it's a type mismatch error.
32 let &x
= &&(&1 as &T
);
33 let &&x
= &&(&1 as &T
);
36 let &x
= &1 as &T
; //~ ERROR type `&T` cannot be dereferenced
37 let &&x
= &(&1 as &T
); //~ ERROR type `&T` cannot be dereferenced
38 let box x
= box 1 as Box
<T
>; //~ ERROR the trait `core::marker::Sized` is not implemented
42 //~^ ERROR mismatched types
47 let &&&x
= &(&1 as &T
);
48 //~^ ERROR mismatched types
53 let box box x
= box 1 as Box
<T
>;
54 //~^ ERROR mismatched types