Skip to content
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

Add explicit_extern_abis Feature and Enforce Explicit ABIs #135340

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

obeis
Copy link
Contributor

@obeis obeis commented Jan 10, 2025

The unstable explicit_extern_abis feature is introduced, requiring explicit ABIs in extern blocks. Hard errors will be enforced with this feature enabled in a future edition.

RFC rust-lang/rfcs#3722

Update #134986

@rustbot
Copy link
Collaborator

rustbot commented Jan 10, 2025

r? @wesleywiser

rustbot has assigned @wesleywiser.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 10, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jan 10, 2025

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

@traviscross traviscross added the F-explicit_extern_abis `#![feature(explicit_extern_abis)]` label Jan 10, 2025
@traviscross
Copy link
Contributor

@rustbot labels +S-blocked
@rustbot author

We're still finalizing the timing and name of the next edition, and in any case, I think I'd like to see a separate PR for adding the various bits for the next edition that's separate from any edition item.

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 10, 2025
@rust-log-analyzer

This comment has been minimized.

@obeis obeis force-pushed the explicit-extern-abis branch from 938c721 to b327d2d Compare January 10, 2025 18:14
@rust-log-analyzer

This comment has been minimized.

@workingjubilee
Copy link
Member

I do not think we will accept the edition changes being folded into this PR, @obeis

@obeis obeis force-pushed the explicit-extern-abis branch from b327d2d to e25d0af Compare January 10, 2025 19:42
@obeis obeis force-pushed the explicit-extern-abis branch from e25d0af to 20f28b1 Compare January 10, 2025 19:55
@rust-log-analyzer

This comment has been minimized.

@obeis obeis force-pushed the explicit-extern-abis branch 2 times, most recently from fe8b62b to bc8ed0e Compare January 10, 2025 20:30
@rust-log-analyzer

This comment has been minimized.

@obeis obeis force-pushed the explicit-extern-abis branch from bc8ed0e to e1db710 Compare January 11, 2025 15:05
@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Jan 11, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jan 11, 2025

This PR modifies tests/run-make/. If this PR is trying to port a Makefile
run-make test to use rmake.rs, please update the
run-make port tracking issue
so we can track our progress. You can either modify the tracking issue
directly, or you can comment on the tracking issue and link this PR.

cc @jieyouxu

@traviscross traviscross added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 12, 2025
@Amanieu Amanieu removed the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Jan 22, 2025
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 16, 2025
@obeis obeis force-pushed the explicit-extern-abis branch from d8ddeb1 to 008c19c Compare March 18, 2025 19:48
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 18, 2025
@obeis obeis requested a review from traviscross March 18, 2025 19:51
@bors
Copy link
Collaborator

bors commented Apr 2, 2025

☔ The latest upstream changes (presumably #139269) made this pull request unmergeable. Please resolve the merge conflicts.

@traviscross
Copy link
Contributor

Let's please update that comment as suggested.

@rustbot author

After that, this looks OK to me as a lang and edition matter, and the impl looks OK to me, so r=me along with your own review.

r? compiler

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 7, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 7, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot assigned Nadrieril and unassigned traviscross Apr 7, 2025
@obeis obeis force-pushed the explicit-extern-abis branch from 008c19c to 76c779f Compare April 8, 2025 02:50
@obeis
Copy link
Contributor Author

obeis commented Apr 8, 2025

@rustbot ready
@bors r=@traviscross rollup

@bors
Copy link
Collaborator

bors commented Apr 8, 2025

@obeis: 🔑 Insufficient privileges: Not in reviewers

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 8, 2025
@bors
Copy link
Collaborator

bors commented Apr 8, 2025

@obeis: 🔑 Insufficient privileges: not in try users

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 8, 2025
@traviscross
Copy link
Contributor

@obeis: That part of my note there was directed at the compiler reviewer I assigned.

@Nadrieril
Copy link
Member

I would like this to be implemented as an allow-by-default lint, likely called implicit_extern_abis. Given how simple the lint is, we may not even need to put it behind a feature gate. If there's anything undecided then ok for the feature gate.

Having it as a lint makes it easy to deny on a later edition and makes the edition migration trivial. With the current implementation, I don't think we can easily do the "first make the crate muti-edition-valid, then update the edition" process, whereas with a lint one can just deny(edition_2027_migration_lints) (I forget the exact name).

@traviscross
Copy link
Contributor

There already is a lint here (missing_abi), and it's already warn-by-default. It includes a machine-applicable suggestion even. What this PR is doing is making it a hard error (not a lint) in a future edition.

Playground link

@traviscross
Copy link
Contributor

Making it a hard error is in accordance with RFC 3722.

In terms of process, once we add a new particular numbered edition (e.g. "Rust 2025"), the edition team will need to accept this change into that edition, and lang will need to make a decision to stabilize this in that edition.

Until then, this hard error must remain under a feature flag and can only be present in the future edition (introduced in #137606) which abides by a set of rules documented here and FCPed by the edition team.

@Nadrieril
Copy link
Member

Nadrieril commented Apr 9, 2025

Oh, I see, I went a bit fast. All I want is a run-rustfix test in edition 2024 with deny(edition_future_compatibility) that checks that the migration is correctly applied. I think the way to make this happen is to add

    @future_incompatible = FutureIncompatibleInfo {
        reason: FutureIncompatibilityReason::EditionError(Edition::EditionFuture),
        reference: "issue #xxxx",
    };

to the lint declaration.

EDIT: oh, the lint is already warn-by-default so then there's no need for a new test. Still, this annotation would improve the error message.

Comment on lines +827 to +832
#[derive(Diagnostic)]
#[diag(ast_passes_extern_without_abi)]
pub(crate) struct MissingAbi {
#[primary_span]
pub span: Span,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hard error should have a suggestion too, in case someone changes the edition string by hand.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mixed feelings about a suggestion in the new edition. One purpose of making this a hard error is that we don't want to suggest that "C" is the default any longer (and we may want to later consider making "Rust" the default). We do machine-applicable suggestions when we're really sure that's the right fix, but once we move away from this default, it's no longer actually clear that is what the user meant.

If we want to add some help text here telling the user that old editions inferred a default and that this is no longer true, and so the user needs to pick one explicitly, that'd of course be OK. If we want to go further and add a machine-applicable fix to this hard error, then I'd want a lang decision here to that effect.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Help text sounds good, it solves the problem of "user updates edition without thinking, doesn't understand the new error".

@traviscross
Copy link
Contributor

Oh, I see, I went a bit fast. All I want is a run-rustfix test in edition 2024 with deny(edition_future_compatibility) that checks that the migration is correctly applied. I think the way to make this happen is to add

    @future_incompatible = FutureIncompatibleInfo {
        reason: FutureIncompatibilityReason::EditionError(Edition::EditionFuture),
        reference: "issue #xxxx",
    };

to the lint declaration.

EDIT: oh, the lint is already warn-by-default so then there's no need for a new test. Still, this annotation would improve the error message.

This cannot be done. Please see my earlier review comment:

#135340 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs F-explicit_extern_abis `#![feature(explicit_extern_abis)]` 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.