Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Panic when normalizing <sample::TraitImpl<N> as sample::Trait>::R #88856

Closed
hideki1217 opened this issue Sep 11, 2021 · 1 comment · Fixed by #91255
Closed

Panic when normalizing <sample::TraitImpl<N> as sample::Trait>::R #88856

hideki1217 opened this issue Sep 11, 2021 · 1 comment · Fixed by #91255
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

@hideki1217
Copy link

Code

// main.rs
use sample::{Trait, TraitImpl};

fn sample<P,Convert>(p:P,f:Convert) -> i32 
where 
    P:Trait,Convert:Fn(P::R)->i32 
{
    f(p.func())
}
fn main() {
    let t = TraitImpl::<10>(4);
    sample(t,|x|x.0);
}
// lib.rs
pub trait Trait{
    type R;
    fn func(self)->Self::R;
}
pub struct TraitImpl<const N:usize>(pub i32);
impl<const N:usize> Trait for TraitImpl<N>
where [();N/2]:,
{
    type R = Self;
    fn func(self)->Self::R {
        self
    }
}

Meta

rustc --version --verbose:

rustc 1.57.0-nightly (b69fe5726 2021-09-10)
binary: rustc
commit-hash: b69fe57261086e70aea9d5b58819a1794bf7c121
commit-date: 2021-09-10
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
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 `<sample::TraitImpl<N> as sample::Trait>::R`

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1146: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.57.0-nightly (b69fe5726 2021-09-10) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `<sample::TraitImpl<N> as sample::Trait>::R`
end of query stack
error: could not compile `sample`
Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1146:9
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_infer::infer::InferCtxtBuilder::enter
   8: core::ops::function::FnOnce::call_once
   9: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  10: rustc_data_structures::stack::ensure_sufficient_stack
  11: rustc_query_system::query::plumbing::get_query_impl
  12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::normalize_generic_arg_after_erasing_regions
  13: rustc_middle::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder::normalize_generic_arg_after_erasing_regions
  14: rustc_middle::ty::util::fold_list
  15: rustc_middle::ty::normalize_erasing_regions::<impl rustc_middle::ty::context::TyCtxt>::normalize_erasing_regions
  16: rustc_middle::ty::layout::<impl rustc_middle::ty::instance::Instance>::fn_sig_for_fn_abi
  17: <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::of_instance
  18: rustc_codegen_llvm::mono_item::<impl rustc_codegen_ssa::traits::declare::PreDefineMethods for rustc_codegen_llvm::context::CodegenCx>::predefine_fn
  19: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  20: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  21: rustc_codegen_llvm::base::compile_codegen_unit
  22: rustc_codegen_ssa::base::codegen_crate
  23: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  24: rustc_interface::queries::Queries::ongoing_codegen
  25: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  26: rustc_span::with_source_map
  27: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@hideki1217 hideki1217 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 Sep 11, 2021
@adam-azarchs
Copy link

This is happening in non-nightly rust 1.56.0 as well.

# for free to join this conversation on GitHub. Already have an account? # 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