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: node_type: no type for node HirId #132517

Closed
matthiaskrgr opened this issue Nov 2, 2024 · 2 comments · Fixed by #132528
Closed

ICE: node_type: no type for node HirId #132517

matthiaskrgr opened this issue Nov 2, 2024 · 2 comments · Fixed by #132528
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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):

fn main() {
    try_map_project::<M, _>(|_| todo!())
}

original:

use std::ops::Deref;

trait Foo {
    fn foo() {}
}

impl Foo for u8 {}

fn bar<T: Deref>() where T::Target: Foo {
    <<T as Deref>::Target as Foo>::foo()
}

fn main() {
    try_map_project::<M, _>(|_| todo!())
}

Version information

rustc 1.84.0-nightly (ef972a346 2024-11-02)
binary: rustc
commit-hash: ef972a346668ed4234d1a43ed4ad7ca4e9c58d51
commit-date: 2024-11-02
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1

Possibly related line of code:

pub fn node_types_mut(&mut self) -> LocalTableInContextMut<'_, Ty<'tcx>> {
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.node_types }
}
pub fn node_type(&self, id: HirId) -> Ty<'tcx> {
self.node_type_opt(id).unwrap_or_else(|| {
bug!("node_type: no type for node {}", tls::with(|tcx| tcx.hir().node_to_string(id)))
})
}
pub fn node_type_opt(&self, id: HirId) -> Option<Ty<'tcx>> {
validate_hir_id_for_typeck_results(self.hir_owner, id);
self.node_types.get(&id.local_id).cloned()

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

Program output

error[E0412]: cannot find type `M` in this scope
 --> /tmp/icemaker_global_tempdir.0zjaEjm1FMGM/rustc_testrunner_tmpdir_reporting.6sYqdvafiXNm/mvce.rs:2:23
  |
2 |     try_map_project::<M, _>(|_| todo!())
  |                       ^ not found in this scope

error[E0425]: cannot find function `try_map_project` in this scope
 --> /tmp/icemaker_global_tempdir.0zjaEjm1FMGM/rustc_testrunner_tmpdir_reporting.6sYqdvafiXNm/mvce.rs:2:5
  |
2 |     try_map_project::<M, _>(|_| todo!())
  |     ^^^^^^^^^^^^^^^ not found in this scope

error: internal compiler error: compiler/rustc_middle/src/ty/typeck_results.rs:316:13: node_type: no type for node HirId(DefId(0:3 ~ mvce[4f49]::main).6) (type `_`)

