]> git.lizzy.rs Git - rust.git/blobdiff - src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.rs
Add another test case + fmt
[rust.git] / src / test / ui / rfc-2632-const-trait-impl / const-drop-fail.rs
index 3d505c700860887521af04007fdd46eae68c8556..3d4de088f5530f02cd9b8235160281c9192adb00 100644 (file)
@@ -4,6 +4,8 @@
 #![feature(const_fn_trait_bound)]
 #![cfg_attr(precise, feature(const_precise_live_drops))]
 
+use std::marker::PhantomData;
+
 struct NonTrivialDrop;
 
 impl Drop for NonTrivialDrop {
@@ -18,6 +20,19 @@ impl const Drop for ConstImplWithDropGlue {
     fn drop(&mut self) {}
 }
 
+trait A { fn a() { println!("A"); } }
+
+impl A for NonTrivialDrop {}
+
+struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
+//~^ ERROR `~const` is not allowed
+
+impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {
+    fn drop(&mut self) {
+        T::a();
+    }
+}
+
 const fn check<T: ~const Drop>(_: T) {}
 
 macro_rules! check_all {
@@ -31,6 +46,9 @@ macro_rules! check_all {
     //~^ ERROR the trait bound
     ConstImplWithDropGlue(NonTrivialDrop),
     //~^ ERROR the trait bound
+    ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
+    //~^ ERROR the trait bound
+    //~| ERROR the trait bound
 }
 
 fn main() {}