Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggest &str.chars() on attempt to &str.iter() #90786

Closed
matthiaskrgr opened this issue Nov 10, 2021 · 0 comments · Fixed by #90803
Closed

suggest &str.chars() on attempt to &str.iter() #90786

matthiaskrgr opened this issue Nov 10, 2021 · 0 comments · Fixed by #90803
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Given the following code:

pub fn main() {
let _ = "hello world".iter();
}

The current output is:

error[E0599]: no method named `iter` found for reference `&'static str` in the current scope
 --> src/main.rs:2:23
  |
2 | let _ = "hello world".iter();
  |                       ^^^^ method not found in `&'static str`

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

Ideally the output should look like:

maybe add a "did you mean .chars()?" suggestion and underline the .iter() or something?

@matthiaskrgr matthiaskrgr added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 10, 2021
@TaKO8Ki TaKO8Ki self-assigned this Nov 11, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this issue Nov 16, 2021
…-iter, r=estebank

Suggest `&str.chars()` on attempt to `&str.iter()`

closes rust-lang#90786
@bors bors closed this as completed in b17de50 Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants