]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/issue-21726.rs
New upstream version 1.19.0+dfsg1
[rustc.git] / src / test / run-pass / issue-21726.rs
CommitLineData
85aaf69f
SL
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
c34b1796
AL
15// pretty-expanded FIXME #23616
16
85aaf69f
SL
17fn main() { }
18
19fn foo<'a>(s: &'a str) {
20 let b: B<()> = B::new(s, ());
21 b.get_short();
22}
23
24trait IntoRef<'a> {
25 type T: Clone;
26 fn into_ref(self, &'a str) -> Self::T;
27}
28
29impl<'a> IntoRef<'a> for () {
30 type T = &'a str;
31 fn into_ref(self, s: &'a str) -> &'a str {
32 s
33 }
34}
35
36struct B<'a, P: IntoRef<'a>>(P::T);
37
38impl<'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}