]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-21726.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / issues / issue-21726.rs
1 // Copyright 2015 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 // compile-pass
12 #![allow(dead_code)]
13 // Regression test for #21726: an issue arose around the rules for
14 // subtyping of projection types that resulted in an unconstrained
15 // region, yielding region inference failures.
16
17 // pretty-expanded FIXME #23616
18
19 fn main() { }
20
21 fn foo<'a>(s: &'a str) {
22     let b: B<()> = B::new(s, ());
23     b.get_short();
24 }
25
26 trait IntoRef<'a> {
27     type T: Clone;
28     fn into_ref(self, _: &'a str) -> Self::T;
29 }
30
31 impl<'a> IntoRef<'a> for () {
32     type T = &'a str;
33     fn into_ref(self, s: &'a str) -> &'a str {
34         s
35     }
36 }
37
38 struct B<'a, P: IntoRef<'a>>(P::T);
39
40 impl<'a, P: IntoRef<'a>> B<'a, P> {
41     fn new(s: &'a str, i: P) -> B<'a, P> {
42         B(i.into_ref(s))
43     }
44
45     fn get_short(&self) -> P::T {
46         self.0.clone()
47     }
48 }