-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Display for rustc_target::callconv::Conv
#135808
base: master
Are you sure you want to change the base?
Conversation
Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval The Miri subtree was changed cc @rust-lang/miri Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri |
It's miri related, and Ralf looks busy, so r? @oli-obk |
@bors r+ rollup has no test changes as for almost all cases the |
@@ -920,8 +920,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | |||
fn check_abi<'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 ABI {exp_abi} using caller ABI {}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't about ExternAbi
though, it is about the underlying calling convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope it'd help by providing more context. Initially we indeed used ExternAbi
here for check_abi
, but after #133103 we passed FnAbi
instead of ExternAbi
, so we can check the number of fixed args like what is done in rust-lang/miri#4122.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this is how we allow e.g. calling a C
function through a C-unwind
fn pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't about ExternAbi though, it is about the underlying calling convention.
The underlying calling convention is still mappable to one of the ExternAbi strings, and we can still express conflicts in terms of that. Dropping data randomly, like erasing "rust-cold" to "Cold", or "x86-interrupt" to "X86Intr", will mostly be confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The concrete error this comment is attached to does not have a ui test; the other one changed in this PR is tested at
//~^ ERROR: calling a function with calling convention C using calling convention Rust |
and
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, those two say "calling convention" but this error says "ABI"? is that what you mean by "the concrete error"... does not have a UI test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this one here is triggered when you call a built-in shim the wrong way (rather than some normal Rust function), which we don't have a test for. We should add one.
And indeed it should say "calling convention".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we should change the error message in check_abi
to use "calling convention" and add a test that will invoke the check_abi
here.
Other than that, should we continue with impl Display for Conv
or map the calling convention to ExternAbi
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please implement Display by mapping Conv back to the matching ExternAbi variant (without unwind
). This will sometimes give a surprising result, but it will still be comprehensible. If this is properly tested, then I can elaborate on the error message in a followup that gives the rest of the information necessary to fix the problem.
Of course, if even this is considered impossible by my peers, then I can relent for now and simply make possible the impossible later.
@bors r- |
Follow up of #133103 (comment)