Skip to content

Conversation

Flying-Toast
Copy link
Contributor

@Flying-Toast Flying-Toast commented May 6, 2023

The lint that suggests loop {} instead of while true {} has functionality to 'pierce' parenthesis in cases like while (true) {}. In these cases, the emitted span only went to the hi of the true itself, not spanning the entire loop condition.

Before:

warning: denote infinite loops with `loop { ... }`
 --> /tmp/foobar.rs:2:5
  |
2 |     while ((((((true)))))) {}
  |     ^^^^^^^^^^^^^^^^ help: use `loop`
  |
  = note: `#[warn(while_true)]` on by default

After:

warning: denote infinite loops with `loop { ... }`
 --> /tmp/foobar.rs:2:5
  |
2 |     while ((((((true)))))) {}
  |     ^^^^^^^^^^^^^^^^^^^^^^ help: use `loop`
  |
  = note: `#[warn(while_true)]` on by default

This is especially a problem for rustfix.

@rustbot
Copy link
Collaborator

rustbot commented May 6, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 6, 2023
The lint that suggests `loop {}` instead of `while true {}` has functionality to 'pierce' parenthesis
in cases like `while (true) {}`. In these cases, the emitted span only went to the hi of the `true`
itself, not spanning the entire loop condition.

Before:
```
warning: denote infinite loops with `loop { ... }`
 --> /tmp/foobar.rs:2:5
  |
2 |     while ((((((true)))))) {}
  |     ^^^^^^^^^^^^^^^^ help: use `loop`
  |
  = note: `#[warn(while_true)]` on by default
```

After:
```
warning: denote infinite loops with `loop { ... }`
 --> /tmp/foobar.rs:2:5
  |
2 |     while ((((((true)))))) {}
  |     ^^^^^^^^^^^^^^^^^^^^^^ help: use `loop`
  |
  = note: `#[warn(while_true)]` on by default
```
@compiler-errors
Copy link
Member

r? @compiler-errors @bors r+ rollup

@bors
Copy link
Collaborator

bors commented May 6, 2023

📌 Commit faa797e has been approved by compiler-errors

It is now in the queue for this repository.

@rustbot rustbot assigned compiler-errors and unassigned davidtwco May 6, 2023
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 6, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request May 7, 2023
Rollup of 7 pull requests

Successful merges:

 - rust-lang#105583 (Operand::extract_field: only cast llval if it's a pointer and replace bitcast w/ pointercast.)
 - rust-lang#110094 (clean up `transmute`s in `core`)
 - rust-lang#111150 (added TraitAlias to check_item() for missing_docs)
 - rust-lang#111293 (rustc --explain E0726 - grammar fixing (it's => its + add a `the` where it felt right to do so))
 - rust-lang#111300 (Emit while_true lint spanning the entire loop condition)
 - rust-lang#111301 (Remove calls to `mem::forget` and `mem::replace` in `Option::get_or_insert_with`.)
 - rust-lang#111303 (update Rust Unstable Book docs for `--extern force`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 88a0204 into rust-lang:master May 7, 2023
@rustbot rustbot added this to the 1.71.0 milestone May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants