Closed
Description
Code
code reduced from ./src/test/ui/expr/if/if-let.rs
pub fn main() {
if true {
} else if let a = 1 { //~ WARN irrefutable `if let`
}
}
Meta
rustc --version --verbose
:
rustc 1.52.0-nightly (9b471a3f5 2021-02-19)
binary: rustc
commit-hash: 9b471a3f5fe57e5c6e08acf665f2094422415a3d
commit-date: 2021-02-19
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1
Error output
rustc -Zunpretty=hir,typed ./src/test/ui/expr/if/if-let.rs
warning: irrefutable `if let` pattern
--> ./src/test/ui/expr/if/if-let.rs:3:12
|
3 | } else if let a = 1 { //~ WARN irrefutable `if let`
| ____________^
4 | | }
| |_____^
|
= note: `#[warn(irrefutable_let_patterns)]` on by default
= note: this pattern will always match, so the `if let` is useless
= help: consider replacing the `if let` with a `let`
warning: unused variable: `a`
--> ./src/test/ui/expr/if/if-let.rs:3:19
|
3 | } else if let a = 1 { //~ WARN irrefutable `if let`
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
= note: `#[warn(unused_variables)]` on by default
thread 'rustc' panicked at 'print_if saw if with weird alternative', compiler/rustc_hir_pretty/src/lib.rs:1106:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.52.0-nightly (9b471a3f5 2021-02-19) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z unpretty=hir,typed
query stack during panic:
end of query stack
warning: 2 warnings emitted
Backtrace
warning: irrefutable `if let` pattern
--> ./src/test/ui/expr/if/if-let.rs:3:12
|
3 | } else if let a = 1 { //~ WARN irrefutable `if let`
| ____________^
4 | | }
| |_____^
|
= note: `#[warn(irrefutable_let_patterns)]` on by default
= note: this pattern will always match, so the `if let` is useless
= help: consider replacing the `if let` with a `let`
warning: unused variable: `a`
--> ./src/test/ui/expr/if/if-let.rs:3:19
|
3 | } else if let a = 1 { //~ WARN irrefutable `if let`
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
= note: `#[warn(unused_variables)]` on by default
thread 'rustc' panicked at 'print_if saw if with weird alternative', compiler/rustc_hir_pretty/src/lib.rs:1106:25
stack backtrace:
0: 0x7f9ec782aab0 - std::backtrace_rs::backtrace::libunwind::trace::hb4de9797f80b7b8c
at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
1: 0x7f9ec782aab0 - std::backtrace_rs::backtrace::trace_unsynchronized::h59566d0bd20efff7
at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f9ec782aab0 - std::sys_common::backtrace::_print_fmt::hcfa5ce6be50275d4
at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/sys_common/backtrace.rs:67:5
3: 0x7f9ec782aab0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd8c307a38b9bab04
at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/sys_common/backtrace.rs:46:22
4: 0x7f9ec789be6c - core::fmt::write::h3868db8542c90941
at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/core/src/fmt/mod.rs:1092:17
5: 0x7f9ec781d992 - std::io::Write::write_fmt::hab90295d5a0f197d
at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/io/mod.rs:1568:15
6: 0x7f9ec782e9a5 - std::sys_common::backtrace::_print::h19224910b8700cf1
at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/sys_common/backtrace.rs:49:5
7: 0x7f9ec782e9a5 - std::sys_common::backtrace::print::h25dedfa68c5fb84a
at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/sys_common/backtrace.rs:36:9
8: 0x7f9ec782e9a5 - std::panicking::default_hook::{{closure}}::h12c5765653a72a42
at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/panicking.rs:208:50
9: 0x7f9ec782e453 - std::panicking::default_hook::he65cee71c4209f0c
at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/panicking.rs:225:9
10: 0x7f9ec808d08b - rustc_driver::report_ice::h56d5f6e6a9fb9d03
11: 0x7f9ec782f2a6 - std::panicking::rust_panic_with_hook::h01a674d863fe0d8a
at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/panicking.rs:595:17
12: 0x7f9ec8fa4a41 - std::panicking::begin_panic::{{closure}}::h5e9fb21077bcfadf
13: 0x7f9ec8fa4a0d - std::sys_common::backtrace::__rust_end_short_backtrace::ha2819b916bca578d
14: 0x7f9ec8f9d6c9 - std::panicking::begin_panic::hb606139d6809b89e
15: 0x7f9ecac449a2 - rustc_hir_pretty::State::print_else::h13a42ddbc0c4e458
16: 0x7f9eca06f4f7 - rustc_hir_pretty::State::print_expr::h630362f92949cd28
17: 0x7f9ecac4462e - rustc_hir_pretty::State::print_block_maybe_unclosed::hcf06e8cd6e66bb18
18: 0x7f9eca06f1b2 - rustc_hir_pretty::State::print_expr::h630362f92949cd28
19: 0x7f9ec8041cbb - <rustc_driver::pretty::TypedAnnotation as rustc_hir_pretty::PpAnn>::nested::h53a621d91a26f1b3
20: 0x7f9ecac41b5c - rustc_hir_pretty::State::print_item::hd997ca7f360e8261
21: 0x7f9ec8041cbb - <rustc_driver::pretty::TypedAnnotation as rustc_hir_pretty::PpAnn>::nested::h53a621d91a26f1b3
22: 0x7f9ec8f9b3b3 - rustc_hir_pretty::State::print_mod::hcf0cdbb827143e3c
23: 0x7f9ec8f9a79a - rustc_hir_pretty::print_crate::hd1b9ef1369b4e493
24: 0x7f9ec80455e1 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h78403d5a5d7ddadf
25: 0x7f9ec808493c - rustc_query_system::dep_graph::graph::DepGraph<K>::with_ignore::h82f9688f71c0f5b9
26: 0x7f9ec80429d8 - rustc_driver::pretty::print_after_hir_lowering::h102b65afa3784540
27: 0x7f9ec809463e - rustc_interface::passes::QueryContext::enter::he206c0d61f6fb2e9
28: 0x7f9eca3ff6d7 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::hae97633c8f5175d4
29: 0x7f9eca3f7e11 - rustc_span::with_source_map::hd16d211d24c668a9
30: 0x7f9eca3fec62 - scoped_tls::ScopedKey<T>::set::h08e96579ac07fec5
31: 0x7f9eca400448 - std::sys_common::backtrace::__rust_begin_short_backtrace::h84dc4b3263d56f8c
32: 0x7f9eca3deaba - core::ops::function::FnOnce::call_once{{vtable.shim}}::h209d27a00dc0b7e3
33: 0x7f9ec783fffa - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h321523073ee11258
at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/alloc/src/boxed.rs:1546:9
34: 0x7f9ec783fffa - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf0e85e12c83b99b3
at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/alloc/src/boxed.rs:1546:9
35: 0x7f9ec783fffa - std::sys::unix::thread::Thread::new::thread_start::hba22c7961aa0e2f8
at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/sys/unix/thread.rs:71:17
36: 0x7f9ec7745299 - start_thread
37: 0x7f9ec765a153 - clone
38: 0x0 - <unknown>
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.52.0-nightly (9b471a3f5 2021-02-19) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z unpretty=hir,typed
query stack during panic:
end of query stack
warning: 2 warnings emitted