Skip to content

Error for .toString() doesn't suggest .to_string() #101013

Closed
@scottmcm

Description

@scottmcm

Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=b273ae376e9d4fd5c5b14c61866b3d0b

fn main() {
    "hello".toString();
}

The current output is:

error[[E0599]](https://doc.rust-lang.org/nightly/error-index.html#E0599): no method named `toString` found for reference `&'static str` in the current scope
 --> src/main.rs:2:13
  |
2 |     "hello".toString();
  |             ^^^^^^^^ method not found in `&'static str`

For more information about this error, try `rustc --explain E0599`.

Ideally the output should look like:

error[E0599]: no method named `toString` found for reference `&'static str` in the current scope
 --> src/main.rs:2:13
  |
2 |     "hello".toString();
  |             ^^^^^^^^ method not found in `&'static str`
  |
  | help: did you mean `to_string`?
  |
2 |     "hello".to_string();
  |             ^^^^^^^^^

AKA it would be nice to include in-scope trait methods in the typo possibilities list, not just inherent methods.

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