about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2022-09-06 18:41:01 +0200
committerCamille GILLOT <gillot.camille@gmail.com>2023-03-09 17:45:13 +0000
commit4462bb54e3bbff7eecae1816836f306fcc309e05 (patch)
treeaac24138a84068a1ca3a60247704bbcddc241bd4 /tests/ui
parentbe758ef5ab570b7685c9a5eecacab65911da9e6f (diff)
downloadrust-4462bb54e3bbff7eecae1816836f306fcc309e05.tar.gz
rust-4462bb54e3bbff7eecae1816836f306fcc309e05.zip
Introduce a no-op PlaceMention statement for `let _ =`.
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/binding/issue-53114-safety-checks.rs3
-rw-r--r--tests/ui/binding/issue-53114-safety-checks.stderr38
-rw-r--r--tests/ui/unsafe/unsafe-fn-deref-ptr.mir.stderr20
-rw-r--r--tests/ui/unsafe/unsafe-fn-deref-ptr.rs3
-rw-r--r--tests/ui/unsafe/unsafe-fn-deref-ptr.thir.stderr2
5 files changed, 50 insertions, 16 deletions
diff --git a/tests/ui/binding/issue-53114-safety-checks.rs b/tests/ui/binding/issue-53114-safety-checks.rs
index e646dfba3e0..0bffab32782 100644
--- a/tests/ui/binding/issue-53114-safety-checks.rs
+++ b/tests/ui/binding/issue-53114-safety-checks.rs
@@ -21,7 +21,7 @@ fn let_wild_gets_unsafe_field() {
     let u2 = U { a: I(1) };
     let p = P { a: &2, b: &3 };
     let _ = &p.b;  //~ ERROR    reference to packed field
-    let _ = u1.a;  // #53114: should eventually signal error as well
+    let _ = u1.a;  //~ ERROR  [E0133]
     let _ = &u2.a; //~ ERROR  [E0133]
 
     // variation on above with `_` in substructure
@@ -36,6 +36,7 @@ fn let_ascribe_gets_unsafe_field() {
     let p = P { a: &2, b: &3 };
     let _: _ = &p.b;  //~ ERROR    reference to packed field
     let _: _ = u1.a;  //~ ERROR  [E0133]
+                      //~^ ERROR  [E0133]
     let _: _ = &u2.a; //~ ERROR  [E0133]
 
     // variation on above with `_` in substructure
diff --git a/tests/ui/binding/issue-53114-safety-checks.stderr b/tests/ui/binding/issue-53114-safety-checks.stderr
index 0760e04490c..67902ac7b54 100644
--- a/tests/ui/binding/issue-53114-safety-checks.stderr
+++ b/tests/ui/binding/issue-53114-safety-checks.stderr
@@ -26,7 +26,7 @@ LL |     let _: _ = &p.b;
    = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
 
 error[E0793]: reference to packed field is unaligned
-  --> $DIR/issue-53114-safety-checks.rs:42:20
+  --> $DIR/issue-53114-safety-checks.rs:43:20
    |
 LL |     let (_,): _ = (&p.b,);
    |                    ^^^^
@@ -35,7 +35,7 @@ LL |     let (_,): _ = (&p.b,);
    = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
 
 error[E0793]: reference to packed field is unaligned
-  --> $DIR/issue-53114-safety-checks.rs:51:11
+  --> $DIR/issue-53114-safety-checks.rs:52:11
    |
 LL |     match &p.b  { _ => { } }
    |           ^^^^
@@ -44,7 +44,7 @@ LL |     match &p.b  { _ => { } }
    = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
 
 error[E0793]: reference to packed field is unaligned
-  --> $DIR/issue-53114-safety-checks.rs:56:12
+  --> $DIR/issue-53114-safety-checks.rs:57:12
    |
 LL |     match (&p.b,)  { (_,) => { } }
    |            ^^^^
@@ -53,6 +53,14 @@ LL |     match (&p.b,)  { (_,) => { } }
    = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
+  --> $DIR/issue-53114-safety-checks.rs:24:13
+   |
+LL |     let _ = u1.a;
+   |             ^^^^ access to union field
+   |
+   = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
+
+error[E0133]: access to union field is unsafe and requires unsafe function or block
   --> $DIR/issue-53114-safety-checks.rs:25:13
    |
 LL |     let _ = &u2.a;
@@ -77,6 +85,14 @@ LL |     let (_,) = (&u2.a,);
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
+  --> $DIR/issue-53114-safety-checks.rs:38:16
+   |
+LL |     let _: _ = u1.a;
+   |                ^^^^ access to union field
+   |
+   = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
+
+error[E0133]: access to union field is unsafe and requires unsafe function or block
   --> $DIR/issue-53114-safety-checks.rs:38:12
    |
 LL |     let _: _ = u1.a;
@@ -85,7 +101,7 @@ LL |     let _: _ = u1.a;
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/issue-53114-safety-checks.rs:39:16
+  --> $DIR/issue-53114-safety-checks.rs:40:16
    |
 LL |     let _: _ = &u2.a;
    |                ^^^^^ access to union field
@@ -93,7 +109,7 @@ LL |     let _: _ = &u2.a;
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/issue-53114-safety-checks.rs:43:20
+  --> $DIR/issue-53114-safety-checks.rs:44:20
    |
 LL |     let (_,): _ = (u1.a,);
    |                    ^^^^ access to union field
@@ -101,7 +117,7 @@ LL |     let (_,): _ = (u1.a,);
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/issue-53114-safety-checks.rs:44:20
+  --> $DIR/issue-53114-safety-checks.rs:45:20
    |
 LL |     let (_,): _ = (&u2.a,);
    |                    ^^^^^ access to union field
@@ -109,7 +125,7 @@ LL |     let (_,): _ = (&u2.a,);
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/issue-53114-safety-checks.rs:52:11
+  --> $DIR/issue-53114-safety-checks.rs:53:11
    |
 LL |     match u1.a  { _ => { } }
    |           ^^^^ access to union field
@@ -117,7 +133,7 @@ LL |     match u1.a  { _ => { } }
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/issue-53114-safety-checks.rs:53:11
+  --> $DIR/issue-53114-safety-checks.rs:54:11
    |
 LL |     match &u2.a { _ => { } }
    |           ^^^^^ access to union field
@@ -125,7 +141,7 @@ LL |     match &u2.a { _ => { } }
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/issue-53114-safety-checks.rs:57:12
+  --> $DIR/issue-53114-safety-checks.rs:58:12
    |
 LL |     match (u1.a,)  { (_,) => { } }
    |            ^^^^ access to union field
@@ -133,14 +149,14 @@ LL |     match (u1.a,)  { (_,) => { } }
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
 error[E0133]: access to union field is unsafe and requires unsafe function or block
-  --> $DIR/issue-53114-safety-checks.rs:58:12
+  --> $DIR/issue-53114-safety-checks.rs:59:12
    |
 LL |     match (&u2.a,) { (_,) => { } }
    |            ^^^^^ access to union field
    |
    = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
 
-error: aborting due to 17 previous errors
+error: aborting due to 19 previous errors
 
 Some errors have detailed explanations: E0133, E0793.
 For more information about an error, try `rustc --explain E0133`.
diff --git a/tests/ui/unsafe/unsafe-fn-deref-ptr.mir.stderr b/tests/ui/unsafe/unsafe-fn-deref-ptr.mir.stderr
index 62b8710a733..ba89ad97275 100644
--- a/tests/ui/unsafe/unsafe-fn-deref-ptr.mir.stderr
+++ b/tests/ui/unsafe/unsafe-fn-deref-ptr.mir.stderr
@@ -1,4 +1,20 @@
 error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
+  --> $DIR/unsafe-fn-deref-ptr.rs:5:13
+   |
+LL |     let _ = *p;
+   |             ^^ dereference of raw pointer
+   |
+   = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
+
+error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
+  --> $DIR/unsafe-fn-deref-ptr.rs:6:17
+   |
+LL |     let _: u8 = *p;
+   |                 ^^ dereference of raw pointer
+   |
+   = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
+
+error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
   --> $DIR/unsafe-fn-deref-ptr.rs:6:12
    |
 LL |     let _: u8 = *p;
@@ -7,13 +23,13 @@ LL |     let _: u8 = *p;
    = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
 
 error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
-  --> $DIR/unsafe-fn-deref-ptr.rs:7:12
+  --> $DIR/unsafe-fn-deref-ptr.rs:8:12
    |
 LL |     return *p;
    |            ^^ dereference of raw pointer
    |
    = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
 
-error: aborting due to 2 previous errors
+error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0133`.
diff --git a/tests/ui/unsafe/unsafe-fn-deref-ptr.rs b/tests/ui/unsafe/unsafe-fn-deref-ptr.rs
index 72c881061c4..e5c16f044b0 100644
--- a/tests/ui/unsafe/unsafe-fn-deref-ptr.rs
+++ b/tests/ui/unsafe/unsafe-fn-deref-ptr.rs
@@ -2,8 +2,9 @@
 // [thir]compile-flags: -Z thir-unsafeck
 
 fn f(p: *const u8) -> u8 {
-    let _ = *p; //[thir]~ ERROR dereference of raw pointer is unsafe
+    let _ = *p; //~ ERROR dereference of raw pointer is unsafe
     let _: u8 = *p; //~ ERROR dereference of raw pointer is unsafe
+                    //[mir]~^ ERROR dereference of raw pointer is unsafe
     return *p; //~ ERROR dereference of raw pointer is unsafe
 }
 
diff --git a/tests/ui/unsafe/unsafe-fn-deref-ptr.thir.stderr b/tests/ui/unsafe/unsafe-fn-deref-ptr.thir.stderr
index 24313352a41..f42a3f06037 100644
--- a/tests/ui/unsafe/unsafe-fn-deref-ptr.thir.stderr
+++ b/tests/ui/unsafe/unsafe-fn-deref-ptr.thir.stderr
@@ -15,7 +15,7 @@ LL |     let _: u8 = *p;
    = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
 
 error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
-  --> $DIR/unsafe-fn-deref-ptr.rs:7:12
+  --> $DIR/unsafe-fn-deref-ptr.rs:8:12
    |
 LL |     return *p;
    |            ^^ dereference of raw pointer