Skip to content

E0606 "hello" as bool could suggest is_empty() #106883

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

Closed
matthiaskrgr opened this issue Jan 14, 2023 · 1 comment · Fixed by #106896
Closed

E0606 "hello" as bool could suggest is_empty() #106883

matthiaskrgr opened this issue Jan 14, 2023 · 1 comment · Fixed by #106896
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

matthiaskrgr commented Jan 14, 2023

Code

fn main() {
    let v = "hello" as bool;
}

Current output

error[E0606]: casting `&'static str` as `bool` is invalid
 --> src/lib.rs:2:13
  |
2 |     let v = "hello" as bool;
  |             ^^^^^^^^^^^^^^^

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

Desired output

error[E0606]: casting `&'static str` as `bool` is invalid
 --> src/lib.rs:2:13
  |
2 |     let v = "hello" as bool;
  |             ^^^^^^^^^^^^^^^

help: to find out if a &str or String contains something or not, use: `!"hello".is_empty()`

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

Rationale and extra context

No response

Other cases

No response

Anything else?

No response

@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 Jan 14, 2023
@Ezrashaw
Copy link
Contributor

@rustbot claim

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