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: fn_arg_names: unexpected item DefId(..) #118510

Closed
matthiaskrgr opened this issue Dec 1, 2023 · 1 comment · Fixed by #118526
Closed

ICE: fn_arg_names: unexpected item DefId(..) #118510

matthiaskrgr opened this issue Dec 1, 2023 · 1 comment · Fixed by #118526
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

pub enum Sexpr<'a> {
    Ident(&'a mut S),
}

fn map<'a, F: FnOnce(&Foo<'a>) -> T>(f: F) {}

fn main() {
    map(Sexpr::Ident);
}

original:

pub enum Sexpr<'a> {
    Ident(&'a mut S),
}

fn map<'a, F: FnOnce(&Foo<'a>) -> T>(f: F) {}

fn main() {
    map(Sexpr::Ident);
    //~^ ERROR type mismatch in function arguments
}

Version information

rustc 1.76.0-nightly (9bf30ebdf 2023-12-01)
binary: rustc
commit-hash: 9bf30ebdfa50db6286d9400615c2bcb324c1a587
commit-date: 2023-12-01
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0412]: cannot find type `S` in this scope
 --> /tmp/icemaker_global_tempdir.0ZDzaBQJByF1/rustc_testrunner_tmpdir_reporting.KXRpI6OsUH2b/mvce.rs:2:19
  |
2 |     Ident(&'a mut S),
  |                   ^ not found in this scope
  |
help: you might be missing a type parameter
  |
1 | pub enum Sexpr<'a, S> {
  |                  +++

error[E0412]: cannot find type `Foo` in this scope
 --> /tmp/icemaker_global_tempdir.0ZDzaBQJByF1/rustc_testrunner_tmpdir_reporting.KXRpI6OsUH2b/mvce.rs:5:23
  |
5 | fn map<'a, F: FnOnce(&Foo<'a>) -> T>(f: F) {}
  |                       ^^^ not found in this scope

error[E0412]: cannot find type `T` in this scope
 --> /tmp/icemaker_global_tempdir.0ZDzaBQJByF1/rustc_testrunner_tmpdir_reporting.KXRpI6OsUH2b/mvce.rs:5:35
  |
5 | fn map<'a, F: FnOnce(&Foo<'a>) -> T>(f: F) {}
  |            -                      ^ help: a type parameter with a similar name exists: `F`
  |            |
  |            similarly named type parameter `F` defined here

