Skip to content

Compiler error: thread 'rustc' panicked at 'Box<dyn Any>' #105529

Closed
@rayhem

Description

@rayhem

Code

You can see the full context for the change that triggered the panic at https://github.com/rayhem/advent/commit/99a2921e828506bc66a09da793f73710e68d6413.

Long story short, I was working on generalizing some execution + display code for this year's Advent of Code. I believe this issue arose due to an interaction with this function,

pub fn execute_with_timing<P: Puzzle>(
    input_file: &std::path::Path,
    puzzle: P,
) -> std::result::Result<TimedResults, Error>

and how I store my puzzles,

let mut puzzles: HashMap<i32, Box<dyn Puzzle>> = HashMap::new();
// ...
let timed_results = execute_with_timing(&filename, puzzles.get(&1))?;

as this was the section of code I was working on refactoring.

Meta

rustc --version --verbose:

rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: x86_64-unknown-linux-gnu
release: 1.65.0
LLVM version: 15.0.0

Error output

See errorlog.txt for a full log.

error: internal compiler error: compiler/rustc_middle/src/ty/context.rs:703:13: node_type: no type for node `expr {
                                        let res = $crate::fmt::format($crate::__export::format_args!($($arg)*));
                                        res
                                    } (hir_id=HirId { owner: DefId(0:72 ~ 2022[472a]::main), local_id: 265 })`
Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/897e37553bba8b42751c67658967889d11ecd120/compiler/rustc_errors/src/lib.rs:1462:9
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner>::bug::<&alloc::string::String>
   3: <rustc_errors::Handler>::bug::<&alloc::string::String>
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
   5: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
   6: rustc_middle::util::bug::bug_fmt
   7: <rustc_middle::ty::context::TypeckResults>::expr_ty_adjusted
   8: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt>::note_obligation_cause_code::<rustc_middle::ty::Predicate>
   9: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::note_obligation_cause
  10: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_selection_error
  11: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  12: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
  13: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
  14: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  15: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_decl
  16: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  17: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  18: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  20: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  21: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_match::{closure#0}
  22: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  23: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  24: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_match::{closure#0}
  26: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  27: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  29: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
  31: rustc_typeck::check::check::check_fn
  32: <rustc_infer::infer::InferCtxtBuilder>::enter::<&rustc_middle::ty::context::TypeckResults, <rustc_typeck::check::inherited::InheritedBuilder>::enter<rustc_typeck::check::typeck_with_fallback<rustc_typeck::check::typeck::{closure#0}>::{closure#1}, &rustc_middle::ty::context::TypeckResults>::{closure#0}>
  33: rustc_typeck::check::typeck
  34: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults>
  35: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults>>
  36: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  37: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_typeck::check::typeck_item_bodies::{closure#0}>::{closure#0}>
  38: rustc_typeck::check::typeck_item_bodies
  39: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), ()>
  40: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), ()>>
  41: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>
  42: <rustc_session::session::Session>::time::<(), rustc_typeck::check_crate::{closure#7}>
  43: rustc_typeck::check_crate
  44: rustc_interface::passes::analysis
  45: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  46: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorGuaranteed>>>
  47: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  48: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  49: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  50: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions