Skip to content

Suggest invalid expression when use public #100165

Closed

Description

When writing public let some = 3; it will suggest pub let some = 3; and I think nothing should be suggested before it is validated.

Note:
The statement to be suggested must be checked if it is true or not, if true it is suggested and if not it is not.

The issue from: #99903

Given the following code:

fn main() {
    public let some = 3;
}

The current output is:

   Compiling playground v0.0.1 (/playground)
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found keyword `let`
 --> src/main.rs:2:12
  |
2 |     public let some = 3;
  |            ^^^ expected one of 8 possible tokens
  |
help: write `pub` instead of `public` to make the item public
  |
2 |     pub let some = 3;
  |     ~~~

error: could not compile `playground` due to previous error

Ideally the output should look like:

   Compiling playground v0.0.1 (/playground)
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found keyword `let`
 --> src/main.rs:2:12
  |
2 |     public let some = 3;
  |            ^^^ expected one of 8 possible tokens

error: could not compile `playground` due to previous error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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