Skip to content

ICE: Failed to normalize &'{erased} mut Alias(Opaque #141850

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
matthiaskrgr opened this issue Jun 1, 2025 · 1 comment
Open

ICE: Failed to normalize &'{erased} mut Alias(Opaque #141850

matthiaskrgr opened this issue Jun 1, 2025 · 1 comment
Labels
C-bug Category: This is a bug. F-pin_ergonomics `#![feature(pin_ergonomics)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

//@compile-flags: --edition=2024
#![feature(pin_ergonomics)]
async fn a() {
    wrapper_call(handler, ()).await;
}
async fn wrapper_call<F, Args>(handler: F, args: Args) -> F::Output
where
    F: Handler<Args>,
{
    handler.call(args).await
}
async fn handler();
trait Handler<Args>: 'static {
    type Output;
    type Future: Future<Output = Self::Output>;
    fn call(&self, args: Args) -> Self::Future;
}
impl<Func, Fut> Handler() for Func
where
    Func: Fn() -> Fut + Clone + 'static,
    Fut: Future,
{
    type Output = Fut;
}

original:

#![feature(pin_ergonomics)]
async fn a() {
    wrapper_call(handler, ()).await;
}
async fn wrapper_call<F, Args>(handler: F, args: Args) -> F::Output
where
    F: Handler<Args>,
{
    handler.call(args).await
}
async fn handler();
trait Handler<Args>: 'static {
    type Output;
    type Future: Future<Output = Self::Output>;
    fn call(&self, args: Args) -> Self::Future;
}
impl<Func, Fut> Handler() for Func
where
    Func: Fn() -> Fut + Clone + 'static,
    Fut: Future,
{
    type Output = Fut;
}

Version information

rustc 1.89.0-nightly (13a454090 2025-06-01)
binary: rustc
commit-hash: 13a4540908d25642c0fa0ab726095cf57bbe6824
commit-date: 2025-06-01
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5

Possibly related line of code:

fn normalize_generic_arg_after_erasing_regions(
&self,
arg: ty::GenericArg<'tcx>,
) -> ty::GenericArg<'tcx> {
let arg = self.typing_env.as_query_input(arg);
self.tcx.try_normalize_generic_arg_after_erasing_regions(arg).unwrap_or_else(|_| {
bug!(
"Failed to normalize {:?} in typing_env={:?}, \
maybe try to call `try_normalize_erasing_regions` instead",
arg.value,
self.typing_env,
)
})

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2024

Program output

error: free function without a body
  --> /tmp/icemaker_global_tempdir.RuqRgdhmMFsu/rustc_testrunner_tmpdir_reporting.kFTDMkrcqGyG/mvce.rs:11:1
   |
11 | async fn handler();
   | ^^^^^^^^^^^^^^^^^^-
   |                   |
   |                   help: provide a definition for the function: `{ <body> }`

warning: the feature `pin_ergonomics` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.RuqRgdhmMFsu/rustc_testrunner_tmpdir_reporting.kFTDMkrcqGyG/mvce.rs:1:12
  |
1 | #![feature(pin_ergonomics)]
  |            ^^^^^^^^^^^^^^
  |
  = note: see issue #130494 <https://github.com/rust-lang/rust/issues/130494> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.RuqRgdhmMFsu/rustc_testrunner_tmpdir_reporting.kFTDMkrcqGyG/mvce.rs:23:2
   |
23 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.RuqRgdhmMFsu/rustc_testrunner_tmpdir_reporting.kFTDMkrcqGyG/mvce.rs`

error[E0658]: parenthetical notation is only stable when used with `Fn`-family traits
  --> /tmp/icemaker_global_tempdir.RuqRgdhmMFsu/rustc_testrunner_tmpdir_reporting.kFTDMkrcqGyG/mvce.rs:17:17
   |
17 | impl<Func, Fut> Handler() for Func
   |                 ^^^^^^^^^
   |
   = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
   = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
   = note: this compiler was built on 2025-06-01; consider upgrading it if it is out of date

error[E0229]: associated item constraints are not allowed here
  --> /tmp/icemaker_global_tempdir.RuqRgdhmMFsu/rustc_testrunner_tmpdir_reporting.kFTDMkrcqGyG/mvce.rs:17:17
   |
