about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-04-06 14:08:20 +0200
committerRalf Jung <post@ralfj.de>2024-04-06 14:08:27 +0200
commit9989653269fafb2dd35a4ff94fbb6e0c93555c17 (patch)
treeb17d5c7ee66890411b87651a064dc0ea6a533793
parentbfaf6b07ee9a4b778a807d648b1135d3b2d9e226 (diff)
downloadrust-9989653269fafb2dd35a4ff94fbb6e0c93555c17.tar.gz
rust-9989653269fafb2dd35a4ff94fbb6e0c93555c17.zip
make 'missing extern static' error consistent with missing shim
-rw-r--r--src/tools/miri/src/machine.rs8
-rw-r--r--src/tools/miri/tests/fail/extern_static.stderr4
-rw-r--r--src/tools/miri/tests/fail/extern_static_in_const.stderr4
-rw-r--r--src/tools/miri/tests/fail/extern_static_wrong_size.rs2
-rw-r--r--src/tools/miri/tests/fail/extern_static_wrong_size.stderr4
-rw-r--r--src/tools/miri/tests/fail/issue-miri-3288-ice-symbolic-alignment-extern-static.stderr4
6 files changed, 11 insertions, 15 deletions
diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs
index 14b7afcc971..ff081328a72 100644
--- a/src/tools/miri/src/machine.rs
+++ b/src/tools/miri/src/machine.rs
@@ -1066,7 +1066,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
             let extern_decl_layout = ecx.tcx.layout_of(ty::ParamEnv::empty().and(def_ty)).unwrap();
             if extern_decl_layout.size != shim_size || extern_decl_layout.align.abi != shim_align {
                 throw_unsup_format!(
-                    "`extern` static `{name}` from crate `{krate}` has been declared \
+                    "extern static `{link_name}` has been declared as `{krate}::{name}` \
                     with a size of {decl_size} bytes and alignment of {decl_align} bytes, \
                     but Miri emulates it via an extern static shim \
                     with a size of {shim_size} bytes and alignment of {shim_align} bytes",
@@ -1080,11 +1080,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
             }
             Ok(ptr)
         } else {
-            throw_unsup_format!(
-                "`extern` static `{name}` from crate `{krate}` is not supported by Miri",
-                name = ecx.tcx.def_path_str(def_id),
-                krate = ecx.tcx.crate_name(def_id.krate),
-            )
+            throw_unsup_format!("extern static `{link_name}` is not supported by Miri",)
         }
     }
 
diff --git a/src/tools/miri/tests/fail/extern_static.stderr b/src/tools/miri/tests/fail/extern_static.stderr
index c3de4dadb0a..34bb273f04b 100644
--- a/src/tools/miri/tests/fail/extern_static.stderr
+++ b/src/tools/miri/tests/fail/extern_static.stderr
@@ -1,8 +1,8 @@
-error: unsupported operation: `extern` static `FOO` from crate `extern_static` is not supported by Miri
+error: unsupported operation: extern static `FOO` is not supported by Miri
   --> $DIR/extern_static.rs:LL:CC
    |
 LL |     let _val = unsafe { std::ptr::addr_of!(FOO) };
-   |                                            ^^^ `extern` static `FOO` from crate `extern_static` is not supported by Miri
+   |                                            ^^^ extern static `FOO` is not supported by Miri
    |
    = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
    = note: BACKTRACE:
diff --git a/src/tools/miri/tests/fail/extern_static_in_const.stderr b/src/tools/miri/tests/fail/extern_static_in_const.stderr
index 23f775f2588..45d1632cce2 100644
--- a/src/tools/miri/tests/fail/extern_static_in_const.stderr
+++ b/src/tools/miri/tests/fail/extern_static_in_const.stderr
@@ -1,8 +1,8 @@
-error: unsupported operation: `extern` static `E` from crate `extern_static_in_const` is not supported by Miri
+error: unsupported operation: extern static `E` is not supported by Miri
   --> $DIR/extern_static_in_const.rs:LL:CC
    |
 LL |     let _val = X;
-   |                ^ `extern` static `E` from crate `extern_static_in_const` is not supported by Miri
+   |                ^ extern static `E` is not supported by Miri
    |
    = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
    = note: BACKTRACE:
diff --git a/src/tools/miri/tests/fail/extern_static_wrong_size.rs b/src/tools/miri/tests/fail/extern_static_wrong_size.rs
index 17061f0e5c8..fee3c38c25e 100644
--- a/src/tools/miri/tests/fail/extern_static_wrong_size.rs
+++ b/src/tools/miri/tests/fail/extern_static_wrong_size.rs
@@ -6,5 +6,5 @@ extern "C" {
 }
 
 fn main() {
-    let _val = unsafe { environ }; //~ ERROR: /has been declared with a size of 1 bytes and alignment of 1 bytes, but Miri emulates it via an extern static shim with a size of [48] bytes and alignment of [48] bytes/
+    let _val = unsafe { environ }; //~ ERROR: /with a size of 1 bytes and alignment of 1 bytes, but Miri emulates it via an extern static shim with a size of [48] bytes and alignment of [48] bytes/
 }
diff --git a/src/tools/miri/tests/fail/extern_static_wrong_size.stderr b/src/tools/miri/tests/fail/extern_static_wrong_size.stderr
index c935a548f80..27699d780c2 100644
--- a/src/tools/miri/tests/fail/extern_static_wrong_size.stderr
+++ b/src/tools/miri/tests/fail/extern_static_wrong_size.stderr
@@ -1,8 +1,8 @@
-error: unsupported operation: `extern` static `environ` from crate `extern_static_wrong_size` has been declared with a size of 1 bytes and alignment of 1 bytes, but Miri emulates it via an extern static shim with a size of N bytes and alignment of N bytes
+error: unsupported operation: extern static `environ` has been declared as `extern_static_wrong_size::environ` with a size of 1 bytes and alignment of 1 bytes, but Miri emulates it via an extern static shim with a size of N bytes and alignment of N bytes
   --> $DIR/extern_static_wrong_size.rs:LL:CC
    |
 LL |     let _val = unsafe { environ };
-   |                         ^^^^^^^ `extern` static `environ` from crate `extern_static_wrong_size` has been declared with a size of 1 bytes and alignment of 1 bytes, but Miri emulates it via an extern static shim with a size of N bytes and alignment of N bytes
+   |                         ^^^^^^^ extern static `environ` has been declared as `extern_static_wrong_size::environ` with a size of 1 bytes and alignment of 1 bytes, but Miri emulates it via an extern static shim with a size of N bytes and alignment of N bytes
    |
    = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
    = note: BACKTRACE:
diff --git a/src/tools/miri/tests/fail/issue-miri-3288-ice-symbolic-alignment-extern-static.stderr b/src/tools/miri/tests/fail/issue-miri-3288-ice-symbolic-alignment-extern-static.stderr
index a4249d2e881..e5dbe749884 100644
--- a/src/tools/miri/tests/fail/issue-miri-3288-ice-symbolic-alignment-extern-static.stderr
+++ b/src/tools/miri/tests/fail/issue-miri-3288-ice-symbolic-alignment-extern-static.stderr
@@ -1,8 +1,8 @@
-error: unsupported operation: `extern` static `_dispatch_queue_attr_concurrent` from crate `issue_miri_3288_ice_symbolic_alignment_extern_static` is not supported by Miri
+error: unsupported operation: extern static `_dispatch_queue_attr_concurrent` is not supported by Miri
   --> $DIR/issue-miri-3288-ice-symbolic-alignment-extern-static.rs:LL:CC
    |
 LL |     let _val = *DISPATCH_QUEUE_CONCURRENT;
-   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^ `extern` static `_dispatch_queue_attr_concurrent` from crate `issue_miri_3288_ice_symbolic_alignment_extern_static` is not supported by Miri
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^ extern static `_dispatch_queue_attr_concurrent` is not supported by Miri
    |
    = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
    = note: BACKTRACE: