Skip to content

report improper_ctypes lints from external macros - #160870

Open
im-lunex wants to merge 1 commit into
rust-lang:mainfrom
im-lunex:fix_#160862
Open

im-lunex wants to merge 1 commit into
rust-lang:mainfrom
im-lunex:fix_#160862

Conversation

@im-lunex

@im-lunex im-lunex commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

FFI safety belongs to the types being defined, not the macro generating the extern function. Currently, cross-crate macros trigger a heuristic that silently drops these warnings.

This PR enables report_in_external_macro for improper_ctypes and improper_ctypes_definitions. Warnings now emit as expected, while code suggestions stay suppressed for external spans.

uses_power_alignment is untouched as it follows a separate emission path.

Fixes #160862

@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 Aug 10, 2026
@rustbot

rustbot commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

r? @khyperia

rustbot has assigned @khyperia.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 18 candidates

@im-lunex
im-lunex marked this pull request as draft August 10, 2026 17:41
@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 Aug 10, 2026
@im-lunex
im-lunex marked this pull request as ready for review August 10, 2026 17:47
@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 Aug 10, 2026
@khyperia

Copy link
Copy Markdown
Member

thanks for the PR, we appreciate it! ❤️

uses_power_alignment is untouched as it follows a separate emission path.

hmm, why are you mentioning this?

@im-lunex

Copy link
Copy Markdown
Contributor Author

when I was adding report_in_external_macro to the two lints.. saw USES_POWER_ALIGNMENT sitting just below them in the same pass. it confused me for a second on whether I should touch it too then realized it was completely unrelated... but taught it would be better to add this for more clarification...

@khyperia

Copy link
Copy Markdown
Member

right, thanks! this looks good to me, but I'm unsure of the review process for lint changes like this, especially because the issue was just created and you posted a PR to fix it immediately, and am inexperienced with estimating lint ecosystem impact/etc. - e.g. if the macro comes from a third party crate you can't easily update. So, rerolling for that perspective, and I'll listen/learn for next time~

@rustbot reroll

@rustbot rustbot assigned dingxiangfei2009 and unassigned khyperia Aug 13, 2026
@im-lunex

im-lunex commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor Author

r? @oli-obk

@rustbot rustbot assigned mati865 and oli-obk and unassigned dingxiangfei2009 and mati865 Aug 21, 2026
@rustbot

rustbot commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@oli-obk oli-obk added the I-lang-easy-decision Issue: The decision needed by the team is conjectured to be easy; this does not imply nomination label Sep 7, 2026
@oli-obk

oli-obk commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Let's see whether T-lang knows of any reason of why we shouldn't do this, seems simple enough and probably won't cause any new large amounts of lints reported in the ecosystem

@oli-obk oli-obk added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-lang Relevant to the language team L-improper_ctypes Lint: improper_ctypes and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 10, 2026
@oli-obk oli-obk added the S-waiting-on-t-lang Status: Awaiting decision from T-lang label Sep 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. I-lang-easy-decision Issue: The decision needed by the team is conjectured to be easy; this does not imply nomination L-improper_ctypes Lint: improper_ctypes S-waiting-on-t-lang Status: Awaiting decision from T-lang T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

improper_ctypes_definitions is sometimes (but not always) bypassed by cross-crate macros

6 participants