about summary refs log tree commit diff
path: root/tests/ui/error-codes
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-08-17 14:19:34 +0200
committerRalf Jung <post@ralfj.de>2024-09-15 09:51:32 +0200
commit3175cc2814dfa8a5201fdb165d67cc44300a77f4 (patch)
tree75fa73cd15e7a002db825abb3dbfeb8f6690df87 /tests/ui/error-codes
parent4f1be92153167dfc2a54215bfd49f398c04ce647 (diff)
downloadrust-3175cc2814dfa8a5201fdb165d67cc44300a77f4.tar.gz
rust-3175cc2814dfa8a5201fdb165d67cc44300a77f4.zip
stabilize const_mut_refs
Diffstat (limited to 'tests/ui/error-codes')
-rw-r--r--tests/ui/error-codes/E0017.rs2
-rw-r--r--tests/ui/error-codes/E0017.stderr14
-rw-r--r--tests/ui/error-codes/E0388.rs13
-rw-r--r--tests/ui/error-codes/E0388.stderr55
-rw-r--r--tests/ui/error-codes/E0396-fixed.rs9
-rw-r--r--tests/ui/error-codes/E0396-fixed.stderr9
-rw-r--r--tests/ui/error-codes/E0396.rs20
-rw-r--r--tests/ui/error-codes/E0396.stderr55
8 files changed, 7 insertions, 170 deletions
diff --git a/tests/ui/error-codes/E0017.rs b/tests/ui/error-codes/E0017.rs
index c046f7859fa..e103d3bf5b1 100644
--- a/tests/ui/error-codes/E0017.rs
+++ b/tests/ui/error-codes/E0017.rs
@@ -1,5 +1,3 @@
-#![feature(const_mut_refs)]
-
 //@ normalize-stderr-test: "\(size: ., align: .\)" -> ""
 //@ normalize-stderr-test: " +│ ╾─+╼" -> ""
 
diff --git a/tests/ui/error-codes/E0017.stderr b/tests/ui/error-codes/E0017.stderr
index bb9f718b895..285d363592f 100644
--- a/tests/ui/error-codes/E0017.stderr
+++ b/tests/ui/error-codes/E0017.stderr
@@ -1,5 +1,5 @@
 warning: taking a mutable reference to a `const` item
-  --> $DIR/E0017.rs:10:30
+  --> $DIR/E0017.rs:8:30
    |
 LL | const CR: &'static mut i32 = &mut C;
    |                              ^^^^^^
@@ -7,26 +7,26 @@ LL | const CR: &'static mut i32 = &mut C;
    = note: each usage of a `const` item creates a new temporary
    = note: the mutable reference will refer to this temporary, not the original `const` item
 note: `const` item defined here
-  --> $DIR/E0017.rs:7:1
+  --> $DIR/E0017.rs:5:1
    |
 LL | const C: i32 = 2;
    | ^^^^^^^^^^^^
    = note: `#[warn(const_item_mutation)]` on by default
 
 error[E0764]: mutable references are not allowed in the final value of constants
-  --> $DIR/E0017.rs:10:30
+  --> $DIR/E0017.rs:8:30
    |
 LL | const CR: &'static mut i32 = &mut C;
    |                              ^^^^^^
 
 error[E0596]: cannot borrow immutable static item `X` as mutable
-  --> $DIR/E0017.rs:13:39
+  --> $DIR/E0017.rs:11:39
    |
 LL | static STATIC_REF: &'static mut i32 = &mut X;
    |                                       ^^^^^^ cannot borrow as mutable
 
 warning: taking a mutable reference to a `const` item
-  --> $DIR/E0017.rs:15:38
+  --> $DIR/E0017.rs:13:38
    |
 LL | static CONST_REF: &'static mut i32 = &mut C;
    |                                      ^^^^^^
@@ -34,13 +34,13 @@ LL | static CONST_REF: &'static mut i32 = &mut C;
    = note: each usage of a `const` item creates a new temporary
    = note: the mutable reference will refer to this temporary, not the original `const` item
 note: `const` item defined here
-  --> $DIR/E0017.rs:7:1
+  --> $DIR/E0017.rs:5:1
    |
 LL | const C: i32 = 2;
    | ^^^^^^^^^^^^
 
 error[E0764]: mutable references are not allowed in the final value of statics
-  --> $DIR/E0017.rs:15:38
+  --> $DIR/E0017.rs:13:38
    |
 LL | static CONST_REF: &'static mut i32 = &mut C;
    |                                      ^^^^^^
diff --git a/tests/ui/error-codes/E0388.rs b/tests/ui/error-codes/E0388.rs
deleted file mode 100644
index bbc5f2710bf..00000000000
--- a/tests/ui/error-codes/E0388.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-static X: i32 = 1;
-const C: i32 = 2;
-
-const CR: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed
-
-//~| WARN taking a mutable
-static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0658
-
-static CONST_REF: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed
-
-//~| WARN taking a mutable
-
-fn main() {}
diff --git a/tests/ui/error-codes/E0388.stderr b/tests/ui/error-codes/E0388.stderr
deleted file mode 100644
index cb7047072bd..00000000000
--- a/tests/ui/error-codes/E0388.stderr
+++ /dev/null
@@ -1,55 +0,0 @@
-warning: taking a mutable reference to a `const` item
-  --> $DIR/E0388.rs:4:30
-   |
-LL | const CR: &'static mut i32 = &mut C;
-   |                              ^^^^^^
-   |
-   = note: each usage of a `const` item creates a new temporary
-   = note: the mutable reference will refer to this temporary, not the original `const` item
-note: `const` item defined here
-  --> $DIR/E0388.rs:2:1
-   |
-LL | const C: i32 = 2;
-   | ^^^^^^^^^^^^
-   = note: `#[warn(const_item_mutation)]` on by default
-
-error[E0764]: mutable references are not allowed in the final value of constants
-  --> $DIR/E0388.rs:4:30
-   |
-LL | const CR: &'static mut i32 = &mut C;
-   |                              ^^^^^^
-
-error[E0658]: mutable references are not allowed in statics
-  --> $DIR/E0388.rs:7:39
-   |
-LL | static STATIC_REF: &'static mut i32 = &mut X;
-   |                                       ^^^^^^
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-warning: taking a mutable reference to a `const` item
-  --> $DIR/E0388.rs:9:38
-   |
-LL | static CONST_REF: &'static mut i32 = &mut C;
-   |                                      ^^^^^^
-   |
-   = note: each usage of a `const` item creates a new temporary
-   = note: the mutable reference will refer to this temporary, not the original `const` item
-note: `const` item defined here
-  --> $DIR/E0388.rs:2:1
-   |
-LL | const C: i32 = 2;
-   | ^^^^^^^^^^^^
-
-error[E0764]: mutable references are not allowed in the final value of statics
-  --> $DIR/E0388.rs:9:38
-   |
-LL | static CONST_REF: &'static mut i32 = &mut C;
-   |                                      ^^^^^^
-
-error: aborting due to 3 previous errors; 2 warnings emitted
-
-Some errors have detailed explanations: E0658, E0764.
-For more information about an error, try `rustc --explain E0658`.
diff --git a/tests/ui/error-codes/E0396-fixed.rs b/tests/ui/error-codes/E0396-fixed.rs
deleted file mode 100644
index fe20da1a8ea..00000000000
--- a/tests/ui/error-codes/E0396-fixed.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-#![feature(const_mut_refs)]
-
-const REG_ADDR: *mut u8 = 0x5f3759df as *mut u8;
-
-const VALUE: u8 = unsafe { *REG_ADDR };
-//~^ ERROR evaluation of constant value failed
-
-fn main() {
-}
diff --git a/tests/ui/error-codes/E0396-fixed.stderr b/tests/ui/error-codes/E0396-fixed.stderr
deleted file mode 100644
index c14f4948095..00000000000
--- a/tests/ui/error-codes/E0396-fixed.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0080]: evaluation of constant value failed
-  --> $DIR/E0396-fixed.rs:5:28
-   |
-LL | const VALUE: u8 = unsafe { *REG_ADDR };
-   |                            ^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got 0x5f3759df[noalloc] which is a dangling pointer (it has no provenance)
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/error-codes/E0396.rs b/tests/ui/error-codes/E0396.rs
deleted file mode 100644
index 383eda3d636..00000000000
--- a/tests/ui/error-codes/E0396.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-const REG_ADDR: *mut u8 = 0x5f3759df as *mut u8;
-
-const VALUE: u8 = unsafe { *REG_ADDR };
-//~^ ERROR dereferencing raw mutable pointers in constants is unstable
-
-const unsafe fn unreachable() -> ! {
-    use std::convert::Infallible;
-
-    const INFALLIBLE: *mut Infallible = &[] as *const [Infallible] as *const _ as _;
-    match *INFALLIBLE {}
-    //~^ ERROR dereferencing raw mutable pointers in constant functions is unstable
-    //~| ERROR dereferencing raw mutable pointers in constant functions is unstable
-
-    const BAD: () = unsafe { match *INFALLIBLE {} };
-    //~^ ERROR dereferencing raw mutable pointers in constants is unstable
-    //~| ERROR dereferencing raw mutable pointers in constants is unstable
-}
-
-fn main() {
-}
diff --git a/tests/ui/error-codes/E0396.stderr b/tests/ui/error-codes/E0396.stderr
deleted file mode 100644
index 8bc14139d63..00000000000
--- a/tests/ui/error-codes/E0396.stderr
+++ /dev/null
@@ -1,55 +0,0 @@
-error[E0658]: dereferencing raw mutable pointers in constants is unstable
-  --> $DIR/E0396.rs:3:28
-   |
-LL | const VALUE: u8 = unsafe { *REG_ADDR };
-   |                            ^^^^^^^^^
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error[E0658]: dereferencing raw mutable pointers in constants is unstable
-  --> $DIR/E0396.rs:14:36
-   |
-LL |     const BAD: () = unsafe { match *INFALLIBLE {} };
-   |                                    ^^^^^^^^^^^
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error[E0658]: dereferencing raw mutable pointers in constants is unstable
-  --> $DIR/E0396.rs:14:36
-   |
-LL |     const BAD: () = unsafe { match *INFALLIBLE {} };
-   |                                    ^^^^^^^^^^^
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
-
-error[E0658]: dereferencing raw mutable pointers in constant functions is unstable
-  --> $DIR/E0396.rs:10:11
-   |
-LL |     match *INFALLIBLE {}
-   |           ^^^^^^^^^^^
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error[E0658]: dereferencing raw mutable pointers in constant functions is unstable
-  --> $DIR/E0396.rs:10:11
-   |
-LL |     match *INFALLIBLE {}
-   |           ^^^^^^^^^^^
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
-
-error: aborting due to 5 previous errors
-
-For more information about this error, try `rustc --explain E0658`.