-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Description
Summary
fn match_opt_none() -> i8 {
let x = None;
match x {
Some(data) => data,
None => 42,
}
}
fn main() {}
with cargo clippy --fix
Version
rustc 1.72.0-nightly (32d81eccd 2023-07-02)
binary: rustc
commit-hash: 32d81eccd64513bacef9dfa1574543ada6b45d85
commit-date: 2023-07-02
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5
Error output
Backtrace
warning: failed to automatically apply fixes suggested by rustc to crate `g`
after fixes were automatically applied the compiler reported errors within these files:
* src/main.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
warning: function `match_opt_none` is never used
--> src/main.rs:2:4
|
2 | fn match_opt_none() -> i8 {
| ^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: 1 warning emitted
thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', src/tools/clippy/clippy_lints/src/methods/unnecessary_literal_unwrap.rs:81:36
stack backtrace:
0: 0x7f01b7d67e31 - std::backtrace_rs::backtrace::libunwind::trace::h1aa701a6f07f9bbb
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x7f01b7d67e31 - std::backtrace_rs::backtrace::trace_unsynchronized::h9ae9d6e8c5c72b62
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f01b7d67e31 - std::sys_common::backtrace::_print_fmt::hfaef5052365cf665
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/sys_common/backtrace.rs:65:5
3: 0x7f01b7d67e31 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::haeef210b4538668a
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7f01b7dc95df - core::fmt::rt::Argument::fmt::h33bbbf421d58fca4
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/core/src/fmt/rt.rs:138:9
5: 0x7f01b7dc95df - core::fmt::write::he44b856c4b45f787
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/core/src/fmt/mod.rs:1094:21
6: 0x7f01b7d5a967 - std::io::Write::write_fmt::hded42ab4301c934e
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/io/mod.rs:1714:15
7: 0x7f01b7d67c45 - std::sys_common::backtrace::_print::h12bd163b4566637e
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7f01b7d67c45 - std::sys_common::backtrace::print::h78df3905035fd00a
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7f01b7d6a9f3 - std::panicking::default_hook::{{closure}}::h588795889886bd81
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/panicking.rs:269:22
10: 0x7f01b7d6a784 - std::panicking::default_hook::h8f33142631f33dcd
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/panicking.rs:288:9
11: 0x7f01bb00da9b - <rustc_driver_impl[aedb6f0638cc4997]::install_ice_hook::{closure#0} as core[66236b962f4f8b3]::ops::function::FnOnce<(&core[66236b962f4f8b3]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
12: 0x7f01b7d6b21e - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h3d4c5f73aa534950
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/alloc/src/boxed.rs:2024:9
13: 0x7f01b7d6b21e - std::panicking::rust_panic_with_hook::hf8beb94f0fe0d1f3
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/panicking.rs:709:13
14: 0x7f01b7d6afa7 - std::panicking::begin_panic_handler::{{closure}}::hb0757d0bce9a38d8
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/panicking.rs:597:13
15: 0x7f01b7d68266 - std::sys_common::backtrace::__rust_end_short_backtrace::hd2391b102482ac32
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/sys_common/backtrace.rs:151:18
16: 0x7f01b7d6acf2 - rust_begin_unwind
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/panicking.rs:593:5
17: 0x7f01b7dc5833 - core::panicking::panic_fmt::h9c2f93dd251db167
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/core/src/panicking.rs:67:14
18: 0x7f01b7dc5992 - core::panicking::panic_bounds_check::ha549f20123d0dc40
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/core/src/panicking.rs:162:5
19: 0x56090fcda248 - <clippy_utils[963815423727865b]::diagnostics::span_lint_and_then<rustc_lint[e2531b73e1252f52]::context::LateContext, rustc_span[175a833f7d8153f1]::span_encoding::Span, clippy_lints[9f662dfa9206825f]::methods::unnecessary_literal_unwrap::check::{closure#1}>::{closure#0} as core[66236b962f4f8b3]::ops::function::FnOnce<(&mut rustc_errors[9487b0fe91249864]::diagnostic_builder::DiagnosticBuilder<()>,)>>::call_once::{shim:vtable#0}
20: 0x56090fccc3eb - rustc_middle[b999effd84d4d25b]::lint::struct_lint_level::struct_lint_level_impl::<alloc[67293afed414a74a]::string::String>
21: 0x56090fcbe1e4 - rustc_middle[b999effd84d4d25b]::lint::struct_lint_level::<alloc[67293afed414a74a]::string::String, clippy_utils[963815423727865b]::diagnostics::span_lint_and_then<rustc_lint[e2531b73e1252f52]::context::LateContext, rustc_span[175a833f7d8153f1]::span_encoding::Span, clippy_lints[9f662dfa9206825f]::methods::unnecessary_literal_unwrap::check::{closure#1}>::{closure#0}>
22: 0x56090fb3a03c - <rustc_lint[e2531b73e1252f52]::context::LateContext as rustc_lint[e2531b73e1252f52]::context::LintContext>::struct_span_lint::<rustc_span[175a833f7d8153f1]::span_encoding::Span, alloc[67293afed414a74a]::string::String, clippy_utils[963815423727865b]::diagnostics::span_lint_and_then<rustc_lint[e2531b73e1252f52]::context::LateContext, rustc_span[175a833f7d8153f1]::span_encoding::Span, clippy_lints[9f662dfa9206825f]::methods::unnecessary_literal_unwrap::check::{closure#1}>::{closure#0}>
23: 0x56090faf919c - clippy_utils[963815423727865b]::diagnostics::span_lint_and_then::<rustc_lint[e2531b73e1252f52]::context::LateContext, rustc_span[175a833f7d8153f1]::span_encoding::Span, clippy_lints[9f662dfa9206825f]::methods::unnecessary_literal_unwrap::check::{closure#1}>
24: 0x56090fde5df2 - clippy_lints[9f662dfa9206825f]::methods::unnecessary_literal_unwrap::check
25: 0x56090fc1f369 - <clippy_lints[9f662dfa9206825f]::methods::Methods>::check_methods
26: 0x56090fc1c7a4 - <clippy_lints[9f662dfa9206825f]::methods::Methods as rustc_lint[e2531b73e1252f52]::passes::LateLintPass>::check_expr
27: 0x7f01bb444e66 - <rustc_lint[e2531b73e1252f52]::early::RuntimeCombinedEarlyLintPass as rustc_lint[e2531b73e1252f52]::passes::EarlyLintPass>::check_generic_arg
28: 0x7f01bb3df6c6 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}>
29: 0x7f01bb3dff8c - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr
30: 0x7f01bb3e0099 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_block
31: 0x7f01bb3df6d1 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}>
32: 0x7f01bb3dff8c - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_expr
33: 0x7f01bb3e03e5 - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_nested_body
34: 0x7f01bb3e05ca - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_fn
35: 0x7f01bb3b0883 - rustc_hir[7da11ae52209a363]::intravisit::walk_item::<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>
36: 0x7f01bb3e0d2f - <rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass> as rustc_hir[7da11ae52209a363]::intravisit::Visitor>::visit_nested_item
37: 0x7f01bb3b0108 - rustc_hir[7da11ae52209a363]::intravisit::walk_mod::<rustc_lint[e2531b73e1252f52]::late::LateContextAndPass<rustc_lint[e2531b73e1252f52]::late::RuntimeCombinedLateLintPass>>
38: 0x7f01ba48246e - rustc_lint[e2531b73e1252f52]::late::late_lint_crate::<rustc_lint[e2531b73e1252f52]::BuiltinCombinedLateLintPass>
39: 0x7f01ba481888 - <rustc_session[7e329d50d0b7b6ab]::session::Session>::time::<(), rustc_lint[e2531b73e1252f52]::late::check_crate<rustc_lint[e2531b73e1252f52]::BuiltinCombinedLateLintPass, rustc_interface[69a9f571ec0ef69d]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}::{closure#0}>
40: 0x7f01ba481723 - <rustc_session[7e329d50d0b7b6ab]::session::Session>::time::<(), rustc_interface[69a9f571ec0ef69d]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}>
41: 0x7f01ba4812d9 - std[d57842597b9c3de2]::panicking::try::<(), core[66236b962f4f8b3]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[69a9f571ec0ef69d]::passes::analysis::{closure#5}::{closure#1}>>
42: 0x7f01ba4806e0 - <rustc_session[7e329d50d0b7b6ab]::session::Session>::time::<(), rustc_interface[69a9f571ec0ef69d]::passes::analysis::{closure#5}>
43: 0x7f01ba47e367 - rustc_interface[69a9f571ec0ef69d]::passes::analysis
44: 0x7f01ba4fc8da - rustc_query_impl[b332ceb5079bcc8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b332ceb5079bcc8]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b999effd84d4d25b]::query::erase::Erased<[u8; 1usize]>>
45: 0x7f01ba4fc8c9 - <rustc_query_impl[b332ceb5079bcc8]::query_impl::analysis::dynamic_query::{closure#2} as core[66236b962f4f8b3]::ops::function::FnOnce<(rustc_middle[b999effd84d4d25b]::ty::context::TyCtxt, ())>>::call_once
46: 0x7f01ba8041df - rustc_query_system[16e9793ec34b9d59]::query::plumbing::try_execute_query::<rustc_query_impl[b332ceb5079bcc8]::DynamicConfig<rustc_query_system[16e9793ec34b9d59]::query::caches::SingleCache<rustc_middle[b999effd84d4d25b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[b332ceb5079bcc8]::plumbing::QueryCtxt, true>
47: 0x7f01ba803d84 - rustc_query_impl[b332ceb5079bcc8]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
48: 0x7f01ba28e735 - <rustc_middle[b999effd84d4d25b]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[aedb6f0638cc4997]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>>
49: 0x7f01ba28dd61 - <rustc_interface[69a9f571ec0ef69d]::interface::Compiler>::enter::<rustc_driver_impl[aedb6f0638cc4997]::run_compiler::{closure#1}::{closure#2}, core[66236b962f4f8b3]::result::Result<core[66236b962f4f8b3]::option::Option<rustc_interface[69a9f571ec0ef69d]::queries::Linker>, rustc_span[175a833f7d8153f1]::ErrorGuaranteed>>
50: 0x7f01ba284885 - rustc_span[175a833f7d8153f1]::set_source_map::<core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>, rustc_interface[69a9f571ec0ef69d]::interface::run_compiler<core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>, rustc_driver_impl[aedb6f0638cc4997]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
51: 0x7f01ba283ca6 - <scoped_tls[6271c32cbaced029]::ScopedKey<rustc_span[175a833f7d8153f1]::SessionGlobals>>::set::<rustc_interface[69a9f571ec0ef69d]::interface::run_compiler<core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>, rustc_driver_impl[aedb6f0638cc4997]::run_compiler::{closure#1}>::{closure#0}, core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>>
52: 0x7f01ba283256 - std[d57842597b9c3de2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[69a9f571ec0ef69d]::util::run_in_thread_pool_with_globals<rustc_interface[69a9f571ec0ef69d]::interface::run_compiler<core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>, rustc_driver_impl[aedb6f0638cc4997]::run_compiler::{closure#1}>::{closure#0}, core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>>
53: 0x7f01ba89828e - <<std[d57842597b9c3de2]::thread::Builder>::spawn_unchecked_<rustc_interface[69a9f571ec0ef69d]::util::run_in_thread_pool_with_globals<rustc_interface[69a9f571ec0ef69d]::interface::run_compiler<core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>, rustc_driver_impl[aedb6f0638cc4997]::run_compiler::{closure#1}>::{closure#0}, core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[66236b962f4f8b3]::result::Result<(), rustc_span[175a833f7d8153f1]::ErrorGuaranteed>>::{closure#1} as core[66236b962f4f8b3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
54: 0x7f01b7d75695 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h224d71f7c1e19ed0
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/alloc/src/boxed.rs:2010:9
55: 0x7f01b7d75695 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9c133a1396147f3c
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/alloc/src/boxed.rs:2010:9
56: 0x7f01b7d75695 - std::sys::unix::thread::Thread::new::thread_start::hb96c84e6fd62e1f0
at /rustc/32d81eccd64513bacef9dfa1574543ada6b45d85/library/std/src/sys/unix/thread.rs:108:17
57: 0x7f01b7a2044b - <unknown>
58: 0x7f01b7aa3e40 - <unknown>
59: 0x0 - <unknown>
error: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new
note: rustc 1.72.0-nightly (32d81eccd 2023-07-02) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -C target-cpu=native
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
note: Clippy version: clippy 0.1.72 (32d81ec 2023-07-02)
Original diagnostics will follow.
warning: function `match_opt_none` is never used
--> src/main.rs:2:4
|
2 | fn match_opt_none() -> i8 {
| ^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: this pattern reimplements `Option::unwrap_or`
--> src/main.rs:4:5
|
4 | / match x {
5 | | Some(data) => data,
6 | | None => 42,
7 | | }
| |_____^ help: replace with: `x.unwrap_or(42)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or
= note: `#[warn(clippy::manual_unwrap_or)]` on by default
warning: `g` (bin "g" test) generated 2 warnings (run `cargo clippy --fix --bin "g" --tests` to apply 1 suggestion)
warning: `g` (bin "g") generated 2 warnings (2 duplicates)
Finished dev [unoptimized + debuginfo] target(s) in 0.42s
kontheocharis
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️