thread 'rustc' panicked at compiler/rustc_middle/src/ty/typeck_results.rs:316:13:
Box<dyn Any>
stack backtrace:
   0:     0x7866550584aa - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hce429173f4835cf6
   1:     0x7866558040ca - core::fmt::write::hd474fbdfe63c8008
   2:     0x786656c7b011 - std::io::Write::write_fmt::ha6b1be51a74d6c82
   3:     0x786655058302 - std::sys::backtrace::BacktraceLock::print::h9a37e75f7192ac21
   4:     0x78665505a806 - std::panicking::default_hook::{{closure}}::hd9ac8cf20a0b7897
   5:     0x78665505a650 - std::panicking::default_hook::hdde16dcfa738c4aa
   6:     0x7866540ddb49 - std[85c38ff02e03f0e6]::panicking::update_hook::<alloc[39d8aefd6e9d2d6]::boxed::Box<rustc_driver_impl[8ea1370c87ac4c52]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x78665505af18 - std::panicking::rust_panic_with_hook::h6eef9cc88a2d4e79
   8:     0x786654117231 - std[85c38ff02e03f0e6]::panicking::begin_panic::<rustc_errors[a3358f633eebb703]::ExplicitBug>::{closure#0}
   9:     0x78665410a206 - std[85c38ff02e03f0e6]::sys::backtrace::__rust_end_short_backtrace::<std[85c38ff02e03f0e6]::panicking::begin_panic<rustc_errors[a3358f633eebb703]::ExplicitBug>::{closure#0}, !>
  10:     0x786654105829 - std[85c38ff02e03f0e6]::panicking::begin_panic::<rustc_errors[a3358f633eebb703]::ExplicitBug>
  11:     0x786654120e01 - <rustc_errors[a3358f633eebb703]::diagnostic::BugAbort as rustc_errors[a3358f633eebb703]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x78665479a363 - rustc_middle[b16c40c3cb132ea9]::util::bug::opt_span_bug_fmt::<rustc_span[94bdfa138cad1541]::span_encoding::Span>::{closure#0}
  13:     0x78665478095a - rustc_middle[b16c40c3cb132ea9]::ty::context::tls::with_opt::<rustc_middle[b16c40c3cb132ea9]::util::bug::opt_span_bug_fmt<rustc_span[94bdfa138cad1541]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7866547807eb - rustc_middle[b16c40c3cb132ea9]::ty::context::tls::with_context_opt::<rustc_middle[b16c40c3cb132ea9]::ty::context::tls::with_opt<rustc_middle[b16c40c3cb132ea9]::util::bug::opt_span_bug_fmt<rustc_span[94bdfa138cad1541]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7866528cf260 - rustc_middle[b16c40c3cb132ea9]::util::bug::bug_fmt
  16:     0x786655a4a37e - <rustc_middle[b16c40c3cb132ea9]::ty::typeck_results::TypeckResults>::node_type
  17:     0x78665688d9db - <rustc_hir_typeck[643602d1ca0da9fa]::fallback::AnnotateUnitFallbackVisitor as rustc_hir[885137f5f5b6a9f]::intravisit::Visitor>::visit_ty
  18:     0x7866574eab28 - rustc_hir[885137f5f5b6a9f]::intravisit::walk_generic_args::<rustc_hir_typeck[643602d1ca0da9fa]::fallback::AnnotateUnitFallbackVisitor>.cold
  19:     0x78665688dda0 - rustc_hir[885137f5f5b6a9f]::intravisit::walk_qpath::<rustc_hir_typeck[643602d1ca0da9fa]::fallback::AnnotateUnitFallbackVisitor>
  20:     0x78665688dc52 - <rustc_hir_typeck[643602d1ca0da9fa]::fallback::AnnotateUnitFallbackVisitor as rustc_hir[885137f5f5b6a9f]::intravisit::Visitor>::visit_qpath
  21:     0x78665688e7e6 - <rustc_hir_typeck[643602d1ca0da9fa]::fallback::AnnotateUnitFallbackVisitor as rustc_hir[885137f5f5b6a9f]::intravisit::Visitor>::visit_expr
  22:     0x78665688e73e - <rustc_hir_typeck[643602d1ca0da9fa]::fallback::AnnotateUnitFallbackVisitor as rustc_hir[885137f5f5b6a9f]::intravisit::Visitor>::visit_expr
  23:     0x78665688e66d - <rustc_hir_typeck[643602d1ca0da9fa]::fallback::AnnotateUnitFallbackVisitor as rustc_hir[885137f5f5b6a9f]::intravisit::Visitor>::visit_block
  24:     0x78665688e84c - <rustc_hir_typeck[643602d1ca0da9fa]::fallback::AnnotateUnitFallbackVisitor as rustc_hir[885137f5f5b6a9f]::intravisit::Visitor>::visit_expr
  25:     0x78665688d071 - <core[d9ceb9bc2a384707]::iter::adapters::filter_map::FilterMap<core[d9ceb9bc2a384707]::iter::adapters::copied::Copied<core[d9ceb9bc2a384707]::slice::iter::Iter<rustc_type_ir[45f01c5603667543]::ty_kind::TyVid>>, <rustc_hir_typeck[643602d1ca0da9fa]::fn_ctxt::FnCtxt>::try_to_suggest_annotations::{closure#0}> as core[d9ceb9bc2a384707]::iter::traits::iterator::Iterator>::next
  26:     0x78665688c9ad - <rustc_hir_typeck[643602d1ca0da9fa]::fn_ctxt::FnCtxt>::try_to_suggest_annotations
  27:     0x78665688c4c5 - <rustc_hir_typeck[643602d1ca0da9fa]::fn_ctxt::FnCtxt>::lint_never_type_fallback_flowing_into_unsafe_code
  28:     0x78665628c644 - <rustc_hir_typeck[643602d1ca0da9fa]::fn_ctxt::FnCtxt>::type_inference_fallback
  29:     0x786655b1b302 - rustc_hir_typeck[643602d1ca0da9fa]::typeck
  30:     0x786655b1ac93 - rustc_query_impl[c0318c643aee4f05]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c0318c643aee4f05]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b16c40c3cb132ea9]::query::erase::Erased<[u8; 8usize]>>
  31:     0x786655f21d81 - rustc_query_system[708ef94f36d60214]::query::plumbing::try_execute_query::<rustc_query_impl[c0318c643aee4f05]::DynamicConfig<rustc_query_system[708ef94f36d60214]::query::caches::VecCache<rustc_span[94bdfa138cad1541]::def_id::LocalDefId, rustc_middle[b16c40c3cb132ea9]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[c0318c643aee4f05]::plumbing::QueryCtxt, false>
  32:     0x786655f2024d - rustc_query_impl[c0318c643aee4f05]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  33:     0x786655f1fec7 - <rustc_middle[b16c40c3cb132ea9]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[614b5c894f29c678]::check_crate::{closure#4}>::{closure#0}
  34:     0x786655f1de99 - rustc_hir_analysis[614b5c894f29c678]::check_crate
  35:     0x786655ce384a - rustc_interface[46946d42a40348f7]::passes::run_required_analyses
  36:     0x7866563d451e - rustc_interface[46946d42a40348f7]::passes::analysis
  37:     0x7866563d44ef - rustc_query_impl[c0318c643aee4f05]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c0318c643aee4f05]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b16c40c3cb132ea9]::query::erase::Erased<[u8; 1usize]>>
  38:     0x7866567a1bae - rustc_query_system[708ef94f36d60214]::query::plumbing::try_execute_query::<rustc_query_impl[c0318c643aee4f05]::DynamicConfig<rustc_query_system[708ef94f36d60214]::query::caches::SingleCache<rustc_middle[b16c40c3cb132ea9]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c0318c643aee4f05]::plumbing::QueryCtxt, false>
  39:     0x7866567a188e - rustc_query_impl[c0318c643aee4f05]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x786656665292 - rustc_interface[46946d42a40348f7]::interface::run_compiler::<core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>, rustc_driver_impl[8ea1370c87ac4c52]::run_compiler::{closure#0}>::{closure#1}
  41:     0x7866566f0590 - std[85c38ff02e03f0e6]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[46946d42a40348f7]::util::run_in_thread_with_globals<rustc_interface[46946d42a40348f7]::util::run_in_thread_pool_with_globals<rustc_interface[46946d42a40348f7]::interface::run_compiler<core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>, rustc_driver_impl[8ea1370c87ac4c52]::run_compiler::{closure#0}>::{closure#1}, core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>>::{closure#0}, core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>>
  42:     0x7866566f09ab - <<std[85c38ff02e03f0e6]::thread::Builder>::spawn_unchecked_<rustc_interface[46946d42a40348f7]::util::run_in_thread_with_globals<rustc_interface[46946d42a40348f7]::util::run_in_thread_pool_with_globals<rustc_interface[46946d42a40348f7]::interface::run_compiler<core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>, rustc_driver_impl[8ea1370c87ac4c52]::run_compiler::{closure#0}>::{closure#1}, core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>>::{closure#0}, core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d9ceb9bc2a384707]::result::Result<(), rustc_span[94bdfa138cad1541]::ErrorGuaranteed>>::{closure#1} as core[d9ceb9bc2a384707]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7866566f1479 - std::sys::pal::unix::thread::Thread::new::thread_start::h00969398ad9e9953
  44:     0x786657f8339d - <unknown>
  45:     0x78665800849c - <unknown>
  46:                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: please make sure that you have updated to the latest nightly

note: rustc 1.84.0-nightly (ef972a346 2024-11-02) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0412, E0425.
For more information about an error, try `rustc --explain E0412`.

@matthiaskrgr matthiaskrgr added 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. labels Nov 2, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 2, 2024
@matthiaskrgr
Copy link
Member Author

bisects to #132383 cc @compiler-errors

@jieyouxu jieyouxu added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue S-has-bisection Status: a bisection has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 2, 2024
@matthiaskrgr
Copy link
Member Author

fn main() {
    x::<_>(|_| panic!())
}

@compiler-errors compiler-errors self-assigned this Nov 2, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Nov 2, 2024
… r=jieyouxu

Use `*_opt` typeck results fns to not ICE in fallback suggestion

Self-explanatory. Fixes rust-lang#132517.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Nov 2, 2024
… r=jieyouxu

Use `*_opt` typeck results fns to not ICE in fallback suggestion

Self-explanatory. Fixes rust-lang#132517.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Nov 2, 2024
… r=jieyouxu

Use `*_opt` typeck results fns to not ICE in fallback suggestion

Self-explanatory. Fixes rust-lang#132517.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Nov 3, 2024
… r=jieyouxu

Use `*_opt` typeck results fns to not ICE in fallback suggestion

Self-explanatory. Fixes rust-lang#132517.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Nov 3, 2024
… r=jieyouxu

Use `*_opt` typeck results fns to not ICE in fallback suggestion

Self-explanatory. Fixes rust-lang#132517.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 3, 2024
… r=jieyouxu

Use `*_opt` typeck results fns to not ICE in fallback suggestion

Self-explanatory. Fixes rust-lang#132517.
@bors bors closed this as completed in 1a0ab89 Nov 3, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 3, 2024
Rollup merge of rust-lang#132528 - compiler-errors:fallback-sugg-opt, r=jieyouxu

Use `*_opt` typeck results fns to not ICE in fallback suggestion

Self-explanatory. Fixes rust-lang#132517.
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) ❄️ S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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