Skip to content

perf:cache FFI safety results in improper_ctypes lint - #163348

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
xonx4l:improper_ctypes-lint-cache
Oct 8, 2026
Merged

rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
xonx4l:improper_ctypes-lint-cache

Conversation

@xonx4l

@xonx4l xonx4l commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

This PR cache FFI safety results in improper_ctypes lint .

ImproperCTypesVisitor's cache field is recreated empty at every call site, so a struct type gets fully re-walked from scratch each time instead of once .

The implementation here moves the cache onto ImproperCtypesLint, so it remembers types we already checked and found FFI-safe, so we don't check the same type again every time it shows up in another function. We only remember "safe" types, never "unsafe" ones. That way we never need to keep the actual type around, just a fingerprint of it.Thus it persists across a whole module worth of foreign items.

@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 Sep 25, 2026
@rustbot

rustbot commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

r? @nnethercote

rustbot has assigned @nnethercote.
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 77 candidates
  • Random selection from 19 candidates

@rust-log-analyzer

This comment has been minimized.

@nnethercote

Copy link
Copy Markdown
Contributor

What motivated this change? Do you have any measurements showing that it improves compile times?

@nnethercote nnethercote 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 Sep 27, 2026
@xonx4l

xonx4l commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor Author

The motivation for the change is that the cache is recreated empty at every call site, so a struct shared across many extern functions gets fully re-checked from scratch each time instead of once.

For measurement I profiled a test file containing some extern "C" functions sharing a few structs with cachegrind :).

Before: 2,000,537,577 instructions count , After: 1,753,411,352 instructions count

Which gives approx a total of 12% of instructions count reduction. Thank you!

let ffi_res = visitor.check_type(state, ty);
if matches!(ffi_res, FfiResult::FfiSafe) {
self.known_safe.borrow_mut().insert(key);
}

@nnethercote nnethercote Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's unfortunate to have this contains + "do stuff" + insert pattern repeated three times. Can you factor it out into a separate method? It might need a closure argument for the "do stuff" part.

@rustbot author

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, will make it a separate method . Thank you!

@rustbot

rustbot commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

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

@xonx4l

xonx4l commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@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 Oct 5, 2026
@nnethercote

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 54a6d2e has been approved by nnethercote

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 6, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 6, 2026
… r=nnethercote

perf:cache FFI safety results in improper_ctypes lint

This PR cache FFI safety results in improper_ctypes lint .

ImproperCTypesVisitor's cache field is recreated empty at every call site, so a struct type gets fully re-walked from scratch each time instead of once .

The implementation here moves the cache onto ImproperCtypesLint, so it remembers types we already checked and found FFI-safe, so we don't check the same type again every time it shows up in another function. We only remember "safe" types, never "unsafe" ones. That way we never need to keep the actual type around, just a fingerprint of it.Thus it persists across a whole module worth of foreign items.
rust-bors Bot pushed a commit that referenced this pull request Oct 6, 2026
Rollup of 3 pull requests

Successful merges:

 - #163809 (Adjust the adjustment to wasi TLS to no longer adjust)
 - #163348 (perf:cache FFI safety results in improper_ctypes lint)
 - #163772 (comptime fn error: suggest wrapping in const block)
@rust-bors

rust-bors Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

⌛ Testing commit 54a6d2e with merge b1bfbc8...

Workflow: https://github.com/rust-lang/rust/actions/runs/37416185729

rust-bors Bot pushed a commit that referenced this pull request Oct 6, 2026
perf:cache FFI safety results in improper_ctypes lint

This PR cache FFI safety results in improper_ctypes lint .

ImproperCTypesVisitor's cache field is recreated empty at every call site, so a struct type gets fully re-walked from scratch each time instead of once .

The implementation here moves the cache onto ImproperCtypesLint, so it remembers types we already checked and found FFI-safe, so we don't check the same type again every time it shows up in another function. We only remember "safe" types, never "unsafe" ones. That way we never need to keep the actual type around, just a fingerprint of it.Thus it persists across a whole module worth of foreign items.
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 6, 2026
… r=nnethercote

