mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
committed by
Josh Stone
parent
c9ba9aab8c
commit
7e0eb3bc6d
@@ -156,7 +156,16 @@ pub(crate) fn check_expr_call(
|
||||
pub(crate) fn check_call_abi(&self, abi: ExternAbi, span: Span) {
|
||||
let canon_abi = match AbiMap::from_target(&self.sess().target).canonize_abi(abi, false) {
|
||||
AbiMapping::Direct(canon_abi) | AbiMapping::Deprecated(canon_abi) => canon_abi,
|
||||
AbiMapping::Invalid => return,
|
||||
AbiMapping::Invalid => {
|
||||
// This should be reported elsewhere, but we want to taint this body
|
||||
// so that we don't try to evaluate calls to ABIs that are invalid.
|
||||
let guar = self.dcx().span_delayed_bug(
|
||||
span,
|
||||
format!("invalid abi for platform should have reported an error: {abi}"),
|
||||
);
|
||||
self.set_tainted_by_errors(guar);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let valid = match canon_abi {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Fix for #142969 where an invalid ABI in a signature still had its call ABI computed
|
||||
// because CTFE tried to evaluate it, despite previous errors during AST-to-HIR lowering.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
const extern "rust-invalid" fn foo() {
|
||||
//~^ ERROR `"rust-invalid"` is not a supported ABI for the current target
|
||||
panic!()
|
||||
}
|
||||
|
||||
const _: () = foo();
|
||||
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,9 @@
|
||||
error[E0570]: `"rust-invalid"` is not a supported ABI for the current target
|
||||
--> $DIR/invalid-call-abi-ctfe.rs:6:1
|
||||
|
|
||||
LL | const extern "rust-invalid" fn foo() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0570`.
|
||||
Reference in New Issue
Block a user