]> git.proxmox.com Git - rustc.git/blame - src/test/ui/regions/regions-outlives-projection-container-hrtb.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / regions / regions-outlives-projection-container-hrtb.rs
CommitLineData
85aaf69f
SL
1// Test that structs with higher-ranked where clauses don't generate
2// "outlives" requirements. Issue #22246.
3
4#![allow(dead_code)]
a1dfa0c6 5
9346a6ac 6pub trait TheTrait<'b> {
85aaf69f
SL
7 type TheAssocType;
8}
9
10pub struct TheType<'b> {
11 m: [fn(&'b()); 0]
12}
13
14impl<'a,'b> TheTrait<'a> for TheType<'b> {
15 type TheAssocType = &'b ();
16}
17
85aaf69f
SL
18pub struct WithHrAssoc<T>
19 where for<'a> T : TheTrait<'a>
20{
21 m: [T; 0]
22}
23
24fn with_assoc<'a,'b>() {
b039eaaf 25 // We get an error because 'b:'a does not hold:
85aaf69f
SL
26
27 let _: &'a WithHrAssoc<TheType<'b>> = loop { };
923072b8 28 //~^ ERROR lifetime may not live long enough
85aaf69f
SL
29}
30
85aaf69f
SL
31pub trait TheSubTrait : for<'a> TheTrait<'a> {
32}
33
34impl<'b> TheSubTrait for TheType<'b> { }
35
36pub struct WithHrAssocSub<T>
37 where T : TheSubTrait
38{
39 m: [T; 0]
40}
41
42fn with_assoc_sub<'a,'b>() {
e9174d1e
SL
43 // The error here is just because `'b:'a` must hold for the type
44 // below to be well-formed, it is not related to the HR relation.
85aaf69f
SL
45
46 let _: &'a WithHrAssocSub<TheType<'b>> = loop { };
923072b8 47 //~^ ERROR lifetime may not live long enough
85aaf69f
SL
48}
49
a1dfa0c6 50
e9174d1e 51fn main() {
85aaf69f 52}