perf:cache FFI safety results in improper_ctypes lint

This PR cache FFI safety results in improper_ctypes lint .

ImproperCTypesVisitor's cache field is recreated empty at every call site, so a struct type gets fully re-walked from scratch each time instead of once .

The implementation here moves the cache onto ImproperCtypesLint, so it remembers types we already checked and found FFI-safe, so we don't check the same type again every time it shows up in another function. We only remember "safe" types, never "unsafe" ones. That way we never need to keep the actual type around, just a fingerprint of it.Thus it persists across a whole module worth of foreign items.
@jhpratt

jhpratt commented Oct 6, 2026

Copy link
Copy Markdown
Member

@bors yield once more

@rust-bors

rust-bors Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #163859.

@rust-bors

rust-bors Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. It was not possible to cancel some workflows.

The next pull request likely to be tested is #163831.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 6, 2026
… r=nnethercote

perf:cache FFI safety results in improper_ctypes lint

This PR cache FFI safety results in improper_ctypes lint .

ImproperCTypesVisitor's cache field is recreated empty at every call site, so a struct type gets fully re-walked from scratch each time instead of once .

The implementation here moves the cache onto ImproperCtypesLint, so it remembers types we already checked and found FFI-safe, so we don't check the same type again every time it shows up in another function. We only remember "safe" types, never "unsafe" ones. That way we never need to keep the actual type around, just a fingerprint of it.Thus it persists across a whole module worth of foreign items.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 6, 2026
… r=nnethercote

perf:cache FFI safety results in improper_ctypes lint

This PR cache FFI safety results in improper_ctypes lint .

ImproperCTypesVisitor's cache field is recreated empty at every call site, so a struct type gets fully re-walked from scratch each time instead of once .

The implementation here moves the cache onto ImproperCtypesLint, so it remembers types we already checked and found FFI-safe, so we don't check the same type again every time it shows up in another function. We only remember "safe" types, never "unsafe" ones. That way we never need to keep the actual type around, just a fingerprint of it.Thus it persists across a whole module worth of foreign items.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 6, 2026
… r=nnethercote

perf:cache FFI safety results in improper_ctypes lint

This PR cache FFI safety results in improper_ctypes lint .

ImproperCTypesVisitor's cache field is recreated empty at every call site, so a struct type gets fully re-walked from scratch each time instead of once .

The implementation here moves the cache onto ImproperCtypesLint, so it remembers types we already checked and found FFI-safe, so we don't check the same type again every time it shows up in another function. We only remember "safe" types, never "unsafe" ones. That way we never need to keep the actual type around, just a fingerprint of it.Thus it persists across a whole module worth of foreign items.
rust-bors Bot pushed a commit that referenced this pull request Oct 6, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI)
 - #163863 (use the type name instead of `Self` in constructor paths again)
 - #163864 (Remove CLAUDE.md)
 - #163877 (Add regression test for duplicated rustdoc search results between std and core)
 - #162000 (peel_transparent_wrappers only works on non-1ZST)
 - #163257 (abby DSL: sanity checks on forall where clauses)
 - #163348 (perf:cache FFI safety results in improper_ctypes lint)
 - #163768 (Move more `rustdoc-html` tests in the right location)
 - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places)
 - #163807 (Add `has_reliable_f16b` for Arm)
 - #163826 (Update books)
 - #163849 (ci: update to PowerShell 7.6.6)
 - #163870 (Add if-installed:auto:spellcheck to pre-push script)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 6, 2026
… r=nnethercote

perf:cache FFI safety results in improper_ctypes lint

This PR cache FFI safety results in improper_ctypes lint .

ImproperCTypesVisitor's cache field is recreated empty at every call site, so a struct type gets fully re-walked from scratch each time instead of once .

