about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-02-05 20:51:33 -0800
committerMichael Goulet <michael@errs.io>2022-02-11 12:45:51 -0800
commit06eb912e761d39c63490ab5e688abcf2f94fc61d (patch)
tree340ed5c2093f1dbd8f6ae4e3fc88cdb6d0563f99
parent77dae2d25d900a8e7493c548498cdc94bdcee3d9 (diff)
downloadrust-06eb912e761d39c63490ab5e688abcf2f94fc61d.tar.gz
rust-06eb912e761d39c63490ab5e688abcf2f94fc61d.zip
fix tests, add new tests checking borrowck CFTE ICE
-rw-r--r--src/test/ui/const-generics/const-generic-default-wont-borrowck.rs6
-rw-r--r--src/test/ui/const-generics/const-generic-default-wont-borrowck.stderr9
-rw-r--r--src/test/ui/consts/const-mut-refs/issue-76510.32bit.stderr17
-rw-r--r--src/test/ui/consts/const-mut-refs/issue-76510.64bit.stderr17
-rw-r--r--src/test/ui/consts/const-mut-refs/issue-76510.rs1
-rw-r--r--src/test/ui/consts/issue-78655.rs2
-rw-r--r--src/test/ui/consts/issue-78655.stderr11
7 files changed, 23 insertions, 40 deletions
diff --git a/src/test/ui/const-generics/const-generic-default-wont-borrowck.rs b/src/test/ui/const-generics/const-generic-default-wont-borrowck.rs
new file mode 100644
index 00000000000..bb5a2f1766f
--- /dev/null
+++ b/src/test/ui/const-generics/const-generic-default-wont-borrowck.rs
@@ -0,0 +1,6 @@
+struct X<const N: usize = {
+    let s: &'static str; s.len()
+    //~^ ERROR borrow of possibly-uninitialized variable
+}>;
+
+fn main() {}
diff --git a/src/test/ui/const-generics/const-generic-default-wont-borrowck.stderr b/src/test/ui/const-generics/const-generic-default-wont-borrowck.stderr
new file mode 100644
index 00000000000..6c25019b0ce
--- /dev/null
+++ b/src/test/ui/const-generics/const-generic-default-wont-borrowck.stderr
@@ -0,0 +1,9 @@
+error[E0381]: borrow of possibly-uninitialized variable: `s`
+  --> $DIR/const-generic-default-wont-borrowck.rs:2:26
+   |
+LL |     let s: &'static str; s.len()
+   |                          ^^^^^^^ use of possibly-uninitialized `*s`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0381`.
diff --git a/src/test/ui/consts/const-mut-refs/issue-76510.32bit.stderr b/src/test/ui/consts/const-mut-refs/issue-76510.32bit.stderr
index a9411fb0e3d..61b00be345f 100644
--- a/src/test/ui/consts/const-mut-refs/issue-76510.32bit.stderr
+++ b/src/test/ui/consts/const-mut-refs/issue-76510.32bit.stderr
@@ -19,18 +19,7 @@ error[E0596]: cannot borrow data in a `&` reference as mutable
 LL | const S: &'static mut str = &mut " hello ";
    |                             ^^^^^^^^^^^^^^ cannot borrow as mutable
 
-error[E0080]: it is undefined behavior to use this value
-  --> $DIR/issue-76510.rs:5:1
-   |
-LL | const S: &'static mut str = &mut " hello ";
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered mutable reference in a `const`
-   |
-   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
-   = note: the raw bytes of the constant (size: 8, align: 4) {
-               ╾─alloc3──╼ 07 00 00 00                         │ ╾──╼....
-           }
-
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
 
-Some errors have detailed explanations: E0080, E0596, E0658, E0764.
-For more information about an error, try `rustc --explain E0080`.
+Some errors have detailed explanations: E0596, E0658, E0764.
+For more information about an error, try `rustc --explain E0596`.
diff --git a/src/test/ui/consts/const-mut-refs/issue-76510.64bit.stderr b/src/test/ui/consts/const-mut-refs/issue-76510.64bit.stderr
index 9ad5f20d57c..61b00be345f 100644
--- a/src/test/ui/consts/const-mut-refs/issue-76510.64bit.stderr
+++ b/src/test/ui/consts/const-mut-refs/issue-76510.64bit.stderr
@@ -19,18 +19,7 @@ error[E0596]: cannot borrow data in a `&` reference as mutable
 LL | const S: &'static mut str = &mut " hello ";
    |                             ^^^^^^^^^^^^^^ cannot borrow as mutable
 
-error[E0080]: it is undefined behavior to use this value
-  --> $DIR/issue-76510.rs:5:1
-   |
-LL | const S: &'static mut str = &mut " hello ";
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered mutable reference in a `const`
-   |
-   = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
-   = note: the raw bytes of the constant (size: 16, align: 8) {
-               ╾───────alloc3────────╼ 07 00 00 00 00 00 00 00 │ ╾──────╼........
-           }
-
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
 
-Some errors have detailed explanations: E0080, E0596, E0658, E0764.
-For more information about an error, try `rustc --explain E0080`.
+Some errors have detailed explanations: E0596, E0658, E0764.
+For more information about an error, try `rustc --explain E0596`.
diff --git a/src/test/ui/consts/const-mut-refs/issue-76510.rs b/src/test/ui/consts/const-mut-refs/issue-76510.rs
index 892f6c98116..143d2fb6b9a 100644
--- a/src/test/ui/consts/const-mut-refs/issue-76510.rs
+++ b/src/test/ui/consts/const-mut-refs/issue-76510.rs
@@ -6,7 +6,6 @@ const S: &'static mut str = &mut " hello ";
 //~^ ERROR: mutable references are not allowed in the final value of constants
 //~| ERROR: mutation through a reference is not allowed in constants
 //~| ERROR: cannot borrow data in a `&` reference as mutable
-//~| ERROR: it is undefined behavior to use this value
 
 const fn trigger() -> [(); unsafe {
         let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3));
diff --git a/src/test/ui/consts/issue-78655.rs b/src/test/ui/consts/issue-78655.rs
index 066764bc46f..b85e6129925 100644
--- a/src/test/ui/consts/issue-78655.rs
+++ b/src/test/ui/consts/issue-78655.rs
@@ -1,4 +1,4 @@
-const FOO: *const u32 = { //~ ERROR encountered dangling pointer in final constant
+const FOO: *const u32 = {
     let x;
     &x //~ ERROR borrow of possibly-uninitialized variable: `x`
 };
diff --git a/src/test/ui/consts/issue-78655.stderr b/src/test/ui/consts/issue-78655.stderr
index cf3fe18f802..734266a3453 100644
--- a/src/test/ui/consts/issue-78655.stderr
+++ b/src/test/ui/consts/issue-78655.stderr
@@ -4,15 +4,6 @@ error[E0381]: borrow of possibly-uninitialized variable: `x`
 LL |     &x
    |     ^^ use of possibly-uninitialized `x`
 
-error: encountered dangling pointer in final constant
-  --> $DIR/issue-78655.rs:1:1
-   |
-LL | / const FOO: *const u32 = {
-LL | |     let x;
-LL | |     &x
-LL | | };
-   | |__^
-
 error: could not evaluate constant pattern
   --> $DIR/issue-78655.rs:7:9
    |
@@ -25,6 +16,6 @@ error: could not evaluate constant pattern
 LL |     let FOO = FOO;
    |         ^^^
 
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0381`.