rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.17k stars 12.7k forks source link

ICE: `node_type: no type for node HirId` #132517

Open matthiaskrgr opened 2 hours ago

matthiaskrgr commented 2 hours ago

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: https://github.com/rust-lang/rust/blob/ef972a346668ed4234d1a43ed4ad7ca4e9c58d51/compiler/rustc_middle/src/ty/typeck_results.rs#L310-L322

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::(|_| 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::(|_| 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 stack backtrace: 0: 0x7866550584aa - ::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::>::{closure#0} 7: 0x78665505af18 - std::panicking::rust_panic_with_hook::h6eef9cc88a2d4e79 8: 0x786654117231 - std[85c38ff02e03f0e6]::panicking::begin_panic::::{closure#0} 9: 0x78665410a206 - std[85c38ff02e03f0e6]::sys::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 10: 0x786654105829 - std[85c38ff02e03f0e6]::panicking::begin_panic:: 11: 0x786654120e01 - ::emit_producing_guarantee 12: 0x78665479a363 - rustc_middle[b16c40c3cb132ea9]::util::bug::opt_span_bug_fmt::::{closure#0} 13: 0x78665478095a - rustc_middle[b16c40c3cb132ea9]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 14: 0x7866547807eb - rustc_middle[b16c40c3cb132ea9]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 15: 0x7866528cf260 - rustc_middle[b16c40c3cb132ea9]::util::bug::bug_fmt 16: 0x786655a4a37e - ::node_type 17: 0x78665688d9db - ::visit_ty 18: 0x7866574eab28 - rustc_hir[885137f5f5b6a9f]::intravisit::walk_generic_args::.cold 19: 0x78665688dda0 - rustc_hir[885137f5f5b6a9f]::intravisit::walk_qpath:: 20: 0x78665688dc52 - ::visit_qpath 21: 0x78665688e7e6 - ::visit_expr 22: 0x78665688e73e - ::visit_expr 23: 0x78665688e66d - ::visit_block 24: 0x78665688e84c - ::visit_expr 25: 0x78665688d071 - >, ::try_to_suggest_annotations::{closure#0}> as core[d9ceb9bc2a384707]::iter::traits::iterator::Iterator>::next 26: 0x78665688c9ad - ::try_to_suggest_annotations 27: 0x78665688c4c5 - ::lint_never_type_fallback_flowing_into_unsafe_code 28: 0x78665628c644 - ::type_inference_fallback 29: 0x786655b1b302 - rustc_hir_typeck[643602d1ca0da9fa]::typeck 30: 0x786655b1ac93 - rustc_query_impl[c0318c643aee4f05]::plumbing::__rust_begin_short_backtrace::> 31: 0x786655f21d81 - rustc_query_system[708ef94f36d60214]::query::plumbing::try_execute_query::>, 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 - ::par_body_owners::::{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::> 38: 0x7866567a1bae - rustc_query_system[708ef94f36d60214]::query::plumbing::try_execute_query::>, 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::, rustc_driver_impl[8ea1370c87ac4c52]::run_compiler::{closure#0}>::{closure#1} 41: 0x7866566f0590 - std[85c38ff02e03f0e6]::sys::backtrace::__rust_begin_short_backtrace::, 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 - <::spawn_unchecked_, 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 - 45: 0x78665800849c - 46: 0x0 - 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 commented 2 hours ago

bisects to #132383 cc @compiler-errors

matthiaskrgr commented 1 hour ago
fn main() {
    x::<_>(|_| panic!())
}