The implementation here moves the cache onto ImproperCtypesLint, so it remembers types we already checked and found FFI-safe, so we don't check the same type again every time it shows up in another function. We only remember "safe" types, never "unsafe" ones. That way we never need to keep the actual type around, just a fingerprint of it.Thus it persists across a whole module worth of foreign items.
rust-bors Bot pushed a commit that referenced this pull request Oct 6, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI)
 - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`)
 - #163863 (use the type name instead of `Self` in constructor paths again)
 - #163864 (Remove CLAUDE.md)
 - #163877 (Add regression test for duplicated rustdoc search results between std and core)
 - #162000 (peel_transparent_wrappers only works on non-1ZST)
 - #163257 (abby DSL: sanity checks on forall where clauses)
 - #163348 (perf:cache FFI safety results in improper_ctypes lint)
 - #163768 (Move more `rustdoc-html` tests in the right location)
 - #163778 (check is_indirect_first_projection when replacing in RefProp)
 - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places)
 - #163807 (Add `has_reliable_f16b` for Arm)
 - #163826 (Update books)
 - #163849 (ci: update to PowerShell 7.6.6)
 - #163870 (Add if-installed:auto:spellcheck to pre-push script)
 - #163874 (explicitly check for fresh vars in canonicalize)
 - #163880 (Don't add pkgs.rustc to PATH in nix dev shell)
rust-bors Bot pushed a commit that referenced this pull request Oct 6, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI)
 - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`)
 - #163863 (use the type name instead of `Self` in constructor paths again)
 - #163864 (Remove CLAUDE.md)
 - #163877 (Add regression test for duplicated rustdoc search results between std and core)
 - #162000 (peel_transparent_wrappers only works on non-1ZST)
 - #163257 (abby DSL: sanity checks on forall where clauses)
 - #163348 (perf:cache FFI safety results in improper_ctypes lint)
 - #163768 (Move more `rustdoc-html` tests in the right location)
 - #163778 (check is_indirect_first_projection when replacing in RefProp)
 - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places)
 - #163807 (Add `has_reliable_f16b` for Arm)
 - #163826 (Update books)
 - #163849 (ci: update to PowerShell 7.6.6)
 - #163870 (Add if-installed:auto:spellcheck to pre-push script)
 - #163874 (explicitly check for fresh vars in canonicalize)
 - #163880 (Don't add pkgs.rustc to PATH in nix dev shell)
rust-bors Bot pushed a commit that referenced this pull request Oct 6, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI)
 - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`)
 - #163863 (use the type name instead of `Self` in constructor paths again)
 - #163864 (Remove CLAUDE.md)
 - #163877 (Add regression test for duplicated rustdoc search results between std and core)
 - #162000 (peel_transparent_wrappers only works on non-1ZST)
 - #163257 (abby DSL: sanity checks on forall where clauses)
 - #163348 (perf:cache FFI safety results in improper_ctypes lint)
 - #163768 (Move more `rustdoc-html` tests in the right location)
 - #163778 (check is_indirect_first_projection when replacing in RefProp)
 - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places)
 - #163807 (Add `has_reliable_f16b` for Arm)
 - #163826 (Update books)
 - #163849 (ci: update to PowerShell 7.6.6)
 - #163870 (Add if-installed:auto:spellcheck to pre-push script)
 - #163874 (explicitly check for fresh vars in canonicalize)
 - #163880 (Don't add pkgs.rustc to PATH in nix dev shell)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 7, 2026
… r=nnethercote

perf:cache FFI safety results in improper_ctypes lint

This PR cache FFI safety results in improper_ctypes lint .

ImproperCTypesVisitor's cache field is recreated empty at every call site, so a struct type gets fully re-walked from scratch each time instead of once .

The implementation here moves the cache onto ImproperCtypesLint, so it remembers types we already checked and found FFI-safe, so we don't check the same type again every time it shows up in another function. We only remember "safe" types, never "unsafe" ones. That way we never need to keep the actual type around, just a fingerprint of it.Thus it persists across a whole module worth of foreign items.
rust-bors Bot pushed a commit that referenced this pull request Oct 7, 2026
…uwer

Rollup of 25 pull requests

Successful merges:

 - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI)
 - #163806 (even more `tests/crashes` migration for `-Znext-solver`)
 - #162156 (add IBM f128 type)
 - #163508 (Document the `rustc_on_unimplemented` attribute.)
 - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`)
 - #163863 (use the type name instead of `Self` in constructor paths again)
 - #163864 (Remove CLAUDE.md)
 - #163877 (Add regression test for duplicated rustdoc search results between std and core)
 - #163916 (Shrink `PartialRes` and its alignment)
 - #149753 (On name resolution error in parameter list, suggest possible `const` typo and avoid unnecessary second error)
 - #152557 (Oneshot `is_ready`)
 - #157273 (Stabilize `optimize` attribute)
 - #162000 (peel_transparent_wrappers only works on non-1ZST)
 - #163257 (abby DSL: sanity checks on forall where clauses)
 - #163343 (`unit` and `[1 x unit]` layouts are incompatible on big-endian targets)
 - #163348 (perf:cache FFI safety results in improper_ctypes lint)
 - #163768 (Move more `rustdoc-html` tests in the right location)
 - #163778 (check is_indirect_first_projection when replacing in RefProp)
 - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places)
 - #163807 (Add `has_reliable_f16b` for Arm)
 - #163809 (Switch TLS implementation for wasi and bump SDK version to 34)
 - #163826 (Update books)
 - #163849 (ci: update to PowerShell 7.6.6)
 - #163869 (INSTALL.md: use UCRT64 instead of MINGW64 in MSYS2 section)
 - #163870 (Add if-installed:auto:spellcheck to pre-push script)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 7, 2026
… r=nnethercote

perf:cache FFI safety results in improper_ctypes lint

This PR cache FFI safety results in improper_ctypes lint .

ImproperCTypesVisitor's cache field is recreated empty at every call site, so a struct type gets fully re-walked from scratch each time instead of once .

The implementation here moves the cache onto ImproperCtypesLint, so it remembers types we already checked and found FFI-safe, so we don't check the same type again every time it shows up in another function. We only remember "safe" types, never "unsafe" ones. That way we never need to keep the actual type around, just a fingerprint of it.Thus it persists across a whole module worth of foreign items.
rust-bors Bot pushed a commit that referenced this pull request Oct 7, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI)
 - #163806 (even more `tests/crashes` migration for `-Znext-solver`)
 - #163508 (Document the `rustc_on_unimplemented` attribute.)
 - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`)
 - #163863 (use the type name instead of `Self` in constructor paths again)
 - #163864 (Remove CLAUDE.md)
 - #163877 (Add regression test for duplicated rustdoc search results between std and core)
 - #163916 (Shrink `PartialRes` and its alignment)
 - #149753 (On name resolution error in parameter list, suggest possible `const` typo and avoid unnecessary second error)
 - #152557 (Oneshot `is_ready`)
 - #157273 (Stabilize `optimize` attribute)
 - #162000 (peel_transparent_wrappers only works on non-1ZST)
 - #163257 (abby DSL: sanity checks on forall where clauses)
 - #163343 (`unit` and `[1 x unit]` layouts are incompatible on big-endian targets)
 - #163348 (perf:cache FFI safety results in improper_ctypes lint)
 - #163768 (Move more `rustdoc-html` tests in the right location)
 - #163778 (check is_indirect_first_projection when replacing in RefProp)
 - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places)
 - #163807 (Add `has_reliable_f16b` for Arm)
 - #163809 (Switch TLS implementation for wasi and bump SDK version to 34)
 - #163826 (Update books)
 - #163849 (ci: update to PowerShell 7.6.6)
 - #163869 (INSTALL.md: use UCRT64 instead of MINGW64 in MSYS2 section)
 - #163870 (Add if-installed:auto:spellcheck to pre-push script)
rust-bors Bot pushed a commit that referenced this pull request Oct 7, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI)
 - #163806 (even more `tests/crashes` migration for `-Znext-solver`)
 - #163508 (Document the `rustc_on_unimplemented` attribute.)
 - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`)
 - #163863 (use the type name instead of `Self` in constructor paths again)
 - #163864 (Remove CLAUDE.md)
 - #163877 (Add regression test for duplicated rustdoc search results between std and core)
 - #163916 (Shrink `PartialRes` and its alignment)
 - #149753 (On name resolution error in parameter list, suggest possible `const` typo and avoid unnecessary second error)
 - #152557 (Oneshot `is_ready`)
 - #157273 (Stabilize `optimize` attribute)
 - #162000 (peel_transparent_wrappers only works on non-1ZST)
 - #163257 (abby DSL: sanity checks on forall where clauses)
 - #163343 (`unit` and `[1 x unit]` layouts are incompatible on big-endian targets)
 - #163348 (perf:cache FFI safety results in improper_ctypes lint)
 - #163768 (Move more `rustdoc-html` tests in the right location)
 - #163778 (check is_indirect_first_projection when replacing in RefProp)
 - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places)
 - #163807 (Add `has_reliable_f16b` for Arm)
 - #163809 (Switch TLS implementation for wasi and bump SDK version to 34)
 - #163826 (Update books)
 - #163849 (ci: update to PowerShell 7.6.6)
 - #163869 (INSTALL.md: use UCRT64 instead of MINGW64 in MSYS2 section)
 - #163870 (Add if-installed:auto:spellcheck to pre-push script)
rust-bors Bot pushed a commit that referenced this pull request Oct 7, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI)
 - #163806 (even more `tests/crashes` migration for `-Znext-solver`)
 - #163508 (Document the `rustc_on_unimplemented` attribute.)
 - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`)
 - #163863 (use the type name instead of `Self` in constructor paths again)
 - #163864 (Remove CLAUDE.md)
 - #163877 (Add regression test for duplicated rustdoc search results between std and core)
 - #163916 (Shrink `PartialRes` and its alignment)
 - #149753 (On name resolution error in parameter list, suggest possible `const` typo and avoid unnecessary second error)
 - #152557 (Oneshot `is_ready`)
 - #157273 (Stabilize `optimize` attribute)
 - #162000 (peel_transparent_wrappers only works on non-1ZST)
 - #163257 (abby DSL: sanity checks on forall where clauses)
 - #163343 (`unit` and `[1 x unit]` layouts are incompatible on big-endian targets)
 - #163348 (perf:cache FFI safety results in improper_ctypes lint)
 - #163768 (Move more `rustdoc-html` tests in the right location)
 - #163778 (check is_indirect_first_projection when replacing in RefProp)
 - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places)
 - #163807 (Add `has_reliable_f16b` for Arm)
 - #163809 (Switch TLS implementation for wasi and bump SDK version to 34)
 - #163826 (Update books)
 - #163849 (ci: update to PowerShell 7.6.6)
 - #163869 (INSTALL.md: use UCRT64 instead of MINGW64 in MSYS2 section)
 - #163870 (Add if-installed:auto:spellcheck to pre-push script)
rust-bors Bot pushed a commit that referenced this pull request Oct 7, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI)
 - #163806 (even more `tests/crashes` migration for `-Znext-solver`)
 - #163508 (Document the `rustc_on_unimplemented` attribute.)
 - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`)
 - #163863 (use the type name instead of `Self` in constructor paths again)
 - #163864 (Remove CLAUDE.md)
 - #163877 (Add regression test for duplicated rustdoc search results between std and core)
 - #163916 (Shrink `PartialRes` and its alignment)
 - #149753 (On name resolution error in parameter list, suggest possible `const` typo and avoid unnecessary second error)
 - #152557 (Oneshot `is_ready`)
 - #157273 (Stabilize `optimize` attribute)
 - #162000 (peel_transparent_wrappers only works on non-1ZST)
 - #163257 (abby DSL: sanity checks on forall where clauses)
 - #163343 (`unit` and `[1 x unit]` layouts are incompatible on big-endian targets)
 - #163348 (perf:cache FFI safety results in improper_ctypes lint)
 - #163768 (Move more `rustdoc-html` tests in the right location)
 - #163778 (check is_indirect_first_projection when replacing in RefProp)
 - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places)
 - #163807 (Add `has_reliable_f16b` for Arm)
 - #163809 (Switch TLS implementation for wasi and bump SDK version to 34)
 - #163826 (Update books)
 - #163849 (ci: update to PowerShell 7.6.6)
 - #163869 (INSTALL.md: use UCRT64 instead of MINGW64 in MSYS2 section)
 - #163870 (Add if-installed:auto:spellcheck to pre-push script)
rust-bors Bot pushed a commit that referenced this pull request Oct 7, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI)
 - #163806 (even more `tests/crashes` migration for `-Znext-solver`)
 - #163508 (Document the `rustc_on_unimplemented` attribute.)
 - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`)
 - #163863 (use the type name instead of `Self` in constructor paths again)
 - #163864 (Remove CLAUDE.md)
 - #163877 (Add regression test for duplicated rustdoc search results between std and core)
 - #163916 (Shrink `PartialRes` and its alignment)
 - #149753 (On name resolution error in parameter list, suggest possible `const` typo and avoid unnecessary second error)
 - #152557 (Oneshot `is_ready`)
 - #157273 (Stabilize `optimize` attribute)
 - #162000 (peel_transparent_wrappers only works on non-1ZST)
 - #163343 (`unit` and `[1 x unit]` layouts are incompatible on big-endian targets)
 - #163348 (perf:cache FFI safety results in improper_ctypes lint)
 - #163768 (Move more `rustdoc-html` tests in the right location)
 - #163778 (check is_indirect_first_projection when replacing in RefProp)
 - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places)
 - #163807 (Add `has_reliable_f16b` for Arm)
 - #163809 (Switch TLS implementation for wasi and bump SDK version to 34)
 - #163826 (Update books)
 - #163849 (ci: update to PowerShell 7.6.6)
 - #163869 (INSTALL.md: use UCRT64 instead of MINGW64 in MSYS2 section)
 - #163870 (Add if-installed:auto:spellcheck to pre-push script)
@rust-bors
rust-bors Bot merged commit dfa9cf1 into rust-lang:main Oct 8, 2026
14 of 15 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 8, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 8, 2026
Rollup merge of #163348 - xonx4l:improper_ctypes-lint-cache, r=nnethercote

perf:cache FFI safety results in improper_ctypes lint

This PR cache FFI safety results in improper_ctypes lint .

ImproperCTypesVisitor's cache field is recreated empty at every call site, so a struct type gets fully re-walked from scratch each time instead of once .

The implementation here moves the cache onto ImproperCtypesLint, so it remembers types we already checked and found FFI-safe, so we don't check the same type again every time it shows up in another function. We only remember "safe" types, never "unsafe" ones. That way we never need to keep the actual type around, just a fingerprint of it.Thus it persists across a whole module worth of foreign items.
@rust-timer

Copy link
Copy Markdown
Collaborator

Note

This PR was benchmarked as part of triage of its containing rollup: triage URL.

Finished benchmarking commit (e5ce1f7): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.3%, -0.1%] 4
Improvements ✅
(secondary)
-0.3% [-0.7%, -0.1%] 21
All ❌✅ (primary) -0.1% [-0.3%, -0.1%] 4

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

This perf run didn't have relevant results for this metric.

Binary size

This perf run didn't have relevant results for this metric.

Artifact size: 408.59 MiB -> 408.61 MiB (0.00%)

@JonathanBrouwer

Copy link
Copy Markdown
Member

This is noise, all PRs in the rollup have the same results

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.

7 participants