error: internal compiler error: /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/compiler/rustc_middle/src/hir/mod.rs:202:13: fn_arg_names: unexpected item DefId(0:6 ~ mvce[9b80]::Sexpr::Ident::{constructor#0})
 --> /tmp/icemaker_global_tempdir.0ZDzaBQJByF1/rustc_testrunner_tmpdir_reporting.KXRpI6OsUH2b/mvce.rs:2:5
  |
2 |     Ident(&'a mut S),
  |     ^^^^^

thread 'rustc' panicked at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/compiler/rustc_errors/src/lib.rs:998:33:
Box<dyn Any>
stack backtrace:
   0:     0x7fe84a9ed28c - std::backtrace_rs::backtrace::libunwind::trace::h9d732439270c3383
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fe84a9ed28c - std::backtrace_rs::backtrace::trace_unsynchronized::h00fc8ac1c9b3c142
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fe84a9ed28c - std::sys_common::backtrace::_print_fmt::h6e04e141aa46ac91
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fe84a9ed28c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0fc019919d3e63a6
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fe84aa402c0 - core::fmt::rt::Argument::fmt::h5b48578e292a11d2
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/core/src/fmt/rt.rs:142:9
   5:     0x7fe84aa402c0 - core::fmt::write::h0b89aa2be2cfe571
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fe84a9e10ef - std::io::Write::write_fmt::h0ba18fb86594bb3f
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/std/src/io/mod.rs:1810:15
   7:     0x7fe84a9ed074 - std::sys_common::backtrace::_print::h71e0da75223aab58
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fe84a9ed074 - std::sys_common::backtrace::print::h8f0759a29c219f85
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fe84a9efd07 - std::panicking::default_hook::{{closure}}::h3abd6eee3cd0fda2
  10:     0x7fe84a9efa6f - std::panicking::default_hook::h097cf129ec363cfe
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/std/src/panicking.rs:292:9
  11:     0x7fe8476e6590 - std[93ea1b589bf29457]::panicking::update_hook::<alloc[5f7f0bf396af8345]::boxed::Box<rustc_driver_impl[48609f831332dbe0]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fe84a9f0448 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1d8a6b4800e422c1
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/alloc/src/boxed.rs:2021:9
  13:     0x7fe84a9f0448 - std::panicking::rust_panic_with_hook::h81a08ac0cc2711f4
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/std/src/panicking.rs:783:13
  14:     0x7fe847a235b4 - std[93ea1b589bf29457]::panicking::begin_panic::<rustc_errors[13238c54a1371c29]::ExplicitBug>::{closure#0}
  15:     0x7fe847a18fd6 - std[93ea1b589bf29457]::sys_common::backtrace::__rust_end_short_backtrace::<std[93ea1b589bf29457]::panicking::begin_panic<rustc_errors[13238c54a1371c29]::ExplicitBug>::{closure#0}, !>
  16:     0x7fe847a14386 - std[93ea1b589bf29457]::panicking::begin_panic::<rustc_errors[13238c54a1371c29]::ExplicitBug>
  17:     0x7fe8479ed5ee - <rustc_errors[13238c54a1371c29]::HandlerInner>::span_bug::<rustc_span[1e2a69f3aea93f35]::span_encoding::Span, alloc[5f7f0bf396af8345]::string::String>
  18:     0x7fe8479ed3d8 - <rustc_errors[13238c54a1371c29]::Handler>::span_bug::<rustc_span[1e2a69f3aea93f35]::span_encoding::Span, alloc[5f7f0bf396af8345]::string::String>
  19:     0x7fe847a27afb - rustc_middle[99f34480590a0e22]::util::bug::opt_span_bug_fmt::<rustc_span[1e2a69f3aea93f35]::span_encoding::Span>::{closure#0}
  20:     0x7fe847a27b4a - rustc_middle[99f34480590a0e22]::ty::context::tls::with_opt::<rustc_middle[99f34480590a0e22]::util::bug::opt_span_bug_fmt<rustc_span[1e2a69f3aea93f35]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7fe847a199d8 - rustc_middle[99f34480590a0e22]::ty::context::tls::with_context_opt::<rustc_middle[99f34480590a0e22]::ty::context::tls::with_opt<rustc_middle[99f34480590a0e22]::util::bug::opt_span_bug_fmt<rustc_span[1e2a69f3aea93f35]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7fe847a1903b - rustc_middle[99f34480590a0e22]::util::bug::span_bug_fmt::<rustc_span[1e2a69f3aea93f35]::span_encoding::Span>
  23:     0x7fe849c2fbe1 - rustc_query_impl[27c039f8cc0d4cec]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[27c039f8cc0d4cec]::query_impl::fn_arg_names::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99f34480590a0e22]::query::erase::Erased<[u8; 16usize]>>.cold.0
  24:     0x7fe848cd0773 - <rustc_query_impl[27c039f8cc0d4cec]::query_impl::fn_arg_names::dynamic_query::{closure#2} as core[75f1a5f8e69b4518]::ops::function::FnOnce<(rustc_middle[99f34480590a0e22]::ty::context::TyCtxt, rustc_span[1e2a69f3aea93f35]::def_id::DefId)>>::call_once
  25:     0x7fe848af3b69 - rustc_query_system[eb791f1d27a77a7b]::query::plumbing::try_execute_query::<rustc_query_impl[27c039f8cc0d4cec]::DynamicConfig<rustc_query_system[eb791f1d27a77a7b]::query::caches::DefaultCache<rustc_span[1e2a69f3aea93f35]::def_id::DefId, rustc_middle[99f34480590a0e22]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[27c039f8cc0d4cec]::plumbing::QueryCtxt, false>
  26:     0x7fe848af3221 - rustc_query_impl[27c039f8cc0d4cec]::query_impl::fn_arg_names::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7fe8491f4d4f - rustc_middle[99f34480590a0e22]::query::plumbing::query_get_at::<rustc_query_system[eb791f1d27a77a7b]::query::caches::DefaultCache<rustc_span[1e2a69f3aea93f35]::def_id::DefId, rustc_middle[99f34480590a0e22]::query::erase::Erased<[u8; 16usize]>>>
  28:     0x7fe848202c0e - <rustc_infer[a6b898bd471e499]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[970c28e4f2c5a3b8]::traits::error_reporting::suggestions::TypeErrCtxtExt>::note_conflicting_fn_args
  29:     0x7fe84820150c - <rustc_infer[a6b898bd471e499]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[970c28e4f2c5a3b8]::traits::error_reporting::suggestions::TypeErrCtxtExt>::report_closure_arg_mismatch
  30:     0x7fe848229096 - <rustc_infer[a6b898bd471e499]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[970c28e4f2c5a3b8]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_type_parameter_mismatch_error
  31:     0x7fe8482190e8 - <rustc_infer[a6b898bd471e499]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[970c28e4f2c5a3b8]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_selection_error
  32:     0x7fe848241398 - <rustc_infer[a6b898bd471e499]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[970c28e4f2c5a3b8]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_fulfillment_error
  33:     0x7fe848216767 - <rustc_infer[a6b898bd471e499]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[970c28e4f2c5a3b8]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
  34:     0x7fe8493a8e51 - <rustc_hir_typeck[b75a8e014774e517]::fn_ctxt::FnCtxt>::check_argument_types
  35:     0x7fe84939e0ef - <rustc_hir_typeck[b75a8e014774e517]::fn_ctxt::FnCtxt>::check_call
  36:     0x7fe84947e37b - <rustc_hir_typeck[b75a8e014774e517]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  37:     0x7fe848f64776 - <rustc_hir_typeck[b75a8e014774e517]::fn_ctxt::FnCtxt>::check_block_with_expected
  38:     0x7fe84947e70d - <rustc_hir_typeck[b75a8e014774e517]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  39:     0x7fe848e440ef - rustc_hir_typeck[b75a8e014774e517]::check::check_fn
  40:     0x7fe848d08759 - rustc_hir_typeck[b75a8e014774e517]::typeck
  41:     0x7fe848d07b3d - rustc_query_impl[27c039f8cc0d4cec]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[27c039f8cc0d4cec]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99f34480590a0e22]::query::erase::Erased<[u8; 8usize]>>
  42:     0x7fe848c6c343 - rustc_query_system[eb791f1d27a77a7b]::query::plumbing::try_execute_query::<rustc_query_impl[27c039f8cc0d4cec]::DynamicConfig<rustc_query_system[eb791f1d27a77a7b]::query::caches::VecCache<rustc_span[1e2a69f3aea93f35]::def_id::LocalDefId, rustc_middle[99f34480590a0e22]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[27c039f8cc0d4cec]::plumbing::QueryCtxt, false>
  43:     0x7fe848c6bfd0 - rustc_query_impl[27c039f8cc0d4cec]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  44:     0x7fe84946a860 - <rustc_middle[99f34480590a0e22]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[a7e15cd0e5348565]::check_crate::{closure#7}>::{closure#0}
  45:     0x7fe849469320 - rustc_hir_analysis[a7e15cd0e5348565]::check_crate
  46:     0x7fe849470e62 - rustc_interface[dae0a1533f7b1618]::passes::analysis
  47:     0x7fe849470a9d - rustc_query_impl[27c039f8cc0d4cec]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[27c039f8cc0d4cec]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99f34480590a0e22]::query::erase::Erased<[u8; 1usize]>>
  48:     0x7fe84995de40 - rustc_query_system[eb791f1d27a77a7b]::query::plumbing::try_execute_query::<rustc_query_impl[27c039f8cc0d4cec]::DynamicConfig<rustc_query_system[eb791f1d27a77a7b]::query::caches::SingleCache<rustc_middle[99f34480590a0e22]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[27c039f8cc0d4cec]::plumbing::QueryCtxt, false>
  49:     0x7fe84995dc47 - rustc_query_impl[27c039f8cc0d4cec]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  50:     0x7fe84996c512 - rustc_interface[dae0a1533f7b1618]::interface::run_compiler::<core[75f1a5f8e69b4518]::result::Result<(), rustc_span[1e2a69f3aea93f35]::ErrorGuaranteed>, rustc_driver_impl[48609f831332dbe0]::run_compiler::{closure#0}>::{closure#0}
  51:     0x7fe84995f909 - std[93ea1b589bf29457]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[dae0a1533f7b1618]::util::run_in_thread_with_globals<rustc_interface[dae0a1533f7b1618]::util::run_in_thread_pool_with_globals<rustc_interface[dae0a1533f7b1618]::interface::run_compiler<core[75f1a5f8e69b4518]::result::Result<(), rustc_span[1e2a69f3aea93f35]::ErrorGuaranteed>, rustc_driver_impl[48609f831332dbe0]::run_compiler::{closure#0}>::{closure#0}, core[75f1a5f8e69b4518]::result::Result<(), rustc_span[1e2a69f3aea93f35]::ErrorGuaranteed>>::{closure#0}, core[75f1a5f8e69b4518]::result::Result<(), rustc_span[1e2a69f3aea93f35]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[75f1a5f8e69b4518]::result::Result<(), rustc_span[1e2a69f3aea93f35]::ErrorGuaranteed>>
  52:     0x7fe84995f733 - <<std[93ea1b589bf29457]::thread::Builder>::spawn_unchecked_<rustc_interface[dae0a1533f7b1618]::util::run_in_thread_with_globals<rustc_interface[dae0a1533f7b1618]::util::run_in_thread_pool_with_globals<rustc_interface[dae0a1533f7b1618]::interface::run_compiler<core[75f1a5f8e69b4518]::result::Result<(), rustc_span[1e2a69f3aea93f35]::ErrorGuaranteed>, rustc_driver_impl[48609f831332dbe0]::run_compiler::{closure#0}>::{closure#0}, core[75f1a5f8e69b4518]::result::Result<(), rustc_span[1e2a69f3aea93f35]::ErrorGuaranteed>>::{closure#0}, core[75f1a5f8e69b4518]::result::Result<(), rustc_span[1e2a69f3aea93f35]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[75f1a5f8e69b4518]::result::Result<(), rustc_span[1e2a69f3aea93f35]::ErrorGuaranteed>>::{closure#1} as core[75f1a5f8e69b4518]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  53:     0x7fe84a9fa2d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfe69761f953335b6
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/alloc/src/boxed.rs:2007:9
  54:     0x7fe84a9fa2d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h626a827d88bd2697
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/alloc/src/boxed.rs:2007:9
  55:     0x7fe84a9fa2d5 - std::sys::unix::thread::Thread::new::thread_start::h3df882f04a39f11a
                               at /rustc/9bf30ebdfa50db6286d9400615c2bcb324c1a587/library/std/src/sys/unix/thread.rs:108:17
  56:     0x7fe8448aa9eb - <unknown>
  57:     0x7fe84492e7cc - <unknown>
  58:                0x0 - <unknown>

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.76.0-nightly (9bf30ebdf 2023-12-01) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [fn_arg_names] looking up function parameter names for `Sexpr::Ident`
#1 [typeck] type-checking `main`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors

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

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Dec 1, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 1, 2023
@sjwang05
Copy link
Contributor

sjwang05 commented Dec 1, 2023

searched nightlies: from nightly-2023-11-29 to nightly-2023-12-01
regressed nightly: nightly-2023-12-01
searched commit range: b10cfcd...87e1447
regressed commit: 87e1447

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 2, 2023
@bors bors closed this as completed in 21d88b3 Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants