Skip to content

refactor: apply clippy::borrow_deref_ref#6916

Closed
shulaoda wants to merge 1 commit into
rust-lang:mainfrom
shulaoda:05-23-refactor_apply_clippy_borrow_deref_ref
Closed

refactor: apply clippy::borrow_deref_ref#6916
shulaoda wants to merge 1 commit into
rust-lang:mainfrom
shulaoda:05-23-refactor_apply_clippy_borrow_deref_ref

Conversation

@shulaoda
Copy link
Copy Markdown
Contributor

Summary

  • Removes redundant &*x patterns where x is already a reference type (&T, &Box<T>, &P<T>, …). Deref-then-reborrow yields the same &T, so the operators add nothing.
  • Touches src/expr.rs, src/items.rs, src/macros.rs, src/matches.rs, and src/patterns.rs — 12 sites in total.
  • Addresses clippy::borrow_deref_ref, run as a single-rule pass: cargo clippy -- -A clippy::all -W clippy::borrow_deref_ref.

Representative changes:

  • rewrite_pair(&*lhs, &*rhs, …)rewrite_pair(lhs, rhs, …)
  • rewrite_unary_prefix(context, &sp_delim, &*rhs, shape)… , rhs, shape
  • rewrite_assign_rhs(context, lhs, &*ty, …)… , ty, …
  • Some(&*block)Some(block)
  • is_short_pattern_inner(context, &*p)is_short_pattern_inner(context, p)

This is a narrower sibling of clippy::explicit_auto_derefborrow_deref_ref specifically targets the &*x no-op when x: &T, which auto-deref does not need to mediate at all.

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label May 22, 2026
@ytmimi
Copy link
Copy Markdown
Contributor

ytmimi commented May 22, 2026

Going to close until we decide on which clippy lints we want to enforce in the codebase.

@ytmimi ytmimi closed this May 22, 2026
@rustbot rustbot removed the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants