Rollup merge of #135808 - tiif:conv_display, r=workingjubilee
Implement Display for ``rustc_target::callconv::Conv`` Follow up of https://github.com/rust-lang/rust/pull/133103#discussion_r1885552854
This commit is contained in:
commit
836db3ccae
15 changed files with 58 additions and 27 deletions
|
|
@ -932,12 +932,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
self.read_c_str_with_char_size(ptr, wchar_t.size, wchar_t.align.abi)
|
||||
}
|
||||
|
||||
/// Check that the ABI is what we expect.
|
||||
fn check_abi<'a>(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, exp_abi: Conv) -> InterpResult<'a, ()> {
|
||||
/// Check that the calling convention is what we expect.
|
||||
fn check_callconv<'a>(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, exp_abi: Conv) -> InterpResult<'a, ()> {
|
||||
if fn_abi.conv != exp_abi {
|
||||
throw_ub_format!(
|
||||
"calling a function with ABI {:?} using caller ABI {:?}",
|
||||
exp_abi,
|
||||
"calling a function with calling convention {exp_abi} using caller calling convention {}",
|
||||
fn_abi.conv
|
||||
);
|
||||
}
|
||||
|
|
@ -973,7 +972,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
exp_abi: Conv,
|
||||
link_name: Symbol,
|
||||
) -> InterpResult<'tcx, ()> {
|
||||
self.check_abi(abi, exp_abi)?;
|
||||
self.check_callconv(abi, exp_abi)?;
|
||||
if let Some((body, instance)) = self.eval_context_mut().lookup_exported_symbol(link_name)? {
|
||||
// If compiler-builtins is providing the symbol, then don't treat it as a clash.
|
||||
// We'll use our built-in implementation in `emulate_foreign_item_inner` for increased
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ fn main() {
|
|||
}
|
||||
|
||||
unsafe {
|
||||
let _ = malloc(0); //~ ERROR: calling a function with ABI C using caller ABI Rust
|
||||
let _ = malloc(0); //~ ERROR: calling a function with calling convention "C" using caller calling convention "Rust"
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: Undefined Behavior: calling a function with ABI C using caller ABI Rust
|
||||
error: Undefined Behavior: calling a function with calling convention "C" using caller calling convention "Rust"
|
||||
--> tests/fail/function_calls/check_arg_abi.rs:LL:CC
|
||||
|
|
||||
LL | let _ = malloc(0);
|
||||
| ^^^^^^^^^ calling a function with ABI C using caller ABI Rust
|
||||
| ^^^^^^^^^ calling a function with calling convention "C" using caller calling convention "Rust"
|
||||
|
|
||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
||||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ fn main() {
|
|||
// Make sure we check the ABI when Miri itself invokes a function
|
||||
// as part of a shim implementation.
|
||||
std::intrinsics::catch_unwind(
|
||||
//~^ ERROR: calling a function with calling convention C using calling convention Rust
|
||||
//~^ ERROR: calling a function with calling convention "C" using calling convention "Rust"
|
||||
std::mem::transmute::<extern "C" fn(*mut u8), _>(try_fn),
|
||||
std::ptr::null_mut(),
|
||||
|_, _| unreachable!(),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: Undefined Behavior: calling a function with calling convention C using calling convention Rust
|
||||
error: Undefined Behavior: calling a function with calling convention "C" using calling convention "Rust"
|
||||
--> tests/fail/function_calls/check_callback_abi.rs:LL:CC
|
||||
|
|
||||
LL | / std::intrinsics::catch_unwind(
|
||||
|
|
@ -7,7 +7,7 @@ LL | | std::mem::transmute::<extern "C" fn(*mut u8), _>(try_fn),
|
|||
LL | | std::ptr::null_mut(),
|
||||
LL | | |_, _| unreachable!(),
|
||||
LL | | );
|
||||
| |_________^ calling a function with calling convention C using calling convention Rust
|
||||
| |_________^ calling a function with calling convention "C" using calling convention "Rust"
|
||||
|
|
||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
||||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: Undefined Behavior: calling a function with calling convention Rust using calling convention C
|
||||
error: Undefined Behavior: calling a function with calling convention "Rust" using calling convention "C"
|
||||
--> tests/fail/function_calls/exported_symbol_abi_mismatch.rs:LL:CC
|
||||
|
|
||||
LL | foo();
|
||||
| ^^^^^ calling a function with calling convention Rust using calling convention C
|
||||
| ^^^^^ calling a function with calling convention "Rust" using calling convention "C"
|
||||
|
|
||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
||||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: Undefined Behavior: calling a function with calling convention Rust using calling convention C
|
||||
error: Undefined Behavior: calling a function with calling convention "Rust" using calling convention "C"
|
||||
--> tests/fail/function_calls/exported_symbol_abi_mismatch.rs:LL:CC
|
||||
|
|
||||
LL | std::mem::transmute::<unsafe fn(), unsafe extern "C" fn()>(foo)();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling a function with calling convention Rust using calling convention C
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling a function with calling convention "Rust" using calling convention "C"
|
||||
|
|
||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
||||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: Undefined Behavior: calling a function with calling convention Rust using calling convention C
|
||||
error: Undefined Behavior: calling a function with calling convention "Rust" using calling convention "C"
|
||||
--> tests/fail/function_calls/exported_symbol_abi_mismatch.rs:LL:CC
|
||||
|
|
||||
LL | foo();
|
||||
| ^^^^^ calling a function with calling convention Rust using calling convention C
|
||||
| ^^^^^ calling a function with calling convention "Rust" using calling convention "C"
|
||||
|
|
||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
||||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ fn main() {
|
|||
#[cfg(fn_ptr)]
|
||||
unsafe {
|
||||
std::mem::transmute::<unsafe fn(), unsafe extern "C" fn()>(foo)();
|
||||
//~[fn_ptr]^ ERROR: calling a function with calling convention Rust using calling convention C
|
||||
//~[fn_ptr]^ ERROR: calling a function with calling convention "Rust" using calling convention "C"
|
||||
}
|
||||
|
||||
// `Instance` caching should not suppress ABI check.
|
||||
|
|
@ -28,8 +28,8 @@ fn main() {
|
|||
}
|
||||
unsafe {
|
||||
foo();
|
||||
//~[no_cache]^ ERROR: calling a function with calling convention Rust using calling convention C
|
||||
//~[cache]| ERROR: calling a function with calling convention Rust using calling convention C
|
||||
//~[no_cache]^ ERROR: calling a function with calling convention "Rust" using calling convention "C"
|
||||
//~[cache]| ERROR: calling a function with calling convention "Rust" using calling convention "C"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//@error-in-other-file: Undefined Behavior: calling a function with calling convention C using calling convention Rust
|
||||
//@error-in-other-file: Undefined Behavior: calling a function with calling convention "C" using calling convention "Rust"
|
||||
#![feature(explicit_tail_calls)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: Undefined Behavior: calling a function with calling convention C using calling convention Rust
|
||||
error: Undefined Behavior: calling a function with calling convention "C" using calling convention "Rust"
|
||||
--> RUSTLIB/core/src/ops/function.rs:LL:CC
|
||||
|
|
||||
LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling a function with calling convention C using calling convention Rust
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling a function with calling convention "C" using calling convention "Rust"
|
||||
|
|
||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
||||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue