Skip to content

Commit f7feabc

Browse files
committed
Auto merge of rust-lang#3455 - RalfJung:extern-static, r=RalfJung
make 'missing extern static' error consistent with missing shim What's relevant is mostly the link name of the external symbol, not its Rust path.
2 parents bfaf6b0 + 9989653 commit f7feabc

6 files changed

+11
-15
lines changed

src/tools/miri/src/machine.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
10661066
let extern_decl_layout = ecx.tcx.layout_of(ty::ParamEnv::empty().and(def_ty)).unwrap();
10671067
if extern_decl_layout.size != shim_size || extern_decl_layout.align.abi != shim_align {
10681068
throw_unsup_format!(
1069-
"`extern` static `{name}` from crate `{krate}` has been declared \
1069+
"extern static `{link_name}` has been declared as `{krate}::{name}` \
10701070
with a size of {decl_size} bytes and alignment of {decl_align} bytes, \
10711071
but Miri emulates it via an extern static shim \
10721072
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> {
10801080
}
10811081
Ok(ptr)
10821082
} else {
1083-
throw_unsup_format!(
1084-
"`extern` static `{name}` from crate `{krate}` is not supported by Miri",
1085-
name = ecx.tcx.def_path_str(def_id),
1086-
krate = ecx.tcx.crate_name(def_id.krate),
1087-
)
1083+
throw_unsup_format!("extern static `{link_name}` is not supported by Miri",)
10881084
}
10891085
}
10901086

src/tools/miri/tests/fail/extern_static.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: unsupported operation: `extern` static `FOO` from crate `extern_static` is not supported by Miri
1+
error: unsupported operation: extern static `FOO` is not supported by Miri
22
--> $DIR/extern_static.rs:LL:CC
33
|
44
LL | let _val = unsafe { std::ptr::addr_of!(FOO) };
5-
| ^^^ `extern` static `FOO` from crate `extern_static` is not supported by Miri
5+
| ^^^ extern static `FOO` is not supported by Miri
66
|
77
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
88
= note: BACKTRACE:

src/tools/miri/tests/fail/extern_static_in_const.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: unsupported operation: `extern` static `E` from crate `extern_static_in_const` is not supported by Miri
1+
error: unsupported operation: extern static `E` is not supported by Miri
22
--> $DIR/extern_static_in_const.rs:LL:CC
33
|
44
LL | let _val = X;
5-
| ^ `extern` static `E` from crate `extern_static_in_const` is not supported by Miri
5+
| ^ extern static `E` is not supported by Miri
66
|
77
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
88
= note: BACKTRACE:

src/tools/miri/tests/fail/extern_static_wrong_size.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ extern "C" {
66
}
77

88
fn main() {
9-
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/
9+
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/
1010
}

src/tools/miri/tests/fail/extern_static_wrong_size.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
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
1+
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
22
--> $DIR/extern_static_wrong_size.rs:LL:CC
33
|
44
LL | let _val = unsafe { environ };
5-
| ^^^^^^^ `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
5+
| ^^^^^^^ 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
66
|
77
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
88
= note: BACKTRACE:

src/tools/miri/tests/fail/issue-miri-3288-ice-symbolic-alignment-extern-static.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: unsupported operation: `extern` static `_dispatch_queue_attr_concurrent` from crate `issue_miri_3288_ice_symbolic_alignment_extern_static` is not supported by Miri
1+
error: unsupported operation: extern static `_dispatch_queue_attr_concurrent` is not supported by Miri
22
--> $DIR/issue-miri-3288-ice-symbolic-alignment-extern-static.rs:LL:CC
33
|
44
LL | let _val = *DISPATCH_QUEUE_CONCURRENT;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ `extern` static `_dispatch_queue_attr_concurrent` from crate `issue_miri_3288_ice_symbolic_alignment_extern_static` is not supported by Miri
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ extern static `_dispatch_queue_attr_concurrent` is not supported by Miri
66
|
77
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
88
= note: BACKTRACE:

0 commit comments

Comments
 (0)