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

Improve missing_abi lint #132357

Merged
merged 2 commits into from
Nov 1, 2024
Merged

Improve missing_abi lint #132357

merged 2 commits into from
Nov 1, 2024

Conversation

m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Oct 30, 2024

This is for the migration lint for rust-lang/rfcs#3722

It is not yet marked as an edition migration lint, because Edition2027 doesn't exist yet.

The lint now includes a machine applicable suggestion:

warning: extern declarations without an explicit ABI are deprecated
 --> src/main.rs:3:1
  |
3 | extern fn a() {}
  | ^^^^^^ help: explicitly specify the C ABI: `extern "C"`
  |

@rustbot
Copy link
Collaborator

rustbot commented Oct 30, 2024

r? @lcnr

rustbot has assigned @lcnr.
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. labels Oct 30, 2024
@jieyouxu jieyouxu added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 30, 2024
Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

LGTM, and happy to approve this if and when it is approved on the lang side.

Would like to see some explicit tests exercising that this does in fact error in edition 2024, and perhaps also exercising the error on free extern functions (extern fn() {}) vs extern blocks.

@compiler-errors
Copy link
Member

compiler-errors commented Oct 30, 2024

Well, seems like from the RFC that this may be too late for 2024: rust-lang/rfcs#3722 (comment).

However, it would be very cool to pull out the edition-independent parts of this -- the change to make the suggestion applicable can still be applied to the lint, and storing the extern span seems nice to do anyways.

@m-ou-se m-ou-se added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. labels Oct 31, 2024
@m-ou-se m-ou-se marked this pull request as ready for review October 31, 2024 09:47
@m-ou-se
Copy link
Member Author

m-ou-se commented Oct 31, 2024

Updated. Removed the edition stuff. This now just improves the lint. I'll send a separate PR to make it warn-by-default that can then be FCP'd.

@m-ou-se m-ou-se changed the title Require explicit ABI for extern in Rust 2024 Improve missing_abi lint Oct 31, 2024
@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Oct 31, 2024

📌 Commit a433ea2 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 31, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 31, 2024
…rrors

Improve missing_abi lint

This is for the migration lint for rust-lang/rfcs#3722

It is not yet marked as an edition migration lint, because `Edition2027` doesn't exist yet.

The lint now includes a machine applicable suggestion:

```
warning: extern declarations without an explicit ABI are deprecated
 --> src/main.rs:3:1
  |
3 | extern fn a() {}
  | ^^^^^^ help: explicitly specify the C ABI: `extern "C"`
  |
```
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 31, 2024
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#131168 (Fix `target_os` for `mipsel-sony-psx`)
 - rust-lang#132209 (Fix validation when lowering `?` trait bounds)
 - rust-lang#132357 (Improve missing_abi lint)
 - rust-lang#132385 (compiler: Move `rustc_target::spec::abi::Abi` to `rustc_abi::ExternAbi`)
 - rust-lang#132417 (macOS: Document the difference between Clang's `-darwin` and `-macosx` targets)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 1, 2024
…kingjubilee

Rollup of 9 pull requests

Successful merges:

 - rust-lang#131168 (Fix `target_os` for `mipsel-sony-psx`)
 - rust-lang#132209 (Fix validation when lowering `?` trait bounds)
 - rust-lang#132294 (Bump Fuchsia)
 - rust-lang#132357 (Improve missing_abi lint)
 - rust-lang#132385 (compiler: Move `rustc_target::spec::abi::Abi` to `rustc_abi::ExternAbi`)
 - rust-lang#132403 (continue `TypingMode` refactor)
 - rust-lang#132417 (macOS: Document the difference between Clang's `-darwin` and `-macosx` targets)
 - rust-lang#132421 (Remove `""` case from RISC-V `llvm_abiname` match statement)
 - rust-lang#132422 (llvm: Match new LLVM 128-bit integer alignment on sparc)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6b0c8cf into rust-lang:master Nov 1, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Nov 1, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 1, 2024
Rollup merge of rust-lang#132357 - m-ou-se:explicit-abi, r=compiler-errors

Improve missing_abi lint

This is for the migration lint for rust-lang/rfcs#3722

It is not yet marked as an edition migration lint, because `Edition2027` doesn't exist yet.

The lint now includes a machine applicable suggestion:

```
warning: extern declarations without an explicit ABI are deprecated
 --> src/main.rs:3:1
  |
3 | extern fn a() {}
  | ^^^^^^ help: explicitly specify the C ABI: `extern "C"`
  |
```
@m-ou-se m-ou-se deleted the explicit-abi branch November 1, 2024 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants