Skip to content

infinite recursion ICE #52701

Closed
Closed
@DutchGhost

Description

@DutchGhost

The following ICE's on nightly and beta, both on debug and release mode:

fn rec() -> impl Fn() { rec() }

fn main() {
    let f = rec();
}

Stable refuses to compile:

 Compiling playground v0.0.1 (file:///playground)
warning: function cannot return without recurring
 --> src/main.rs:2:1
  |
2 | fn rec() -> impl Fn() { rec() }
  | ^^^^^^^^^^^^^^^^^^^^^   ----- recursive call site
  | |
  | cannot return without recurring
  |
  = note: #[warn(unconditional_recursion)] on by default
  = help: a `loop` may express intention better if this is on purpose

error[E0275]: overflow evaluating the requirement `impl std::ops::Fn<()>`
  |
  = help: consider adding a `#![recursion_limit="128"]` attribute to your crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0275`.
error: Could not compile `playground`.

To learn more, run the command again with --verbose.

in a way, this is related to #28728 (LLVM optimization bug)

ICE message:

error: internal compiler error: librustc\traits\query\normalize.rs:124: infinite recursion generic_ty: impl std::ops::Fn<()>, substs: [], concrete_ty: impl std::ops::Fn<()>, ty: impl std::ops::Fn<()>
Backtrace: ``` thread 'main' panicked at 'Box', librustc_errors\lib.rs:557:9 stack backtrace: 0: ::drop 1: std::error::> for alloc::boxed::Box<(dyn std::error::Error + core::marker::Send + core::marker::Sync + 'a)>>::from 2: std::panicking::take_hook 3: std::panicking::take_hook 4: ::fmt 5: std::panicking::rust_panic_with_hook 6: ::fmt 7: rustc_errors::Handler::bug 8: as core::clone::Clone>::clone 9: rustc::ty::context::tls::track_diagnostic 10: rustc::ty::context::tls::track_diagnostic 11: rustc::ty::context::tls::track_diagnostic 12: rustc::session::bug_fmt 13: rustc::session::bug_fmt 14: as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty 15: as rustc_traits::lowering::Lower>>>::lower 16: as rustc_traits::lowering::Lower>>>::lower 17: as rustc::ty::context::Lift<'tcx>>::lift_to_tcx 18: rustc_traits::provide 19: as core::fmt::Debug>::fmt 20: rustc::ty::context::tls::track_diagnostic 21: rustc::dep_graph::graph::DepGraph::assert_ignored 22: rustc::ty::context::tls::track_diagnostic 23: rustc::ty::query::plumbing::>::try_print_query_stack 24: rustc::ty::query::plumbing::>::try_print_query_stack 25: as rustc::ty::fold::TypeFolder<'tcx, 'tcx>>::fold_ty 26: as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind 27: rustc_mir::monomorphize::collector::collect_crate_mono_items 28: >::visit_local 29: ::fmt 30: rustc_mir::monomorphize::collector::collect_crate_mono_items 31: 32: ::next 33: rustc::ty::context::tls::track_diagnostic 34: rustc::dep_graph::graph::DepGraph::assert_ignored 35: rustc::ty::context::tls::track_diagnostic 36: rustc::ty::query::plumbing::>::try_print_query_stack 37: rustc::ty::query::plumbing::>::try_print_query_stack 38: ::codegen_crate 39: >::visit_item 40: rustc_driver::driver::phase_4_codegen 41: >::visit_impl_item 42: >::visit_impl_item 43: >::visit_item 44: ::fmt 45: rustc_driver::driver::compile_input 46: rustc_driver::run_compiler 47: rustc_driver::target_features::add_configuration 48: >::visit_impl_item 49: _rust_maybe_catch_panic 50: rustc_driver::profile::dump 51: rustc_driver::main 52: 53: std::panicking::update_panic_count 54: _rust_maybe_catch_panic 55: std::rt::lang_start_internal 56: 57: 58: BaseThreadInitThunk 59: RtlUserThreadStart query stack during panic: #0 [normalize_ty_after_erasing_regions] normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: impl std::ops::Fn<()> }` #1 [collect_and_partition_mono_items] collect_and_partition_mono_items end of query stack error: aborting due to previous error

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.29.0-nightly (874dec2 2018-07-21) running on x86_64-pc-windows-msvc

note: compiler flags: -C opt-level=3 --crate-type bin

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

error: Could not compile llvm-opt-ice.

To learn more, run the command again with --verbose.

</details>

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions