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

ICE: Generic traits of associated types of generic structs #91069

Closed
djkoloski opened this issue Nov 20, 2021 · 1 comment · Fixed by #91908
Closed

ICE: Generic traits of associated types of generic structs #91069

djkoloski opened this issue Nov 20, 2021 · 1 comment · Fixed by #91908
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. 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

@djkoloski
Copy link
Contributor

djkoloski commented Nov 20, 2021

Source: rkyv/rkyv#221

Code

lib.rs

pub trait Associate {
    type Associated;
}

pub struct Wrap<'a> {
    pub field: &'a i32,
}

pub trait Create<T> {
    fn create() -> Self;
}

pub fn oh_no<'a, T>()
where
    Wrap<'a>: Associate,
    <Wrap<'a> as Associate>::Associated: Create<T>,
{
    <Wrap<'a> as Associate>::Associated::create();
}

It is worth noting that this code should not compile.

Meta

This bug occurs in both beta and nightly.

rustc --version --verbose:

rustc 1.56.1 (59eed8a2a 2021-11-01)
binary: rustc
commit-hash: 59eed8a2aac0230a8b53e89d4e99d55912ba6b35
commit-date: 2021-11-01
host: x86_64-pc-windows-msvc
release: 1.56.1
LLVM version: 13.0.0

Error output

error: internal compiler error: compiler\rustc_traits\src\normalize_erasing_regions.rs:54:32: could not fully normalize `<Wrap as Associate>::Associated`

thread 'rustc' panicked at 'Box<dyn Any>', compiler\rustc_errors\src\lib.rs:1147: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.56.1 (59eed8a2a 2021-11-01) 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

query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `<Wrap as Associate>::Associated`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `oh_no`
end of query stack
error: could not compile `erase_repro`
Backtrace

error: internal compiler error: compiler\rustc_traits\src\normalize_erasing_regions.rs:54:32: could not fully normalize `<Wrap as Associate>::Associated`

thread 'rustc' panicked at 'Box<dyn Any>', compiler\rustc_errors\src\lib.rs:1147:9
stack backtrace:
   0:     0x7ffea42c7a9e - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h90fc78c6027cfe27
   1:     0x7ffea42f268a - core::fmt::write::h8afcb1031f89d60b
   2:     0x7ffea42bae08 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::hb4b34c43836aedaf
   3:     0x7ffea42cb586 - std::panicking::take_hook::h8b2fe3f8f4cf4b43
   4:     0x7ffea42cb074 - std::panicking::take_hook::h8b2fe3f8f4cf4b43
   5:     0x7ffea486a525 - <serde_json::value::WriterFormatter as std::io::Write>::flush::hc1d196eaca04d7a8
   6:     0x7ffea42cbe99 - std::panicking::rust_panic_with_hook::h844a8dc19bbe524e
   7:     0x7ffea8e82430 - rustc_errors::diagnostic_builder::DiagnosticBuilder::code::h1645263d95f3b09a
   8:     0x7ffea8e823e9 - rustc_errors::diagnostic_builder::DiagnosticBuilder::code::h1645263d95f3b09a
   9:     0x7ffea9157ad1 - rustc_query_system::query::job::report_cycle::h12a555504324913c
  10:     0x7ffea8eb3080 - <rustc_errors::json::Diagnostic::from_errors_diagnostic::BufWriter as std::io::Write>::flush::hf0501cbec5358cf0
  11:     0x7ffea8ebad75 - rustc_errors::HandlerInner::emit_diagnostic::h728ec3ea46d2ed21
  12:     0x7ffea8eb8822 - rustc_errors::Handler::bug::h011b35fa3752efe1
  13:     0x7ffea8ba1ad7 - rustc_middle::ty::structural_impls::<impl core::fmt::Debug for rustc_middle::ty::closure::UpvarBorrow>::fmt::ha3dccab8f654b6b0
  14:     0x7ffea8b9fd90 - rustc_middle::ty::consts::valtree::ValTree::zst::hb53ec78846c4e3d7
  15:     0x7ffea8b9fd33 - rustc_middle::ty::consts::valtree::ValTree::zst::hb53ec78846c4e3d7
  16:     0x7ffea8ba1a09 - rustc_middle::ty::structural_impls::<impl core::fmt::Debug for rustc_middle::ty::closure::UpvarBorrow>::fmt::ha3dccab8f654b6b0
  17:     0x7ffea914e197 - rustc_middle::util::bug::bug_fmt::hb871ea62c9ba791a
  18:     0x7ffea7abf034 - <&chalk_ir::GenericArg<rustc_middle::traits::chalk::RustInterner> as rustc_traits::chalk::lowering::LowerInto<rustc_middle::ty::subst::GenericArg>>::lower_into::hac3acef454f06bed
  19:     0x7ffea7b9e463 - <rustc_traits::chalk::db::RustIrDatabase as chalk_ir::UnificationDatabase<rustc_middle::traits::chalk::RustInterner>>::adt_variance::he39df3eff3cd9e56
  20:     0x7ffea7ff8d0f - <rustc_span::def_id::DefIndex as rustc_query_impl::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string::hbb4b4890437407bc
  21:     0x7ffea7fa23e3 - <rustc_span::def_id::DefIndex as rustc_query_impl::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string::hbb4b4890437407bc
  22:     0x7ffea80d6f9f - rustc_metadata::rmeta::decoder::__ty_decoder_impl::<impl rustc_serialize::serialize::Decoder for rustc_metadata::rmeta::decoder::DecodeContext>::error::h95b02aeeaf1dc4be   
  23:     0x7ffea7c80a96 - <fixedbitset::FixedBitSet as core::fmt::Debug>::fmt::hedf20157683d04ae
  24:     0x7ffea8051deb - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h02f98d8f46101c14
  25:     0x7ffea8c6e181 - rustc_middle::ty::flags::FlagComputation::for_unevaluated_const::hf9370068502c458d
  26:     0x7ffea8c6e3f6 - <rustc_middle::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_middle::ty::fold::TypeFolder>::fold_ty::h97ea4149e1d91295
  27:     0x7ffea78bddcb - <rustc_mir::transform::dest_prop::CandidateAssignment as core::fmt::Debug>::fmt::h90783a921d19b6b1
  28:     0x7ffea790e94c - rustc_mir::dataflow::drop_flag_effects::on_all_children_bits::is_terminal_path::h8bbacca9de22ebf2
  29:     0x7ffea763202d - <rustc_mir::transform::elaborate_drops::ElaborateDrops as rustc_mir::transform::MirPass>::run_pass::h2d10c480fb5efb89
  30:     0x7ffea75d1033 - rustc_mir::transform::run_passes::h183bcfaf18b69333
  31:     0x7ffea75da478 - rustc_mir::transform::run_passes::h183bcfaf18b69333
  32:     0x7ffea75d9b00 - rustc_mir::transform::run_passes::h183bcfaf18b69333
  33:     0x7ffea7ff8eaf - <rustc_span::def_id::DefIndex as rustc_query_impl::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string::hbb4b4890437407bc
  34:     0x7ffea7fa5623 - <rustc_span::def_id::DefIndex as rustc_query_impl::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string::hbb4b4890437407bc
  35:     0x7ffea80d801d - rustc_metadata::rmeta::decoder::__ty_decoder_impl::<impl rustc_serialize::serialize::Decoder for rustc_metadata::rmeta::decoder::DecodeContext>::error::h95b02aeeaf1dc4be   
  36:     0x7ffea7cd468a - <fixedbitset::FixedBitSet as core::fmt::Debug>::fmt::hedf20157683d04ae
  37:     0x7ffea8046d59 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h02f98d8f46101c14
  38:     0x7ffea75dafe9 - rustc_mir::transform::run_passes::h183bcfaf18b69333
  39:     0x7ffea7ff38ef - <rustc_span::def_id::DefIndex as rustc_query_impl::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string::hbb4b4890437407bc
  40:     0x7ffea7f92511 - <rustc_span::def_id::DefIndex as rustc_query_impl::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string::hbb4b4890437407bc
  41:     0x7ffea80d34de - rustc_metadata::rmeta::decoder::__ty_decoder_impl::<impl rustc_serialize::serialize::Decoder for rustc_metadata::rmeta::decoder::DecodeContext>::error::h95b02aeeaf1dc4be   
  42:     0x7ffea7da1403 - <fixedbitset::FixedBitSet as core::fmt::Debug>::fmt::hedf20157683d04ae
  43:     0x7ffea7cbaf39 - <fixedbitset::FixedBitSet as core::fmt::Debug>::fmt::hedf20157683d04ae
  44:     0x7ffea8047200 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h02f98d8f46101c14
  45:     0x7ffea8371ec9 - <rustc_metadata::rmeta::encoder::EncodeContext as rustc_middle::ty::codec::TyEncoder>::encode_alloc_id::h1def24179fdbee6d
  46:     0x7ffea838f396 - <rustc_metadata::rmeta::encoder::ImplVisitor as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item::h69098d911b1ad348
  47:     0x7ffea83f1505 - <rustc_metadata::rmeta::decoder::DecodeContext as rustc_middle::ty::codec::TyDecoder>::decode_alloc_id::h7b90eba30f514af9
  48:     0x7ffea84cbcf2 - rustc_metadata::rmeta::decoder::cstore_impl::<impl rustc_middle::middle::cstore::CrateStore for rustc_metadata::creader::CStore>::encode_metadata::h7bc78bca2f8068cf        
  49:     0x7ffea8bebaa4 - rustc_middle::ty::context::TyCtxt::encode_metadata::h5ddfe09d2e3d95b9
  50:     0x7ffea49b3c8c - rustc_interface::queries::Queries::ongoing_codegen::h81f3e17d2f79ca80
  51:     0x7ffea48bf413 - regex_syntax::hir::Error::pattern::h26de5cae1e560f3c
  52:     0x7ffea48897b5 - rustc_driver::pretty::print_after_hir_lowering::h8daab7168b9a121b
  53:     0x7ffea48c14c7 - regex_syntax::hir::Error::pattern::h26de5cae1e560f3c
  54:     0x7ffea488dfc0 - <tracing_subscriber::util::TryInitError as core::fmt::Display>::fmt::h6e9774f2c0dd7eb3
  55:     0x7ffea488a248 - rustc_driver::pretty::print_after_hir_lowering::h8daab7168b9a121b
  56:     0x7ffea487e67d - <rustc_driver::Compilation as core::fmt::Debug>::fmt::ha388fa55e25fcec9
  57:     0x7ffea42da1cc - std::sys::windows::thread::Thread::new::h5ab92c811b2297f5
  58:     0x7fff0f967034 - BaseThreadInitThunk
  59:     0x7fff10822651 - RtlUserThreadStart

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-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

query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `<Wrap as Associate>::Associated`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `oh_no`
#2 [optimized_mir] optimizing MIR for `oh_no`
end of query stack
error: could not compile `erase_repro`

@djkoloski djkoloski 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 20, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 5, 2021
@Alexendoo
Copy link
Member

No longer ICEs since #91462

@Alexendoo Alexendoo added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Dec 5, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 14, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 14, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 12, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 12, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 12, 2022
@bors bors closed this as completed in 9b17e2d Feb 12, 2022
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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. 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.

3 participants