]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #89551 - jhpratt:stabilize-const_raw_ptr_deref, r=oli-obk
authorbors <bors@rust-lang.org>
Sat, 13 Nov 2021 17:10:15 +0000 (17:10 +0000)
committerbors <bors@rust-lang.org>
Sat, 13 Nov 2021 17:10:15 +0000 (17:10 +0000)
Stabilize `const_raw_ptr_deref` for `*const T`

This stabilizes dereferencing immutable raw pointers in const contexts.
It does not stabilize `*mut T` dereferencing. This is behind the
same feature gate as mutable references.

closes https://github.com/rust-lang/rust/issues/51911

62 files changed:
compiler/rustc_const_eval/src/transform/check_consts/check.rs
compiler/rustc_const_eval/src/transform/check_consts/ops.rs
compiler/rustc_feature/src/accepted.rs
compiler/rustc_feature/src/active.rs
library/core/src/lib.rs
library/core/tests/lib.rs
library/std/src/lib.rs
src/test/ui/consts/const-deref-ptr.rs
src/test/ui/consts/const-deref-ptr.stderr
src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.rs [deleted file]
src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr [deleted file]
src/test/ui/consts/const-eval/assign-to-static-within-other-static.rs
src/test/ui/consts/const-eval/assign-to-static-within-other-static.stderr
src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs
src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr
src/test/ui/consts/const-eval/dangling.rs
src/test/ui/consts/const-eval/dangling.stderr
src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs
src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr
src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient.rs
src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs
src/test/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr
src/test/ui/consts/const-eval/heap/alloc_intrinsic_transient.rs
src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr
src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr
src/test/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs
src/test/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs
src/test/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr
src/test/ui/consts/const-eval/mod-static-with-const-fn.rs
src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr
src/test/ui/consts/const-eval/partial_ptr_overwrite.rs
src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs
src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr
src/test/ui/consts/const-mut-refs/mut_ref_in_final.rs
src/test/ui/consts/const-mut-refs/mut_ref_in_final.stderr
src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs
src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr
src/test/ui/consts/const-suggest-feature.rs
src/test/ui/consts/const-suggest-feature.stderr
src/test/ui/consts/int_ptr_for_zst_slices.rs
src/test/ui/consts/min_const_fn/allow_raw_ptr_dereference_const_fn.rs
src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs
src/test/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr
src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr
src/test/ui/consts/miri_unleashed/const_refers_to_static2.32bit.stderr
src/test/ui/consts/miri_unleashed/const_refers_to_static2.64bit.stderr
src/test/ui/consts/offset_from.rs
src/test/ui/consts/offset_from_ub.rs
src/test/ui/consts/offset_from_ub.stderr
src/test/ui/consts/ptr_comparisons.rs
src/test/ui/consts/ptr_comparisons.stderr
src/test/ui/consts/validate_never_arrays.rs
src/test/ui/consts/write_to_mut_ref_dest.mut_refs.stderr [deleted file]
src/test/ui/consts/write_to_mut_ref_dest.rs
src/test/ui/consts/write_to_mut_ref_dest.stock.stderr
src/test/ui/enum-discriminant/arbitrary_enum_discriminant.rs
src/test/ui/error-codes/E0396-fixed.rs
src/test/ui/error-codes/E0396.rs
src/test/ui/error-codes/E0396.stderr
src/test/ui/unsafe/unsafe-unstable-const-fn.mir.stderr
src/test/ui/unsafe/unsafe-unstable-const-fn.rs
src/test/ui/unsafe/unsafe-unstable-const-fn.thir.stderr

index 61fd828a430020d9c096a7a559135de424924a77..2854e6fd396c243ba358eaa169efff7692dccce8 100644 (file)
@@ -722,7 +722,7 @@ fn visit_projection_elem(
         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 @@ fn visit_projection_elem(
                             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() {
index 230d023efb9fbfbd41f86a8c302f35eb0b1db25c..6391c88600936f12796e25f4fcc514359a09c291 100644 (file)
@@ -400,18 +400,18 @@ fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<
 }
 
 #[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(),),
         )
     }
 }
index 941d957103c0cef98dd5e474ee99fd13caa5ba72..3bd1272c7cb47dcb8038efd809c02dae492cd1aa 100644 (file)
@@ -299,6 +299,8 @@ macro_rules! 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
index 0266b7844ba7fce5181ef9bfef21631e058be0af..d8b4539d831bb8dff367979e48d89be58e149af0 100644 (file)
@@ -408,9 +408,6 @@ pub fn set(&self, features: &mut Features, span: Span) {
     /// 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),
 
index 1099877a008506ea9b58c3206e8a9e0648f9b6c3..584b90d613f6b1583a50824fbb3ed64ffef08b68 100644 (file)
 #![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)]
index 199842f0ab11d42f95b3f77db46c18b42cb910c0..b9acd0d29903d6d14c50c19167b8a2d80d3d9cb5 100644 (file)
@@ -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)]
index 59dff9f6771b6c6c3a0bbf24c18de3c15bf8c364..f2490a77ce0f8aa72a86d9e3c22cb70d413fdaf6 100644 (file)
 #![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)]
index b5f603bb47ac43e9f08a3d76fb066d19214d5cd4..4aca75e3a1793326bbd9d2208dd9c9d6ca547ba9 100644 (file)
@@ -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);
 }
index 61fcb524319d57227b133e665f70e7428f0ee36f..316843889c683ae765112752fe4dfa9cc8d89acd 100644 (file)
@@ -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 <https://github.com/rust-lang/rust/issues/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 (file)
index 037c6f9..0000000
+++ /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<u32>);
-
-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 (file)
index 296a6bf..0000000
+++ /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`.
index 648caae30b4275fdf4dedfeae2a3122d97a759f6..ecf97223f6ada690c3ec193866e3d454bf698268 100644 (file)
@@ -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;
index bf5e476d80045711821a4f014efab4ed776bb231..4b6784acfcf06829e1eff0d79d5671aaeee2ad79 100644 (file)
@@ -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
index 11f6a58be360ce96550a973884a357396f2006af..c3f8b9f31ea8df46dbff623db18c6c1b74e902d9 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_raw_ptr_deref)]
-
 fn main() {}
 
 // fine
index ca3290077378a9edf8a7fb0a3135f9265f5b07a8..44fa437806b15b325c12bbbe60698c4e4cb5a87b 100644 (file)
@@ -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
index 610531c7b4c9e8fad03dcd8703b3fbe66565b542..4fcf879218b7ebbd3e230c6b029fc5f3b0df3de5 100644 (file)
@@ -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.
index 5665a9c3e05239c853efb8059e19c40a4d189f60..92d70573d98a15d709219cc71013dd1ade3a9a2d 100644 (file)
@@ -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
index 4df541eeeb4e9ae14e6da37f044e831a73db56ee..1a1d9a6d540d899e6469740c1cbdc70827d90f82 100644 (file)
@@ -1,6 +1,5 @@
 #![feature(core_intrinsics)]
 #![feature(const_heap)]
-#![feature(const_raw_ptr_deref)]
 #![feature(const_mut_refs)]
 use std::intrinsics;
 
index 327e2911205a3f465aa5d407b612893d2a84585e..74fb65ca1a658fdba44d987d38b55be201d594dc 100644 (file)
@@ -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
 
index de7fb65f6858f513bcf3c0945c625ca98eefa4c4..0a8fc7bcaac55509596e8941d9b3188ea3301cc6 100644 (file)
@@ -1,7 +1,6 @@
 // run-pass
 #![feature(core_intrinsics)]
 #![feature(const_heap)]
-#![feature(const_raw_ptr_deref)]
 #![feature(const_mut_refs)]
 use std::intrinsics;
 
index e6ef9974aa8eb82122f3b392c5e18fe91e66ca98..f746f27000fff32bc0368dbc5c31ba847600997a 100644 (file)
@@ -1,6 +1,5 @@
 #![feature(core_intrinsics)]
 #![feature(const_heap)]
-#![feature(const_raw_ptr_deref)]
 #![feature(const_mut_refs)]
 use std::intrinsics;
 
index 08679350d6d548705ea6bab08c9f02d6495e7d76..adaa4716f1532dd5c28fc3dc79ed0e8c2cbb82d7 100644 (file)
@@ -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();
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
index c55cd32d26425b22b41b99a6b2b865eebe124989..92193bb33e299f05ac69131ac58987fbe762b680 100644 (file)
@@ -1,7 +1,6 @@
 // run-pass
 #![feature(core_intrinsics)]
 #![feature(const_heap)]
-#![feature(const_raw_ptr_deref)]
 #![feature(const_mut_refs)]
 use std::intrinsics;
 
index c11fea8533d8517eeae0d68c4de907b4e43fc35d..597703de01e9e9d724bd6868bd0bdc61b911cfe0 100644 (file)
@@ -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 .<deref>: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
index 58d24dc2e8e0be709bb71448529a50439574d875..08fbb67b37172fa20fc78d37367364f357c0db59 100644 (file)
@@ -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 .<deref>: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
index 63a3fd4e090bae63293ccebb0a27658596546e57..b53c9ac7a2c772402578ec1c82c37f879255174b 100644 (file)
@@ -2,7 +2,6 @@
 // compile-test
 #![feature(core_intrinsics)]
 #![feature(const_heap)]
-#![feature(const_raw_ptr_deref)]
 #![feature(const_mut_refs)]
 use std::intrinsics;
 
index 625f7670bcd63b5b85bae1dfdf1e7b8a2719b03a..77871c394b7947d4a904459c48ffa9344008b812 100644 (file)
@@ -1,6 +1,5 @@
 #![feature(core_intrinsics)]
 #![feature(const_heap)]
-#![feature(const_raw_ptr_deref)]
 #![feature(const_mut_refs)]
 use std::intrinsics;
 
index ee84f8e54f3441d14e9671003e65ddee218ba935..8f4fea96c593dc4197e4e7aeae02935aafa9a798 100644 (file)
@@ -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};
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
index 481e04694634444e68d126e1026d4f74b9d4f25d..b6b74e67d20cb0f0dbb7eae6724424587e18585a 100644 (file)
@@ -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 @@ unsafe impl Sync for Foo {}
 
 static BAR: () = unsafe {
     *FOO.0.get() = 5;
-    //~^ mutation through a reference
+    //~^ ERROR could not evaluate static initializer
 };
 
 fn main() {
index 38282c0e3005dabec9585d1b226c0241756858b4..d127d1d455bd43e978a54fa22fdd0717670080d4 100644 (file)
@@ -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 <https://github.com/rust-lang/rust/issues/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`.
index 5371f9f1749bbe27ab1c63abba78b9847a132262..07bca7d64ff69356600427380426f3b5f98e3bd3 100644 (file)
@@ -1,5 +1,5 @@
 // Test for the behavior described in <https://github.com/rust-lang/rust/issues/87184>.
-#![feature(const_mut_refs, const_raw_ptr_deref)]
+#![feature(const_mut_refs)]
 
 const PARTIAL_OVERWRITE: () = {
     let mut p = &42;
index c7d84303fe54ca6028248b792869357a0605c38e..1800b0a9785b1e0ef127d04ebcda4f0d167b50ac 100644 (file)
@@ -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
index 7f2e4899184e3592dec1c9d2e2c5e258f0e13422..8ac60da38634b8f3b0c1d81f840ea6610316458b 100644 (file)
@@ -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
index f35f3c5e8ef58e78741802c8971f113ea0a2f078..a7d329f125be4ff3a47c07049ff288c2c0d6b7eb 100644 (file)
@@ -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;
index fb43ce213176ddd18c6120096beb2ba734885785..3a9ce79f10ef295b562ba60a0653f6c9cab2cfc4 100644 (file)
@@ -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));
    |                                        -------------------------------^^--
index 24d7bc49147d89df6f825b806763cbfb5f46eb63..e0704e24a2e68ff520f2a07136133bd26da14496 100644 (file)
@@ -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.
index b3fcd6a7fecd3d508239c744e174fa7372c5b187..7d6716787aad5513cd25e51a7f4431a5182afb4f 100644 (file)
@@ -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();
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
index d11b91edb88578ed0ab10bbc4a528c508b746538..d76d01a3d5ed82c33b1958a7492faa82080bc62a 100644 (file)
@@ -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() {}
index 1ccc3d754ff00fda191e8aec7b83cf93cb453199..3bc1eacf32f96edca29c774cce6438b0ea5622cc 100644 (file)
@@ -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 <https://github.com/rust-lang/rust/issues/51911> for more information
-   = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
+   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
+   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
 
 error: aborting due to previous error
 
index 34dafd00d28dc8e85fe85febc058825f0c5f8024..34e5bb322befc2e6ca581eaadfece07ca6f7d2b7 100644 (file)
@@ -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) };
 
index f4279e6b825e2d26ef15a75bef7d471b250f2558..d221157556085ceea53f1cd8c60d136a1850b71f 100644 (file)
@@ -1,5 +1,4 @@
 // check-pass
-#![feature(const_raw_ptr_deref)]
 
 use std::ptr;
 
index 719a7a9172a9b89e47ca3476bd4cb8a96ad5c296..a6e1788bb7f0762dc9c29b72e9e5cd55b02c6255 100644 (file)
@@ -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() {}
index 86ff4721c2165de3c282ceb008caa8d6cc8b28e2..820b6433f36c524c050c91df99160cac254281d2 100644 (file)
@@ -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 <https://github.com/rust-lang/rust/issues/51911> for more information
-   = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
+   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/51911> for more information
-   = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
+   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/51911> for more information
-   = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
+   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
+   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
 
 error: aborting due to 3 previous errors
 
index e5cd86b3d6c2f316c2020761013db9c5cb7b3530..c48f59fe84890ec964fe12e0aa307f1722ecf152 100644 (file)
@@ -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
    |
index 1a6ed0f43b0f1d0581a03e8cc167a328f3b56d0c..039b466ee078056bb67abcbec952eeca0e66765b 100644 (file)
@@ -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
    |
index 4f268dd905d03d9aae102ea6890d27c3effe3867..e0e2ec31efbaf7773a5dad210bbd8bb1a86c7d17 100644 (file)
@@ -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
    |
index 8d501e0d9533783f0e83a46f637b794affbb6e71..4c9b1c1571de41bf4f1874ea5a1d8cca732e0b7f 100644 (file)
@@ -1,6 +1,5 @@
 // run-pass
 
-#![feature(const_raw_ptr_deref)]
 #![feature(const_ptr_offset_from)]
 
 struct Struct {
index 4b55c299b5c4c93901bd44cc47acbdb8a73992bf..cbc88bc4d9c382999971f5095021a03641ecd160 100644 (file)
@@ -1,4 +1,3 @@
-#![feature(const_raw_ptr_deref)]
 #![feature(const_ptr_offset_from)]
 #![feature(core_intrinsics)]
 
index 2478ff081d770ed1f86f8b3f6594f18527111f51..ffd6ad58c301d69e392006cc569bbfac09957102 100644 (file)
@@ -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::<impl *const u8>::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
index 971b7c3cb179af680cea13be5d2acc7d79fdb77a..8161c7af968bf70f90df36e3366961965f48700e 100644 (file)
@@ -8,7 +8,6 @@
     core_intrinsics,
     const_raw_ptr_comparison,
     const_ptr_offset,
-    const_raw_ptr_deref
 )]
 
 const FOO: &usize = &42;
index 48cd5da213f3df9f7e91c81e3e111c415ecdeab3..cfec25a7194cbbb194fb22670546aca52c8469aa 100644 (file)
@@ -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::<impl *const usize>::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 <https://github.com/rust-lang/rust/issues/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 };
    | --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
index 1990fb073970ecc903b6d4160341f80fd4d7c0bb..a02e386c66c4d3550442cdd9edd6906f9b304999 100644 (file)
@@ -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 (file)
index 3ee5090..0000000
+++ /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 <https://github.com/rust-lang/rust/issues/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`.
index d35df330bb8c33c956480b628daf3b857019d1ca..484ec4244355edf7f3d53bde410d2c057783d662 100644 (file)
@@ -1,4 +1,5 @@
 // revisions: stock mut_refs
+//[mut_refs] check-pass
 
 #![cfg_attr(mut_refs, feature(const_mut_refs))]
 
@@ -8,7 +9,7 @@
     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}
 };
index 2b6d1d3267b619ebc6769d85f2710c8ff3cb159d..bb10592760632b9610b292bb03303432c248e643 100644 (file)
@@ -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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/51911> for more information
-   = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
+   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
+   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
 
 error: aborting due to 2 previous errors
 
index f2270602d87ebce98a3f9cbd0438dbf96b1967e2..22c5332c9259fe9dbec36648690045cd8253fecc 100644 (file)
@@ -1,5 +1,5 @@
 // run-pass
-#![feature(arbitrary_enum_discriminant, const_raw_ptr_deref, test)]
+#![feature(arbitrary_enum_discriminant, test)]
 
 extern crate test;
 
index 654b21f05b6fe58e315fa586b73f59969c9e8b20..fe20da1a8ea87fa88b4a1e6eb872db31a5c97c03 100644 (file)
@@ -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
index 58ed3c2c7227fd1f96647e2fd51cd7eb87a4d5bb..4415b70e75ec354227fbfdbd1c268b7877e54118 100644 (file)
@@ -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() {
index 20dad1b983c1c917d02193df92ac5e1b7905e877..8c87f40674f2afb8c61fb8053f9026e2f8e1cbaf 100644 (file)
@@ -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 <https://github.com/rust-lang/rust/issues/51911> for more information
-   = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
+   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/51911> for more information
-   = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
+   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/51911> for more information
-   = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
+   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
+   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
 
 error: aborting due to 3 previous errors
 
index 99808495ea6757b2c73ae47906ad28b227053e36..dcb84a80cb034da634e3debfee374513cce5bff8 100644 (file)
@@ -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
index 0476759ca6d980f44af8889e640d5030178e0f79..581b15cdfb0cd4796bbdc4582259c28d039d4663 100644 (file)
@@ -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")]
index 99808495ea6757b2c73ae47906ad28b227053e36..dcb84a80cb034da634e3debfee374513cce5bff8 100644 (file)
@@ -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