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

Rollup of 7 pull requests #100974

Closed
wants to merge 148 commits into from
Closed

Conversation

JohnTitor
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

dpaoliello and others added 30 commits July 22, 2022 09:55
…ister

Enable raw-dylib for bin crates

Fixes rust-lang#93842

When `raw-dylib` is used in a `bin` crate, we need to collect all of the `raw-dylib` functions, generate the import library and add that to the linker command line.

I also changed the tests so that 1) the C   dlls are created after the Rust dlls, thus there is no chance of accidentally using them in the Rust linking process and 2) disabled generating import libraries when building with MSVC.
Rollup of 7 pull requests

Successful merges:

 - rust-lang#98211 (Implement `fs::get_path` for FreeBSD.)
 - rust-lang#99353 (Slightly improve mismatched GAT where clause error)
 - rust-lang#99593 (Suggest removing the tuple struct field for the unwrapped value)
 - rust-lang#99615 (Remove some explicit `self.infcx` for `FnCtxt`, which already derefs into `InferCtxt`)
 - rust-lang#99711 (Remove reachable coverage without counters)
 - rust-lang#99718 (Avoid `&str`/`Symbol` to `String` conversions)
 - rust-lang#99720 (Sync rustc_codegen_cranelift)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This avoids monomorphizing all linker code for each codegen backend and
will allow passing in extra information to the archive builder from the
codegen backend.
This is probably the wrong way to do this...
This avoids differences in line endings.
jyn514 and others added 17 commits August 23, 2022 21:14
 # Stabilization proposal

The feature was implemented in rust-lang#50045 by est31 and has been in nightly since 2018-05-16 (over 4 years now).
There are [no open issues][issue-label] other than the tracking issue. There is a strong consensus that `break` is the right keyword and we should not use `return`.

There have been several concerns raised about this feature on the tracking issue (other than the one about tests, which has been fixed, and an interaction with try blocks, which has been fixed).
1. nrc's original comment about cost-benefit analysis: rust-lang#48863 (comment)
2. joshtriplett's comments about seeing use cases: rust-lang#48863 (comment)
3. withoutboats's comments that Rust does not need more control flow constructs: rust-lang#48863 (comment)

Many different examples of code that's simpler using this feature have been provided:
- A lexer by rpjohnst which must repeat code without label-break-value: rust-lang#48863 (comment)
- A snippet by SergioBenitez which avoids using a new function and adding several new return points to a function: rust-lang#48863 (comment). This particular case would also work if `try` blocks were stabilized (at the cost of making the code harder to optimize).
- Several examples by JohnBSmith: rust-lang#48863 (comment)
- Several examples by Centril: rust-lang#48863 (comment)
- An example by petrochenkov where this is used in the compiler itself to avoid duplicating error checking code: rust-lang#48863 (comment)
- Amanieu recently provided another example related to complex conditions, where try blocks would not have helped: rust-lang#48863 (comment)

Additionally, petrochenkov notes that this is strictly more powerful than labelled loops due to macros which accidentally exit a loop instead of being consumed by the macro matchers: rust-lang#48863 (comment)

nrc later resolved their concern, mostly because of the aforementioned macro problems.
joshtriplett suggested that macros could be able to generate IR directly
(rust-lang#48863 (comment)) but there are no open RFCs,
and the design space seems rather speculative.

joshtriplett later resolved his concerns, due to a symmetry between this feature and existing labelled break: rust-lang#48863 (comment)

withoutboats has regrettably left the language team.

joshtriplett later posted that the lang team would consider starting an FCP given a stabilization report: rust-lang#48863 (comment)

[issue-label]: https://github.com/rust-lang/rust/issues?q=is:issue is:open label:F-label_break_value 

 ## Report

  Feature gate:
    - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/src/test/ui/feature-gates/feature-gate-label_break_value.rs
  Diagnostics:
    - https://github.com/rust-lang/rust/blob/6b2d3d5f3cd1e553d87b5496632132565b6779d3/compiler/rustc_parse/src/parser/diagnostics.rs#L2629
    - https://github.com/rust-lang/rust/blob/f65bf0b2bb1a99f73095c01a118f3c37d3ee614c/compiler/rustc_resolve/src/diagnostics.rs#L749
    - https://github.com/rust-lang/rust/blob/f65bf0b2bb1a99f73095c01a118f3c37d3ee614c/compiler/rustc_resolve/src/diagnostics.rs#L1001
    - https://github.com/rust-lang/rust/blob/111df9e6eda1d752233482c1309d00d20a4bbf98/compiler/rustc_passes/src/loops.rs#L254
    - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/compiler/rustc_parse/src/parser/expr.rs#L2079
    - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/compiler/rustc_parse/src/parser/expr.rs#L1569
  Tests:
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_continue.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_unlabeled_break.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_illegal_uses.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/unused_labels.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/run-pass/for-loop-while/label_break_value.rs

 ## Interactions with other features

Labels follow the hygiene of local variables.

label-break-value is permitted within `try` blocks:
```rust
let _: Result<(), ()> = try {
    'foo: {
        Err(())?;
        break 'foo;
    }
};
```

label-break-value is disallowed within closures, generators, and async blocks:
```rust
'a: {
    || break 'a
    //~^ ERROR use of unreachable label `'a`
    //~| ERROR `break` inside of a closure
}
```

label-break-value is disallowed on [_BlockExpression_]; it can only occur as a [_LoopExpression_]:
```rust
fn labeled_match() {
    match false 'b: { //~ ERROR block label not supported here
        _ => {}
    }
}

macro_rules! m {
    ($b:block) => {
        'lab: $b; //~ ERROR cannot use a `block` macro fragment here
        unsafe $b; //~ ERROR cannot use a `block` macro fragment here
        |x: u8| -> () $b; //~ ERROR cannot use a `block` macro fragment here
    }
}

fn foo() {
    m!({});
}
```

[_BlockExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/block-expr.html
[_LoopExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/loop-expr.html
Support compiling codegen units in parallel
According to rust-lang#100960 (comment),
this selector is only really intended to apply to item info. However,
it's so broad that it's hard to tell when it deliberately applies vs where it
accidentally applies.
… r=petrochenkov

Stabilize `#![feature(label_break_value)]`

See the stabilization report in rust-lang#48863 (comment).
Uplift `clippy::for_loops_over_fallibles` lint into rustc

This PR, as the title suggests, uplifts [`clippy::for_loops_over_fallibles`] lint into rustc. This lint warns for code like this:
```rust
for _ in Some(1) {}
for _ in Ok::<_, ()>(1) {}
```
i.e. directly iterating over `Option` and `Result` using `for` loop.

There are a number of suggestions that this PR adds (on top of what clippy suggested):
1. If the argument (? is there a better name for that expression) of a `for` loop is a `.next()` call, then we can suggest removing it (or rather replacing with `.by_ref()` to allow iterator being used later)
   ```rust
    for _ in iter.next() {}
    // turns into
    for _ in iter.by_ref() {}
    ```
2. (otherwise) We can suggest using `while let`, this is useful for non-iterator, iterator-like things like [async] channels
   ```rust
   for _ in rx.recv() {}
   // turns into
   while let Some(_) = rx.recv() {}
   ```
3. If the argument type is `Result<impl IntoIterator, _>` and the body has a `Result<_, _>` type, we can suggest using `?`
   ```rust
   for _ in f() {}
   // turns into
   for _ in f()? {}
   ```
4. To preserve the original behavior and clear intent, we can suggest using `if let`
   ```rust
   for _ in f() {}
   // turns into
   if let Some(_) = f() {}
   ```
(P.S. `Some` and `Ok` are interchangeable depending on the type)

I still feel that the lint wording/look is somewhat off, so I'll be happy to hear suggestions (on how to improve suggestions :D)!

Resolves rust-lang#99272

