Skip to content

More accurately check for interior mutability in invalid_reference_casting lint - #160159

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
Urgau:invalid_ref_casts-unsafe-cell
Jul 31, 2026
Merged

More accurately check for interior mutability in invalid_reference_casting lint#160159
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
Urgau:invalid_ref_casts-unsafe-cell

Conversation

@Urgau

@Urgau Urgau commented Jul 29, 2026

Copy link
Copy Markdown
Member

This PR replaces the Freeze trait check in the invalid_reference_casting lint by a recursive type check.

The check was not enough to determine if a type has "interior mutability", as Freeze is proxy for "has some interior mutability", not "fully covered by interior mutability".

As requested in #159960 (comment)

r? mejrs

@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 Jul 29, 2026
@Urgau

Urgau commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 29, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 29, 2026
More accurately check for interior mutability in `invalid_reference_casting` lint
@rust-log-analyzer

This comment has been minimized.

@Urgau
Urgau force-pushed the invalid_ref_casts-unsafe-cell branch from a769af4 to 4b7cb31 Compare July 29, 2026 16:40
@rust-bors

rust-bors Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: b235b37 (b235b372268a906fe0e2f0deabfe4fbb2889d954)
Base parent: d366396 (d3663963ca08f465d01d283a7199778902623bb9)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (b235b37): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -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
Improvements ✅
(secondary)
-2.6% [-2.6%, -2.6%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -3.9%, secondary -5.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.9% [-5.3%, -3.0%] 3
Improvements ✅
(secondary)
-5.6% [-5.6%, -5.6%] 1
All ❌✅ (primary) -3.9% [-5.3%, -3.0%] 3

Cycles

Results (primary -0.1%, secondary 0.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.7% [0.5%, 1.3%] 6
Regressions ❌
(secondary)
1.6% [0.4%, 4.6%] 15
Improvements ✅
(primary)
-0.9% [-2.4%, -0.4%] 6
Improvements ✅
(secondary)
-1.9% [-4.1%, -0.5%] 4
All ❌✅ (primary) -0.1% [-2.4%, 1.3%] 12

Binary size

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

Bootstrap: 489.658s -> 495.449s (1.18%)
Artifact size: 390.17 MiB -> 390.19 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 29, 2026
Comment thread compiler/rustc_lint/src/reference_casting.rs Outdated
@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 Jul 30, 2026
@Urgau
Urgau force-pushed the invalid_ref_casts-unsafe-cell branch from 4b7cb31 to 0c2035c Compare July 31, 2026 09:14
@Urgau Urgau 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 Jul 31, 2026

@mejrs mejrs left a comment

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.

@rust-bors

rust-bors Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 0c2035c has been approved by mejrs

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 Jul 31, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 31, 2026
…l, r=mejrs

More accurately check for interior mutability in `invalid_reference_casting` lint

This PR replaces the `Freeze` trait check in the `invalid_reference_casting` lint by a recursive type check.

The check was not enough to determine if a type has "interior mutability", as `Freeze` is proxy for "has *some* interior mutability", not "fully covered by interior mutability".

As requested in rust-lang#159960 (comment)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 31, 2026
…l, r=mejrs

More accurately check for interior mutability in `invalid_reference_casting` lint

This PR replaces the `Freeze` trait check in the `invalid_reference_casting` lint by a recursive type check.

The check was not enough to determine if a type has "interior mutability", as `Freeze` is proxy for "has *some* interior mutability", not "fully covered by interior mutability".

As requested in rust-lang#159960 (comment)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 31, 2026
…l, r=mejrs

More accurately check for interior mutability in `invalid_reference_casting` lint

This PR replaces the `Freeze` trait check in the `invalid_reference_casting` lint by a recursive type check.

The check was not enough to determine if a type has "interior mutability", as `Freeze` is proxy for "has *some* interior mutability", not "fully covered by interior mutability".

As requested in rust-lang#159960 (comment)
rust-bors Bot pushed a commit that referenced this pull request Jul 31, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #160100 (Add "system" option to `override-allocator` directive)
 - #159675 (rustc: Support `--jobs` options for limiting parallelism in various parts of the compiler)
 - #159999 (Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends)
 - #160233 (Bubble bad path error while parsing field to avoid unecessary second error)
 - #160272 (rustc_metadata: Move native library search code to `rustc_codegen_ssa`)
 - #154202 (rustfmt: Format `cfg_select!`)
 - #158835 (rustc_passes: lint unused `#[path]` attributes on inline modules)
 - #159520 (Suggest `Vec<T>` instead of `[T]`)
 - #160034 (Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser)
 - #160066 (rustc_middle: lint attribute cleanups)
 - #160085 (Remove various superfluous lint attributes)
 - #160113 (Coalesce `rustc_on_unimplemented` attributes and lint malformed filters)
 - #160119 (fix query cycle in `coroutine_hidden_types` for the next solver)
 - #160147 (tests: Remove `-Zthreads` options from tests in `ui/parallel-rustc`)
 - #160157 (Remove outdated comments from `va_list.rs`)
 - #160159 (More accurately check for interior mutability in `invalid_reference_casting` lint)
 - #160208 (rustdoc: Fix crash when trying to list attributes on an opaque type)
 - #160244 (Rename splat to rustc_splat in error messages)
 - #160246 (dont fire `unused_mut` on `&pin mut self`)
 - #160247 (Configure backport nominations for rustfmt)
 - #160274 (renovate: update lock files weekly)
rust-bors Bot pushed a commit that referenced this pull request Jul 31, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #160100 (Add "system" option to `override-allocator` directive)
 - #160220 (Refactor: shrink region ext traits)
 - #159675 (rustc: Support `--jobs` options for limiting parallelism in various parts of the compiler)
 - #159999 (Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends)
 - #160233 (Bubble bad path error while parsing field to avoid unecessary second error)
 - #160272 (rustc_metadata: Move native library search code to `rustc_codegen_ssa`)
 - #154202 (rustfmt: Format `cfg_select!`)
 - #159520 (Suggest `Vec<T>` instead of `[T]`)
 - #159710 (Add rustdoc/cargo PGO profiles to reproducible artifacts)
 - #160034 (Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser)
 - #160066 (rustc_middle: lint attribute cleanups)
 - #160085 (Remove various superfluous lint attributes)
 - #160113 (Coalesce `rustc_on_unimplemented` attributes and lint malformed filters)
 - #160119 (fix query cycle in `coroutine_hidden_types` for the next solver)
 - #160147 (tests: Remove `-Zthreads` options from tests in `ui/parallel-rustc`)
 - #160157 (Remove outdated comments from `va_list.rs`)
 - #160159 (More accurately check for interior mutability in `invalid_reference_casting` lint)
 - #160208 (rustdoc: Fix crash when trying to list attributes on an opaque type)
 - #160244 (Rename splat to rustc_splat in error messages)
 - #160246 (dont fire `unused_mut` on `&pin mut self`)
 - #160247 (Configure backport nominations for rustfmt)
 - #160274 (renovate: update lock files weekly)
@rust-bors
rust-bors Bot merged commit c70f022 into rust-lang:main Jul 31, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 31, 2026
rust-timer added a commit that referenced this pull request Jul 31, 2026
Rollup merge of #160159 - Urgau:invalid_ref_casts-unsafe-cell, r=mejrs

More accurately check for interior mutability in `invalid_reference_casting` lint

This PR replaces the `Freeze` trait check in the `invalid_reference_casting` lint by a recursive type check.

The check was not enough to determine if a type has "interior mutability", as `Freeze` is proxy for "has *some* interior mutability", not "fully covered by interior mutability".

As requested in #159960 (comment)
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Aug 3, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - rust-lang/rust#160100 (Add "system" option to `override-allocator` directive)
 - rust-lang/rust#160220 (Refactor: shrink region ext traits)
 - rust-lang/rust#159675 (rustc: Support `--jobs` options for limiting parallelism in various parts of the compiler)
 - rust-lang/rust#159999 (Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends)
 - rust-lang/rust#160233 (Bubble bad path error while parsing field to avoid unecessary second error)
 - rust-lang/rust#160272 (rustc_metadata: Move native library search code to `rustc_codegen_ssa`)
 - rust-lang/rust#154202 (rustfmt: Format `cfg_select!`)
 - rust-lang/rust#159520 (Suggest `Vec<T>` instead of `[T]`)
 - rust-lang/rust#159710 (Add rustdoc/cargo PGO profiles to reproducible artifacts)
 - rust-lang/rust#160034 (Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser)
 - rust-lang/rust#160066 (rustc_middle: lint attribute cleanups)
 - rust-lang/rust#160085 (Remove various superfluous lint attributes)
 - rust-lang/rust#160113 (Coalesce `rustc_on_unimplemented` attributes and lint malformed filters)
 - rust-lang/rust#160119 (fix query cycle in `coroutine_hidden_types` for the next solver)
 - rust-lang/rust#160147 (tests: Remove `-Zthreads` options from tests in `ui/parallel-rustc`)
 - rust-lang/rust#160157 (Remove outdated comments from `va_list.rs`)
 - rust-lang/rust#160159 (More accurately check for interior mutability in `invalid_reference_casting` lint)
 - rust-lang/rust#160208 (rustdoc: Fix crash when trying to list attributes on an opaque type)
 - rust-lang/rust#160244 (Rename splat to rustc_splat in error messages)
 - rust-lang/rust#160246 (dont fire `unused_mut` on `&pin mut self`)
 - rust-lang/rust#160247 (Configure backport nominations for rustfmt)
 - rust-lang/rust#160274 (renovate: update lock files weekly)
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.

5 participants