rust-lang/rust

ICE: unexpected sort of node: glacier fixed/83471-2.rs with -Zsave-analysis

matthiaskrgr opened this issue · 2 comments

Code

code from glacier ./fixed/83471-2.rs

#![feature(lang_items)]
// #![feature(no_core)]
// #![no_core]

#[lang = "fn"]
trait MyFn<T> {
    const call: i32 = 42;
    //~^ ERROR: `call` trait item in `fn`/`fn_mut` lang item must be a function
}

#[lang = "fn_mut"]
trait MyFnMut<T> {
    fn call(i: i32, j: i32) -> i32 { i + j }
    //~^ ERROR: first argument of `call` in `fn`/`fn_mut` lang item must be a reference
}

fn main() {
    let a = || 42;
    a();

    let mut i = 0;
    let mut b = || { i += 1; };
    b();
}

Meta

rustc --version --verbose:

rustc 1.57.0-nightly (addb4da68 2021-09-25)
binary: rustc
commit-hash: addb4da686a97da46159f0123cb6cdc2ce3d7fdb
commit-date: 2021-09-25
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0

Error output

rustc ./83471-2.rs -Zsave-analysis

error[E0152]: found duplicate lang item `fn`
 --> ./83471-2.rs:6:1
  |
6 | / trait MyFn<T> {
7 | |     const call: i32 = 42;
8 | |     //~^ ERROR: `call` trait item in `fn`/`fn_mut` lang item must be a function
9 | | }
  | |_^
  |
  = note: the lang item is first defined in crate `core` (which `std` depends on)
  = note: first definition in `core` loaded from /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-0e3656b1fda5fd7b.rlib
  = note: second definition in the local crate (`83471_2`)

error[E0152]: found duplicate lang item `fn_mut`
  --> ./83471-2.rs:12:1
   |
12 | / trait MyFnMut<T> {
13 | |     fn call(i: i32, j: i32) -> i32 { i + j }
14 | |     //~^ ERROR: first argument of `call` in `fn`/`fn_mut` lang item must be a reference
15 | | }
   | |_^
   |
   = note: the lang item is first defined in crate `core` (which `std` depends on)
   = note: first definition in `core` loaded from /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-0e3656b1fda5fd7b.rlib
   = note: second definition in the local crate (`83471_2`)

error: `call` trait item in `fn` lang item must be a function
 --> ./83471-2.rs:7:5
  |
7 |     const call: i32 = 42;
  |     ^^^^^^^^^^^^^^^^^^^^^

error: first argument of `call` in `fn_mut` lang item must be a reference
  --> ./83471-2.rs:13:16
   |
13 |     fn call(i: i32, j: i32) -> i32 { i + j }
   |                ^^^

error: internal compiler error: compiler/rustc_typeck/src/collect.rs:1876:13: unexpected sort of node in fn_sig(): TraitItem(TraitItem { ident: call#0, def_id: DefId(0:5 ~ 83471_2[9b65]::MyFn::call), generics: Generics { params: [], where_clause: WhereClause { predicates: [], span: no-location (#0) }, span: no-location (#0) }, kind: Const(Ty { hir_id: HirId { owner: DefId(0:5 ~ 83471_2[9b65]::MyFn::call), local_id: 1 }, kind: Path(Resolved(None, Path { span: ./83471-2.rs:7:17: 7:20 (#0), res: PrimTy(Int(I32)), segments: [PathSegment { ident: i32#0, hir_id: Some(HirId { owner: DefId(0:5 ~ 83471_2[9b65]::MyFn::call), local_id: 2 }), res: Some(Err), args: None, infer_args: false }] })), span: ./83471-2.rs:7:17: 7:20 (#0) }, Some(BodyId { hir_id: HirId { owner: DefId(0:5 ~ 83471_2[9b65]::MyFn::call), local_id: 3 } })), span: ./83471-2.rs:7:5: 7:26 (#0) })

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1146:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.57.0-nightly (addb4da68 2021-09-25) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z save-analysis

query stack during panic:
#0 [fn_sig] computing function signature of `MyFn::call`
#1 [typeck] type-checking `main`
end of query stack
error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0152`.
Backtrace

error: internal compiler error: compiler/rustc_typeck/src/collect.rs:1876:13: unexpected sort of node in fn_sig(): TraitItem(TraitItem { ident: call#0, def_id: DefId(0:5 ~ 83471_2[9b65]::MyFn::call), generics: Generics { params: [], where_clause: WhereClause { predicates: [], span: no-location (#0) }, span: no-location (#0) }, kind: Const(Ty { hir_id: HirId { owner: DefId(0:5 ~ 83471_2[9b65]::MyFn::call), local_id: 1 }, kind: Path(Resolved(None, Path { span: ./83471-2.rs:7:17: 7:20 (#0), res: PrimTy(Int(I32)), segments: [PathSegment { ident: i32#0, hir_id: Some(HirId { owner: DefId(0:5 ~ 83471_2[9b65]::MyFn::call), local_id: 2 }), res: Some(Err), args: None, infer_args: false }] })), span: ./83471-2.rs:7:17: 7:20 (#0) }, Some(BodyId { hir_id: HirId { owner: DefId(0:5 ~ 83471_2[9b65]::MyFn::call), local_id: 3 } })), span: ./83471-2.rs:7:5: 7:26 (#0) })

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1146:9
stack backtrace:
   0:     0x7f22f504705c - std::backtrace_rs::backtrace::libunwind::trace::h2ab374bc2a3b7023
                               at /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f22f504705c - std::backtrace_rs::backtrace::trace_unsynchronized::h128cb5178b04dc46
                               at /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f22f504705c - std::sys_common::backtrace::_print_fmt::h5344f9eefca2041f
                               at /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f22f504705c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h213003bc5c7acf04
                               at /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f22f50a502c - core::fmt::write::h78bf85fc3e93663f
                               at /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/library/core/src/fmt/mod.rs:1161:17
   5:     0x7f22f50387b5 - std::io::Write::write_fmt::he619515c888f21a5
                               at /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/library/std/src/io/mod.rs:1668:15
   6:     0x7f22f504a380 - std::sys_common::backtrace::_print::hf706674f77848203
                               at /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f22f504a380 - std::sys_common::backtrace::print::hf0b6c7a88804ec56
                               at /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f22f504a380 - std::panicking::default_hook::{{closure}}::h2dde766cd83a333a
                               at /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/library/std/src/panicking.rs:210:50
   9:     0x7f22f5049f2b - std::panicking::default_hook::h501e3b2e134eb149
                               at /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/library/std/src/panicking.rs:227:9
  10:     0x7f22f58241c1 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h8ff5de92123cb8fd
  11:     0x7f22f504ab99 - std::panicking::rust_panic_with_hook::hc09e869c4cf00885
                               at /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/library/std/src/panicking.rs:628:17
  12:     0x7f22f68fcd8b - std::panicking::begin_panic::{{closure}}::h5c7a29a9f3c50d8d
  13:     0x7f22f68fccc6 - std::sys_common::backtrace::__rust_end_short_backtrace::h11b7892876009c1e
  14:     0x7f22f68fcd5f - std::panicking::begin_panic::hd63e7fe0ba9182da
  15:     0x7f22f690d65d - std::panic::panic_any::h3c06e175d31a9167
  16:     0x7f22f690f6fa - rustc_errors::HandlerInner::bug::he6d06053695a98ed
  17:     0x7f22f690f1a0 - rustc_errors::Handler::bug::h61abf9991ffffcbc
  18:     0x7f22f6786f16 - rustc_middle::ty::context::tls::with_opt::hd0b25ef1fa372784
  19:     0x7f22f6787420 - rustc_middle::util::bug::opt_span_bug_fmt::he982db01d383152c
  20:     0x7f22f6787396 - rustc_middle::util::bug::bug_fmt::h3252ae0338f3fde6
  21:     0x7f22f6ccf572 - rustc_typeck::collect::fn_sig::h9eec030476329f27
  22:     0x7f22f70be9d6 - rustc_query_system::query::plumbing::try_execute_query::h770da3a7d681a72d
  23:     0x7f22f7166d5c - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::fn_sig::h6b065c18230f06ab
  24:     0x7f22f6be9eb1 - rustc_typeck::check::method::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::lookup_method_in_trait::h5ee7e33de494458f
  25:     0x7f22f7922f58 - rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::try_overloaded_call_traits::h06fc024f187a2cf3
  26:     0x7f22f7986189 - rustc_typeck::check::callee::DeferredCallResolution::resolve::h8166e0c22c8306de
  27:     0x7f22f792eb06 - rustc_typeck::check::upvar::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::analyze_closure::haa242e22fbdfebee
  28:     0x7f22f7938c5d - rustc_hir::intravisit::walk_stmt::h0524d20f3c4601e3
  29:     0x7f22f7934cb2 - rustc_hir::intravisit::walk_block::h287b7dc4fe76ea84
  30:     0x7f22f6bf22e4 - rustc_hir::intravisit::walk_body::h03dd7f2a1e650e70
  31:     0x7f22f6c4f101 - rustc_infer::infer::InferCtxtBuilder::enter::hdb12dfea297a175f
  32:     0x7f22f6c03d0d - rustc_typeck::check::typeck::hd320344c890821b5
  33:     0x7f22f70b9a7c - rustc_query_system::query::plumbing::try_execute_query::h5bbb54711c9a400d
  34:     0x7f22f7166ef9 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck::h32b5ef98ec541fe2
  35:     0x7f22f58844bf - <rustc_save_analysis::dump_visitor::DumpVisitor as rustc_hir::intravisit::Visitor>::visit_item::h93f5d0cfab8431c2
  36:     0x7f22f587d186 - rustc_hir::intravisit::Visitor::visit_nested_item::h2549e6dfe87b0190
  37:     0x7f22f586b267 - rustc_hir::intravisit::walk_mod::h0223efe4087b2f3c
  38:     0x7f22f5879753 - rustc_middle::hir::map::Map::walk_toplevel_module::h45feb396b1d61930
  39:     0x7f22f5880f65 - rustc_save_analysis::dump_visitor::DumpVisitor::process_crate::h8ff18f5dcf8350f0
  40:     0x7f22f584bfcc - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h4b8f4fd8c7477d47
  41:     0x7f22f585f7c7 - std::thread::local::LocalKey<T>::with::h0e3c13258bb2c636
  42:     0x7f22f582910d - rustc_save_analysis::process_crate::h0090fef5623cc7e1
  43:     0x7f22f5832005 - rustc_session::utils::<impl rustc_session::session::Session>::time::hfc47fd6664b549ae
  44:     0x7f22f76d2b6e - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::hded9061889acb733
  45:     0x7f22f76c2fe2 - rustc_span::with_source_map::hce3a664e96079636
  46:     0x7f22f76d3744 - rustc_interface::interface::create_compiler_and_run::ha4222a436c1ad978
  47:     0x7f22f76c3fb2 - std::sys_common::backtrace::__rust_begin_short_backtrace::h4110caeb43804b52
  48:     0x7f22f76e5922 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h78b1590830fa3a44
  49:     0x7f22f5057ac3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h59eef3b9c8a82350
                               at /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/library/alloc/src/boxed.rs:1638:9
  50:     0x7f22f5057ac3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb5bbe017c347469c
                               at /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/library/alloc/src/boxed.rs:1638:9
  51:     0x7f22f5057ac3 - std::sys::unix::thread::Thread::new::thread_start::h62931528f61e35f5
                               at /rustc/addb4da686a97da46159f0123cb6cdc2ce3d7fdb/library/std/src/sys/unix/thread.rs:106:17
  52:     0x7f22f4f65259 - start_thread
  53:     0x7f22f4e7a5e3 - __GI___clone
  54:                0x0 - <unknown>

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.57.0-nightly (addb4da68 2021-09-25) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z save-analysis

query stack during panic:
#0 [fn_sig] computing function signature of `MyFn::call`
#1 [typeck] type-checking `main`
end of query stack
error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0152`.

Related to #9307

triage: still crashing 🙃