diff --git a/compiler/rustc_const_eval/messages.ftl b/compiler/rustc_const_eval/messages.ftl index 1442f1832b9b5..343a8a554b07b 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 fc0b6a4550858..52ee3499bddac 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -19,7 +19,6 @@ use rustc_mir_dataflow::Analysis; 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}; @@ -163,24 +162,6 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> { } } -struct LocalReturnTyVisitor<'ck, 'mir, 'tcx> { - kind: LocalKind, - checker: &'ck mut Checker<'mir, 'tcx>, -} - -impl<'ck, 'mir, 'tcx> TypeVisitor> for LocalReturnTyVisitor<'ck, '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>, @@ -226,25 +207,6 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { 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); } @@ -344,16 +306,8 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { 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). @@ -361,7 +315,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { // 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 @@ -375,12 +329,11 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { // `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_has_storage_dead(place.local) { - self.check_op(ops::TransientMutBorrow(kind)); - } else { - self.check_op(ops::MutBorrow(kind)); - } + place.is_indirect() || self.local_has_storage_dead(place.local) } + }; + if !is_transient { + self.check_op(ops::EscapingMutBorrow(kind)); } } } @@ -626,58 +579,6 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { } } } - 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 c6361710ac9ca..d602a0ace14e9 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 as hir; 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::{ @@ -463,9 +463,9 @@ impl<'tcx> NonConstOp<'tcx> for CellBorrow { /// 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 struct MutBorrow(pub hir::BorrowKind); +pub 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 } @@ -492,49 +492,6 @@ impl<'tcx> NonConstOp<'tcx> for MutBorrow { } } -#[derive(Debug)] -pub 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 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 struct PanicNonStr; @@ -556,24 +513,6 @@ impl<'tcx> NonConstOp<'tcx> for RawPtrComparison { } } -#[derive(Debug)] -pub 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. @@ -620,33 +559,3 @@ impl<'tcx> NonConstOp<'tcx> for ThreadLocalAccess { ccx.dcx().create_err(errors::ThreadLocalAccessErr { span }) } } - -/// Types that cannot appear in the signature or locals of a `const fn`. -pub mod mut_ref { - use super::*; - - #[derive(Debug)] - pub 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 b862bb6716c71..ec9e7d816501b 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 152627cf6545f..4d5091cd954e9 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 03b40e28f8b4b..ad3cbd64bdf3f 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -139,6 +139,8 @@ 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 24f691ea7fa20..93d28d53c97fc 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -404,8 +404,6 @@ declare_features! ( (unstable, const_fn_floating_point_arithmetic, "1.48.0", Some(57241)), /// 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/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index b39fde1c4f087..3b45796e29c04 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -4657,7 +4657,6 @@ declare_lint! { /// ### Example /// /// ```rust,compile_fail - /// #![feature(const_mut_refs)] /// const WRITE_AFTER_CAST: () = unsafe { /// let mut x = 0; /// let ptr = &x as *const i32 as *mut i32; diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 3e44adf73f045..ffd115f3862e8 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -166,13 +166,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 3d4add6fae452..1023089b84686 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 e3640627c562a..55dcf67b1bd37 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -194,6 +194,7 @@ // Language features: // tidy-alphabetical-start #![cfg_attr(bootstrap, feature(asm_const))] +#![cfg_attr(bootstrap, feature(const_mut_refs))] #![cfg_attr(bootstrap, feature(min_exhaustive_patterns))] #![feature(abi_unadjusted)] #![feature(adt_const_params)] @@ -205,7 +206,6 @@ #![feature(cfg_target_has_atomic_equal_alignment)] #![feature(const_fn_floating_point_arithmetic)] #![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/tests/lib.rs b/library/core/tests/lib.rs index 8872b4cbfd5ba..ec89ffa4b9fd5 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -27,7 +27,7 @@ #![feature(const_ipv6)] #![feature(const_likely)] #![feature(const_maybe_uninit_as_mut_ptr)] -#![feature(const_mut_refs)] +#![cfg_attr(bootstrap, 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 93a74ef739b90..8f279bdb4a411 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))] #![cfg_attr(bootstrap, feature(min_exhaustive_patterns))] #![feature(alloc_error_handler)] #![feature(allocator_internals)] @@ -282,7 +283,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 9d06e14e88c52..0838d064a5fa1 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 f54503ada9759..0b51f3aed4761 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,6 +1,5 @@ #![warn(clippy::missing_const_for_fn)] #![allow(incomplete_features, clippy::let_and_return, clippy::missing_transmute_annotations)] -#![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 2c229068e4dda..03824734b7dda 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,6 +1,5 @@ #![warn(clippy::missing_const_for_fn)] #![allow(incomplete_features, clippy::let_and_return, clippy::missing_transmute_annotations)] -#![feature(const_mut_refs)] #![feature(const_trait_impl)] use std::mem::transmute; diff --git a/tests/ui/const-generics/issues/issue-100313.rs b/tests/ui/const-generics/issues/issue-100313.rs index e07fde76a4a83..553165f90b889 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 a422764fe2c58..6e419078e5eed 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 8e78748e896e1..d8e4b74d73c98 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 0018bf18e419b..a4dd277d706d8 100644 --- a/tests/ui/consts/const-address-of-mut.rs +++ b/tests/ui/consts/const-address-of-mut.rs @@ -1,12 +1,13 @@ +//@check-pass #![feature(raw_ref_op)] -const A: () = { 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; }; //~ mutable pointer +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 95a91ff463f69..0000000000000 --- 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:3: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:5: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:9: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 ac9e8b64b4897..9cf9360dcbd08 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 cdde14756e471..2fd7222da521f 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 0c292ec5af72e..83ed496ac2c25 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 1ba20f908eaf7..69e980eb13d3e 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.64bit.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr index d06792283262d..ec7cc7d4140ac 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 ed483bccc1fac..c283a5fae7de6 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 105e8e38d84eb..09b65cc8aa962 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs @@ -1,6 +1,5 @@ #![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 bd82e6781be1e..e6e0d13e01b88 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:6:1 + --> $DIR/alloc_intrinsic_untyped.rs:5: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 345fc096ca15a..3cc035c66d33f 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 da7ab7f8ba43a..3054e79770d9f 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 a42c26c0a8dee..0b0d2676dd3ef 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 1b9abec3571ea..0000000000000 --- 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 70b224b9b4c9b..0000000000000 --- 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 5d99f265e62be..0000000000000 --- 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 e6639826cb26a..031e92f74dc7f 100644 --- a/tests/ui/consts/const-eval/issue-65394.rs +++ b/tests/ui/consts/const-eval/issue-65394.rs @@ -1,11 +1,11 @@ // 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 _: Vec = { let mut x = Vec::::new(); //~ ERROR destructor of - let r = &mut x; //~ ERROR mutable references are not allowed in constants + 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 index 1fa4da4a78be4..aae5ec7b4871b 100644 --- a/tests/ui/consts/const-eval/issue-65394.stderr +++ b/tests/ui/consts/const-eval/issue-65394.stderr @@ -1,13 +1,3 @@ -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 | @@ -17,7 +7,6 @@ LL | let mut x = Vec::::new(); LL | }; | - value is dropped here -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0493, E0658. -For more information about an error, try `rustc --explain E0493`. +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 b6b74e67d20cb..7de9d44305d60 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 901ae1922c74e..47bfc235a1afe 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 02288d8d60ce5..e37fe2d8238cf 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 d6c76886853f4..1e99d84bba4bc 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 3203ca764bb0c..1443d353848b0 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 5aced5b1bd6d5..3320e62781288 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 086a1001d11ca..69f1d01b2f31c 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 2a133c057b3e3..315e865df93f3 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 945367f182308..2e4bfc4550727 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)] #![deny(writes_through_immutable_pointer)] #![allow(invalid_reference_casting)] diff --git a/tests/ui/consts/const-fn-error.rs b/tests/ui/consts/const-fn-error.rs index 50b7ce1f8c01d..42061ef0670f5 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 14603e433c1c3..e886a0b4fe44c 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 c834046c5b07f..d74178662b3aa 100644 --- a/tests/ui/consts/const-for-feature-gate.rs +++ b/tests/ui/consts/const-for-feature-gate.rs @@ -5,7 +5,6 @@ const _: () = { //~^ 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 0f2f912572e8d..3344611a60ca8 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 8db2485355833..4f8034e73f09a 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 8605fb8eef54a..2b817c2d20c8e 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 7e0f1a812fd9c..0000000000000 --- 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 516162194cdf8..0000000000000 --- 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 dcc8ff370e1ec..aca3589720cc7 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 66a4ec50c11de..26567db7b2a12 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)] #![feature(raw_ref_op)] struct Foo { 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 1b3091c8dba5d..2553ad3199f65 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 ce9be4ac5c2af..0000000000000 --- 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 212d172fe1316..0000000000000 --- 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 685e3a129c25e..6ebbd4e50f6df 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 @@ use std::mem::{transmute, ManuallyDrop}; 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 ab4487026cf4b..aff86e83578d7 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 2 previous errors +error: aborting due to 1 previous error -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 93197d5bce494..867c68cfd39bc 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,3 @@ -#![feature(const_mut_refs)] #![feature(raw_ref_op)] const NULL: *mut i32 = std::ptr::null_mut(); 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 59e6aa4011c23..00a8421076b88 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 @@ -1,11 +1,11 @@ error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/mut_ref_in_final.rs:10:21 + --> $DIR/mut_ref_in_final.rs:9:21 | LL | const B: *mut i32 = &mut 4; | ^^^^^^ error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:16:40 + --> $DIR/mut_ref_in_final.rs:15:40 | LL | const B3: Option<&mut i32> = Some(&mut 42); | ----------^^- @@ -15,7 +15,7 @@ LL | const B3: Option<&mut i32> = Some(&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:19:42 + --> $DIR/mut_ref_in_final.rs:18:42 | LL | const B4: Option<&mut i32> = helper(&mut 42); | ------------^^- @@ -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:34:65 + --> $DIR/mut_ref_in_final.rs:33: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:37:67 + --> $DIR/mut_ref_in_final.rs:36: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:40:71 + --> $DIR/mut_ref_in_final.rs:39: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:53:53 + --> $DIR/mut_ref_in_final.rs:52: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:55:54 + --> $DIR/mut_ref_in_final.rs:54: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:57:52 + --> $DIR/mut_ref_in_final.rs:56: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:59:53 + --> $DIR/mut_ref_in_final.rs:58: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 c12c22447b59c..d45ee45982ecc 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)] #![feature(raw_ref_op)] 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 9325746c1e725..b9d29d0c1f43e 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 d76d01a3d5ed8..33543bb229245 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 faa1226ca2540..0755e5efff12a 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 1f68de8eed09b..7928b2766e9ad 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 ae890131715e9..0000000000000 --- 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 806aa5f8f6fba..a69902c34392d 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 5b7f8d29df7c6..f8d9f3ddb9b2b 100644 --- a/tests/ui/consts/control-flow/loop.rs +++ b/tests/ui/consts/control-flow/loop.rs @@ -52,14 +52,12 @@ const _: i32 = { 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 2815b888ccd97..13d5d3e0b55c8 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 e3f43ce203754..805c03da546ab 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 2dbb471131ecf..da8139129c9f3 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 e9444e5c09481..4758318000977 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 42a6026cfbad3..ebcfcda8f4255 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.64bit.stderr b/tests/ui/consts/interior-mut-const-via-union.64bit.stderr index 9cc98975ca9b5..f39ebe0afbd23 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 20485b90bf7aa..6d40a9ba850eb 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 33347d8df622a..52f8c9bf149a6 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 @@ const C1: &'static mut [usize] = &mut []; 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 e755e5601a87d..57fcb1c7e9a52 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 35071999111f5..d528d6a88de60 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 3484437e57173..ad9ee9a5a3ef4 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 00f5c3251e0a9..56c4b6ea36f6a 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 aa75423ca4d64..0000000000000 --- a/tests/ui/consts/min_const_fn/address_of.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![feature(raw_ref_op)] - -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 143760c0943d2..0000000000000 --- 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:5: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:13: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 76245c08ffc8c..26ed8cc616b85 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 @@ impl Foo { 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 } const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } - //~^ mutable references - //~| mutable references - //~| mutable references } 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 daa0ab2614fb1..c02f8c76d4418 100644 --- a/tests/ui/consts/min_const_fn/min_const_fn.stderr +++ b/tests/ui/consts/min_const_fn/min_const_fn.stderr @@ -6,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 } | ^^^ @@ -155,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 } | ^^^ @@ -167,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 } | ^^^^^^^^^^ @@ -176,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 } } | ^^^^^^^^^^ @@ -185,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 } | ^^^^^^^^^^ @@ -194,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 } } | ^^^^^^^^^^ @@ -202,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 @@ -221,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 +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 df20ff446cda2..0000000000000 --- 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 13d733494d219..0000000000000 --- 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 06e7d6f5d70f3..8b09b529ecc65 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 unsafe fn call_unsafe_generic_cell_const_unsafe_fn_immediate() 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 580b1d50f774e..0000000000000 --- 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 31653602c75d2..0000000000000 --- 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 a0518c99cda56..25cefa036ebb3 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 793cbac687915..874dd0389d455 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 2b8f32deda7d7..bbe038cf6a40d 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)] +#![feature(const_refs_to_cell)] // 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 d45deee18fa80..ea457c96f153c 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 9e0506e7e386c..72d15702e8913 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 e921365c7d407..e2e256980d2fa 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 b7d92d6523a81..c6ea0d0c924da 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 1201f608232df..e015f75620690 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 deaa053c4156b..c3920ff7241bc 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 64bf6bd73b0a5..bcb9dfb704b1d 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 0bca8a8dca42f..36a0c8ad80500 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 420e32128a4b9..91406c16f4866 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)] #![feature(raw_ref_op)] diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.stderr b/tests/ui/consts/qualif-indirect-mutation-fail.stderr index 458dc2071c48e..21c872ed13f20 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:15:9 + --> $DIR/qualif-indirect-mutation-fail.rs:14: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:21:1 + --> $DIR/qualif-indirect-mutation-fail.rs:20:1 | LL | }; | ^ error[E0493]: destructor of `Option` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:31:9 + --> $DIR/qualif-indirect-mutation-fail.rs:30: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:32:1 + --> $DIR/qualif-indirect-mutation-fail.rs:31:1 | LL | }; | ^ error[E0493]: destructor of `(u32, Option)` cannot be evaluated at compile-time - --> $DIR/qualif-indirect-mutation-fail.rs:9:9 + --> $DIR/qualif-indirect-mutation-fail.rs:8: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:36:9 + --> $DIR/qualif-indirect-mutation-fail.rs:35: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:44:9 + --> $DIR/qualif-indirect-mutation-fail.rs:43: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:52:9 + --> $DIR/qualif-indirect-mutation-fail.rs:51: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:49:9 + --> $DIR/qualif-indirect-mutation-fail.rs:48: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:62:9 + --> $DIR/qualif-indirect-mutation-fail.rs:61: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:59:9 + --> $DIR/qualif-indirect-mutation-fail.rs:58: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 9d5f0d4306d72..de417216a4943 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 547f6449f1303..2b1fe55df78b3 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 42cb119d2aeeb..37cd2b51ad143 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 5ff9c0b6e2b90..0000000000000 --- 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.mut_refs.stderr b/tests/ui/consts/write_to_mut_ref_dest.mut_refs.stderr new file mode 100644 index 0000000000000..1755aa41feaaf --- /dev/null +++ b/tests/ui/consts/write_to_mut_ref_dest.mut_refs.stderr @@ -0,0 +1,10 @@ +warning: the feature `const_mut_refs` has been stable since 1.82.0-dev and no longer requires an attribute to enable + --> $DIR/write_to_mut_ref_dest.rs:4:31 + | +LL | #![cfg_attr(mut_refs, feature(const_mut_refs))] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(stable_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/consts/write_to_mut_ref_dest.rs b/tests/ui/consts/write_to_mut_ref_dest.rs index 42ac228403841..18ded32a76f56 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 39b830ae4e915..82ac85bd2509a 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 f64f0db6b25a1..63ef788032f3c 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 c046f7859fa09..e103d3bf5b116 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 bb9f718b89592..285d363592f8b 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 bbc5f2710bf9a..0000000000000 --- 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 cb7047072bd08..0000000000000 --- 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 fe20da1a8ea87..0000000000000 --- 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 c14f4948095de..0000000000000 --- 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 383eda3d636f1..0000000000000 --- 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 8bc14139d63b1..0000000000000 --- 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 df1e5fcb47352..8e8e01467287a 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 f97e2d25e6c25..be3fc8d28c51e 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 071e724a0faa3..61c507f9791bf 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 ff0a9dbf110c4..7f450ebe6fccf 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 98ce6cfae7b38..95fe7085e5027 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 590c426c77379..7f1011ea2400d 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 0498a8a162590..dcda2b9536aa9 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 02cb9cb22a3f4..adcff6637b0d9 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 cd5fa60994720..7b57e0405af98 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 1d56d015dfc15..faf24c6d91145 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 b251d84a9670e..3d400bf015871 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 a9640816b893d..5a98c32e83887 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 912700f2a8345..fd0f6d02684a6 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 b451555ec3ccd..dd3ea5d241d76 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 4ab1704a9fbbf..5bd81fb3ab631 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 296614f7fd076..aa59e1c8dc492 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 3c6d4757fea2a..1c3c66bc3ce76 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 47f9fc664cef5..13c469d656cfc 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 4b8f72de5b77d..0974948b3a06b 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 f9bce4368c179..6f30615c352d0 100644 --- a/tests/ui/static/raw-ref-deref-without-unsafe.rs +++ b/tests/ui/static/raw-ref-deref-without-unsafe.rs @@ -1,4 +1,3 @@ -#![feature(const_mut_refs)] use std::ptr; diff --git a/tests/ui/static/raw-ref-deref-without-unsafe.stderr b/tests/ui/static/raw-ref-deref-without-unsafe.stderr index ac4df8b410c0e..39557fa14b7a6 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:11: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:11: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 470229d5fa7cd..d16b787fef84e 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 f21269235e9b8..60d1356467927 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 05df0471b1430..af30f53836618 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 a6499fd15ec64..3bc1aec00c11e 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 4 previous errors +error: aborting due to 2 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 b7178c2b52bfb..a9f5b2089c4d8 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 2d25084314eaf..3373d627b5e12 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[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 +error: aborting due to 1 previous error -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`.