Note irrefutable while let in loop type errors#157033
Conversation
|
rustbot has assigned @petrochenkov. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? @Nadrieril |
|
|
|
Hi @anoshyn, thanks for your PR! The implementation looks good to me, I only have some nitpicks about the exact error message. |
|
@Nadrieril Thanks for the review. I addressed both nits in 4fe62be:
The focused UI test still passes: |
|
Nice! There's a third nit, I'm just not sure what's the right method call to make that happen. Can I let you look around first? If you don't find how we can ask on Zulip. |
|
Oh, right, I missed it. I think the missing piece is to make this a span label rather than a separate span note, so the text appears next to the underline: I’ll try replacing span_note with span_label and bless the UI output. If that doesn’t produce the intended shape, I’ll ask on Zulip. |
|
Very nice, looks good to me! @bors r+ rollup |
…hile-let-note, r=Nadrieril Note irrefutable while let in loop type errors When a while-let loop is used where a non-unit value is expected, rustc already notes that while loops evaluate to unit. For simple irrefutable while-let patterns, add an extra note explaining that the pattern always matches and the loop condition never fails. Covers binding, wildcard, and tuples made from those patterns. Fixes rust-lang#116572. Tested with: ```./x test tests/ui/coercion/coerce-loop-issue-122561.rs --bless```
…hile-let-note, r=Nadrieril Note irrefutable while let in loop type errors When a while-let loop is used where a non-unit value is expected, rustc already notes that while loops evaluate to unit. For simple irrefutable while-let patterns, add an extra note explaining that the pattern always matches and the loop condition never fails. Covers binding, wildcard, and tuples made from those patterns. Fixes rust-lang#116572. Tested with: ```./x test tests/ui/coercion/coerce-loop-issue-122561.rs --bless```
…uwer Rollup of 12 pull requests Successful merges: - #154591 (Remove `will_cache_on_disk_for_key_fn`) - #156672 (Misc improvements to coroutine transform code) - #157027 (HIR ty lowering: Move some things into submodules) - #157051 (Allow two object files for a single CGU in CompiledModule) - #157100 (Some more per owner things) - #153497 (Use `trait_object_dummy_self` more & heavily fix+update related docs) - #155638 (Fix tupled closure signature in `AsyncFn` arg mismatch diagnostic) - #156826 (style: Clarify nullary call and `()` no-break rule applies past max width) - #157004 (Remove unused functions in `value_analysis.rs`) - #157032 (Fixed more &x ->&mut x suggestions) - #157033 (Note irrefutable while let in loop type errors) - #157139 (compiler: `ops::RangeInclusive` → `range::RangeInclusive`) Failed merges: - #156875 (Correct and document semantics of `yield` terminator)
Rollup merge of #157033 - anoshyn:issue-116572-irrefutable-while-let-note, r=Nadrieril Note irrefutable while let in loop type errors When a while-let loop is used where a non-unit value is expected, rustc already notes that while loops evaluate to unit. For simple irrefutable while-let patterns, add an extra note explaining that the pattern always matches and the loop condition never fails. Covers binding, wildcard, and tuples made from those patterns. Fixes #116572. Tested with: ```./x test tests/ui/coercion/coerce-loop-issue-122561.rs --bless```
When a while-let loop is used where a non-unit value is expected, rustc already notes that while loops evaluate to unit. For simple irrefutable while-let patterns, add an extra note explaining that the pattern always matches and the loop condition never fails. Covers binding, wildcard, and tuples made from those patterns.
Fixes #116572.
Tested with:
./x test tests/ui/coercion/coerce-loop-issue-122561.rs --bless