Skip to content

Name similarity metric should consider ordering of name parts being swapped #145015

@meithecatte

Description

@meithecatte

Code

fn main() {
    dbg!(u16::from_bytes_le([21, 37]));
}

Current output

error[E0599]: no function or associated item named `from_bytes_le` found for type `u16` in the current scope
 --> src/main.rs:2:15
  |
2 |     dbg!(u16::from_bytes_le([21, 37]));
  |               ^^^^^^^^^^^^^ function or associated item not found in `u16`
  |
help: there is an associated function `from_be` with a similar name
  |
2 -     dbg!(u16::from_bytes_le([21, 37]));
2 +     dbg!(u16::from_be([21, 37]));
  |

Desired output

error[E0599]: no function or associated item named `from_bytes_le` found for type `u16` in the current scope
 --> src/main.rs:2:15
  |
2 |     dbg!(u16::from_bytes_le([21, 37]));
  |               ^^^^^^^^^^^^^ function or associated item not found in `u16`
  |
help: there is an associated function `from_le_bytes` with a similar name
  |
2 -     dbg!(u16::from_bytes_le([21, 37]));
2 +     dbg!(u16::from_le_bytes([21, 37]));
  |

Rationale and extra context

No response

Other cases

Rust Version

current nightly on play.rust-lang.org

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions