]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-41936-variance-coerce-unsized-cycle.rs
Consider privacy more carefully when suggesting accessing fields
[rust.git] / src / test / ui / issues / issue-41936-variance-coerce-unsized-cycle.rs
1 // check-pass
2 #![allow(dead_code)]
3 // Regression test for #41936. The coerce-unsized trait check in
4 // coherence was using subtyping, which triggered variance
5 // computation, which failed because it required type info for fields
6 // that had not (yet) been computed.
7
8 #![feature(unsize)]
9 #![feature(coerce_unsized)]
10
11 use std::{marker,ops};
12
13 // Change the array to a non-array, and error disappears
14 // Adding a new field to the end keeps the error
15 struct LogDataBuf([u8;8]);
16
17 struct Aref<T: ?Sized>
18 {
19     // Inner structure triggers the error, removing the inner removes the message.
20     ptr: Box<ArefInner<T>>,
21 }
22 impl<T: ?Sized + marker::Unsize<U>, U: ?Sized> ops::CoerceUnsized<Aref<U>> for Aref<T> {}
23
24 struct ArefInner<T: ?Sized>
25 {
26     // Even with this field commented out, the error is raised.
27     data: T,
28 }
29
30 fn main(){}