]> git.lizzy.rs Git - rust.git/blob - src/test/ui/object-pointer-types.rs
Rollup merge of #53317 - estebank:abolish-ice, r=oli-obk
[rust.git] / src / test / ui / object-pointer-types.rs
1 // Copyright 2012 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.
4 //
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.
10
11
12 trait Foo {
13     fn borrowed(&self);
14     fn borrowed_mut(&mut self);
15
16     fn owned(self: Box<Self>);
17 }
18
19 fn borrowed_receiver(x: &Foo) {
20     x.borrowed();
21     x.borrowed_mut(); // See [1]
22     x.owned(); //~ ERROR no method named `owned` found
23 }
24
25 fn borrowed_mut_receiver(x: &mut Foo) {
26     x.borrowed();
27     x.borrowed_mut();
28     x.owned(); //~ ERROR no method named `owned` found
29 }
30
31 fn owned_receiver(x: Box<Foo>) {
32     x.borrowed();
33     x.borrowed_mut(); // See [1]
34     x.managed();  //~ ERROR no method named `managed` found
35     x.owned();
36 }
37
38 fn main() {}
39
40 // [1]: These cases are illegal, but the error is not detected
41 // until borrowck, so see the test borrowck-object-mutability.rs