]> git.proxmox.com Git - rustc.git/blame - src/test/ui/associated-types/issue-21726.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / test / ui / associated-types / issue-21726.rs
CommitLineData
60c5eb7d 1// check-pass
0bf4aa26 2#![allow(dead_code)]
85aaf69f
SL
3// Regression test for #21726: an issue arose around the rules for
4// subtyping of projection types that resulted in an unconstrained
5// region, yielding region inference failures.
6
c34b1796
AL
7// pretty-expanded FIXME #23616
8
85aaf69f
SL
9fn main() { }
10
11fn foo<'a>(s: &'a str) {
12 let b: B<()> = B::new(s, ());
13 b.get_short();
14}
15
16trait IntoRef<'a> {
17 type T: Clone;
041b39d2 18 fn into_ref(self, _: &'a str) -> Self::T;
85aaf69f
SL
19}
20
21impl<'a> IntoRef<'a> for () {
22 type T = &'a str;
23 fn into_ref(self, s: &'a str) -> &'a str {
24 s
25 }
26}
27
28struct B<'a, P: IntoRef<'a>>(P::T);
29
30impl<'a, P: IntoRef<'a>> B<'a, P> {
31 fn new(s: &'a str, i: P) -> B<'a, P> {
32 B(i.into_ref(s))
33 }
34
35 fn get_short(&self) -> P::T {
36 self.0.clone()
37 }
38}