Skip to content

Improperctypes refactor2.2#155359

Open
niacdoial wants to merge 1 commit intorust-lang:mainfrom
niacdoial:improperctypes-refactor2.2
Open

Improperctypes refactor2.2#155359
niacdoial wants to merge 1 commit intorust-lang:mainfrom
niacdoial:improperctypes-refactor2.2

Conversation

@niacdoial
Copy link
Copy Markdown
Contributor

This is "part 2/3 of 2/3 of 1/2" of the original pull request #134697 (refactor plus overhaul of the ImproperCTypes family of lints)
(all pulls of this series of pulls are supersets of the previous pulls.)
previous pull: #155358
next pull: #146273

This commit splits the lint's visit_type function into multiple functions that focus on specific things:

  • visit_indirection (references, boxes, raw pointers)
  • visit_variant_fields (the list of fields of a struct, enum variant, or union)
  • visit_enum
  • visit_struct_or_union
  • visit_type (most "easy" decisions such as labeling char unsafe are here)

since, during these visits, we often move from an "outer type" to an "inner type" (structs, arrays, pointers, etc...),
two structs have been added to track the current state of a visit:

  • VisitorState tracks the state related to the "original type" being checked (function argument/return, static variable)
  • OuterTyData tracks the data related to the type "immediately outer to the current visited type"

r? petrochenkov (because you asked me to)

@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 Apr 15, 2026
@rust-log-analyzer

This comment has been minimized.

@niacdoial niacdoial force-pushed the improperctypes-refactor2.2 branch from a439f4d to fa0fcc6 Compare April 15, 2026 21:18
@petrochenkov
Copy link
Copy Markdown
Contributor

Blocked on #155358.
@rustbot blocked

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 16, 2026
@petrochenkov
Copy link
Copy Markdown
Contributor

#155358 has landed, unblocking.
@rustbot author (to rebase)

@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-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Apr 17, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 17, 2026

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

Another interal change that shouldn't impact rustc users.
The goal is to break apart the gigantic visit_type function into more
managable and easily-editable bits that focus on specific parts of FFI safety.
In particular, all matters linked to indirections (RawPtr,Ref,boxes) are
grouped in a single function.
@niacdoial niacdoial force-pushed the improperctypes-refactor2.2 branch from fa0fcc6 to b2f3002 Compare April 17, 2026 11:38
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 17, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@niacdoial
Copy link
Copy Markdown
Contributor Author

can't believe I let this amount of time pass between tests being OK and this...
@rustbot review

@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 Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants