Skip to content

Commit a0e81ec

Browse files
Add regression test for rust-lang#34426
1 parent d1fff4a commit a0e81ec

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/test/ui/dropck/dropck_traits.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// run-pass
2+
//! Regression test for #34426, regarding HRTB in drop impls
3+
4+
pub trait Lifetime<'a> {}
5+
impl<'a> Lifetime<'a> for i32 {}
6+
7+
#[allow(dead_code)]
8+
struct Foo<L>
9+
where
10+
for<'a> L: Lifetime<'a>,
11+
{
12+
l: L,
13+
}
14+
15+
impl<L> Drop for Foo<L>
16+
where
17+
for<'a> L: Lifetime<'a>,
18+
{
19+
fn drop(&mut self) {
20+
println!("drop with hrtb");
21+
}
22+
}
23+
24+
pub trait Lifetime2<'a, 'b> {}
25+
impl<'a, 'b> Lifetime2<'a, 'b> for i32 {}
26+
27+
#[allow(dead_code)]
28+
struct Bar<L>
29+
where
30+
for<'a, 'b> L: Lifetime2<'a, 'b>,
31+
{
32+
l: L,
33+
}
34+
35+
impl<L> Drop for Bar<L>
36+
where
37+
for<'a, 'b> L: Lifetime2<'a, 'b>,
38+
{
39+
fn drop(&mut self) {
40+
println!("drop with hrtb");
41+
}
42+
}
43+
44+
fn main() {
45+
let _foo = Foo { l: 0 };
46+
47+
let _bar = Bar { l: 0 };
48+
}

0 commit comments

Comments
 (0)