about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir1
-rw-r--r--tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir1
-rw-r--r--tests/mir-opt/building/match_false_edges.main.built.after.mir1
-rw-r--r--tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir1
-rw-r--r--tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir1
-rw-r--r--tests/mir-opt/issue_72181.main.built.after.mir2
-rw-r--r--tests/mir-opt/issue_91633.bar.built.after.mir1
-rw-r--r--tests/mir-opt/issue_91633.hey.built.after.mir1
-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
13 files changed, 59 insertions, 16 deletions
diff --git a/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir b/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir
index cb36bc64da6..0e6de839df3 100644
--- a/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir
+++ b/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir
@@ -100,6 +100,7 @@ fn full_tested_match() -> () {
     }
 
     bb11: {
+        PlaceMention(_1);                // scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6
         StorageDead(_2);                 // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
         StorageDead(_1);                 // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
         _0 = const ();                   // scope 0 at $DIR/match_false_edges.rs:+0:28: +6:2
diff --git a/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir b/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir
index 7f8755faac6..37e6b1cd4b4 100644
--- a/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir
+++ b/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir
@@ -100,6 +100,7 @@ fn full_tested_match2() -> () {
     }
 
     bb11: {
+        PlaceMention(_1);                // scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6
         StorageDead(_2);                 // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
         StorageDead(_1);                 // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
         _0 = const ();                   // scope 0 at $DIR/match_false_edges.rs:+0:29: +6:2
diff --git a/tests/mir-opt/building/match_false_edges.main.built.after.mir b/tests/mir-opt/building/match_false_edges.main.built.after.mir
index e8b93f4371e..7b8983138d2 100644
--- a/tests/mir-opt/building/match_false_edges.main.built.after.mir
+++ b/tests/mir-opt/building/match_false_edges.main.built.after.mir
@@ -162,6 +162,7 @@ fn main() -> () {
     }
 
     bb19: {
+        PlaceMention(_1);                // scope 0 at $DIR/match_false_edges.rs:+1:13: +6:6
         StorageDead(_2);                 // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7
         StorageDead(_1);                 // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7
         _0 = const ();                   // scope 0 at $DIR/match_false_edges.rs:+0:11: +7:2
diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir
index 234cd083977..d80a77fefe5 100644
--- a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir
+++ b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir
@@ -77,6 +77,7 @@ fn move_out_by_subslice() -> () {
     bb6: {
         StorageDead(_2);                 // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
         FakeRead(ForLet(None), _1);      // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
+        PlaceMention(_1);                // scope 1 at $DIR/uniform_array_move_out.rs:+2:21: +2:22
         StorageLive(_12);                // scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12
         _12 = move _1[0..2];             // scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12
         _0 = const ();                   // scope 0 at $DIR/uniform_array_move_out.rs:+0:27: +3:2
diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir
index 24a189498d3..5f5c18c9f0c 100644
--- a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir
+++ b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir
@@ -77,6 +77,7 @@ fn move_out_from_end() -> () {
     bb6: {
         StorageDead(_2);                 // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
         FakeRead(ForLet(None), _1);      // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
+        PlaceMention(_1);                // scope 1 at $DIR/uniform_array_move_out.rs:+2:20: +2:21
         StorageLive(_12);                // scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16
         _12 = move _1[1 of 2];           // scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16
         _0 = const ();                   // scope 0 at $DIR/uniform_array_move_out.rs:+0:24: +3:2
diff --git a/tests/mir-opt/issue_72181.main.built.after.mir b/tests/mir-opt/issue_72181.main.built.after.mir
index e8683692770..724e55e17fb 100644
--- a/tests/mir-opt/issue_72181.main.built.after.mir
+++ b/tests/mir-opt/issue_72181.main.built.after.mir
@@ -29,6 +29,7 @@ fn main() -> () {
     }
 
     bb1: {
+        PlaceMention(_1);                // scope 0 at $DIR/issue_72181.rs:+1:13: +1:34
         StorageDead(_1);                 // scope 0 at $DIR/issue_72181.rs:+1:34: +1:35
         StorageLive(_2);                 // scope 1 at $DIR/issue_72181.rs:+3:9: +3:10
         StorageLive(_3);                 // scope 1 at $DIR/issue_72181.rs:+3:14: +3:27
@@ -49,6 +50,7 @@ fn main() -> () {
 
     bb2: {
         _5 = (_2[_6].0: u64);            // scope 4 at $DIR/issue_72181.rs:+4:22: +4:28
+        PlaceMention(_5);                // scope 2 at $DIR/issue_72181.rs:+4:13: +4:30
         StorageDead(_6);                 // scope 2 at $DIR/issue_72181.rs:+4:30: +4:31
         StorageDead(_5);                 // scope 2 at $DIR/issue_72181.rs:+4:30: +4:31
         _0 = const ();                   // scope 0 at $DIR/issue_72181.rs:+0:11: +5:2
diff --git a/tests/mir-opt/issue_91633.bar.built.after.mir b/tests/mir-opt/issue_91633.bar.built.after.mir
index c3fb90e8402..760e5a8f90a 100644
--- a/tests/mir-opt/issue_91633.bar.built.after.mir
+++ b/tests/mir-opt/issue_91633.bar.built.after.mir
@@ -20,6 +20,7 @@ fn bar(_1: Box<[T]>) -> () {
 
     bb1: {
         StorageDead(_3);                 // scope 0 at $DIR/issue_91633.rs:+4:18: +4:19
+        PlaceMention((*_2));             // scope 0 at $DIR/issue_91633.rs:+4:14: +4:19
         StorageDead(_2);                 // scope 0 at $DIR/issue_91633.rs:+4:19: +4:20
         _0 = const ();                   // scope 0 at $DIR/issue_91633.rs:+3:2: +5:3
         drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue_91633.rs:+5:2: +5:3
diff --git a/tests/mir-opt/issue_91633.hey.built.after.mir b/tests/mir-opt/issue_91633.hey.built.after.mir
index ccb06dd5983..19f0c133e2e 100644
--- a/tests/mir-opt/issue_91633.hey.built.after.mir
+++ b/tests/mir-opt/issue_91633.hey.built.after.mir
@@ -23,6 +23,7 @@ fn hey(_1: &[T]) -> () {
     bb1: {
         StorageDead(_4);                 // scope 0 at $DIR/issue_91633.rs:+4:19: +4:20
         _2 = &(*_3);                     // scope 0 at $DIR/issue_91633.rs:+4:14: +4:20
+        PlaceMention(_2);                // scope 0 at $DIR/issue_91633.rs:+4:14: +4:20
         StorageDead(_2);                 // scope 0 at $DIR/issue_91633.rs:+4:20: +4:21
         _0 = const ();                   // scope 0 at $DIR/issue_91633.rs:+3:2: +5:3
         StorageDead(_3);                 // scope 0 at $DIR/issue_91633.rs:+5:2: +5:3
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