Skip to content

Commit

Permalink
Rollup merge of #111230 - zacklukem:eq-less-to-less-eq, r=compiler-er…
Browse files Browse the repository at this point in the history
…rors

add hint for =< as <=

Adds a compiler hint for when `=<` is typed instead of `<=`

Example hint:
```rust
fn foo() {
    if 1 =< 3 {
        println!("Hello, World!");
    }
}
```
```
error: expected type, found `3`
 --> main.rs:2:13
  |
2 |     if 1 =< 3 {
  |          -- ^ expected type
  |          |
  |          help: did you mean: `<=`
```

This PR only emits the suggestion if there is no space between the `=` and `<`.  This hopefully narrows the scope of when this error is emitted, however this still allows this error to be emitted in cases such as this:
```
error: expected expression, found `;`
 --> main.rs:2:18
  |
2 |     if 1 =< [i32;; 3]>::hello() {
  |          --      ^ expected expression
  |          |
  |          help: did you mean: `<=`
```

Which could be a good reason not to merge since I haven't been able to think of any other ways of narrowing the scope of this diagnostic.

closes #111128
  • Loading branch information
matthiaskrgr authored May 6, 2023
2 parents b34f83a + 95c57e8 commit b2ea5d5
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit b2ea5d5

Please sign in to comment.