]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/declare_interior_mutable_const.rs
FROM_ITER_INSTEAD_OF_COLLECT: avoid unwrapping unconditionally
[rust.git] / tests / ui / declare_interior_mutable_const.rs
index 646d3ec8b472ef6c25f25003e6a774b333a4a388..3afcdca2f04dd165b03f7fb7fcdf0e12d0867073 100644 (file)
@@ -121,18 +121,24 @@ impl<T> AssocTypesFromGenericParam<T> for u64
     const BOUNDED: T::ToBeBounded = AtomicUsize::new(15);
 }
 
-trait SelfType {
+// a constant whose type is `Self` should be linted at the implementation site as well.
+// (`Option` requires `Sized` bound.)
+trait SelfType: Sized {
     const SELF: Self;
+    // this was the one in the original issue (#5050).
+    const WRAPPED_SELF: Option<Self>;
 }
 
 impl SelfType for u64 {
     const SELF: Self = 16;
+    const WRAPPED_SELF: Option<Self> = Some(20);
 }
 
 impl SelfType for AtomicUsize {
     // this (interior mutable `Self` const) exists in `parking_lot`.
     // `const_trait_impl` will replace it in the future, hopefully.
     const SELF: Self = AtomicUsize::new(17); //~ ERROR interior mutable
+    const WRAPPED_SELF: Option<Self> = Some(AtomicUsize::new(21)); //~ ERROR interior mutable
 }
 
 // Even though a constant contains a generic type, if it also have a interior mutable type,