Skip to content

Provide a pointer to the correct names for Boolean types #98492

Closed
@alexwlchan

Description

@alexwlchan

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

fn main() {
    let value: Boolean = true;
}

The current output is:

error[E0412]: cannot find type `Boolean` in this scope
 --> src/main.rs:2:16
  |
2 |     let value: Boolean = true;
  |                ^^^^^^^ not found in this scope

For more information about this error, try `rustc --explain E0412`.
error: could not compile `example` due to previous error

Ideally the output should look like:

error[E0412]: cannot find type `Boolean ` in this scope
    --> src/main.rs:4:16
     |
4    |       let value: Boolean = true;
     |                  ^^^^^^^ help: a type with a similar meaning exists: `bool`

I stumbled here when returning to Rust after a while writing code in non-Rust languages; I'm sure I'm not the only person who's gotten the name of Rust's boolean type wrong. It's not hard to work out the correct behaviour, but I thought it would be nice if Rust could help programmers coming from other languages.

(I don't feel strongly about this suggestion and won't mind if it's closed as WONTFIX, but I know Esteban would be sad if he knew I'd had an idea for a diagnostic improvement that I didn't tell anyone.)

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