]> git.lizzy.rs Git - rust.git/commitdiff
slightly improve protector-related error messages
authorRalf Jung <post@ralfj.de>
Sat, 27 Aug 2022 15:19:35 +0000 (11:19 -0400)
committerRalf Jung <post@ralfj.de>
Sun, 28 Aug 2022 13:27:10 +0000 (09:27 -0400)
also rename some tests that still used outdated "barrier" terminology

22 files changed:
src/stacked_borrows/diagnostics.rs
tests/fail/stacked_borrows/aliasing_mut1.stderr
tests/fail/stacked_borrows/aliasing_mut2.stderr
tests/fail/stacked_borrows/aliasing_mut4.stderr
tests/fail/stacked_borrows/deallocate_against_barrier1.rs [deleted file]
tests/fail/stacked_borrows/deallocate_against_barrier1.stderr [deleted file]
tests/fail/stacked_borrows/deallocate_against_barrier2.rs [deleted file]
tests/fail/stacked_borrows/deallocate_against_barrier2.stderr [deleted file]
tests/fail/stacked_borrows/deallocate_against_protector1.rs [new file with mode: 0644]
tests/fail/stacked_borrows/deallocate_against_protector1.stderr [new file with mode: 0644]
tests/fail/stacked_borrows/deallocate_against_protector2.rs [new file with mode: 0644]
tests/fail/stacked_borrows/deallocate_against_protector2.stderr [new file with mode: 0644]
tests/fail/stacked_borrows/illegal_write6.stderr
tests/fail/stacked_borrows/invalidate_against_barrier1.rs [deleted file]
tests/fail/stacked_borrows/invalidate_against_barrier1.stderr [deleted file]
tests/fail/stacked_borrows/invalidate_against_barrier2.rs [deleted file]
tests/fail/stacked_borrows/invalidate_against_barrier2.stderr [deleted file]
tests/fail/stacked_borrows/invalidate_against_protector1.rs [new file with mode: 0644]
tests/fail/stacked_borrows/invalidate_against_protector1.stderr [new file with mode: 0644]
tests/fail/stacked_borrows/invalidate_against_protector2.rs [new file with mode: 0644]
tests/fail/stacked_borrows/invalidate_against_protector2.stderr [new file with mode: 0644]
tests/fail/stacked_borrows/newtype_retagging.stderr

index 741a3d363dd35facc6c2a570d172c572f7b79103..87f0ce74191815fcf3b70efa0a038c8cc93bed5a 100644 (file)
@@ -2,7 +2,7 @@
 use std::fmt;
 
 use rustc_middle::mir::interpret::{alloc_range, AllocId, AllocRange};
-use rustc_span::{Span, SpanData};
+use rustc_span::{Span, SpanData, DUMMY_SP};
 use rustc_target::abi::Size;
 
 use crate::helpers::CurrentSpan;
@@ -91,6 +91,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 
 #[derive(Clone, Debug)]
 struct Protection {
+    /// The parent tag from which this protected tag was derived.
     orig_tag: ProvenanceExtra,
     tag: SbTag,
     span: Span,
@@ -342,32 +343,39 @@ pub fn get_logs_relevant_to(
 
         let protected = protector_tag
             .and_then(|protector| {
-                self.history.protectors.iter().find_map(|protection| {
-                    if protection.tag == protector {
-                        Some((protection.orig_tag, protection.span.data()))
-                    } else {
-                        None
-                    }
+                self.history.protectors.iter().find(|protection| {
+                    protection.tag == protector
                 })
             })
-            .and_then(|(tag, call_span)| {
+            .and_then(|protection| {
                 self.history.creations.iter().rev().find_map(|event| {
-                    if ProvenanceExtra::Concrete(event.retag.new_tag) == tag {
-                        Some((event.retag.orig_tag, event.span.data(), call_span))
+                    if ProvenanceExtra::Concrete(event.retag.new_tag) == protection.orig_tag {
+                        Some((protection, event))
                     } else {
                         None
                     }
                 })
             })
-            .map(|(protecting_tag, protecting_tag_span, protection_span)| {
+            .map(|(protection, protection_parent)| {
+                let protected_tag = protection.tag;
                 [
                     (
                         format!(
-                            "{tag:?} was protected due to {protecting_tag:?} which was created here"
+                            "{tag:?} cannot be used for memory access because that would remove protected tag {protected_tag:?}, protected by this function call",
                         ),
-                        protecting_tag_span,
+                        protection.span.data(),
                     ),
-                    (format!("this protector is live for this call"), protection_span),
+                    if protection_parent.retag.new_tag == tag {
+                        (format!("{protected_tag:?} was derived from {tag:?}, the tag used for this memory access"), DUMMY_SP.data())
+                    } else {
+                        (
+                            format!(
+                                "{protected_tag:?} was derived from {protected_parent_tag:?}, which in turn was created here",
+                                protected_parent_tag = protection_parent.retag.new_tag,
+                            ),
+                            protection_parent.span.data()
+                        )
+                    }
                 ]
             });
 
index e3f05f3350a5c60842fe241edff11c2ce29cc42c..e5be3061b32c4a210203ae4b6cbbfa8be63ebd55 100644 (file)
@@ -11,16 +11,12 @@ help: <TAG> was created by a Unique retag at offsets [0x0..0x4]
    |
 LL |     let xraw: *mut i32 = unsafe { mem::transmute(&mut x) };
    |                                                  ^^^^^^
-help: <TAG> was protected due to <TAG> which was created here
-  --> $DIR/aliasing_mut1.rs:LL:CC
-   |
-LL |     let xraw: *mut i32 = unsafe { mem::transmute(&mut x) };
-   |                                                  ^^^^^^
-help: this protector is live for this call
+help: <TAG> cannot be used for memory access because that would remove protected tag <TAG>, protected by this function call
   --> $DIR/aliasing_mut1.rs:LL:CC
    |
 LL | pub fn safe(_x: &mut i32, _y: &mut i32) {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = help: <TAG> was derived from <TAG>, the tag used for this memory access
    = note: backtrace:
    = note: inside `safe` at $DIR/aliasing_mut1.rs:LL:CC
 note: inside `main` at $DIR/aliasing_mut1.rs:LL:CC
index 94c2ffa07f7159c06d01f623b062fdbaf8fc5809..c3dd3a893c0724d646fb3280789dc1b58c76a621 100644 (file)
@@ -11,16 +11,16 @@ help: <TAG> was created by a Unique retag at offsets [0x0..0x4]
    |
 LL |     let xref = &mut x;
    |                ^^^^^^
-help: <TAG> was protected due to <TAG> which was created here
-  --> $DIR/aliasing_mut2.rs:LL:CC
-   |
-LL |     safe_raw(xshr, xraw);
-   |              ^^^^
-help: this protector is live for this call
+help: <TAG> cannot be used for memory access because that would remove protected tag <TAG>, protected by this function call
   --> $DIR/aliasing_mut2.rs:LL:CC
    |
 LL | pub fn safe(_x: &i32, _y: &mut i32) {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: <TAG> was derived from <TAG>, which in turn was created here
+  --> $DIR/aliasing_mut2.rs:LL:CC
+   |
+LL |     safe_raw(xshr, xraw);
+   |              ^^^^
    = note: backtrace:
    = note: inside `safe` at $DIR/aliasing_mut2.rs:LL:CC
 note: inside `main` at $DIR/aliasing_mut2.rs:LL:CC
index f48d39b2e49f0154657dfab36e3d0c398a414bf0..601422ece3020c59a40aa5a4733cceea044023f5 100644 (file)
@@ -11,16 +11,16 @@ help: <TAG> was created by a Unique retag at offsets [0x0..0x4]
    |
 LL |     let xref = &mut x;
    |                ^^^^^^
-help: <TAG> was protected due to <TAG> which was created here
-  --> $DIR/aliasing_mut4.rs:LL:CC
-   |
-LL |     safe_raw(xshr, xraw as *mut _);
-   |              ^^^^
-help: this protector is live for this call
+help: <TAG> cannot be used for memory access because that would remove protected tag <TAG>, protected by this function call
   --> $DIR/aliasing_mut4.rs:LL:CC
    |
 LL | pub fn safe(_x: &i32, _y: &mut Cell<i32>) {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: <TAG> was derived from <TAG>, which in turn was created here
+  --> $DIR/aliasing_mut4.rs:LL:CC
+   |
+LL |     safe_raw(xshr, xraw as *mut _);
+   |              ^^^^
    = note: backtrace:
    = note: inside `safe` at $DIR/aliasing_mut4.rs:LL:CC
 note: inside `main` at $DIR/aliasing_mut4.rs:LL:CC
diff --git a/tests/fail/stacked_borrows/deallocate_against_barrier1.rs b/tests/fail/stacked_borrows/deallocate_against_barrier1.rs
deleted file mode 100644 (file)
index 9b71042..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-//@error-pattern: /deallocating while item \[Unique for .*\] is protected/
-
-fn inner(x: &mut i32, f: fn(&mut i32)) {
-    // `f` may mutate, but it may not deallocate!
-    f(x)
-}
-
-fn main() {
-    inner(Box::leak(Box::new(0)), |x| {
-        let raw = x as *mut _;
-        drop(unsafe { Box::from_raw(raw) });
-    });
-}
diff --git a/tests/fail/stacked_borrows/deallocate_against_barrier1.stderr b/tests/fail/stacked_borrows/deallocate_against_barrier1.stderr
deleted file mode 100644 (file)
index 689c0a5..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-error: Undefined Behavior: deallocating while item [Unique for <TAG>] is protected by call ID
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
-   |
-LL |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating while item [Unique for <TAG>] is protected by call ID
-   |
-   = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
-   = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
-   = note: backtrace:
-   = note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `alloc::alloc::box_free::<i32, std::alloc::Global>` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `std::ptr::drop_in_place::<std::boxed::Box<i32>> - shim(Some(std::boxed::Box<i32>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
-   = note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC
-note: inside closure at $DIR/deallocate_against_barrier1.rs:LL:CC
-  --> $DIR/deallocate_against_barrier1.rs:LL:CC
-   |
-LL |         drop(unsafe { Box::from_raw(raw) });
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: inside `<[closure@$DIR/deallocate_against_barrier1.rs:LL:CC] as std::ops::FnOnce<(&mut i32,)>>::call_once - shim` at RUSTLIB/core/src/ops/function.rs:LL:CC
-note: inside `inner` at $DIR/deallocate_against_barrier1.rs:LL:CC
-  --> $DIR/deallocate_against_barrier1.rs:LL:CC
-   |
-LL |     f(x)
-   |     ^^^^
-note: inside `main` at $DIR/deallocate_against_barrier1.rs:LL:CC
-  --> $DIR/deallocate_against_barrier1.rs:LL:CC
-   |
-LL | /     inner(Box::leak(Box::new(0)), |x| {
-LL | |         let raw = x as *mut _;
-LL | |         drop(unsafe { Box::from_raw(raw) });
-LL | |     });
-   | |______^
-
-note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
-
-error: aborting due to previous error
-
diff --git a/tests/fail/stacked_borrows/deallocate_against_barrier2.rs b/tests/fail/stacked_borrows/deallocate_against_barrier2.rs
deleted file mode 100644 (file)
index 36e133e..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-//@error-pattern: /deallocating while item \[SharedReadWrite for .*\] is protected/
-use std::marker::PhantomPinned;
-
-pub struct NotUnpin(i32, PhantomPinned);
-
-fn inner(x: &mut NotUnpin, f: fn(&mut NotUnpin)) {
-    // `f` may mutate, but it may not deallocate!
-    f(x)
-}
-
-fn main() {
-    inner(Box::leak(Box::new(NotUnpin(0, PhantomPinned))), |x| {
-        let raw = x as *mut _;
-        drop(unsafe { Box::from_raw(raw) });
-    });
-}
diff --git a/tests/fail/stacked_borrows/deallocate_against_barrier2.stderr b/tests/fail/stacked_borrows/deallocate_against_barrier2.stderr
deleted file mode 100644 (file)
index a1a7ce0..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-error: Undefined Behavior: deallocating while item [SharedReadWrite for <TAG>] is protected by call ID
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
-   |
-LL |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating while item [SharedReadWrite for <TAG>] is protected by call ID
-   |
-   = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
-   = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
-   = note: backtrace:
-   = note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `alloc::alloc::box_free::<NotUnpin, std::alloc::Global>` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `std::ptr::drop_in_place::<std::boxed::Box<NotUnpin>> - shim(Some(std::boxed::Box<NotUnpin>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
-   = note: inside `std::mem::drop::<std::boxed::Box<NotUnpin>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC
-note: inside closure at $DIR/deallocate_against_barrier2.rs:LL:CC
-  --> $DIR/deallocate_against_barrier2.rs:LL:CC
-   |
-LL |         drop(unsafe { Box::from_raw(raw) });
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: inside `<[closure@$DIR/deallocate_against_barrier2.rs:LL:CC] as std::ops::FnOnce<(&mut NotUnpin,)>>::call_once - shim` at RUSTLIB/core/src/ops/function.rs:LL:CC
-note: inside `inner` at $DIR/deallocate_against_barrier2.rs:LL:CC
-  --> $DIR/deallocate_against_barrier2.rs:LL:CC
-   |
-LL |     f(x)
-   |     ^^^^
-note: inside `main` at $DIR/deallocate_against_barrier2.rs:LL:CC
-  --> $DIR/deallocate_against_barrier2.rs:LL:CC
-   |
-LL | /     inner(Box::leak(Box::new(NotUnpin(0, PhantomPinned))), |x| {
-LL | |         let raw = x as *mut _;
-LL | |         drop(unsafe { Box::from_raw(raw) });
-LL | |     });
-   | |______^
-
-note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
-
-error: aborting due to previous error
-
diff --git a/tests/fail/stacked_borrows/deallocate_against_protector1.rs b/tests/fail/stacked_borrows/deallocate_against_protector1.rs
new file mode 100644 (file)
index 0000000..9b71042
--- /dev/null
@@ -0,0 +1,13 @@
+//@error-pattern: /deallocating while item \[Unique for .*\] is protected/
+
+fn inner(x: &mut i32, f: fn(&mut i32)) {
+    // `f` may mutate, but it may not deallocate!
+    f(x)
+}
+
+fn main() {
+    inner(Box::leak(Box::new(0)), |x| {
+        let raw = x as *mut _;
+        drop(unsafe { Box::from_raw(raw) });
+    });
+}
diff --git a/tests/fail/stacked_borrows/deallocate_against_protector1.stderr b/tests/fail/stacked_borrows/deallocate_against_protector1.stderr
new file mode 100644 (file)
index 0000000..2ead0c6
--- /dev/null
@@ -0,0 +1,38 @@
+error: Undefined Behavior: deallocating while item [Unique for <TAG>] is protected by call ID
+  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+   |
+LL |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating while item [Unique for <TAG>] is protected by call ID
+   |
+   = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
+   = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
+   = note: backtrace:
+   = note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
+   = note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
+   = note: inside `alloc::alloc::box_free::<i32, std::alloc::Global>` at RUSTLIB/alloc/src/alloc.rs:LL:CC
+   = note: inside `std::ptr::drop_in_place::<std::boxed::Box<i32>> - shim(Some(std::boxed::Box<i32>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
+   = note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC
+note: inside closure at $DIR/deallocate_against_protector1.rs:LL:CC
+  --> $DIR/deallocate_against_protector1.rs:LL:CC
+   |
+LL |         drop(unsafe { Box::from_raw(raw) });
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: inside `<[closure@$DIR/deallocate_against_protector1.rs:LL:CC] as std::ops::FnOnce<(&mut i32,)>>::call_once - shim` at RUSTLIB/core/src/ops/function.rs:LL:CC
+note: inside `inner` at $DIR/deallocate_against_protector1.rs:LL:CC
+  --> $DIR/deallocate_against_protector1.rs:LL:CC
+   |
+LL |     f(x)
+   |     ^^^^
+note: inside `main` at $DIR/deallocate_against_protector1.rs:LL:CC
+  --> $DIR/deallocate_against_protector1.rs:LL:CC
+   |
+LL | /     inner(Box::leak(Box::new(0)), |x| {
+LL | |         let raw = x as *mut _;
+LL | |         drop(unsafe { Box::from_raw(raw) });
+LL | |     });
+   | |______^
+
+note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
+
+error: aborting due to previous error
+
diff --git a/tests/fail/stacked_borrows/deallocate_against_protector2.rs b/tests/fail/stacked_borrows/deallocate_against_protector2.rs
new file mode 100644 (file)
index 0000000..36e133e
--- /dev/null
@@ -0,0 +1,16 @@
+//@error-pattern: /deallocating while item \[SharedReadWrite for .*\] is protected/
+use std::marker::PhantomPinned;
+
+pub struct NotUnpin(i32, PhantomPinned);
+
+fn inner(x: &mut NotUnpin, f: fn(&mut NotUnpin)) {
+    // `f` may mutate, but it may not deallocate!
+    f(x)
+}
+
+fn main() {
+    inner(Box::leak(Box::new(NotUnpin(0, PhantomPinned))), |x| {
+        let raw = x as *mut _;
+        drop(unsafe { Box::from_raw(raw) });
+    });
+}
diff --git a/tests/fail/stacked_borrows/deallocate_against_protector2.stderr b/tests/fail/stacked_borrows/deallocate_against_protector2.stderr
new file mode 100644 (file)
index 0000000..60be936
--- /dev/null
@@ -0,0 +1,38 @@
+error: Undefined Behavior: deallocating while item [SharedReadWrite for <TAG>] is protected by call ID
+  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+   |
+LL |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating while item [SharedReadWrite for <TAG>] is protected by call ID
+   |
+   = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
+   = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
+   = note: backtrace:
+   = note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
+   = note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
+   = note: inside `alloc::alloc::box_free::<NotUnpin, std::alloc::Global>` at RUSTLIB/alloc/src/alloc.rs:LL:CC
+   = note: inside `std::ptr::drop_in_place::<std::boxed::Box<NotUnpin>> - shim(Some(std::boxed::Box<NotUnpin>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
+   = note: inside `std::mem::drop::<std::boxed::Box<NotUnpin>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC
+note: inside closure at $DIR/deallocate_against_protector2.rs:LL:CC
+  --> $DIR/deallocate_against_protector2.rs:LL:CC
+   |
+LL |         drop(unsafe { Box::from_raw(raw) });
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: inside `<[closure@$DIR/deallocate_against_protector2.rs:LL:CC] as std::ops::FnOnce<(&mut NotUnpin,)>>::call_once - shim` at RUSTLIB/core/src/ops/function.rs:LL:CC
+note: inside `inner` at $DIR/deallocate_against_protector2.rs:LL:CC
+  --> $DIR/deallocate_against_protector2.rs:LL:CC
+   |
+LL |     f(x)
+   |     ^^^^
+note: inside `main` at $DIR/deallocate_against_protector2.rs:LL:CC
+  --> $DIR/deallocate_against_protector2.rs:LL:CC
+   |
+LL | /     inner(Box::leak(Box::new(NotUnpin(0, PhantomPinned))), |x| {
+LL | |         let raw = x as *mut _;
+LL | |         drop(unsafe { Box::from_raw(raw) });
+LL | |     });
+   | |______^
+
+note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
+
+error: aborting due to previous error
+
index 56576b1ff39b51488c6373f5fa646f9ac8211ca7..fd3b19adcf5ea6d7d5f29635d34cc8454420de46 100644 (file)
@@ -11,12 +11,7 @@ help: <TAG> was created by a SharedReadWrite retag at offsets [0x0..0x4]
    |
 LL |     let p = x as *mut u32;
    |             ^
-help: <TAG> was protected due to <TAG> which was created here
-  --> $DIR/illegal_write6.rs:LL:CC
-   |
-LL |     foo(x, p);
-   |         ^
-help: this protector is live for this call
+help: <TAG> cannot be used for memory access because that would remove protected tag <TAG>, protected by this function call
   --> $DIR/illegal_write6.rs:LL:CC
    |
 LL | / fn foo(a: &mut u32, y: *mut u32) -> u32 {
@@ -26,6 +21,11 @@ LL | |     unsafe { *y = 2 };
 LL | |     return *a;
 LL | | }
    | |_^
+help: <TAG> was derived from <TAG>, which in turn was created here
+  --> $DIR/illegal_write6.rs:LL:CC
+   |
+LL |     foo(x, p);
+   |         ^
    = note: backtrace:
    = note: inside `foo` at $DIR/illegal_write6.rs:LL:CC
 note: inside `main` at $DIR/illegal_write6.rs:LL:CC
diff --git a/tests/fail/stacked_borrows/invalidate_against_barrier1.rs b/tests/fail/stacked_borrows/invalidate_against_barrier1.rs
deleted file mode 100644 (file)
index d0f4351..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-fn inner(x: *mut i32, _y: &mut i32) {
-    // If `x` and `y` alias, retagging is fine with this... but we really
-    // shouldn't be allowed to use `x` at all because `y` was assumed to be
-    // unique for the duration of this call.
-    let _val = unsafe { *x }; //~ ERROR: protect
-}
-
-fn main() {
-    let mut x = 0;
-    let xraw = &mut x as *mut _;
-    let xref = unsafe { &mut *xraw };
-    inner(xraw, xref);
-}
diff --git a/tests/fail/stacked_borrows/invalidate_against_barrier1.stderr b/tests/fail/stacked_borrows/invalidate_against_barrier1.stderr
deleted file mode 100644 (file)
index 378f7b7..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-error: Undefined Behavior: not granting access to tag <TAG> because incompatible item [Unique for <TAG>] is protected by call ID
-  --> $DIR/invalidate_against_barrier1.rs:LL:CC
-   |
-LL |     let _val = unsafe { *x };
-   |                         ^^ not granting access to tag <TAG> because incompatible item [Unique for <TAG>] is protected by call ID
-   |
-   = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
-   = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
-help: <TAG> was created by a SharedReadWrite retag at offsets [0x0..0x4]
-  --> $DIR/invalidate_against_barrier1.rs:LL:CC
-   |
-LL |     let xraw = &mut x as *mut _;
-   |                ^^^^^^
-help: <TAG> was protected due to <TAG> which was created here
-  --> $DIR/invalidate_against_barrier1.rs:LL:CC
-   |
-LL |     inner(xraw, xref);
-   |                 ^^^^
-help: this protector is live for this call
-  --> $DIR/invalidate_against_barrier1.rs:LL:CC
-   |
-LL | / fn inner(x: *mut i32, _y: &mut i32) {
-LL | |     // If `x` and `y` alias, retagging is fine with this... but we really
-LL | |     // shouldn't be allowed to use `x` at all because `y` was assumed to be
-LL | |     // unique for the duration of this call.
-LL | |     let _val = unsafe { *x };
-LL | | }
-   | |_^
-   = note: backtrace:
-   = note: inside `inner` at $DIR/invalidate_against_barrier1.rs:LL:CC
-note: inside `main` at $DIR/invalidate_against_barrier1.rs:LL:CC
-  --> $DIR/invalidate_against_barrier1.rs:LL:CC
-   |
-LL |     inner(xraw, xref);
-   |     ^^^^^^^^^^^^^^^^^
-
-note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
-
-error: aborting due to previous error
-
diff --git a/tests/fail/stacked_borrows/invalidate_against_barrier2.rs b/tests/fail/stacked_borrows/invalidate_against_barrier2.rs
deleted file mode 100644 (file)
index f4e7673..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-fn inner(x: *mut i32, _y: &i32) {
-    // If `x` and `y` alias, retagging is fine with this... but we really
-    // shouldn't be allowed to write to `x` at all because `y` was assumed to be
-    // immutable for the duration of this call.
-    unsafe { *x = 0 }; //~ ERROR: protect
-}
-
-fn main() {
-    let mut x = 0;
-    let xraw = &mut x as *mut _;
-    let xref = unsafe { &*xraw };
-    inner(xraw, xref);
-}
diff --git a/tests/fail/stacked_borrows/invalidate_against_barrier2.stderr b/tests/fail/stacked_borrows/invalidate_against_barrier2.stderr
deleted file mode 100644 (file)
index 0352b67..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-error: Undefined Behavior: not granting access to tag <TAG> because incompatible item [SharedReadOnly for <TAG>] is protected by call ID
-  --> $DIR/invalidate_against_barrier2.rs:LL:CC
-   |
-LL |     unsafe { *x = 0 };
-   |              ^^^^^^ not granting access to tag <TAG> because incompatible item [SharedReadOnly for <TAG>] is protected by call ID
-   |
-   = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
-   = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
-help: <TAG> was created by a SharedReadWrite retag at offsets [0x0..0x4]
-  --> $DIR/invalidate_against_barrier2.rs:LL:CC
-   |
-LL |     let xraw = &mut x as *mut _;
-   |                ^^^^^^
-help: <TAG> was protected due to <TAG> which was created here
-  --> $DIR/invalidate_against_barrier2.rs:LL:CC
-   |
-LL |     inner(xraw, xref);
-   |                 ^^^^
-help: this protector is live for this call
-  --> $DIR/invalidate_against_barrier2.rs:LL:CC
-   |
-LL | / fn inner(x: *mut i32, _y: &i32) {
-LL | |     // If `x` and `y` alias, retagging is fine with this... but we really
-LL | |     // shouldn't be allowed to write to `x` at all because `y` was assumed to be
-LL | |     // immutable for the duration of this call.
-LL | |     unsafe { *x = 0 };
-LL | | }
-   | |_^
-   = note: backtrace:
-   = note: inside `inner` at $DIR/invalidate_against_barrier2.rs:LL:CC
-note: inside `main` at $DIR/invalidate_against_barrier2.rs:LL:CC
-  --> $DIR/invalidate_against_barrier2.rs:LL:CC
-   |
-LL |     inner(xraw, xref);
-   |     ^^^^^^^^^^^^^^^^^
-
-note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
-
-error: aborting due to previous error
-
diff --git a/tests/fail/stacked_borrows/invalidate_against_protector1.rs b/tests/fail/stacked_borrows/invalidate_against_protector1.rs
new file mode 100644 (file)
index 0000000..d0f4351
--- /dev/null
@@ -0,0 +1,13 @@
+fn inner(x: *mut i32, _y: &mut i32) {
+    // If `x` and `y` alias, retagging is fine with this... but we really
+    // shouldn't be allowed to use `x` at all because `y` was assumed to be
+    // unique for the duration of this call.
+    let _val = unsafe { *x }; //~ ERROR: protect
+}
+
+fn main() {
+    let mut x = 0;
+    let xraw = &mut x as *mut _;
+    let xref = unsafe { &mut *xraw };
+    inner(xraw, xref);
+}
diff --git a/tests/fail/stacked_borrows/invalidate_against_protector1.stderr b/tests/fail/stacked_borrows/invalidate_against_protector1.stderr
new file mode 100644 (file)
index 0000000..18236ad
--- /dev/null
@@ -0,0 +1,40 @@
+error: Undefined Behavior: not granting access to tag <TAG> because incompatible item [Unique for <TAG>] is protected by call ID
+  --> $DIR/invalidate_against_protector1.rs:LL:CC
+   |
+LL |     let _val = unsafe { *x };
+   |                         ^^ not granting access to tag <TAG> because incompatible item [Unique for <TAG>] is protected by call ID
+   |
+   = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
+   = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
+help: <TAG> was created by a SharedReadWrite retag at offsets [0x0..0x4]
+  --> $DIR/invalidate_against_protector1.rs:LL:CC
+   |
+LL |     let xraw = &mut x as *mut _;
+   |                ^^^^^^
+help: <TAG> cannot be used for memory access because that would remove protected tag <TAG>, protected by this function call
+  --> $DIR/invalidate_against_protector1.rs:LL:CC
+   |
+LL | / fn inner(x: *mut i32, _y: &mut i32) {
+LL | |     // If `x` and `y` alias, retagging is fine with this... but we really
+LL | |     // shouldn't be allowed to use `x` at all because `y` was assumed to be
+LL | |     // unique for the duration of this call.
+LL | |     let _val = unsafe { *x };
+LL | | }
+   | |_^
+help: <TAG> was derived from <TAG>, which in turn was created here
+  --> $DIR/invalidate_against_protector1.rs:LL:CC
+   |
+LL |     inner(xraw, xref);
+   |                 ^^^^
+   = note: backtrace:
+   = note: inside `inner` at $DIR/invalidate_against_protector1.rs:LL:CC
+note: inside `main` at $DIR/invalidate_against_protector1.rs:LL:CC
+  --> $DIR/invalidate_against_protector1.rs:LL:CC
+   |
+LL |     inner(xraw, xref);
+   |     ^^^^^^^^^^^^^^^^^
+
+note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
+
+error: aborting due to previous error
+
diff --git a/tests/fail/stacked_borrows/invalidate_against_protector2.rs b/tests/fail/stacked_borrows/invalidate_against_protector2.rs
new file mode 100644 (file)
index 0000000..f4e7673
--- /dev/null
@@ -0,0 +1,13 @@
+fn inner(x: *mut i32, _y: &i32) {
+    // If `x` and `y` alias, retagging is fine with this... but we really
+    // shouldn't be allowed to write to `x` at all because `y` was assumed to be
+    // immutable for the duration of this call.
+    unsafe { *x = 0 }; //~ ERROR: protect
+}
+
+fn main() {
+    let mut x = 0;
+    let xraw = &mut x as *mut _;
+    let xref = unsafe { &*xraw };
+    inner(xraw, xref);
+}
diff --git a/tests/fail/stacked_borrows/invalidate_against_protector2.stderr b/tests/fail/stacked_borrows/invalidate_against_protector2.stderr
new file mode 100644 (file)
index 0000000..20b9d47
--- /dev/null
@@ -0,0 +1,40 @@
+error: Undefined Behavior: not granting access to tag <TAG> because incompatible item [SharedReadOnly for <TAG>] is protected by call ID
+  --> $DIR/invalidate_against_protector2.rs:LL:CC
+   |
+LL |     unsafe { *x = 0 };
+   |              ^^^^^^ not granting access to tag <TAG> because incompatible item [SharedReadOnly for <TAG>] is protected by call ID
+   |
+   = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
+   = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
+help: <TAG> was created by a SharedReadWrite retag at offsets [0x0..0x4]
+  --> $DIR/invalidate_against_protector2.rs:LL:CC
+   |
+LL |     let xraw = &mut x as *mut _;
+   |                ^^^^^^
+help: <TAG> cannot be used for memory access because that would remove protected tag <TAG>, protected by this function call
+  --> $DIR/invalidate_against_protector2.rs:LL:CC
+   |
+LL | / fn inner(x: *mut i32, _y: &i32) {
+LL | |     // If `x` and `y` alias, retagging is fine with this... but we really
+LL | |     // shouldn't be allowed to write to `x` at all because `y` was assumed to be
+LL | |     // immutable for the duration of this call.
+LL | |     unsafe { *x = 0 };
+LL | | }
+   | |_^
+help: <TAG> was derived from <TAG>, which in turn was created here
+  --> $DIR/invalidate_against_protector2.rs:LL:CC
+   |
+LL |     inner(xraw, xref);
+   |                 ^^^^
+   = note: backtrace:
+   = note: inside `inner` at $DIR/invalidate_against_protector2.rs:LL:CC
+note: inside `main` at $DIR/invalidate_against_protector2.rs:LL:CC
+  --> $DIR/invalidate_against_protector2.rs:LL:CC
+   |
+LL |     inner(xraw, xref);
+   |     ^^^^^^^^^^^^^^^^^
+
+note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
+
+error: aborting due to previous error
+
index 2d26787231dc68805f011d0b26c921e538b00d08..e75502d361059445f8439ccf8a430d01f891fb1c 100644 (file)
@@ -11,18 +11,18 @@ help: <TAG> was created by a SharedReadWrite retag at offsets [0x0..0x4]
    |
 LL |     let ptr = Box::into_raw(Box::new(0i32));
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: <TAG> was protected due to <TAG> which was created here
-  --> $DIR/newtype_retagging.rs:LL:CC
-   |
-LL |             Newtype(&mut *ptr),
-   |             ^^^^^^^^^^^^^^^^^^
-help: this protector is live for this call
+help: <TAG> cannot be used for memory access because that would remove protected tag <TAG>, protected by this function call
   --> $DIR/newtype_retagging.rs:LL:CC
    |
 LL | / fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) {
 LL | |     dealloc();
 LL | | }
    | |_^
+help: <TAG> was derived from <TAG>, which in turn was created here
+  --> $DIR/newtype_retagging.rs:LL:CC
+   |
+LL |             Newtype(&mut *ptr),
+   |             ^^^^^^^^^^^^^^^^^^
    = note: backtrace:
    = note: inside `std::boxed::Box::<i32>::from_raw_in` at RUSTLIB/alloc/src/boxed.rs:LL:CC
    = note: inside `std::boxed::Box::<i32>::from_raw` at RUSTLIB/alloc/src/boxed.rs:LL:CC