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 in type inference #87327

Closed
dlblv opened this issue Jul 20, 2021 · 3 comments
Closed

ICE in type inference #87327

dlblv opened this issue Jul 20, 2021 · 3 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) A-trait-system Area: Trait system 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

@dlblv
Copy link

dlblv commented Jul 20, 2021

Code

struct S<T: Sized>(T);

impl<T: Sized> Iterator for S<T>{
    type Item = T;
    fn next(&mut self) -> Option<<Self as Iterator>::Item> {
        union U {
            a: <Self as Iterator>::Item,
        }
        None
    }
}

Meta

rustc --version --verbose:

rustc 1.53.0 (53cb7b09b 2021-06-17)
binary: rustc
commit-hash: 53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b
commit-date: 2021-06-17
host: x86_64-unknown-linux-gnu
release: 1.53.0
LLVM version: 12.0.1

Error output

error: internal compiler error: compiler/rustc_traits/src/normalize_erasing_regions.rs:54:32: could not fully normalize `<<S<T> as std::iter::Iterator>::next::U as std::iter::Iterator>::Item`

thread 'rustc' panicked at 'Box<Any>', /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panic.rs:59:5
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.53.0 (53cb7b09b 2021-06-17) running on x86_64-unknown-linux-gnu

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 `<<impl at src/lib.rs:3:1: 12:2>::next::U as std::iter::Iterator>::Item`
#1 [check_mod_unstable_api_usage] checking for unstable API usage in top-level module
end of query stack
Backtrace

error: internal compiler error: compiler/rustc_traits/src/normalize_erasing_regions.rs:54:32: could not fully normalize `<<S<T> as std::iter::Iterator>::next::U as std::iter::Iterator>::Item`

thread 'rustc' panicked at 'Box<Any>', /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panic.rs:59:5
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::force_query_with_job
  12: rustc_query_system::query::plumbing::get_query_impl
  13: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::normalize_generic_arg_after_erasing_regions
  14: <rustc_middle::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_middle::ty::fold::TypeFolder>::fold_ty
  15: rustc_middle::ty::normalize_erasing_regions::<impl rustc_middle::ty::context::TyCtxt>::normalize_erasing_regions
  16: <rustc_passes::stability::Checker as rustc_hir::intravisit::Visitor>::visit_item
  17: rustc_middle::hir::map::Map::visit_item_likes_in_module
  18: rustc_passes::stability::check_mod_unstable_api_usage
  19: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  20: rustc_query_system::query::plumbing::force_query_with_job
  21: rustc_query_system::query::plumbing::get_query_impl
  22: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_unstable_api_usage
  23: std::panic::catch_unwind
  24: rustc_session::utils::<impl rustc_session::session::Session>::time
  25: rustc_interface::passes::analysis
  26: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  27: rustc_data_structures::stack::ensure_sufficient_stack
  28: rustc_query_system::query::plumbing::force_query_with_job
  29: rustc_query_system::query::plumbing::get_query_impl
  30: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  31: rustc_interface::passes::QueryContext::enter
  32: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  33: rustc_span::with_source_map
  34: rustc_interface::interface::create_compiler_and_run
  35: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.53.0 (53cb7b09b 2021-06-17) running on x86_64-unknown-linux-gnu

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 `<<impl at src/lib.rs:3:1: 12:2>::next::U as std::iter::Iterator>::Item`
#1 [check_mod_unstable_api_usage] checking for unstable API usage in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack

@dlblv dlblv 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 Jul 20, 2021
@jyn514 jyn514 changed the title Critical compiler bug in type inference ICE in type inference Jul 20, 2021
@jyn514
Copy link
Member

jyn514 commented Jul 20, 2021

Simplified:

union U {
    a: <Self as Iterator>::Item,
}

@jonas-schievink jonas-schievink added A-associated-items Area: Associated items (types, constants & functions) I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jul 20, 2021
@camelid camelid added the A-trait-system Area: Trait system label Jul 21, 2021
@apiraino
Copy link
Contributor

I wonder if this could relate to this comment from a similar issue (there's a bunch of them).

@jyn514
Copy link
Member

jyn514 commented Jul 22, 2021

Yup, this is a duplicate of #81199, good catch :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-trait-system Area: Trait system 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

No branches or pull requests

5 participants