diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-03-10 19:00:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-10 19:00:11 +0100 |
| commit | af35dc2a959ca98af1a9d8a329b3fce6c7dd69a7 (patch) | |
| tree | d8747ea5a197a2dc67857def2a613c36cdb08112 | |
| parent | fa685a54995accf77785e7df5f89b05a9d4c473e (diff) | |
| parent | 5f7ca55df6a89e3caa3131a13490cc01956149e7 (diff) | |
| download | rust-af35dc2a959ca98af1a9d8a329b3fce6c7dd69a7.tar.gz rust-af35dc2a959ca98af1a9d8a329b3fce6c7dd69a7.zip | |
Rollup merge of #94805 - oli-obk:drop_box, r=pnkfelix
Revert accidental stabilization fixes #94804
| -rw-r--r-- | library/alloc/src/boxed.rs | 3 | ||||
| -rw-r--r-- | library/alloc/tests/boxed.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/consts/drop_box.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/consts/drop_box.stderr | 11 |
4 files changed, 17 insertions, 3 deletions
diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 68bf59a01b3..f753189c683 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -1170,8 +1170,7 @@ impl<T: ?Sized, A: Allocator> Box<T, A> { } #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_box", issue = "92521")] -unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> const Drop for Box<T, A> { +unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for Box<T, A> { fn drop(&mut self) { // FIXME: Do nothing, drop is currently performed by compiler. } diff --git a/library/alloc/tests/boxed.rs b/library/alloc/tests/boxed.rs index 0d7acfed8c6..9e5123be989 100644 --- a/library/alloc/tests/boxed.rs +++ b/library/alloc/tests/boxed.rs @@ -160,7 +160,7 @@ fn const_box() { *boxed = 42; assert!(*boxed == 42); - *boxed + *Box::leak(boxed) }; assert!(VALUE == 42); diff --git a/src/test/ui/consts/drop_box.rs b/src/test/ui/consts/drop_box.rs new file mode 100644 index 00000000000..58a373a9673 --- /dev/null +++ b/src/test/ui/consts/drop_box.rs @@ -0,0 +1,4 @@ +const fn f<T>(_: Box<T>) {} +//~^ ERROR destructors cannot be evaluated at compile-time + +fn main() {} diff --git a/src/test/ui/consts/drop_box.stderr b/src/test/ui/consts/drop_box.stderr new file mode 100644 index 00000000000..b9d6581e8ec --- /dev/null +++ b/src/test/ui/consts/drop_box.stderr @@ -0,0 +1,11 @@ +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/drop_box.rs:1:15 + | +LL | const fn f<T>(_: Box<T>) {} + | ^ - value is dropped here + | | + | constant functions cannot evaluate destructors + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0493`. |
