rust-lang / rust-lang/rust-clippy

Regression in `useless_transmute` due to rustup

Open
#5,343 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug E-medium I-false-positive T-middle
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

After rust-lang/rust#69189, the following check returns true for types, where only the lifetimes differ: &'a T == &'b T

https://github.com/rust-lang/rust-clippy/blob/c036c4f4a5199a6650929b2da0c9c31e0494d57b/clippy_lints/src/transmute.rs#L303-L307

According to https://github.com/rust-lang/rust/pull/69189#issuecomment-601193980, this probably needs to be fixed by checking the lifetimes of the types with MIR borrowck.

Originally posted by @flip1995 in https://github.com/rust-lang/rust-clippy/pull/5333

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in clippy_lints/src/transmute.rs at lines 303-307, then read rust-lang/rust#69189 and its linked discussion about MIR borrowck. Investigate how to distinguish reference types whose lifetimes differ, and verify that the useless_transmute check no longer treats those types as equal.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.