]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/unsafety-checking-cycle.rs
Auto merge of #95604 - nbdd0121:used2, r=petrochenkov
[rust.git] / src / test / ui / impl-trait / unsafety-checking-cycle.rs
1 // Ensure that we don't get a cycle error from trying to determine whether an
2 // opaque type implements `Freeze` in safety checking, when it doesn't matter.
3
4 // check-pass
5
6 #![feature(rustc_attrs)]
7
8 struct AnyValue<T>(T);
9
10 // No need to check for `Freeze` here, there's no
11 // `rustc_layout_scalar_valid_range_start` involved.
12 fn not_restricted(c: bool) -> impl Sized {
13     if c {
14         let x = AnyValue(not_restricted(false));
15         &x.0;
16     }
17     2u32
18 }
19
20 #[rustc_layout_scalar_valid_range_start(1)]
21 struct NonZero<T>(T);
22
23 // No need to check for `Freeze` here, we're not borrowing the field.
24 fn not_field(c: bool) -> impl Sized {
25     if c {
26         let x = unsafe { NonZero(not_field(false)) };
27         &x;
28     }
29     5u32
30 }
31
32 fn main() {}