diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 7b41023ff31bf..e9a31b37e5af9 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -104,6 +104,7 @@ #![feature(const_convert)] #![feature(const_default)] #![feature(const_destruct)] +#![feature(const_drop_in_place)] #![feature(const_eval_select)] #![feature(const_heap)] #![feature(const_index)] diff --git a/library/alloc/src/raw_vec/mod.rs b/library/alloc/src/raw_vec/mod.rs index 0309d63cce06d..b4e2b65ba8b0a 100644 --- a/library/alloc/src/raw_vec/mod.rs +++ b/library/alloc/src/raw_vec/mod.rs @@ -417,7 +417,8 @@ impl RawVec { } } -unsafe impl<#[may_dangle] T, A: Allocator> Drop for RawVec { +#[rustc_const_unstable(feature = "const_heap", issue = "79597")] +unsafe impl<#[may_dangle] T, A: [const] Allocator + [const] Destruct> const Drop for RawVec { /// Frees the memory owned by the `RawVec` *without* trying to drop its contents. fn drop(&mut self) { // SAFETY: We are in a Drop impl, self.inner will not be used again. @@ -861,7 +862,10 @@ impl RawVecInner { } Ok(()) } +} +#[rustc_const_unstable(feature = "const_heap", issue = "79597")] +const impl RawVecInner { /// # Safety /// /// This function deallocates the owned allocation, but does not update `ptr` or `cap` to diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index a08e99a277d70..26a58310a742f 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -79,9 +79,7 @@ use core::cmp::Ordering; use core::hash::{Hash, Hasher}; #[cfg(not(no_global_oom_handling))] use core::iter; -#[cfg(not(no_global_oom_handling))] -use core::marker::Destruct; -use core::marker::{Freeze, PhantomData}; +use core::marker::{Destruct, Freeze, PhantomData}; use core::mem::{self, Assume, ManuallyDrop, MaybeUninit, SizedTypeProperties, TransmuteFrom}; use core::ops::{self, Index, IndexMut, Range, RangeBounds}; use core::ptr::{self, NonNull}; @@ -2190,7 +2188,8 @@ impl Vec { /// [`spare_capacity_mut()`]: Vec::spare_capacity_mut #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub unsafe fn set_len(&mut self, new_len: usize) { + #[rustc_const_unstable(feature = "const_heap", issue = "79597")] + pub const unsafe fn set_len(&mut self, new_len: usize) { ub_checks::assert_unsafe_precondition!( check_library_ub, "Vec::set_len requires that new_len <= capacity()", @@ -4255,7 +4254,10 @@ impl Ord for Vec { } #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<#[may_dangle] T, A: Allocator> Drop for Vec { +#[rustc_const_unstable(feature = "const_heap", issue = "79597")] +unsafe impl<#[may_dangle] T: [const] Destruct, A: [const] Allocator + [const] Destruct> const Drop + for Vec +{ fn drop(&mut self) { unsafe { // use drop for [T] @@ -4474,7 +4476,10 @@ impl From<&str> for Vec { } #[stable(feature = "array_try_from_vec", since = "1.48.0")] -impl TryFrom> for [T; N] { +#[rustc_const_unstable(feature = "const_convert", issue = "143773")] +impl const + TryFrom> for [T; N] +{ type Error = Vec; /// Gets the entire contents of the `Vec` as an array, diff --git a/tests/ui/consts/bad-array-size-in-type-err.stderr b/tests/ui/consts/bad-array-size-in-type-err.stderr index 84e16f8d931ea..13b0b6c4f4a65 100644 --- a/tests/ui/consts/bad-array-size-in-type-err.stderr +++ b/tests/ui/consts/bad-array-size-in-type-err.stderr @@ -57,6 +57,10 @@ LL | pub const fn i(_: Wrap) {} | ^ - value is dropped here | | | the destructor for this type cannot be evaluated in constant functions + | + = note: see issue #133214 for more information + = help: add `#![feature(const_destruct)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: aborting due to 7 previous errors diff --git a/tests/ui/consts/const-eval/issue-65394.stock.stderr b/tests/ui/consts/const-eval/issue-65394.stock.stderr index f33593862a763..514d454df3dc0 100644 --- a/tests/ui/consts/const-eval/issue-65394.stock.stderr +++ b/tests/ui/consts/const-eval/issue-65394.stock.stderr @@ -6,6 +6,10 @@ LL | let mut x = Vec::::new(); ... LL | }; | - value is dropped here + | + = note: see issue #133214 for more information + = help: add `#![feature(const_destruct)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/livedrop.stderr b/tests/ui/consts/const-eval/livedrop.stderr index 1add814060370..b090e35f07e3f 100644 --- a/tests/ui/consts/const-eval/livedrop.stderr +++ b/tests/ui/consts/const-eval/livedrop.stderr @@ -6,6 +6,10 @@ LL | let mut always_returned = None; ... LL | always_returned = never_returned; | --------------- value is dropped here + | + = note: see issue #133214 for more information + = help: add `#![feature(const_destruct)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: aborting due to 1 previous error diff --git a/tests/ui/consts/control-flow/drop-fail.precise.stderr b/tests/ui/consts/control-flow/drop-fail.precise.stderr index 32afc51c3ee34..6f07d2329615b 100644 --- a/tests/ui/consts/control-flow/drop-fail.precise.stderr +++ b/tests/ui/consts/control-flow/drop-fail.precise.stderr @@ -1,14 +1,14 @@ -error[E0493]: destructor of `Option>` cannot be evaluated at compile-time - --> $DIR/drop-fail.rs:9:9 +error[E0493]: destructor of `Option` cannot be evaluated at compile-time + --> $DIR/drop-fail.rs:16:9 | -LL | let x = Some(Vec::new()); +LL | let x = Some(NotConstDestruct); | ^ the destructor for this type cannot be evaluated in constants ... LL | }; | - value is dropped here -error[E0493]: destructor of `Option>` cannot be evaluated at compile-time - --> $DIR/drop-fail.rs:40:9 +error[E0493]: destructor of `Option` cannot be evaluated at compile-time + --> $DIR/drop-fail.rs:47:9 | LL | let mut tmp = None; | ^^^^^^^ the destructor for this type cannot be evaluated in constants diff --git a/tests/ui/consts/control-flow/drop-fail.rs b/tests/ui/consts/control-flow/drop-fail.rs index 2b73e37b23d03..3593e5af26b00 100644 --- a/tests/ui/consts/control-flow/drop-fail.rs +++ b/tests/ui/consts/control-flow/drop-fail.rs @@ -3,10 +3,17 @@ #![feature(const_destruct)] #![cfg_attr(precise, feature(const_precise_live_drops))] + +struct NotConstDestruct; + +impl Drop for NotConstDestruct { + fn drop(&mut self) {} +} + // `x` is *not* always moved into the final value and may be dropped inside the initializer. -const _: Option> = { - let y: Option> = None; - let x = Some(Vec::new()); +const _: Option = { + let y: Option = None; + let x = Some(NotConstDestruct); //[stock,precise]~^ ERROR destructor of if true { @@ -18,16 +25,16 @@ const _: Option> = { // We only clear `NeedsDrop` if a local is moved from in entirely. This is a shortcoming of the // existing analysis. -const _: Vec = { - let vec_tuple = (Vec::new(),); +const _: NotConstDestruct = { + let vec_tuple = (NotConstDestruct,); //[stock]~^ ERROR destructor of vec_tuple.0 }; // This applies to single-field enum variants as well. -const _: Vec = { - let x: Result<_, Vec> = Ok(Vec::new()); +const _: NotConstDestruct = { + let x: Result<_, NotConstDestruct> = Ok(NotConstDestruct); //[stock]~^ ERROR destructor of match x { @@ -35,8 +42,8 @@ const _: Vec = { } }; -const _: Option> = { - let mut some = Some(Vec::new()); +const _: Option = { + let mut some = Some(NotConstDestruct); let mut tmp = None; //[stock,precise]~^ ERROR destructor of diff --git a/tests/ui/consts/control-flow/drop-fail.stock.stderr b/tests/ui/consts/control-flow/drop-fail.stock.stderr index 8fe60fd736765..3caef5810939c 100644 --- a/tests/ui/consts/control-flow/drop-fail.stock.stderr +++ b/tests/ui/consts/control-flow/drop-fail.stock.stderr @@ -1,32 +1,32 @@ -error[E0493]: destructor of `Option>` cannot be evaluated at compile-time - --> $DIR/drop-fail.rs:9:9 +error[E0493]: destructor of `Option` cannot be evaluated at compile-time + --> $DIR/drop-fail.rs:16:9 | -LL | let x = Some(Vec::new()); +LL | let x = Some(NotConstDestruct); | ^ the destructor for this type cannot be evaluated in constants ... LL | }; | - value is dropped here -error[E0493]: destructor of `(Vec,)` cannot be evaluated at compile-time - --> $DIR/drop-fail.rs:22:9 +error[E0493]: destructor of `(NotConstDestruct,)` cannot be evaluated at compile-time + --> $DIR/drop-fail.rs:29:9 | -LL | let vec_tuple = (Vec::new(),); +LL | let vec_tuple = (NotConstDestruct,); | ^^^^^^^^^ the destructor for this type cannot be evaluated in constants ... LL | }; | - value is dropped here -error[E0493]: destructor of `Result, Vec>` cannot be evaluated at compile-time - --> $DIR/drop-fail.rs:30:9 +error[E0493]: destructor of `Result` cannot be evaluated at compile-time + --> $DIR/drop-fail.rs:37:9 | -LL | let x: Result<_, Vec> = Ok(Vec::new()); +LL | let x: Result<_, NotConstDestruct> = Ok(NotConstDestruct); | ^ the destructor for this type cannot be evaluated in constants ... LL | }; | - value is dropped here -error[E0493]: destructor of `Option>` cannot be evaluated at compile-time - --> $DIR/drop-fail.rs:40:9 +error[E0493]: destructor of `Option` cannot be evaluated at compile-time + --> $DIR/drop-fail.rs:47:9 | LL | let mut tmp = None; | ^^^^^^^ the destructor for this type cannot be evaluated in constants diff --git a/tests/ui/consts/miri_unleashed/assoc_const.rs b/tests/ui/consts/miri_unleashed/assoc_const.rs index 812207ee80900..753a53077e086 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.rs +++ b/tests/ui/consts/miri_unleashed/assoc_const.rs @@ -4,6 +4,13 @@ // a test demonstrating why we do need to run static const qualification on associated constants // instead of just checking the final constant + +struct NotConstDestruct; + +impl Drop for NotConstDestruct { + fn drop(&mut self) {} +} + trait Foo { const X: T; } @@ -15,18 +22,18 @@ trait Bar> { impl Foo for () { const X: u32 = 42; } -impl Foo> for String { - const X: Vec = Vec::new(); +impl Foo for NotConstDestruct { + const X: NotConstDestruct = NotConstDestruct; } impl Bar for () {} -impl Bar, String> for String {} +impl Bar for NotConstDestruct {} fn main() { // this is fine, but would have been forbidden by the static checks on `F` let x = <() as Bar>::F; // this test only causes errors due to the line below, so post-monomorphization - let y = , String>>::F; + let y = >::F; } //~? WARN skipping const checks diff --git a/tests/ui/consts/miri_unleashed/assoc_const.stderr b/tests/ui/consts/miri_unleashed/assoc_const.stderr index 0b276c8d70705..29f371373aef9 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const.stderr @@ -1,32 +1,32 @@ -error[E0080]: calling non-const function ` as Drop>::drop` - --> $DIR/assoc_const.rs:12:31 +error[E0080]: calling non-const function `::drop` + --> $DIR/assoc_const.rs:19:31 | LL | const F: u32 = (U::X, 42).1; - | ^ evaluation of `, std::string::String>>::F` failed inside this call + | ^ evaluation of `>::F` failed inside this call | -note: inside `std::ptr::drop_glue::<(Vec, u32)> - shim(Some((Vec, u32)))` +note: inside `std::ptr::drop_glue::<(NotConstDestruct, u32)> - shim(Some((NotConstDestruct, u32)))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `std::ptr::drop_glue::> - shim(Some(Vec))` +note: inside `std::ptr::drop_glue:: - shim(Some(NotConstDestruct))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: erroneous constant encountered - --> $DIR/assoc_const.rs:29:13 + --> $DIR/assoc_const.rs:36:13 | -LL | let y = , String>>::F; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let y = >::F; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/assoc_const.rs:29:13 + --> $DIR/assoc_const.rs:36:13 | -LL | let y = , String>>::F; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let y = >::F; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/assoc_const.rs:12:20 + --> $DIR/assoc_const.rs:19:20 | LL | const F: u32 = (U::X, 42).1; | ^^^^^^^^^^ diff --git a/tests/ui/consts/miri_unleashed/drop.rs b/tests/ui/consts/miri_unleashed/drop.rs index 0edd3a03c5996..dc7d3f5aa243e 100644 --- a/tests/ui/consts/miri_unleashed/drop.rs +++ b/tests/ui/consts/miri_unleashed/drop.rs @@ -2,20 +2,26 @@ use std::mem::ManuallyDrop; + +struct NotConstDestruct; + +impl Drop for NotConstDestruct { + fn drop(&mut self) {} +} + fn main() {} static TEST_OK: () = { - let v: Vec = Vec::new(); + let v: NotConstDestruct = NotConstDestruct; let _v = ManuallyDrop::new(v); }; // Make sure we catch executing bad drop functions. // The actual error is tested by the error-pattern above. static TEST_BAD: () = { - let _v: Vec = Vec::new(); -}; -//~^ NOTE failed inside this call -//~| ERROR calling non-const function ` as Drop>::drop` -//~| NOTE inside `std::ptr::drop_glue::> - shim(Some(Vec))` + let _v: NotConstDestruct = NotConstDestruct; +}; //~ NOTE failed inside this call + //~| ERROR calling non-const function `::drop` + //~| NOTE inside `std::ptr::drop_glue:: - shim(Some(NotConstDestruct))` //~? WARN skipping const checks diff --git a/tests/ui/consts/miri_unleashed/drop.stderr b/tests/ui/consts/miri_unleashed/drop.stderr index 2dfe75c468595..6e2afda763171 100644 --- a/tests/ui/consts/miri_unleashed/drop.stderr +++ b/tests/ui/consts/miri_unleashed/drop.stderr @@ -1,18 +1,18 @@ -error[E0080]: calling non-const function ` as Drop>::drop` - --> $DIR/drop.rs:16:1 +error[E0080]: calling non-const function `::drop` + --> $DIR/drop.rs:23:1 | LL | }; | ^ evaluation of `TEST_BAD` failed inside this call | -note: inside `std::ptr::drop_glue::> - shim(Some(Vec))` +note: inside `std::ptr::drop_glue:: - shim(Some(NotConstDestruct))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/drop.rs:15:9 + --> $DIR/drop.rs:22:9 | -LL | let _v: Vec = Vec::new(); +LL | let _v: NotConstDestruct = NotConstDestruct; | ^^ error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/consts/promote-not.stderr b/tests/ui/consts/promote-not.stderr index ec552d9dd7d48..ebe2a963a74b1 100644 --- a/tests/ui/consts/promote-not.stderr +++ b/tests/ui/consts/promote-not.stderr @@ -46,6 +46,10 @@ LL | let x = &String::new(); ... LL | }; | - value is dropped here + | + = note: see issue #133214 for more information + = help: add `#![feature(const_destruct)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0716]: temporary value dropped while borrowed --> $DIR/promote-not.rs:60:33 diff --git a/tests/ui/consts/promoted_const_call3.stderr b/tests/ui/consts/promoted_const_call3.stderr index 34c833d5bb77c..22d017abe6111 100644 --- a/tests/ui/consts/promoted_const_call3.stderr +++ b/tests/ui/consts/promoted_const_call3.stderr @@ -6,6 +6,10 @@ LL | let _: &'static _ = &String::new(); LL | LL | }; | - value is dropped here + | + = note: see issue #133214 for more information + = help: add `#![feature(const_destruct)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0493]: destructor of `String` cannot be evaluated at compile-time --> $DIR/promoted_const_call3.rs:8:30 @@ -14,6 +18,10 @@ LL | let _: &'static _ = &id(&String::new()); | ^^^^^^^^^^^^^ - value is dropped here | | | the destructor for this type cannot be evaluated in constants + | + = note: see issue #133214 for more information + = help: add `#![feature(const_destruct)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_const_call3.rs:13:26 diff --git a/tests/ui/consts/promoted_const_call5.stderr b/tests/ui/consts/promoted_const_call5.stderr index 1b5fa4352837e..b65422e44a510 100644 --- a/tests/ui/consts/promoted_const_call5.stderr +++ b/tests/ui/consts/promoted_const_call5.stderr @@ -5,6 +5,10 @@ LL | let _: &'static _ = &id(&new_string()); | ^^^^^^^^^^^^ - value is dropped here | | | the destructor for this type cannot be evaluated in constants + | + = note: see issue #133214 for more information + = help: add `#![feature(const_destruct)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_const_call5.rs:31:26 diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.rs b/tests/ui/consts/qualif-indirect-mutation-fail.rs index b70fca7b86430..00c9d4900f5f6 100644 --- a/tests/ui/consts/qualif-indirect-mutation-fail.rs +++ b/tests/ui/consts/qualif-indirect-mutation-fail.rs @@ -1,32 +1,38 @@ //@ compile-flags: --crate-type=lib #![feature(const_precise_live_drops)] +struct NotConstDestruct; + +impl Drop for NotConstDestruct { + fn drop(&mut self) {} +} + // Mutable borrow of a field with drop impl. pub const fn f() { - let mut a: (u32, Option) = (0, None); //~ ERROR destructor of + let mut a: (u32, Option) = (0, None); //~ ERROR destructor of let _ = &mut a.1; } // Mutable borrow of a type with drop impl. pub const A1: () = { let mut x = None; //~ ERROR destructor of - let mut y = Some(String::new()); + let mut y = Some(NotConstDestruct); let a = &mut x; let b = &mut y; std::mem::swap(a, b); std::mem::forget(y); -}; //~ ERROR calling non-const function ` as Drop>::drop` +}; //~ ERROR calling non-const function `::drop` // Mutable borrow of a type with drop impl. pub const A2: () = { let mut x = None; - let mut y = Some(String::new()); + let mut y = Some(NotConstDestruct); let a = &mut x; let b = &mut y; std::mem::swap(a, b); std::mem::forget(y); let _z = x; //~ ERROR destructor of -}; //~ ERROR calling non-const function ` as Drop>::drop` +}; //~ ERROR calling non-const function `::drop` // Shared borrow of a type that might be !Freeze and Drop. pub const fn g1() { @@ -43,19 +49,19 @@ pub const fn g2() { // Mutable raw reference to a Drop type. pub const fn address_of_mut() { - let mut x: Option = None; //~ ERROR destructor of + let mut x: Option = None; //~ ERROR destructor of &raw mut x; - let mut y: Option = None; //~ ERROR destructor of + let mut y: Option = None; //~ ERROR destructor of std::ptr::addr_of_mut!(y); } // Const raw reference to a Drop type. Conservatively assumed to allow mutation // until resolution of https://github.com/rust-lang/rust/issues/56604. pub const fn address_of_const() { - let x: Option = None; //~ ERROR destructor of + let x: Option = None; //~ ERROR destructor of &raw const x; - let y: Option = None; //~ ERROR destructor of + let y: Option = None; //~ ERROR destructor of std::ptr::addr_of!(y); } diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.stderr b/tests/ui/consts/qualif-indirect-mutation-fail.stderr index 102bbe03b2efd..9bf679f8a5348 100644 --- a/tests/ui/consts/qualif-indirect-mutation-fail.stderr +++ b/tests/ui/consts/qualif-indirect-mutation-fail.stderr @@ -1,5 +1,5 @@ -error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:12:9 +error[E0493]: destructor of `Option` cannot be evaluated at compile-time + --> $DIR/qualif-indirect-mutation-fail.rs:18:9 | LL | let mut x = None; | ^^^^^ the destructor for this type cannot be evaluated in constants @@ -7,51 +7,47 @@ LL | let mut x = None; LL | }; | - value is dropped here -error[E0080]: calling non-const function ` as Drop>::drop` - --> $DIR/qualif-indirect-mutation-fail.rs:18:1 +error[E0080]: calling non-const function `::drop` + --> $DIR/qualif-indirect-mutation-fail.rs:24:1 | LL | }; | ^ evaluation of `A1` failed inside this call | -note: inside `std::ptr::drop_glue::> - shim(Some(Option))` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `std::ptr::drop_glue:: - shim(Some(String))` +note: inside `std::ptr::drop_glue::> - shim(Some(Option))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `std::ptr::drop_glue::> - shim(Some(Vec))` +note: inside `std::ptr::drop_glue:: - shim(Some(NotConstDestruct))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:28:9 +error[E0493]: destructor of `Option` cannot be evaluated at compile-time + --> $DIR/qualif-indirect-mutation-fail.rs:34:9 | LL | let _z = x; | ^^ the destructor for this type cannot be evaluated in constants LL | }; | - value is dropped here -error[E0080]: calling non-const function ` as Drop>::drop` - --> $DIR/qualif-indirect-mutation-fail.rs:29:1 +error[E0080]: calling non-const function `::drop` + --> $DIR/qualif-indirect-mutation-fail.rs:35:1 | LL | }; | ^ evaluation of `A2` failed inside this call | -note: inside `std::ptr::drop_glue::> - shim(Some(Option))` +note: inside `std::ptr::drop_glue::> - shim(Some(Option))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `std::ptr::drop_glue:: - shim(Some(String))` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `std::ptr::drop_glue::> - shim(Some(Vec))` +note: inside `std::ptr::drop_glue:: - shim(Some(NotConstDestruct))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -error[E0493]: destructor of `(u32, Option)` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:6:9 +error[E0493]: destructor of `(u32, Option)` cannot be evaluated at compile-time + --> $DIR/qualif-indirect-mutation-fail.rs:12:9 | -LL | let mut a: (u32, Option) = (0, None); +LL | let mut a: (u32, Option) = (0, None); | ^^^^^ the destructor for this type cannot be evaluated in constant functions LL | let _ = &mut a.1; LL | } | - value is dropped here error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:33:9 + --> $DIR/qualif-indirect-mutation-fail.rs:39:9 | LL | let x: Option = None; | ^ the destructor for this type cannot be evaluated in constant functions @@ -60,44 +56,44 @@ LL | } | - value is dropped here error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:41:9 + --> $DIR/qualif-indirect-mutation-fail.rs:47:9 | LL | let _y = x; | ^^ the destructor for this type cannot be evaluated in constant functions LL | } | - value is dropped here -error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:49:9 +error[E0493]: destructor of `Option` cannot be evaluated at compile-time + --> $DIR/qualif-indirect-mutation-fail.rs:55:9 | -LL | let mut y: Option = None; +LL | let mut y: Option = None; | ^^^^^ the destructor for this type cannot be evaluated in constant functions LL | std::ptr::addr_of_mut!(y); LL | } | - value is dropped here -error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:46:9 +error[E0493]: destructor of `Option` cannot be evaluated at compile-time + --> $DIR/qualif-indirect-mutation-fail.rs:52:9 | -LL | let mut x: Option = None; +LL | let mut x: Option = None; | ^^^^^ the destructor for this type cannot be evaluated in constant functions ... LL | } | - value is dropped here -error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:59:9 +error[E0493]: destructor of `Option` cannot be evaluated at compile-time + --> $DIR/qualif-indirect-mutation-fail.rs:65:9 | -LL | let y: Option = None; +LL | let y: Option = None; | ^ the destructor for this type cannot be evaluated in constant functions LL | std::ptr::addr_of!(y); LL | } | - value is dropped here -error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:56:9 +error[E0493]: destructor of `Option` cannot be evaluated at compile-time + --> $DIR/qualif-indirect-mutation-fail.rs:62:9 | -LL | let x: Option = None; +LL | let x: Option = None; | ^ the destructor for this type cannot be evaluated in constant functions ... LL | } diff --git a/tests/ui/drop/repeat-drop-2.stderr b/tests/ui/drop/repeat-drop-2.stderr index cea7baf697664..ff2bc7fe6bf1d 100644 --- a/tests/ui/drop/repeat-drop-2.stderr +++ b/tests/ui/drop/repeat-drop-2.stderr @@ -6,6 +6,10 @@ LL | const _: [String; 0] = [String::new(); 0]; | || | |the destructor for this type cannot be evaluated in constants | value is dropped here + | + = note: see issue #133214 for more information + = help: add `#![feature(const_destruct)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0382]: use of moved value: `foo` --> $DIR/repeat-drop-2.rs:4:17 diff --git a/tests/ui/mir/drop-elaboration-after-borrowck-error.stderr b/tests/ui/mir/drop-elaboration-after-borrowck-error.stderr index 22d05fa4ddab0..a3b8b97b3ac0c 100644 --- a/tests/ui/mir/drop-elaboration-after-borrowck-error.stderr +++ b/tests/ui/mir/drop-elaboration-after-borrowck-error.stderr @@ -6,6 +6,10 @@ LL | a[0] = String::new(); | | | the destructor for this type cannot be evaluated in statics | value is dropped here + | + = note: see issue #133214 for more information + = help: add `#![feature(const_destruct)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0493]: destructor of `[String; 1]` cannot be evaluated at compile-time --> $DIR/drop-elaboration-after-borrowck-error.rs:5:9 @@ -15,6 +19,10 @@ LL | let a: [String; 1]; ... LL | }; | - value is dropped here + | + = note: see issue #133214 for more information + = help: add `#![feature(const_destruct)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0493]: destructor of `T` cannot be evaluated at compile-time --> $DIR/drop-elaboration-after-borrowck-error.rs:17:9 diff --git a/tests/ui/traits/const-traits/const-closure-with-indestructible-indestructible.next.stderr b/tests/ui/traits/const-traits/const-closure-with-indestructible-indestructible.next.stderr index 8b5c4f59fbdee..62d9091c50b10 100644 --- a/tests/ui/traits/const-traits/const-closure-with-indestructible-indestructible.next.stderr +++ b/tests/ui/traits/const-traits/const-closure-with-indestructible-indestructible.next.stderr @@ -1,20 +1,20 @@ -error[E0277]: the trait bound `Vec: const Destruct` is not satisfied - --> $DIR/const-closure-with-indestructible-indestructible.rs:10:16 +error[E0277]: the trait bound `NotConstDestruct: const Destruct` is not satisfied + --> $DIR/const-closure-with-indestructible-indestructible.rs:18:16 | LL | i_need(const || { | _________------_^ | | | | | required by a bound introduced by this call LL | | -LL | | let y = v; +LL | | let y = n; LL | | }) | |_________^ | note: required by a bound in `i_need` - --> $DIR/const-closure-with-indestructible-indestructible.rs:5:20 + --> $DIR/const-closure-with-indestructible-indestructible.rs:13:20 | -LL | const fn i_need(x: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `i_need` +LL | const fn i_need(x: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `i_need` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/const-closure-with-indestructible-indestructible.old.stderr b/tests/ui/traits/const-traits/const-closure-with-indestructible-indestructible.old.stderr index 8b5c4f59fbdee..62d9091c50b10 100644 --- a/tests/ui/traits/const-traits/const-closure-with-indestructible-indestructible.old.stderr +++ b/tests/ui/traits/const-traits/const-closure-with-indestructible-indestructible.old.stderr @@ -1,20 +1,20 @@ -error[E0277]: the trait bound `Vec: const Destruct` is not satisfied - --> $DIR/const-closure-with-indestructible-indestructible.rs:10:16 +error[E0277]: the trait bound `NotConstDestruct: const Destruct` is not satisfied + --> $DIR/const-closure-with-indestructible-indestructible.rs:18:16 | LL | i_need(const || { | _________------_^ | | | | | required by a bound introduced by this call LL | | -LL | | let y = v; +LL | | let y = n; LL | | }) | |_________^ | note: required by a bound in `i_need` - --> $DIR/const-closure-with-indestructible-indestructible.rs:5:20 + --> $DIR/const-closure-with-indestructible-indestructible.rs:13:20 | -LL | const fn i_need(x: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `i_need` +LL | const fn i_need(x: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `i_need` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/const-closure-with-indestructible-indestructible.rs b/tests/ui/traits/const-traits/const-closure-with-indestructible-indestructible.rs index d26260dd2d078..c6dcd119347d4 100644 --- a/tests/ui/traits/const-traits/const-closure-with-indestructible-indestructible.rs +++ b/tests/ui/traits/const-traits/const-closure-with-indestructible-indestructible.rs @@ -2,14 +2,22 @@ //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver #![feature(const_trait_impl, const_closures, const_destruct)] -const fn i_need(x: F) {} + + +struct NotConstDestruct; + +impl Drop for NotConstDestruct { + fn drop(&mut self) {} +} + +const fn i_need(x: F) {} fn main() { const { - let v = Vec::::new(); + let n = NotConstDestruct; i_need(const || { //~^ ERROR the trait bound - let y = v; + let y = n; }) }; }