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

panic: index out of bounds: the len is 1 but the index is 1' consts.rs:354:77 #5497

Closed
matthiaskrgr opened this issue Apr 20, 2020 · 0 comments · Fixed by #5499
Closed

panic: index out of bounds: the len is 1 but the index is 1' consts.rs:354:77 #5497

matthiaskrgr opened this issue Apr 20, 2020 · 0 comments · Fixed by #5499
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@matthiaskrgr
Copy link
Member

code from rustc src/test/ui/associated-const/issue-69020-assoc-const-arith-overflow.rs

pub fn main() {}

pub trait Foo {
    const OOB: i32;
}

impl<T: Foo> Foo for Vec<T> {
    const OOB: i32 = [1][1] + T::OOB;
    //~^ ERROR operation will panic
}
thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', src/tools/clippy/clippy_lints/src/consts.rs:354:77
stack backtrace:
   0:     0x7fcbd01c2b14 - backtrace::backtrace::libunwind::trace::h7bba70f7ded37b1a
                               at /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1:     0x7fcbd01c2b14 - backtrace::backtrace::trace_unsynchronized::hbc2a98ef03b9b628
                               at /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2:     0x7fcbd01c2b14 - std::sys_common::backtrace::_print_fmt::h53c3bbd997b3e6e1
                               at src/libstd/sys_common/backtrace.rs:78
   3:     0x7fcbd01c2b14 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3036d02651b66f16
                               at src/libstd/sys_common/backtrace.rs:59
   4:     0x7fcbd02010ec - core::fmt::write::he7ad59d56ec03526
                               at src/libcore/fmt/mod.rs:1069
   5:     0x7fcbd01b4563 - std::io::Write::write_fmt::h3420fa1775e02fea
                               at src/libstd/io/mod.rs:1504
   6:     0x7fcbd01c7b15 - std::sys_common::backtrace::_print::he2dbb58105bd7d63
                               at src/libstd/sys_common/backtrace.rs:62
   7:     0x7fcbd01c7b15 - std::sys_common::backtrace::print::h2ea64c440ed8582c
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x7fcbd01c7b15 - std::panicking::default_hook::{{closure}}::h1c2bdeaadb5ce59b
                               at src/libstd/panicking.rs:198
   9:     0x7fcbd01c7852 - std::panicking::default_hook::h24ef3f3ac24d2c0e
                               at src/libstd/panicking.rs:218
  10:     0x55b4647aba11 - clippy_driver::report_clippy_ice::hce5ad5b9f956cbc4
  11:     0x7fcbd01c8295 - std::panicking::rust_panic_with_hook::hde7d2e36d005bc1b
                               at src/libstd/panicking.rs:515
  12:     0x7fcbd01c7dab - rust_begin_unwind
                               at src/libstd/panicking.rs:419
  13:     0x7fcbd01fdd81 - core::panicking::panic_fmt::h2ec72744b1a0689c
                               at src/libcore/panicking.rs:111
  14:     0x7fcbd01fdd42 - core::panicking::panic_bounds_check::hef4d21592baf7399
                               at src/libcore/panicking.rs:69
  15:     0x55b46492ee71 - clippy_lints::consts::ConstEvalLateContext::expr::hc388c1d4fd392c84
  16:     0x55b4648a066c - clippy_lints::identity_op::check::h2e812aca765489ef
  17:     0x55b4648a0514 - <clippy_lints::identity_op::IdentityOp as rustc_lint::passes::LateLintPass>::check_expr::h5a4bcc03e98b25be
  18:     0x7fcbd23f0ce3 - <rustc_lint::late::LateLintPassObjects as rustc_lint::passes::LateLintPass>::check_expr::hd8f2520fadbc5228
  19:     0x7fcbd0a71e82 - <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_expr::hf92cd1bba4b1fc8c
  20:     0x7fcbd0a727e6 - <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_nested_body::hb2f8b6ebcefa4d7c
  21:     0x7fcbd0a74750 - rustc_hir::intravisit::Visitor::visit_nested_impl_item::haaeb666cc77c146b
  22:     0x7fcbd0a3af40 - rustc_hir::intravisit::walk_item::h2fe2c74431d7bfad
  23:     0x7fcbd0a73fa8 - rustc_hir::intravisit::Visitor::visit_nested_item::h5efe0571ee5e02ba
  24:     0x7fcbd0a3482e - rustc_hir::intravisit::walk_crate::h121a9f4db6eb3af1
  25:     0x7fcbd0a4ec4f - rustc_lint::late::late_lint_pass_crate::h3ce5c658f5bd5787
  26:     0x7fcbd0a50dd0 - rustc_session::utils::<impl rustc_session::session::Session>::time::h01e6bb092c3dd6bb
  27:     0x7fcbd0a4d054 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h259244b8d551effc
  28:     0x7fcbd0a4d840 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h8c4cd027ccb7a6fb
  29:     0x7fcbd0a51878 - rustc_session::utils::<impl rustc_session::session::Session>::time::h08f4f2bc17c9fbd6
  30:     0x7fcbd0ab6d04 - rustc_interface::passes::analysis::hba604b22f2d83c77
  31:     0x7fcbd077cb6b - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute::h96f19701d405050f
  32:     0x7fcbd08ab787 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hc272ec8a37831d13
  33:     0x7fcbd077ee5c - rustc_query_system::query::plumbing::get_query::hc2d771b6d5bde200
  34:     0x7fcbd08e18e7 - rustc_middle::ty::context::tls::enter_global::h51ccd7b8ef171497
  35:     0x7fcbd08b8bb5 - rustc_interface::interface::run_compiler_in_existing_thread_pool::hc2d2b0461abde8c3
  36:     0x7fcbd076d0dd - scoped_tls::ScopedKey<T>::set::h5b416022bdfe1862
  37:     0x7fcbd0769a64 - rustc_ast::attr::with_globals::he6d5f98a6db16af6
  38:     0x7fcbd0774f24 - std::sys_common::backtrace::__rust_begin_short_backtrace::hb4b411189be36ab3
  39:     0x7fcbd08bb6ee - core::ops::function::FnOnce::call_once{{vtable.shim}}::h10154aec77bcc0bf
  40:     0x7fcbd01a3edf - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::ha8178d8e7d3a3960
                               at /rustc/dbf8b6bf116c7bece2987ff4bd2792f008a6ee77/src/liballoc/boxed.rs:1008
  41:     0x7fcbd01d8303 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h0f8f9fd9eb599d28
                               at /rustc/dbf8b6bf116c7bece2987ff4bd2792f008a6ee77/src/liballoc/boxed.rs:1008
  42:     0x7fcbd01d8303 - std::sys::unix::thread::Thread::new::thread_start::h65556e407d591283
                               at src/libstd/sys/unix/thread.rs:87
  43:     0x7fcbd00e946f - start_thread
  44:     0x7fcbcffff3d3 - clone
  45:                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-clippy/issues/new

note: Clippy version: clippy 0.0.212 (891e1a8 2020-04-18)

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack

clippy 0.0.212 (891e1a8 2020-04-18)

@matthiaskrgr matthiaskrgr added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Apr 20, 2020
bors added a commit that referenced this issue Apr 20, 2020
fix crash on issue-69020-assoc-const-arith-overflow.rs

Fixes #5497

changelog: fix crash on rustc test issue-69020-assoc-const-arith-overflow.rs
@bors bors closed this as completed in 7221db2 Apr 21, 2020
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