17 | impl<Func, Fut> Handler() for Func
   |                 ^^^^^^^^^ associated item constraint not allowed here
   |
help: parenthesized trait syntax expands to `Handler<(), Output=()>`
  --> /tmp/icemaker_global_tempdir.RuqRgdhmMFsu/rustc_testrunner_tmpdir_reporting.kFTDMkrcqGyG/mvce.rs:17:17
   |
17 | impl<Func, Fut> Handler() for Func
   |                 ^^^^^^^^^

error[E0046]: not all trait items implemented, missing: `Future`, `call`
  --> /tmp/icemaker_global_tempdir.RuqRgdhmMFsu/rustc_testrunner_tmpdir_reporting.kFTDMkrcqGyG/mvce.rs:17:1
   |
14 |       type Future: Future<Output = Self::Output>;
   |       ------------------------------------------ `Future` from trait
15 |       fn call(&self, args: Args) -> Self::Future;
   |       ------------------------------------------- `call` from trait
16 |   }
17 | / impl<Func, Fut> Handler() for Func
18 | | where
19 | |     Func: Fn() -> Fut + Clone + 'static,
20 | |     Fut: Future,
   | |________________^ missing `Future`, `call` in implementation

error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:171:13: Failed to normalize &'{erased} mut Alias(Opaque, AliasTy { args: [FnDef(DefId(0:11 ~ mvce[0140]::handler), []), ()], def_id: DefId(0:9 ~ mvce[0140]::wrapper_call::{opaque#0}), .. }) in typing_env=TypingEnv { typing_mode: PostAnalysis, param_env: ParamEnv { caller_bounds: [] } }, maybe try to call `try_normalize_erasing_regions` instead


