Skip to content

ICE: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:169:13: Failed to normalize Alias(... #139659

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

Open
theemathas opened this issue Apr 11, 2025 · 1 comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. 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. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@theemathas
Copy link
Contributor

Code

trait Trait {
    type Output;
}

impl<O, F: Fn() -> O> Trait for F {
    type Output = O;
}

struct Wrap<P>(P);
struct WrapOutput<O>(O);

impl<P: Trait> Trait for Wrap<P> {
    type Output = WrapOutput<P::Output>;
}

fn wrap<P: Trait>(x: P) -> impl Trait {
    Wrap(x)
}

fn consume<P: Trait>(_: P) -> P::Output {
    unimplemented!()
}

pub fn recurse() -> impl Sized {
    consume(wrap(recurse))
}

Note: Reproducing this ICE requires cargo build. Using cargo check compiles fine.

Minimized from real code written by fearless_process on the rust community discord.

Very similar to #139658, which instead gives "overflow evaluating the requirement".

Meta

rustc --version --verbose:

rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: aarch64-apple-darwin
release: 1.86.0
LLVM version: 19.1.7

The issue also reproduces on rustc 1.88.0-nightly (0fe8f3454 2025-04-10).

Error output

error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:169:13: Failed to normalize Alias(Opaque, AliasTy { args: [], def_id: DefId(0:26 ~ foo[b3e3]::recurse::{opaque#0}), .. }) in typing_env=TypingEnv { typing_mode: PostAnalysis, param_env: ParamEnv { caller_bounds: [] } }, maybe try to call `try_normalize_erasing_regions` instead
Backtrace

thread 'rustc' panicked at compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:169:13:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: rustc_ty_utils::abi::fn_abi_new_uncached
   7: rustc_ty_utils::abi::fn_abi_of_instance
      [... omitted 2 frames ...]
   8: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<(rustc_middle::ty::instance::Instance, &rustc_middle::ty::list::RawList<(), rustc_middle::ty::Ty>)>, rustc_middle::query::erase::Erased<[u8; 16]>>>
   9: rustc_monomorphize::mono_checks::check_mono_item
      [... omitted 2 frames ...]
  10: rustc_monomorphize::collector::items_of_instance
      [... omitted 2 frames ...]
  11: rustc_monomorphize::collector::collect_items_rec::{closure#0}
  12: rustc_monomorphize::collector::collect_items_rec
  13: rustc_monomorphize::collector::collect_crate_mono_items
  14: rustc_monomorphize::partitioning::collect_and_partition_mono_items
      [... omitted 5 frames ...]
  15: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
  16: rustc_metadata::rmeta::encoder::encode_metadata
  17: rustc_metadata::fs::encode_and_write_metadata
  18: <rustc_interface::queries::Linker>::codegen_and_build_linker
  19: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  20: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.86.0 (05f9846f8 2025-03-31) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED]

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

query stack during panic:
#0 [fn_abi_of_instance] computing call ABI of `recurse`
#1 [check_mono_item] monomorphization-time checking
#2 [items_of_instance] collecting items used by `recurse`
#3 [collect_and_partition_mono_items] collect_and_partition_mono_items
#4 [exported_symbols] collecting exported symbols for crate `0`
end of query stack
there was a panic while trying to force a dep node
try_mark_green dep node stack:
#0 exported_symbols(foo[b3e3])
end of try_mark_green dep node stack
error: could not compile `foo` (lib)

Caused by:
  process didn't exit successfully: `/Users/timch/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc --crate-name foo --edition=2024 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=204 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=61fd0e4f3351c637 -C extra-filename=-2bc4f207b16319e9 --out-dir /Users/timch/foo/target/debug/deps -C incremental=/Users/timch/foo/target/debug/incremental -L dependency=/Users/timch/foo/target/debug/deps` (exit status: 101)

@theemathas theemathas 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 Apr 11, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 11, 2025
@theemathas
Copy link
Contributor Author

I think this looks related to #139406, since I can't figure out what type is recurse() supposed to be returning.

cc @lcnr

@lcnr lcnr added the A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. label Apr 24, 2025
@jieyouxu jieyouxu added T-types Relevant to the types team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. 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. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants