]> git.lizzy.rs Git - rust.git/blob - src/test/parse-fail/regions-infer-paramd-method.rs
rollup merge of #24541: alexcrichton/issue-24538
[rust.git] / src / test / parse-fail / regions-infer-paramd-method.rs
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.
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 // ignore-test
12 // ignored due to problems with by value self.
13
14 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
15 // file at the top-level directory of this distribution and at
16 // http://rust-lang.org/COPYRIGHT.
17 //
18 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
19 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
20 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
21 // option. This file may not be copied, modified, or distributed
22 // except according to those terms.
23
24 // compile-flags: -Z parse-only
25
26 // Here: foo is parameterized because it contains a method that
27 // refers to self.
28
29 trait foo<'a> {
30     fn self_int(self) -> &'a isize;
31
32     fn any_int(self) -> &isize;
33 }
34
35 struct with_foo<'a> {
36     f: @foo<'a>
37 }
38
39 trait set_foo_foo {
40     fn set_foo(&mut self, f: @foo);
41 }
42
43 impl<'a> set_foo_foo for with_foo<'a> {
44     fn set_foo(&mut self, f: @foo) {
45         self.f = f; //~ ERROR mismatched types: expected `@foo/&self`, found `@foo/&`
46     }
47 }
48
49 // Bar is not region parameterized.
50
51 trait bar {
52     fn any_int(&self) -> &isize;
53 }
54
55 struct with_bar {
56     f: bar
57 }
58
59 trait set_foo_bar {
60     fn set_foo(&mut self, f: bar);
61 }
62
63 impl set_foo_bar for with_bar {
64     fn set_foo(&mut self, f: bar) {
65         self.f = f;
66     }
67 }
68
69 fn main() {}