Skip to content

Can't hash a TyVid _#0t with complex generic constants in trait selection #77650

Closed
@zeyonaut

Description

@zeyonaut

Code

#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]
fn c<T, const N: core::num::NonZeroUsize>() where [T; N.get()]: Sized {
	use core::convert::TryFrom;
	<[T; N.get()]>::try_from(())
}

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (98edd1fbf 2020-10-06)
binary: rustc
commit-hash: 98edd1fbf8a68977a2a7c1312eb1ebff80515a92
commit-date: 2020-10-06
host: x86_64-pc-windows-msvc
release: 1.49.0-nightly
LLVM version: 11.0

Error output

cargo check

error: internal compiler error: compiler\rustc_middle\src\ich\impls_ty.rs:167:9: ty::TyKind::hash_stable() - can't hash a TyVid _#0t.

thread 'rustc' panicked at 'Box<Any>', compiler\rustc_errors\src\lib.rs:945:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.49.0-nightly (98edd1fbf 2020-10-06) running on x86_64-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

stack backtrace:
   0:     0x7ff949529859 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc20a26e0f7659afd
   1:     0x7ff949556f8b - core::fmt::write::h435be716304d26a1
   2:     0x7ff94951b1d8 - <std::io::IoSlice as core::fmt::Debug>::fmt::h997d94c78f1ba97b
   3:     0x7ff94952ec44 - std::panicking::take_hook::hbf7e33d26fc3ca30
   4:     0x7ff94952e828 - std::panicking::take_hook::hbf7e33d26fc3ca30
   5:     0x7ff903296257 - rustc_driver::report_ice::hf0a13013cc3176ab
   6:     0x7ff94952f6a0 - std::panicking::rust_panic_with_hook::h19068ccbe4b337a1
   7:     0x7ff9079441a0 - <rustc_errors::snippet::Style as core::fmt::Debug>::fmt::h154d3f8b7cc27034
   8:     0x7ff9079440c9 - <rustc_errors::snippet::Style as core::fmt::Debug>::fmt::h154d3f8b7cc27034
   9:     0x7ff907944111 - <rustc_errors::snippet::Style as core::fmt::Debug>::fmt::h154d3f8b7cc27034
  10:     0x7ff90797712f - rustc_errors::HandlerInner::err_count::hc7ff30e58befa0c0
  11:     0x7ff9079757e2 - rustc_errors::Handler::bug::h9f679e586b05b709
  12:     0x7ff9074039df - rustc_middle::util::bug::bug_fmt::h60c898222be388c9
  13:     0x7ff907402380 - rustc_middle::ty::walk::<impl rustc_middle::ty::subst::GenericArg>::walk_shallow::h6736da826cdc0fb1
  14:     0x7ff907401c33 - rustc_middle::ty::walk::<impl rustc_middle::ty::subst::GenericArg>::walk_shallow::h6736da826cdc0fb1
  15:     0x7ff90740390c - rustc_middle::util::bug::bug_fmt::h60c898222be388c9
  16:     0x7ff907403870 - rustc_middle::util::bug::bug_fmt::h60c898222be388c9
  17:     0x7ff90746c657 - rustc_middle::ich::impls_ty::<impl rustc_data_structures::stable_hasher::HashStable<rustc_middle::ich::hcx::StableHashingContext> for rustc_middle::ty::sty::TyVid>::hash_stable::he85cc0b432224c1c
  18:     0x7ff907481be7 - ZN12rustc_middle2ty3sty108_DERIVE_rustc_data_structures_stable_hasher_HashStable_rustc_middle_ich_StableHashingContext_ctx_FOR_InferTy161_$LT$impl$u20$rustc_data_structures..stable_hasher..HashStable$LT$rustc_middle..ich..hcx..StableHashingContext$GT$$u20
  19:     0x7ff905533322 - rustc_ty::provide::hc4eaf8b508875cf0
  20:     0x7ff9072355c7 - <rustc_infer::infer::error_reporting::nice_region_error::util::AnonymousParamInfo as core::fmt::Debug>::fmt::h7efdbeeecf550314
  21:     0x7ff90723af2a - <rustc_infer::infer::error_reporting::nice_region_error::util::AnonymousParamInfo as core::fmt::Debug>::fmt::h7efdbeeecf550314
  22:     0x7ff90720b225 - <rustc_infer::traits::project::ProjectionCacheEntry as core::fmt::Debug>::fmt::h0a95a64bb725d4ab
  23:     0x7ff9071ad6f8 - <rustc_infer::infer::region_constraints::TaintDirections as core::fmt::Debug>::fmt::h8e4875807837cabe
  24:     0x7ff907182fbc - <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::consts::hf0afc3d1c8a957dc
  25:     0x7ff9071a81e5 - <rustc_infer::infer::region_constraints::TaintDirections as core::fmt::Debug>::fmt::h8e4875807837cabe
  26:     0x7ff907182818 - <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::tys::h7c217f6064efedb5
  27:     0x7ff907181c18 - <rustc_infer::infer::equate::Equate as rustc_middle::ty::relate::TypeRelation>::consts::h63f8ea93cf718eaf
  28:     0x7ff907183ae3 - <rustc_infer::infer::equate::Equate as rustc_middle::ty::relate::TypeRelation>::tys::h647abfd8cf27091c
  29:     0x7ff907004488 - <rustc_trait_selection::traits::structural_match::NonStructuralMatchTy as core::fmt::Debug>::fmt::h64985691e98f414f
  30:     0x7ff9070d0001 - <rustc_trait_selection::traits::specialize::OverlapError as core::fmt::Debug>::fmt::hc34c9b365e0fa69c
  31:     0x7ff9070003b7 - <rustc_trait_selection::traits::structural_match::NonStructuralMatchTy as core::fmt::Debug>::fmt::h64985691e98f414f
  32:     0x7ff9070f74ad - <rustc_trait_selection::traits::specialize::OverlapError as core::fmt::Debug>::fmt::hc34c9b365e0fa69c
  33:     0x7ff906f3b2e6 - unicode_normalization::__test_api::stream_safe::h690fea7d6b5af898
  34:     0x7ff906f9243d - rustc_trait_selection::traits::select::SelectionContext::coinductive_predicate::h6b6e77acf8c0a35c
  35:     0x7ff906f3fdad - unicode_normalization::__test_api::stream_safe::h690fea7d6b5af898
  36:     0x7ff906fc3d45 - <rustc_middle::ty::Predicate as rustc_trait_selection::traits::query::type_op::normalize::Normalizable>::type_op_method::h46c94790e3ea7f8c
  37:     0x7ff906f879ed - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::outlives_bounds::InferCtxtExt>::implied_outlives_bounds::hdd7fd10f01368aed
  38:     0x7ff906f868a6 - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::outlives_bounds::InferCtxtExt>::implied_outlives_bounds::hdd7fd10f01368aed
  39:     0x7ff906f848cc - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::outlives_bounds::InferCtxtExt>::implied_outlives_bounds::hdd7fd10f01368aed
  40:     0x7ff9070d8898 - <rustc_trait_selection::traits::specialize::OverlapError as core::fmt::Debug>::fmt::hc34c9b365e0fa69c
  41:     0x7ff906f73735 - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::outlives_bounds::InferCtxtExt>::implied_outlives_bounds::hdd7fd10f01368aed
  42:     0x7ff906f83b3b - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::outlives_bounds::InferCtxtExt>::implied_outlives_bounds::hdd7fd10f01368aed
  43:     0x7ff906f8f661 - rustc_trait_selection::traits::select::SelectionContext::evaluate_root_obligation::h2250270a1f7a05c8
  44:     0x7ff9070d9910 - <rustc_trait_selection::traits::specialize::OverlapError as core::fmt::Debug>::fmt::hc34c9b365e0fa69c
  45:     0x7ff906f713f3 - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::outlives_bounds::InferCtxtExt>::implied_outlives_bounds::hdd7fd10f01368aed
  46:     0x7ff906f8eb59 - rustc_trait_selection::traits::select::SelectionContext::evaluate_root_obligation::h2250270a1f7a05c8
  47:     0x7ff9070de1ff - <rustc_trait_selection::traits::specialize::OverlapError as core::fmt::Debug>::fmt::hc34c9b365e0fa69c
  48:     0x7ff906f8e420 - rustc_trait_selection::traits::select::SelectionContext::evaluate_root_obligation::h2250270a1f7a05c8
  49:     0x7ff906f3fbf2 - unicode_normalization::__test_api::stream_safe::h690fea7d6b5af898
  50:     0x7ff906f8df20 - rustc_trait_selection::traits::select::SelectionContext::evaluate_root_obligation::h2250270a1f7a05c8
  51:     0x7ff9055cd2c8 - <rustc_middle::ty::sty::TraitRef as rustc_traits::chalk::lowering::LowerInto<chalk_solve::rust_ir::TraitBound<rustc_middle::traits::chalk::RustInterner>>>::lower_into::h206a34999f983c8d
  52:     0x7ff90563399d - <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_traits::chalk::lowering::LowerInto<chalk_ir::Substitution<rustc_middle::traits::chalk::RustInterner>>>::lower_into::h1abdda0443bed3bb
  53:     0x7ff906f47000 - unicode_normalization::__test_api::stream_safe::h690fea7d6b5af898
  54:     0x7ff9070d745c - <rustc_trait_selection::traits::specialize::OverlapError as core::fmt::Debug>::fmt::hc34c9b365e0fa69c
  55:     0x7ff906f7a65c - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::outlives_bounds::InferCtxtExt>::implied_outlives_bounds::hdd7fd10f01368aed
  56:     0x7ff9070e3822 - <rustc_trait_selection::traits::specialize::OverlapError as core::fmt::Debug>::fmt::hc34c9b365e0fa69c
  57:     0x7ff90705e573 - <rustc_trait_selection::traits::specialize::OverlapError as core::fmt::Debug>::fmt::hc34c9b365e0fa69c
  58:     0x7ff906f6e29b - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation::h8db5c0de92844531
  59:     0x7ff906f6e35d - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow::h053728187dff94ae
  60:     0x7ff906f6d0dd - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::predicate_can_apply::h83d3d17d6eca8cd9
  61:     0x7ff906f6401c - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_selection_error::he2084dd47d6a63e7
  62:     0x7ff906f68ced - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error::h0ef495573412ebc9
  63:     0x7ff906f59b68 - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors::hcac8181ca5516371
  64:     0x7ff905914b13 - rustc_typeck::check::fn_ctxt::FnCtxt::self_type_matches_expected_vid::h303bc981a63090bc
  65:     0x7ff9058ebd20 - rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call::hc77d949c0a735f07
  66:     0x7ff9058e9626 - rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call::hc77d949c0a735f07
  67:     0x7ff9058fe791 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation::h669de37db836f047
  68:     0x7ff9058fdf76 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation::h669de37db836f047
  69:     0x7ff905919d96 - rustc_typeck::check::fn_ctxt::FnCtxt::check_block_no_value::hd87c74780cf92ed8
  70:     0x7ff9058fe53c - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation::h669de37db836f047
  71:     0x7ff9058fdf76 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation::h669de37db836f047
  72:     0x7ff9059089f8 - rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation::h669de37db836f047
  73:     0x7ff905a04c00 - rustc_typeck::check::check::check_wf_new::h7470c2936cbb4783
  74:     0x7ff905b48669 - <rustc_typeck::variance::terms::InferredIndex as core::fmt::Debug>::fmt::h30130af156673c1b
  75:     0x7ff905ba36ef - <rustc_typeck::check::fixup_opaque_types::FixupFolder as rustc_middle::ty::fold::TypeFolder>::fold_ty::h6632bf304b0f133e
  76:     0x7ff905aeff6e - <rustc_typeck::bounds::Bounds as core::fmt::Debug>::fmt::hd2d90731af763459
  77:     0x7ff905a17756 - <rustc_typeck::check::check::check_opaque_for_inheriting_lifetimes::ProhibitOpaqueVisitor as core::fmt::Debug>::fmt::h6f94ef8e05dad7f7
  78:     0x7ff905ac4537 - <<rustc_typeck::collect::const_evaluatable_predicates_of::ConstCollector as rustc_hir::intravisit::Visitor>::visit_ty::TyAliasVisitor as rustc_middle::ty::fold::TypeVisitor>::visit_const::hf8b5df8275e77bc5
  79:     0x7ff905a66dbd - rustc_typeck::check::cast::CastCheck::do_check::h89d6d0a90ea63ed1
  80:     0x7ff90596667e - rustc_typeck::check::writeback::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::resolve_type_vars_in_body::h94c00915f034e1d5
  81:     0x7ff9059ec122 - rustc_typeck::check::writeback::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::resolve_type_vars_in_body::h94c00915f034e1d5
  82:     0x7ff905ba8f74 - <rustc_typeck::check::CheckItemTypesVisitor as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item::h7adf3d78f139a967
  83:     0x7ff905ab67dd - <<rustc_typeck::collect::const_evaluatable_predicates_of::ConstCollector as rustc_hir::intravisit::Visitor>::visit_ty::TyAliasVisitor as rustc_middle::ty::fold::TypeVisitor>::visit_const::hf8b5df8275e77bc5
  84:     0x7ff905a19646 - <rustc_typeck::check::check::check_opaque_for_inheriting_lifetimes::ProhibitOpaqueVisitor as core::fmt::Debug>::fmt::h6f94ef8e05dad7f7
  85:     0x7ff905ac3e9f - <<rustc_typeck::collect::const_evaluatable_predicates_of::ConstCollector as rustc_hir::intravisit::Visitor>::visit_ty::TyAliasVisitor as rustc_middle::ty::fold::TypeVisitor>::visit_const::hf8b5df8275e77bc5
  86:     0x7ff905a6c059 - rustc_typeck::check::cast::CastCheck::do_check::h89d6d0a90ea63ed1
  87:     0x7ff9059997bc - rustc_typeck::check::writeback::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::resolve_type_vars_in_body::h94c00915f034e1d5
  88:     0x7ff905b0a65e - rustc_typeck::check_crate::h5a65844e844f9082
  89:     0x7ff9034ae8ea - rustc_interface::passes::QueryContext::print_stats::h385de07cf326c54f
  90:     0x7ff90322715b - <rustc_metadata::foreign_modules::Collector as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_impl_item::h4fd1acdc6b656b0f
  91:     0x7ff903227936 - <rustc_metadata::foreign_modules::Collector as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_impl_item::h4fd1acdc6b656b0f
  92:     0x7ff9032a4bb2 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h8e1972fe1de8a9ac
  93:     0x7ff9032c0976 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h8e1972fe1de8a9ac
  94:     0x7ff90324ffb6 - <rustc_ast_passes::node_count::NodeCounter as rustc_ast::visit::Visitor>::visit_attribute::hf9ef02ad4e2defcf
  95:     0x7ff9032291dc - <rustc_metadata::foreign_modules::Collector as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_impl_item::h4fd1acdc6b656b0f
  96:     0x7ff9032bbdd4 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h8e1972fe1de8a9ac
  97:     0x7ff90325801c - <rustc_driver::args::Error as core::fmt::Debug>::fmt::h555e01581ae0b052
  98:     0x7ff9032befb8 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h8e1972fe1de8a9ac
  99:     0x7ff90329a1d0 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h8e1972fe1de8a9ac
 100:     0x7ff9032c14c3 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::h8e1972fe1de8a9ac
 101:     0x7ff90323ffc3 - <rustc_ast_passes::node_count::NodeCounter as rustc_ast::visit::Visitor>::visit_attribute::hf9ef02ad4e2defcf
 102:     0x7ff94953f577 - std::sys::windows::thread::Thread::new::h04914a10b014a9d7
 103:     0x7ff99b6c7bd4 - BaseThreadInitThunk
 104:     0x7ff99d2ace51 - RtlUserThreadStart

Query Stack

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `[^0; _]: std::convert::From<()>`
#1 [typeck] type-checking `c`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-const_generics`#![feature(const_generics)]`F-generic_const_exprs`#![feature(generic_const_exprs)]`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.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions