Add (back) unsupported_calling_conventions lint to reject more invalid calling conventions by RalfJung · Pull Request #141435 · rust-lang/rust (original) (raw)

@RalfJung

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

labels

May 23, 2025

@traviscross traviscross added P-lang-drag-1

Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang

and removed T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

labels

May 23, 2025

@traviscross traviscross changed the titleadd (back) unsupported_calling_conventions lint to reject more invalid calling conventions Add (back) unsupported_calling_conventions lint to reject more invalid calling conventions

May 27, 2025

@traviscross traviscross added I-lang-radar

Items that are on lang's radar and will need eventual work or consideration.

and removed I-lang-nominated

Nominated for discussion during a lang team meeting.

P-lang-drag-1

Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang

labels

May 28, 2025

@RalfJung RalfJung deleted the unsupported_calling_conventions branch

June 9, 2025 09:03

This was referenced

Jun 9, 2025

workingjubilee added a commit to workingjubilee/rustc that referenced this pull request

Jun 12, 2025

@workingjubilee

…cl-and-other-abis, r=RalfJung

compiler: Ease off the accelerator on unsupported_calling_conventions

This is to give us more time to discuss rust-lang#142330 without the ecosystem having an anxiety attack. I have withdrawn unsupported_calling_conventions from report-in-deps

I believe we should consider this a simple suspension of the decision in rust-lang#141435 to start this process, rather than a reversal. That is, we may continue with linting again. But I believe we are about to get a... reasonable amount of feedback just from currently available information and should allow ourselves time to process it.

workingjubilee added a commit to workingjubilee/rustc that referenced this pull request

Jun 12, 2025

@workingjubilee

…cl-and-other-abis, r=RalfJung

compiler: Ease off the accelerator on unsupported_calling_conventions

This is to give us more time to discuss rust-lang#142330 without the ecosystem having an anxiety attack. I have withdrawn unsupported_calling_conventions from report-in-deps

I believe we should consider this a simple suspension of the decision in rust-lang#141435 to start this process, rather than a reversal. That is, we may continue with linting again. But I believe we are about to get a... reasonable amount of feedback just from currently available information and should allow ourselves time to process it.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Jun 12, 2025

@matthiaskrgr

…cl-and-other-abis, r=RalfJung

compiler: Ease off the accelerator on unsupported_calling_conventions

This is to give us more time to discuss rust-lang#142330 without the ecosystem having an anxiety attack. I have withdrawn unsupported_calling_conventions from report-in-deps

I believe we should consider this a simple suspension of the decision in rust-lang#141435 to start this process, rather than a reversal. That is, we may continue with linting again. But I believe we are about to get a... reasonable amount of feedback just from currently available information and should allow ourselves time to process it.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Jun 12, 2025

@matthiaskrgr

…cl-and-other-abis, r=RalfJung

compiler: Ease off the accelerator on unsupported_calling_conventions

This is to give us more time to discuss rust-lang#142330 without the ecosystem having an anxiety attack. I have withdrawn unsupported_calling_conventions from report-in-deps

I believe we should consider this a simple suspension of the decision in rust-lang#141435 to start this process, rather than a reversal. That is, we may continue with linting again. But I believe we are about to get a... reasonable amount of feedback just from currently available information and should allow ourselves time to process it.

bors added a commit that referenced this pull request

Jun 12, 2025

@bors

…r-abis, r=RalfJung

compiler: Ease off the accelerator on unsupported_calling_conventions

This is to give us more time to discuss #142330 without the ecosystem having an anxiety attack. I have withdrawn unsupported_calling_conventions from report-in-deps

I believe we should consider this a simple suspension of the decision in #141435 to start this process, rather than a reversal. That is, we may continue with linting again. But I believe we are about to get a... reasonable amount of feedback just from currently available information and should allow ourselves time to process it.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Jun 12, 2025

@matthiaskrgr

…cl-and-other-abis, r=RalfJung

compiler: Ease off the accelerator on unsupported_calling_conventions

This is to give us more time to discuss rust-lang#142330 without the ecosystem having an anxiety attack. I have withdrawn unsupported_calling_conventions from report-in-deps

I believe we should consider this a simple suspension of the decision in rust-lang#141435 to start this process, rather than a reversal. That is, we may continue with linting again. But I believe we are about to get a... reasonable amount of feedback just from currently available information and should allow ourselves time to process it.

bors added a commit that referenced this pull request

Jun 13, 2025

@bors

…r-abis, r=ChrisDenton,RalfJung

compiler: Ease off the accelerator on unsupported_calling_conventions

This is to give us more time to discuss #142330 without the ecosystem having an anxiety attack. I have withdrawn unsupported_calling_conventions from report-in-deps

I believe we should consider this a simple suspension of the decision in #141435 to start this process, rather than a reversal. That is, we may continue with linting again. But I believe we are about to get a... reasonable amount of feedback just from currently available information and should allow ourselves time to process it.

github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request

Jun 16, 2025

@bors

…r-abis, r=ChrisDenton,RalfJung

compiler: Ease off the accelerator on unsupported_calling_conventions

This is to give us more time to discuss rust-lang/rust#142330 without the ecosystem having an anxiety attack. I have withdrawn unsupported_calling_conventions from report-in-deps

I believe we should consider this a simple suspension of the decision in rust-lang/rust#141435 to start this process, rather than a reversal. That is, we may continue with linting again. But I believe we are about to get a... reasonable amount of feedback just from currently available information and should allow ourselves time to process it.

workingjubilee added a commit to workingjubilee/rustc that referenced this pull request

Jun 23, 2025

@workingjubilee

…abi, r=jdonszelmann,RalfJung

Reject unsupported extern "{abi}"s consistently in all positions

Modify the handling of extern "{abi}" in the compiler so that it has consistent errors without regard to the position in the grammar.

What

Implement the following breakages:

In particular, these architecture-specific ABIs now only compile on their architectures[^4]:

ABIs that are logically x86-specific but actually permitted on all Windows targets remain permitted on Windows, as before. For non-Windows targets, they error if we had previously done so in other positions.

How

We modify rustc_ast_lowering to prevent unsupported ABIs from leaking through the HIR without being checked for target support. They now emit hard errors for every case where we would return Invalid from AbiMap::canonize_abi. 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, unsupported ABI strings error instead of triggering the warning unsupported_fn_ptr_calling_conventions. The code is also simpler compared to alternative implementations that might e.g. split on unstable vs. stable, only suffering some unavoidable complication to support the newly-revived unsupported_calling_conventions lint.[^5]

However, per rust-lang#86232 this does cause errors for rare usages of extern "{abi}" that were theoretically possible to write in Rust source, without previous warning or error. For instance, trait declarations without impls were never checked. These are the exact kinds of leakages that this new approach prevents.

This differs from the following PRs:

Why or Why Not

We already made the decision to issue the unsupported_fn_ptr_calling_conventions future compatibility warning. It has warned in dependencies since rust-lang#135767, which reached stable with Rust 1.87. That was released on 2025 May 17, and it is now June. As we already had erred on these ABI strings in most other positions, and warn on stable for function pointer types, this breakage has had reasonable foreshadowing.

Upgrading the warning to an error addresses a real problem. In some cases the Rust compiler can attempt to actually compute the ABI for calling a function with an unsupported ABI. We could accept this case and compute unsupported ABIs according to some other ABI, silently[^6]. However, this obviously exposes Rust to errors in codegen. We cannot lower directly to the "obvious", target-incorrect ABI and then trust code generators like LLVM to reliably error on these cases, either.

Other considerations include:

pub trait UsedToSneakBy {
    pub extern "gpu-kernel" fn sneaky();
}

r? lang

Fixes rust-lang#86232 Fixes rust-lang#132430 Fixes rust-lang#138738 Fixes rust-lang#142107

[crater run]: rust-lang#142134 (comment) [^9]: Upon any impl, even for provided fn within trait declarations, e.g. pub extern "gpu-kernel" fn sneaky() {}, different HIR types were used which would, in fact, get checked. Likewise for anything with function pointers. Thus we would be discussing deprecation cycles for code that is impotent or forewarned[^7]. [^4]: Some already will not compile, due to reaching ICEs or LLVM errors. [^5]: That lint cannot be moved in a similar way yet because lints operate on HIR, so you cannot emit lints when the HIR has not been completely formed. [^6]: We already do this for all AbiStr we cannot parse, pretending they are ExternAbi::Rust, but we also emit an error to prevent reaching too far into codegen. [^7]: It actually did appear in two cases in rustc's test suite because we are a collection of Rust edge-cases by the simple fact that we don't care if the code actually runs. These cases are being excised in 643a9d2

rust-timer added a commit that referenced this pull request

Jun 24, 2025

@rust-timer

Rollup merge of #142134 - workingjubilee:reject-unsupported-abi, r=jdonszelmann,RalfJung

Reject unsupported extern "{abi}"s consistently in all positions

Modify the handling of extern "{abi}" in the compiler so that it has consistent errors without regard to the position in the grammar.

What

Implement the following breakages:

In particular, these architecture-specific ABIs now only compile on their architectures[^4]:

ABIs that are logically x86-specific but actually permitted on all Windows targets remain permitted on Windows, as before. For non-Windows targets, they error if we had previously done so in other positions.

How

We modify rustc_ast_lowering to prevent unsupported ABIs from leaking through the HIR without being checked for target support. They now emit hard errors for every case where we would return Invalid from AbiMap::canonize_abi. 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, unsupported ABI strings error instead of triggering the warning unsupported_fn_ptr_calling_conventions. The code is also simpler compared to alternative implementations that might e.g. split on unstable vs. stable, only suffering some unavoidable complication to support the newly-revived unsupported_calling_conventions lint.[^5]

However, per #86232 this does cause errors for rare usages of extern "{abi}" that were theoretically possible to write in Rust source, without previous warning or error. For instance, trait declarations without impls were never checked. These are the exact kinds of leakages that this new approach prevents.

This differs from the following PRs:

Why or Why Not

We already made the decision to issue the unsupported_fn_ptr_calling_conventions future compatibility warning. It has warned in dependencies since #135767, which reached stable with Rust 1.87. That was released on 2025 May 17, and it is now June. As we already had erred on these ABI strings in most other positions, and warn on stable for function pointer types, this breakage has had reasonable foreshadowing.

Upgrading the warning to an error addresses a real problem. In some cases the Rust compiler can attempt to actually compute the ABI for calling a function with an unsupported ABI. We could accept this case and compute unsupported ABIs according to some other ABI, silently[^6]. However, this obviously exposes Rust to errors in codegen. We cannot lower directly to the "obvious", target-incorrect ABI and then trust code generators like LLVM to reliably error on these cases, either.

Other considerations include:

pub trait UsedToSneakBy {
    pub extern "gpu-kernel" fn sneaky();
}

r? lang

Fixes #86232 Fixes #132430 Fixes #138738 Fixes #142107

[crater run]: #142134 (comment) [^9]: Upon any impl, even for provided fn within trait declarations, e.g. pub extern "gpu-kernel" fn sneaky() {}, different HIR types were used which would, in fact, get checked. Likewise for anything with function pointers. Thus we would be discussing deprecation cycles for code that is impotent or forewarned[^7]. [^4]: Some already will not compile, due to reaching ICEs or LLVM errors. [^5]: That lint cannot be moved in a similar way yet because lints operate on HIR, so you cannot emit lints when the HIR has not been completely formed. [^6]: We already do this for all AbiStr we cannot parse, pretending they are ExternAbi::Rust, but we also emit an error to prevent reaching too far into codegen. [^7]: It actually did appear in two cases in rustc's test suite because we are a collection of Rust edge-cases by the simple fact that we don't care if the code actually runs. These cases are being excised in 643a9d2

wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this pull request

Aug 11, 2025

@he32

Pkgsrc changes:

Upstream changes relative to 1.88.0:

Version 1.89.0 (2025-08-07)

Language

Compiler

Platform Support

Refer to Rust's platform support page for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These previously stable APIs are now stable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Internal Changes

These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools.

tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request

Aug 12, 2025

@tmeijn

This MR contains the following updates:

Package Update Change
rust minor 1.88.0 -> 1.89.0

MR created with the help of el-capitano/tools/renovate-bot.

Proposed changes to behavior should be submitted there as MRs.


Release Notes

rust-lang/rust (rust)

v1.89.0

Compare Source

==========================

Language

Compiler

Platform Support

Refer to Rust's platform support page for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These previously stable APIs are now stable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Internal Changes

These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools.


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this MR and you won't be reminded about this update again.



This MR has been generated by Renovate Bot.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request

Oct 18, 2025

@he32

Pkgsrc changes:

Upstream changes:

Version 1.90 (2025-09-18)

Language

Compiler

Platform Support

Refer to Rust's platform support page for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These previously stable APIs are now stable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Version 1.89.0 (2025-08-07)

Language

Compiler

Platform Support

Refer to Rust's platform support page for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These previously stable APIs are now stable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Internal Changes

These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request

Oct 23, 2025

@he32

Pkgsrc changes:

Upstream changes:

Version 1.90 (2025-09-18)

Language

Compiler

Platform Support

Refer to Rust's platform support page for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These previously stable APIs are now stable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Version 1.89.0 (2025-08-07)

Language

Compiler

Platform Support

Refer to Rust's platform support page for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These previously stable APIs are now stable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Internal Changes

These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools.