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 with clippy on nightly #4579

Closed
magnet opened this issue Sep 25, 2019 · 8 comments · Fixed by #4590
Closed

ICE with clippy on nightly #4579

magnet opened this issue Sep 25, 2019 · 8 comments · Fixed by #4590
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@magnet
Copy link

magnet commented Sep 25, 2019

My project compiles fine on recent nightlies since July.

On nightly-2019-07-31, Clippy works fine. On the next nightly, nightly-2019-08-01 and until today (nightly-2019-09-25), Clippy triggers an ICE. Something happened between nightly-2019-07-31 and nightly-2019-08-01 that hasn't been fixed since.

Command-line:

cargo clippy --all --all-targets -- -Dwarnings -Drust-2018-idioms

(I've been trying to run cargo-bisect-rustc with a script to invoke clippy, but didn't manage, it says the start of the range has the regression -- but I'm just invoking it wrong, not sure how to do it for clippy).

Error on nightly-2019-08-01:

error: internal compiler error: src/librustc/ty/context.rs:516: node_type: no type for node `expr 5 (hir_id=HirId { owner: DefIndex(228), local_id: 255 })`

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:644:9
stack backtrace:
  0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: rustc::util::common::panic_hook
   7: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
   8: std::panicking::begin_panic
   9: rustc_errors::Handler::bug
  10: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  11: rustc::ty::context::tls::with_opt::{{closure}}
  12: rustc::ty::context::tls::with_context_opt
  13: rustc::ty::context::tls::with_opt
  14: rustc::util::bug::opt_span_bug_fmt
  15: rustc::util::bug::bug_fmt
  16: rustc::ty::context::TypeckTables::node_type::{{closure}}
  17: rustc::ty::context::TypeckTables::expr_ty
  18: clippy_lints::consts::ConstEvalLateContext::expr
  19: clippy_lints::consts::constant_simple
  20: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  21: clippy_lints::utils::hir_utils::SpanlessHash::hash_tykind
  22: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  23: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  24: clippy_lints::utils::hir_utils::SpanlessHash::hash_block
  25: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  26: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  27: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  28: clippy_lints::utils::hir_utils::SpanlessHash::hash_block
  29: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  30: <clippy_lints::copies::CopyAndPaste as rustc::lint::LateLintPass>::check_expr
  31: <rustc::lint::context::LateLintPassObjects as rustc::lint::LateLintPass>::check_expr
  32: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr
  33: rustc::hir::intravisit::walk_expr
  34: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr
  35: rustc::hir::intravisit::walk_arm
  36: rustc::hir::intravisit::walk_expr
  37: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr
  38: rustc::hir::intravisit::walk_expr
  39: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr
  40: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_nested_body
  41: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_fn
  42: rustc::hir::intravisit::walk_impl_item
  43: rustc::hir::intravisit::Visitor::visit_nested_impl_item
  44: rustc::hir::intravisit::walk_item
  45: rustc::hir::intravisit::Visitor::visit_nested_item
  46: rustc::hir::intravisit::walk_item
  47: rustc::hir::intravisit::Visitor::visit_nested_item
  48: rustc::hir::intravisit::walk_crate
  49: rustc::lint::context::late_lint_pass_crate
  50: rustc::lint::context::late_lint_crate
  51: rustc::util::common::time
  52: rustc::util::common::time
  53: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  54: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  55: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  56: rustc_interface::passes::analysis::{{closure}}
  57: rustc::util::common::time
  58: rustc_interface::passes::analysis
  59: rustc::ty::query::__query_compute::analysis
  60: rustc::dep_graph::graph::DepGraph::with_task_impl
  61: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  62: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  63: rustc_interface::passes::create_global_ctxt::{{closure}}
  64: rustc_interface::interface::run_compiler_in_existing_thread_pool
  65: std::thread::local::LocalKey<T>::with
  66: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error


note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.38.0-nightly (8a58268b5 2019-07-31) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `mysql_common`.

Error on nightly-2019-09-25 (double panic!):

error: internal compiler error: src/librustc/ty/context.rs:513: node_type: no type for node `expr 5 (hir_id=HirId { owner: DefIndex(228), local_id: 255 })`

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:812:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:76
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:60
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1030
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:64
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:196
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:210
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:477
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_context_opt
  18: rustc::ty::context::tls::with_opt
  19: rustc::util::bug::opt_span_bug_fmt
  20: rustc::util::bug::bug_fmt
  21: rustc::ty::context::TypeckTables::node_type::{{closure}}
  22: rustc::ty::context::TypeckTables::expr_ty
  23: clippy_lints::consts::ConstEvalLateContext::expr
  24: clippy_lints::consts::constant_simple
  25: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  26: clippy_lints::utils::hir_utils::SpanlessHash::hash_tykind
  27: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  28: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  29: clippy_lints::utils::hir_utils::SpanlessHash::hash_block
  30: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  31: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  32: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  33: clippy_lints::utils::hir_utils::SpanlessHash::hash_block
  34: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  35: <clippy_lints::copies::CopyAndPaste as rustc::lint::LateLintPass>::check_expr
  36: <rustc::lint::context::LateLintPassObjects as rustc::lint::LateLintPass>::check_expr
  37: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr
  38: rustc::hir::intravisit::walk_expr
  39: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr
  40: rustc::hir::intravisit::walk_arm
  41: rustc::hir::intravisit::walk_expr
  42: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr
  43: rustc::hir::intravisit::walk_expr
  44: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr
  45: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_nested_body
  46: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_fn
  47: rustc::hir::intravisit::walk_impl_item
  48: rustc::hir::intravisit::Visitor::visit_nested_impl_item
  49: rustc::hir::intravisit::walk_item
  50: rustc::hir::intravisit::Visitor::visit_nested_item
  51: rustc::hir::intravisit::walk_item
  52: rustc::hir::intravisit::Visitor::visit_nested_item
  53: rustc::hir::intravisit::walk_crate
  54: rustc::lint::context::late_lint_pass_crate
  55: rustc::lint::context::late_lint_crate
  56: rustc::util::common::time
  57: rustc::util::common::time
  58: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  59: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  60: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  61: rustc_interface::passes::analysis::{{closure}}
  62: rustc::util::common::time
  63: rustc_interface::passes::analysis
  64: rustc::ty::query::__query_compute::analysis
  65: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  66: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  67: rustc_interface::passes::create_global_ctxt::{{closure}}
  68: rustc_interface::interface::run_compiler_in_existing_thread_pool
  69: std::thread::local::LocalKey<T>::with
  70: scoped_tls::ScopedKey<T>::set
  71: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.39.0-nightly (6ef275e6c 2019-09-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
thread 'rustc' panicked at 'already borrowed: BorrowMutError', src/libcore/result.rs:1165:5
stack backtrace:
   0:     0x7fcff3992ae4 - backtrace::backtrace::libunwind::trace::hc496b60554206774
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
   1:     0x7fcff3992ae4 - backtrace::backtrace::trace_unsynchronized::ha20a82d0af0c65c5
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
   2:     0x7fcff3992ae4 - std::sys_common::backtrace::_print_fmt::h41aff515dcee7039
                               at src/libstd/sys_common/backtrace.rs:76
   3:     0x7fcff3992ae4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9cece4375f2f7fda
                               at src/libstd/sys_common/backtrace.rs:60
   4:     0x7fcff39cb12c - core::fmt::write::hecb5092b1fa0aafc
                               at src/libcore/fmt/mod.rs:1030
   5:     0x7fcff3986d07 - std::io::Write::write_fmt::h3a49fae144e74a2a
                               at src/libstd/io/mod.rs:1412
   6:     0x7fcff3997315 - std::sys_common::backtrace::_print::h24134367c784cf37
                               at src/libstd/sys_common/backtrace.rs:64
   7:     0x7fcff3997315 - std::sys_common::backtrace::print::ha95f6cb55d52824a
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x7fcff3997315 - std::panicking::default_hook::{{closure}}::hf48b3987cc8265dd
                               at src/libstd/panicking.rs:196
   9:     0x7fcff3997006 - std::panicking::default_hook::h6d285b42ab8557a8
                               at src/libstd/panicking.rs:210
  10:     0x7fcff3eccf83 - rustc_driver::report_ice::h45cf923dd58ab6c9
  11:     0x7fcff3997afc - std::panicking::rust_panic_with_hook::h694c05b962beffa6
                               at src/libstd/panicking.rs:477
  12:     0x7fcff39975b2 - std::panicking::continue_panic_fmt::h6d9edb7f6134fa29
                               at src/libstd/panicking.rs:380
  13:     0x7fcff39974a6 - rust_begin_unwind
                               at src/libstd/panicking.rs:307
  14:     0x7fcff39c4aba - core::panicking::panic_fmt::h06aa024bca353ba1
                               at src/libcore/panicking.rs:85
  15:     0x7fcff39c4cf7 - core::result::unwrap_failed::hef0e5f380db2d8ff
                               at src/libcore/result.rs:1165
  16:     0x7fcff5ca1e05 - rustc_errors::Handler::force_print_diagnostic::h7bc5ce1adc02a5e1
  17:     0x7fcff5580061 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::try_print_query_stack::h1f63bbe074ec7299
  18:     0x7fcff3ecdb95 - rustc_driver::report_ice::h45cf923dd58ab6c9
  19:     0x7fcff3997afc - std::panicking::rust_panic_with_hook::h694c05b962beffa6
                               at src/libstd/panicking.rs:477
  20:     0x7fcff5c891fd - std::panicking::begin_panic::h46d3b006bb005b25
  21:     0x7fcff5ca2563 - rustc_errors::HandlerInner::bug::hcc4f7785c0bbe624
  22:     0x7fcff5ca144a - rustc_errors::Handler::bug::hab74f2c21f11224d
  23:     0x7fcff553e6b3 - rustc::util::bug::opt_span_bug_fmt::{{closure}}::h6fc69d466ad28204
  24:     0x7fcff553e183 - rustc::ty::context::tls::with_opt::{{closure}}::hfca6eae075a58800
  25:     0x7fcff553de53 - rustc::ty::context::tls::with_context_opt::hb524b2b02be1c26b
  26:     0x7fcff553de97 - rustc::ty::context::tls::with_opt::hd739a53bdacc1686
  27:     0x7fcff553e5c8 - rustc::util::bug::opt_span_bug_fmt::h7313400faf0ca111
  28:     0x7fcff553e532 - rustc::util::bug::bug_fmt::hd38ca659e7f5fbf2
  29:     0x7fcff57332ed - rustc::ty::context::TypeckTables::node_type::{{closure}}::h45cfcdea8892a145
  30:     0x7fcff57338de - rustc::ty::context::TypeckTables::expr_ty::hdbc326f824822726
  31:     0x5570daf855f0 - clippy_lints::consts::ConstEvalLateContext::expr::h476dcfba85a16648
  32:     0x5570daf8539f - clippy_lints::consts::constant_simple::h0033a46e094c8fa8
  33:     0x5570db027c98 - clippy_lints::utils::hir_utils::SpanlessHash::hash_expr::hb3a00a2e46413865
  34:     0x5570db028564 - clippy_lints::utils::hir_utils::SpanlessHash::hash_tykind::h9314f4421e877319
  35:     0x5570db027d5a - clippy_lints::utils::hir_utils::SpanlessHash::hash_expr::hb3a00a2e46413865
  36:     0x5570db027dcc - clippy_lints::utils::hir_utils::SpanlessHash::hash_expr::hb3a00a2e46413865
  37:     0x5570db027c3a - clippy_lints::utils::hir_utils::SpanlessHash::hash_block::hd6d05f29f61dffea
  38:     0x5570db028011 - clippy_lints::utils::hir_utils::SpanlessHash::hash_expr::hb3a00a2e46413865
  39:     0x5570db027dcc - clippy_lints::utils::hir_utils::SpanlessHash::hash_expr::hb3a00a2e46413865
  40:     0x5570db027dcc - clippy_lints::utils::hir_utils::SpanlessHash::hash_expr::hb3a00a2e46413865
  41:     0x5570db027c3a - clippy_lints::utils::hir_utils::SpanlessHash::hash_block::hd6d05f29f61dffea
  42:     0x5570db028011 - clippy_lints::utils::hir_utils::SpanlessHash::hash_expr::hb3a00a2e46413865
  43:     0x5570daf8d624 - <clippy_lints::copies::CopyAndPaste as rustc::lint::LateLintPass>::check_expr::hafdaa2e6d85823f9
  44:     0x7fcff5349973 - <rustc::lint::context::LateLintPassObjects as rustc::lint::LateLintPass>::check_expr::h92fc9b6d5ac04045
  45:     0x7fcff4022b01 - <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr::h12cebf9c1cf2cad7
  46:     0x7fcff3fb69fe - rustc::hir::intravisit::walk_expr::h22863d0f325bad4d
  47:     0x7fcff4022b0c - <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr::h12cebf9c1cf2cad7
  48:     0x7fcff3fb5ec9 - rustc::hir::intravisit::walk_arm::h4dcd337addea4e6e
  49:     0x7fcff3fb6bab - rustc::hir::intravisit::walk_expr::h22863d0f325bad4d
  50:     0x7fcff4022b0c - <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr::h12cebf9c1cf2cad7
  51:     0x7fcff3fb69fe - rustc::hir::intravisit::walk_expr::h22863d0f325bad4d
  52:     0x7fcff4022b0c - <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr::h12cebf9c1cf2cad7
  53:     0x7fcff40235b4 - <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_nested_body::h30c84ae9e6e13e52
  54:     0x7fcff4023d78 - <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_fn::h111fb9e2942ab5ff
  55:     0x7fcff3fb2296 - rustc::hir::intravisit::walk_impl_item::h5fae9c15ba497e5b
  56:     0x7fcff4032910 - rustc::hir::intravisit::Visitor::visit_nested_impl_item::h478ffa9961652ae8
  57:     0x7fcff3fb802c - rustc::hir::intravisit::walk_item::h95848141061b61dd
  58:     0x7fcff4032221 - rustc::hir::intravisit::Visitor::visit_nested_item::hea2c814b2f7155c8
  59:     0x7fcff3fb784d - rustc::hir::intravisit::walk_item::h95848141061b61dd
  60:     0x7fcff4032221 - rustc::hir::intravisit::Visitor::visit_nested_item::hea2c814b2f7155c8
  61:     0x7fcff3fb125e - rustc::hir::intravisit::walk_crate::he664d7e3ca6f8268
  62:     0x7fcff4036617 - rustc::lint::context::late_lint_pass_crate::h12558ee0f7c1b24a
  63:     0x7fcff4035b5e - rustc::lint::context::late_lint_crate::h649fac40252f6658
  64:     0x7fcff3fb9853 - rustc::util::common::time::h19fe295c62a0d841
  65:     0x7fcff3fbacdb - rustc::util::common::time::h78af02ba11ad31c0
  66:     0x7fcff39a824a - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:80
  67:     0x7fcff3f3e4d3 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h6e79df7223bdcbe5
  68:     0x7fcff39a824a - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:80
  69:     0x7fcff3fc1e52 - rustc_interface::passes::analysis::{{closure}}::hf11984d88e167908
  70:     0x7fcff3fba230 - rustc::util::common::time::h445708af66271f8e
  71:     0x7fcff3f7c584 - rustc_interface::passes::analysis::h8a47af605888fc80
  72:     0x7fcff3e65851 - rustc::ty::query::__query_compute::analysis::hb9ae680a51f13bb9
  73:     0x7fcff3e7517e - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h751f86f55fa3f327
  74:     0x7fcff3e9840a - rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}::h24275668f616227f
  75:     0x7fcff3ff8aaa - rustc_interface::passes::create_global_ctxt::{{closure}}::h279ea41337b1550b
  76:     0x7fcff3e9a6be - rustc_interface::interface::run_compiler_in_existing_thread_pool::h8f7b1ed446f84b95
  77:     0x7fcff3ecece2 - std::thread::local::LocalKey<T>::with::h307a7a354e416993
  78:     0x7fcff3ed48ae - scoped_tls::ScopedKey<T>::set::h2f6a18a3def76ab5
  79:     0x7fcff3ef50a2 - syntax::with_globals::h1fcbc798c727ae20
  80:     0x7fcff3e8a310 - std::sys_common::backtrace::__rust_begin_short_backtrace::h1a2ca6bd7bcfc1d4
  81:     0x7fcff39a824a - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:80
  82:     0x7fcff3e8b939 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h560e3eeff12b2618
  83:     0x7fcff39791ef - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hbf2f21e18d2cee36
                               at /rustc/6ef275e6c3cb1384ec78128eceeb4963ff788dca/src/liballoc/boxed.rs:922
  84:     0x7fcff39a6ef0 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h680214b55e06abc5
                               at /rustc/6ef275e6c3cb1384ec78128eceeb4963ff788dca/src/liballoc/boxed.rs:922
  85:     0x7fcff39a6ef0 - std::sys_common::thread::start_thread::ha3ffac07979d9757
                               at src/libstd/sys_common/thread.rs:13
  86:     0x7fcff39a6ef0 - std::sys::unix::thread::Thread::new::thread_start::hbce32216c8c0810e
                               at src/libstd/sys/unix/thread.rs:79
  87:     0x7fcff38f6164 - start_thread
  88:     0x7fcff3804def - __clone
  89:                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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.39.0-nightly (6ef275e6c 2019-09-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
thread panicked while processing panic. aborting.
error: could not compile `mysql_common`.
@phansch phansch added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Sep 26, 2019
@phansch
Copy link
Member

phansch commented Sep 26, 2019

Thanks for the report!

Are you able to share the code that triggers the ICE? That would help a lot with fixing the issue. If not, are you able to maybe provide a trimmed down version of the code that causes the ICE?

@flip1995
Copy link
Member

PRs that were merged between nightly-2019-07-31 and nightly-2019-08-01:
#4306 #3766

Since #4306 is a rustup this ICE is probably caused by #3766.

@flip1995
Copy link
Member

flip1995 commented Sep 26, 2019

Clippy panics at this line:

ExprKind::Lit(ref lit) => Some(lit_to_constant(&lit.node, self.tables.expr_ty(e))),

because expr_ty panics. This results from this call to this hash closure:

match map.entry(hash(expr)) {

@flip1995
Copy link
Member

This ICE can be reproduced with the https://github.com/blackbeam/rust_mysql_common crate

@magnet
Copy link
Author

magnet commented Sep 26, 2019

I couldn't repro directly by running clippy on mysql_common, but this code does it (there are likely simpler ways to reproduce, but this is my code trimmed down; the main fn doesn't cause the ICE, I just had it in to remove warnings):

#![feature(async_await)]

use futures::executor::ThreadPool;
use mysql_async::{error::Error, Conn};
use std::future::Future;

pub struct ClippyIce;

impl ClippyIce {
    async fn boom<R, Ft, F>(&mut self, _: F) -> Result<R, Error>
    where
        Ft: Future<Output = Result<(Conn, R), Error>>,
        F: FnOnce(Conn) -> Ft,
    {
        unimplemented!()
    }
}

fn main() {
    ThreadPool::new()
        .expect("Failed to create threadpool")
        .run(ClippyIce.boom::<(), _, _>(|_| async { unimplemented!() }))
        .unwrap();
}
[dependencies]
mysql_async = "0.20"
futures-preview = "0.3.0-alpha.17"

This builds fine with cargo check/build, but Clippy will crash on 2019-08-01 and pass on 2019-07-31.

@sylvain101010
Copy link

other data points to help:

Compiler panics when compiling mysql_common 0.18.0.

I tried to lint a project which have mysql_common as dependency using cargo clippy but I got the following error:

error: internal compiler error: src/librustc/ty/context.rs:516: node_type: no type for node `expr 5 (hir_id=HirId { owner: DefIndex(228), local_id: 255 })`

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:644:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: aborting due to previous error


note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.38.0-nightly (8a58268b5 2019-07-31) running on x86_64-apple-darwin

note: compiler flags: -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `mysql_common`

with RUST_BACKTRACE=1

error: internal compiler error: src/librustc/ty/context.rs:515: node_type: no type for node `expr 5 (hir_id=HirId { owner: DefIndex(228), local_id: 255 })`

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:643:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1030
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:214
  10: rustc::util::common::panic_hook
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
  12: std::panicking::begin_panic
  13: rustc_errors::Handler::bug
  14: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  15: rustc::ty::context::tls::with_opt::{{closure}}
  16: rustc::ty::context::tls::with_context_opt
  17: rustc::ty::context::tls::with_opt
  18: rustc::util::bug::opt_span_bug_fmt
  19: rustc::util::bug::bug_fmt
  20: rustc::ty::context::TypeckTables::node_type::{{closure}}
  21: rustc::ty::context::TypeckTables::expr_ty
  22: clippy_lints::consts::ConstEvalLateContext::expr
  23: clippy_lints::consts::constant_simple
  24: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  25: clippy_lints::utils::hir_utils::SpanlessHash::hash_tykind
  26: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  27: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  28: clippy_lints::utils::hir_utils::SpanlessHash::hash_block
  29: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  30: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  31: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  32: clippy_lints::utils::hir_utils::SpanlessHash::hash_block
  33: clippy_lints::utils::hir_utils::SpanlessHash::hash_expr
  34: <clippy_lints::copies::CopyAndPaste as rustc::lint::LateLintPass>::check_expr
  35: <rustc::lint::context::LateLintPassObjects as rustc::lint::LateLintPass>::check_expr
  36: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr
  37: rustc::hir::intravisit::walk_expr
  38: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr
  39: rustc::hir::intravisit::walk_arm
  40: rustc::hir::intravisit::walk_expr
  41: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr
  42: rustc::hir::intravisit::walk_expr
  43: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_expr
  44: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_nested_body
  45: <rustc::lint::context::LateContextAndPass<T> as rustc::hir::intravisit::Visitor>::visit_fn
  46: rustc::hir::intravisit::walk_impl_item
  47: rustc::hir::intravisit::Visitor::visit_nested_impl_item
  48: rustc::hir::intravisit::walk_item
  49: rustc::hir::intravisit::Visitor::visit_nested_item
  50: rustc::hir::intravisit::walk_item
  51: rustc::hir::intravisit::Visitor::visit_nested_item
  52: rustc::hir::intravisit::walk_crate
  53: rustc::lint::context::late_lint_pass_crate
  54: rustc::lint::context::late_lint_crate
  55: rustc::util::common::time
  56: rustc::util::common::time
  57: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  58: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  59: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  60: rustc_interface::passes::analysis::{{closure}}
  61: rustc::util::common::time
  62: rustc_interface::passes::analysis
  63: rustc::ty::query::__query_compute::analysis
  64: rustc::dep_graph::graph::DepGraph::with_task_impl
  65: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  66: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  67: rustc_interface::passes::create_global_ctxt::{{closure}}
  68: rustc_interface::interface::run_compiler_in_existing_thread_pool
  69: std::thread::local::LocalKey<T>::with
  70: scoped_tls::ScopedKey<T>::set
  71: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error


note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.39.0-nightly (eb48d6bde 2019-09-12) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `mysql_common`.

I got the same error with the following Rust versions:

  • nightly-2019-08-01
  • nightly-2019-08-17
  • nightly-2019-09-11
  • nightly-2019-09-13

But it works with:

nightly-2019-07-19

here is the repository to reproduce: https://gitlab.com/bloom42/phaser, just run cargo clippy -- -D warnings -A clippy::needless_return with one of the affected Rust versions

Please note it does not panic when compiling, only when clippy is 'checking'

@sylvain101010
Copy link

A quick fix while waiting for the fix is to use cargo +nightly-2019-07-19 clippy

@flip1995
Copy link
Member

flip1995 commented Sep 27, 2019

This minimal reproducer only ICEs because it depends on mysql_common. #4579 (comment)

Here's a (minimal?) reproducer without external dependencies:

use std::ptr;

fn main() {
    match Some(0_usize) {
        Some(_) => {
            let s = "012345";
            unsafe { ptr::read(s.as_ptr().offset(1) as *const [u8; 5]) };
            //                                                     ^ No expr_ty for this expr 
        },
        _ => (),
    };
}

Playground

flip1995 added a commit to flip1995/rust-clippy that referenced this issue Sep 27, 2019
flip1995 added a commit to flip1995/rust-clippy that referenced this issue Sep 27, 2019
flip1995 added a commit to flip1995/rust-clippy that referenced this issue Sep 27, 2019
flip1995 added a commit to flip1995/rust-clippy that referenced this issue Sep 27, 2019
flip1995 added a commit to flip1995/rust-clippy that referenced this issue Sep 30, 2019
flip1995 added a commit to flip1995/rust-clippy that referenced this issue Sep 30, 2019
flip1995 added a commit to flip1995/rust-clippy that referenced this issue Sep 30, 2019
bors added a commit that referenced this issue Oct 1, 2019
Fix ICE #4579

Fixes #4579
Fixes #4584

r? @phansch

changelog: Fix ICE caused by Clippys const-utils
bors added a commit that referenced this issue Oct 2, 2019
Fix ICE #4579

Fixes #4579
Fixes #4584

r? @phansch

changelog: Fix ICE caused by Clippys const-utils
flip1995 added a commit to flip1995/rust-clippy that referenced this issue Oct 2, 2019
flip1995 added a commit to flip1995/rust-clippy that referenced this issue Oct 2, 2019
bors added a commit that referenced this issue Oct 2, 2019
Fix ICE #4579

Fixes #4579
Fixes #4584

r? @phansch

changelog: Fix ICE caused by Clippys const-utils
@bors bors closed this as completed in 83f90aa Oct 2, 2019
flip1995 added a commit that referenced this issue Oct 11, 2019
flip1995 added a commit that referenced this issue Oct 11, 2019
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue May 5, 2020
Changes:
````
travis: temporarily disable rustfmt ci check until rust-lang#4742 is resolved
rustup rust-lang/rust#65792
Fix ICE rust-lang#4579
Add regression test for ICE rust-lang#4579
Run update_lints for Unicode lint
Re-add false positive check
Add raw string regression test for useless_format lint
Re-factor useless_format lint
Update Unicode lint tests
[Backported] Rustup to rust-lang/rust#59545
````

Fixes ##65888
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.

4 participants