]> git.proxmox.com Git - rustc.git/blame - src/test/ui/dropck/dropck_traits.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / dropck / dropck_traits.rs
CommitLineData
dfeec247
XL
1// run-pass
2//! Regression test for #34426, regarding HRTB in drop impls
3
4// All of this Drop impls should compile.
5
6pub trait Lifetime<'a> {}
7impl<'a> Lifetime<'a> for i32 {}
8
9#[allow(dead_code)]
10struct Foo<L>
11where
12 for<'a> L: Lifetime<'a>,
13{
14 l: L,
15}
16
17impl<L> Drop for Foo<L>
18where
19 for<'a> L: Lifetime<'a>,
20{
21 fn drop(&mut self) {}
22}
23
24#[allow(dead_code)]
25struct Foo2<L>
26where
27 for<'a> L: Lifetime<'a>,
28{
29 l: L,
30}
31
32impl<T: for<'a> Lifetime<'a>> Drop for Foo2<T>
33where
34 for<'x> T: Lifetime<'x>,
35{
36 fn drop(&mut self) {}
37}
38
39pub trait Lifetime2<'a, 'b> {}
40impl<'a, 'b> Lifetime2<'a, 'b> for i32 {}
41
42#[allow(dead_code)]
43struct Bar<L>
44where
45 for<'a, 'b> L: Lifetime2<'a, 'b>,
46{
47 l: L,
48}
49
50impl<L> Drop for Bar<L>
51where
52 for<'a, 'b> L: Lifetime2<'a, 'b>,
53{
54 fn drop(&mut self) {}
55}
56
57#[allow(dead_code)]
58struct FnHolder<T: for<'a> Fn(&'a T, dyn for<'b> Lifetime2<'a, 'b>) -> u8>(T);
59
60impl<T: for<'a> Fn(&'a T, dyn for<'b> Lifetime2<'a, 'b>) -> u8> Drop for FnHolder<T> {
61 fn drop(&mut self) {}
62}
63
64fn main() {
65 let _foo = Foo { l: 0 };
66
67 let _bar = Bar { l: 0 };
68}