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

ICE: thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', clippy_lints/src/methods/unnecessary_literal_unwrap.rs:98:36 #11099

Closed
y21 opened this issue Jul 3, 2023 · 0 comments · Fixed by #11106
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@y21
Copy link
Member

y21 commented Jul 3, 2023

Summary

An ICE spotted in the wild: https://github.com/hash-org/hashc/actions/runs/5444774442/jobs/9903084327#step:8:132

Small reproducer:

fn main() {
  None::<i32>.unwrap_or_default();
}

Version

rustc 1.72.0-nightly (5bd28f5ea 2023-06-28)
binary: rustc
commit-hash: 5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0
commit-date: 2023-06-28
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5

Error output

Backtrace

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:     0x7fdf73925e61 - std::backtrace_rs::backtrace::libunwind::trace::h5ce8db1912fa0c1f
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
 1:     0x7fdf73925e61 - std::backtrace_rs::backtrace::trace_unsynchronized::he4bbc2b1009275a2
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
 2:     0x7fdf73925e61 - std::sys_common::backtrace::_print_fmt::h850cfb06bfa31ba4
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/std/src/sys_common/backtrace.rs:65:5
 3:     0x7fdf73925e61 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1b7c35c1f6d053d9
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/std/src/sys_common/backtrace.rs:44:22
 4:     0x7fdf7398763f - core::fmt::rt::Argument::fmt::hec2555f32021416c
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/core/src/fmt/rt.rs:138:9
 5:     0x7fdf7398763f - core::fmt::write::hd6cf2d22c3c018cc
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/core/src/fmt/mod.rs:1094:21
 6:     0x7fdf73918997 - std::io::Write::write_fmt::hedf74eca7c2ca256
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/std/src/io/mod.rs:1714:15
 7:     0x7fdf73925c75 - std::sys_common::backtrace::_print::hf4e3d9b927e4f737
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/std/src/sys_common/backtrace.rs:47:5
 8:     0x7fdf73925c75 - std::sys_common::backtrace::print::h8564480b3c5e7d68
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/std/src/sys_common/backtrace.rs:34:9
 9:     0x7fdf73928a23 - std::panicking::default_hook::{{closure}}::h18d3d1ae568fd983
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/std/src/panicking.rs:269:22
10:     0x7fdf739287b4 - std::panicking::default_hook::h94c1f863d9937cf7
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/std/src/panicking.rs:288:9
11:     0x7fdf76c9079b - <rustc_driver_impl[c923a25382e6f86e]::install_ice_hook::{closure#0} as core[5b52bdd80f2b5198]::ops::function::FnOnce<(&core[5b52bdd80f2b5198]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
12:     0x7fdf7392924e - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hed90b769a5ccdc9c
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/alloc/src/boxed.rs:2024:9
13:     0x7fdf7392924e - std::panicking::rust_panic_with_hook::ha95aefb921a95644
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/std/src/panicking.rs:709:13
14:     0x7fdf73928fd7 - std::panicking::begin_panic_handler::{{closure}}::h091d95547ecdbca1
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/std/src/panicking.rs:597:13
15:     0x7fdf73926296 - std::sys_common::backtrace::__rust_end_short_backtrace::h648bf79e56cc718c
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/std/src/sys_common/backtrace.rs:151:18
16:     0x7fdf73928d22 - rust_begin_unwind
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/std/src/panicking.rs:593:5
17:     0x7fdf73983893 - core::panicking::panic_fmt::ha9acf6905b52ba6c
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/core/src/panicking.rs:67:14
18:     0x7fdf739839f2 - core::panicking::panic_bounds_check::haae8c7ca27be81d9
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/core/src/panicking.rs:162:5
19:     0x565078a0bb78 - <clippy_utils[dc0267f2510d6c15]::diagnostics::span_lint_and_then<rustc_lint[e582040643e9114c]::context::LateContext, rustc_span[5216bc3763fa4dcf]::span_encoding::Span, clippy_lints[41dd6ee57012f9ce]::methods::unnecessary_literal_unwrap::check::{closure#1}>::{closure#0} as core[5b52bdd80f2b5198]::ops::function::FnOnce<(&mut rustc_errors[5c6030d8c3858c73]::diagnostic_builder::DiagnosticBuilder<()>,)>>::call_once::{shim:vtable#0}
20:     0x5650789fde22 - rustc_middle[a1dccb58286d3ba8]::lint::struct_lint_level::struct_lint_level_impl::<alloc[27c9fe8bf6a2e6a2]::string::String>
21:     0x5650789ef424 - rustc_middle[a1dccb58286d3ba8]::lint::struct_lint_level::<alloc[27c9fe8bf6a2e6a2]::string::String, clippy_utils[dc0267f2510d6c15]::diagnostics::span_lint_and_then<rustc_lint[e582040643e9114c]::context::LateContext, rustc_span[5216bc3763fa4dcf]::span_encoding::Span, clippy_lints[41dd6ee57012f9ce]::methods::unnecessary_literal_unwrap::check::{closure#1}>::{closure#0}>
22:     0x5650789b7f2c - <rustc_lint[e582040643e9114c]::context::LateContext as rustc_lint[e582040643e9114c]::context::LintContext>::struct_span_lint::<rustc_span[5216bc3763fa4dcf]::span_encoding::Span, alloc[27c9fe8bf6a2e6a2]::string::String, clippy_utils[dc0267f2510d6c15]::diagnostics::span_lint_and_then<rustc_lint[e582040643e9114c]::context::LateContext, rustc_span[5216bc3763fa4dcf]::span_encoding::Span, clippy_lints[41dd6ee57012f9ce]::methods::unnecessary_literal_unwrap::check::{closure#1}>::{closure#0}>
23:     0x5650787c3c29 - clippy_lints[41dd6ee57012f9ce]::methods::unnecessary_literal_unwrap::check
24:     0x5650787fad32 - <clippy_lints[41dd6ee57012f9ce]::methods::Methods>::check_methods
25:     0x5650787f89e8 - <clippy_lints[41dd6ee57012f9ce]::methods::Methods as rustc_lint[e582040643e9114c]::passes::LateLintPass>::check_expr
26:     0x7fdf770c70a6 - <rustc_lint[e582040643e9114c]::late::RuntimeCombinedLateLintPass as rustc_lint[e582040643e9114c]::passes::LateLintPass>::check_expr
27:     0x7fdf77061a96 - <rustc_lint[e582040643e9114c]::late::LateContextAndPass<rustc_lint[e582040643e9114c]::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint[e582040643e9114c]::late::LateContextAndPass<rustc_lint[e582040643e9114c]::late::RuntimeCombinedLateLintPass> as rustc_hir[655fc525311d4d25]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}>
28:     0x7fdf7706235c - <rustc_lint[e582040643e9114c]::late::LateContextAndPass<rustc_lint[e582040643e9114c]::late::RuntimeCombinedLateLintPass> as rustc_hir[655fc525311d4d25]::intravisit::Visitor>::visit_expr
29:     0x7fdf7703224b - rustc_hir[655fc525311d4d25]::intravisit::walk_block::<rustc_lint[e582040643e9114c]::late::LateContextAndPass<rustc_lint[e582040643e9114c]::late::RuntimeCombinedLateLintPass>>
30:     0x7fdf77062469 - <rustc_lint[e582040643e9114c]::late::LateContextAndPass<rustc_lint[e582040643e9114c]::late::RuntimeCombinedLateLintPass> as rustc_hir[655fc525311d4d25]::intravisit::Visitor>::visit_block
31:     0x7fdf77061aa1 - <rustc_lint[e582040643e9114c]::late::LateContextAndPass<rustc_lint[e582040643e9114c]::late::RuntimeCombinedLateLintPass>>::with_lint_attrs::<<rustc_lint[e582040643e9114c]::late::LateContextAndPass<rustc_lint[e582040643e9114c]::late::RuntimeCombinedLateLintPass> as rustc_hir[655fc525311d4d25]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}>
32:     0x7fdf7706235c - <rustc_lint[e582040643e9114c]::late::LateContextAndPass<rustc_lint[e582040643e9114c]::late::RuntimeCombinedLateLintPass> as rustc_hir[655fc525311d4d25]::intravisit::Visitor>::visit_expr
33:     0x7fdf770627b5 - <rustc_lint[e582040643e9114c]::late::LateContextAndPass<rustc_lint[e582040643e9114c]::late::RuntimeCombinedLateLintPass> as rustc_hir[655fc525311d4d25]::intravisit::Visitor>::visit_nested_body
34:     0x7fdf7706299a - <rustc_lint[e582040643e9114c]::late::LateContextAndPass<rustc_lint[e582040643e9114c]::late::RuntimeCombinedLateLintPass> as rustc_hir[655fc525311d4d25]::intravisit::Visitor>::visit_fn
35:     0x7fdf77033c23 - rustc_hir[655fc525311d4d25]::intravisit::walk_item::<rustc_lint[e582040643e9114c]::late::LateContextAndPass<rustc_lint[e582040643e9114c]::late::RuntimeCombinedLateLintPass>>
36:     0x7fdf770630ef - <rustc_lint[e582040643e9114c]::late::LateContextAndPass<rustc_lint[e582040643e9114c]::late::RuntimeCombinedLateLintPass> as rustc_hir[655fc525311d4d25]::intravisit::Visitor>::visit_nested_item
37:     0x7fdf770334a8 - rustc_hir[655fc525311d4d25]::intravisit::walk_mod::<rustc_lint[e582040643e9114c]::late::LateContextAndPass<rustc_lint[e582040643e9114c]::late::RuntimeCombinedLateLintPass>>
38:     0x7fdf760b125e - rustc_lint[e582040643e9114c]::late::late_lint_crate::<rustc_lint[e582040643e9114c]::BuiltinCombinedLateLintPass>
39:     0x7fdf760b0678 - <rustc_session[17f2309dba35d20d]::session::Session>::time::<(), rustc_lint[e582040643e9114c]::late::check_crate<rustc_lint[e582040643e9114c]::BuiltinCombinedLateLintPass, rustc_interface[f8db984e9bc2c23a]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}::{closure#0}>
40:     0x7fdf760b0513 - <rustc_session[17f2309dba35d20d]::session::Session>::time::<(), rustc_interface[f8db984e9bc2c23a]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}>
41:     0x7fdf760b00c9 - std[1b53aa499255e0c]::panicking::try::<(), core[5b52bdd80f2b5198]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[f8db984e9bc2c23a]::passes::analysis::{closure#5}::{closure#1}>>
42:     0x7fdf760af4d0 - <rustc_session[17f2309dba35d20d]::session::Session>::time::<(), rustc_interface[f8db984e9bc2c23a]::passes::analysis::{closure#5}>
43:     0x7fdf760ad157 - rustc_interface[f8db984e9bc2c23a]::passes::analysis
44:     0x7fdf76134d4a - rustc_query_impl[35d2e235666c19ba]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[35d2e235666c19ba]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a1dccb58286d3ba8]::query::erase::Erased<[u8; 1usize]>>
45:     0x7fdf76134d39 - <rustc_query_impl[35d2e235666c19ba]::query_impl::analysis::dynamic_query::{closure#2} as core[5b52bdd80f2b5198]::ops::function::FnOnce<(rustc_middle[a1dccb58286d3ba8]::ty::context::TyCtxt, ())>>::call_once
46:     0x7fdf762d9368 - rustc_query_system[fec6f493e9650b57]::query::plumbing::try_execute_query::<rustc_query_impl[35d2e235666c19ba]::DynamicConfig<rustc_query_system[fec6f493e9650b57]::query::caches::SingleCache<rustc_middle[a1dccb58286d3ba8]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[35d2e235666c19ba]::plumbing::QueryCtxt, false>
47:     0x7fdf762d9139 - rustc_query_impl[35d2e235666c19ba]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
48:     0x7fdf75e1ffc5 - <rustc_middle[a1dccb58286d3ba8]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[c923a25382e6f86e]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[5b52bdd80f2b5198]::result::Result<(), rustc_span[5216bc3763fa4dcf]::ErrorGuaranteed>>
49:     0x7fdf75e1f5f1 - <rustc_interface[f8db984e9bc2c23a]::interface::Compiler>::enter::<rustc_driver_impl[c923a25382e6f86e]::run_compiler::{closure#1}::{closure#2}, core[5b52bdd80f2b5198]::result::Result<core[5b52bdd80f2b5198]::option::Option<rustc_interface[f8db984e9bc2c23a]::queries::Linker>, rustc_span[5216bc3763fa4dcf]::ErrorGuaranteed>>
50:     0x7fdf75e16115 - rustc_span[5216bc3763fa4dcf]::set_source_map::<core[5b52bdd80f2b5198]::result::Result<(), rustc_span[5216bc3763fa4dcf]::ErrorGuaranteed>, rustc_interface[f8db984e9bc2c23a]::interface::run_compiler<core[5b52bdd80f2b5198]::result::Result<(), rustc_span[5216bc3763fa4dcf]::ErrorGuaranteed>, rustc_driver_impl[c923a25382e6f86e]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
51:     0x7fdf75e15536 - <scoped_tls[d2d50f9e0583bf74]::ScopedKey<rustc_span[5216bc3763fa4dcf]::SessionGlobals>>::set::<rustc_interface[f8db984e9bc2c23a]::interface::run_compiler<core[5b52bdd80f2b5198]::result::Result<(), rustc_span[5216bc3763fa4dcf]::ErrorGuaranteed>, rustc_driver_impl[c923a25382e6f86e]::run_compiler::{closure#1}>::{closure#0}, core[5b52bdd80f2b5198]::result::Result<(), rustc_span[5216bc3763fa4dcf]::ErrorGuaranteed>>
52:     0x7fdf75e14afc - std[1b53aa499255e0c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f8db984e9bc2c23a]::util::run_in_thread_pool_with_globals<rustc_interface[f8db984e9bc2c23a]::interface::run_compiler<core[5b52bdd80f2b5198]::result::Result<(), rustc_span[5216bc3763fa4dcf]::ErrorGuaranteed>, rustc_driver_impl[c923a25382e6f86e]::run_compiler::{closure#1}>::{closure#0}, core[5b52bdd80f2b5198]::result::Result<(), rustc_span[5216bc3763fa4dcf]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5b52bdd80f2b5198]::result::Result<(), rustc_span[5216bc3763fa4dcf]::ErrorGuaranteed>>
53:     0x7fdf764cabbe - <<std[1b53aa499255e0c]::thread::Builder>::spawn_unchecked_<rustc_interface[f8db984e9bc2c23a]::util::run_in_thread_pool_with_globals<rustc_interface[f8db984e9bc2c23a]::interface::run_compiler<core[5b52bdd80f2b5198]::result::Result<(), rustc_span[5216bc3763fa4dcf]::ErrorGuaranteed>, rustc_driver_impl[c923a25382e6f86e]::run_compiler::{closure#1}>::{closure#0}, core[5b52bdd80f2b5198]::result::Result<(), rustc_span[5216bc3763fa4dcf]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5b52bdd80f2b5198]::result::Result<(), rustc_span[5216bc3763fa4dcf]::ErrorGuaranteed>>::{closure#1} as core[5b52bdd80f2b5198]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
54:     0x7fdf739336c5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hdbc0aef15db98218
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/alloc/src/boxed.rs:2010:9
55:     0x7fdf739336c5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8ad1d8fc5d57372a
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/alloc/src/boxed.rs:2010:9
56:     0x7fdf739336c5 - std::sys::unix::thread::Thread::new::thread_start::h94617354d8b43e85
                             at /rustc/839e9a6e1210934fd24b15548b811a97c77138fc/library/std/src/sys/unix/thread.rs:108:17
57:     0x7fdf737f4609 - start_thread
58:     0x7fdf735c8133 - clone
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 (839e9a6e1 2023-07-02) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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 (839e9a6 2023-07-02)

@y21 y21 added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jul 3, 2023
@bors bors closed this as completed in fca1f9a Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant