Skip to content

Take doc(alias) into account when providing typo suggestions #83968

Closed
@jyn514

Description

@jyn514

Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a5d74dbaa80fd7833c2b937fc94f58fa

fn main() {
    let x = [1, 2, 3].length();
}

The current output is:

error[E0599]: no method named `length` found for array `[{integer}; 3]` in the current scope
 --> src/main.rs:2:23
  |
2 |     let x = [1, 2, 3].length();
  |                       ^^^^^^ method not found in `[{integer}; 3]`

Ideally the output should look like:

error[E0599]: no method named `length` found for array `[{integer}; 3]` in the current scope
 --> src/main.rs:2:23
  |
2 |     let x = [1, 2, 3].length();
  |                       ^^^^^^ help: a function with an alias to `length` exists: `len`

Searching for length will already bring up len in the docs: https://doc.rust-lang.org/std/?search=length
It would be nice if the CLI errors had feature parity.

Meta

rustc --version: 1.51.0

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-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