Skip to content

ICE with mismatch in trait associated constant #105632

Closed

Description

@jruderman

Code

#![feature(associated_const_equality)]
#![allow(dead_code)]

trait TraitWAssocConst {
    const A: usize;
}

fn foo<T: TraitWAssocConst<A = 1>>() {}

fn bar<T: TraitWAssocConst<A = 0>>() {
    foo::<T>();
}

fn main() {}

Error output

thread <unnamed> panicked at 'called Option::unwrap() on a None value', compiler/rustc_trait_selection/src/traits/project.rs:562

Backtrace
   0:        0x10ebef796 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd6dea84f06cc919a
   1:        0x10ec4e15a - core::fmt::write::h91ecc43dcb5a87d3
   2:        0x10ebe1c5c - std::io::Write::write_fmt::hc922635edee92051
   3:        0x10ebef57a - std::sys_common::backtrace::print::h86bd5791976d67a9
   4:        0x10ebf28e3 - std::panicking::default_hook::{{closure}}::h32c4d35e1d887df2
   5:        0x10ebf2638 - std::panicking::default_hook::hcd90b2b89f8c0e15
   6:        0x10ebf30a3 - std::panicking::rust_panic_with_hook::h9198f3fe823c744c
   7:        0x10ebf2e33 - std::panicking::begin_panic_handler::{{closure}}::h935bfbd23a054b53
   8:        0x10ebefc38 - std::sys_common::backtrace::__rust_end_short_backtrace::h1a500d61b73a0659
   9:        0x10ebf2b3d - _rust_begin_unwind
  10:        0x10ec7a903 - core::panicking::panic_fmt::he9045b6279698c2c
  11:        0x10ec7a9d7 - core::panicking::panic::h8341ec280685e050
  12:        0x11a8be735 - <rustc_trait_selection[a1a4268d0f076ce6]::traits::project::AssocTypeNormalizer as rustc_middle[81f54e6dd5330834]::ty::fold::TypeFolder>::fold_ty
  13:        0x11a8bd618 - <rustc_trait_selection[a1a4268d0f076ce6]::traits::project::AssocTypeNormalizer>::fold::<rustc_middle[81f54e6dd5330834]::ty::Ty>
  14:        0x11a8c4bd7 - rustc_trait_selection[a1a4268d0f076ce6]::traits::project::normalize_with_depth_to::<rustc_middle[81f54e6dd5330834]::ty::Ty>
  15:        0x11a955d8f - <rustc_infer[4bee525d6ce90e13]::infer::at::At as rustc_trait_selection[a1a4268d0f076ce6]::traits::project::NormalizeExt>::normalize::<rustc_middle[81f54e6dd5330834]::ty::Ty>
  16:        0x11a9f3d4e - <rustc_trait_selection[a1a4268d0f076ce6]::traits::engine::ObligationCtxt>::normalize::<rustc_middle[81f54e6dd5330834]::ty::Ty>
  17:        0x11a9344f5 - <rustc_infer[4bee525d6ce90e13]::infer::InferCtxt>::probe::<(), <rustc_infer[4bee525d6ce90e13]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[a1a4268d0f076ce6]::traits::error_reporting::InferCtxtPrivExt>::report_projection_error::{closure#0}>
  18:        0x11a9deb24 - <rustc_infer[4bee525d6ce90e13]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[a1a4268d0f076ce6]::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  19:        0x11a9cd0a3 - <rustc_infer[4bee525d6ce90e13]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[a1a4268d0f076ce6]::traits::error_reporting::TypeErrCtxtExt>::report_fulfillment_errors
  20:        0x11911a1ff - <rustc_hir_typeck[207f971536c734c5]::fn_ctxt::FnCtxt>::check_argument_types
  21:        0x1190f3bd4 - <rustc_hir_typeck[207f971536c734c5]::fn_ctxt::FnCtxt>::confirm_builtin_call
  22:        0x1190f0add - <rustc_hir_typeck[207f971536c734c5]::fn_ctxt::FnCtxt>::check_call
  23:        0x1191710cd - <rustc_hir_typeck[207f971536c734c5]::fn_ctxt::FnCtxt>::check_expr_kind
  24:        0x119107c8f - <rustc_hir_typeck[207f971536c734c5]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25:        0x119122505 - <rustc_hir_typeck[207f971536c734c5]::fn_ctxt::FnCtxt>::check_stmt
  26:        0x119122c2f - <rustc_hir_typeck[207f971536c734c5]::fn_ctxt::FnCtxt>::check_block_with_expected
  27:        0x1191714af - <rustc_hir_typeck[207f971536c734c5]::fn_ctxt::FnCtxt>::check_expr_kind
  28:        0x119107c8f - <rustc_hir_typeck[207f971536c734c5]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  29:        0x119109850 - <rustc_hir_typeck[207f971536c734c5]::fn_ctxt::FnCtxt>::check_return_expr
  30:        0x1192adeed - rustc_hir_typeck[207f971536c734c5]::check::check_fn
  31:        0x119218f1a - <rustc_hir_typeck[207f971536c734c5]::inherited::InheritedBuilder>::enter::<rustc_hir_typeck[207f971536c734c5]::typeck_with_fallback<rustc_hir_typeck[207f971536c734c5]::typeck::{closure#0}>::{closure#0}::{closure#1}, &rustc_middle[81f54e6dd5330834]::ty::context::TypeckResults>
  32:        0x119241089 - rustc_hir_typeck[207f971536c734c5]::typeck
  33:        0x11a11fa39 - rustc_query_system[179a71b5a36883c6]::query::plumbing::try_execute_query::<rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt, rustc_query_system[179a71b5a36883c6]::query::caches::VecCache<rustc_span[e3bcd7e2de09f7c3]::def_id::LocalDefId, &rustc_middle[81f54e6dd5330834]::ty::context::TypeckResults>>
  34:        0x11a19f144 - rustc_query_system[179a71b5a36883c6]::query::plumbing::get_query::<rustc_query_impl[964bc029a4576ad4]::queries::typeck, rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt>
  35:        0x1192be777 - std[e9f68177e3155681]::panicking::try::<(), core[d953718cd3bcc963]::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures[69a6efa400d2eccf]::sync::par_for_each_in<&[rustc_span[e3bcd7e2de09f7c3]::def_id::LocalDefId], <rustc_middle[81f54e6dd5330834]::hir::map::Map>::par_body_owners<rustc_hir_typeck[207f971536c734c5]::typeck_item_bodies::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}>>
  36:        0x1192bcbf5 - rustc_data_structures[69a6efa400d2eccf]::sync::par_for_each_in::<&[rustc_span[e3bcd7e2de09f7c3]::def_id::LocalDefId], <rustc_middle[81f54e6dd5330834]::hir::map::Map>::par_body_owners<rustc_hir_typeck[207f971536c734c5]::typeck_item_bodies::{closure#0}>::{closure#0}>
  37:        0x119240737 - rustc_hir_typeck[207f971536c734c5]::typeck_item_bodies
  38:        0x11a0ed6b4 - rustc_query_system[179a71b5a36883c6]::query::plumbing::try_execute_query::<rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt, rustc_query_system[179a71b5a36883c6]::query::caches::DefaultCache<(), ()>>
  39:        0x11a1920b1 - rustc_query_system[179a71b5a36883c6]::query::plumbing::get_query::<rustc_query_impl[964bc029a4576ad4]::queries::typeck_item_bodies, rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt>
  40:        0x118f6e863 - <rustc_session[78db928f84e94300]::session::Session>::time::<(), rustc_hir_analysis[7e82910673f8c84]::check_crate::{closure#7}>
  41:        0x118fbb1a6 - rustc_hir_analysis[7e82910673f8c84]::check_crate
  42:        0x1194decb0 - rustc_interface[9fb4355f0ea261b0]::passes::analysis
  43:        0x11a0dc482 - rustc_query_system[179a71b5a36883c6]::query::plumbing::try_execute_query::<rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt, rustc_query_system[179a71b5a36883c6]::query::caches::DefaultCache<(), core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>>
  44:        0x11a19f521 - rustc_query_system[179a71b5a36883c6]::query::plumbing::get_query::<rustc_query_impl[964bc029a4576ad4]::queries::analysis, rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt>
  45:        0x118c4160a - <rustc_interface[9fb4355f0ea261b0]::passes::QueryContext>::enter::<rustc_driver[f5ca9ba73eed523d]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>
  46:        0x118c899cb - rustc_span[e3bcd7e2de09f7c3]::with_source_map::<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_interface[9fb4355f0ea261b0]::interface::run_compiler<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_driver[f5ca9ba73eed523d]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  47:        0x118c7b8ee - <scoped_tls[10e5aad72c190240]::ScopedKey<rustc_span[e3bcd7e2de09f7c3]::SessionGlobals>>::set::<rustc_interface[9fb4355f0ea261b0]::interface::run_compiler<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_driver[f5ca9ba73eed523d]::run_compiler::{closure#1}>::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>
  48:        0x118c4a3b7 - std[e9f68177e3155681]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[9fb4355f0ea261b0]::util::run_in_thread_pool_with_globals<rustc_interface[9fb4355f0ea261b0]::interface::run_compiler<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_driver[f5ca9ba73eed523d]::run_compiler::{closure#1}>::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>
  49:        0x118c2cdb9 - <<std[e9f68177e3155681]::thread::Builder>::spawn_unchecked_<rustc_interface[9fb4355f0ea261b0]::util::run_in_thread_pool_with_globals<rustc_interface[9fb4355f0ea261b0]::interface::run_compiler<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_driver[f5ca9ba73eed523d]::run_compiler::{closure#1}>::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>::{closure#1} as core[d953718cd3bcc963]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  50:        0x11ac1f3a7 - std::sys::unix::thread::Thread::new::thread_start::h6bf891e61773eb8a
  51:     0x7ff80c3874e1 - __pthread_start

Regression

Regression in nightly-2022-12-04, in rollup 24f2704, likely from #104903 (@spastorino, @lcnr)

Version

rustc 1.68.0-nightly (bdb07a8ec 2022-12-11)
binary: rustc
commit-hash: bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4
commit-date: 2022-12-11
host: x86_64-apple-darwin
release: 1.68.0-nightly
LLVM version: 15.0.6

Activity

  1. added
    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.
    on Dec 12, 2022
  2. added 5 commits that reference this issue on Dec 14, 2022
    ae6dfa6
    d2b716d
    b9e0d60
    968b053
    78cf8cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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