diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 61fd828a43002..2854e6fd396c2 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -722,7 +722,7 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> { match elem { ProjectionElem::Deref => { let base_ty = Place::ty_from(place_local, proj_base, self.body, self.tcx).ty; - if let ty::RawPtr(_) = base_ty.kind() { + if base_ty.is_unsafe_ptr() { if proj_base.is_empty() { let decl = &self.body.local_decls[place_local]; if let Some(box LocalInfo::StaticRef { def_id, .. }) = decl.local_info { @@ -731,7 +731,13 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> { return; } } - self.check_op(ops::RawPtrDeref); + + // `*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() { diff --git a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs index 230d023efb9fb..6391c88600936 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs @@ -400,18 +400,18 @@ impl NonConstOp for RawPtrComparison { } #[derive(Debug)] -pub struct RawPtrDeref; -impl NonConstOp for RawPtrDeref { +pub struct RawMutPtrDeref; +impl NonConstOp for RawMutPtrDeref { fn status_in_item(&self, _: &ConstCx<'_, '_>) -> Status { - Status::Unstable(sym::const_raw_ptr_deref) + Status::Unstable(sym::const_mut_refs) } fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { feature_err( &ccx.tcx.sess.parse_sess, - sym::const_raw_ptr_deref, + sym::const_mut_refs, span, - &format!("dereferencing raw pointers in {}s is unstable", ccx.const_kind(),), + &format!("dereferencing raw mutable pointers in {}s is unstable", ccx.const_kind(),), ) } } diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 941d957103c0c..3bd1272c7cb47 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -299,6 +299,8 @@ declare_features! ( (accepted, const_panic, "1.57.0", Some(51999), None), /// Lessens the requirements for structs to implement `Unsize`. (accepted, relaxed_struct_unsize, "1.58.0", Some(81793), None), + /// Allows dereferencing raw pointers during const eval. + (accepted, const_raw_ptr_deref, "1.58.0", Some(51911), None), // ------------------------------------------------------------------------- // feature-group-end: accepted features diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 0266b7844ba7f..d8b4539d831bb 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -408,9 +408,6 @@ declare_features! ( /// Allows inferring `'static` outlives requirements (RFC 2093). (active, infer_static_outlives_requirements, "1.26.0", Some(54185), None), - /// Allows dereferencing raw pointers during const eval. - (active, const_raw_ptr_deref, "1.27.0", Some(51911), None), - /// Allows inconsistent bounds in where clauses. (active, trivial_bounds, "1.28.0", Some(48214), None), diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 1099877a00850..584b90d613f6b 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -156,7 +156,7 @@ #![feature(const_impl_trait)] #![feature(const_mut_refs)] #![feature(const_precise_live_drops)] -#![feature(const_raw_ptr_deref)] +#![cfg_attr(bootstrap, feature(const_raw_ptr_deref))] #![feature(const_refs_to_cell)] #![feature(decl_macro)] #![feature(doc_cfg)] diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 199842f0ab11d..b9acd0d29903d 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -56,7 +56,7 @@ #![feature(const_mut_refs)] #![feature(const_pin)] #![feature(const_slice_from_raw_parts)] -#![feature(const_raw_ptr_deref)] +#![cfg_attr(bootstrap, feature(const_raw_ptr_deref))] #![feature(never_type)] #![feature(unwrap_infallible)] #![feature(result_into_ok_or_err)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 59dff9f6771b6..f2490a77ce0f8 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -264,7 +264,8 @@ #![feature(const_ipv4)] #![feature(const_ipv6)] #![feature(const_option)] -#![feature(const_raw_ptr_deref)] +#![cfg_attr(bootstrap, feature(const_raw_ptr_deref))] +#![cfg_attr(not(bootstrap), feature(const_mut_refs))] #![feature(const_socketaddr)] #![feature(const_trait_impl)] #![feature(container_error_extra)] diff --git a/src/test/ui/consts/const-deref-ptr.rs b/src/test/ui/consts/const-deref-ptr.rs index b5f603bb47ac4..4aca75e3a1793 100644 --- a/src/test/ui/consts/const-deref-ptr.rs +++ b/src/test/ui/consts/const-deref-ptr.rs @@ -1,7 +1,7 @@ -// Check that you can't dereference raw pointers in constants. +// Check that you can't dereference invalid raw pointers in constants. fn main() { static C: u64 = unsafe {*(0xdeadbeef as *const u64)}; - //~^ ERROR dereferencing raw pointers in statics is unstable + //~^ ERROR could not evaluate static initializer println!("{}", C); } diff --git a/src/test/ui/consts/const-deref-ptr.stderr b/src/test/ui/consts/const-deref-ptr.stderr index 61fcb524319d5..316843889c683 100644 --- a/src/test/ui/consts/const-deref-ptr.stderr +++ b/src/test/ui/consts/const-deref-ptr.stderr @@ -1,12 +1,9 @@ -error[E0658]: dereferencing raw pointers in statics is unstable +error[E0080]: could not evaluate static initializer --> $DIR/const-deref-ptr.rs:4:29 | LL | static C: u64 = unsafe {*(0xdeadbeef as *const u64)}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #51911 for more information - = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0xdeadbeef is not a valid pointer error: aborting due to previous error -For more information about this error, try `rustc --explain E0658`. +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.rs b/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.rs deleted file mode 100644 index 037c6f9f7e662..0000000000000 --- a/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.rs +++ /dev/null @@ -1,19 +0,0 @@ -// New test for #53818: modifying static memory at compile-time is not allowed. -// The test should never compile successfully - -#![feature(const_raw_ptr_deref, const_mut_refs)] - -use std::cell::UnsafeCell; - -struct Foo(UnsafeCell); - -unsafe impl Send for Foo {} -unsafe impl Sync for Foo {} - -static FOO: Foo = Foo(UnsafeCell::new(42)); - -static BAR: () = unsafe { - *FOO.0.get() = 5; //~ ERROR -}; - -fn main() {} diff --git a/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr b/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr deleted file mode 100644 index 296a6bf542163..0000000000000 --- a/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0080]: could not evaluate static initializer - --> $DIR/assign-to-static-within-other-static-2.rs:16:5 - | -LL | *FOO.0.get() = 5; - | ^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/assign-to-static-within-other-static.rs b/src/test/ui/consts/const-eval/assign-to-static-within-other-static.rs index 648caae30b427..ecf97223f6ada 100644 --- a/src/test/ui/consts/const-eval/assign-to-static-within-other-static.rs +++ b/src/test/ui/consts/const-eval/assign-to-static-within-other-static.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_raw_ptr_deref)] - use std::cell::UnsafeCell; static mut FOO: u32 = 42; diff --git a/src/test/ui/consts/const-eval/assign-to-static-within-other-static.stderr b/src/test/ui/consts/const-eval/assign-to-static-within-other-static.stderr index bf5e476d80045..4b6784acfcf06 100644 --- a/src/test/ui/consts/const-eval/assign-to-static-within-other-static.stderr +++ b/src/test/ui/consts/const-eval/assign-to-static-within-other-static.stderr @@ -1,5 +1,5 @@ error[E0080]: could not evaluate static initializer - --> $DIR/assign-to-static-within-other-static.rs:10:5 + --> $DIR/assign-to-static-within-other-static.rs:8:5 | LL | FOO = 5; | ^^^^^^^ modifying a static's initial value from another static's initializer diff --git a/src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs b/src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs index 11f6a58be360c..c3f8b9f31ea8d 100644 --- a/src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs +++ b/src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs @@ -1,5 +1,3 @@ -#![feature(const_raw_ptr_deref)] - fn main() {} // fine diff --git a/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr b/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr index ca3290077378a..44fa437806b15 100644 --- a/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr +++ b/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $DIR/const_raw_ptr_ops2.rs:9:26 + --> $DIR/const_raw_ptr_ops2.rs:7:26 | LL | const Z2: i32 = unsafe { *(42 as *const i32) }; | ^^^^^^^^^^^^^^^^^^^ 0x2a is not a valid pointer error[E0080]: evaluation of constant value failed - --> $DIR/const_raw_ptr_ops2.rs:11:26 + --> $DIR/const_raw_ptr_ops2.rs:9:26 | LL | const Z3: i32 = unsafe { *(44 as *const i32) }; | ^^^^^^^^^^^^^^^^^^^ 0x2c is not a valid pointer diff --git a/src/test/ui/consts/const-eval/dangling.rs b/src/test/ui/consts/const-eval/dangling.rs index 610531c7b4c9e..4fcf879218b7e 100644 --- a/src/test/ui/consts/const-eval/dangling.rs +++ b/src/test/ui/consts/const-eval/dangling.rs @@ -1,5 +1,3 @@ -#![feature(const_raw_ptr_deref)] - use std::mem; // Make sure we error with the right kind of error on a too large slice. diff --git a/src/test/ui/consts/const-eval/dangling.stderr b/src/test/ui/consts/const-eval/dangling.stderr index 5665a9c3e0523..92d70573d98a1 100644 --- a/src/test/ui/consts/const-eval/dangling.stderr +++ b/src/test/ui/consts/const-eval/dangling.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/dangling.rs:8:16 + --> $DIR/dangling.rs:6:16 | LL | let _val = &*slice; | ^^^^^^^ invalid metadata in wide pointer: slice is bigger than largest supported object diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs index 4df541eeeb4e9..1a1d9a6d540d8 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs @@ -1,6 +1,5 @@ #![feature(core_intrinsics)] #![feature(const_heap)] -#![feature(const_raw_ptr_deref)] #![feature(const_mut_refs)] use std::intrinsics; diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr index 327e2911205a3..74fb65ca1a658 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr @@ -1,14 +1,14 @@ error[E0080]: evaluation of constant value failed - --> $DIR/alloc_intrinsic_errors.rs:10:17 + --> $DIR/alloc_intrinsic_errors.rs:9:17 | LL | const FOO: i32 = foo(); - | ----- inside `FOO` at $DIR/alloc_intrinsic_errors.rs:7:18 + | ----- inside `FOO` at $DIR/alloc_intrinsic_errors.rs:6:18 ... LL | let _ = intrinsics::const_allocate(4, 3) as * mut i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | align has to be a power of 2, `3` is not a power of 2 - | inside `foo` at $DIR/alloc_intrinsic_errors.rs:10:17 + | inside `foo` at $DIR/alloc_intrinsic_errors.rs:9:17 error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient.rs b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient.rs index de7fb65f6858f..0a8fc7bcaac55 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient.rs +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient.rs @@ -1,7 +1,6 @@ // run-pass #![feature(core_intrinsics)] #![feature(const_heap)] -#![feature(const_raw_ptr_deref)] #![feature(const_mut_refs)] use std::intrinsics; diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs index e6ef9974aa8eb..f746f27000fff 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs @@ -1,6 +1,5 @@ #![feature(core_intrinsics)] #![feature(const_heap)] -#![feature(const_raw_ptr_deref)] #![feature(const_mut_refs)] use std::intrinsics; diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr index 08679350d6d54..adaa4716f1532 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr @@ -1,5 +1,5 @@ error: untyped pointers are not allowed in constant - --> $DIR/alloc_intrinsic_nontransient_fail.rs:7:1 + --> $DIR/alloc_intrinsic_nontransient_fail.rs:6:1 | LL | const FOO: *const i32 = foo(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_transient.rs b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_transient.rs index c55cd32d26425..92193bb33e299 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_transient.rs +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_transient.rs @@ -1,7 +1,6 @@ // run-pass #![feature(core_intrinsics)] #![feature(const_heap)] -#![feature(const_raw_ptr_deref)] #![feature(const_mut_refs)] use std::intrinsics; diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr index c11fea8533d85..597703de01e9e 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc_intrinsic_uninit.rs:9:1 + --> $DIR/alloc_intrinsic_uninit.rs:8:1 | LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr index 58d24dc2e8e0b..08fbb67b37172 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr +++ b/src/test/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:9:1 + --> $DIR/alloc_intrinsic_uninit.rs:8:1 | LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs index 63a3fd4e090ba..b53c9ac7a2c77 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs @@ -2,7 +2,6 @@ // compile-test #![feature(core_intrinsics)] #![feature(const_heap)] -#![feature(const_raw_ptr_deref)] #![feature(const_mut_refs)] use std::intrinsics; diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs index 625f7670bcd63..77871c394b794 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs @@ -1,6 +1,5 @@ #![feature(core_intrinsics)] #![feature(const_heap)] -#![feature(const_raw_ptr_deref)] #![feature(const_mut_refs)] use std::intrinsics; diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr index ee84f8e54f344..8f4fea96c593d 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr @@ -1,5 +1,5 @@ error: untyped pointers are not allowed in constant - --> $DIR/alloc_intrinsic_untyped.rs:7:1 + --> $DIR/alloc_intrinsic_untyped.rs:6:1 | LL | const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/const-eval/mod-static-with-const-fn.rs b/src/test/ui/consts/const-eval/mod-static-with-const-fn.rs index 481e046946344..b6b74e67d20cb 100644 --- a/src/test/ui/consts/const-eval/mod-static-with-const-fn.rs +++ b/src/test/ui/consts/const-eval/mod-static-with-const-fn.rs @@ -1,7 +1,7 @@ // New test for #53818: modifying static memory at compile-time is not allowed. // The test should never compile successfully -#![feature(const_raw_ptr_deref)] +#![feature(const_mut_refs)] use std::cell::UnsafeCell; @@ -14,7 +14,7 @@ static FOO: Foo = Foo(UnsafeCell::new(42)); static BAR: () = unsafe { *FOO.0.get() = 5; - //~^ mutation through a reference + //~^ ERROR could not evaluate static initializer }; fn main() { diff --git a/src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr b/src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr index 38282c0e3005d..d127d1d455bd4 100644 --- a/src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr +++ b/src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr @@ -1,12 +1,9 @@ -error[E0658]: mutation through a reference is not allowed in statics +error[E0080]: could not evaluate static initializer --> $DIR/mod-static-with-const-fn.rs:16:5 | LL | *FOO.0.get() = 5; - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #57349 for more information - = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable + | ^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer error: aborting due to previous error -For more information about this error, try `rustc --explain E0658`. +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/partial_ptr_overwrite.rs b/src/test/ui/consts/const-eval/partial_ptr_overwrite.rs index 5371f9f1749bb..07bca7d64ff69 100644 --- a/src/test/ui/consts/const-eval/partial_ptr_overwrite.rs +++ b/src/test/ui/consts/const-eval/partial_ptr_overwrite.rs @@ -1,5 +1,5 @@ // Test for the behavior described in . -#![feature(const_mut_refs, const_raw_ptr_deref)] +#![feature(const_mut_refs)] const PARTIAL_OVERWRITE: () = { let mut p = &42; diff --git a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs index c7d84303fe54c..1800b0a9785b1 100644 --- a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs +++ b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs @@ -1,5 +1,3 @@ -#![feature(const_raw_ptr_deref)] - fn main() { let x: &'static bool = &(42 as *const i32 == 43 as *const i32); //~^ ERROR temporary value dropped while borrowed diff --git a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr index 7f2e4899184e3..8ac60da38634b 100644 --- a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr +++ b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_raw_ptr_ops.rs:4:29 + --> $DIR/promoted_raw_ptr_ops.rs:2:29 | LL | let x: &'static bool = &(42 as *const i32 == 43 as *const i32); | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use @@ -10,7 +10,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_raw_ptr_ops.rs:6:30 + --> $DIR/promoted_raw_ptr_ops.rs:4:30 | LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); | -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use @@ -21,7 +21,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_raw_ptr_ops.rs:8:28 + --> $DIR/promoted_raw_ptr_ops.rs:6:28 | LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use @@ -32,7 +32,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_raw_ptr_ops.rs:10:29 + --> $DIR/promoted_raw_ptr_ops.rs:8:29 | LL | let a: &'static bool = &(main as fn() == main as fn()); | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use diff --git a/src/test/ui/consts/const-mut-refs/mut_ref_in_final.rs b/src/test/ui/consts/const-mut-refs/mut_ref_in_final.rs index f35f3c5e8ef58..a7d329f125be4 100644 --- a/src/test/ui/consts/const-mut-refs/mut_ref_in_final.rs +++ b/src/test/ui/consts/const-mut-refs/mut_ref_in_final.rs @@ -1,6 +1,5 @@ #![feature(const_mut_refs)] #![feature(raw_ref_op)] -#![feature(const_raw_ptr_deref)] const NULL: *mut i32 = std::ptr::null_mut(); const A: *const i32 = &4; diff --git a/src/test/ui/consts/const-mut-refs/mut_ref_in_final.stderr b/src/test/ui/consts/const-mut-refs/mut_ref_in_final.stderr index fb43ce213176d..3a9ce79f10ef2 100644 --- a/src/test/ui/consts/const-mut-refs/mut_ref_in_final.stderr +++ b/src/test/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:11:21 + --> $DIR/mut_ref_in_final.rs:10:21 | LL | const B: *mut i32 = &mut 4; | ^^^^^^ error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:17:40 + --> $DIR/mut_ref_in_final.rs:16: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:20:42 + --> $DIR/mut_ref_in_final.rs:19: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:35:65 + --> $DIR/mut_ref_in_final.rs:34: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:38:67 + --> $DIR/mut_ref_in_final.rs:37: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:41:71 + --> $DIR/mut_ref_in_final.rs:40:71 | LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- diff --git a/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs b/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs index 24d7bc49147d8..e0704e24a2e68 100644 --- a/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs +++ b/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs @@ -1,6 +1,5 @@ #![feature(const_mut_refs)] #![feature(raw_ref_op)] -#![feature(const_raw_ptr_deref)] // This file checks that our dynamic checks catch things that the static checks miss. // We do not have static checks for these, because we do not look into function bodies. diff --git a/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr b/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr index b3fcd6a7fecd3..7d6716787aad5 100644 --- a/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr +++ b/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of constant value failed - --> $DIR/mut_ref_in_final_dynamic_check.rs:14:10 + --> $DIR/mut_ref_in_final_dynamic_check.rs:13:10 | LL | Some(&mut *(42 as *mut i32)) | ^^^^^^^^^^^^^^^^^^^^^^ | | | 0x2a is not a valid pointer - | inside `helper` at $DIR/mut_ref_in_final_dynamic_check.rs:14:10 + | inside `helper` at $DIR/mut_ref_in_final_dynamic_check.rs:13:10 ... LL | const A: Option<&mut i32> = helper(); - | -------- inside `A` at $DIR/mut_ref_in_final_dynamic_check.rs:19:29 + | -------- inside `A` at $DIR/mut_ref_in_final_dynamic_check.rs:18:29 error: encountered dangling pointer in final constant - --> $DIR/mut_ref_in_final_dynamic_check.rs:26:1 + --> $DIR/mut_ref_in_final_dynamic_check.rs:25:1 | LL | const B: Option<&mut i32> = helper2(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/const-suggest-feature.rs b/src/test/ui/consts/const-suggest-feature.rs index d11b91edb8857..d76d01a3d5ed8 100644 --- a/src/test/ui/consts/const-suggest-feature.rs +++ b/src/test/ui/consts/const-suggest-feature.rs @@ -1,7 +1,7 @@ const WRITE: () = unsafe { *std::ptr::null_mut() = 0; - //~^ ERROR dereferencing raw pointers in constants is unstable - //~| HELP add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + //~^ ERROR dereferencing raw mutable pointers in constants is unstable + //~| HELP add `#![feature(const_mut_refs)]` to the crate attributes to enable }; fn main() {} diff --git a/src/test/ui/consts/const-suggest-feature.stderr b/src/test/ui/consts/const-suggest-feature.stderr index 1ccc3d754ff00..3bc1eacf32f96 100644 --- a/src/test/ui/consts/const-suggest-feature.stderr +++ b/src/test/ui/consts/const-suggest-feature.stderr @@ -1,11 +1,11 @@ -error[E0658]: dereferencing raw pointers in constants is unstable +error[E0658]: dereferencing raw mutable pointers in constants is unstable --> $DIR/const-suggest-feature.rs:2:5 | LL | *std::ptr::null_mut() = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: see issue #51911 for more information - = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error: aborting due to previous error diff --git a/src/test/ui/consts/int_ptr_for_zst_slices.rs b/src/test/ui/consts/int_ptr_for_zst_slices.rs index 34dafd00d28dc..34e5bb322befc 100644 --- a/src/test/ui/consts/int_ptr_for_zst_slices.rs +++ b/src/test/ui/consts/int_ptr_for_zst_slices.rs @@ -1,6 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) - -#![feature(const_raw_ptr_deref)] +// check-pass const FOO: &str = unsafe { &*(1_usize as *const [u8; 0] as *const [u8] as *const str) }; diff --git a/src/test/ui/consts/min_const_fn/allow_raw_ptr_dereference_const_fn.rs b/src/test/ui/consts/min_const_fn/allow_raw_ptr_dereference_const_fn.rs index f4279e6b825e2..d221157556085 100644 --- a/src/test/ui/consts/min_const_fn/allow_raw_ptr_dereference_const_fn.rs +++ b/src/test/ui/consts/min_const_fn/allow_raw_ptr_dereference_const_fn.rs @@ -1,5 +1,4 @@ // check-pass -#![feature(const_raw_ptr_deref)] use std::ptr; diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs b/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs index 719a7a9172a9b..a6e1788bb7f07 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs +++ b/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs @@ -1,10 +1,10 @@ const fn bad_const_fn_deref_raw(x: *mut usize) -> &'static usize { unsafe { &*x } } -//~^ dereferencing raw pointers in constant functions +//~^ dereferencing raw mutable pointers in constant functions const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x } -//~^ dereferencing raw pointers in constant functions +//~^ dereferencing raw mutable pointers in constant functions const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static usize { &*x } -//~^ dereferencing raw pointers in constant functions +//~^ dereferencing raw mutable pointers in constant functions fn main() {} diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr b/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr index 86ff4721c2165..820b6433f36c5 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr @@ -1,29 +1,29 @@ -error[E0658]: dereferencing raw pointers in constant functions is unstable +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 #51911 for more information - = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error[E0658]: dereferencing raw pointers in constant functions is unstable +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 #51911 for more information - = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error[E0658]: dereferencing raw pointers in constant functions is unstable +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 #51911 for more information - = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error: aborting due to 3 previous errors diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr index e5cd86b3d6c2f..c48f59fe84890 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr @@ -33,11 +33,6 @@ help: skipping check that does not even have a feature gate | LL | unsafe { *(&FOO as *const _ as *const usize) } | ^^^ -help: skipping check for `const_raw_ptr_deref` feature - --> $DIR/const_refers_to_static.rs:18:14 - | -LL | unsafe { *(&FOO as *const _ as *const usize) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate --> $DIR/const_refers_to_static.rs:22:32 | diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static2.32bit.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static2.32bit.stderr index 1a6ed0f43b0f1..039b466ee0780 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static2.32bit.stderr +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static2.32bit.stderr @@ -35,11 +35,6 @@ help: skipping check that does not even have a feature gate | LL | unsafe { &*(&FOO as *const _ as *const usize) } | ^^^ -help: skipping check for `const_raw_ptr_deref` feature - --> $DIR/const_refers_to_static2.rs:14:14 - | -LL | unsafe { &*(&FOO as *const _ as *const usize) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate --> $DIR/const_refers_to_static2.rs:21:6 | diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static2.64bit.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static2.64bit.stderr index 4f268dd905d03..e0e2ec31efbaf 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static2.64bit.stderr +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static2.64bit.stderr @@ -35,11 +35,6 @@ help: skipping check that does not even have a feature gate | LL | unsafe { &*(&FOO as *const _ as *const usize) } | ^^^ -help: skipping check for `const_raw_ptr_deref` feature - --> $DIR/const_refers_to_static2.rs:14:14 - | -LL | unsafe { &*(&FOO as *const _ as *const usize) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate --> $DIR/const_refers_to_static2.rs:21:6 | diff --git a/src/test/ui/consts/offset_from.rs b/src/test/ui/consts/offset_from.rs index 8d501e0d95337..4c9b1c1571de4 100644 --- a/src/test/ui/consts/offset_from.rs +++ b/src/test/ui/consts/offset_from.rs @@ -1,6 +1,5 @@ // run-pass -#![feature(const_raw_ptr_deref)] #![feature(const_ptr_offset_from)] struct Struct { diff --git a/src/test/ui/consts/offset_from_ub.rs b/src/test/ui/consts/offset_from_ub.rs index 4b55c299b5c4c..cbc88bc4d9c38 100644 --- a/src/test/ui/consts/offset_from_ub.rs +++ b/src/test/ui/consts/offset_from_ub.rs @@ -1,4 +1,3 @@ -#![feature(const_raw_ptr_deref)] #![feature(const_ptr_offset_from)] #![feature(core_intrinsics)] diff --git a/src/test/ui/consts/offset_from_ub.stderr b/src/test/ui/consts/offset_from_ub.stderr index 2478ff081d770..ffd6ad58c301d 100644 --- a/src/test/ui/consts/offset_from_ub.stderr +++ b/src/test/ui/consts/offset_from_ub.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:18:27 + --> $DIR/offset_from_ub.rs:17:27 | LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from cannot compute offset of pointers into different allocations. @@ -13,25 +13,25 @@ LL | unsafe { intrinsics::ptr_offset_from(self, origin) } | 0x2a is not a valid pointer | inside `ptr::const_ptr::::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/offset_from_ub.rs:24:14 + ::: $DIR/offset_from_ub.rs:23:14 | LL | unsafe { (42 as *const u8).offset_from(&5u8) as usize } - | ----------------------------------- inside `NOT_PTR` at $DIR/offset_from_ub.rs:24:14 + | ----------------------------------- inside `NOT_PTR` at $DIR/offset_from_ub.rs:23:14 error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:31:14 + --> $DIR/offset_from_ub.rs:30:14 | LL | unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 1_isize cannot be divided by 2_isize without remainder error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:37:14 + --> $DIR/offset_from_ub.rs:36:14 | LL | unsafe { ptr_offset_from(ptr, ptr) } | ^^^^^^^^^^^^^^^^^^^^^^^^^ null pointer is not a valid pointer for this operation error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:44:14 + --> $DIR/offset_from_ub.rs:43:14 | LL | unsafe { ptr_offset_from(ptr2, ptr1) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0x10 is not a valid pointer diff --git a/src/test/ui/consts/ptr_comparisons.rs b/src/test/ui/consts/ptr_comparisons.rs index 971b7c3cb179a..8161c7af968bf 100644 --- a/src/test/ui/consts/ptr_comparisons.rs +++ b/src/test/ui/consts/ptr_comparisons.rs @@ -8,7 +8,6 @@ core_intrinsics, const_raw_ptr_comparison, const_ptr_offset, - const_raw_ptr_deref )] const FOO: &usize = &42; diff --git a/src/test/ui/consts/ptr_comparisons.stderr b/src/test/ui/consts/ptr_comparisons.stderr index 48cd5da213f3d..cfec25a7194cb 100644 --- a/src/test/ui/consts/ptr_comparisons.stderr +++ b/src/test/ui/consts/ptr_comparisons.stderr @@ -7,19 +7,19 @@ LL | unsafe { intrinsics::offset(self, count) } | pointer arithmetic failed: alloc3 has size $WORD, so pointer to $TWO_WORDS bytes starting at offset 0 is out-of-bounds | inside `ptr::const_ptr::::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - ::: $DIR/ptr_comparisons.rs:60:34 + ::: $DIR/ptr_comparisons.rs:59:34 | LL | const _: *const usize = unsafe { (FOO as *const usize).offset(2) }; - | ------------------------------- inside `_` at $DIR/ptr_comparisons.rs:60:34 + | ------------------------------- inside `_` at $DIR/ptr_comparisons.rs:59:34 error[E0080]: evaluation of constant value failed - --> $DIR/ptr_comparisons.rs:63:33 + --> $DIR/ptr_comparisons.rs:62:33 | LL | unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 1000]))[999]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: alloc3 has size $WORD, so pointer to 1000 bytes starting at offset 0 is out-of-bounds error: any use of this value will cause an error - --> $DIR/ptr_comparisons.rs:67:27 + --> $DIR/ptr_comparisons.rs:66:27 | LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 }; | --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- @@ -31,7 +31,7 @@ LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + = note: for more information, see issue #71800 error: any use of this value will cause an error - --> $DIR/ptr_comparisons.rs:72:27 + --> $DIR/ptr_comparisons.rs:71:27 | LL | const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 }; | --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- diff --git a/src/test/ui/consts/validate_never_arrays.rs b/src/test/ui/consts/validate_never_arrays.rs index 1990fb073970e..a02e386c66c4d 100644 --- a/src/test/ui/consts/validate_never_arrays.rs +++ b/src/test/ui/consts/validate_never_arrays.rs @@ -1,5 +1,5 @@ // stderr-per-bitwidth -#![feature(const_raw_ptr_deref, never_type)] +#![feature(never_type)] const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior const _: &[!; 0] = unsafe { &*(1_usize as *const [!; 0]) }; // ok diff --git a/src/test/ui/consts/write_to_mut_ref_dest.mut_refs.stderr b/src/test/ui/consts/write_to_mut_ref_dest.mut_refs.stderr deleted file mode 100644 index 3ee50907461ca..0000000000000 --- a/src/test/ui/consts/write_to_mut_ref_dest.mut_refs.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: dereferencing raw pointers in constants is unstable - --> $DIR/write_to_mut_ref_dest.rs:11:18 - | -LL | unsafe { *b = 5; } - | ^^^^^^ - | - = note: see issue #51911 for more information - = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/write_to_mut_ref_dest.rs b/src/test/ui/consts/write_to_mut_ref_dest.rs index d35df330bb8c3..484ec4244355e 100644 --- a/src/test/ui/consts/write_to_mut_ref_dest.rs +++ b/src/test/ui/consts/write_to_mut_ref_dest.rs @@ -1,4 +1,5 @@ // revisions: stock mut_refs +//[mut_refs] check-pass #![cfg_attr(mut_refs, feature(const_mut_refs))] @@ -8,7 +9,7 @@ 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; } //~ ERROR dereferencing raw pointers in constants + unsafe { *b = 5; } //[stock]~ ERROR dereferencing raw mutable pointers in constants } &{a} }; diff --git a/src/test/ui/consts/write_to_mut_ref_dest.stock.stderr b/src/test/ui/consts/write_to_mut_ref_dest.stock.stderr index 2b6d1d3267b61..bb10592760632 100644 --- a/src/test/ui/consts/write_to_mut_ref_dest.stock.stderr +++ b/src/test/ui/consts/write_to_mut_ref_dest.stock.stderr @@ -1,5 +1,5 @@ error[E0658]: mutable references are not allowed in constants - --> $DIR/write_to_mut_ref_dest.rs:10:27 + --> $DIR/write_to_mut_ref_dest.rs:11:27 | LL | let b: *mut u32 = &mut a; | ^^^^^^ @@ -7,14 +7,14 @@ LL | let b: *mut u32 = &mut a; = note: see issue #57349 for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error[E0658]: dereferencing raw pointers in constants is unstable - --> $DIR/write_to_mut_ref_dest.rs:11:18 +error[E0658]: dereferencing raw mutable pointers in constants is unstable + --> $DIR/write_to_mut_ref_dest.rs:12:18 | LL | unsafe { *b = 5; } | ^^^^^^ | - = note: see issue #51911 for more information - = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error: aborting due to 2 previous errors diff --git a/src/test/ui/enum-discriminant/arbitrary_enum_discriminant.rs b/src/test/ui/enum-discriminant/arbitrary_enum_discriminant.rs index f2270602d87eb..22c5332c9259f 100644 --- a/src/test/ui/enum-discriminant/arbitrary_enum_discriminant.rs +++ b/src/test/ui/enum-discriminant/arbitrary_enum_discriminant.rs @@ -1,5 +1,5 @@ // run-pass -#![feature(arbitrary_enum_discriminant, const_raw_ptr_deref, test)] +#![feature(arbitrary_enum_discriminant, test)] extern crate test; diff --git a/src/test/ui/error-codes/E0396-fixed.rs b/src/test/ui/error-codes/E0396-fixed.rs index 654b21f05b6fe..fe20da1a8ea87 100644 --- a/src/test/ui/error-codes/E0396-fixed.rs +++ b/src/test/ui/error-codes/E0396-fixed.rs @@ -1,6 +1,6 @@ -#![feature(const_raw_ptr_deref)] +#![feature(const_mut_refs)] -const REG_ADDR: *const u8 = 0x5f3759df as *const u8; +const REG_ADDR: *mut u8 = 0x5f3759df as *mut u8; const VALUE: u8 = unsafe { *REG_ADDR }; //~^ ERROR evaluation of constant value failed diff --git a/src/test/ui/error-codes/E0396.rs b/src/test/ui/error-codes/E0396.rs index 58ed3c2c7227f..4415b70e75ec3 100644 --- a/src/test/ui/error-codes/E0396.rs +++ b/src/test/ui/error-codes/E0396.rs @@ -1,19 +1,17 @@ -// gate-test-const_raw_ptr_deref - -const REG_ADDR: *const u8 = 0x5f3759df as *const u8; +const REG_ADDR: *mut u8 = 0x5f3759df as *mut u8; const VALUE: u8 = unsafe { *REG_ADDR }; -//~^ ERROR dereferencing raw pointers in constants is unstable +//~^ ERROR dereferencing raw mutable pointers in constants is unstable const unsafe fn unreachable() -> ! { use std::convert::Infallible; - const INFALLIBLE: *const Infallible = [].as_ptr(); + const INFALLIBLE: *mut Infallible = &[] as *const [Infallible] as *const _ as _; match *INFALLIBLE {} - //~^ ERROR dereferencing raw pointers in constant functions is unstable + //~^ ERROR dereferencing raw mutable pointers in constant functions is unstable const BAD: () = unsafe { match *INFALLIBLE {} }; - //~^ ERROR dereferencing raw pointers in constants is unstable + //~^ ERROR dereferencing raw mutable pointers in constants is unstable } fn main() { diff --git a/src/test/ui/error-codes/E0396.stderr b/src/test/ui/error-codes/E0396.stderr index 20dad1b983c1c..8c87f40674f2a 100644 --- a/src/test/ui/error-codes/E0396.stderr +++ b/src/test/ui/error-codes/E0396.stderr @@ -1,29 +1,29 @@ -error[E0658]: dereferencing raw pointers in constants is unstable - --> $DIR/E0396.rs:5:28 +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 #51911 for more information - = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error[E0658]: dereferencing raw pointers in constant functions is unstable - --> $DIR/E0396.rs:12:11 +error[E0658]: dereferencing raw mutable pointers in constant functions is unstable + --> $DIR/E0396.rs:10:11 | LL | match *INFALLIBLE {} | ^^^^^^^^^^^ | - = note: see issue #51911 for more information - = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error[E0658]: dereferencing raw pointers in constants is unstable - --> $DIR/E0396.rs:15:36 +error[E0658]: dereferencing raw mutable pointers in constants is unstable + --> $DIR/E0396.rs:13:36 | LL | const BAD: () = unsafe { match *INFALLIBLE {} }; | ^^^^^^^^^^^ | - = note: see issue #51911 for more information - = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error: aborting due to 3 previous errors diff --git a/src/test/ui/unsafe/unsafe-unstable-const-fn.mir.stderr b/src/test/ui/unsafe/unsafe-unstable-const-fn.mir.stderr index 99808495ea675..dcb84a80cb034 100644 --- a/src/test/ui/unsafe/unsafe-unstable-const-fn.mir.stderr +++ b/src/test/ui/unsafe/unsafe-unstable-const-fn.mir.stderr @@ -1,5 +1,5 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block - --> $DIR/unsafe-unstable-const-fn.rs:11:5 + --> $DIR/unsafe-unstable-const-fn.rs:10:5 | LL | *a == b | ^^ dereference of raw pointer diff --git a/src/test/ui/unsafe/unsafe-unstable-const-fn.rs b/src/test/ui/unsafe/unsafe-unstable-const-fn.rs index 0476759ca6d98..581b15cdfb0cd 100644 --- a/src/test/ui/unsafe/unsafe-unstable-const-fn.rs +++ b/src/test/ui/unsafe/unsafe-unstable-const-fn.rs @@ -3,7 +3,6 @@ #![stable(feature = "foo", since = "1.33.0")] #![feature(staged_api)] -#![feature(const_raw_ptr_deref)] #[stable(feature = "foo", since = "1.33.0")] #[rustc_const_unstable(feature = "const_foo", issue = "none")] diff --git a/src/test/ui/unsafe/unsafe-unstable-const-fn.thir.stderr b/src/test/ui/unsafe/unsafe-unstable-const-fn.thir.stderr index 99808495ea675..dcb84a80cb034 100644 --- a/src/test/ui/unsafe/unsafe-unstable-const-fn.thir.stderr +++ b/src/test/ui/unsafe/unsafe-unstable-const-fn.thir.stderr @@ -1,5 +1,5 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block - --> $DIR/unsafe-unstable-const-fn.rs:11:5 + --> $DIR/unsafe-unstable-const-fn.rs:10:5 | LL | *a == b | ^^ dereference of raw pointer