-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
I was debugging a Clippy lint, and added a big dbg! around the following section: https://github.com/rust-lang/rust-clippy/blob/e85b1dd6dae1429b384c63e46a61daa1c6aae134/clippy_lints/src/unnested_or_patterns.rs#L324-L334
resulting in:
&& dbg!(fps1.iter().enumerate().all(|(idx_1, fp1)| {
if idx_1 == idx {
// In the case of `k`, we merely require identical field names
// so that we will transform into `ident_k: p1_k | p2_k`.
let pos = fps2.iter().position(|fp2| eq_id(fp1.ident, fp2.ident));
pos_in_2.set(pos);
pos.is_some()
} else {
fps2.iter().any(|fp2| eq_field_pat(fp1, fp2))
}
})))Then I tried running the modified code on a test case. The case itself is not relevant to the bug I'm pretty sure, but here it is for completeness:
#![warn(clippy::unnested_or_patterns)]
#![allow(
clippy::cognitive_complexity,
clippy::match_ref_pats,
clippy::upper_case_acronyms,
clippy::needless_if,
clippy::manual_range_patterns
)]
#![allow(unreachable_patterns, irrefutable_let_patterns, unused)]
fn issue15219() {
struct Foo {
bar: i8,
}
let u = Foo { bar: 8 };
if let Foo { bar } | Foo { bar } = u {}
//~^ unnested_or_patterns
}When running the test, I got the following error:
thread '<unnamed>' panicked at ~/.cache/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ui_test-0.30.2/src/diagnostics/rustc.rs:108:88:
called `Result::unwrap()` on an `Err` value: Error("EOF while parsing an object", line: 2, column: 0)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at ~/.cache/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ui_test-0.30.2/src/status_emitter/text.rs:256:29:
0 (tests/ui/unnested3.rs: ) not finished
error: a bug in `ui_test` occurred
called `Result::unwrap()` on an `Err` value: Error("EOF while parsing an object", line: 2, column: 0)
Then I've tried to minimize the reproducer a little, and got the following results:
- this still gives the same panic:
&& dbg!(fps1.iter().enumerate().all(|(idx_1, fp1)| { if idx_1 == idx { true } else { fps2.iter().any(|fp2| eq_field_pat(fp1, fp2)) } })))
- this results in a different panic:
namely:
&& dbg!(fps1.iter().enumerate().all(|(idx_1, _fp1)| { if idx_1 == idx { true } else { false } })))
thread '<unnamed>' panicked at ~/.cache/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ui_test-0.30.2/src/diagnostics/rustc.rs:108:88: called `Result::unwrap()` on an `Err` value: Error("key must be a string", line: 1, column: 3) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread '<unnamed>' panicked at ~/.cache/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ui_test-0.30.2/src/status_emitter/text.rs:256:29: 0 (tests/ui/unnested3.rs: ) not finished error: a bug in `ui_test` occurred called `Result::unwrap()` on an `Err` value: Error("key must be a string", line: 1, column: 3) - and this works just fine:
&& dbg!(fps1.iter().enumerate().all(|(_idx_1, _fp1)| { false })))
For even more context, the seemingly unbalanced closing paren is coming from the matches! invocation that this whole dbg! thing is contained in
Metadata
Metadata
Assignees
Labels
No labels