Skip to content

dont fire unused_mut on &pin mut self - #160246

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Albab-Hasan:pin-ergonomics-unused-mut
Jul 31, 2026
Merged

dont fire unused_mut on &pin mut self#160246
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Albab-Hasan:pin-ergonomics-unused-mut

Conversation

@Albab-Hasan

Copy link
Copy Markdown
Contributor

SelfKind::Pinned in Param::from_self was setting the binding mutability to mutbl, so &pin mut self produced a mutable binding and triggered unused_mut spuriously. the mut qualifies the pin reference, not the binding. same as SelfKind::Region which uses Mutability::Not.

fixes #142077

r? @petrochenkov

`SelfKind::Pinned` in `Param::from_self` was setting the binding mutability
to `mutbl`, so `&pin mut self` produced a mutable binding and triggered
`unused_mut` spuriously. the `mut` qualifies the pin reference, not the
binding -- same as `SelfKind::Region` which uses `Mutability::Not`.

fixes rust-lang#142077
@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 31, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 7f51ec6 has been approved by petrochenkov

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
…mut, r=petrochenkov

dont fire `unused_mut` on `&pin mut self`

`SelfKind::Pinned` in `Param::from_self` was setting the binding mutability to `mutbl`, so `&pin mut self` produced a mutable binding and triggered `unused_mut` spuriously. the `mut` qualifies the pin reference, not the binding. same as `SelfKind::Region` which uses `Mutability::Not`.

fixes rust-lang#142077

r? @petrochenkov
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 31, 2026
…mut, r=petrochenkov

dont fire `unused_mut` on `&pin mut self`

`SelfKind::Pinned` in `Param::from_self` was setting the binding mutability to `mutbl`, so `&pin mut self` produced a mutable binding and triggered `unused_mut` spuriously. the `mut` qualifies the pin reference, not the binding. same as `SelfKind::Region` which uses `Mutability::Not`.

fixes rust-lang#142077

r? @petrochenkov
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 718c55f 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 #160246 - Albab-Hasan:pin-ergonomics-unused-mut, r=petrochenkov

dont fire `unused_mut` on `&pin mut self`

`SelfKind::Pinned` in `Param::from_self` was setting the binding mutability to `mutbl`, so `&pin mut self` produced a mutable binding and triggered `unused_mut` spuriously. the `mut` qualifies the pin reference, not the binding. same as `SelfKind::Region` which uses `Mutability::Not`.

fixes #142077

r? @petrochenkov
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.

diagnostics: pin_ergonomics: unused_mut spans are wrong, would destroy code

3 participants