diff --git a/compiler/rustc_const_eval/messages.ftl b/compiler/rustc_const_eval/messages.ftl index 8a6dfb89249..381569b37a2 100644 --- a/compiler/rustc_const_eval/messages.ftl +++ b/compiler/rustc_const_eval/messages.ftl @@ -230,9 +230,6 @@ const_eval_memory_exhausted = const_eval_modified_global = modifying a static's initial value from another static's initializer -const_eval_mut_deref = - mutation through a reference is not allowed in {const_eval_const_context}s - const_eval_mutable_ptr_in_final = encountered mutable pointer in final value of {const_eval_intern_kind} const_eval_nested_static_in_thread_local = #[thread_local] does not support implicit nested statics, please create explicit static items and refer to them instead @@ -363,10 +360,6 @@ const_eval_too_generic = const_eval_too_many_caller_args = calling a function with more arguments than it expected -const_eval_transient_mut_borrow = mutable references are not allowed in {const_eval_const_context}s - -const_eval_transient_mut_raw = raw mutable pointers are not allowed in {const_eval_const_context}s - const_eval_try_block_from_output_non_const = `try` block cannot convert `{$ty}` to the result in {const_eval_const_context}s const_eval_unallowed_fn_pointer_call = function pointer calls are not allowed in {const_eval_const_context}s diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index c20c2c60c1c..f477a058257 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -22,7 +22,6 @@ use rustc_span::{sym, Span, Symbol, DUMMY_SP}; use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::traits::{self, ObligationCauseCode, ObligationCtxt}; -use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitor}; use tracing::{debug, instrument, trace}; use super::ops::{self, NonConstOp, Status}; @@ -166,24 +165,6 @@ fn in_return_place( } } -struct LocalReturnTyVisitor<'a, 'mir, 'tcx> { - kind: LocalKind, - checker: &'a mut Checker<'mir, 'tcx>, -} - -impl<'a, 'mir, 'tcx> TypeVisitor> for LocalReturnTyVisitor<'a, 'mir, 'tcx> { - fn visit_ty(&mut self, t: Ty<'tcx>) { - match t.kind() { - ty::FnPtr(..) => {} - ty::Ref(_, _, hir::Mutability::Mut) => { - self.checker.check_op(ops::mut_ref::MutRef(self.kind)); - t.super_visit_with(self) - } - _ => t.super_visit_with(self), - } - } -} - pub struct Checker<'mir, 'tcx> { ccx: &'mir ConstCx<'mir, 'tcx>, qualifs: Qualifs<'mir, 'tcx>, @@ -230,25 +211,6 @@ pub fn check_body(&mut self) { return; } - // The local type and predicate checks are not free and only relevant for `const fn`s. - if self.const_kind() == hir::ConstContext::ConstFn { - for (idx, local) in body.local_decls.iter_enumerated() { - // Handle the return place below. - if idx == RETURN_PLACE { - continue; - } - - self.span = local.source_info.span; - self.check_local_or_return_ty(local.ty, idx); - } - - // impl trait is gone in MIR, so check the return type of a const fn by its signature - // instead of the type of the return place. - self.span = body.local_decls[RETURN_PLACE].source_info.span; - let return_ty = self.ccx.fn_sig().output(); - self.check_local_or_return_ty(return_ty.skip_binder(), RETURN_PLACE); - } - if !tcx.has_attr(def_id, sym::rustc_do_not_const_check) { self.visit_body(body); } @@ -358,16 +320,8 @@ fn check_static(&mut self, def_id: DefId, span: Span) { self.check_op_spanned(ops::StaticAccess, span) } - fn check_local_or_return_ty(&mut self, ty: Ty<'tcx>, local: Local) { - let kind = self.body.local_kind(local); - - let mut visitor = LocalReturnTyVisitor { kind, checker: self }; - - visitor.visit_ty(ty); - } - fn check_mut_borrow(&mut self, place: &Place<'_>, kind: hir::BorrowKind) { - match self.const_kind() { + let is_transient = match self.const_kind() { // In a const fn all borrows are transient or point to the places given via // references in the arguments (so we already checked them with // TransientMutBorrow/MutBorrow as appropriate). @@ -375,7 +329,7 @@ fn check_mut_borrow(&mut self, place: &Place<'_>, kind: hir::BorrowKind) { // NOTE: Once we have heap allocations during CTFE we need to figure out // how to prevent `const fn` to create long-lived allocations that point // to mutable memory. - hir::ConstContext::ConstFn => self.check_op(ops::TransientMutBorrow(kind)), + hir::ConstContext::ConstFn => true, _ => { // For indirect places, we are not creating a new permanent borrow, it's just as // transient as the already existing one. For reborrowing references this is handled @@ -389,12 +343,11 @@ fn check_mut_borrow(&mut self, place: &Place<'_>, kind: hir::BorrowKind) { // `StorageDead` in every control flow path leading to a `return` terminator. // The good news is that interning will detect if any unexpected mutable // pointer slips through. - if place.is_indirect() || self.local_is_transient(place.local) { - self.check_op(ops::TransientMutBorrow(kind)); - } else { - self.check_op(ops::MutBorrow(kind)); - } + place.is_indirect() || self.local_is_transient(place.local) } + }; + if !is_transient { + self.check_op(ops::EscapingMutBorrow(kind)); } } } @@ -636,58 +589,6 @@ fn visit_operand(&mut self, op: &Operand<'tcx>, location: Location) { } } } - fn visit_projection_elem( - &mut self, - place_ref: PlaceRef<'tcx>, - elem: PlaceElem<'tcx>, - context: PlaceContext, - location: Location, - ) { - trace!( - "visit_projection_elem: place_ref={:?} elem={:?} \ - context={:?} location={:?}", - place_ref, elem, context, location, - ); - - self.super_projection_elem(place_ref, elem, context, location); - - match elem { - ProjectionElem::Deref => { - let base_ty = place_ref.ty(self.body, self.tcx).ty; - if base_ty.is_unsafe_ptr() { - if place_ref.projection.is_empty() { - let decl = &self.body.local_decls[place_ref.local]; - // If this is a static, then this is not really dereferencing a pointer, - // just directly accessing a static. That is not subject to any feature - // gates (except for the one about whether statics can even be used, but - // that is checked already by `visit_operand`). - if let LocalInfo::StaticRef { .. } = *decl.local_info() { - return; - } - } - - // `*const T` is stable, `*mut T` is not - if !base_ty.is_mutable_ptr() { - return; - } - - self.check_op(ops::RawMutPtrDeref); - } - - if context.is_mutating_use() { - self.check_op(ops::MutDeref); - } - } - - ProjectionElem::ConstantIndex { .. } - | ProjectionElem::Downcast(..) - | ProjectionElem::OpaqueCast(..) - | ProjectionElem::Subslice { .. } - | ProjectionElem::Subtype(..) - | ProjectionElem::Field(..) - | ProjectionElem::Index(_) => {} - } - } fn visit_source_info(&mut self, source_info: &SourceInfo) { trace!("visit_source_info: source_info={:?}", source_info); diff --git a/compiler/rustc_const_eval/src/check_consts/ops.rs b/compiler/rustc_const_eval/src/check_consts/ops.rs index e8f10c88408..bd492244d95 100644 --- a/compiler/rustc_const_eval/src/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/check_consts/ops.rs @@ -8,7 +8,7 @@ use rustc_hir::def_id::DefId; use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::{ImplSource, Obligation, ObligationCause}; -use rustc_middle::mir::{self, CallSource}; +use rustc_middle::mir::CallSource; use rustc_middle::span_bug; use rustc_middle::ty::print::{with_no_trimmed_paths, PrintTraitRefExt as _}; use rustc_middle::ty::{ @@ -431,9 +431,9 @@ fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { /// This op is for `&mut` borrows in the trailing expression of a constant /// which uses the "enclosing scopes rule" to leak its locals into anonymous /// static or const items. -pub(crate) struct MutBorrow(pub hir::BorrowKind); +pub(crate) struct EscapingMutBorrow(pub hir::BorrowKind); -impl<'tcx> NonConstOp<'tcx> for MutBorrow { +impl<'tcx> NonConstOp<'tcx> for EscapingMutBorrow { fn status_in_item(&self, _ccx: &ConstCx<'_, 'tcx>) -> Status { Status::Forbidden } @@ -460,49 +460,6 @@ fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { } } -#[derive(Debug)] -pub(crate) struct TransientMutBorrow(pub hir::BorrowKind); - -impl<'tcx> NonConstOp<'tcx> for TransientMutBorrow { - fn status_in_item(&self, _: &ConstCx<'_, 'tcx>) -> Status { - Status::Unstable(sym::const_mut_refs) - } - - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { - let kind = ccx.const_kind(); - match self.0 { - hir::BorrowKind::Raw => ccx - .tcx - .sess - .create_feature_err(errors::TransientMutRawErr { span, kind }, sym::const_mut_refs), - hir::BorrowKind::Ref => ccx.tcx.sess.create_feature_err( - errors::TransientMutBorrowErr { span, kind }, - sym::const_mut_refs, - ), - } - } -} - -#[derive(Debug)] -pub(crate) struct MutDeref; -impl<'tcx> NonConstOp<'tcx> for MutDeref { - fn status_in_item(&self, _: &ConstCx<'_, 'tcx>) -> Status { - Status::Unstable(sym::const_mut_refs) - } - - fn importance(&self) -> DiagImportance { - // Usually a side-effect of a `TransientMutBorrow` somewhere. - DiagImportance::Secondary - } - - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { - ccx.tcx.sess.create_feature_err( - errors::MutDerefErr { span, kind: ccx.const_kind() }, - sym::const_mut_refs, - ) - } -} - /// A call to a `panic()` lang item where the first argument is _not_ a `&str`. #[derive(Debug)] pub(crate) struct PanicNonStr; @@ -524,24 +481,6 @@ fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { } } -#[derive(Debug)] -pub(crate) struct RawMutPtrDeref; -impl<'tcx> NonConstOp<'tcx> for RawMutPtrDeref { - fn status_in_item(&self, _: &ConstCx<'_, '_>) -> Status { - Status::Unstable(sym::const_mut_refs) - } - - #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { - feature_err( - &ccx.tcx.sess, - sym::const_mut_refs, - span, - format!("dereferencing raw mutable pointers in {}s is unstable", ccx.const_kind(),), - ) - } -} - /// Casting raw pointer or function pointer to an integer. /// Not currently intended to ever be allowed, even behind a feature gate: operation depends on /// allocation base addresses that are not known at compile-time. @@ -588,33 +527,3 @@ fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { ccx.dcx().create_err(errors::ThreadLocalAccessErr { span }) } } - -/// Types that cannot appear in the signature or locals of a `const fn`. -pub(crate) mod mut_ref { - use super::*; - - #[derive(Debug)] - pub(crate) struct MutRef(pub mir::LocalKind); - impl<'tcx> NonConstOp<'tcx> for MutRef { - fn status_in_item(&self, _ccx: &ConstCx<'_, 'tcx>) -> Status { - Status::Unstable(sym::const_mut_refs) - } - - fn importance(&self) -> DiagImportance { - match self.0 { - mir::LocalKind::Temp => DiagImportance::Secondary, - mir::LocalKind::ReturnPointer | mir::LocalKind::Arg => DiagImportance::Primary, - } - } - - #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { - feature_err( - &ccx.tcx.sess, - sym::const_mut_refs, - span, - format!("mutable references are not allowed in {}s", ccx.const_kind()), - ) - } - } -} diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs index 57e52254757..4e2b727cf9f 100644 --- a/compiler/rustc_const_eval/src/errors.rs +++ b/compiler/rustc_const_eval/src/errors.rs @@ -93,30 +93,6 @@ pub(crate) struct PanicNonStrErr { pub span: Span, } -#[derive(Diagnostic)] -#[diag(const_eval_mut_deref, code = E0658)] -pub(crate) struct MutDerefErr { - #[primary_span] - pub span: Span, - pub kind: ConstContext, -} - -#[derive(Diagnostic)] -#[diag(const_eval_transient_mut_borrow, code = E0658)] -pub(crate) struct TransientMutBorrowErr { - #[primary_span] - pub span: Span, - pub kind: ConstContext, -} - -#[derive(Diagnostic)] -#[diag(const_eval_transient_mut_raw, code = E0658)] -pub(crate) struct TransientMutRawErr { - #[primary_span] - pub span: Span, - pub kind: ConstContext, -} - #[derive(Diagnostic)] #[diag(const_eval_max_num_nodes_in_const)] pub(crate) struct MaxNumNodesInConstErr { diff --git a/compiler/rustc_error_codes/src/error_codes/E0764.md b/compiler/rustc_error_codes/src/error_codes/E0764.md index 152627cf654..4d5091cd954 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0764.md +++ b/compiler/rustc_error_codes/src/error_codes/E0764.md @@ -3,8 +3,6 @@ A mutable reference was used in a constant. Erroneous code example: ```compile_fail,E0764 -#![feature(const_mut_refs)] - fn main() { const OH_NO: &'static mut usize = &mut 1; // error! } @@ -26,8 +24,6 @@ Remember: you cannot use a function call inside a constant or static. However, you can totally use it in constant functions: ``` -#![feature(const_mut_refs)] - const fn foo(x: usize) -> usize { let mut y = 1; let z = &mut y; diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 468ea81524a..b5c86b8519d 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -143,6 +143,8 @@ macro_rules! declare_features { (accepted, const_let, "1.33.0", Some(48821)), /// Allows the use of `loop` and `while` in constants. (accepted, const_loop, "1.46.0", Some(52000)), + /// Allows using `&mut` in constant functions. + (accepted, const_mut_refs, "CURRENT_RUSTC_VERSION", Some(57349)), /// Allows panicking during const eval (producing compile-time errors). (accepted, const_panic, "1.57.0", Some(51999)), /// Allows dereferencing raw pointers during const eval. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 05856dca491..57e77aa0fc5 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -403,8 +403,6 @@ pub fn internal(&self, feature: Symbol) -> bool { (incomplete, const_closures, "1.68.0", Some(106003)), /// Allows `for _ in _` loops in const contexts. (unstable, const_for, "1.56.0", Some(87575)), - /// Allows using `&mut` in constant functions. - (unstable, const_mut_refs, "1.41.0", Some(57349)), /// Be more precise when looking for live drops in a const context. (unstable, const_precise_live_drops, "1.46.0", Some(73255)), /// Allows references to types with interior mutability within constants diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 7aaa4e73df7..a67ea75825d 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -164,13 +164,13 @@ // // Language features: // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(const_mut_refs))] #![cfg_attr(not(test), feature(coroutine_trait))] #![cfg_attr(test, feature(panic_update_hook))] #![cfg_attr(test, feature(test))] #![feature(allocator_internals)] #![feature(allow_internal_unstable)] #![feature(cfg_sanitize)] -#![feature(const_mut_refs)] #![feature(const_precise_live_drops)] #![feature(const_ptr_write)] #![feature(const_try)] diff --git a/library/alloc/tests/lib.rs b/library/alloc/tests/lib.rs index c5c6a122cfe..ffc9a233b66 100644 --- a/library/alloc/tests/lib.rs +++ b/library/alloc/tests/lib.rs @@ -6,7 +6,7 @@ #![feature(cow_is_borrowed)] #![feature(const_cow_is_borrowed)] #![feature(const_heap)] -#![feature(const_mut_refs)] +#![cfg_attr(bootstrap, feature(const_mut_refs))] #![feature(const_slice_from_raw_parts_mut)] #![feature(const_ptr_write)] #![feature(const_try)] diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 5b5d5d1a961..d503e58423f 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -191,6 +191,7 @@ // // Language features: // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(const_mut_refs))] #![feature(abi_unadjusted)] #![feature(adt_const_params)] #![feature(allow_internal_unsafe)] @@ -201,7 +202,6 @@ #![feature(cfg_target_has_atomic_equal_alignment)] #![feature(cfg_ub_checks)] #![feature(const_for)] -#![feature(const_mut_refs)] #![feature(const_precise_live_drops)] #![feature(const_refs_to_cell)] #![feature(decl_macro)] diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index ddb9195d2e7..5fa3b9bf61f 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -1569,7 +1569,7 @@ pub const fn align_offset(self, align: usize) -> usize /// /// ``` /// #![feature(const_pointer_is_aligned)] - /// #![feature(const_mut_refs)] + /// # #![cfg_attr(bootstrap, feature(const_mut_refs))] /// /// // On some platforms, the alignment of primitives is less than their size. /// #[repr(align(4))] @@ -1695,7 +1695,7 @@ pub const fn is_aligned(self) -> bool /// ``` /// #![feature(pointer_is_aligned_to)] /// #![feature(const_pointer_is_aligned)] - /// #![feature(const_mut_refs)] + /// # #![cfg_attr(bootstrap, feature(const_mut_refs))] /// /// // On some platforms, the alignment of i32 is less than 4. /// #[repr(align(4))] diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index dbceb8abafc..948ea9bc098 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -1,4 +1,5 @@ // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(const_mut_refs))] #![cfg_attr(target_has_atomic = "128", feature(integer_atomics))] #![cfg_attr(test, feature(cfg_match))] #![feature(alloc_layout_extra)] @@ -26,7 +27,6 @@ #![feature(const_ipv6)] #![feature(const_likely)] #![feature(const_maybe_uninit_as_mut_ptr)] -#![feature(const_mut_refs)] #![feature(const_nonnull_new)] #![feature(const_option)] #![feature(const_option_ext)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 60969af3e85..bc5369ddc3d 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -272,6 +272,7 @@ // // Language features: // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(const_mut_refs))] #![feature(alloc_error_handler)] #![feature(allocator_internals)] #![feature(allow_internal_unsafe)] @@ -281,7 +282,6 @@ #![feature(cfg_target_thread_local)] #![feature(cfi_encoding)] #![feature(concat_idents)] -#![feature(const_mut_refs)] #![feature(decl_macro)] #![feature(deprecated_suggestion)] #![feature(doc_cfg)] diff --git a/src/tools/clippy/tests/ui/arithmetic_side_effects.rs b/src/tools/clippy/tests/ui/arithmetic_side_effects.rs index 9d06e14e88c..0838d064a5f 100644 --- a/src/tools/clippy/tests/ui/arithmetic_side_effects.rs +++ b/src/tools/clippy/tests/ui/arithmetic_side_effects.rs @@ -1,5 +1,8 @@ //@aux-build:proc_macro_derive.rs +#![feature(f128)] +#![feature(f16)] + #![allow( clippy::assign_op_pattern, clippy::erasing_op, @@ -10,9 +13,6 @@ arithmetic_overflow, unconditional_panic )] -#![feature(const_mut_refs)] -#![feature(f128)] -#![feature(f16)] #![warn(clippy::arithmetic_side_effects)] extern crate proc_macro_derive; diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.fixed b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.fixed index 0aef4d31fd9..41b424a8e5d 100644 --- a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.fixed +++ b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.fixed @@ -1,7 +1,6 @@ #![warn(clippy::missing_const_for_fn)] #![allow(incomplete_features, clippy::let_and_return, clippy::missing_transmute_annotations)] #![allow(unsupported_calling_conventions)] -#![feature(const_mut_refs)] #![feature(const_trait_impl)] use std::mem::transmute; diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs index 4246494fe72..27593575a01 100644 --- a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs +++ b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs @@ -1,7 +1,6 @@ #![warn(clippy::missing_const_for_fn)] #![allow(incomplete_features, clippy::let_and_return, clippy::missing_transmute_annotations)] #![allow(unsupported_calling_conventions)] -#![feature(const_mut_refs)] #![feature(const_trait_impl)] use std::mem::transmute; diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr index 6bc71e29840..12d97b17119 100644 --- a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr +++ b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr @@ -1,5 +1,5 @@ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:15:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:14:5 | LL | / pub fn new() -> Self { LL | | @@ -16,7 +16,7 @@ LL | pub const fn new() -> Self { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:21:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:20:5 | LL | / fn const_generic_params<'a, T, const N: usize>(&self, b: &'a [T; N]) -> &'a [T; N] { LL | | @@ -30,7 +30,7 @@ LL | const fn const_generic_params<'a, T, const N: usize>(&self, b: &'a [T; | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:28:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:27:1 | LL | / fn one() -> i32 { LL | | @@ -44,7 +44,7 @@ LL | const fn one() -> i32 { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:34:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:33:1 | LL | / fn two() -> i32 { LL | | @@ -59,7 +59,7 @@ LL | const fn two() -> i32 { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:41:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:40:1 | LL | / fn string() -> String { LL | | @@ -73,7 +73,7 @@ LL | const fn string() -> String { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:47:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:46:1 | LL | / unsafe fn four() -> i32 { LL | | @@ -87,7 +87,7 @@ LL | const unsafe fn four() -> i32 { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:53:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:52:1 | LL | / fn generic(t: T) -> T { LL | | @@ -101,7 +101,7 @@ LL | const fn generic(t: T) -> T { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:62:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:61:1 | LL | / fn generic_arr(t: [T; 1]) -> T { LL | | @@ -115,7 +115,7 @@ LL | const fn generic_arr(t: [T; 1]) -> T { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:76:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:75:9 | LL | / pub fn b(self, a: &A) -> B { LL | | @@ -129,7 +129,7 @@ LL | pub const fn b(self, a: &A) -> B { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:86:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:85:5 | LL | / fn const_fn_stabilized_before_msrv(byte: u8) { LL | | @@ -143,7 +143,7 @@ LL | const fn const_fn_stabilized_before_msrv(byte: u8) { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:98:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:97:1 | LL | / fn msrv_1_46() -> i32 { LL | | @@ -157,7 +157,7 @@ LL | const fn msrv_1_46() -> i32 { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:118:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:117:1 | LL | fn d(this: D) {} | ^^^^^^^^^^^^^^^^ @@ -168,7 +168,7 @@ LL | const fn d(this: D) {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:126:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:125:9 | LL | / fn deref_ptr_can_be_const(self) -> usize { LL | | @@ -182,7 +182,7 @@ LL | const fn deref_ptr_can_be_const(self) -> usize { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:131:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:130:9 | LL | / fn deref_copied_val(self) -> usize { LL | | @@ -196,7 +196,7 @@ LL | const fn deref_copied_val(self) -> usize { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:142:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:141:5 | LL | / fn union_access_can_be_const() { LL | | @@ -211,7 +211,7 @@ LL | const fn union_access_can_be_const() { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:150:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:149:9 | LL | extern "C" fn c() {} | ^^^^^^^^^^^^^^^^^^^^ @@ -222,7 +222,7 @@ LL | const extern "C" fn c() {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:154:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:153:9 | LL | extern fn implicit_c() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -233,7 +233,7 @@ LL | const extern fn implicit_c() {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:171:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:170:9 | LL | / pub fn new(strings: Vec) -> Self { LL | | Self { strings } @@ -246,7 +246,7 @@ LL | pub const fn new(strings: Vec) -> Self { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:176:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:175:9 | LL | / pub fn empty() -> Self { LL | | Self { strings: Vec::new() } @@ -259,7 +259,7 @@ LL | pub const fn empty() -> Self { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:187:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:186:9 | LL | / pub fn new(text: String) -> Self { LL | | let vec = Vec::new(); @@ -273,7 +273,7 @@ LL | pub const fn new(text: String) -> Self { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:206:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:205:5 | LL | fn alias_ty_is_projection(bar: <() as FooTrait>::Foo) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -284,7 +284,7 @@ LL | const fn alias_ty_is_projection(bar: <() as FooTrait>::Foo) {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:210:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:209:5 | LL | extern "C-unwind" fn c_unwind() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -295,7 +295,7 @@ LL | const extern "C-unwind" fn c_unwind() {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:212:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:211:5 | LL | extern "system" fn system() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -306,7 +306,7 @@ LL | const extern "system" fn system() {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:214:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:213:5 | LL | extern "system-unwind" fn system_unwind() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -317,7 +317,7 @@ LL | const extern "system-unwind" fn system_unwind() {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:216:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:215:5 | LL | pub extern "stdcall" fn std_call() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -328,7 +328,7 @@ LL | pub const extern "stdcall" fn std_call() {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:218:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:217:5 | LL | pub extern "stdcall-unwind" fn std_call_unwind() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/tidy/src/issues.txt b/src/tools/tidy/src/issues.txt index 5205fa14294..bdc37ce3212 100644 --- a/src/tools/tidy/src/issues.txt +++ b/src/tools/tidy/src/issues.txt @@ -675,8 +675,6 @@ ui/consts/auxiliary/issue-17718-aux.rs ui/consts/auxiliary/issue-63226.rs ui/consts/const-eval/issue-100878.rs ui/consts/const-eval/issue-104390.rs -ui/consts/const-eval/issue-114994-fail.rs -ui/consts/const-eval/issue-114994.rs ui/consts/const-eval/issue-43197.rs ui/consts/const-eval/issue-44578.rs ui/consts/const-eval/issue-47971.rs diff --git a/tests/ui/const-generics/issues/issue-100313.rs b/tests/ui/const-generics/issues/issue-100313.rs index e07fde76a4a..553165f90b8 100644 --- a/tests/ui/const-generics/issues/issue-100313.rs +++ b/tests/ui/const-generics/issues/issue-100313.rs @@ -1,5 +1,4 @@ #![allow(incomplete_features)] -#![feature(const_mut_refs)] #![feature(adt_const_params, unsized_const_params)] struct T; diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr index a422764fe2c..6e419078e5e 100644 --- a/tests/ui/const-generics/issues/issue-100313.stderr +++ b/tests/ui/const-generics/issues/issue-100313.stderr @@ -1,16 +1,16 @@ error[E0080]: evaluation of constant value failed - --> $DIR/issue-100313.rs:10:13 + --> $DIR/issue-100313.rs:9:13 | LL | *(B as *const bool as *mut bool) = false; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ writing to ALLOC0 which is read-only | note: inside `T::<&true>::set_false` - --> $DIR/issue-100313.rs:10:13 + --> $DIR/issue-100313.rs:9:13 | LL | *(B as *const bool as *mut bool) = false; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: inside `_` - --> $DIR/issue-100313.rs:18:5 + --> $DIR/issue-100313.rs:17:5 | LL | x.set_false(); | ^^^^^^^^^^^^^ diff --git a/tests/ui/consts/auxiliary/const_mut_refs_crate.rs b/tests/ui/consts/auxiliary/const_mut_refs_crate.rs index 8e78748e896..d8e4b74d73c 100644 --- a/tests/ui/consts/auxiliary/const_mut_refs_crate.rs +++ b/tests/ui/consts/auxiliary/const_mut_refs_crate.rs @@ -10,8 +10,6 @@ // See also ../const-mut-refs-crate.rs for more details // about this test. -#![feature(const_mut_refs)] - // if we used immutable references here, then promotion would // turn the `&42` into a promoted, which gets duplicated arbitrarily. pub static mut FOO: &'static mut i32 = &mut 42; diff --git a/tests/ui/consts/const-address-of-mut.rs b/tests/ui/consts/const-address-of-mut.rs index c3f37843d3c..2dd909b4ce7 100644 --- a/tests/ui/consts/const-address-of-mut.rs +++ b/tests/ui/consts/const-address-of-mut.rs @@ -1,10 +1,12 @@ -const A: () = { let mut x = 2; &raw mut x; }; //~ mutable pointer +//@check-pass -static B: () = { let mut x = 2; &raw mut x; }; //~ mutable pointer +const A: () = { let mut x = 2; &raw mut x; }; + +static B: () = { let mut x = 2; &raw mut x; }; const fn foo() { let mut x = 0; - let y = &raw mut x; //~ mutable pointer + let y = &raw mut x; } fn main() {} diff --git a/tests/ui/consts/const-address-of-mut.stderr b/tests/ui/consts/const-address-of-mut.stderr deleted file mode 100644 index d4243485de1..00000000000 --- a/tests/ui/consts/const-address-of-mut.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0658]: raw mutable pointers are not allowed in constants - --> $DIR/const-address-of-mut.rs:1:32 - | -LL | const A: () = { let mut x = 2; &raw mut x; }; - | ^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: raw mutable pointers are not allowed in statics - --> $DIR/const-address-of-mut.rs:3:33 - | -LL | static B: () = { let mut x = 2; &raw mut x; }; - | ^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: raw mutable pointers are not allowed in constant functions - --> $DIR/const-address-of-mut.rs:7:13 - | -LL | let y = &raw mut x; - | ^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 3 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs index ac9e8b64b48..9cf9360dcbd 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs @@ -1,6 +1,5 @@ #![feature(core_intrinsics)] #![feature(const_heap)] -#![feature(const_mut_refs)] use std::intrinsics; const FOO: i32 = foo(); diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr index cdde14756e4..2fd7222da52 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr @@ -1,16 +1,16 @@ error[E0080]: evaluation of constant value failed - --> $DIR/alloc_intrinsic_errors.rs:9:17 + --> $DIR/alloc_intrinsic_errors.rs:8:17 | LL | let _ = intrinsics::const_allocate(4, 3) as *mut i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid align passed to `const_allocate`: 3 is not a power of 2 | note: inside `foo` - --> $DIR/alloc_intrinsic_errors.rs:9:17 + --> $DIR/alloc_intrinsic_errors.rs:8:17 | LL | let _ = intrinsics::const_allocate(4, 3) as *mut i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: inside `FOO` - --> $DIR/alloc_intrinsic_errors.rs:6:18 + --> $DIR/alloc_intrinsic_errors.rs:5:18 | LL | const FOO: i32 = foo(); | ^^^^^ diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient.rs index 0c292ec5af7..83ed496ac2c 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(core_intrinsics)] #![feature(const_heap)] -#![feature(const_mut_refs)] use std::intrinsics; const FOO: &i32 = foo(); diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_transient.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_transient.rs index 1ba20f908ea..69e980eb13d 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_transient.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_transient.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(core_intrinsics)] #![feature(const_heap)] -#![feature(const_mut_refs)] use std::intrinsics; const FOO: i32 = foo(); diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr index 383c167d3c0..271c8611091 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc_intrinsic_uninit.rs:8:1 + --> $DIR/alloc_intrinsic_uninit.rs:7:1 | LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; | ^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized memory, but expected an integer diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr index d0679228326..ec7cc7d4140 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc_intrinsic_uninit.rs:8:1 + --> $DIR/alloc_intrinsic_uninit.rs:7:1 | LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; | ^^^^^^^^^^^^^^^ constructing invalid value at .: encountered uninitialized memory, but expected an integer diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs index ed483bccc1f..c283a5fae7d 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs @@ -2,7 +2,6 @@ // compile-test #![feature(core_intrinsics)] #![feature(const_heap)] -#![feature(const_mut_refs)] use std::intrinsics; const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs index 7be14e3cff7..26cb69e458b 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs @@ -1,9 +1,8 @@ // We unleash Miri here since this test demonstrates code that bypasses the checks against interning -// mutable pointers, which currently ICEs. Unleashing Miri silence the ICE. +// mutable pointers, which currently ICEs. Unleashing Miri silences the ICE. //@ compile-flags: -Zunleash-the-miri-inside-of-you #![feature(core_intrinsics)] #![feature(const_heap)] -#![feature(const_mut_refs)] use std::intrinsics; const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 }; diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr index 119198bd347..0dc49dc3cd8 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr @@ -1,5 +1,5 @@ error: encountered mutable pointer in final value of constant - --> $DIR/alloc_intrinsic_untyped.rs:9:1 + --> $DIR/alloc_intrinsic_untyped.rs:8:1 | LL | const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 }; | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic.rs b/tests/ui/consts/const-eval/heap/dealloc_intrinsic.rs index 345fc096ca1..3cc035c66d3 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(core_intrinsics)] #![feature(const_heap)] -#![feature(const_mut_refs)] use std::intrinsics; diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs index da7ab7f8ba4..3054e79770d 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs @@ -1,6 +1,5 @@ #![feature(core_intrinsics)] #![feature(const_heap)] -#![feature(const_mut_refs)] // Strip out raw byte dumps to make comparison platform-independent: //@ normalize-stderr-test: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr index a42c26c0a8d..0b0d2676dd3 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/dealloc_intrinsic_dangling.rs:12:1 + --> $DIR/dealloc_intrinsic_dangling.rs:11:1 | LL | const _X: &'static u8 = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free) @@ -10,7 +10,7 @@ LL | const _X: &'static u8 = unsafe { } error[E0080]: evaluation of constant value failed - --> $DIR/dealloc_intrinsic_dangling.rs:23:5 + --> $DIR/dealloc_intrinsic_dangling.rs:22:5 | LL | *reference | ^^^^^^^^^^ memory access failed: ALLOC1 has been freed, so this pointer is dangling diff --git a/tests/ui/consts/const-eval/issue-114994-fail.rs b/tests/ui/consts/const-eval/issue-114994-fail.rs deleted file mode 100644 index 1b9abec3571..00000000000 --- a/tests/ui/consts/const-eval/issue-114994-fail.rs +++ /dev/null @@ -1,14 +0,0 @@ -// This checks that function pointer signatures that are referenced mutably -// but contain a &mut T parameter still fail in a constant context: see issue #114994. -// -//@ check-fail - -const fn use_mut_const_fn(_f: &mut fn(&mut String)) { //~ ERROR mutable references are not allowed in constant functions - () -} - -const fn use_mut_const_tuple_fn(_f: (fn(), &mut u32)) { //~ ERROR mutable references are not allowed in constant functions - -} - -fn main() {} diff --git a/tests/ui/consts/const-eval/issue-114994-fail.stderr b/tests/ui/consts/const-eval/issue-114994-fail.stderr deleted file mode 100644 index 70b224b9b4c..00000000000 --- a/tests/ui/consts/const-eval/issue-114994-fail.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0658]: mutable references are not allowed in constant functions - --> $DIR/issue-114994-fail.rs:6:27 - | -LL | const fn use_mut_const_fn(_f: &mut fn(&mut String)) { - | ^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: mutable references are not allowed in constant functions - --> $DIR/issue-114994-fail.rs:10:33 - | -LL | const fn use_mut_const_tuple_fn(_f: (fn(), &mut u32)) { - | ^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/const-eval/issue-114994.rs b/tests/ui/consts/const-eval/issue-114994.rs deleted file mode 100644 index 5d99f265e62..00000000000 --- a/tests/ui/consts/const-eval/issue-114994.rs +++ /dev/null @@ -1,18 +0,0 @@ -// This checks that function pointer signatures containing &mut T types -// work in a constant context: see issue #114994. -// -//@ check-pass - -const fn use_const_fn(_f: fn(&mut String)) { - () -} - -const fn get_some_fn() -> fn(&mut String) { - String::clear -} - -const fn some_const_fn() { - let _f: fn(&mut String) = String::clear; -} - -fn main() {} diff --git a/tests/ui/consts/const-eval/issue-65394.rs b/tests/ui/consts/const-eval/issue-65394.rs index e6639826cb2..2304dbebc7e 100644 --- a/tests/ui/consts/const-eval/issue-65394.rs +++ b/tests/ui/consts/const-eval/issue-65394.rs @@ -1,11 +1,16 @@ +//@ revisions: stock precise_drops +//@[precise_drops] check-pass + // This test originated from #65394. We conservatively assume that `x` is still `LiveDrop` even // after it has been moved because a mutable reference to it exists at some point in the const body. // -// We will likely have to change this behavior before we allow `&mut` in a `const`. +// With `&mut` in `const` being stable, this surprising behavior is now observable. +// `const_precise_live_drops` fixes that. +#![cfg_attr(precise_drops, feature(const_precise_live_drops))] const _: Vec = { - let mut x = Vec::::new(); //~ ERROR destructor of - let r = &mut x; //~ ERROR mutable references are not allowed in constants + let mut x = Vec::::new(); //[stock]~ ERROR destructor of + let r = &mut x; let y = x; y }; diff --git a/tests/ui/consts/const-eval/issue-65394.stderr b/tests/ui/consts/const-eval/issue-65394.stderr deleted file mode 100644 index 1fa4da4a78b..00000000000 --- a/tests/ui/consts/const-eval/issue-65394.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0658]: mutable references are not allowed in constants - --> $DIR/issue-65394.rs:8:13 - | -LL | let r = &mut x; - | ^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 `Vec` cannot be evaluated at compile-time - --> $DIR/issue-65394.rs:7:9 - | -LL | let mut x = Vec::::new(); - | ^^^^^ the destructor for this type cannot be evaluated in constants -... -LL | }; - | - value is dropped here - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0493, E0658. -For more information about an error, try `rustc --explain E0493`. diff --git a/tests/ui/consts/const-eval/issue-65394.stock.stderr b/tests/ui/consts/const-eval/issue-65394.stock.stderr new file mode 100644 index 00000000000..f33593862a7 --- /dev/null +++ b/tests/ui/consts/const-eval/issue-65394.stock.stderr @@ -0,0 +1,12 @@ +error[E0493]: destructor of `Vec` cannot be evaluated at compile-time + --> $DIR/issue-65394.rs:12:9 + | +LL | let mut x = Vec::::new(); + | ^^^^^ the destructor for this type cannot be evaluated in constants +... +LL | }; + | - value is dropped here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/consts/const-eval/mod-static-with-const-fn.rs b/tests/ui/consts/const-eval/mod-static-with-const-fn.rs index b6b74e67d20..7de9d44305d 100644 --- a/tests/ui/consts/const-eval/mod-static-with-const-fn.rs +++ b/tests/ui/consts/const-eval/mod-static-with-const-fn.rs @@ -1,8 +1,6 @@ // New test for #53818: modifying static memory at compile-time is not allowed. // The test should never compile successfully -#![feature(const_mut_refs)] - use std::cell::UnsafeCell; struct Foo(UnsafeCell); diff --git a/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr b/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr index 901ae1922c7..47bfc235a1a 100644 --- a/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr +++ b/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr @@ -1,5 +1,5 @@ error[E0080]: could not evaluate static initializer - --> $DIR/mod-static-with-const-fn.rs:16:5 + --> $DIR/mod-static-with-const-fn.rs:14:5 | LL | *FOO.0.get() = 5; | ^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer diff --git a/tests/ui/consts/const-eval/nrvo.rs b/tests/ui/consts/const-eval/nrvo.rs index 02288d8d60c..e37fe2d8238 100644 --- a/tests/ui/consts/const-eval/nrvo.rs +++ b/tests/ui/consts/const-eval/nrvo.rs @@ -4,8 +4,6 @@ // its address may be taken and it may be written to indirectly. Ensure that the const-eval // interpreter can handle this. -#![feature(const_mut_refs)] - #[inline(never)] // Try to ensure that MIR optimizations don't optimize this away. const fn init(buf: &mut [u8; 1024]) { buf[33] = 3; diff --git a/tests/ui/consts/const-eval/partial_ptr_overwrite.rs b/tests/ui/consts/const-eval/partial_ptr_overwrite.rs index d6c76886853..1e99d84bba4 100644 --- a/tests/ui/consts/const-eval/partial_ptr_overwrite.rs +++ b/tests/ui/consts/const-eval/partial_ptr_overwrite.rs @@ -1,5 +1,4 @@ // Test for the behavior described in . -#![feature(const_mut_refs)] const PARTIAL_OVERWRITE: () = { let mut p = &42; diff --git a/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr b/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr index 3203ca764bb..1443d353848 100644 --- a/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr +++ b/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/partial_ptr_overwrite.rs:8:9 + --> $DIR/partial_ptr_overwrite.rs:7:9 | LL | *(ptr as *mut u8) = 123; | ^^^^^^^^^^^^^^^^^^^^^^^ unable to overwrite parts of a pointer in memory at ALLOC0 diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.rs b/tests/ui/consts/const-eval/raw-pointer-ub.rs index 5aced5b1bd6..3320e627812 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.rs +++ b/tests/ui/consts/const-eval/raw-pointer-ub.rs @@ -1,4 +1,4 @@ -#![feature(const_mut_refs, const_intrinsic_copy)] +#![feature(const_intrinsic_copy)] const MISALIGNED_LOAD: () = unsafe { diff --git a/tests/ui/consts/const-eval/ub-enum-overwrite.rs b/tests/ui/consts/const-eval/ub-enum-overwrite.rs index 086a1001d11..69f1d01b2f3 100644 --- a/tests/ui/consts/const-eval/ub-enum-overwrite.rs +++ b/tests/ui/consts/const-eval/ub-enum-overwrite.rs @@ -1,5 +1,3 @@ -#![feature(const_mut_refs)] - enum E { A(u8), B, diff --git a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr index 2a133c057b3..315e865df93 100644 --- a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr +++ b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum-overwrite.rs:13:14 + --> $DIR/ub-enum-overwrite.rs:11:14 | LL | unsafe { *p } | ^^ using uninitialized data, but this operation requires initialized memory diff --git a/tests/ui/consts/const-eval/ub-write-through-immutable.rs b/tests/ui/consts/const-eval/ub-write-through-immutable.rs index 9860b8fde4a..d09ec5a0341 100644 --- a/tests/ui/consts/const-eval/ub-write-through-immutable.rs +++ b/tests/ui/consts/const-eval/ub-write-through-immutable.rs @@ -1,5 +1,5 @@ //! Ensure we catch UB due to writing through a shared reference. -#![feature(const_mut_refs, const_refs_to_cell)] +#![feature(const_refs_to_cell)] #![allow(invalid_reference_casting)] use std::mem; diff --git a/tests/ui/consts/const-fn-error.rs b/tests/ui/consts/const-fn-error.rs index 50b7ce1f8c0..42061ef0670 100644 --- a/tests/ui/consts/const-fn-error.rs +++ b/tests/ui/consts/const-fn-error.rs @@ -5,7 +5,6 @@ const fn f(x: usize) -> usize { for i in 0..x { //~^ ERROR cannot convert //~| ERROR `for` is not allowed in a `const fn` - //~| ERROR mutable references are not allowed in constant functions //~| ERROR cannot call non-const fn sum += i; } diff --git a/tests/ui/consts/const-fn-error.stderr b/tests/ui/consts/const-fn-error.stderr index 14603e433c1..e886a0b4fe4 100644 --- a/tests/ui/consts/const-fn-error.stderr +++ b/tests/ui/consts/const-fn-error.stderr @@ -5,7 +5,6 @@ LL | / for i in 0..x { LL | | LL | | LL | | -LL | | LL | | sum += i; LL | | } | |_____^ @@ -28,16 +27,6 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable LL + #![feature(const_trait_impl)] | -error[E0658]: mutable references are not allowed in constant functions - --> $DIR/const-fn-error.rs:5:14 - | -LL | for i in 0..x { - | ^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0015]: cannot call non-const fn ` as Iterator>::next` in constant functions --> $DIR/const-fn-error.rs:5:14 | @@ -50,7 +39,7 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable LL + #![feature(const_trait_impl)] | -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0015, E0658. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const-for-feature-gate.rs b/tests/ui/consts/const-for-feature-gate.rs index c834046c5b0..d74178662b3 100644 --- a/tests/ui/consts/const-for-feature-gate.rs +++ b/tests/ui/consts/const-for-feature-gate.rs @@ -5,7 +5,6 @@ //~^ error: `for` is not allowed in a `const` //~| ERROR: cannot convert //~| ERROR: cannot call - //~| ERROR: mutable references }; fn main() {} diff --git a/tests/ui/consts/const-for-feature-gate.stderr b/tests/ui/consts/const-for-feature-gate.stderr index 0f2f912572e..3344611a60c 100644 --- a/tests/ui/consts/const-for-feature-gate.stderr +++ b/tests/ui/consts/const-for-feature-gate.stderr @@ -22,16 +22,6 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable LL + #![feature(const_trait_impl)] | -error[E0658]: mutable references are not allowed in constants - --> $DIR/const-for-feature-gate.rs:4:14 - | -LL | for _ in 0..5 {} - | ^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0015]: cannot call non-const fn ` as Iterator>::next` in constants --> $DIR/const-for-feature-gate.rs:4:14 | @@ -44,7 +34,7 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable LL + #![feature(const_trait_impl)] | -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0015, E0658. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const-for.rs b/tests/ui/consts/const-for.rs index 8db24853558..4f8034e73f0 100644 --- a/tests/ui/consts/const-for.rs +++ b/tests/ui/consts/const-for.rs @@ -1,5 +1,4 @@ #![feature(const_for)] -#![feature(const_mut_refs)] const _: () = { for _ in 0..5 {} diff --git a/tests/ui/consts/const-for.stderr b/tests/ui/consts/const-for.stderr index 8605fb8eef5..2b817c2d20c 100644 --- a/tests/ui/consts/const-for.stderr +++ b/tests/ui/consts/const-for.stderr @@ -1,5 +1,5 @@ error[E0015]: cannot convert `std::ops::Range` into an iterator in constants - --> $DIR/const-for.rs:5:14 + --> $DIR/const-for.rs:4:14 | LL | for _ in 0..5 {} | ^^^^ @@ -13,7 +13,7 @@ LL + #![feature(const_trait_impl)] | error[E0015]: cannot call non-const fn ` as Iterator>::next` in constants - --> $DIR/const-for.rs:5:14 + --> $DIR/const-for.rs:4:14 | LL | for _ in 0..5 {} | ^^^^ diff --git a/tests/ui/consts/const-multi-ref.rs b/tests/ui/consts/const-multi-ref.rs deleted file mode 100644 index 7e0f1a812fd..00000000000 --- a/tests/ui/consts/const-multi-ref.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Ensure that we point the user to the erroneous borrow but not to any subsequent borrows of that -// initial one. - -const _: i32 = { - let mut a = 5; - let p = &mut a; //~ ERROR mutable references are not allowed in constants - - let reborrow = {p}; - let pp = &reborrow; - let ppp = &pp; - ***ppp -}; - -const _: std::cell::Cell = { - let mut a = std::cell::Cell::new(5); - let p = &a; //~ ERROR borrowed element may contain interior mutability - - let reborrow = {p}; - let pp = &reborrow; - let ppp = &pp; - a -}; - -fn main() {} diff --git a/tests/ui/consts/const-multi-ref.stderr b/tests/ui/consts/const-multi-ref.stderr deleted file mode 100644 index 516162194cd..00000000000 --- a/tests/ui/consts/const-multi-ref.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0658]: mutable references are not allowed in constants - --> $DIR/const-multi-ref.rs:6:13 - | -LL | let p = &mut a; - | ^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: cannot borrow here, since the borrowed element may contain interior mutability - --> $DIR/const-multi-ref.rs:16:13 - | -LL | let p = &a; - | ^^ - | - = note: see issue #80384 for more information - = help: add `#![feature(const_refs_to_cell)]` 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 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/const-mut-refs-crate.rs b/tests/ui/consts/const-mut-refs-crate.rs index dcc8ff370e1..aca3589720c 100644 --- a/tests/ui/consts/const-mut-refs-crate.rs +++ b/tests/ui/consts/const-mut-refs-crate.rs @@ -1,8 +1,6 @@ //@ run-pass //@ aux-build:const_mut_refs_crate.rs -#![feature(const_mut_refs)] - //! Regression test for https://github.com/rust-lang/rust/issues/79738 //! Show how we are not duplicating allocations anymore. Statics that //! copy their value from another static used to also duplicate diff --git a/tests/ui/consts/const-mut-refs/const_mut_address_of.rs b/tests/ui/consts/const-mut-refs/const_mut_address_of.rs index 437bdc88722..e88a01ec765 100644 --- a/tests/ui/consts/const-mut-refs/const_mut_address_of.rs +++ b/tests/ui/consts/const-mut-refs/const_mut_address_of.rs @@ -1,5 +1,4 @@ //@ check-pass -#![feature(const_mut_refs)] struct Foo { x: usize diff --git a/tests/ui/consts/const-mut-refs/const_mut_refs.rs b/tests/ui/consts/const-mut-refs/const_mut_refs.rs index 1b3091c8dba..2553ad3199f 100644 --- a/tests/ui/consts/const-mut-refs/const_mut_refs.rs +++ b/tests/ui/consts/const-mut-refs/const_mut_refs.rs @@ -1,5 +1,4 @@ //@ check-pass -#![feature(const_mut_refs)] use std::sync::Mutex; diff --git a/tests/ui/consts/const-mut-refs/feature-gate-const_mut_refs.rs b/tests/ui/consts/const-mut-refs/feature-gate-const_mut_refs.rs deleted file mode 100644 index ce9be4ac5c2..00000000000 --- a/tests/ui/consts/const-mut-refs/feature-gate-const_mut_refs.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn main() { - foo(&mut 5); -} - -const fn foo(x: &mut i32) -> i32 { //~ ERROR mutable references - *x + 1 - -} diff --git a/tests/ui/consts/const-mut-refs/feature-gate-const_mut_refs.stderr b/tests/ui/consts/const-mut-refs/feature-gate-const_mut_refs.stderr deleted file mode 100644 index 212d172fe13..00000000000 --- a/tests/ui/consts/const-mut-refs/feature-gate-const_mut_refs.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: mutable references are not allowed in constant functions - --> $DIR/feature-gate-const_mut_refs.rs:5:14 - | -LL | const fn foo(x: &mut i32) -> i32 { - | ^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/const-mut-refs/issue-76510.rs b/tests/ui/consts/const-mut-refs/issue-76510.rs index 685e3a129c2..6ebbd4e50f6 100644 --- a/tests/ui/consts/const-mut-refs/issue-76510.rs +++ b/tests/ui/consts/const-mut-refs/issue-76510.rs @@ -2,7 +2,6 @@ const S: &'static mut str = &mut " hello "; //~^ ERROR: mutable references are not allowed in the final value of constants -//~| ERROR: mutation through a reference is not allowed in constants const fn trigger() -> [(); unsafe { let s = transmute::<(*const u8, usize), &ManuallyDrop>((S.as_ptr(), 3)); diff --git a/tests/ui/consts/const-mut-refs/issue-76510.stderr b/tests/ui/consts/const-mut-refs/issue-76510.stderr index ab4487026cf..aff86e83578 100644 --- a/tests/ui/consts/const-mut-refs/issue-76510.stderr +++ b/tests/ui/consts/const-mut-refs/issue-76510.stderr @@ -4,17 +4,6 @@ error[E0764]: mutable references are not allowed in the final value of constants LL | const S: &'static mut str = &mut " hello "; | ^^^^^^^^^^^^^^ -error[E0658]: mutation through a reference is not allowed in constants - --> $DIR/issue-76510.rs:3:29 - | -LL | const S: &'static mut str = &mut " hello "; - | ^^^^^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0658, E0764. -For more information about an error, try `rustc --explain E0658`. +For more information about this error, try `rustc --explain E0764`. diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs b/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs index 10339ee6798..60a9171731e 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs @@ -1,4 +1,4 @@ -#![feature(const_mut_refs)] +use std::cell::UnsafeCell; const NULL: *mut i32 = std::ptr::null_mut(); const A: *const i32 = &4; @@ -25,7 +25,14 @@ const fn helper(x: &mut i32) -> Option<&mut i32> { Some(x) } x }; -use std::cell::UnsafeCell; +// Still ok, since `x` will be moved before the final pointer is crated, +// so `_ref` doesn't actually point to the memory that escapes. +const C_NO: *const i32 = &{ + let mut x = 42; + let _ref = &mut x; + x +}; + struct NotAMutex(UnsafeCell); unsafe impl Sync for NotAMutex {} diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr b/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr index 00a8421076b..53d7b3d65f9 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr @@ -25,7 +25,7 @@ LL | const B4: Option<&mut i32> = helper(&mut 42); | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:33:65 + --> $DIR/mut_ref_in_final.rs:40:65 | LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -35,7 +35,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:36:67 + --> $DIR/mut_ref_in_final.rs:43:67 | LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -45,7 +45,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a static requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:39:71 + --> $DIR/mut_ref_in_final.rs:46:71 | LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -55,25 +55,25 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a static requires that borrow lasts for `'static` error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/mut_ref_in_final.rs:52:53 + --> $DIR/mut_ref_in_final.rs:59:53 | LL | static RAW_MUT_CAST_S: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/mut_ref_in_final.rs:54:54 + --> $DIR/mut_ref_in_final.rs:61:54 | LL | static RAW_MUT_COERCE_S: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^ error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/mut_ref_in_final.rs:56:52 + --> $DIR/mut_ref_in_final.rs:63:52 | LL | const RAW_MUT_CAST_C: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/mut_ref_in_final.rs:58:53 + --> $DIR/mut_ref_in_final.rs:65:53 | LL | const RAW_MUT_COERCE_C: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^ diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs index e208845e747..7bf178484cc 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs @@ -1,7 +1,7 @@ //@ normalize-stderr-test: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr-test: "( 0x[0-9a-f][0-9a-f] │)? ([0-9a-f][0-9a-f] |__ |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?()?─*╼ )+ *│.*" -> " HEX_DUMP" //@ normalize-stderr-test: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP" -#![feature(const_mut_refs, const_refs_to_static)] +#![feature(const_refs_to_static)] use std::sync::Mutex; diff --git a/tests/ui/consts/const-ref-to-static-linux-vtable.rs b/tests/ui/consts/const-ref-to-static-linux-vtable.rs index 9325746c1e7..b9d29d0c1f4 100644 --- a/tests/ui/consts/const-ref-to-static-linux-vtable.rs +++ b/tests/ui/consts/const-ref-to-static-linux-vtable.rs @@ -1,6 +1,6 @@ //@check-pass //! This is the reduced version of the "Linux kernel vtable" use-case. -#![feature(const_mut_refs, const_refs_to_static)] +#![feature(const_refs_to_static)] use std::ptr::addr_of_mut; #[repr(C)] diff --git a/tests/ui/consts/const-suggest-feature.rs b/tests/ui/consts/const-suggest-feature.rs index d76d01a3d5e..33543bb2292 100644 --- a/tests/ui/consts/const-suggest-feature.rs +++ b/tests/ui/consts/const-suggest-feature.rs @@ -1,7 +1,10 @@ +use std::cell::Cell; + const WRITE: () = unsafe { - *std::ptr::null_mut() = 0; - //~^ ERROR dereferencing raw mutable pointers in constants is unstable - //~| HELP add `#![feature(const_mut_refs)]` to the crate attributes to enable + let x = Cell::new(0); + let y = &x; + //~^ ERROR interior mutability + //~| HELP add `#![feature(const_refs_to_cell)]` to the crate attributes to enable }; fn main() {} diff --git a/tests/ui/consts/const-suggest-feature.stderr b/tests/ui/consts/const-suggest-feature.stderr index faa1226ca25..0755e5efff1 100644 --- a/tests/ui/consts/const-suggest-feature.stderr +++ b/tests/ui/consts/const-suggest-feature.stderr @@ -1,11 +1,11 @@ -error[E0658]: dereferencing raw mutable pointers in constants is unstable - --> $DIR/const-suggest-feature.rs:2:5 +error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability + --> $DIR/const-suggest-feature.rs:5:13 | -LL | *std::ptr::null_mut() = 0; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let y = &x; + | ^^ | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable + = note: see issue #80384 for more information + = help: add `#![feature(const_refs_to_cell)]` 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_let_assign3.rs b/tests/ui/consts/const_let_assign3.rs index 1f68de8eed0..7928b2766e9 100644 --- a/tests/ui/consts/const_let_assign3.rs +++ b/tests/ui/consts/const_let_assign3.rs @@ -1,23 +1,24 @@ +//@ check-pass + struct S { state: u32, } impl S { const fn foo(&mut self, x: u32) { - //~^ ERROR mutable reference self.state = x; } } const FOO: S = { let mut s = S { state: 42 }; - s.foo(3); //~ ERROR mutable reference + s.foo(3); s }; type Array = [u32; { let mut x = 2; - let y = &mut x; //~ ERROR mutable reference + let y = &mut x; *y = 42; *y }]; diff --git a/tests/ui/consts/const_let_assign3.stderr b/tests/ui/consts/const_let_assign3.stderr deleted file mode 100644 index ae890131715..00000000000 --- a/tests/ui/consts/const_let_assign3.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0658]: mutable references are not allowed in constants - --> $DIR/const_let_assign3.rs:14:5 - | -LL | s.foo(3); - | ^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: mutable references are not allowed in constant functions - --> $DIR/const_let_assign3.rs:6:18 - | -LL | const fn foo(&mut self, x: u32) { - | ^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: mutable references are not allowed in constants - --> $DIR/const_let_assign3.rs:20:13 - | -LL | let y = &mut x; - | ^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 3 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/const_refs_to_static_fail.rs b/tests/ui/consts/const_refs_to_static_fail.rs index 806aa5f8f6f..a69902c3439 100644 --- a/tests/ui/consts/const_refs_to_static_fail.rs +++ b/tests/ui/consts/const_refs_to_static_fail.rs @@ -1,6 +1,6 @@ //@ normalize-stderr-test: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr-test: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?()?─*╼ )+ *│.*" -> "HEX_DUMP" -#![feature(const_refs_to_static, const_mut_refs, sync_unsafe_cell)] +#![feature(const_refs_to_static, sync_unsafe_cell)] use std::cell::SyncUnsafeCell; static S: SyncUnsafeCell = SyncUnsafeCell::new(0); diff --git a/tests/ui/consts/control-flow/loop.rs b/tests/ui/consts/control-flow/loop.rs index 5b7f8d29df7..f8d9f3ddb9b 100644 --- a/tests/ui/consts/control-flow/loop.rs +++ b/tests/ui/consts/control-flow/loop.rs @@ -52,14 +52,12 @@ fn main() { for i in 0..4 { //~ ERROR `for` is not allowed in a `const` //~^ ERROR: cannot call - //~| ERROR: mutable references //~| ERROR: cannot convert x += i; } for i in 0..4 { //~ ERROR `for` is not allowed in a `const` //~^ ERROR: cannot call - //~| ERROR: mutable references //~| ERROR: cannot convert x += i; } diff --git a/tests/ui/consts/control-flow/loop.stderr b/tests/ui/consts/control-flow/loop.stderr index 2815b888ccd..13d5d3e0b55 100644 --- a/tests/ui/consts/control-flow/loop.stderr +++ b/tests/ui/consts/control-flow/loop.stderr @@ -4,7 +4,6 @@ error[E0658]: `for` is not allowed in a `const` LL | / for i in 0..4 { LL | | LL | | -LL | | LL | | x += i; LL | | } | |_____^ @@ -14,12 +13,11 @@ LL | | } = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `for` is not allowed in a `const` - --> $DIR/loop.rs:60:5 + --> $DIR/loop.rs:59:5 | LL | / for i in 0..4 { LL | | LL | | -LL | | LL | | x += i; LL | | } | |_____^ @@ -42,16 +40,6 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable LL + #![feature(const_trait_impl)] | -error[E0658]: mutable references are not allowed in constants - --> $DIR/loop.rs:53:14 - | -LL | for i in 0..4 { - | ^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0015]: cannot call non-const fn ` as Iterator>::next` in constants --> $DIR/loop.rs:53:14 | @@ -65,7 +53,7 @@ LL + #![feature(const_trait_impl)] | error[E0015]: cannot convert `std::ops::Range` into an iterator in constants - --> $DIR/loop.rs:60:14 + --> $DIR/loop.rs:59:14 | LL | for i in 0..4 { | ^^^^ @@ -78,18 +66,8 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable LL + #![feature(const_trait_impl)] | -error[E0658]: mutable references are not allowed in constants - --> $DIR/loop.rs:60:14 - | -LL | for i in 0..4 { - | ^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0015]: cannot call non-const fn ` as Iterator>::next` in constants - --> $DIR/loop.rs:60:14 + --> $DIR/loop.rs:59:14 | LL | for i in 0..4 { | ^^^^ @@ -100,7 +78,7 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable LL + #![feature(const_trait_impl)] | -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0015, E0658. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/copy-intrinsic.rs b/tests/ui/consts/copy-intrinsic.rs index e3f43ce2037..805c03da546 100644 --- a/tests/ui/consts/copy-intrinsic.rs +++ b/tests/ui/consts/copy-intrinsic.rs @@ -2,7 +2,6 @@ // ignore-tidy-linelength #![feature(intrinsics, staged_api)] -#![feature(const_mut_refs)] use std::mem; extern "rust-intrinsic" { diff --git a/tests/ui/consts/copy-intrinsic.stderr b/tests/ui/consts/copy-intrinsic.stderr index 2dbb471131e..da8139129c9 100644 --- a/tests/ui/consts/copy-intrinsic.stderr +++ b/tests/ui/consts/copy-intrinsic.stderr @@ -1,23 +1,23 @@ error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:29:5 + --> $DIR/copy-intrinsic.rs:28:5 | LL | copy_nonoverlapping(0x100 as *const i32, dangle, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x100[noalloc] which is a dangling pointer (it has no provenance) error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:38:5 + --> $DIR/copy-intrinsic.rs:37:5 | LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x28 which is at or beyond the end of the allocation of size 4 bytes error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:45:5 + --> $DIR/copy-intrinsic.rs:44:5 | LL | copy(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy` error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:51:5 + --> $DIR/copy-intrinsic.rs:50:5 | LL | copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy_nonoverlapping` diff --git a/tests/ui/consts/fn_trait_refs.rs b/tests/ui/consts/fn_trait_refs.rs index e9444e5c094..47583180009 100644 --- a/tests/ui/consts/fn_trait_refs.rs +++ b/tests/ui/consts/fn_trait_refs.rs @@ -4,7 +4,6 @@ #![feature(fn_traits)] #![feature(unboxed_closures)] #![feature(const_trait_impl)] -#![feature(const_mut_refs)] #![feature(const_cmp)] #![feature(const_refs_to_cell)] diff --git a/tests/ui/consts/fn_trait_refs.stderr b/tests/ui/consts/fn_trait_refs.stderr index 42a6026cfba..ebcfcda8f42 100644 --- a/tests/ui/consts/fn_trait_refs.stderr +++ b/tests/ui/consts/fn_trait_refs.stderr @@ -5,25 +5,25 @@ LL | #![feature(const_fn_trait_ref_impls)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0635]: unknown feature `const_cmp` - --> $DIR/fn_trait_refs.rs:8:12 + --> $DIR/fn_trait_refs.rs:7:12 | LL | #![feature(const_cmp)] | ^^^^^^^^^ error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:15:15 + --> $DIR/fn_trait_refs.rs:14:15 | LL | T: ~const Fn<()> + ~const Destruct, | ^^^^^^ error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:15:31 + --> $DIR/fn_trait_refs.rs:14:31 | LL | T: ~const Fn<()> + ~const Destruct, | ^^^^^^^^ error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:15:15 + --> $DIR/fn_trait_refs.rs:14:15 | LL | T: ~const Fn<()> + ~const Destruct, | ^^^^^^ @@ -31,19 +31,19 @@ LL | T: ~const Fn<()> + ~const Destruct, = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:22:15 + --> $DIR/fn_trait_refs.rs:21:15 | LL | T: ~const FnMut<()> + ~const Destruct, | ^^^^^^^^^ error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:22:34 + --> $DIR/fn_trait_refs.rs:21:34 | LL | T: ~const FnMut<()> + ~const Destruct, | ^^^^^^^^ error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:22:15 + --> $DIR/fn_trait_refs.rs:21:15 | LL | T: ~const FnMut<()> + ~const Destruct, | ^^^^^^^^^ @@ -51,13 +51,13 @@ LL | T: ~const FnMut<()> + ~const Destruct, = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:29:15 + --> $DIR/fn_trait_refs.rs:28:15 | LL | T: ~const FnOnce<()>, | ^^^^^^^^^^ error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:29:15 + --> $DIR/fn_trait_refs.rs:28:15 | LL | T: ~const FnOnce<()>, | ^^^^^^^^^^ @@ -65,19 +65,19 @@ LL | T: ~const FnOnce<()>, = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:36:15 + --> $DIR/fn_trait_refs.rs:35:15 | LL | T: ~const Fn<()> + ~const Destruct, | ^^^^^^ error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:36:31 + --> $DIR/fn_trait_refs.rs:35:31 | LL | T: ~const Fn<()> + ~const Destruct, | ^^^^^^^^ error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:36:15 + --> $DIR/fn_trait_refs.rs:35:15 | LL | T: ~const Fn<()> + ~const Destruct, | ^^^^^^ @@ -85,19 +85,19 @@ LL | T: ~const Fn<()> + ~const Destruct, = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:50:15 + --> $DIR/fn_trait_refs.rs:49:15 | LL | T: ~const FnMut<()> + ~const Destruct, | ^^^^^^^^^ error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:50:34 + --> $DIR/fn_trait_refs.rs:49:34 | LL | T: ~const FnMut<()> + ~const Destruct, | ^^^^^^^^ error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:50:15 + --> $DIR/fn_trait_refs.rs:49:15 | LL | T: ~const FnMut<()> + ~const Destruct, | ^^^^^^^^^ @@ -105,7 +105,7 @@ LL | T: ~const FnMut<()> + ~const Destruct, = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0015]: cannot call non-const operator in constants - --> $DIR/fn_trait_refs.rs:72:17 + --> $DIR/fn_trait_refs.rs:71:17 | LL | assert!(test_one == (1, 1, 1)); | ^^^^^^^^^^^^^^^^^^^^^ @@ -117,7 +117,7 @@ LL + #![feature(effects)] | error[E0015]: cannot call non-const operator in constants - --> $DIR/fn_trait_refs.rs:75:17 + --> $DIR/fn_trait_refs.rs:74:17 | LL | assert!(test_two == (2, 2)); | ^^^^^^^^^^^^^^^^^^ @@ -129,7 +129,7 @@ LL + #![feature(effects)] | error[E0015]: cannot call non-const closure in constant functions - --> $DIR/fn_trait_refs.rs:17:5 + --> $DIR/fn_trait_refs.rs:16:5 | LL | f() | ^^^ @@ -145,7 +145,7 @@ LL + #![feature(effects)] | error[E0493]: destructor of `T` cannot be evaluated at compile-time - --> $DIR/fn_trait_refs.rs:13:23 + --> $DIR/fn_trait_refs.rs:12:23 | LL | const fn tester_fn(f: T) -> T::Output | ^ the destructor for this type cannot be evaluated in constant functions @@ -154,7 +154,7 @@ LL | } | - value is dropped here error[E0015]: cannot call non-const closure in constant functions - --> $DIR/fn_trait_refs.rs:24:5 + --> $DIR/fn_trait_refs.rs:23:5 | LL | f() | ^^^ @@ -170,7 +170,7 @@ LL + #![feature(effects)] | error[E0493]: destructor of `T` cannot be evaluated at compile-time - --> $DIR/fn_trait_refs.rs:20:27 + --> $DIR/fn_trait_refs.rs:19:27 | LL | const fn tester_fn_mut(mut f: T) -> T::Output | ^^^^^ the destructor for this type cannot be evaluated in constant functions @@ -179,7 +179,7 @@ LL | } | - value is dropped here error[E0015]: cannot call non-const closure in constant functions - --> $DIR/fn_trait_refs.rs:31:5 + --> $DIR/fn_trait_refs.rs:30:5 | LL | f() | ^^^ @@ -195,7 +195,7 @@ LL + #![feature(effects)] | error[E0493]: destructor of `T` cannot be evaluated at compile-time - --> $DIR/fn_trait_refs.rs:34:21 + --> $DIR/fn_trait_refs.rs:33:21 | LL | const fn test_fn(mut f: T) -> (T::Output, T::Output, T::Output) | ^^^^^ the destructor for this type cannot be evaluated in constant functions @@ -204,7 +204,7 @@ LL | } | - value is dropped here error[E0493]: destructor of `T` cannot be evaluated at compile-time - --> $DIR/fn_trait_refs.rs:48:25 + --> $DIR/fn_trait_refs.rs:47:25 | LL | const fn test_fn_mut(mut f: T) -> (T::Output, T::Output) | ^^^^^ the destructor for this type cannot be evaluated in constant functions diff --git a/tests/ui/consts/interior-mut-const-via-union.32bit.stderr b/tests/ui/consts/interior-mut-const-via-union.32bit.stderr index e9e9f1a4545..fb06643df85 100644 --- a/tests/ui/consts/interior-mut-const-via-union.32bit.stderr +++ b/tests/ui/consts/interior-mut-const-via-union.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/interior-mut-const-via-union.rs:35:1 + --> $DIR/interior-mut-const-via-union.rs:34:1 | LL | fn main() { | ^^^^^^^^^ constructing invalid value at ..y..0: encountered `UnsafeCell` in read-only memory @@ -10,13 +10,13 @@ LL | fn main() { } note: erroneous constant encountered - --> $DIR/interior-mut-const-via-union.rs:37:25 + --> $DIR/interior-mut-const-via-union.rs:36:25 | LL | let _: &'static _ = &C; | ^^ note: erroneous constant encountered - --> $DIR/interior-mut-const-via-union.rs:37:25 + --> $DIR/interior-mut-const-via-union.rs:36:25 | LL | let _: &'static _ = &C; | ^^ diff --git a/tests/ui/consts/interior-mut-const-via-union.64bit.stderr b/tests/ui/consts/interior-mut-const-via-union.64bit.stderr index 9cc98975ca9..f39ebe0afbd 100644 --- a/tests/ui/consts/interior-mut-const-via-union.64bit.stderr +++ b/tests/ui/consts/interior-mut-const-via-union.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/interior-mut-const-via-union.rs:35:1 + --> $DIR/interior-mut-const-via-union.rs:34:1 | LL | fn main() { | ^^^^^^^^^ constructing invalid value at ..y..0: encountered `UnsafeCell` in read-only memory @@ -10,13 +10,13 @@ LL | fn main() { } note: erroneous constant encountered - --> $DIR/interior-mut-const-via-union.rs:37:25 + --> $DIR/interior-mut-const-via-union.rs:36:25 | LL | let _: &'static _ = &C; | ^^ note: erroneous constant encountered - --> $DIR/interior-mut-const-via-union.rs:37:25 + --> $DIR/interior-mut-const-via-union.rs:36:25 | LL | let _: &'static _ = &C; | ^^ diff --git a/tests/ui/consts/interior-mut-const-via-union.rs b/tests/ui/consts/interior-mut-const-via-union.rs index 20485b90bf7..6d40a9ba850 100644 --- a/tests/ui/consts/interior-mut-const-via-union.rs +++ b/tests/ui/consts/interior-mut-const-via-union.rs @@ -3,7 +3,6 @@ // //@ build-fail //@ stderr-per-bitwidth -#![feature(const_mut_refs)] use std::cell::Cell; use std::mem::ManuallyDrop; diff --git a/tests/ui/consts/issue-17718-const-bad-values.rs b/tests/ui/consts/issue-17718-const-bad-values.rs index 33347d8df62..52f8c9bf149 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.rs +++ b/tests/ui/consts/issue-17718-const-bad-values.rs @@ -6,6 +6,5 @@ static mut S: usize = 3; const C2: &'static mut usize = unsafe { &mut S }; //~^ ERROR: referencing statics in constants -//~| ERROR: mutable references are not allowed fn main() {} diff --git a/tests/ui/consts/issue-17718-const-bad-values.stderr b/tests/ui/consts/issue-17718-const-bad-values.stderr index e755e5601a8..57fcb1c7e9a 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.stderr +++ b/tests/ui/consts/issue-17718-const-bad-values.stderr @@ -16,17 +16,7 @@ LL | const C2: &'static mut usize = unsafe { &mut S }; = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. = help: to fix this, the value can be extracted to a `const` and then used. -error[E0658]: mutable references are not allowed in constants - --> $DIR/issue-17718-const-bad-values.rs:7:41 - | -LL | const C2: &'static mut usize = unsafe { &mut S }; - | ^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0658, E0764. For more information about an error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/issue-69488.rs b/tests/ui/consts/issue-69488.rs index 35071999111..d528d6a88de 100644 --- a/tests/ui/consts/issue-69488.rs +++ b/tests/ui/consts/issue-69488.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(const_ptr_write)] -#![feature(const_mut_refs)] // Or, equivalently: `MaybeUninit`. pub union BagOfBits { diff --git a/tests/ui/consts/issue-94371.rs b/tests/ui/consts/issue-94371.rs index 3484437e571..ad9ee9a5a3e 100644 --- a/tests/ui/consts/issue-94371.rs +++ b/tests/ui/consts/issue-94371.rs @@ -1,7 +1,6 @@ //@ check-pass #![feature(const_swap)] -#![feature(const_mut_refs)] #[repr(C)] struct Demo(u64, bool, u64, u32, u64, u64, u64); diff --git a/tests/ui/consts/issue-94675.rs b/tests/ui/consts/issue-94675.rs index 00f5c3251e0..56c4b6ea36f 100644 --- a/tests/ui/consts/issue-94675.rs +++ b/tests/ui/consts/issue-94675.rs @@ -1,6 +1,6 @@ //@ known-bug: #103507 -#![feature(const_trait_impl, const_mut_refs)] +#![feature(const_trait_impl)] struct Foo<'a> { bar: &'a mut Vec, diff --git a/tests/ui/consts/min_const_fn/address_of.rs b/tests/ui/consts/min_const_fn/address_of.rs deleted file mode 100644 index dc481e17ba3..00000000000 --- a/tests/ui/consts/min_const_fn/address_of.rs +++ /dev/null @@ -1,15 +0,0 @@ -const fn mutable_address_of_in_const() { - let mut a = 0; - let b = &raw mut a; //~ ERROR mutable pointer -} - -struct X; - -impl X { - const fn inherent_mutable_address_of_in_const() { - let mut a = 0; - let b = &raw mut a; //~ ERROR mutable pointer - } -} - -fn main() {} diff --git a/tests/ui/consts/min_const_fn/address_of.stderr b/tests/ui/consts/min_const_fn/address_of.stderr deleted file mode 100644 index dd6fe6486d4..00000000000 --- a/tests/ui/consts/min_const_fn/address_of.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0658]: raw mutable pointers are not allowed in constant functions - --> $DIR/address_of.rs:3:13 - | -LL | let b = &raw mut a; - | ^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: raw mutable pointers are not allowed in constant functions - --> $DIR/address_of.rs:11:17 - | -LL | let b = &raw mut a; - | ^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/min_const_fn/min_const_fn.rs b/tests/ui/consts/min_const_fn/min_const_fn.rs index f7663f6044e..ed5aa40b66c 100644 --- a/tests/ui/consts/min_const_fn/min_const_fn.rs +++ b/tests/ui/consts/min_const_fn/min_const_fn.rs @@ -37,34 +37,22 @@ const fn new(t: T) -> Self { Foo(t) } const fn into_inner(self) -> T { self.0 } //~ destructor of const fn get(&self) -> &T { &self.0 } const fn get_mut(&mut self) -> &mut T { &mut self.0 } - //~^ mutable references - //~| mutable references - //~| mutable references } impl<'a, T> Foo { const fn new_lt(t: T) -> Self { Foo(t) } const fn into_inner_lt(self) -> T { self.0 } //~ destructor of - const fn get_lt(&'a self) -> &T { &self.0 } //~ WARNING elided lifetime has a name - const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } //~ WARNING elided lifetime has a name - //~^ mutable references - //~| mutable references - //~| mutable references + const fn get_lt(&self) -> &T { &self.0 } + const fn get_mut_lt(&mut self) -> &mut T { &mut self.0 } } impl Foo { const fn new_s(t: T) -> Self { Foo(t) } const fn into_inner_s(self) -> T { self.0 } //~ ERROR destructor const fn get_s(&self) -> &T { &self.0 } const fn get_mut_s(&mut self) -> &mut T { &mut self.0 } - //~^ mutable references - //~| mutable references - //~| mutable references } impl Foo { const fn get_sq(&self) -> &T { &self.0 } const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 } - //~^ mutable references - //~| mutable references - //~| mutable references } @@ -98,7 +86,6 @@ const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } } //~^ ERROR pointers cannot be cast to integers const fn foo30_6() -> bool { let x = true; x } const fn inc(x: &mut i32) { *x += 1 } -//~^ ERROR mutable references // ok const fn foo36(a: bool, b: bool) -> bool { a && b } diff --git a/tests/ui/consts/min_const_fn/min_const_fn.stderr b/tests/ui/consts/min_const_fn/min_const_fn.stderr index 4b348a182b8..c02f8c76d44 100644 --- a/tests/ui/consts/min_const_fn/min_const_fn.stderr +++ b/tests/ui/consts/min_const_fn/min_const_fn.stderr @@ -1,23 +1,3 @@ -warning: elided lifetime has a name - --> $DIR/min_const_fn.rs:47:34 - | -LL | impl<'a, T> Foo { - | -- lifetime `'a` declared here -... -LL | const fn get_lt(&'a self) -> &T { &self.0 } - | ^ this elided lifetime gets resolved as `'a` - | - = note: `#[warn(elided_named_lifetimes)]` on by default - -warning: elided lifetime has a name - --> $DIR/min_const_fn.rs:48:42 - | -LL | impl<'a, T> Foo { - | -- lifetime `'a` declared here -... -LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } - | ^ this elided lifetime gets resolved as `'a` - error[E0493]: destructor of `Foo` cannot be evaluated at compile-time --> $DIR/min_const_fn.rs:37:25 | @@ -26,144 +6,24 @@ LL | const fn into_inner(self) -> T { self.0 } | | | the destructor for this type cannot be evaluated in constant functions -error[E0658]: mutable references are not allowed in constant functions - --> $DIR/min_const_fn.rs:39:22 - | -LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: mutable references are not allowed in constant functions - --> $DIR/min_const_fn.rs:39:36 - | -LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: mutable references are not allowed in constant functions - --> $DIR/min_const_fn.rs:39:45 - | -LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 `Foo` cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:46:28 + --> $DIR/min_const_fn.rs:43:28 | LL | const fn into_inner_lt(self) -> T { self.0 } | ^^^^ - value is dropped here | | | the destructor for this type cannot be evaluated in constant functions -error[E0658]: mutable references are not allowed in constant functions - --> $DIR/min_const_fn.rs:48:25 - | -LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: mutable references are not allowed in constant functions - --> $DIR/min_const_fn.rs:48:42 - | -LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: mutable references are not allowed in constant functions - --> $DIR/min_const_fn.rs:48:51 - | -LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 `Foo` cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:55:27 + --> $DIR/min_const_fn.rs:49:27 | LL | const fn into_inner_s(self) -> T { self.0 } | ^^^^ - value is dropped here | | | the destructor for this type cannot be evaluated in constant functions -error[E0658]: mutable references are not allowed in constant functions - --> $DIR/min_const_fn.rs:57:24 - | -LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: mutable references are not allowed in constant functions - --> $DIR/min_const_fn.rs:57:38 - | -LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: mutable references are not allowed in constant functions - --> $DIR/min_const_fn.rs:57:47 - | -LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: mutable references are not allowed in constant functions - --> $DIR/min_const_fn.rs:64:25 - | -LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: mutable references are not allowed in constant functions - --> $DIR/min_const_fn.rs:64:39 - | -LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: mutable references are not allowed in constant functions - --> $DIR/min_const_fn.rs:64:48 - | -LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: referencing statics in constant functions is unstable - --> $DIR/min_const_fn.rs:89:27 + --> $DIR/min_const_fn.rs:77:27 | LL | const fn foo25() -> u32 { BAR } | ^^^ @@ -175,7 +35,7 @@ LL | const fn foo25() -> u32 { BAR } = help: to fix this, the value can be extracted to a `const` and then used. error[E0658]: referencing statics in constant functions is unstable - --> $DIR/min_const_fn.rs:90:37 + --> $DIR/min_const_fn.rs:78:37 | LL | const fn foo26() -> &'static u32 { &BAR } | ^^^ @@ -187,7 +47,7 @@ LL | const fn foo26() -> &'static u32 { &BAR } = help: to fix this, the value can be extracted to a `const` and then used. error: pointers cannot be cast to integers during const eval - --> $DIR/min_const_fn.rs:91:42 + --> $DIR/min_const_fn.rs:79:42 | LL | const fn foo30(x: *const u32) -> usize { x as usize } | ^^^^^^^^^^ @@ -196,7 +56,7 @@ LL | const fn foo30(x: *const u32) -> usize { x as usize } = note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior error: pointers cannot be cast to integers during const eval - --> $DIR/min_const_fn.rs:93:63 + --> $DIR/min_const_fn.rs:81:63 | LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } } | ^^^^^^^^^^ @@ -205,7 +65,7 @@ LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } = note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior error: pointers cannot be cast to integers during const eval - --> $DIR/min_const_fn.rs:95:42 + --> $DIR/min_const_fn.rs:83:42 | LL | const fn foo30_2(x: *mut u32) -> usize { x as usize } | ^^^^^^^^^^ @@ -214,7 +74,7 @@ LL | const fn foo30_2(x: *mut u32) -> usize { x as usize } = note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior error: pointers cannot be cast to integers during const eval - --> $DIR/min_const_fn.rs:97:63 + --> $DIR/min_const_fn.rs:85:63 | LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } } | ^^^^^^^^^^ @@ -222,18 +82,8 @@ LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } = note: at compile-time, pointers do not have an integer value = note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior -error[E0658]: mutable references are not allowed in constant functions - --> $DIR/min_const_fn.rs:100:14 - | -LL | const fn inc(x: &mut i32) { *x += 1 } - | ^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 `AlanTuring` cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:122:19 + --> $DIR/min_const_fn.rs:109:19 | LL | const fn no_apit2(_x: AlanTuring) {} | ^^ - value is dropped here @@ -241,14 +91,14 @@ LL | const fn no_apit2(_x: AlanTuring) {} | the destructor for this type cannot be evaluated in constant functions error[E0493]: destructor of `impl std::fmt::Debug` cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:124:18 + --> $DIR/min_const_fn.rs:111:18 | LL | const fn no_apit(_x: impl std::fmt::Debug) {} | ^^ - value is dropped here | | | the destructor for this type cannot be evaluated in constant functions -error: aborting due to 24 previous errors; 2 warnings emitted +error: aborting due to 11 previous errors Some errors have detailed explanations: E0493, E0658. For more information about an error, try `rustc --explain E0493`. diff --git a/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs b/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs deleted file mode 100644 index df20ff446cd..00000000000 --- a/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs +++ /dev/null @@ -1,13 +0,0 @@ -const fn bad_const_fn_deref_raw(x: *mut usize) -> &'static usize { unsafe { &*x } } -//~^ dereferencing raw mutable pointers in constant functions - -const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x } -//~^ dereferencing raw mutable pointers in constant functions - -const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static usize { &*x } -//~^ dereferencing raw mutable pointers in constant functions - -const unsafe fn bad_const_unsafe_deref_raw_underscore(x: *mut usize) { let _ = *x; } -//~^ dereferencing raw mutable pointers in constant functions - -fn main() {} diff --git a/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr b/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr deleted file mode 100644 index 13d733494d2..00000000000 --- a/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0658]: dereferencing raw mutable pointers in constant functions is unstable - --> $DIR/min_const_fn_unsafe_bad.rs:1:77 - | -LL | const fn bad_const_fn_deref_raw(x: *mut usize) -> &'static usize { unsafe { &*x } } - | ^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: dereferencing raw mutable pointers in constant functions is unstable - --> $DIR/min_const_fn_unsafe_bad.rs:4:70 - | -LL | const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x } - | ^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: dereferencing raw mutable pointers in constant functions is unstable - --> $DIR/min_const_fn_unsafe_bad.rs:7:83 - | -LL | const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static usize { &*x } - | ^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: dereferencing raw mutable pointers in constant functions is unstable - --> $DIR/min_const_fn_unsafe_bad.rs:10:80 - | -LL | const unsafe fn bad_const_unsafe_deref_raw_underscore(x: *mut usize) { let _ = *x; } - | ^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 4 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/min_const_fn/min_const_fn_unsafe_ok.rs b/tests/ui/consts/min_const_fn/min_const_fn_unsafe_ok.rs index 06e7d6f5d70..8b09b529ecc 100644 --- a/tests/ui/consts/min_const_fn/min_const_fn_unsafe_ok.rs +++ b/tests/ui/consts/min_const_fn/min_const_fn_unsafe_ok.rs @@ -41,4 +41,12 @@ const fn call_unsafe_generic_cell_const_fn() ret_null_mut_ptr_no_unsafe::>>() } +const fn bad_const_fn_deref_raw(x: *mut usize) -> &'static usize { unsafe { &*x } } + +const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x } + +const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static usize { &*x } + +const unsafe fn bad_const_unsafe_deref_raw_underscore(x: *mut usize) { let _ = *x; } + fn main() {} diff --git a/tests/ui/consts/min_const_fn/mutable_borrow.rs b/tests/ui/consts/min_const_fn/mutable_borrow.rs deleted file mode 100644 index 580b1d50f77..00000000000 --- a/tests/ui/consts/min_const_fn/mutable_borrow.rs +++ /dev/null @@ -1,17 +0,0 @@ -const fn mutable_ref_in_const() -> u8 { - let mut a = 0; - let b = &mut a; //~ ERROR mutable references - *b -} - -struct X; - -impl X { - const fn inherent_mutable_ref_in_const() -> u8 { - let mut a = 0; - let b = &mut a; //~ ERROR mutable references - *b - } -} - -fn main() {} diff --git a/tests/ui/consts/min_const_fn/mutable_borrow.stderr b/tests/ui/consts/min_const_fn/mutable_borrow.stderr deleted file mode 100644 index 31653602c75..00000000000 --- a/tests/ui/consts/min_const_fn/mutable_borrow.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0658]: mutable references are not allowed in constant functions - --> $DIR/mutable_borrow.rs:3:13 - | -LL | let b = &mut a; - | ^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: mutable references are not allowed in constant functions - --> $DIR/mutable_borrow.rs:12:17 - | -LL | let b = &mut a; - | ^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/miri_unleashed/box.stderr b/tests/ui/consts/miri_unleashed/box.stderr index a0518c99cda..25cefa036eb 100644 --- a/tests/ui/consts/miri_unleashed/box.stderr +++ b/tests/ui/consts/miri_unleashed/box.stderr @@ -11,16 +11,6 @@ help: skipping check that does not even have a feature gate | LL | &mut *(Box::new(0)) | ^^^^^^^^^^^^^ -help: skipping check for `const_mut_refs` feature - --> $DIR/box.rs:8:5 - | -LL | &mut *(Box::new(0)) - | ^^^^^^^^^^^^^^^^^^^ -help: skipping check for `const_mut_refs` feature - --> $DIR/box.rs:8:5 - | -LL | &mut *(Box::new(0)) - | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/consts/miri_unleashed/mutable_references.stderr b/tests/ui/consts/miri_unleashed/mutable_references.stderr index 793cbac6879..874dd0389d4 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references.stderr @@ -177,11 +177,6 @@ help: skipping check for `const_refs_to_static` feature | LL | const SUBTLE: &mut i32 = unsafe { static mut STATIC: i32 = 0; &mut STATIC }; | ^^^^^^ -help: skipping check for `const_mut_refs` feature - --> $DIR/mutable_references.rs:30:63 - | -LL | const SUBTLE: &mut i32 = unsafe { static mut STATIC: i32 = 0; &mut STATIC }; - | ^^^^^^^^^^^ help: skipping check that does not even have a feature gate --> $DIR/mutable_references.rs:40:28 | @@ -197,16 +192,6 @@ help: skipping check that does not even have a feature gate | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check for `const_mut_refs` feature - --> $DIR/mutable_references.rs:65:49 - | -LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check for `const_mut_refs` feature - --> $DIR/mutable_references.rs:65:49 - | -LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check for `const_refs_to_static` feature --> $DIR/mutable_references.rs:72:43 | diff --git a/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs b/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs index 2b8f32deda7..126d78158fe 100644 --- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs +++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs @@ -1,6 +1,6 @@ //@ stderr-per-bitwidth //@ compile-flags: -Zunleash-the-miri-inside-of-you -#![feature(const_refs_to_cell, const_mut_refs)] + // All "inner" allocations that come with a `static` are interned immutably. This means it is // crucial that we do not accept any form of (interior) mutability there. use std::sync::atomic::*; diff --git a/tests/ui/consts/missing_span_in_backtrace.rs b/tests/ui/consts/missing_span_in_backtrace.rs index d45deee18fa..ea457c96f15 100644 --- a/tests/ui/consts/missing_span_in_backtrace.rs +++ b/tests/ui/consts/missing_span_in_backtrace.rs @@ -2,7 +2,6 @@ #![feature(const_swap)] -#![feature(const_mut_refs)] use std::{ mem::{self, MaybeUninit}, ptr, diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index 9e0506e7e38..72d15702e89 100644 --- a/tests/ui/consts/missing_span_in_backtrace.stderr +++ b/tests/ui/consts/missing_span_in_backtrace.stderr @@ -10,13 +10,13 @@ note: inside `std::ptr::swap_nonoverlapping_simple_untyped::>` note: inside `swap_nonoverlapping::>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `X` - --> $DIR/missing_span_in_backtrace.rs:17:9 + --> $DIR/missing_span_in_backtrace.rs:16:9 | -17 | / ptr::swap_nonoverlapping( -18 | | &mut ptr1 as *mut _ as *mut MaybeUninit, -19 | | &mut ptr2 as *mut _ as *mut MaybeUninit, -20 | | mem::size_of::<&i32>(), -21 | | ); +16 | / ptr::swap_nonoverlapping( +17 | | &mut ptr1 as *mut _ as *mut MaybeUninit, +18 | | &mut ptr2 as *mut _ as *mut MaybeUninit, +19 | | mem::size_of::<&i32>(), +20 | | ); | |_________^ = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/mut-ptr-to-static.rs b/tests/ui/consts/mut-ptr-to-static.rs index e921365c7d4..e2e256980d2 100644 --- a/tests/ui/consts/mut-ptr-to-static.rs +++ b/tests/ui/consts/mut-ptr-to-static.rs @@ -1,5 +1,4 @@ //@run-pass -#![feature(const_mut_refs)] #![feature(sync_unsafe_cell)] use std::cell::SyncUnsafeCell; diff --git a/tests/ui/consts/promoted-const-drop.rs b/tests/ui/consts/promoted-const-drop.rs index b7d92d6523a..c6ea0d0c924 100644 --- a/tests/ui/consts/promoted-const-drop.rs +++ b/tests/ui/consts/promoted-const-drop.rs @@ -1,5 +1,4 @@ #![feature(const_trait_impl)] -#![feature(const_mut_refs)] struct A(); diff --git a/tests/ui/consts/promoted-const-drop.stderr b/tests/ui/consts/promoted-const-drop.stderr index 1201f608232..e015f756206 100644 --- a/tests/ui/consts/promoted-const-drop.stderr +++ b/tests/ui/consts/promoted-const-drop.stderr @@ -1,5 +1,5 @@ error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/promoted-const-drop.rs:6:12 + --> $DIR/promoted-const-drop.rs:5:12 | LL | impl const Drop for A { | ^^^^ @@ -8,7 +8,7 @@ LL | impl const Drop for A { = note: adding a non-const method body in the future would be a breaking change error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted-const-drop.rs:14:26 + --> $DIR/promoted-const-drop.rs:13:26 | LL | let _: &'static A = &A(); | ---------- ^^^ creates a temporary value which is freed while still in use @@ -19,7 +19,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted-const-drop.rs:15:28 + --> $DIR/promoted-const-drop.rs:14:28 | LL | let _: &'static [A] = &[C]; | ------------ ^^^ creates a temporary value which is freed while still in use diff --git a/tests/ui/consts/promoted_const_call.rs b/tests/ui/consts/promoted_const_call.rs index deaa053c415..c3920ff7241 100644 --- a/tests/ui/consts/promoted_const_call.rs +++ b/tests/ui/consts/promoted_const_call.rs @@ -1,6 +1,5 @@ //@ known-bug: #103507 -#![feature(const_mut_refs)] #![feature(const_trait_impl)] struct Panic; diff --git a/tests/ui/consts/promoted_const_call.stderr b/tests/ui/consts/promoted_const_call.stderr index 64bf6bd73b0..bcb9dfb704b 100644 --- a/tests/ui/consts/promoted_const_call.stderr +++ b/tests/ui/consts/promoted_const_call.stderr @@ -1,5 +1,5 @@ error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/promoted_const_call.rs:7:12 + --> $DIR/promoted_const_call.rs:6:12 | LL | impl const Drop for Panic { fn drop(&mut self) { panic!(); } } | ^^^^ @@ -8,7 +8,7 @@ LL | impl const Drop for Panic { fn drop(&mut self) { panic!(); } } = note: adding a non-const method body in the future would be a breaking change error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:11:26 + --> $DIR/promoted_const_call.rs:10:26 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -19,7 +19,7 @@ LL | }; | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:11:30 + --> $DIR/promoted_const_call.rs:10:30 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^ - temporary value is freed at the end of this statement @@ -28,7 +28,7 @@ LL | let _: &'static _ = &id(&Panic); | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:17:26 + --> $DIR/promoted_const_call.rs:16:26 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -39,7 +39,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:17:30 + --> $DIR/promoted_const_call.rs:16:30 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^ - temporary value is freed at the end of this statement @@ -48,7 +48,7 @@ LL | let _: &'static _ = &id(&Panic); | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:20:26 + --> $DIR/promoted_const_call.rs:19:26 | LL | let _: &'static _ = &&(Panic, 0).1; | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -59,7 +59,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:20:27 + --> $DIR/promoted_const_call.rs:19:27 | LL | let _: &'static _ = &&(Panic, 0).1; | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use diff --git a/tests/ui/consts/promotion-mutable-ref.rs b/tests/ui/consts/promotion-mutable-ref.rs index 0bca8a8dca4..36a0c8ad805 100644 --- a/tests/ui/consts/promotion-mutable-ref.rs +++ b/tests/ui/consts/promotion-mutable-ref.rs @@ -1,5 +1,4 @@ //@ run-pass -#![feature(const_mut_refs)] static mut TEST: i32 = { // We must not promote this, as CTFE needs to be able to mutate it later. diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.rs b/tests/ui/consts/qualif-indirect-mutation-fail.rs index a99d0633ba1..c6e08a557c8 100644 --- a/tests/ui/consts/qualif-indirect-mutation-fail.rs +++ b/tests/ui/consts/qualif-indirect-mutation-fail.rs @@ -1,5 +1,4 @@ //@ compile-flags: --crate-type=lib -#![feature(const_mut_refs)] #![feature(const_precise_live_drops)] #![feature(const_swap)] diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.stderr b/tests/ui/consts/qualif-indirect-mutation-fail.stderr index 21c872ed13f..433dfba2257 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:14:9 + --> $DIR/qualif-indirect-mutation-fail.rs:13:9 | LL | let mut x = None; | ^^^^^ the destructor for this type cannot be evaluated in constants @@ -16,13 +16,13 @@ note: inside `std::ptr::drop_in_place:: - shim(Some(String))` note: inside `std::ptr::drop_in_place::> - shim(Some(Option))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `A1` - --> $DIR/qualif-indirect-mutation-fail.rs:20:1 + --> $DIR/qualif-indirect-mutation-fail.rs:19:1 | LL | }; | ^ error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:30:9 + --> $DIR/qualif-indirect-mutation-fail.rs:29:9 | LL | let _z = x; | ^^ the destructor for this type cannot be evaluated in constants @@ -39,49 +39,49 @@ note: inside `std::ptr::drop_in_place:: - shim(Some(String))` note: inside `std::ptr::drop_in_place::> - shim(Some(Option))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `A2` - --> $DIR/qualif-indirect-mutation-fail.rs:31:1 + --> $DIR/qualif-indirect-mutation-fail.rs:30:1 | LL | }; | ^ error[E0493]: destructor of `(u32, Option)` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:8:9 + --> $DIR/qualif-indirect-mutation-fail.rs:7:9 | LL | let mut a: (u32, Option) = (0, None); | ^^^^^ the destructor for this type cannot be evaluated in constant functions error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:35:9 + --> $DIR/qualif-indirect-mutation-fail.rs:34:9 | LL | let x: Option = None; | ^ the destructor for this type cannot be evaluated in constant functions error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:43:9 + --> $DIR/qualif-indirect-mutation-fail.rs:42:9 | LL | let _y = x; | ^^ the destructor for this type cannot be evaluated in constant functions error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:51:9 + --> $DIR/qualif-indirect-mutation-fail.rs:50:9 | LL | let mut y: Option = None; | ^^^^^ the destructor for this type cannot be evaluated in constant functions error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:48:9 + --> $DIR/qualif-indirect-mutation-fail.rs:47:9 | LL | let mut x: Option = None; | ^^^^^ the destructor for this type cannot be evaluated in constant functions error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:61:9 + --> $DIR/qualif-indirect-mutation-fail.rs:60:9 | LL | let y: Option = None; | ^ the destructor for this type cannot be evaluated in constant functions error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:58:9 + --> $DIR/qualif-indirect-mutation-fail.rs:57:9 | LL | let x: Option = None; | ^ the destructor for this type cannot be evaluated in constant functions diff --git a/tests/ui/consts/qualif-indirect-mutation-pass.rs b/tests/ui/consts/qualif-indirect-mutation-pass.rs index 9d5f0d4306d..de417216a49 100644 --- a/tests/ui/consts/qualif-indirect-mutation-pass.rs +++ b/tests/ui/consts/qualif-indirect-mutation-pass.rs @@ -1,6 +1,5 @@ //@ compile-flags: --crate-type=lib //@ check-pass -#![feature(const_mut_refs)] #![feature(const_precise_live_drops)] // Mutable reference allows only mutation of !Drop place. diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.rs b/tests/ui/consts/static_mut_containing_mut_ref2.rs index 547f6449f13..2b1fe55df78 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref2.rs +++ b/tests/ui/consts/static_mut_containing_mut_ref2.rs @@ -1,13 +1,10 @@ -//@ revisions: stock mut_refs #![allow(static_mut_refs)] -#![cfg_attr(mut_refs, feature(const_mut_refs))] static mut STDERR_BUFFER_SPACE: u8 = 0; pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; - //[mut_refs]~^ ERROR could not evaluate static initializer - //[stock]~^^ ERROR mutation through a reference is not allowed in statics + //~^ ERROR could not evaluate static initializer }; fn main() {} diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.mut_refs.stderr b/tests/ui/consts/static_mut_containing_mut_ref2.stderr similarity index 86% rename from tests/ui/consts/static_mut_containing_mut_ref2.mut_refs.stderr rename to tests/ui/consts/static_mut_containing_mut_ref2.stderr index 42cb119d2ae..37cd2b51ad1 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref2.mut_refs.stderr +++ b/tests/ui/consts/static_mut_containing_mut_ref2.stderr @@ -1,5 +1,5 @@ error[E0080]: could not evaluate static initializer - --> $DIR/static_mut_containing_mut_ref2.rs:8:5 + --> $DIR/static_mut_containing_mut_ref2.rs:6:5 | LL | *(&mut STDERR_BUFFER_SPACE) = 42; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.stock.stderr b/tests/ui/consts/static_mut_containing_mut_ref2.stock.stderr deleted file mode 100644 index 5ff9c0b6e2b..00000000000 --- a/tests/ui/consts/static_mut_containing_mut_ref2.stock.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: mutation through a reference is not allowed in statics - --> $DIR/static_mut_containing_mut_ref2.rs:8:5 - | -LL | *(&mut STDERR_BUFFER_SPACE) = 42; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/write_to_mut_ref_dest.rs b/tests/ui/consts/write_to_mut_ref_dest.rs index 42ac2284038..18ded32a76f 100644 --- a/tests/ui/consts/write_to_mut_ref_dest.rs +++ b/tests/ui/consts/write_to_mut_ref_dest.rs @@ -1,17 +1,14 @@ -//@ revisions: stock mut_refs -//@[mut_refs] check-pass - -#![cfg_attr(mut_refs, feature(const_mut_refs))] - -use std::cell::Cell; +//@run-pass const FOO: &u32 = { let mut a = 42; { - let b: *mut u32 = &mut a; //[stock]~ ERROR mutable references are not allowed in constants - unsafe { *b = 5; } //[stock]~ ERROR dereferencing raw mutable pointers in constants + let b: *mut u32 = &mut a; + unsafe { *b = 5; } } &{a} }; -fn main() {} +fn main() { + assert_eq!(*FOO, 5); +} diff --git a/tests/ui/consts/write_to_static_via_mut_ref.rs b/tests/ui/consts/write_to_static_via_mut_ref.rs index 39b830ae4e9..82ac85bd250 100644 --- a/tests/ui/consts/write_to_static_via_mut_ref.rs +++ b/tests/ui/consts/write_to_static_via_mut_ref.rs @@ -1,5 +1,3 @@ -#![feature(const_mut_refs)] - static OH_NO: &mut i32 = &mut 42; //~ ERROR mutable references are not allowed fn main() { assert_eq!(*OH_NO, 42); diff --git a/tests/ui/consts/write_to_static_via_mut_ref.stderr b/tests/ui/consts/write_to_static_via_mut_ref.stderr index f64f0db6b25..63ef788032f 100644 --- a/tests/ui/consts/write_to_static_via_mut_ref.stderr +++ b/tests/ui/consts/write_to_static_via_mut_ref.stderr @@ -1,11 +1,11 @@ error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/write_to_static_via_mut_ref.rs:3:26 + --> $DIR/write_to_static_via_mut_ref.rs:1:26 | LL | static OH_NO: &mut i32 = &mut 42; | ^^^^^^^ error[E0594]: cannot assign to `*OH_NO`, as `OH_NO` is an immutable static item - --> $DIR/write_to_static_via_mut_ref.rs:6:5 + --> $DIR/write_to_static_via_mut_ref.rs:4:5 | LL | *OH_NO = 43; | ^^^^^^^^^^^ cannot assign diff --git a/tests/ui/error-codes/E0017.rs b/tests/ui/error-codes/E0017.rs index c046f7859fa..e103d3bf5b1 100644 --- a/tests/ui/error-codes/E0017.rs +++ b/tests/ui/error-codes/E0017.rs @@ -1,5 +1,3 @@ -#![feature(const_mut_refs)] - //@ normalize-stderr-test: "\(size: ., align: .\)" -> "" //@ normalize-stderr-test: " +│ ╾─+╼" -> "" diff --git a/tests/ui/error-codes/E0017.stderr b/tests/ui/error-codes/E0017.stderr index bb9f718b895..285d363592f 100644 --- a/tests/ui/error-codes/E0017.stderr +++ b/tests/ui/error-codes/E0017.stderr @@ -1,5 +1,5 @@ warning: taking a mutable reference to a `const` item - --> $DIR/E0017.rs:10:30 + --> $DIR/E0017.rs:8:30 | LL | const CR: &'static mut i32 = &mut C; | ^^^^^^ @@ -7,26 +7,26 @@ LL | const CR: &'static mut i32 = &mut C; = note: each usage of a `const` item creates a new temporary = note: the mutable reference will refer to this temporary, not the original `const` item note: `const` item defined here - --> $DIR/E0017.rs:7:1 + --> $DIR/E0017.rs:5:1 | LL | const C: i32 = 2; | ^^^^^^^^^^^^ = note: `#[warn(const_item_mutation)]` on by default error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/E0017.rs:10:30 + --> $DIR/E0017.rs:8:30 | LL | const CR: &'static mut i32 = &mut C; | ^^^^^^ error[E0596]: cannot borrow immutable static item `X` as mutable - --> $DIR/E0017.rs:13:39 + --> $DIR/E0017.rs:11:39 | LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ cannot borrow as mutable warning: taking a mutable reference to a `const` item - --> $DIR/E0017.rs:15:38 + --> $DIR/E0017.rs:13:38 | LL | static CONST_REF: &'static mut i32 = &mut C; | ^^^^^^ @@ -34,13 +34,13 @@ LL | static CONST_REF: &'static mut i32 = &mut C; = note: each usage of a `const` item creates a new temporary = note: the mutable reference will refer to this temporary, not the original `const` item note: `const` item defined here - --> $DIR/E0017.rs:7:1 + --> $DIR/E0017.rs:5:1 | LL | const C: i32 = 2; | ^^^^^^^^^^^^ error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/E0017.rs:15:38 + --> $DIR/E0017.rs:13:38 | LL | static CONST_REF: &'static mut i32 = &mut C; | ^^^^^^ diff --git a/tests/ui/error-codes/E0388.rs b/tests/ui/error-codes/E0388.rs deleted file mode 100644 index bbc5f2710bf..00000000000 --- a/tests/ui/error-codes/E0388.rs +++ /dev/null @@ -1,13 +0,0 @@ -static X: i32 = 1; -const C: i32 = 2; - -const CR: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed - -//~| WARN taking a mutable -static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0658 - -static CONST_REF: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed - -//~| WARN taking a mutable - -fn main() {} diff --git a/tests/ui/error-codes/E0388.stderr b/tests/ui/error-codes/E0388.stderr deleted file mode 100644 index cb7047072bd..00000000000 --- a/tests/ui/error-codes/E0388.stderr +++ /dev/null @@ -1,55 +0,0 @@ -warning: taking a mutable reference to a `const` item - --> $DIR/E0388.rs:4:30 - | -LL | const CR: &'static mut i32 = &mut C; - | ^^^^^^ - | - = note: each usage of a `const` item creates a new temporary - = note: the mutable reference will refer to this temporary, not the original `const` item -note: `const` item defined here - --> $DIR/E0388.rs:2:1 - | -LL | const C: i32 = 2; - | ^^^^^^^^^^^^ - = note: `#[warn(const_item_mutation)]` on by default - -error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/E0388.rs:4:30 - | -LL | const CR: &'static mut i32 = &mut C; - | ^^^^^^ - -error[E0658]: mutable references are not allowed in statics - --> $DIR/E0388.rs:7:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; - | ^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -warning: taking a mutable reference to a `const` item - --> $DIR/E0388.rs:9:38 - | -LL | static CONST_REF: &'static mut i32 = &mut C; - | ^^^^^^ - | - = note: each usage of a `const` item creates a new temporary - = note: the mutable reference will refer to this temporary, not the original `const` item -note: `const` item defined here - --> $DIR/E0388.rs:2:1 - | -LL | const C: i32 = 2; - | ^^^^^^^^^^^^ - -error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/E0388.rs:9:38 - | -LL | static CONST_REF: &'static mut i32 = &mut C; - | ^^^^^^ - -error: aborting due to 3 previous errors; 2 warnings emitted - -Some errors have detailed explanations: E0658, E0764. -For more information about an error, try `rustc --explain E0658`. diff --git a/tests/ui/error-codes/E0396-fixed.rs b/tests/ui/error-codes/E0396-fixed.rs deleted file mode 100644 index fe20da1a8ea..00000000000 --- a/tests/ui/error-codes/E0396-fixed.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(const_mut_refs)] - -const REG_ADDR: *mut u8 = 0x5f3759df as *mut u8; - -const VALUE: u8 = unsafe { *REG_ADDR }; -//~^ ERROR evaluation of constant value failed - -fn main() { -} diff --git a/tests/ui/error-codes/E0396-fixed.stderr b/tests/ui/error-codes/E0396-fixed.stderr deleted file mode 100644 index c14f4948095..00000000000 --- a/tests/ui/error-codes/E0396-fixed.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/E0396-fixed.rs:5:28 - | -LL | const VALUE: u8 = unsafe { *REG_ADDR }; - | ^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got 0x5f3759df[noalloc] which is a dangling pointer (it has no provenance) - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/error-codes/E0396.rs b/tests/ui/error-codes/E0396.rs deleted file mode 100644 index 383eda3d636..00000000000 --- a/tests/ui/error-codes/E0396.rs +++ /dev/null @@ -1,20 +0,0 @@ -const REG_ADDR: *mut u8 = 0x5f3759df as *mut u8; - -const VALUE: u8 = unsafe { *REG_ADDR }; -//~^ ERROR dereferencing raw mutable pointers in constants is unstable - -const unsafe fn unreachable() -> ! { - use std::convert::Infallible; - - const INFALLIBLE: *mut Infallible = &[] as *const [Infallible] as *const _ as _; - match *INFALLIBLE {} - //~^ ERROR dereferencing raw mutable pointers in constant functions is unstable - //~| ERROR dereferencing raw mutable pointers in constant functions is unstable - - const BAD: () = unsafe { match *INFALLIBLE {} }; - //~^ ERROR dereferencing raw mutable pointers in constants is unstable - //~| ERROR dereferencing raw mutable pointers in constants is unstable -} - -fn main() { -} diff --git a/tests/ui/error-codes/E0396.stderr b/tests/ui/error-codes/E0396.stderr deleted file mode 100644 index 8bc14139d63..00000000000 --- a/tests/ui/error-codes/E0396.stderr +++ /dev/null @@ -1,55 +0,0 @@ -error[E0658]: dereferencing raw mutable pointers in constants is unstable - --> $DIR/E0396.rs:3:28 - | -LL | const VALUE: u8 = unsafe { *REG_ADDR }; - | ^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: dereferencing raw mutable pointers in constants is unstable - --> $DIR/E0396.rs:14:36 - | -LL | const BAD: () = unsafe { match *INFALLIBLE {} }; - | ^^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: dereferencing raw mutable pointers in constants is unstable - --> $DIR/E0396.rs:14:36 - | -LL | const BAD: () = unsafe { match *INFALLIBLE {} }; - | ^^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0658]: dereferencing raw mutable pointers in constant functions is unstable - --> $DIR/E0396.rs:10:11 - | -LL | match *INFALLIBLE {} - | ^^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: dereferencing raw mutable pointers in constant functions is unstable - --> $DIR/E0396.rs:10:11 - | -LL | match *INFALLIBLE {} - | ^^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/inline-const/const-expr-lifetime-err.rs b/tests/ui/inline-const/const-expr-lifetime-err.rs index df1e5fcb473..8e8e0146728 100644 --- a/tests/ui/inline-const/const-expr-lifetime-err.rs +++ b/tests/ui/inline-const/const-expr-lifetime-err.rs @@ -1,5 +1,3 @@ -#![feature(const_mut_refs)] - use std::marker::PhantomData; #[derive(PartialEq, Eq)] diff --git a/tests/ui/inline-const/const-expr-lifetime-err.stderr b/tests/ui/inline-const/const-expr-lifetime-err.stderr index f97e2d25e6c..be3fc8d28c5 100644 --- a/tests/ui/inline-const/const-expr-lifetime-err.stderr +++ b/tests/ui/inline-const/const-expr-lifetime-err.stderr @@ -1,5 +1,5 @@ error[E0597]: `y` does not live long enough - --> $DIR/const-expr-lifetime-err.rs:22:30 + --> $DIR/const-expr-lifetime-err.rs:20:30 | LL | fn foo<'a>() { | -- lifetime `'a` defined here diff --git a/tests/ui/inline-const/const-expr-lifetime.rs b/tests/ui/inline-const/const-expr-lifetime.rs index 071e724a0fa..61c507f9791 100644 --- a/tests/ui/inline-const/const-expr-lifetime.rs +++ b/tests/ui/inline-const/const-expr-lifetime.rs @@ -1,7 +1,5 @@ //@ run-pass -#![feature(const_mut_refs)] - use std::marker::PhantomData; // rust-lang/rust#78174: ICE: "cannot convert ReErased to a region vid" diff --git a/tests/ui/inline-const/const-match-pat-lifetime-err.rs b/tests/ui/inline-const/const-match-pat-lifetime-err.rs index ff0a9dbf110..7f450ebe6fc 100644 --- a/tests/ui/inline-const/const-match-pat-lifetime-err.rs +++ b/tests/ui/inline-const/const-match-pat-lifetime-err.rs @@ -1,4 +1,3 @@ -#![feature(const_mut_refs)] #![feature(inline_const_pat)] use std::marker::PhantomData; diff --git a/tests/ui/inline-const/const-match-pat-lifetime-err.stderr b/tests/ui/inline-const/const-match-pat-lifetime-err.stderr index 98ce6cfae7b..95fe7085e50 100644 --- a/tests/ui/inline-const/const-match-pat-lifetime-err.stderr +++ b/tests/ui/inline-const/const-match-pat-lifetime-err.stderr @@ -1,5 +1,5 @@ error[E0597]: `y` does not live long enough - --> $DIR/const-match-pat-lifetime-err.rs:28:29 + --> $DIR/const-match-pat-lifetime-err.rs:27:29 | LL | fn match_invariant_ref<'a>() { | -- lifetime `'a` defined here @@ -15,7 +15,7 @@ LL | } | - `y` dropped here while still borrowed error: lifetime may not live long enough - --> $DIR/const-match-pat-lifetime-err.rs:38:12 + --> $DIR/const-match-pat-lifetime-err.rs:37:12 | LL | fn match_covariant_ref<'a>() { | -- lifetime `'a` defined here diff --git a/tests/ui/inline-const/const-match-pat-lifetime.rs b/tests/ui/inline-const/const-match-pat-lifetime.rs index 590c426c773..7f1011ea240 100644 --- a/tests/ui/inline-const/const-match-pat-lifetime.rs +++ b/tests/ui/inline-const/const-match-pat-lifetime.rs @@ -1,6 +1,5 @@ //@ run-pass -#![feature(const_mut_refs)] #![feature(inline_const_pat)] use std::marker::PhantomData; diff --git a/tests/ui/never_type/issue-52443.rs b/tests/ui/never_type/issue-52443.rs index 0498a8a1625..dcda2b9536a 100644 --- a/tests/ui/never_type/issue-52443.rs +++ b/tests/ui/never_type/issue-52443.rs @@ -9,6 +9,5 @@ fn main() { [(); { for _ in 0usize.. {}; 0}]; //~^ ERROR `for` is not allowed in a `const` //~| ERROR cannot convert - //~| ERROR mutable references //~| ERROR cannot call } diff --git a/tests/ui/never_type/issue-52443.stderr b/tests/ui/never_type/issue-52443.stderr index 02cb9cb22a3..adcff6637b0 100644 --- a/tests/ui/never_type/issue-52443.stderr +++ b/tests/ui/never_type/issue-52443.stderr @@ -55,16 +55,6 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable LL + #![feature(const_trait_impl)] | -error[E0658]: mutable references are not allowed in constants - --> $DIR/issue-52443.rs:9:21 - | -LL | [(); { for _ in 0usize.. {}; 0}]; - | ^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0015]: cannot call non-const fn ` as Iterator>::next` in constants --> $DIR/issue-52443.rs:9:21 | @@ -77,7 +67,7 @@ help: add `#![feature(const_trait_impl)]` to the crate attributes to enable LL + #![feature(const_trait_impl)] | -error: aborting due to 6 previous errors; 1 warning emitted +error: aborting due to 5 previous errors; 1 warning emitted Some errors have detailed explanations: E0015, E0308, E0658. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.rs index cd5fa609947..7b57e0405af 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.rs @@ -1,6 +1,5 @@ //@ known-bug: #110395 #![feature(const_trait_impl)] -#![feature(const_mut_refs)] // #![cfg_attr(precise, feature(const_precise_live_drops))] use std::marker::{Destruct, PhantomData}; diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr index 1d56d015dfc..faf24c6d911 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr @@ -1,5 +1,5 @@ error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop-fail-2.rs:40:25 + --> $DIR/const-drop-fail-2.rs:39:25 | LL | impl const Drop for ConstDropImplWithNonConstBounds { | ^^^^ @@ -8,13 +8,13 @@ LL | impl const Drop for ConstDropImplWithNonConstBounds { = note: adding a non-const method body in the future would be a breaking change error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-drop-fail-2.rs:21:26 + --> $DIR/const-drop-fail-2.rs:20:26 | LL | const fn check(_: T) {} | ^^^^^^^^ error[E0493]: destructor of `T` cannot be evaluated at compile-time - --> $DIR/const-drop-fail-2.rs:21:36 + --> $DIR/const-drop-fail-2.rs:20:36 | LL | const fn check(_: T) {} | ^ - value is dropped here @@ -22,7 +22,7 @@ LL | const fn check(_: T) {} | the destructor for this type cannot be evaluated in constant functions error[E0015]: cannot call non-const fn `::a` in constant functions - --> $DIR/const-drop-fail-2.rs:42:9 + --> $DIR/const-drop-fail-2.rs:41:9 | LL | T::a(); | ^^^^^^ diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr index b251d84a967..3d400bf0158 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr @@ -1,5 +1,5 @@ error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop-fail.rs:20:12 + --> $DIR/const-drop-fail.rs:19:12 | LL | impl const Drop for ConstImplWithDropGlue { | ^^^^ @@ -8,13 +8,13 @@ LL | impl const Drop for ConstImplWithDropGlue { = note: adding a non-const method body in the future would be a breaking change error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-drop-fail.rs:24:26 + --> $DIR/const-drop-fail.rs:23:26 | LL | const fn check(_: T) {} | ^^^^^^^^ error[E0493]: destructor of `T` cannot be evaluated at compile-time - --> $DIR/const-drop-fail.rs:24:36 + --> $DIR/const-drop-fail.rs:23:36 | LL | const fn check(_: T) {} | ^ the destructor for this type cannot be evaluated in constant functions @@ -27,12 +27,12 @@ error[E0080]: evaluation of constant value failed note: inside `std::ptr::drop_in_place:: - shim(Some(NonTrivialDrop))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `check::` - --> $DIR/const-drop-fail.rs:24:43 + --> $DIR/const-drop-fail.rs:23:43 | LL | const fn check(_: T) {} | ^ note: inside `_` - --> $DIR/const-drop-fail.rs:28:23 + --> $DIR/const-drop-fail.rs:27:23 | LL | const _: () = check($exp); | ^^^^^^^^^^^ @@ -54,12 +54,12 @@ note: inside `std::ptr::drop_in_place:: - shim(Some(NonTrivialDr note: inside `std::ptr::drop_in_place:: - shim(Some(ConstImplWithDropGlue))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `check::` - --> $DIR/const-drop-fail.rs:24:43 + --> $DIR/const-drop-fail.rs:23:43 | LL | const fn check(_: T) {} | ^ note: inside `_` - --> $DIR/const-drop-fail.rs:28:23 + --> $DIR/const-drop-fail.rs:27:23 | LL | const _: () = check($exp); | ^^^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.rs index a9640816b89..5a98c32e838 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.rs @@ -2,7 +2,6 @@ //@ revisions: stock precise #![feature(const_trait_impl)] -#![feature(const_mut_refs)] #![cfg_attr(precise, feature(const_precise_live_drops))] use std::marker::{Destruct, PhantomData}; diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr index 912700f2a83..fd0f6d02684 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr @@ -1,5 +1,5 @@ error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop-fail.rs:20:12 + --> $DIR/const-drop-fail.rs:19:12 | LL | impl const Drop for ConstImplWithDropGlue { | ^^^^ @@ -8,13 +8,13 @@ LL | impl const Drop for ConstImplWithDropGlue { = note: adding a non-const method body in the future would be a breaking change error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-drop-fail.rs:24:26 + --> $DIR/const-drop-fail.rs:23:26 | LL | const fn check(_: T) {} | ^^^^^^^^ error[E0493]: destructor of `T` cannot be evaluated at compile-time - --> $DIR/const-drop-fail.rs:24:36 + --> $DIR/const-drop-fail.rs:23:36 | LL | const fn check(_: T) {} | ^ - value is dropped here diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr index b451555ec3c..dd3ea5d241d 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr @@ -1,5 +1,5 @@ error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop.rs:13:16 + --> $DIR/const-drop.rs:12:16 | LL | impl<'a> const Drop for S<'a> { | ^^^^ @@ -8,7 +8,7 @@ LL | impl<'a> const Drop for S<'a> { = note: adding a non-const method body in the future would be a breaking change error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop.rs:47:16 + --> $DIR/const-drop.rs:46:16 | LL | impl const Drop for ConstDrop { | ^^^^ @@ -17,7 +17,7 @@ LL | impl const Drop for ConstDrop { = note: adding a non-const method body in the future would be a breaking change error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop.rs:68:37 + --> $DIR/const-drop.rs:67:37 | LL | impl const Drop for ConstDropWithBound { | ^^^^ @@ -26,7 +26,7 @@ LL | impl const Drop for ConstDropWithBound { = note: adding a non-const method body in the future would be a breaking change error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop.rs:76:30 + --> $DIR/const-drop.rs:75:30 | LL | impl const Drop for ConstDropWithNonconstBound { | ^^^^ @@ -35,13 +35,13 @@ LL | impl const Drop for ConstDropWithNonconstBound { = note: adding a non-const method body in the future would be a breaking change error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-drop.rs:19:22 + --> $DIR/const-drop.rs:18:22 | LL | const fn a(_: T) {} | ^^^^^^^^ error[E0049]: associated function `foo` has 1 const parameter but its trait declaration has 0 const parameters - --> $DIR/const-drop.rs:54:5 + --> $DIR/const-drop.rs:53:5 | LL | #[const_trait] | ^^^^^^^^^^^^^^ found 1 const parameter @@ -50,7 +50,7 @@ LL | fn foo(); | - expected 0 const parameters error[E0049]: associated function `foo` has 1 const parameter but its trait declaration has 0 const parameters - --> $DIR/const-drop.rs:54:5 + --> $DIR/const-drop.rs:53:5 | LL | #[const_trait] | ^^^^^^^^^^^^^^ found 1 const parameter @@ -61,13 +61,13 @@ LL | fn foo(); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0493]: destructor of `T` cannot be evaluated at compile-time - --> $DIR/const-drop.rs:19:32 + --> $DIR/const-drop.rs:18:32 | LL | const fn a(_: T) {} | ^ the destructor for this type cannot be evaluated in constant functions error[E0015]: cannot call non-const fn `::foo` in constant functions - --> $DIR/const-drop.rs:70:13 + --> $DIR/const-drop.rs:69:13 | LL | T::foo(); | ^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs index 4ab1704a9fb..5bd81fb3ab6 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs @@ -2,7 +2,6 @@ //@ known-bug: #110395 //@ revisions: stock precise #![feature(const_trait_impl)] -#![feature(const_mut_refs)] #![feature(never_type)] #![cfg_attr(precise, feature(const_precise_live_drops))] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr index 296614f7fd0..aa59e1c8dc4 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr @@ -1,5 +1,5 @@ error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop.rs:13:16 + --> $DIR/const-drop.rs:12:16 | LL | impl<'a> const Drop for S<'a> { | ^^^^ @@ -8,7 +8,7 @@ LL | impl<'a> const Drop for S<'a> { = note: adding a non-const method body in the future would be a breaking change error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop.rs:47:16 + --> $DIR/const-drop.rs:46:16 | LL | impl const Drop for ConstDrop { | ^^^^ @@ -17,7 +17,7 @@ LL | impl const Drop for ConstDrop { = note: adding a non-const method body in the future would be a breaking change error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop.rs:68:37 + --> $DIR/const-drop.rs:67:37 | LL | impl const Drop for ConstDropWithBound { | ^^^^ @@ -26,7 +26,7 @@ LL | impl const Drop for ConstDropWithBound { = note: adding a non-const method body in the future would be a breaking change error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop.rs:76:30 + --> $DIR/const-drop.rs:75:30 | LL | impl const Drop for ConstDropWithNonconstBound { | ^^^^ @@ -35,13 +35,13 @@ LL | impl const Drop for ConstDropWithNonconstBound { = note: adding a non-const method body in the future would be a breaking change error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-drop.rs:19:22 + --> $DIR/const-drop.rs:18:22 | LL | const fn a(_: T) {} | ^^^^^^^^ error[E0049]: associated function `foo` has 1 const parameter but its trait declaration has 0 const parameters - --> $DIR/const-drop.rs:54:5 + --> $DIR/const-drop.rs:53:5 | LL | #[const_trait] | ^^^^^^^^^^^^^^ found 1 const parameter @@ -50,7 +50,7 @@ LL | fn foo(); | - expected 0 const parameters error[E0049]: associated function `foo` has 1 const parameter but its trait declaration has 0 const parameters - --> $DIR/const-drop.rs:54:5 + --> $DIR/const-drop.rs:53:5 | LL | #[const_trait] | ^^^^^^^^^^^^^^ found 1 const parameter @@ -61,7 +61,7 @@ LL | fn foo(); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0493]: destructor of `T` cannot be evaluated at compile-time - --> $DIR/const-drop.rs:19:32 + --> $DIR/const-drop.rs:18:32 | LL | const fn a(_: T) {} | ^ - value is dropped here @@ -69,7 +69,7 @@ LL | const fn a(_: T) {} | the destructor for this type cannot be evaluated in constant functions error[E0015]: cannot call non-const fn `::foo` in constant functions - --> $DIR/const-drop.rs:70:13 + --> $DIR/const-drop.rs:69:13 | LL | T::foo(); | ^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs index 3c6d4757fea..1c3c66bc3ce 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs @@ -9,7 +9,7 @@ #![crate_type = "lib"] #![feature(no_core, lang_items, unboxed_closures, auto_traits, intrinsics, rustc_attrs, staged_api)] #![feature(fundamental, marker_trait_attr)] -#![feature(const_trait_impl, effects, const_mut_refs)] +#![feature(const_trait_impl, effects)] #![allow(internal_features, incomplete_features)] #![no_std] #![no_core] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-100222.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-100222.rs index 47f9fc664ce..13c469d656c 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-100222.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-100222.rs @@ -3,7 +3,7 @@ //@ check-pass #![allow(incomplete_features)] -#![feature(const_trait_impl, effects, associated_type_defaults, const_mut_refs)] +#![feature(const_trait_impl, effects, associated_type_defaults)] #[cfg_attr(any(yn, yy), const_trait)] pub trait Index { diff --git a/tests/ui/static/raw-ref-deref-with-unsafe.rs b/tests/ui/static/raw-ref-deref-with-unsafe.rs index 4b8f72de5b7..0974948b3a0 100644 --- a/tests/ui/static/raw-ref-deref-with-unsafe.rs +++ b/tests/ui/static/raw-ref-deref-with-unsafe.rs @@ -1,5 +1,4 @@ //@ check-pass -#![feature(const_mut_refs)] use std::ptr; // This code should remain unsafe because of the two unsafe operations here, diff --git a/tests/ui/static/raw-ref-deref-without-unsafe.rs b/tests/ui/static/raw-ref-deref-without-unsafe.rs index f9bce4368c1..289e55b7638 100644 --- a/tests/ui/static/raw-ref-deref-without-unsafe.rs +++ b/tests/ui/static/raw-ref-deref-without-unsafe.rs @@ -1,5 +1,3 @@ -#![feature(const_mut_refs)] - use std::ptr; // This code should remain unsafe because of the two unsafe operations here, diff --git a/tests/ui/static/raw-ref-deref-without-unsafe.stderr b/tests/ui/static/raw-ref-deref-without-unsafe.stderr index ac4df8b410c..f034499bbb5 100644 --- a/tests/ui/static/raw-ref-deref-without-unsafe.stderr +++ b/tests/ui/static/raw-ref-deref-without-unsafe.stderr @@ -1,5 +1,5 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block - --> $DIR/raw-ref-deref-without-unsafe.rs:12:56 + --> $DIR/raw-ref-deref-without-unsafe.rs:10:56 | LL | static mut DEREF_BYTE_PTR: *mut u8 = ptr::addr_of_mut!(*BYTE_PTR); | ^^^^^^^^^ dereference of raw pointer @@ -7,7 +7,7 @@ LL | static mut DEREF_BYTE_PTR: *mut u8 = ptr::addr_of_mut!(*BYTE_PTR); = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior error[E0133]: use of mutable static is unsafe and requires unsafe function or block - --> $DIR/raw-ref-deref-without-unsafe.rs:12:57 + --> $DIR/raw-ref-deref-without-unsafe.rs:10:57 | LL | static mut DEREF_BYTE_PTR: *mut u8 = ptr::addr_of_mut!(*BYTE_PTR); | ^^^^^^^^ use of mutable static diff --git a/tests/ui/statics/mutable_memory_validation.rs b/tests/ui/statics/mutable_memory_validation.rs index 470229d5fa7..d16b787fef8 100644 --- a/tests/ui/statics/mutable_memory_validation.rs +++ b/tests/ui/statics/mutable_memory_validation.rs @@ -4,7 +4,6 @@ //@ normalize-stderr-test: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr-test: "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?()?─*╼ )+ *│.*" -> "HEX_DUMP" -#![feature(const_mut_refs)] #![feature(const_refs_to_static)] use std::cell::UnsafeCell; diff --git a/tests/ui/statics/mutable_memory_validation.stderr b/tests/ui/statics/mutable_memory_validation.stderr index f21269235e9..60d13564679 100644 --- a/tests/ui/statics/mutable_memory_validation.stderr +++ b/tests/ui/statics/mutable_memory_validation.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_memory_validation.rs:16:1 + --> $DIR/mutable_memory_validation.rs:15:1 | LL | const MUH: Meh = Meh { x: unsafe { &mut *(&READONLY as *const _ as *mut _) } }; | ^^^^^^^^^^^^^^ constructing invalid value at .x.: encountered `UnsafeCell` in read-only memory diff --git a/tests/ui/thread-local/thread-local-static.rs b/tests/ui/thread-local/thread-local-static.rs index 05df0471b14..af30f538366 100644 --- a/tests/ui/thread-local/thread-local-static.rs +++ b/tests/ui/thread-local/thread-local-static.rs @@ -7,10 +7,8 @@ #[thread_local] static mut STATIC_VAR_2: [u32; 8] = [4; 8]; const fn g(x: &mut [u32; 8]) { - //~^ ERROR mutable references are not allowed std::mem::swap(x, &mut STATIC_VAR_2) //~^ ERROR thread-local statics cannot be accessed - //~| ERROR mutable references are not allowed //~| ERROR use of mutable static is unsafe } diff --git a/tests/ui/thread-local/thread-local-static.stderr b/tests/ui/thread-local/thread-local-static.stderr index a6499fd15ec..3bc1aec00c1 100644 --- a/tests/ui/thread-local/thread-local-static.stderr +++ b/tests/ui/thread-local/thread-local-static.stderr @@ -1,38 +1,18 @@ error[E0133]: use of mutable static is unsafe and requires unsafe function or block - --> $DIR/thread-local-static.rs:11:28 + --> $DIR/thread-local-static.rs:10:28 | LL | std::mem::swap(x, &mut STATIC_VAR_2) | ^^^^^^^^^^^^ use of mutable static | = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior -error[E0658]: mutable references are not allowed in constant functions - --> $DIR/thread-local-static.rs:9:12 - | -LL | const fn g(x: &mut [u32; 8]) { - | ^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-static.rs:11:28 + --> $DIR/thread-local-static.rs:10:28 | LL | std::mem::swap(x, &mut STATIC_VAR_2) | ^^^^^^^^^^^^ -error[E0658]: mutable references are not allowed in constant functions - --> $DIR/thread-local-static.rs:11:23 - | -LL | std::mem::swap(x, &mut STATIC_VAR_2) - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 2 previous errors -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0133, E0625, E0658. +Some errors have detailed explanations: E0133, E0625. For more information about an error, try `rustc --explain E0133`. diff --git a/tests/ui/unsafe/ranged_ints2_const.rs b/tests/ui/unsafe/ranged_ints2_const.rs index b7178c2b52b..a9f5b2089c4 100644 --- a/tests/ui/unsafe/ranged_ints2_const.rs +++ b/tests/ui/unsafe/ranged_ints2_const.rs @@ -8,19 +8,19 @@ fn main() { const fn foo() -> NonZero { let mut x = unsafe { NonZero(1) }; - let y = &mut x.0; //~ ERROR mutable references + let y = &mut x.0; //~^ ERROR mutation of layout constrained field is unsafe unsafe { NonZero(1) } } const fn bar() -> NonZero { let mut x = unsafe { NonZero(1) }; - let y = unsafe { &mut x.0 }; //~ ERROR mutable references + let y = unsafe { &mut x.0 }; unsafe { NonZero(1) } } const fn boo() -> NonZero { let mut x = unsafe { NonZero(1) }; - unsafe { let y = &mut x.0; } //~ ERROR mutable references + unsafe { let y = &mut x.0; } unsafe { NonZero(1) } } diff --git a/tests/ui/unsafe/ranged_ints2_const.stderr b/tests/ui/unsafe/ranged_ints2_const.stderr index 2d25084314e..3373d627b5e 100644 --- a/tests/ui/unsafe/ranged_ints2_const.stderr +++ b/tests/ui/unsafe/ranged_ints2_const.stderr @@ -6,37 +6,6 @@ LL | let y = &mut x.0; | = note: mutating layout constrained fields cannot statically be checked for valid values -error[E0658]: mutable references are not allowed in constant functions - --> $DIR/ranged_ints2_const.rs:11:13 - | -LL | let y = &mut x.0; - | ^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 -error[E0658]: mutable references are not allowed in constant functions - --> $DIR/ranged_ints2_const.rs:18:22 - | -LL | let y = unsafe { &mut x.0 }; - | ^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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[E0658]: mutable references are not allowed in constant functions - --> $DIR/ranged_ints2_const.rs:24:22 - | -LL | unsafe { let y = &mut x.0; } - | ^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` 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 4 previous errors - -Some errors have detailed explanations: E0133, E0658. -For more information about an error, try `rustc --explain E0133`. +For more information about this error, try `rustc --explain E0133`.