thread 'rustc' panicked at compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:171:13:
Box<dyn Any>
stack backtrace:
   0:     0x7991cc6de703 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1750895f43e843d4
   1:     0x7991cce03237 - core::fmt::write::h6b549521393450c4
   2:     0x7991cc6d4383 - std::io::Write::write_fmt::h56b183ab660d16eb
   3:     0x7991cc6de562 - std::sys::backtrace::BacktraceLock::print::h96fec1ee4eaf5d52
   4:     0x7991cc6e215a - std::panicking::default_hook::{{closure}}::h0272a1832c315d01
   5:     0x7991cc6e1cdf - std::panicking::default_hook::hbb92434c436b38d4
   6:     0x7991cb7fa5b3 - std[d5a5e8436f7bb80d]::panicking::update_hook::<alloc[84a9b4db4b1fd3b6]::boxed::Box<rustc_driver_impl[12f4e41c2796a3e6]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7991cc6e29d3 - std::panicking::rust_panic_with_hook::hdd99d03934c0d55d
   8:     0x7991cb8372d1 - std[d5a5e8436f7bb80d]::panicking::begin_panic::<rustc_errors[78ce2d78f255827f]::ExplicitBug>::{closure#0}
   9:     0x7991cb82bbc6 - std[d5a5e8436f7bb80d]::sys::backtrace::__rust_end_short_backtrace::<std[d5a5e8436f7bb80d]::panicking::begin_panic<rustc_errors[78ce2d78f255827f]::ExplicitBug>::{closure#0}, !>
  10:     0x7991cb82baab - std[d5a5e8436f7bb80d]::panicking::begin_panic::<rustc_errors[78ce2d78f255827f]::ExplicitBug>
  11:     0x7991cb840dc1 - <rustc_errors[78ce2d78f255827f]::diagnostic::BugAbort as rustc_errors[78ce2d78f255827f]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7991cbde238a - rustc_middle[c87150728fec5a49]::util::bug::opt_span_bug_fmt::<rustc_span[1b2e5f36c4767dc6]::span_encoding::Span>::{closure#0}
  13:     0x7991cbdc1dca - rustc_middle[c87150728fec5a49]::ty::context::tls::with_opt::<rustc_middle[c87150728fec5a49]::util::bug::opt_span_bug_fmt<rustc_span[1b2e5f36c4767dc6]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7991cbdc1c3b - rustc_middle[c87150728fec5a49]::ty::context::tls::with_context_opt::<rustc_middle[c87150728fec5a49]::ty::context::tls::with_opt<rustc_middle[c87150728fec5a49]::util::bug::opt_span_bug_fmt<rustc_span[1b2e5f36c4767dc6]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7991c8eaa280 - rustc_middle[c87150728fec5a49]::util::bug::bug_fmt
  16:     0x7991cd8b40ff - <rustc_middle[c87150728fec5a49]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_type_ir[c774dfba22605253]::fold::TypeFolder<rustc_middle[c87150728fec5a49]::ty::context::TyCtxt>>::fold_ty
  17:     0x7991ce422973 - rustc_mir_transform[8ab4230bc871fcc6]::validate::validate_types
  18:     0x7991cdccf4ac - <rustc_mir_transform[8ab4230bc871fcc6]::validate::Validator as rustc_mir_transform[8ab4230bc871fcc6]::pass_manager::MirPass>::run_pass
  19:     0x7991cce109eb - rustc_mir_transform[8ab4230bc871fcc6]::run_optimization_passes
  20:     0x7991cdb3b9dc - rustc_mir_transform[8ab4230bc871fcc6]::optimized_mir
  21:     0x7991cdb3b19d - rustc_query_impl[22a781136fdb8532]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[22a781136fdb8532]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c87150728fec5a49]::query::erase::Erased<[u8; 8usize]>>
  22:     0x7991cce25ae5 - rustc_query_system[58eb503a7502457a]::query::plumbing::try_execute_query::<rustc_query_impl[22a781136fdb8532]::DynamicConfig<rustc_query_system[58eb503a7502457a]::query::caches::DefIdCache<rustc_middle[c87150728fec5a49]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[22a781136fdb8532]::plumbing::QueryCtxt, false>
  23:     0x7991cce24f1b - rustc_query_impl[22a781136fdb8532]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7991ce21e068 - <rustc_middle[c87150728fec5a49]::ty::context::TyCtxt>::coroutine_layout
  25:     0x7991cd51b5ba - rustc_ty_utils[4b7a7000bd020946]::layout::layout_of_uncached
  26:     0x7991cd50b689 - rustc_ty_utils[4b7a7000bd020946]::layout::layout_of
  27:     0x7991cd50b5ea - rustc_query_impl[22a781136fdb8532]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[22a781136fdb8532]::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c87150728fec5a49]::query::erase::Erased<[u8; 16usize]>>
  28:     0x7991cd50a50f - rustc_query_system[58eb503a7502457a]::query::plumbing::try_execute_query::<rustc_query_impl[22a781136fdb8532]::DynamicConfig<rustc_query_system[58eb503a7502457a]::query::caches::DefaultCache<rustc_middle[c87150728fec5a49]::ty::PseudoCanonicalInput<rustc_middle[c87150728fec5a49]::ty::Ty>, rustc_middle[c87150728fec5a49]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[22a781136fdb8532]::plumbing::QueryCtxt, false>
  29:     0x7991cd50a164 - rustc_query_impl[22a781136fdb8532]::query_impl::layout_of::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7991cddd7cf6 - <rustc_mir_transform[8ab4230bc871fcc6]::known_panics_lint::KnownPanicsLint as rustc_mir_transform[8ab4230bc871fcc6]::pass_manager::MirLint>::run_lint
  31:     0x7991cce0b09c - rustc_mir_transform[8ab4230bc871fcc6]::run_analysis_to_runtime_passes
  32:     0x7991cd36f327 - rustc_mir_transform[8ab4230bc871fcc6]::mir_drops_elaborated_and_const_checked
  33:     0x7991cd36ece3 - rustc_query_impl[22a781136fdb8532]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[22a781136fdb8532]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c87150728fec5a49]::query::erase::Erased<[u8; 8usize]>>
  34:     0x7991ccfccd66 - rustc_query_system[58eb503a7502457a]::query::plumbing::try_execute_query::<rustc_query_impl[22a781136fdb8532]::DynamicConfig<rustc_data_structures[cdeb167cf83dddb5]::vec_cache::VecCache<rustc_span[1b2e5f36c4767dc6]::def_id::LocalDefId, rustc_middle[c87150728fec5a49]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[58eb503a7502457a]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[22a781136fdb8532]::plumbing::QueryCtxt, false>
  35:     0x7991ccfcc589 - rustc_query_impl[22a781136fdb8532]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7991ccfc74dc - rustc_interface[2437496f2585cb44]::passes::run_required_analyses
  37:     0x7991cdb4f81e - rustc_interface[2437496f2585cb44]::passes::analysis
  38:     0x7991cdb4f7f3 - rustc_query_impl[22a781136fdb8532]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[22a781136fdb8532]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c87150728fec5a49]::query::erase::Erased<[u8; 0usize]>>
  39:     0x7991cdb526ce - rustc_query_system[58eb503a7502457a]::query::plumbing::try_execute_query::<rustc_query_impl[22a781136fdb8532]::DynamicConfig<rustc_query_system[58eb503a7502457a]::query::caches::SingleCache<rustc_middle[c87150728fec5a49]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[22a781136fdb8532]::plumbing::QueryCtxt, false>
  40:     0x7991cdb522b6 - rustc_query_impl[22a781136fdb8532]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7991ce08edff - rustc_interface[2437496f2585cb44]::passes::create_and_enter_global_ctxt::<core[8a55f9a5e0f462be]::option::Option<rustc_interface[2437496f2585cb44]::queries::Linker>, rustc_driver_impl[12f4e41c2796a3e6]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  42:     0x7991ce08188c - rustc_interface[2437496f2585cb44]::interface::run_compiler::<(), rustc_driver_impl[12f4e41c2796a3e6]::run_compiler::{closure#0}>::{closure#1}
  43:     0x7991ce031448 - std[d5a5e8436f7bb80d]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[2437496f2585cb44]::util::run_in_thread_with_globals<rustc_interface[2437496f2585cb44]::util::run_in_thread_pool_with_globals<rustc_interface[2437496f2585cb44]::interface::run_compiler<(), rustc_driver_impl[12f4e41c2796a3e6]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  44:     0x7991ce031130 - <<std[d5a5e8436f7bb80d]::thread::Builder>::spawn_unchecked_<rustc_interface[2437496f2585cb44]::util::run_in_thread_with_globals<rustc_interface[2437496f2585cb44]::util::run_in_thread_pool_with_globals<rustc_interface[2437496f2585cb44]::interface::run_compiler<(), rustc_driver_impl[12f4e41c2796a3e6]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[8a55f9a5e0f462be]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7991ce02f77d - std::sys::pal::unix::thread::Thread::new::thread_start::h7d76966977b816fa
  46:     0x7991c7aa57eb - <unknown>
  47:     0x7991c7b2918c - <unknown>
  48:                0x0 - <unknown>

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: please make sure that you have updated to the latest nightly

note: rustc 1.89.0-nightly (13a454090 2025-06-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir-dir=dir

query stack during panic:
#0 [optimized_mir] optimizing MIR for `a::{closure#0}`
#1 [layout_of] computing layout of `{async fn body of a()}`
#2 [mir_drops_elaborated_and_const_checked] elaborating drops for `a`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors; 1 warning emitted

Some errors have detailed explanations: E0046, E0229, E0601, E0658.
For more information about an error, try `rustc --explain E0046`.

@rustbot label +F-pin_ergonomics

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Jun 1, 2025
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-pin_ergonomics `#![feature(pin_ergonomics)]` labels Jun 1, 2025
@cyrgani
Copy link
Contributor

cyrgani commented Jun 1, 2025

//@compile-flags: --edition=2024
#![feature(pin_ergonomics)]
async fn a() {
    wrapper_call(handler).await;
}
async fn wrapper_call<F>(_: F) -> F::Output
where
    F: Handler,
{
    todo!()
}
async fn handler();
trait Handler {
    type Output;
}
impl<Func, Fut> Handler for Func
where
    Func: Fn() -> Fut,
    Fut: Future,
{
    type Output = Fut;
}

@compiler-errors compiler-errors added E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Jun 2, 2025
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. F-pin_ergonomics `#![feature(pin_ergonomics)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. 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

4 participants