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

thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', when evaluating T: Unsize<T> #90804

Closed
espadolini opened this issue Nov 11, 2021 · 3 comments · Fixed by #90819
Assignees
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

@espadolini
Copy link

espadolini commented Nov 11, 2021

Code

#![feature(unsize)]

use std::marker::Unsize;

fn unsizing<T: Unsize<T>>(value: T) -> Box<T> {
    Box::new(value) as Box<T>
}

fn main() {
    unsizing::<()>(());
}

Meta

rustc --version --verbose:

rustc 1.58.0-nightly (82af160c2 2021-11-10)
binary: rustc
commit-hash: 82af160c2cb9c349a0373cba98d8ad7f911f0d34
commit-date: 2021-11-10
host: x86_64-apple-darwin
release: 1.58.0-nightly
LLVM version: 13.0.0

Error output

   Compiling unsizer v0.1.0 (/Users/username/unsizer)
thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', /rustc/82af160c2cb9c349a0373cba98d8ad7f911f0d34/compiler/rustc_middle/src/ty/subst.rs:311:43
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: <rustc_trait_selection::traits::select::SelectionContext>::assemble_candidates_for_unsizing
   4: <rustc_trait_selection::traits::select::SelectionContext>::assemble_candidates
   5: <rustc_trait_selection::traits::select::SelectionContext>::candidate_from_obligation_no_cache
   6: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_trait_selection::traits::select::SelectionContext>::in_task<<rustc_trait_selection::traits::select::SelectionContext>::candidate_from_obligation::{closure#0}, core::result::Result<core::option::Option<rustc_middle::traits::select::SelectionCandidate>, rustc_middle::traits::SelectionError>>::{closure#0}, core::result::Result<core::option::Option<rustc_middle::traits::select::SelectionCandidate>, rustc_middle::traits::SelectionError>>
   7: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_anon_task::<rustc_middle::ty::context::TyCtxt, <rustc_trait_selection::traits::select::SelectionContext>::in_task<<rustc_trait_selection::traits::select::SelectionContext>::candidate_from_obligation::{closure#0}, core::result::Result<core::option::Option<rustc_middle::traits::select::SelectionCandidate>, rustc_middle::traits::SelectionError>>::{closure#0}, core::result::Result<core::option::Option<rustc_middle::traits::select::SelectionCandidate>, rustc_middle::traits::SelectionError>>
   8: <rustc_trait_selection::traits::select::SelectionContext>::candidate_from_obligation
   9: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_stack
  10: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_trait_selection::traits::select::SelectionContext>::in_task<<rustc_trait_selection::traits::select::SelectionContext>::evaluate_trait_predicate_recursively::{closure#1}, core::result::Result<rustc_middle::traits::select::EvaluationResult, rustc_middle::traits::select::OverflowError>>::{closure#0}, core::result::Result<rustc_middle::traits::select::EvaluationResult, rustc_middle::traits::select::OverflowError>>
  11: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_anon_task::<rustc_middle::ty::context::TyCtxt, <rustc_trait_selection::traits::select::SelectionContext>::in_task<<rustc_trait_selection::traits::select::SelectionContext>::evaluate_trait_predicate_recursively::{closure#1}, core::result::Result<rustc_middle::traits::select::EvaluationResult, rustc_middle::traits::select::OverflowError>>::{closure#0}, core::result::Result<rustc_middle::traits::select::EvaluationResult, rustc_middle::traits::select::OverflowError>>
  12: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  13: rustc_data_structures::stack::ensure_sufficient_stack::<core::result::Result<rustc_middle::traits::select::EvaluationResult, rustc_middle::traits::select::OverflowError>, <rustc_trait_selection::traits::select::SelectionContext>::evaluate_predicate_recursively::{closure#0}>
  14: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_predicate_recursively
  15: <rustc_infer::infer::InferCtxt>::probe::<core::result::Result<rustc_middle::traits::select::EvaluationResult, rustc_middle::traits::select::OverflowError>, <rustc_trait_selection::traits::select::SelectionContext>::evaluation_probe<<rustc_trait_selection::traits::select::SelectionContext>::evaluate_root_obligation::{closure#0}>::{closure#0}>
  16: <rustc_trait_selection::traits::select::SelectionContext>::evaluate_root_obligation
  17: <rustc_infer::infer::InferCtxtBuilder>::enter_with_canonical::<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Predicate>, core::result::Result<rustc_middle::traits::select::EvaluationResult, rustc_middle::traits::select::OverflowError>, rustc_traits::evaluate_obligation::evaluate_obligation::{closure#0}>
  18: rustc_traits::evaluate_obligation::evaluate_obligation
  19: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task_impl<rustc_middle::ty::context::TyCtxt, rustc_middle::infer::canonical::Canonical<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Predicate>>, core::result::Result<rustc_middle::traits::select::EvaluationResult, rustc_middle::traits::select::OverflowError>>::{closure#0}, core::result::Result<rustc_middle::traits::select::EvaluationResult, rustc_middle::traits::select::OverflowError>>
  20: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_middle::infer::canonical::Canonical<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Predicate>>, core::result::Result<rustc_middle::traits::select::EvaluationResult, rustc_middle::traits::select::OverflowError>>
  21: rustc_data_structures::stack::ensure_sufficient_stack::<(core::result::Result<rustc_middle::traits::select::EvaluationResult, rustc_middle::traits::select::OverflowError>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, rustc_middle::infer::canonical::Canonical<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Predicate>>, core::result::Result<rustc_middle::traits::select::EvaluationResult, rustc_middle::traits::select::OverflowError>>::{closure#3}>
  22: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::evaluate_obligation, rustc_query_impl::plumbing::QueryCtxt>
  23: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::evaluate_obligation
  24: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
  25: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  26: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt>::suggest_add_reference_to_arg::{closure#1}
  27: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt>::suggest_add_reference_to_arg
  28: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_selection_error
  29: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  30: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
  31: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_argument_types
  32: <rustc_typeck::check::fn_ctxt::FnCtxt>::confirm_builtin_call
  33: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
  34: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  35: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  36: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
  37: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  38: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  39: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
  40: rustc_typeck::check::check::check_fn
  41: <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}>
  42: rustc_typeck::check::typeck
  43: <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>
  44: rustc_data_structures::stack::ensure_sufficient_stack::<(&rustc_middle::ty::context::TypeckResults, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults>::{closure#3}>
  45: 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>>
  46: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::typeck, rustc_query_impl::plumbing::QueryCtxt>
  47: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_typeck::check::typeck_item_bodies::{closure#0}>
  48: rustc_typeck::check::typeck_item_bodies
  49: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), ()>
  50: rustc_data_structures::stack::ensure_sufficient_stack::<((), rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (), ()>::{closure#3}>
  51: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), ()>>
  52: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>
  53: <rustc_session::session::Session>::time::<(), rustc_typeck::check_crate::{closure#7}>
  54: rustc_typeck::check_crate
  55: rustc_interface::passes::analysis
  56: <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::ErrorReported>>
  57: rustc_data_structures::stack::ensure_sufficient_stack::<(core::result::Result<(), rustc_errors::ErrorReported>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>::{closure#3}>
  58: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorReported>>>
  59: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  60: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorReported>>
  61: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
  62: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}>
  63: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

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.58.0-nightly (82af160c2 2021-11-10) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `&'static (): core::marker::Unsize`
#1 [typeck] type-checking `main`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
error: internal compiler error: trimmed_def_paths constructed
  |
  = note: delayed at    0: std::backtrace::Backtrace::create
             1: std::backtrace::Backtrace::force_capture
             2: <rustc_errors::Handler>::delay_good_path_bug
             3: rustc_middle::ty::print::pretty::trimmed_def_paths
             4: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), std::collections::hash::map::HashMap<rustc_span::def_id::DefId, rustc_span::symbol::Symbol, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>>
             5: rustc_data_structures::stack::ensure_sufficient_stack::<(std::collections::hash::map::HashMap<rustc_span::def_id::DefId, rustc_span::symbol::Symbol, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (), std::collections::hash::map::HashMap<rustc_span::def_id::DefId, rustc_span::symbol::Symbol, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>>::{closure#3}>
             6: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::ArenaCache<(), std::collections::hash::map::HashMap<rustc_span::def_id::DefId, rustc_span::symbol::Symbol, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>>>
             7: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::trimmed_def_paths, rustc_query_impl::plumbing::QueryCtxt>
             8: <rustc_middle::ty::print::pretty::FmtPrinter<&mut core::fmt::Formatter> as rustc_middle::ty::print::Printer>::print_def_path
             9: <rustc_middle::ty::print::pretty::FmtPrinter<&mut core::fmt::Formatter> as rustc_middle::ty::print::Printer>::default_print_def_path
            10: <rustc_middle::ty::print::pretty::FmtPrinter<&mut core::fmt::Formatter> as rustc_middle::ty::print::Printer>::print_def_path
            11: <rustc_middle::ty::TraitPredicate as rustc_middle::ty::print::Print<rustc_middle::ty::print::pretty::FmtPrinter<&mut core::fmt::Formatter>>>::print
            12: <rustc_middle::ty::PredicateKind as rustc_middle::ty::print::Print<rustc_middle::ty::print::pretty::FmtPrinter<&mut core::fmt::Formatter>>>::print
            13: <rustc_middle::ty::print::pretty::FmtPrinter<&mut core::fmt::Formatter> as rustc_middle::ty::print::pretty::PrettyPrinter>::in_binder::<rustc_middle::ty::PredicateKind>
            14: <rustc_middle::ty::Predicate as core::fmt::Display>::fmt
            15: core::fmt::write
            16: alloc::fmt::format
            17: <core::option::Option<alloc::string::String>>::unwrap_or_else::<<rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_selection_error::{closure#8}>
            18: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_selection_error
            19: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
            20: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
            21: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_argument_types
            22: <rustc_typeck::check::fn_ctxt::FnCtxt>::confirm_builtin_call
            23: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
            24: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
            25: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
            26: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
            27: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
            28: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
            29: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
            30: rustc_typeck::check::check::check_fn
            31: <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}>
            32: rustc_typeck::check::typeck
            33: <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>
            34: rustc_data_structures::stack::ensure_sufficient_stack::<(&rustc_middle::ty::context::TypeckResults, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults>::{closure#3}>
            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_system::query::plumbing::get_query::<rustc_query_impl::queries::typeck, rustc_query_impl::plumbing::QueryCtxt>
            37: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_typeck::check::typeck_item_bodies::{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_data_structures::stack::ensure_sufficient_stack::<((), rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (), ()>::{closure#3}>
            41: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), ()>>
            42: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>
            43: <rustc_session::session::Session>::time::<(), rustc_typeck::check_crate::{closure#7}>
            44: rustc_typeck::check_crate
            45: rustc_interface::passes::analysis
            46: <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::ErrorReported>>
            47: rustc_data_structures::stack::ensure_sufficient_stack::<(core::result::Result<(), rustc_errors::ErrorReported>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>::{closure#3}>
            48: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorReported>>>
            49: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
            50: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorReported>>
            51: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
            52: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}>
            53: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
            54: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
            55: <<std::thread::Builder>::spawn_unchecked<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            56: std::sys::unix::thread::Thread::new::thread_start
            57: __pthread_start
          

thread 'rustc' panicked at 'no warnings or errors encountered even though `delayed_good_path_bugs` issued', compiler/rustc_errors/src/lib.rs:1188:13
stack backtrace:
   0:        0x103f4f861 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9c9c2c58a5e55211
   1:        0x103fa072b - core::fmt::write::h2d5ecb4b9764759c
   2:        0x103f40e3a - std::io::Write::write_fmt::hbb2ed9492eac32a2
   3:        0x103f529c5 - std::panicking::default_hook::{{closure}}::h39365228a3bf0aa2
   4:        0x103f525af - std::panicking::default_hook::h8ca622aa16a42db0
   5:        0x11375e620 - rustc_driver[8702e6016a2d953f]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:        0x103f53206 - std::panicking::rust_panic_with_hook::ha8b89b2b3829767b
   7:        0x103f52c7e - std::panicking::begin_panic_handler::{{closure}}::h92845c1f420a7f41
   8:        0x103f4fce7 - std::sys_common::backtrace::__rust_end_short_backtrace::hdae352311dc8769f
   9:        0x103f52bea - _rust_begin_unwind
  10:        0x103fcb59f - core::panicking::panic_fmt::h88a1b6fbb9084d2c
  11:        0x117e15f02 - core[f4889159fda6615f]::panicking::panic_display::<&str>
  12:        0x117e1d0c5 - <rustc_errors[7f9540041f075328]::HandlerInner>::flush_delayed
  13:        0x117e1939d - <rustc_errors[7f9540041f075328]::HandlerInner as core[f4889159fda6615f]::ops::drop::Drop>::drop
  14:        0x1137d736a - core[f4889159fda6615f]::ptr::drop_in_place::<rustc_session[84d5bb8c04871b82]::parse::ParseSess>
  15:        0x1137e0237 - <alloc[6b2a4c4c8c58ee9a]::rc::Rc<rustc_session[84d5bb8c04871b82]::session::Session> as core[f4889159fda6615f]::ops::drop::Drop>::drop
  16:        0x11376fc12 - core[f4889159fda6615f]::ptr::drop_in_place::<rustc_interface[36a618782d12d380]::interface::Compiler>
  17:        0x11376da04 - rustc_span[a08cc5ade0305263]::with_source_map::<core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>, rustc_interface[36a618782d12d380]::interface::create_compiler_and_run<core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>, rustc_driver[8702e6016a2d953f]::run_compiler::{closure#1}>::{closure#0}>
  18:        0x1137aaa8c - <scoped_tls[504a04b5a30bb02b]::ScopedKey<rustc_span[a08cc5ade0305263]::SessionGlobals>>::set::<rustc_interface[36a618782d12d380]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[36a618782d12d380]::interface::run_compiler<core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>, rustc_driver[8702e6016a2d953f]::run_compiler::{closure#1}>::{closure#0}, core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>::{closure#0}::{closure#0}, core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>
  19:        0x113777642 - std[69c2830741c23f7e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[36a618782d12d380]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[36a618782d12d380]::interface::run_compiler<core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>, rustc_driver[8702e6016a2d953f]::run_compiler::{closure#1}>::{closure#0}, core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>::{closure#0}, core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>
  20:        0x113764435 - <<std[69c2830741c23f7e]::thread::Builder>::spawn_unchecked<rustc_interface[36a618782d12d380]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[36a618782d12d380]::interface::run_compiler<core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>, rustc_driver[8702e6016a2d953f]::run_compiler::{closure#1}>::{closure#0}, core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>::{closure#0}, core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>::{closure#1} as core[f4889159fda6615f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  21:        0x103f5d017 - std::sys::unix::thread::Thread::new::thread_start::h96b3fd9d7d5e1337
  22:     0x7ff809660514 - __pthread_start

error: internal compiler error: unexpected panic

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.58.0-nightly (82af160c2 2021-11-10) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
error: could not compile `unsizer`

Caused by:
  process didn't exit successfully: `rustc --crate-name unsizer --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=380a342bcf3da8e7 -C extra-filename=-380a342bcf3da8e7 --out-dir /Users/username/unsizer/target/debug/deps -C incremental=/Users/username/unsizer/target/debug/incremental -L dependency=/Users/username/unsizer/target/debug/deps` (signal: 4, SIGILL: illegal instruction)
@espadolini espadolini 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 11, 2021
@espadolini
Copy link
Author

espadolini commented Nov 11, 2021

For what it's worth, it also ICEs on stable, after the stability check:

   Compiling unsizer v0.1.0 (/Users/username/unsizer)
error[E0554]: `#![feature]` may not be used on the stable release channel
 --> src/main.rs:1:1
  |
1 | #![feature(unsize)]
  | ^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/compiler/rustc_middle/src/ty/subst.rs:303:43
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

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.56.1 (59eed8a2a 2021-11-01) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `&'static (): std::marker::Unsize`
#1 [typeck] type-checking `main`
end of query stack
For more information about this error, try `rustc --explain E0554`.
error: could not compile `unsizer` due to previous error

@espadolini
Copy link
Author

The minimal code example uses T: Unsize<T> but the bug was initially triggered by using two different generic parameters, T: ?Sized, S: Unsize<T>, and calling the function with the same (sized) type for both parameters.

@JakobDegen
Copy link
Contributor

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 14, 2021
Fixes incorrect handling of TraitRefs when emitting suggestions.

Closes rust-lang#90804 , although there were more issues here that were hidden by the thing that caused this ICE.

Underlying problem was that substitutions were being thrown out, which not only leads to an ICE but also incorrect diagnostics. On top of that, in some cases the self types from the root obligations were being mixed in with those from derived obligations.

This makes a couple diagnostics arguable worse ("`B<C>` does not implement `Copy`" instead of "`C` does not implement `Copy`") but the worse diagnostics are at least still correct and that downside is in my opinion clearly outweighed by the benefits of fixing the ICE and unambiguously wrong diagnostics.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 15, 2021
Fixes incorrect handling of TraitRefs when emitting suggestions.

Closes rust-lang#90804 , although there were more issues here that were hidden by the thing that caused this ICE.

Underlying problem was that substitutions were being thrown out, which not only leads to an ICE but also incorrect diagnostics. On top of that, in some cases the self types from the root obligations were being mixed in with those from derived obligations.

This makes a couple diagnostics arguable worse ("`B<C>` does not implement `Copy`" instead of "`C` does not implement `Copy`") but the worse diagnostics are at least still correct and that downside is in my opinion clearly outweighed by the benefits of fixing the ICE and unambiguously wrong diagnostics.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 15, 2021
Fixes incorrect handling of TraitRefs when emitting suggestions.

Closes rust-lang#90804 , although there were more issues here that were hidden by the thing that caused this ICE.

Underlying problem was that substitutions were being thrown out, which not only leads to an ICE but also incorrect diagnostics. On top of that, in some cases the self types from the root obligations were being mixed in with those from derived obligations.

This makes a couple diagnostics arguable worse ("`B<C>` does not implement `Copy`" instead of "`C` does not implement `Copy`") but the worse diagnostics are at least still correct and that downside is in my opinion clearly outweighed by the benefits of fixing the ICE and unambiguously wrong diagnostics.
JohnTitor added a commit to JohnTitor/rust that referenced this issue Nov 16, 2021
Fixes incorrect handling of TraitRefs when emitting suggestions.

Closes rust-lang#90804 , although there were more issues here that were hidden by the thing that caused this ICE.

Underlying problem was that substitutions were being thrown out, which not only leads to an ICE but also incorrect diagnostics. On top of that, in some cases the self types from the root obligations were being mixed in with those from derived obligations.

This makes a couple diagnostics arguable worse ("`B<C>` does not implement `Copy`" instead of "`C` does not implement `Copy`") but the worse diagnostics are at least still correct and that downside is in my opinion clearly outweighed by the benefits of fixing the ICE and unambiguously wrong diagnostics.
@bors bors closed this as completed in d44cec3 Nov 16, 2021
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.

2 participants