Skip to content

Helpful suggestions for incorrect address-of mutability (2) - #162106

Open
TirushOne wants to merge 1 commit into
rust-lang:mainfrom
TirushOne:addr-mutability-suggestions
Open

Helpful suggestions for incorrect address-of mutability (2)#162106
TirushOne wants to merge 1 commit into
rust-lang:mainfrom
TirushOne:addr-mutability-suggestions

Conversation

@TirushOne

@TirushOne TirushOne commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Added suggestions for & and &raw expressions used as function arguments when the function expects a mutable address. There is now also a suggestion for providing a &raw const/mut when a reference was expected, as well suggestions when & was used but the function expected *mut.

I also did a small refactor, grouping all 'suggest mut' code into a single function called suggest_addr_mut, and removed suggest_ptr_null_mut. Its logic was moved into the new suggest_addr_mut.

The test at tests\ui\span\coerce-suggestions.rs was updated to trigger all new diagnostics and blessed accordingly.

Fixes: #159490.

This PR is mostly a clean-up of #160897, with an extra diagnostics thrown in at the suggestion of chenyukang.

r? petrochenkov

@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 1, 2026
@TirushOne TirushOne changed the title new branch, fresh git history. Helpful suggestions for incorrect address-of mutability (2) Sep 1, 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.

Suggest changing argument mutability

3 participants