summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-15 05:00:58 +0000
committerbors <bors@rust-lang.org>2024-03-15 05:00:58 +0000
commit2bcca41ad81146744295fada789a2699c72f69ac (patch)
tree8929d2a9aae746499e8b225bd2db8be24e4c5196
parent339fb6965026c4260d38ab6fd61cfcbecffd8279 (diff)
parent6b0992faa301ff8ccb280c0acc96fdbd5732aab5 (diff)
Auto merge of #122524 - cuviper:beta-next, r=cuviper
[beta] backports - AST validation: Improve handling of inherent impls nested within functions and anon consts #122004 - Downgrade const eval dangling ptr in final to future incompat lint #122204 r? cuviper
-rw-r--r--compiler/rustc_ast_passes/src/ast_validation.rs57
-rw-r--r--compiler/rustc_const_eval/src/errors.rs7
-rw-r--r--compiler/rustc_const_eval/src/interpret/intern.rs12
-rw-r--r--compiler/rustc_lint_defs/src/builtin.rs46
-rw-r--r--tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs2
-rw-r--r--tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr25
-rw-r--r--tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.rs18
-rw-r--r--tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.stderr23
-rw-r--r--tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr270
-rw-r--r--tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr270
-rw-r--r--tests/ui/consts/miri_unleashed/mutable_references_err.rs19
-rw-r--r--tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr202
-rw-r--r--tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr202
-rw-r--r--tests/ui/consts/miri_unleashed/static-no-inner-mut.rs29
-rw-r--r--tests/ui/parser/impls-nested-within-anon-consts-semantic.rs35
-rw-r--r--tests/ui/parser/impls-nested-within-fns-semantic-0.rs15
-rw-r--r--tests/ui/parser/impls-nested-within-fns-semantic-1.rs22
17 files changed, 1118 insertions, 136 deletions
diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs
index 9ea5d1ed5fa..559ca24d5af 100644
--- a/compiler/rustc_ast_passes/src/ast_validation.rs
+++ b/compiler/rustc_ast_passes/src/ast_validation.rs
@@ -925,35 +925,38 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
only_trait: only_trait.then_some(()),
};
- self.visibility_not_permitted(
- &item.vis,
- errors::VisibilityNotPermittedNote::IndividualImplItems,
- );
- if let &Unsafe::Yes(span) = unsafety {
- self.dcx().emit_err(errors::InherentImplCannotUnsafe {
- span: self_ty.span,
- annotation_span: span,
- annotation: "unsafe",
- self_ty: self_ty.span,
- });
- }
- if let &ImplPolarity::Negative(span) = polarity {
- self.dcx().emit_err(error(span, "negative", false));
- }
- if let &Defaultness::Default(def_span) = defaultness {
- self.dcx().emit_err(error(def_span, "`default`", true));
- }
- if let &Const::Yes(span) = constness {
- self.dcx().emit_err(error(span, "`const`", true));
- }
+ self.with_in_trait_impl(None, |this| {
+ this.visibility_not_permitted(
+ &item.vis,
+ errors::VisibilityNotPermittedNote::IndividualImplItems,
+ );
+ if let &Unsafe::Yes(span) = unsafety {
+ this.dcx().emit_err(errors::InherentImplCannotUnsafe {
+ span: self_ty.span,
+ annotation_span: span,
+ annotation: "unsafe",
+ self_ty: self_ty.span,
+ });
+ }
+ if let &ImplPolarity::Negative(span) = polarity {
+ this.dcx().emit_err(error(span, "negative", false));
+ }
+ if let &Defaultness::Default(def_span) = defaultness {
+ this.dcx().emit_err(error(def_span, "`default`", true));
+ }
+ if let &Const::Yes(span) = constness {
+ this.dcx().emit_err(error(span, "`const`", true));
+ }
- self.visit_vis(&item.vis);
- self.visit_ident(item.ident);
- self.with_tilde_const(Some(DisallowTildeConstContext::Impl(item.span)), |this| {
- this.visit_generics(generics)
+ this.visit_vis(&item.vis);
+ this.visit_ident(item.ident);
+ this.with_tilde_const(
+ Some(DisallowTildeConstContext::Impl(item.span)),
+ |this| this.visit_generics(generics),
+ );
+ this.visit_ty(self_ty);
+ walk_list!(this, visit_assoc_item, items, AssocCtxt::Impl);
});
- self.visit_ty(self_ty);
- walk_list!(self, visit_assoc_item, items, AssocCtxt::Impl);
walk_list!(self, visit_attribute, &item.attrs);
return; // Avoid visiting again.
}
diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs
index 4d2b1ba3eec..7736dc6d5c4 100644
--- a/compiler/rustc_const_eval/src/errors.rs
+++ b/compiler/rustc_const_eval/src/errors.rs
@@ -27,10 +27,13 @@ pub(crate) struct DanglingPtrInFinal {
pub kind: InternKind,
}
-#[derive(Diagnostic)]
+#[derive(LintDiagnostic)]
#[diag(const_eval_mutable_ptr_in_final)]
pub(crate) struct MutablePtrInFinal {
- #[primary_span]
+ // rust-lang/rust#122153: This was marked as `#[primary_span]` under
+ // `derive(Diagnostic)`. Since we expect we may hard-error in future, we are
+ // keeping the field (and skipping it under `derive(LintDiagnostic)`).
+ #[skip_arg]
pub span: Span,
pub kind: InternKind,
}
diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs
index 751fbfacaad..61f170620ea 100644
--- a/compiler/rustc_const_eval/src/interpret/intern.rs
+++ b/compiler/rustc_const_eval/src/interpret/intern.rs
@@ -19,6 +19,7 @@ use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir;
use rustc_middle::mir::interpret::{CtfeProvenance, InterpResult};
use rustc_middle::ty::layout::TyAndLayout;
+use rustc_session::lint;
use super::{AllocId, Allocation, InterpCx, MPlaceTy, Machine, MemoryKind, PlaceTy};
use crate::const_eval;
@@ -195,10 +196,13 @@ pub fn intern_const_alloc_recursive<
})?;
}
if found_bad_mutable_pointer {
- return Err(ecx
- .tcx
- .dcx()
- .emit_err(MutablePtrInFinal { span: ecx.tcx.span, kind: intern_kind }));
+ let err_diag = MutablePtrInFinal { span: ecx.tcx.span, kind: intern_kind };
+ ecx.tcx.emit_node_span_lint(
+ lint::builtin::CONST_EVAL_MUTABLE_PTR_IN_FINAL_VALUE,
+ ecx.best_lint_scope(),
+ err_diag.span,
+ err_diag,
+ )
}
Ok(())
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs
index f209e083d2d..c178359cbc8 100644
--- a/compiler/rustc_lint_defs/src/builtin.rs
+++ b/compiler/rustc_lint_defs/src/builtin.rs
@@ -27,6 +27,7 @@ declare_lint_pass! {
CENUM_IMPL_DROP_CAST,
COHERENCE_LEAK_CHECK,
CONFLICTING_REPR_HINTS,
+ CONST_EVAL_MUTABLE_PTR_IN_FINAL_VALUE,
CONST_EVALUATABLE_UNCHECKED,
CONST_ITEM_MUTATION,
CONST_PATTERNS_WITHOUT_PARTIAL_EQ,
@@ -2906,6 +2907,51 @@ declare_lint! {
}
declare_lint! {
+ /// The `const_eval_mutable_ptr_in_final_value` lint detects if a mutable pointer
+ /// has leaked into the final value of a const expression.
+ ///
+ /// ### Example
+ ///
+ /// ```rust
+ /// pub enum JsValue {
+ /// Undefined,
+ /// Object(std::cell::Cell<bool>),
+ /// }
+ ///
+ /// impl ::std::ops::Drop for JsValue {
+ /// fn drop(&mut self) {}
+ /// }
+ ///
+ /// const UNDEFINED: &JsValue = &JsValue::Undefined;
+ ///
+ /// fn main() {
+ /// }
+ /// ```
+ ///
+ /// {{produces}}
+ ///
+ /// ### Explanation
+ ///
+ /// In the 1.77 release, the const evaluation machinery adopted some
+ /// stricter rules to reject expressions with values that could
+ /// end up holding mutable references to state stored in static memory
+ /// (which is inherently immutable).
+ ///
+ /// This is a [future-incompatible] lint to ease the transition to an error.
+ /// See [issue #122153] for more details.
+ ///
+ /// [issue #122153]: https://github.com/rust-lang/rust/issues/122153
+ /// [future-incompatible]: ../index.md#future-incompatible-lints
+ pub CONST_EVAL_MUTABLE_PTR_IN_FINAL_VALUE,
+ Warn,
+ "detects a mutable pointer that has leaked into final value of a const expression",
+ @future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
+ reference: "issue #122153 <https://github.com/rust-lang/rust/issues/122153>",
+ };
+}
+
+declare_lint! {
/// The `const_evaluatable_unchecked` lint detects a generic constant used
/// in a type.
///
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 105e8e38d84..b8fed212c97 100644
--- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs
+++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs
@@ -1,9 +1,11 @@
#![feature(core_intrinsics)]
#![feature(const_heap)]
#![feature(const_mut_refs)]
+#![deny(const_eval_mutable_ptr_in_final_value)]
use std::intrinsics;
const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 };
//~^ error: mutable pointer in final value of constant
+//~| WARNING this was previously accepted by the compiler
fn main() {}
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 bd82e6781be..bb47adacb9f 100644
--- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr
+++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr
@@ -1,8 +1,31 @@
error: encountered mutable pointer in final value of constant
- --> $DIR/alloc_intrinsic_untyped.rs:6:1
+ --> $DIR/alloc_intrinsic_untyped.rs:7:1
|
LL | const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 };
| ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/alloc_intrinsic_untyped.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error
+Future incompatibility report: Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/alloc_intrinsic_untyped.rs:7:1
+ |
+LL | const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 };
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/alloc_intrinsic_untyped.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
diff --git a/tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.rs b/tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.rs
new file mode 100644
index 00000000000..94defbd7d9c
--- /dev/null
+++ b/tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.rs
@@ -0,0 +1,18 @@
+// check-pass
+use std::cell::Cell;
+
+pub enum JsValue {
+ Undefined,
+ Object(Cell<bool>),
+}
+
+impl ::std::ops::Drop for JsValue {
+ fn drop(&mut self) {}
+}
+
+const UNDEFINED: &JsValue = &JsValue::Undefined;
+ //~^ WARN encountered mutable pointer in final value of constant
+ //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+
+fn main() {
+}
diff --git a/tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.stderr b/tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.stderr
new file mode 100644
index 00000000000..85de4e7ff32
--- /dev/null
+++ b/tests/ui/consts/future-incompat-mutable-in-final-value-issue-121610.stderr
@@ -0,0 +1,23 @@
+warning: encountered mutable pointer in final value of constant
+ --> $DIR/future-incompat-mutable-in-final-value-issue-121610.rs:13:1
+ |
+LL | const UNDEFINED: &JsValue = &JsValue::Undefined;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+ = note: `#[warn(const_eval_mutable_ptr_in_final_value)]` on by default
+
+warning: 1 warning emitted
+
+Future incompatibility report: Future breakage diagnostic:
+warning: encountered mutable pointer in final value of constant
+ --> $DIR/future-incompat-mutable-in-final-value-issue-121610.rs:13:1
+ |
+LL | const UNDEFINED: &JsValue = &JsValue::Undefined;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+ = note: `#[warn(const_eval_mutable_ptr_in_final_value)]` on by default
+
diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr b/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr
index 5e79b975501..c9156958329 100644
--- a/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr
+++ b/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr
@@ -3,197 +3,397 @@ error: encountered mutable pointer in final value of constant
|
LL | const MUH: Meh = Meh {
| ^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0080]: it is undefined behavior to use this value
+ --> $DIR/mutable_references_err.rs:17:1
+ |
+LL | const MUH: Meh = Meh {
+ | ^^^^^^^^^^^^^^ constructing invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+ = note: the raw bytes of the constant (size: 4, align: 4) {
+ ╾ALLOC0╼ │ ╾──╼
+ }
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:28:1
+ --> $DIR/mutable_references_err.rs:30:1
|
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
| ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error[E0080]: it is undefined behavior to use this value
- --> $DIR/mutable_references_err.rs:33:1
+ --> $DIR/mutable_references_err.rs:30:1
+ |
+LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
+ | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>.x: encountered `UnsafeCell` in read-only memory
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+ = note: the raw bytes of the constant (size: 8, align: 4) {
+ ╾ALLOC1╼ ╾ALLOC2╼ │ ╾──╼╾──╼
+ }
+
+error[E0080]: it is undefined behavior to use this value
+ --> $DIR/mutable_references_err.rs:37:1
|
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` or `static`
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 4, align: 4) {
- ╾ALLOC0╼ │ ╾──╼
+ ╾ALLOC3╼ │ ╾──╼
}
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:36:1
+ --> $DIR/mutable_references_err.rs:41:1
|
LL | const BLUNT: &mut i32 = &mut 42;
| ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error[E0080]: it is undefined behavior to use this value
--> $DIR/mutable_references_err.rs:41:1
|
+LL | const BLUNT: &mut i32 = &mut 42;
+ | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` or `static`
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+ = note: the raw bytes of the constant (size: 4, align: 4) {
+ ╾ALLOC4╼ │ ╾──╼
+ }
+
+error[E0080]: it is undefined behavior to use this value
+ --> $DIR/mutable_references_err.rs:48:1
+ |
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 4, align: 4) {
- ╾ALLOC1<imm>╼ │ ╾──╼
+ ╾ALLOC5<imm>╼ │ ╾──╼
}
error[E0080]: it is undefined behavior to use this value
- --> $DIR/mutable_references_err.rs:48:1
+ --> $DIR/mutable_references_err.rs:55:1
|
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 4, align: 4) {
- ╾ALLOC2<imm>╼ │ ╾──╼
+ ╾ALLOC6<imm>╼ │ ╾──╼
}
error[E0080]: evaluation of constant value failed
- --> $DIR/mutable_references_err.rs:52:43
+ --> $DIR/mutable_references_err.rs:59:43
|
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
| ^^^^^^^^^^^^^ constant accesses static
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:56:1
+ --> $DIR/mutable_references_err.rs:63:1
|
LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:58:1
+ --> $DIR/mutable_references_err.rs:67:1
|
LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:60:1
+ --> $DIR/mutable_references_err.rs:71:1
|
LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:72:1
+ --> $DIR/mutable_references_err.rs:84:1
|
LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:74:1
+ --> $DIR/mutable_references_err.rs:88:1
|
LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:76:1
+ --> $DIR/mutable_references_err.rs:92:1
|
LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
warning: skipping const checks
|
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:19:8
+ --> $DIR/mutable_references_err.rs:21:8
|
LL | x: &UnsafeCell::new(42),
| ^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:28:27
+ --> $DIR/mutable_references_err.rs:30:27
|
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:33:40
+ --> $DIR/mutable_references_err.rs:37:40
|
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
| ^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:33:40
+ --> $DIR/mutable_references_err.rs:37:40
|
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
| ^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:33:35
+ --> $DIR/mutable_references_err.rs:37:35
|
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
| ^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:36:25
+ --> $DIR/mutable_references_err.rs:41:25
|
LL | const BLUNT: &mut i32 = &mut 42;
| ^^^^^^^
help: skipping check for `const_mut_refs` feature
- --> $DIR/mutable_references_err.rs:41:49
+ --> $DIR/mutable_references_err.rs:48: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_err.rs:41:49
+ --> $DIR/mutable_references_err.rs:48:49
|
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:41:49
+ --> $DIR/mutable_references_err.rs:48:49
|
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:48:44
+ --> $DIR/mutable_references_err.rs:55:44
|
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
| ^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:48:44
+ --> $DIR/mutable_references_err.rs:55:44
|
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
| ^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:51:36
+ --> $DIR/mutable_references_err.rs:58:36
|
LL | static mut MUTABLE_REF: &mut i32 = &mut 42;
| ^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:52:45
+ --> $DIR/mutable_references_err.rs:59:45
|
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
| ^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:52:45
+ --> $DIR/mutable_references_err.rs:59:45
|
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
| ^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:56:45
+ --> $DIR/mutable_references_err.rs:63:45
|
LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
| ^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:58:46
+ --> $DIR/mutable_references_err.rs:67:46
|
LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
| ^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:60:47
+ --> $DIR/mutable_references_err.rs:71:47
|
LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
| ^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:72:51
+ --> $DIR/mutable_references_err.rs:84:51
|
LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
| ^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:74:49
+ --> $DIR/mutable_references_err.rs:88:49
|
LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ };
| ^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:76:51
+ --> $DIR/mutable_references_err.rs:92:51
|
LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
| ^^^^^^
-error: aborting due to 13 previous errors; 1 warning emitted
+error: aborting due to 16 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0080`.
+Future incompatibility report: Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:17:1
+ |
+LL | const MUH: Meh = Meh {
+ | ^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:30:1
+ |
+LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:41:1
+ |
+LL | const BLUNT: &mut i32 = &mut 42;
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:63:1
+ |
+LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:67:1
+ |
+LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:71:1
+ |
+LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:84:1
+ |
+LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:88:1
+ |
+LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:92:1
+ |
+LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr b/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr
index 5a0b6af1a7b..9bec536635b 100644
--- a/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr
+++ b/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr
@@ -3,197 +3,397 @@ error: encountered mutable pointer in final value of constant
|
LL | const MUH: Meh = Meh {
| ^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0080]: it is undefined behavior to use this value
+ --> $DIR/mutable_references_err.rs:17:1
+ |
+LL | const MUH: Meh = Meh {
+ | ^^^^^^^^^^^^^^ constructing invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+ = note: the raw bytes of the constant (size: 8, align: 8) {
+ ╾ALLOC0╼ │ ╾──────╼
+ }
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:28:1
+ --> $DIR/mutable_references_err.rs:30:1
|
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
| ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error[E0080]: it is undefined behavior to use this value
- --> $DIR/mutable_references_err.rs:33:1
+ --> $DIR/mutable_references_err.rs:30:1
+ |
+LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
+ | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>.x: encountered `UnsafeCell` in read-only memory
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+ = note: the raw bytes of the constant (size: 16, align: 8) {
+ ╾ALLOC1╼ ╾ALLOC2╼ │ ╾──────╼╾──────╼
+ }
+
+error[E0080]: it is undefined behavior to use this value
+ --> $DIR/mutable_references_err.rs:37:1
|
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` or `static`
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 8) {
- ╾ALLOC0╼ │ ╾──────╼
+ ╾ALLOC3╼ │ ╾──────╼
}
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:36:1
+ --> $DIR/mutable_references_err.rs:41:1
|
LL | const BLUNT: &mut i32 = &mut 42;
| ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error[E0080]: it is undefined behavior to use this value
--> $DIR/mutable_references_err.rs:41:1
|
+LL | const BLUNT: &mut i32 = &mut 42;
+ | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` or `static`
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+ = note: the raw bytes of the constant (size: 8, align: 8) {
+ ╾ALLOC4╼ │ ╾──────╼
+ }
+
+error[E0080]: it is undefined behavior to use this value
+ --> $DIR/mutable_references_err.rs:48:1
+ |
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 8) {
- ╾ALLOC1<imm>╼ │ ╾──────╼
+ ╾ALLOC5<imm>╼ │ ╾──────╼
}
error[E0080]: it is undefined behavior to use this value
- --> $DIR/mutable_references_err.rs:48:1
+ --> $DIR/mutable_references_err.rs:55:1
|
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 8) {
- ╾ALLOC2<imm>╼ │ ╾──────╼
+ ╾ALLOC6<imm>╼ │ ╾──────╼
}
error[E0080]: evaluation of constant value failed
- --> $DIR/mutable_references_err.rs:52:43
+ --> $DIR/mutable_references_err.rs:59:43
|
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
| ^^^^^^^^^^^^^ constant accesses static
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:56:1
+ --> $DIR/mutable_references_err.rs:63:1
|
LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:58:1
+ --> $DIR/mutable_references_err.rs:67:1
|
LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:60:1
+ --> $DIR/mutable_references_err.rs:71:1
|
LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:72:1
+ --> $DIR/mutable_references_err.rs:84:1
|
LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:74:1
+ --> $DIR/mutable_references_err.rs:88:1
|
LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error: encountered mutable pointer in final value of constant
- --> $DIR/mutable_references_err.rs:76:1
+ --> $DIR/mutable_references_err.rs:92:1
|
LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
warning: skipping const checks
|
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:19:8
+ --> $DIR/mutable_references_err.rs:21:8
|
LL | x: &UnsafeCell::new(42),
| ^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:28:27
+ --> $DIR/mutable_references_err.rs:30:27
|
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:33:40
+ --> $DIR/mutable_references_err.rs:37:40
|
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
| ^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:33:40
+ --> $DIR/mutable_references_err.rs:37:40
|
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
| ^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:33:35
+ --> $DIR/mutable_references_err.rs:37:35
|
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
| ^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:36:25
+ --> $DIR/mutable_references_err.rs:41:25
|
LL | const BLUNT: &mut i32 = &mut 42;
| ^^^^^^^
help: skipping check for `const_mut_refs` feature
- --> $DIR/mutable_references_err.rs:41:49
+ --> $DIR/mutable_references_err.rs:48: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_err.rs:41:49
+ --> $DIR/mutable_references_err.rs:48:49
|
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:41:49
+ --> $DIR/mutable_references_err.rs:48:49
|
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:48:44
+ --> $DIR/mutable_references_err.rs:55:44
|
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
| ^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:48:44
+ --> $DIR/mutable_references_err.rs:55:44
|
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
| ^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:51:36
+ --> $DIR/mutable_references_err.rs:58:36
|
LL | static mut MUTABLE_REF: &mut i32 = &mut 42;
| ^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:52:45
+ --> $DIR/mutable_references_err.rs:59:45
|
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
| ^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:52:45
+ --> $DIR/mutable_references_err.rs:59:45
|
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
| ^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:56:45
+ --> $DIR/mutable_references_err.rs:63:45
|
LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
| ^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:58:46
+ --> $DIR/mutable_references_err.rs:67:46
|
LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
| ^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:60:47
+ --> $DIR/mutable_references_err.rs:71:47
|
LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
| ^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:72:51
+ --> $DIR/mutable_references_err.rs:84:51
|
LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
| ^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:74:49
+ --> $DIR/mutable_references_err.rs:88:49
|
LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ };
| ^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/mutable_references_err.rs:76:51
+ --> $DIR/mutable_references_err.rs:92:51
|
LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
| ^^^^^^
-error: aborting due to 13 previous errors; 1 warning emitted
+error: aborting due to 16 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0080`.
+Future incompatibility report: Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:17:1
+ |
+LL | const MUH: Meh = Meh {
+ | ^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:30:1
+ |
+LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:41:1
+ |
+LL | const BLUNT: &mut i32 = &mut 42;
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:63:1
+ |
+LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:67:1
+ |
+LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:71:1
+ |
+LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:84:1
+ |
+LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:88:1
+ |
+LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of constant
+ --> $DIR/mutable_references_err.rs:92:1
+ |
+LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/mutable_references_err.rs:4:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.rs b/tests/ui/consts/miri_unleashed/mutable_references_err.rs
index 3bfb0346d6a..f652bf37a2e 100644
--- a/tests/ui/consts/miri_unleashed/mutable_references_err.rs
+++ b/tests/ui/consts/miri_unleashed/mutable_references_err.rs
@@ -1,7 +1,7 @@
// stderr-per-bitwidth
// compile-flags: -Zunleash-the-miri-inside-of-you
#![allow(invalid_reference_casting, static_mut_refs)]
-
+#![deny(const_eval_mutable_ptr_in_final_value)]
use std::cell::UnsafeCell;
use std::sync::atomic::*;
@@ -16,6 +16,8 @@ unsafe impl Sync for Meh {}
// all allocs interned here will be marked immutable.
const MUH: Meh = Meh {
//~^ ERROR encountered mutable pointer in final value of constant
+ //~| WARNING this was previously accepted by the compiler
+ //~| ERROR: it is undefined behavior to use this value
x: &UnsafeCell::new(42),
};
@@ -27,14 +29,19 @@ unsafe impl Sync for Synced {}
// Make sure we also catch this behind a type-erased `dyn Trait` reference.
const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
//~^ ERROR: mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
+//~| ERROR it is undefined behavior to use this value
// Make sure we also catch mutable references in values that shouldn't have them.
static mut FOO: i32 = 0;
const SUBTLE: &mut i32 = unsafe { &mut FOO };
//~^ ERROR: it is undefined behavior to use this value
//~| static
+
const BLUNT: &mut i32 = &mut 42;
//~^ ERROR: mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
+//~| ERROR it is undefined behavior to use this value
// Check for mutable references to read-only memory.
static READONLY: i32 = 0;
@@ -55,10 +62,15 @@ const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
//~^ ERROR: mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
+
const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
//~^ ERROR: mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
+
const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
//~^ ERROR: mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
struct SyncPtr<T> {
x: *const T,
@@ -71,10 +83,15 @@ unsafe impl<T> Sync for SyncPtr<T> {}
// (Also see `static-no-inner-mut` for similar tests on `static`.)
const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
//~^ ERROR mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
+
const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ };
//~^ ERROR mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
+
const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
//~^ ERROR mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
fn main() {
unsafe {
diff --git a/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr b/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr
index e8ed6742fab..b980f056c53 100644
--- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr
+++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr
@@ -3,42 +3,112 @@ error: encountered mutable pointer in final value of static
|
LL | static REF: &AtomicI32 = &AtomicI32::new(42);
| ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0080]: it is undefined behavior to use this value
+ --> $DIR/static-no-inner-mut.rs:9:1
+ |
+LL | static REF: &AtomicI32 = &AtomicI32::new(42);
+ | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+ = note: the raw bytes of the constant (size: 4, align: 4) {
+ ╾ALLOC0╼ │ ╾──╼
+ }
error: encountered mutable pointer in final value of static
- --> $DIR/static-no-inner-mut.rs:10:1
+ --> $DIR/static-no-inner-mut.rs:14:1
|
LL | static REFMUT: &mut i32 = &mut 0;
| ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+
+error[E0080]: it is undefined behavior to use this value
+ --> $DIR/static-no-inner-mut.rs:14:1
+ |
+LL | static REFMUT: &mut i32 = &mut 0;
+ | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` or `static`
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+ = note: the raw bytes of the constant (size: 4, align: 4) {
+ ╾ALLOC1╼ │ ╾──╼
+ }
error: encountered mutable pointer in final value of static
- --> $DIR/static-no-inner-mut.rs:13:1
+ --> $DIR/static-no-inner-mut.rs:20:1
|
LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
| ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+
+error[E0080]: it is undefined behavior to use this value
+ --> $DIR/static-no-inner-mut.rs:20:1
+ |
+LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
+ | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+ = note: the raw bytes of the constant (size: 4, align: 4) {
+ ╾ALLOC2╼ │ ╾──╼
+ }
error: encountered mutable pointer in final value of static
- --> $DIR/static-no-inner-mut.rs:14:1
+ --> $DIR/static-no-inner-mut.rs:25:1
|
LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
| ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+
+error[E0080]: it is undefined behavior to use this value
+ --> $DIR/static-no-inner-mut.rs:25:1
+ |
+LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` or `static`
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+ = note: the raw bytes of the constant (size: 4, align: 4) {
+ ╾ALLOC3╼ │ ╾──╼
+ }
error: encountered mutable pointer in final value of static
- --> $DIR/static-no-inner-mut.rs:29:1
+ --> $DIR/static-no-inner-mut.rs:43:1
|
LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error: encountered mutable pointer in final value of static
- --> $DIR/static-no-inner-mut.rs:31:1
+ --> $DIR/static-no-inner-mut.rs:47:1
|
LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error: encountered mutable pointer in final value of static
- --> $DIR/static-no-inner-mut.rs:33:1
+ --> $DIR/static-no-inner-mut.rs:51:1
|
LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
warning: skipping const checks
|
@@ -48,35 +118,141 @@ help: skipping check that does not even have a feature gate
LL | static REF: &AtomicI32 = &AtomicI32::new(42);
| ^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/static-no-inner-mut.rs:10:27
+ --> $DIR/static-no-inner-mut.rs:14:27
|
LL | static REFMUT: &mut i32 = &mut 0;
| ^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/static-no-inner-mut.rs:13:56
+ --> $DIR/static-no-inner-mut.rs:20:56
|
LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
| ^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/static-no-inner-mut.rs:14:44
+ --> $DIR/static-no-inner-mut.rs:25:44
|
LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
| ^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/static-no-inner-mut.rs:29:52
+ --> $DIR/static-no-inner-mut.rs:43:52
|
LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
| ^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/static-no-inner-mut.rs:31:51
+ --> $DIR/static-no-inner-mut.rs:47:51
|
LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
| ^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/static-no-inner-mut.rs:33:52
+ --> $DIR/static-no-inner-mut.rs:51:52
|
LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
| ^^^^^^
-error: aborting due to 7 previous errors; 1 warning emitted
+error: aborting due to 11 previous errors; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0080`.
+Future incompatibility report: Future breakage diagnostic:
+error: encountered mutable pointer in final value of static
+ --> $DIR/static-no-inner-mut.rs:9:1
+ |
+LL | static REF: &AtomicI32 = &AtomicI32::new(42);
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of static
+ --> $DIR/static-no-inner-mut.rs:14:1
+ |
+LL | static REFMUT: &mut i32 = &mut 0;
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of static
+ --> $DIR/static-no-inner-mut.rs:20:1
+ |
+LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of static
+ --> $DIR/static-no-inner-mut.rs:25:1
+ |
+LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of static
+ --> $DIR/static-no-inner-mut.rs:43:1
+ |
+LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of static
+ --> $DIR/static-no-inner-mut.rs:47:1
+ |
+LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of static
+ --> $DIR/static-no-inner-mut.rs:51:1
+ |
+LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr b/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr
index e8ed6742fab..6542de10da9 100644
--- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr
+++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr
@@ -3,42 +3,112 @@ error: encountered mutable pointer in final value of static
|
LL | static REF: &AtomicI32 = &AtomicI32::new(42);
| ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0080]: it is undefined behavior to use this value
+ --> $DIR/static-no-inner-mut.rs:9:1
+ |
+LL | static REF: &AtomicI32 = &AtomicI32::new(42);
+ | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+ = note: the raw bytes of the constant (size: 8, align: 8) {
+ ╾ALLOC0╼ │ ╾──────╼
+ }
error: encountered mutable pointer in final value of static
- --> $DIR/static-no-inner-mut.rs:10:1
+ --> $DIR/static-no-inner-mut.rs:14:1
|
LL | static REFMUT: &mut i32 = &mut 0;
| ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+
+error[E0080]: it is undefined behavior to use this value
+ --> $DIR/static-no-inner-mut.rs:14:1
+ |
+LL | static REFMUT: &mut i32 = &mut 0;
+ | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` or `static`
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+ = note: the raw bytes of the constant (size: 8, align: 8) {
+ ╾ALLOC1╼ │ ╾──────╼
+ }
error: encountered mutable pointer in final value of static
- --> $DIR/static-no-inner-mut.rs:13:1
+ --> $DIR/static-no-inner-mut.rs:20:1
|
LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
| ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+
+error[E0080]: it is undefined behavior to use this value
+ --> $DIR/static-no-inner-mut.rs:20:1
+ |
+LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
+ | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+ = note: the raw bytes of the constant (size: 8, align: 8) {
+ ╾ALLOC2╼ │ ╾──────╼
+ }
error: encountered mutable pointer in final value of static
- --> $DIR/static-no-inner-mut.rs:14:1
+ --> $DIR/static-no-inner-mut.rs:25:1
|
LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
| ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+
+error[E0080]: it is undefined behavior to use this value
+ --> $DIR/static-no-inner-mut.rs:25:1
+ |
+LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` or `static`
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
+ = note: the raw bytes of the constant (size: 8, align: 8) {
+ ╾ALLOC3╼ │ ╾──────╼
+ }
error: encountered mutable pointer in final value of static
- --> $DIR/static-no-inner-mut.rs:29:1
+ --> $DIR/static-no-inner-mut.rs:43:1
|
LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error: encountered mutable pointer in final value of static
- --> $DIR/static-no-inner-mut.rs:31:1
+ --> $DIR/static-no-inner-mut.rs:47:1
|
LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
error: encountered mutable pointer in final value of static
- --> $DIR/static-no-inner-mut.rs:33:1
+ --> $DIR/static-no-inner-mut.rs:51:1
|
LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
warning: skipping const checks
|
@@ -48,35 +118,141 @@ help: skipping check that does not even have a feature gate
LL | static REF: &AtomicI32 = &AtomicI32::new(42);
| ^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/static-no-inner-mut.rs:10:27
+ --> $DIR/static-no-inner-mut.rs:14:27
|
LL | static REFMUT: &mut i32 = &mut 0;
| ^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/static-no-inner-mut.rs:13:56
+ --> $DIR/static-no-inner-mut.rs:20:56
|
LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
| ^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/static-no-inner-mut.rs:14:44
+ --> $DIR/static-no-inner-mut.rs:25:44
|
LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
| ^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/static-no-inner-mut.rs:29:52
+ --> $DIR/static-no-inner-mut.rs:43:52
|
LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
| ^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/static-no-inner-mut.rs:31:51
+ --> $DIR/static-no-inner-mut.rs:47:51
|
LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
| ^^^^^^^
help: skipping check that does not even have a feature gate
- --> $DIR/static-no-inner-mut.rs:33:52
+ --> $DIR/static-no-inner-mut.rs:51:52
|
LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
| ^^^^^^
-error: aborting due to 7 previous errors; 1 warning emitted
+error: aborting due to 11 previous errors; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0080`.
+Future incompatibility report: Future breakage diagnostic:
+error: encountered mutable pointer in final value of static
+ --> $DIR/static-no-inner-mut.rs:9:1
+ |
+LL | static REF: &AtomicI32 = &AtomicI32::new(42);
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of static
+ --> $DIR/static-no-inner-mut.rs:14:1
+ |
+LL | static REFMUT: &mut i32 = &mut 0;
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of static
+ --> $DIR/static-no-inner-mut.rs:20:1
+ |
+LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of static
+ --> $DIR/static-no-inner-mut.rs:25:1
+ |
+LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of static
+ --> $DIR/static-no-inner-mut.rs:43:1
+ |
+LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of static
+ --> $DIR/static-no-inner-mut.rs:47:1
+ |
+LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Future breakage diagnostic:
+error: encountered mutable pointer in final value of static
+ --> $DIR/static-no-inner-mut.rs:51:1
+ |
+LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153>
+note: the lint level is defined here
+ --> $DIR/static-no-inner-mut.rs:6:9
+ |
+LL | #![deny(const_eval_mutable_ptr_in_final_value)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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 a4033eb5683..8e8a14d1248 100644
--- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs
+++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs
@@ -3,15 +3,29 @@
#![feature(const_refs_to_cell, const_mut_refs)]
// All "inner" allocations that come with a `static` are interned immutably. This means it is
// crucial that we do not accept any form of (interior) mutability there.
-
+#![deny(const_eval_mutable_ptr_in_final_value)]
use std::sync::atomic::*;
-static REF: &AtomicI32 = &AtomicI32::new(42); //~ERROR mutable pointer in final value
-static REFMUT: &mut i32 = &mut 0; //~ERROR mutable pointer in final value
+static REF: &AtomicI32 = &AtomicI32::new(42);
+//~^ ERROR mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
+//~| ERROR it is undefined behavior to use this value
+
+static REFMUT: &mut i32 = &mut 0;
+//~^ ERROR mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
+//~| ERROR it is undefined behavior to use this value
// Different way of writing this that avoids promotion.
-static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; //~ERROR mutable pointer in final value
-static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; //~ERROR mutable pointer in final value
+static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}};
+//~^ ERROR mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
+//~| ERROR it is undefined behavior to use this value
+
+static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}};
+//~^ ERROR mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
+//~| ERROR it is undefined behavior to use this value
// This one is obvious, since it is non-Sync. (It also suppresses the other errors, so it is
// commented out.)
@@ -28,9 +42,14 @@ unsafe impl<T> Sync for SyncPtr<T> {}
// non-dangling raw pointers.
static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
//~^ ERROR mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
+
static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
//~^ ERROR mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
+
static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
//~^ ERROR mutable pointer in final value
+//~| WARNING this was previously accepted by the compiler
fn main() {}
diff --git a/tests/ui/parser/impls-nested-within-anon-consts-semantic.rs b/tests/ui/parser/impls-nested-within-anon-consts-semantic.rs
new file mode 100644
index 00000000000..b74dc3d4926
--- /dev/null
+++ b/tests/ui/parser/impls-nested-within-anon-consts-semantic.rs
@@ -0,0 +1,35 @@
+// Regression test for issue #89342 and for part of #119924.
+// check-pass
+
+struct Expr<const N: u32>;
+
+trait Trait0 {
+ fn required(_: Expr<{
+ struct Type;
+
+ impl Type {
+ // This visibility qualifier used to get rejected.
+ pub fn perform() {}
+ }
+
+ 0
+ }>);
+}
+
+trait Trait1 {}
+
+impl Trait1 for ()
+where
+ [(); {
+ struct Type;
+
+ impl Type {
+ // This visibility qualifier used to get rejected.
+ pub const STORE: Self = Self;
+ }
+
+ 0
+ }]:
+{}
+
+fn main() {}
diff --git a/tests/ui/parser/impls-nested-within-fns-semantic-0.rs b/tests/ui/parser/impls-nested-within-fns-semantic-0.rs
new file mode 100644
index 00000000000..ac7eb5c72b0
--- /dev/null
+++ b/tests/ui/parser/impls-nested-within-fns-semantic-0.rs
@@ -0,0 +1,15 @@
+// Regression test for #121607 and for part of issue #119924.
+// check-pass
+
+trait Trait {
+ fn provided() {
+ pub struct Type;
+
+ impl Type {
+ // This visibility qualifier used to get rejected.
+ pub fn perform() {}
+ }
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/parser/impls-nested-within-fns-semantic-1.rs b/tests/ui/parser/impls-nested-within-fns-semantic-1.rs
new file mode 100644
index 00000000000..7aef3282af1
--- /dev/null
+++ b/tests/ui/parser/impls-nested-within-fns-semantic-1.rs
@@ -0,0 +1,22 @@
+// Regression test for part of issue #119924.
+// check-pass
+
+#![feature(const_trait_impl, effects)]
+
+#[const_trait]
+trait Trait {
+ fn required();
+}
+
+impl const Trait for () {
+ fn required() {
+ pub struct Type;
+
+ impl Type {
+ // This visibility qualifier used to get rejected.
+ pub fn perform() {}
+ }
+ }
+}
+
+fn main() {}