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