[`clippy::for_loops_over_fallibles`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loops_over_fallibles
…-higher-up, r=oli-obk

let-else: break out to one scope higher for let-else

``@est31`` This PR follows up with rust-lang#99518 which is to break out to the last remainder scope. It breaks to the out-most `region_scope` of the block if the first statement is a `let-else`.
…ebank

Parser will not suggest invalid expression when use public

Fixes rust-lang#100165
…s, r=davidtwco

save_analysis: Migrate diagnostic

* Migrate the `rustc_save_analysis` crate's diagnostic to translatable diagnostic structs.

Depends on rust-lang#100694 and rust-lang#100754 for #[fatal(..)] support, then rust-lang@aa68eb4, rust-lang@f5219a3, rust-lang@7da52f6 can be removed. (I copied commits from rust-lang#100754)
… r=GuillaumeGomez

rustdoc: ayu code color selector more specific

According to rust-lang#100960 (comment), this selector is only really intended to apply to item info. However, it's so broad that it's hard to tell when it deliberately applies vs where it accidentally applies.
…bjorn3

Sync rustc_codegen_cranelift

The main highlights this time are support for parallel compilation of codegen units (by me) and improved windows support (by `@afonso360)` In addition `@afonso360` added abi-checker to cg_clif's CI. This has already catched an abi compatibility issue with AArch64. The fix has landed on Cranelift's main branch, but doesn't yet have a release. `@uweigand` also submitted a couple of PR's that will are prerequisites for supporting IBM's s390x architecture.

r? `@ghost`

`@rustbot` label  A-codegen  A-cranelift  T-compiler
@rustbot rustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Aug 24, 2022
@JohnTitor
Copy link
Member Author

@bors r p=7 rollup=never

@bors
Copy link
Contributor

bors commented Aug 24, 2022

📌 Commit 9a87fb4 has been approved by JohnTitor

It is now in the queue for this repository.

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Aug 24, 2022
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
  IMAGE: x86_64-gnu-tools
##[endgroup]
From https://github.com/rust-lang/rust
 * branch              master     -> FETCH_HEAD
Searching for toolstate changes between addacb5878b9970ebc1665768a05cb601e7aea15 and 573ea37dc0028676ffa9053dd89e9232c2bd9340
Clippy or rustfmt subtrees were updated
##[group]Run src/ci/scripts/verify-channel.sh
src/ci/scripts/verify-channel.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
---

---- compile_test stdout ----
diff of stderr:

 error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want
    |
    |
 LL |     for _v in vec.iter().next() {}
    |
    |
    = note: `-D clippy::iter-next-loop` implied by `-D warnings`
-error: aborting due to previous error
-error: aborting due to previous error
 error: for loop over an `Option`. This is more readably written as an `if let` statement
    |
    |
 LL |     for _v in vec.iter().next() {}
    |
    |
    = note: `-D for-loop-over-fallibles` implied by `-D warnings`
 help: to iterate over `vec.iter()` remove the call to `next`
    |
 LL |     for _v in vec.iter().by_ref() {}
    |                         ~~~~~~~~~
 help: consider using `if let` to clear intent
    |
 LL |     if let Some(_v) = vec.iter().next() {}
    |     ~~~~~~~~~~~~  ~~~
 error: aborting due to 2 previous errors
 
 


The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/test/ui/for_loop_unfixable.stage-id.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args for_loop_unfixable.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/clippy-driver" "tests/ui/for_loop_unfixable.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/test/ui/for_loop_unfixable.stage-id" "-A" "unused" "--emit=metadata" "-Dwarnings" "-Zui-testing" "-L" "dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps" "-L" "dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps" "--extern" "tokio=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libtokio-11c942eb60796e9d.rlib" "--extern" "quote=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libquote-021aec868151835c.rlib" "--extern" "parking_lot=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libparking_lot-04f014bd62aa87c5.rlib" "--extern" "serde=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libserde-b0e96f2e9d30bd37.rlib" "--extern" "serde_derive=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps/libserde_derive-507b29393c1a728f.so" "--extern" "regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libregex-7dc368fb32eb8aae.rlib" "--extern" "if_chain=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libif_chain-03f75cdc6d4d3afc.rlib" "--extern" "futures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libfutures-36709515b9cb16b6.rlib" "--extern" "syn=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libsyn-0c795f7a8756f15a.rlib" "--extern" "clippy_lints=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_lints-3e103f3c7cb1e342.rlib" "--extern" "clippy_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_utils-56bce9bcc023120a.rlib" "--extern" "itertools=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libitertools-cdd893c121eb00e4.rlib" "--extern" "rustc_semver=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/librustc_semver-963bbd3f89834643.rlib" "--extern" "derive_new=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps/libderive_new-71205fa4273edf27.so" "--edition=2021" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/test/ui/for_loop_unfixable.stage-id.aux"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
{"message":"you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want","code":{"code":"clippy::iter_next_loop","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loop_unfixable.rs","byte_start":362,"byte_end":379,"line_start":14,"line_end":14,"column_start":15,"column_end":32,"is_primary":true,"text":[{"text":"    for _v in vec.iter().next() {}","highlight_start":15,"highlight_end":32}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`-D clippy::iter-next-loop` implied by `-D warnings`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want\n  --> tests/ui/for_loop_unfixable.rs:14:15\n   |\nLL |     for _v in vec.iter().next() {}\n   |               ^^^^^^^^^^^^^^^^^\n   |\n   = note: `-D clippy::iter-next-loop` implied by `-D warnings`\n\n"}
{"message":"for loop over an `Option`. This is more readably written as an `if let` statement","code":{"code":"for_loop_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loop_unfixable.rs","byte_start":362,"byte_end":379,"line_start":14,"line_end":14,"column_start":15,"column_end":32,"is_primary":true,"text":[{"text":"    for _v in vec.iter().next() {}","highlight_start":15,"highlight_end":32}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`-D for-loop-over-fallibles` implied by `-D warnings`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"to iterate over `vec.iter()` remove the call to `next`","code":null,"level":"help","spans":[{"file_name":"tests/ui/for_loop_unfixable.rs","byte_start":372,"byte_end":379,"line_start":14,"line_end":14,"column_start":25,"column_end":32,"is_primary":true,"text":[{"text":"    for _v in vec.iter().next() {}","highlight_start":25,"highlight_end":32}],"label":null,"suggested_replacement":".by_ref()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null},{"message":"consider using `if let` to clear intent","code":null,"level":"help","spans":[{"file_name":"tests/ui/for_loop_unfixable.rs","byte_start":352,"byte_end":356,"line_start":14,"line_end":14,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":"    for _v in vec.iter().next() {}","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":"if let Some(","suggestion_applicability":"MaybeIncorrect","expansion":{"span":{"file_name":"tests/ui/for_loop_unfixable.rs","byte_start":352,"byte_end":382,"line_start":14,"line_end":14,"column_start":5,"column_end":35,"is_primary":false,"text":[{"text":"    for _v in vec.iter().next() {}","highlight_start":5,"highlight_end":35}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `for` loop","def_site_span":{"file_name":"tests/ui/for_loop_unfixable.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"tests/ui/for_loop_unfixable.rs","byte_start":358,"byte_end":362,"line_start":14,"line_end":14,"column_start":11,"column_end":15,"is_primary":true,"text":[{"text":"    for _v in vec.iter().next() {}","highlight_start":11,"highlight_end":15}],"label":null,"suggested_replacement":") = ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"error: for loop over an `Option`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loop_unfixable.rs:14:15\n   |\nLL |     for _v in vec.iter().next() {}\n   |               ^^^^^^^^^^^^^^^^^\n   |\n   = note: `-D for-loop-over-fallibles` implied by `-D warnings`\nhelp: to iterate over `vec.iter()` remove the call to `next`\n   |\nLL |     for _v in vec.iter().by_ref() {}\n   |                         ~~~~~~~~~\nhelp: consider using `if let` to clear intent\n   |\nLL |     if let Some(_v) = vec.iter().next() {}\n   |     ~~~~~~~~~~~~  ~~~\n\n"}

------------------------------------------

diff of stderr:
diff of stderr:

 error: for loop over `option`, which is an `Option`. This is more readably written as an `if let` statement
    |
 LL |     for x in option {
    |              ^^^^^^
    |
    |
    = note: `-D clippy::for-loops-over-fallibles` implied by `-D warnings`
    = help: consider replacing `for x in option` with `if let Some(x) = option`
 
 error: for loop over `option`, which is an `Option`. This is more readably written as an `if let` statement
    |
 LL |     for x in option.iter() {
    |              ^^^^^^
    |
    |
    = help: consider replacing `for x in option.iter()` with `if let Some(x) = option`
 
 error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement
    |
 LL |     for x in result {
    |              ^^^^^^
    |
    |
    = help: consider replacing `for x in result` with `if let Ok(x) = result`
 
 error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement
    |
 LL |     for x in result.iter_mut() {
    |              ^^^^^^
    |
    |
    = help: consider replacing `for x in result.iter_mut()` with `if let Ok(x) = result`
 
 error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement
    |
 LL |     for x in result.into_iter() {
    |              ^^^^^^
    |
    |
    = help: consider replacing `for x in result.into_iter()` with `if let Ok(x) = result`
 
 error: for loop over `option.ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement
    |
    |
 LL |     for x in option.ok_or("x not found") {
    |
    |
    = help: consider replacing `for x in option.ok_or("x not found")` with `if let Ok(x) = option.ok_or("x not found")`
 
 error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want
    |
    |
 LL |     for x in v.iter().next() {
    |
    |
    = note: `#[deny(clippy::iter_next_loop)]` on by default
 
 error: for loop over `v.iter().next().and(Some(0))`, which is an `Option`. This is more readably written as an `if let` statement
    |
    |
 LL |     for x in v.iter().next().and(Some(0)) {
    |
    |
    = help: consider replacing `for x in v.iter().next().and(Some(0))` with `if let Some(x) = v.iter().next().and(Some(0))`
 
 error: for loop over `v.iter().next().ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement
    |
    |
 LL |     for x in v.iter().next().ok_or("x not found") {
    |
    |
    = help: consider replacing `for x in v.iter().next().ok_or("x not found")` with `if let Ok(x) = v.iter().next().ok_or("x not found")`
 error: this loop never actually loops
   --> $DIR/for_loops_over_fallibles.rs:60:5
    |
    |
 LL | /     while let Some(x) = option {
 LL | |         println!("{}", x);
 LL | |         break;
 LL | |     }
    |
    |
    = note: `#[deny(clippy::never_loop)]` on by default
 error: this loop never actually loops
   --> $DIR/for_loops_over_fallibles.rs:66:5
    |
    |
 LL | /     while let Ok(x) = result {
 LL | |         println!("{}", x);
 LL | |         break;
 LL | |     }
 
-error: aborting due to 11 previous errors
-error: aborting due to 11 previous errors
 error: for loop over an `Option`. This is more readably written as an `if let` statement
    |
 LL |     for x in option {
    |              ^^^^^^
    |
    |
    = note: `-D for-loop-over-fallibles` implied by `-D warnings`
 help: to check pattern in a loop use `while let`
    |
 LL |     while let Some(x) = option {
    |     ~~~~~~~~~~~~~~~ ~~~
 help: consider using `if let` to clear intent
    |
 LL |     if let Some(x) = option {
 
 
 error: for loop over a `Result`. This is more readably written as an `if let` statement
    |
 LL |     for x in result {
    |              ^^^^^^
    |
    |
 help: to check pattern in a loop use `while let`
    |
 LL |     while let Ok(x) = result {
    |     ~~~~~~~~~~~~~ ~~~
 help: consider using `if let` to clear intent
    |
 LL |     if let Ok(x) = result {
 
 
 error: for loop over a `Result`. This is more readably written as an `if let` statement
    |
    |
 LL |     for x in option.ok_or("x not found") {
    |
    |
 help: to check pattern in a loop use `while let`
    |
 LL |     while let Ok(x) = option.ok_or("x not found") {
    |     ~~~~~~~~~~~~~ ~~~
 help: consider using `if let` to clear intent
    |
 LL |     if let Ok(x) = option.ok_or("x not found") {
 
 
 error: for loop over an `Option`. This is more readably written as an `if let` statement
    |
    |
 LL |     for x in v.iter().next() {
    |
    |
 help: to iterate over `v.iter()` remove the call to `next`
    |
 LL |     for x in v.iter().by_ref() {
    |                      ~~~~~~~~~
 help: consider using `if let` to clear intent
    |
 LL |     if let Some(x) = v.iter().next() {
 
 
 error: for loop over an `Option`. This is more readably written as an `if let` statement
    |
    |
 LL |     for x in v.iter().next().and(Some(0)) {
    |
    |
 help: to check pattern in a loop use `while let`
    |
 LL |     while let Some(x) = v.iter().next().and(Some(0)) {
    |     ~~~~~~~~~~~~~~~ ~~~
 help: consider using `if let` to clear intent
    |
 LL |     if let Some(x) = v.iter().next().and(Some(0)) {
 
 
 error: for loop over a `Result`. This is more readably written as an `if let` statement
    |
    |
 LL |     for x in v.iter().next().ok_or("x not found") {
    |
    |
 help: to check pattern in a loop use `while let`
    |
 LL |     while let Ok(x) = v.iter().next().ok_or("x not found") {
    |     ~~~~~~~~~~~~~ ~~~
 help: consider using `if let` to clear intent
    |
 LL |     if let Ok(x) = v.iter().next().ok_or("x not found") {
 
 error: aborting due to 17 previous errors
 
 
---
To only update this specific test, also pass `--test-args for_loops_over_fallibles.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/clippy-driver" "tests/ui/for_loops_over_fallibles.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/test/ui/for_loops_over_fallibles.stage-id" "-A" "unused" "--emit=metadata" "-Dwarnings" "-Zui-testing" "-L" "dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps" "-L" "dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps" "--extern" "tokio=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libtokio-11c942eb60796e9d.rlib" "--extern" "quote=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libquote-021aec868151835c.rlib" "--extern" "parking_lot=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libparking_lot-04f014bd62aa87c5.rlib" "--extern" "serde=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libserde-b0e96f2e9d30bd37.rlib" "--extern" "serde_derive=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps/libserde_derive-507b29393c1a728f.so" "--extern" "regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libregex-7dc368fb32eb8aae.rlib" "--extern" "if_chain=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libif_chain-03f75cdc6d4d3afc.rlib" "--extern" "futures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libfutures-36709515b9cb16b6.rlib" "--extern" "syn=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libsyn-0c795f7a8756f15a.rlib" "--extern" "clippy_lints=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_lints-3e103f3c7cb1e342.rlib" "--extern" "clippy_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_utils-56bce9bcc023120a.rlib" "--extern" "itertools=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libitertools-cdd893c121eb00e4.rlib" "--extern" "rustc_semver=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/librustc_semver-963bbd3f89834643.rlib" "--extern" "derive_new=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps/libderive_new-71205fa4273edf27.so" "--edition=2021" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/test/ui/for_loops_over_fallibles.stage-id.aux"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
{"message":"for loop over `option`, which is an `Option`. This is more readably written as an `if let` statement","code":{"code":"clippy::for_loops_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":223,"byte_end":229,"line_start":9,"line_end":9,"column_start":14,"column_end":20,"is_primary":true,"text":[{"text":"    for x in option {","highlight_start":14,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`-D clippy::for-loops-over-fallibles` implied by `-D warnings`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"consider replacing `for x in option` with `if let Some(x) = option`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: for loop over `option`, which is an `Option`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loops_over_fallibles.rs:9:14\n   |\nLL |     for x in option {\n   |              ^^^^^^\n   |\n   = note: `-D clippy::for-loops-over-fallibles` implied by `-D warnings`\n   = help: consider replacing `for x in option` with `if let Some(x) = option`\n\n"}
{"message":"for loop over `option`, which is an `Option`. This is more readably written as an `if let` statement","code":{"code":"clippy::for_loops_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":309,"byte_end":315,"line_start":14,"line_end":14,"column_start":14,"column_end":20,"is_primary":true,"text":[{"text":"    for x in option.iter() {","highlight_start":14,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider replacing `for x in option.iter()` with `if let Some(x) = option`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: for loop over `option`, which is an `Option`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loops_over_fallibles.rs:14:14\n   |\nLL |     for x in option.iter() {\n   |              ^^^^^^\n   |\n   = help: consider replacing `for x in option.iter()` with `if let Some(x) = option`\n\n"}
{"message":"for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement","code":{"code":"clippy::for_loops_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":401,"byte_end":407,"line_start":19,"line_end":19,"column_start":14,"column_end":20,"is_primary":true,"text":[{"text":"    for x in result {","highlight_start":14,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider replacing `for x in result` with `if let Ok(x) = result`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loops_over_fallibles.rs:19:14\n   |\nLL |     for x in result {\n   |              ^^^^^^\n   |\n   = help: consider replacing `for x in result` with `if let Ok(x) = result`\n\n"}
{"message":"for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement","code":{"code":"clippy::for_loops_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":486,"byte_end":492,"line_start":24,"line_end":24,"column_start":14,"column_end":20,"is_primary":true,"text":[{"text":"    for x in result.iter_mut() {","highlight_start":14,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider replacing `for x in result.iter_mut()` with `if let Ok(x) = result`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loops_over_fallibles.rs:24:14\n   |\nLL |     for x in result.iter_mut() {\n   |              ^^^^^^\n   |\n   = help: consider replacing `for x in result.iter_mut()` with `if let Ok(x) = result`\n\n"}
{"message":"for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement","code":{"code":"clippy::for_loops_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":582,"byte_end":588,"line_start":29,"line_end":29,"column_start":14,"column_end":20,"is_primary":true,"text":[{"text":"    for x in result.into_iter() {","highlight_start":14,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider replacing `for x in result.into_iter()` with `if let Ok(x) = result`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loops_over_fallibles.rs:29:14\n   |\nLL |     for x in result.into_iter() {\n   |              ^^^^^^\n   |\n   = help: consider replacing `for x in result.into_iter()` with `if let Ok(x) = result`\n\n"}
{"message":"for loop over `option.ok_or(\"x not found\")`, which is a `Result`. This is more readably written as an `if let` statement","code":{"code":"clippy::for_loops_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":650,"byte_end":677,"line_start":33,"line_end":33,"column_start":14,"column_end":41,"is_primary":true,"text":[{"text":"    for x in option.ok_or(\"x not found\") {","highlight_start":14,"highlight_end":41}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider replacing `for x in option.ok_or(\"x not found\")` with `if let Ok(x) = option.ok_or(\"x not found\")`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: for loop over `option.ok_or(\"x not found\")`, which is a `Result`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loops_over_fallibles.rs:33:14\n   |\nLL |     for x in option.ok_or(\"x not found\") {\n   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = help: consider replacing `for x in option.ok_or(\"x not found\")` with `if let Ok(x) = option.ok_or(\"x not found\")`\n\n"}
{"message":"you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want","code":{"code":"clippy::iter_next_loop","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":838,"byte_end":853,"line_start":39,"line_end":39,"column_start":14,"column_end":29,"is_primary":true,"text":[{"text":"    for x in v.iter().next() {","highlight_start":14,"highlight_end":29}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[deny(clippy::iter_next_loop)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want\n  --> tests/ui/for_loops_over_fallibles.rs:39:14\n   |\nLL |     for x in v.iter().next() {\n   |              ^^^^^^^^^^^^^^^\n   |\n   = note: `#[deny(clippy::iter_next_loop)]` on by default\n\n"}
{"message":"for loop over `v.iter().next().and(Some(0))`, which is an `Option`. This is more readably written as an `if let` statement","code":{"code":"clippy::for_loops_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":974,"byte_end":1002,"line_start":44,"line_end":44,"column_start":14,"column_end":42,"is_primary":true,"text":[{"text":"    for x in v.iter().next().and(Some(0)) {","highlight_start":14,"highlight_end":42}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider replacing `for x in v.iter().next().and(Some(0))` with `if let Some(x) = v.iter().next().and(Some(0))`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: for loop over `v.iter().next().and(Some(0))`, which is an `Option`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loops_over_fallibles.rs:44:14\n   |\nLL |     for x in v.iter().next().and(Some(0)) {\n   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = help: consider replacing `for x in v.iter().next().and(Some(0))` with `if let Some(x) = v.iter().next().and(Some(0))`\n\n"}
{"message":"for loop over `v.iter().next().ok_or(\"x not found\")`, which is a `Result`. This is more readably written as an `if let` statement","code":{"code":"clippy::for_loops_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":1052,"byte_end":1088,"line_start":48,"line_end":48,"column_start":14,"column_end":50,"is_primary":true,"text":[{"text":"    for x in v.iter().next().ok_or(\"x not found\") {","highlight_start":14,"highlight_end":50}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider replacing `for x in v.iter().next().ok_or(\"x not found\")` with `if let Ok(x) = v.iter().next().ok_or(\"x not found\")`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: for loop over `v.iter().next().ok_or(\"x not found\")`, which is a `Result`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loops_over_fallibles.rs:48:14\n   |\nLL |     for x in v.iter().next().ok_or(\"x not found\") {\n   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = help: consider replacing `for x in v.iter().next().ok_or(\"x not found\")` with `if let Ok(x) = v.iter().next().ok_or(\"x not found\")`\n\n"}
{"message":"this loop never actually loops","code":{"code":"clippy::never_loop","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":1288,"byte_end":1364,"line_start":60,"line_end":63,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    while let Some(x) = option {","highlight_start":5,"highlight_end":33},{"text":"        println!(\"{}\", x);","highlight_start":1,"highlight_end":27},{"text":"        break;","highlight_start":1,"highlight_end":15},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[deny(clippy::never_loop)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error: this loop never actually loops\n  --> tests/ui/for_loops_over_fallibles.rs:60:5\n   |\nLL | /     while let Some(x) = option {\nLL | |         println!(\"{}\", x);\nLL | |         break;\nLL | |     }\n   | |_____^\n   |\n   = note: `#[deny(clippy::never_loop)]` on by default\n\n"}
{"message":"this loop never actually loops","code":{"code":"clippy::never_loop","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":1413,"byte_end":1487,"line_start":66,"line_end":69,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    while let Ok(x) = result {","highlight_start":5,"highlight_end":31},{"text":"        println!(\"{}\", x);","highlight_start":1,"highlight_end":27},{"text":"        break;","highlight_start":1,"highlight_end":15},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: this loop never actually loops\n  --> tests/ui/for_loops_over_fallibles.rs:66:5\n   |\nLL | /     while let Ok(x) = result {\nLL | |         println!(\"{}\", x);\nLL | |         break;\nLL | |     }\n   | |_____^\n\n"}
{"message":"for loop over an `Option`. This is more readably written as an `if let` statement","code":{"code":"for_loop_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":223,"byte_end":229,"line_start":9,"line_end":9,"column_start":14,"column_end":20,"is_primary":true,"text":[{"text":"    for x in option {","highlight_start":14,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`-D for-loop-over-fallibles` implied by `-D warnings`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"to check pattern in a loop use `while let`","code":null,"level":"help","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":214,"byte_end":218,"line_start":9,"line_end":9,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":"    for x in option {","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":"while let Some(","suggestion_applicability":"MaybeIncorrect","expansion":{"span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":214,"byte_end":264,"line_start":9,"line_end":11,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    for x in option {","highlight_start":5,"highlight_end":22},{"text":"        println!(\"{}\", x);","highlight_start":1,"highlight_end":27},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `for` loop","def_site_span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":219,"byte_end":223,"line_start":9,"line_end":9,"column_start":10,"column_end":14,"is_primary":true,"text":[{"text":"    for x in option {","highlight_start":10,"highlight_end":14}],"label":null,"suggested_replacement":") = ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null},{"message":"consider using `if let` to clear intent","code":null,"level":"help","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":214,"byte_end":218,"line_start":9,"line_end":9,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":"    for x in option {","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":"if let Some(","suggestion_applicability":"MaybeIncorrect","expansion":{"span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":214,"byte_end":264,"line_start":9,"line_end":11,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    for x in option {","highlight_start":5,"highlight_end":22},{"text":"        println!(\"{}\", x);","highlight_start":1,"highlight_end":27},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `for` loop","def_site_span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":219,"byte_end":223,"line_start":9,"line_end":9,"column_start":10,"column_end":14,"is_primary":true,"text":[{"text":"    for x in option {","highlight_start":10,"highlight_end":14}],"label":null,"suggested_replacement":") = ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"error: for loop over an `Option`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loops_over_fallibles.rs:9:14\n   |\nLL |     for x in option {\n   |              ^^^^^^\n   |\n   = note: `-D for-loop-over-fallibles` implied by `-D warnings`\nhelp: to check pattern in a loop use `while let`\n   |\nLL |     while let Some(x) = option {\n   |     ~~~~~~~~~~~~~~~ ~~~\nhelp: consider using `if let` to clear intent\n   |\nLL |     if let Some(x) = option {\n   |     ~~~~~~~~~~~~ ~~~\n\n"}
{"message":"for loop over a `Result`. This is more readably written as an `if let` statement","code":{"code":"for_loop_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":401,"byte_end":407,"line_start":19,"line_end":19,"column_start":14,"column_end":20,"is_primary":true,"text":[{"text":"    for x in result {","highlight_start":14,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to check pattern in a loop use `while let`","code":null,"level":"help","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":392,"byte_end":396,"line_start":19,"line_end":19,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":"    for x in result {","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":"while let Ok(","suggestion_applicability":"MaybeIncorrect","expansion":{"span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":392,"byte_end":442,"line_start":19,"line_end":21,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    for x in result {","highlight_start":5,"highlight_end":22},{"text":"        println!(\"{}\", x);","highlight_start":1,"highlight_end":27},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `for` loop","def_site_span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":397,"byte_end":401,"line_start":19,"line_end":19,"column_start":10,"column_end":14,"is_primary":true,"text":[{"text":"    for x in result {","highlight_start":10,"highlight_end":14}],"label":null,"suggested_replacement":") = ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null},{"message":"consider using `if let` to clear intent","code":null,"level":"help","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":392,"byte_end":396,"line_start":19,"line_end":19,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":"    for x in result {","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":"if let Ok(","suggestion_applicability":"MaybeIncorrect","expansion":{"span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":392,"byte_end":442,"line_start":19,"line_end":21,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    for x in result {","highlight_start":5,"highlight_end":22},{"text":"        println!(\"{}\", x);","highlight_start":1,"highlight_end":27},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `for` loop","def_site_span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":397,"byte_end":401,"line_start":19,"line_end":19,"column_start":10,"column_end":14,"is_primary":true,"text":[{"text":"    for x in result {","highlight_start":10,"highlight_end":14}],"label":null,"suggested_replacement":") = ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"error: for loop over a `Result`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loops_over_fallibles.rs:19:14\n   |\nLL |     for x in result {\n   |              ^^^^^^\n   |\nhelp: to check pattern in a loop use `while let`\n   |\nLL |     while let Ok(x) = result {\n   |     ~~~~~~~~~~~~~ ~~~\nhelp: consider using `if let` to clear intent\n   |\nLL |     if let Ok(x) = result {\n   |     ~~~~~~~~~~ ~~~\n\n"}
{"message":"for loop over a `Result`. This is more readably written as an `if let` statement","code":{"code":"for_loop_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":650,"byte_end":677,"line_start":33,"line_end":33,"column_start":14,"column_end":41,"is_primary":true,"text":[{"text":"    for x in option.ok_or(\"x not found\") {","highlight_start":14,"highlight_end":41}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to check pattern in a loop use `while let`","code":null,"level":"help","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":641,"byte_end":645,"line_start":33,"line_end":33,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":"    for x in option.ok_or(\"x not found\") {","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":"while let Ok(","suggestion_applicability":"MaybeIncorrect","expansion":{"span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":641,"byte_end":712,"line_start":33,"line_end":35,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    for x in option.ok_or(\"x not found\") {","highlight_start":5,"highlight_end":43},{"text":"        println!(\"{}\", x);","highlight_start":1,"highlight_end":27},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `for` loop","def_site_span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":646,"byte_end":650,"line_start":33,"line_end":33,"column_start":10,"column_end":14,"is_primary":true,"text":[{"text":"    for x in option.ok_or(\"x not found\") {","highlight_start":10,"highlight_end":14}],"label":null,"suggested_replacement":") = ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null},{"message":"consider using `if let` to clear intent","code":null,"level":"help","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":641,"byte_end":645,"line_start":33,"line_end":33,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":"    for x in option.ok_or(\"x not found\") {","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":"if let Ok(","suggestion_applicability":"MaybeIncorrect","expansion":{"span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":641,"byte_end":712,"line_start":33,"line_end":35,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    for x in option.ok_or(\"x not found\") {","highlight_start":5,"highlight_end":43},{"text":"        println!(\"{}\", x);","highlight_start":1,"highlight_end":27},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `for` loop","def_site_span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":646,"byte_end":650,"line_start":33,"line_end":33,"column_start":10,"column_end":14,"is_primary":true,"text":[{"text":"    for x in option.ok_or(\"x not found\") {","highlight_start":10,"highlight_end":14}],"label":null,"suggested_replacement":") = ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"error: for loop over a `Result`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loops_over_fallibles.rs:33:14\n   |\nLL |     for x in option.ok_or(\"x not found\") {\n   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\nhelp: to check pattern in a loop use `while let`\n   |\nLL |     while let Ok(x) = option.ok_or(\"x not found\") {\n   |     ~~~~~~~~~~~~~ ~~~\nhelp: consider using `if let` to clear intent\n   |\nLL |     if let Ok(x) = option.ok_or(\"x not found\") {\n   |     ~~~~~~~~~~ ~~~\n\n"}
{"message":"for loop over an `Option`. This is more readably written as an `if let` statement","code":{"code":"for_loop_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":838,"byte_end":853,"line_start":39,"line_end":39,"column_start":14,"column_end":29,"is_primary":true,"text":[{"text":"    for x in v.iter().next() {","highlight_start":14,"highlight_end":29}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to iterate over `v.iter()` remove the call to `next`","code":null,"level":"help","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":846,"byte_end":853,"line_start":39,"line_end":39,"column_start":22,"column_end":29,"is_primary":true,"text":[{"text":"    for x in v.iter().next() {","highlight_start":22,"highlight_end":29}],"label":null,"suggested_replacement":".by_ref()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null},{"message":"consider using `if let` to clear intent","code":null,"level":"help","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":829,"byte_end":833,"line_start":39,"line_end":39,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":"    for x in v.iter().next() {","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":"if let Some(","suggestion_applicability":"MaybeIncorrect","expansion":{"span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":829,"byte_end":888,"line_start":39,"line_end":41,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    for x in v.iter().next() {","highlight_start":5,"highlight_end":31},{"text":"        println!(\"{}\", x);","highlight_start":1,"highlight_end":27},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `for` loop","def_site_span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":834,"byte_end":838,"line_start":39,"line_end":39,"column_start":10,"column_end":14,"is_primary":true,"text":[{"text":"    for x in v.iter().next() {","highlight_start":10,"highlight_end":14}],"label":null,"suggested_replacement":") = ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"error: for loop over an `Option`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loops_over_fallibles.rs:39:14\n   |\nLL |     for x in v.iter().next() {\n   |              ^^^^^^^^^^^^^^^\n   |\nhelp: to iterate over `v.iter()` remove the call to `next`\n   |\nLL |     for x in v.iter().by_ref() {\n   |                      ~~~~~~~~~\nhelp: consider using `if let` to clear intent\n   |\nLL |     if let Some(x) = v.iter().next() {\n   |     ~~~~~~~~~~~~ ~~~\n\n"}
{"message":"for loop over an `Option`. This is more readably written as an `if let` statement","code":{"code":"for_loop_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":974,"byte_end":1002,"line_start":44,"line_end":44,"column_start":14,"column_end":42,"is_primary":true,"text":[{"text":"    for x in v.iter().next().and(Some(0)) {","highlight_start":14,"highlight_end":42}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to check pattern in a loop use `while let`","code":null,"level":"help","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":965,"byte_end":969,"line_start":44,"line_end":44,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":"    for x in v.iter().next().and(Some(0)) {","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":"while let Some(","suggestion_applicability":"MaybeIncorrect","expansion":{"span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":965,"byte_end":1037,"line_start":44,"line_end":46,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    for x in v.iter().next().and(Some(0)) {","highlight_start":5,"highlight_end":44},{"text":"        println!(\"{}\", x);","highlight_start":1,"highlight_end":27},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `for` loop","def_site_span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":970,"byte_end":974,"line_start":44,"line_end":44,"column_start":10,"column_end":14,"is_primary":true,"text":[{"text":"    for x in v.iter().next().and(Some(0)) {","highlight_start":10,"highlight_end":14}],"label":null,"suggested_replacement":") = ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null},{"message":"consider using `if let` to clear intent","code":null,"level":"help","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":965,"byte_end":969,"line_start":44,"line_end":44,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":"    for x in v.iter().next().and(Some(0)) {","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":"if let Some(","suggestion_applicability":"MaybeIncorrect","expansion":{"span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":965,"byte_end":1037,"line_start":44,"line_end":46,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    for x in v.iter().next().and(Some(0)) {","highlight_start":5,"highlight_end":44},{"text":"        println!(\"{}\", x);","highlight_start":1,"highlight_end":27},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `for` loop","def_site_span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":970,"byte_end":974,"line_start":44,"line_end":44,"column_start":10,"column_end":14,"is_primary":true,"text":[{"text":"    for x in v.iter().next().and(Some(0)) {","highlight_start":10,"highlight_end":14}],"label":null,"suggested_replacement":") = ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"error: for loop over an `Option`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loops_over_fallibles.rs:44:14\n   |\nLL |     for x in v.iter().next().and(Some(0)) {\n   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\nhelp: to check pattern in a loop use `while let`\n   |\nLL |     while let Some(x) = v.iter().next().and(Some(0)) {\n   |     ~~~~~~~~~~~~~~~ ~~~\nhelp: consider using `if let` to clear intent\n   |\nLL |     if let Some(x) = v.iter().next().and(Some(0)) {\n   |     ~~~~~~~~~~~~ ~~~\n\n"}
{"message":"for loop over a `Result`. This is more readably written as an `if let` statement","code":{"code":"for_loop_over_fallibles","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":1052,"byte_end":1088,"line_start":48,"line_end":48,"column_start":14,"column_end":50,"is_primary":true,"text":[{"text":"    for x in v.iter().next().ok_or(\"x not found\") {","highlight_start":14,"highlight_end":50}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to check pattern in a loop use `while let`","code":null,"level":"help","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":1043,"byte_end":1047,"line_start":48,"line_end":48,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":"    for x in v.iter().next().ok_or(\"x not found\") {","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":"while let Ok(","suggestion_applicability":"MaybeIncorrect","expansion":{"span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":1043,"byte_end":1123,"line_start":48,"line_end":50,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    for x in v.iter().next().ok_or(\"x not found\") {","highlight_start":5,"highlight_end":52},{"text":"        println!(\"{}\", x);","highlight_start":1,"highlight_end":27},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `for` loop","def_site_span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":1048,"byte_end":1052,"line_start":48,"line_end":48,"column_start":10,"column_end":14,"is_primary":true,"text":[{"text":"    for x in v.iter().next().ok_or(\"x not found\") {","highlight_start":10,"highlight_end":14}],"label":null,"suggested_replacement":") = ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null},{"message":"consider using `if let` to clear intent","code":null,"level":"help","spans":[{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":1043,"byte_end":1047,"line_start":48,"line_end":48,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":"    for x in v.iter().next().ok_or(\"x not found\") {","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":"if let Ok(","suggestion_applicability":"MaybeIncorrect","expansion":{"span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":1043,"byte_end":1123,"line_start":48,"line_end":50,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    for x in v.iter().next().ok_or(\"x not found\") {","highlight_start":5,"highlight_end":52},{"text":"        println!(\"{}\", x);","highlight_start":1,"highlight_end":27},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `for` loop","def_site_span":{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":false,"text":[],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"tests/ui/for_loops_over_fallibles.rs","byte_start":1048,"byte_end":1052,"line_start":48,"line_end":48,"column_start":10,"column_end":14,"is_primary":true,"text":[{"text":"    for x in v.iter().next().ok_or(\"x not found\") {","highlight_start":10,"highlight_end":14}],"label":null,"suggested_replacement":") = ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"error: for loop over a `Result`. This is more readably written as an `if let` statement\n  --> tests/ui/for_loops_over_fallibles.rs:48:14\n   |\nLL |     for x in v.iter().next().ok_or(\"x not found\") {\n   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\nhelp: to check pattern in a loop use `while let`\n   |\nLL |     while let Ok(x) = v.iter().next().ok_or(\"x not found\") {\n   |     ~~~~~~~~~~~~~ ~~~\nhelp: consider using `if let` to clear intent\n   |\nLL |     if let Ok(x) = v.iter().next().ok_or(\"x not found\") {\n   |     ~~~~~~~~~~ ~~~\n\n"}

------------------------------------------

thread 'compile_test' panicked at 'Some tests failed', /cargo/registry/src/github.com-1ecc6299db9ec823/compiletest_rs-0.8.0/src/lib.rs:111:22

@JohnTitor JohnTitor closed this Aug 24, 2022
@JohnTitor JohnTitor deleted the rollup-htm8t45 branch August 24, 2022 23:49
@davidtwco davidtwco removed the A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic label Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.