Skip to content

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

Closed
@matthiaskrgr

Description

@matthiaskrgr

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

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