Debian Codegraph @

third_party/rust/pin-project/tests/ui/unstable-features/trivial_bounds.rs

raw
1 // Note: If you change this test, change 'trivial_bounds-feature-gate.rs' at the same time.
2
3 // trivial_bounds
4 // Tracking issue: https://github.com/rust-lang/rust/issues/48214
5 #![feature(trivial_bounds)]
6 #![deny(trivial_bounds)]
7 #![allow(dead_code)]
8
9 use std::marker::{PhantomData, PhantomPinned};
10
11 fn inner() {
12 struct Inner(PhantomPinned);
13
14 struct A(PhantomPinned);
15
16 impl Unpin for A where PhantomPinned: Unpin {} //~ ERROR Unpin does not depend on any type or lifetime parameters
17
18 struct B(Inner);
19
20 impl Unpin for B where Inner: Unpin {} //~ ERROR Unpin does not depend on any type or lifetime parameters
21
22 struct Wrapper<T>(T);
23
24 impl<T> Unpin for Wrapper<T> where T: Unpin {}
25
26 struct C(Inner);
27
28 impl Unpin for C where Wrapper<Inner>: Unpin {} //~ ERROR Unpin does not depend on any type or lifetime parameters
29
30 struct WrapperWithLifetime<'a, T>(PhantomData<&'a ()>, T);
31
32 impl<T> Unpin for WrapperWithLifetime<'_, T> where T: Unpin {}
33
34 struct D(Inner);
35
36 impl<'a> Unpin for D where WrapperWithLifetime<'a, Inner>: Unpin {} // Ok
37 }
38
39 fn main() {}