Open
Description
auto-reduced (treereduce-rust):
//@compile-flags: -Zvalidate-mir
use std::future::Future;
async fn create_task() -> impl Sized {
bind(documentation)
}
async fn documentation() {
!;
}
fn bind<F>(_filter: F) -> impl Sized
where
F: FilterBase,
{
|| -> <F as FilterBase>::Assoc { panic!() }
}
trait FilterBase {
type Assoc;
}
impl<F, R> FilterBase for F
where
F: Fn() -> R,
R: Future,
R: Send,
{
}
original:
// Regression test for #135668
//@ edition: 2021
use std::future::Future;
pub async fn foo() {
let _ = create_task().await;
}
async fn create_task() -> impl Sized {
bind(documentation)
}
async fn documentation() {
compile_error!("bonjour");
//~^ ERROR bonjour
}
fn bind<F>(_filter: F) -> impl Sized
where
F: FilterBase,
{
|| -> <F as FilterBase>::Assoc { panic!() }
}
trait FilterBase {
type Assoc;
}
impl<F, R> FilterBase for F
where
F: Fn() -> R,
// Removing the below line makes it correctly error on both stable and beta
R: Future,
// Removing the below line makes it ICE on both stable and beta
R: Send,
// Removing the above two bounds makes it ICE on stable but correctly error on beta
{
type Type = ();
const CONST: usize = 1; //~ NOTE candidate #2
fn foo(&self) {} //~ NOTE candidate #2
}
fn main() {}
Version information
rustc 1.88.0-nightly (5c54aa781 2025-04-25)
binary: rustc
commit-hash: 5c54aa781f97ae95ef01a3120650907b87d385d3
commit-date: 2025-04-25
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2
Possibly related line of code:
rust/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs
Lines 165 to 177 in 5c54aa7
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zvalidate-mir
Program output
error[E0670]: `async fn` is not permitted in Rust 2015
--> /tmp/icemaker_global_tempdir.Fy7kUrdY3L11/rustc_testrunner_tmpdir_reporting.oROTq4nV8k6c/mvce.rs:8:1
|
8 | async fn create_task() -> impl Sized {
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
= help: pass `--edition 2024` to `rustc`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0670]: `async fn` is not permitted in Rust 2015
--> /tmp/icemaker_global_tempdir.Fy7kUrdY3L11/rustc_testrunner_tmpdir_reporting.oROTq4nV8k6c/mvce.rs:12:1
|
12 | async fn documentation() {
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
= help: pass `--edition 2024` to `rustc`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error: expected expression, found `;`
--> /tmp/icemaker_global_tempdir.Fy7kUrdY3L11/rustc_testrunner_tmpdir_reporting.oROTq4nV8k6c/mvce.rs:13:6
|
13 | !;
| ^ expected expression
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.Fy7kUrdY3L11/rustc_testrunner_tmpdir_reporting.oROTq4nV8k6c/mvce.rs:40:2
|
40 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.Fy7kUrdY3L11/rustc_testrunner_tmpdir_reporting.oROTq4nV8k6c/mvce.rs`
error[E0046]: not all trait items implemented, missing: `Assoc`
--> /tmp/icemaker_global_tempdir.Fy7kUrdY3L11/rustc_testrunner_tmpdir_reporting.oROTq4nV8k6c/mvce.rs:28:1
|
25 | type Assoc;
| ---------- `Assoc` from trait
...
28 | / impl<F, R> FilterBase for F
29 | | where
30 | | F: Fn() -> R,
... |
34 | | R: Send,
| |____________^ missing `Assoc` in implementation
error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:171:13: Failed to normalize Alias(Opaque, AliasTy { args: [FnDef(DefId(0:8 ~ mvce[1e52]::documentation), [])], def_id: DefId(0:13 ~ mvce[1e52]::bind::{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: 0x7d390ed01a93 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h5e5ed7e3dba37109
1: 0x7d390f405ac7 - core::fmt::write::h9eb703e77e802118
2: 0x7d39107f2951 - std::io::Write::write_fmt::h86cc522f97972765
3: 0x7d390ed018f2 - std::sys::backtrace::BacktraceLock::print::h6a10f5f1a1008df7
4: 0x7d390ed0526a - std::panicking::default_hook::{{closure}}::hc9375e73d24b3054
5: 0x7d390ed04def - std::panicking::default_hook::hf26154a2d0532fd5
6: 0x7d390dd75893 - std[ec78c589ec7e8aee]::panicking::update_hook::<alloc[64039d61152c796e]::boxed::Box<rustc_driver_impl[ebb0c86317587fd1]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7d390ed05ae3 - std::panicking::rust_panic_with_hook::h9fb4aeb43df093ef
8: 0x7d390ddb1271 - std[ec78c589ec7e8aee]::panicking::begin_panic::<rustc_errors[737037f1c0007803]::ExplicitBug>::{closure#0}
9: 0x7d390dda52a6 - std[ec78c589ec7e8aee]::sys::backtrace::__rust_end_short_backtrace::<std[ec78c589ec7e8aee]::panicking::begin_panic<rustc_errors[737037f1c0007803]::ExplicitBug>::{closure#0}, !>
10: 0x7d390dda5137 - std[ec78c589ec7e8aee]::panicking::begin_panic::<rustc_errors[737037f1c0007803]::ExplicitBug>
11: 0x7d390ddbb641 - <rustc_errors[737037f1c0007803]::diagnostic::BugAbort as rustc_errors[737037f1c0007803]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x7d390e4045ea - rustc_middle[e11bc8960ffe44ac]::util::bug::opt_span_bug_fmt::<rustc_span[10bfa2f3d1cd0e94]::span_encoding::Span>::{closure#0}
13: 0x7d390e3df60a - rustc_middle[e11bc8960ffe44ac]::ty::context::tls::with_opt::<rustc_middle[e11bc8960ffe44ac]::util::bug::opt_span_bug_fmt<rustc_span[10bfa2f3d1cd0e94]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14: 0x7d390e3df47b - rustc_middle[e11bc8960ffe44ac]::ty::context::tls::with_context_opt::<rustc_middle[e11bc8960ffe44ac]::ty::context::tls::with_opt<rustc_middle[e11bc8960ffe44ac]::util::bug::opt_span_bug_fmt<rustc_span[10bfa2f3d1cd0e94]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15: 0x7d390b68dda0 - rustc_middle[e11bc8960ffe44ac]::util::bug::bug_fmt
16: 0x7d390fd99084 - <rustc_middle[e11bc8960ffe44ac]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_type_ir[e02aabdd9006fd47]::fold::TypeFolder<rustc_middle[e11bc8960ffe44ac]::ty::context::TyCtxt>>::fold_ty
17: 0x7d39106f3fb5 - rustc_mir_transform[8d2ddc6cd67b9b7]::validate::validate_types
18: 0x7d39104fe241 - <rustc_mir_transform[8d2ddc6cd67b9b7]::validate::Validator as rustc_mir_transform[8d2ddc6cd67b9b7]::pass_manager::MirPass>::run_pass
19: 0x7d390d5bbb85 - rustc_mir_transform[8d2ddc6cd67b9b7]::pass_manager::validate_body
20: 0x7d390f40d1cd - rustc_mir_transform[8d2ddc6cd67b9b7]::run_analysis_to_runtime_passes
21: 0x7d390f96f9e5 - rustc_mir_transform[8d2ddc6cd67b9b7]::mir_drops_elaborated_and_const_checked
22: 0x7d390f96f399 - rustc_query_impl[54ec0e3327109f1d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[54ec0e3327109f1d]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e11bc8960ffe44ac]::query::erase::Erased<[u8; 8usize]>>
23: 0x7d390f7622ac - rustc_query_system[1188370fe5183a9d]::query::plumbing::try_execute_query::<rustc_query_impl[54ec0e3327109f1d]::DynamicConfig<rustc_data_structures[d8d4b55b44c07e9d]::vec_cache::VecCache<rustc_span[10bfa2f3d1cd0e94]::def_id::LocalDefId, rustc_middle[e11bc8960ffe44ac]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[1188370fe5183a9d]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[54ec0e3327109f1d]::plumbing::QueryCtxt, false>
24: 0x7d390f761b8f - rustc_query_impl[54ec0e3327109f1d]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
25: 0x7d390fe40e18 - rustc_interface[394fb8669b43967f]::passes::run_required_analyses
26: 0x7d39102d1a9e - rustc_interface[394fb8669b43967f]::passes::analysis
27: 0x7d39102d1a6d - rustc_query_impl[54ec0e3327109f1d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[54ec0e3327109f1d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e11bc8960ffe44ac]::query::erase::Erased<[u8; 0usize]>>
28: 0x7d39102d753d - rustc_query_system[1188370fe5183a9d]::query::plumbing::try_execute_query::<rustc_query_impl[54ec0e3327109f1d]::DynamicConfig<rustc_query_system[1188370fe5183a9d]::query::caches::SingleCache<rustc_middle[e11bc8960ffe44ac]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[54ec0e3327109f1d]::plumbing::QueryCtxt, false>
29: 0x7d39102d7238 - rustc_query_impl[54ec0e3327109f1d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
30: 0x7d3910651e80 - rustc_interface[394fb8669b43967f]::passes::create_and_enter_global_ctxt::<core[db792b049954ae76]::option::Option<rustc_interface[394fb8669b43967f]::queries::Linker>, rustc_driver_impl[ebb0c86317587fd1]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
31: 0x7d39104e9084 - rustc_interface[394fb8669b43967f]::interface::run_compiler::<(), rustc_driver_impl[ebb0c86317587fd1]::run_compiler::{closure#0}>::{closure#1}
32: 0x7d39104a3234 - std[ec78c589ec7e8aee]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[394fb8669b43967f]::util::run_in_thread_with_globals<rustc_interface[394fb8669b43967f]::util::run_in_thread_pool_with_globals<rustc_interface[394fb8669b43967f]::interface::run_compiler<(), rustc_driver_impl[ebb0c86317587fd1]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
33: 0x7d39104a3674 - <<std[ec78c589ec7e8aee]::thread::Builder>::spawn_unchecked_<rustc_interface[394fb8669b43967f]::util::run_in_thread_with_globals<rustc_interface[394fb8669b43967f]::util::run_in_thread_pool_with_globals<rustc_interface[394fb8669b43967f]::interface::run_compiler<(), rustc_driver_impl[ebb0c86317587fd1]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[db792b049954ae76]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
34: 0x7d39104a4a6b - std::sys::pal::unix::thread::Thread::new::thread_start::hd4f8a3dac6df8331
35: 0x7d390a2a370a - <unknown>
36: 0x7d390a327aac - <unknown>
37: 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.88.0-nightly (5c54aa781 2025-04-25) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z validate-mir -Z dump-mir-dir=dir
query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `create_task::{closure#0}`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0046, E0601, E0670.
For more information about an error, try `rustc --explain E0046`.
Metadata
Metadata
Assignees
Labels
Unstable option: MIR validationCategory: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: This bug is tracked inside the repo by a `known-bug` test.Status: A bisection has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.