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

If True is not in scope and is used, suggest the valid true #100686

Closed
Rageking8 opened this issue Aug 17, 2022 · 1 comment · Fixed by #100817
Closed

If True is not in scope and is used, suggest the valid true #100686

Rageking8 opened this issue Aug 17, 2022 · 1 comment · Fixed by #100817
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

@Rageking8
Copy link
Contributor

Rageking8 commented Aug 17, 2022

Given the following code: link

fn main() {
    let x = True;
}

The current output is:

Compiling playground v0.0.1 (/playground)
error[[E0425]](https://doc.rust-lang.org/nightly/error-index.html#E0425): cannot find value `True` in this scope
 --> src/main.rs:2:13
  |
2 |     let x = True;
  |             ^^^^ not found in this scope

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

Ideally the output should suggest something like "if this is meant to be a boolean, consider changing it to true", since True is used for other languages.

@Rageking8 Rageking8 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 Aug 17, 2022
@vincenzopalazzo
Copy link
Member

@rustbot claim

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 25, 2022
…ng_sugg, r=davidtwco

sugg: suggest the usage of boolean value when there is a typo in the keyword

Fixes rust-lang#100686

This adds a new suggestion when there is a well-known typo

With the following program

```rust
fn main() {
    let x = True;
}
```

Now we have the following suggestion

```
error[E0425]: cannot find value `True` in this scope
 --> test.rs:2:13
  |
2 |     let x = True;
  |             ^^^^ not found in this scope
  |
help: you may want to use a bool value instead
  |
2 |     let x = true;
  |             ~~~~

error: aborting due to previous error
```

Signed-off-by: Vincenzo Palazzo <[email protected]>
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 25, 2022
…ng_sugg, r=davidtwco

sugg: suggest the usage of boolean value when there is a typo in the keyword

Fixes rust-lang#100686

This adds a new suggestion when there is a well-known typo

With the following program

```rust
fn main() {
    let x = True;
}
```

Now we have the following suggestion

```
error[E0425]: cannot find value `True` in this scope
 --> test.rs:2:13
  |
2 |     let x = True;
  |             ^^^^ not found in this scope
  |
help: you may want to use a bool value instead
  |
2 |     let x = true;
  |             ~~~~

error: aborting due to previous error
```

Signed-off-by: Vincenzo Palazzo <[email protected]>
@bors bors closed this as completed in 5474460 Aug 27, 2022
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