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

Gracefully handle loop labels missing leading ' in different positions #81236

Merged
merged 9 commits into from
Jan 22, 2021

Conversation

estebank
Copy link
Contributor

Fix #81192.

  • Account for labels when suggesting loop instead of while true
  • Suggest 'a when given a only when appropriate
  • Add loop head span to hir
  • Tweak error for invalid break expr
  • Add more misspelled label tests
  • Avoid emitting redundant "unused label" lint
  • Parse loop labels missing a leading '

Each commit can be reviewed in isolation.

@rust-highfive
Copy link
Collaborator

r? @oli-obk

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 21, 2021
@rust-log-analyzer

This comment has been minimized.

compiler/rustc_resolve/src/late.rs Outdated Show resolved Hide resolved
compiler/rustc_hir/src/hir.rs Show resolved Hide resolved
src/test/ui/label/label_misspelled.rs Show resolved Hide resolved
When encountering a name `a` that isn't resolved, but a label `'a` is
found in the current ribs, only suggest `'a` if this name is the value
expression of a `break` statement.

Solve FIXME.
Point at loop head on invalid `break expr`.
Suggest removing `expr` or using label if available.
When encountering the following typo:

```rust
a: loop { break 'a; }
```

provide an appropriate suggestion.
@oli-obk
Copy link
Contributor

oli-obk commented Jan 22, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Jan 22, 2021

📌 Commit 9e82329 has been approved by oli-obk

@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 Jan 22, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 22, 2021
Rollup of 10 pull requests

Successful merges:

 - rust-lang#80573 (Deny rustc::internal lints for rustdoc and clippy)
 - rust-lang#81173 (Expand docs on Iterator::intersperse)
 - rust-lang#81194 (Stabilize std::panic::panic_any.)
 - rust-lang#81202 (Don't prefix 0x for each segments in `dbg!(Ipv6)`)
 - rust-lang#81225 (Make 'docs' nullable in rustdoc-json output)
 - rust-lang#81227 (Remove doctree::StructType)
 - rust-lang#81233 (Document why not use concat! in dbg! macro)
 - rust-lang#81236 (Gracefully handle loop labels missing leading `'` in different positions)
 - rust-lang#81241 (Turn alloc's force_expr macro into a regular macro_rules.)
 - rust-lang#81242 (Enforce statically that `MIN_NON_ZERO_CAP` is calculated at compile time)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3682a06 into rust-lang:master Jan 22, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 22, 2021
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jan 30, 2021
Gracefully handle loop labels missing leading `'` in different positions

Fix rust-lang#81192.

* Account for labels when suggesting `loop` instead of `while true`
* Suggest `'a` when given `a` only when appropriate
* Add loop head span to hir
* Tweak error for invalid `break expr`
* Add more misspelled label tests
* Avoid emitting redundant "unused label" lint
* Parse loop labels missing a leading `'`

Each commit can be reviewed in isolation.
@estebank estebank deleted the everybody-loop-now branch November 9, 2023 05:15
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Account for missing ' in break tags
6 participants