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