]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-infer-paramd-indirect.rs
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / ui / regions / regions-infer-paramd-indirect.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 // Check that we correctly infer that b and c must be region
13 // parameterized because they reference a which requires a region.
14
15 type a<'a> = &'a isize;
16 type b<'a> = Box<a<'a>>;
17
18 struct c<'a> {
19     f: Box<b<'a>>
20 }
21
22 trait set_f<'a> {
23     fn set_f_ok(&mut self, b: Box<b<'a>>);
24     fn set_f_bad(&mut self, b: Box<b>);
25 }
26
27 impl<'a> set_f<'a> for c<'a> {
28     fn set_f_ok(&mut self, b: Box<b<'a>>) {
29         self.f = b;
30     }
31
32     fn set_f_bad(&mut self, b: Box<b>) {
33         self.f = b;
34         //~^ ERROR mismatched types
35         //~| expected type `std::boxed::Box<std::boxed::Box<&'a isize>>`
36         //~| found type `std::boxed::Box<std::boxed::Box<&isize>>`
37         //~| lifetime mismatch
38     }
39 }
40
41 fn main() {}