]> git.lizzy.rs Git - rust.git/blob - tests/ui/dropck/dropck_no_diverge_on_nonregular_3.rs
Rollup merge of #106446 - bzEq:fix-unwind-lsda, r=Amanieu
[rust.git] / tests / ui / dropck / dropck_no_diverge_on_nonregular_3.rs
1 // Issue 22443: Reject code using non-regular types that would
2 // otherwise cause dropck to loop infinitely.
3 //
4 // This version is just checking that we still sanely handle a trivial
5 // wrapper around the non-regular type. (It also demonstrates how the
6 // error messages will report different types depending on which type
7 // dropck is analyzing.)
8
9 use std::marker::PhantomData;
10
11 struct Digit<T> {
12     elem: T
13 }
14
15 struct Node<T:'static> { m: PhantomData<&'static T> }
16
17 enum FingerTree<T:'static> {
18     Single(T),
19     // According to the bug report, Digit before Box would infinite loop.
20     Deep(
21         Digit<T>,
22         Box<FingerTree<Node<T>>>,
23         )
24 }
25
26 enum Wrapper<T:'static> {
27     Simple,
28     Other(FingerTree<T>),
29 }
30
31 fn main() {
32     let w = //~ ERROR overflow while adding drop-check rules for Option
33         Some(Wrapper::Simple::<u32>);
34     //~^ ERROR overflow while adding drop-check rules for Wrapper
35 }