-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Reject unsupported, unstable ABIs during AST lowering #141877
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
base: master
Are you sure you want to change the base?
Reject unsupported, unstable ABIs during AST lowering #141877
Conversation
We elaborate rustc_ast_lowering to prevent unstable, unsupported ABIs from leaking through the HIR without being checked for target support. Previously ad-hoc checking on various HIR items required making sure we check every HIR item which could contain an extern "{abi}" string. This is a losing proposition compared to gating the lowering itself. As a consequence, unstable ABI strings will now hard-error instead of triggering the FCW `unsupported_fn_ptr_calling_conventions`. This FCW was upgraded to warn in dependencies in Rust 1.87 so it has become active within a stable Rust version and it was within the compiler's nightly-feature contract to break this code without warning, so this breakage has likely had a reasonable amount of foreshadowing.
We already gated unstable, unsupported ABIs during AST lowering. If we check all ABIs for target support during HIR lowering, then we risk duplicate errors in code that uses unstable extern "{abi}"s. Limiting the ABI support checks to stable ABIs reduces this, and remains correct because of gating all unstable ABIs already. This code complication can be reduced when we switch the FCW to error.
Explicitly test it for relevant targets and check it errors on hosts.
r? @Nadrieril rustbot has assigned @Nadrieril. Use |
HIR ty lowering was modified cc @fmease This PR changes a file inside These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
This comment has been minimized.
This comment has been minimized.
@aDotInTheVoid Mm. I... am just gonna remove the |
These commits modify Please ensure that if you've changed the output:
|
It's checking that we produces the rust/src/librustdoc/json/conversions.rs Lines 365 to 378 in 91fad92
rust/src/rustdoc-json-types/lib.rs Lines 771 to 794 in 91fad92
Could you instead change the tests to use some other unstable ABI here? But it's fine to only test this once (with both the |
@aDotInTheVoid Well. Most other unstable ABIs don't have "unwind" cases. |
We move the vectorcall ABI tests into their own file which is now only run on x86-64, while replacing them with rust-cold ABI tests so that aarch64 hosts continue to test an unstable ABI. A better solution might be cross-compiling or something but I really don't have time for that right now.
a705901
to
1fb2cf4
Compare
I have pushed an alternative which does some rearrangement so that we don't have complications due to aarch64 hosts, still test an unstable ABI, and retain the vectorcall-unwind coverage when we do. |
Currently, we check whether ABIs have support on the target we are compiling for during HIR analysis. This unfortunately is a slightly "whack-a-mole" proposition, because there is no inherent relationship between ABI strings and their usages in the HIR1. We can instead check for support in
rustc_ast_lowering
, where we first materializeExternAbi
from strings. This lets us always error on ABIs we wish to error on.As a first step, we throw the switch for unstable ABIs. Despite being nightly features, we actually have emitted future compatibility warnings for all unsupported ABIs for some time:
unsupported_calling_conventions
became a hard error.unsupported_fn_ptr_calling_conventions
is warn-in-deps since Rust 1.87, a stable Rust version.With this we effectively make the latter lint a hard error on unstable ABIs. Stable ABIs still only receive warnings.
As a bonus, this addresses two ICEs that the compiler could reach. It prevents many more LLVM errors from being seen by programmers as well, as most unstable ABIs cannot have correct code generated for them by targets that do not support the ABI.
Fixes #132430
Fixes #138738
Footnotes
For example, we already missed some use-sites of ABI strings because FnSigs are not BareFnTys, requiring us to implement a new future-compat-warning to handle the function pointer case. ↩