rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
99.13k stars 12.8k forks source link

ICE: nested return types #116383

Closed matthiaskrgr closed 1 year ago

matthiaskrgr commented 1 year ago

Code

-Zvalidate-mir reduced from #107346

trait Duh {}

impl Duh for i32 {}

trait Trait {
    type Assoc: Duh;
}

impl<R: Duh, F: FnMut() -> R> Trait for F {
    type Assoc = R;
}

fn foo() -> impl Trait<Assoc = impl Send> {
    || 42
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.75.0-nightly (eb0f3ed59 2023-10-03)
binary: rustc
commit-hash: eb0f3ed59c6508a37c6598bc9762987f053993a7
commit-date: 2023-10-03
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.2

Error output

<output>
Backtrace

``` warning: function `foo` is never used --> 107346.rs:18:4 | 18 | fn foo() -> impl Trait { | ^^^ | = note: `#[warn(dead_code)]` on by default error: internal compiler error: no errors encountered even though `delay_span_bug` issued error: internal compiler error: broken MIR in Item(DefId(0:11 ~ 107346[3e7c]::foo)) (after pass Subtyper) at bb0[1]: Failed subtyping Alias( Opaque, AliasTy { args: [ ], def_id: DefId(0:14 ~ 107346[3e7c]::foo::{opaque#0}), }, ) and Closure( DefId(0:12 ~ 107346[3e7c]::foo::{closure#0}), [ i8, Binder(extern "RustCall" fn(()) -> i32, []), (), ], ) --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ | note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:96:25 0: ::emit_diagnostic 1: ::delay_span_bug:: 2: ::fail:: 3: ::run_pass 4: rustc_mir_transform::pass_manager::validate_body 5: rustc_mir_transform::pass_manager::run_passes_inner 6: rustc_mir_transform::run_analysis_to_runtime_passes 7: rustc_mir_transform::mir_drops_elaborated_and_const_checked 8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 9: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 10: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace 11: rustc_interface::passes::analysis 12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 13: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 14: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 15: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 16: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 17: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 18: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 19: std::sys::unix::thread::Thread::new::thread_start at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/std/src/sys/unix/thread.rs:108:17 20: 21: --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ error: internal compiler error: broken MIR in Item(DefId(0:11 ~ 107346[3e7c]::foo)) (before pass CleanupPostBorrowck) at bb0[1]: Failed subtyping Alias( Opaque, AliasTy { args: [ ], def_id: DefId(0:14 ~ 107346[3e7c]::foo::{opaque#0}), }, ) and Closure( DefId(0:12 ~ 107346[3e7c]::foo::{closure#0}), [ i8, Binder(extern "RustCall" fn(()) -> i32, []), (), ], ) --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ | note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:96:25 0: ::emit_diagnostic 1: ::delay_span_bug:: 2: ::fail:: 3: ::run_pass 4: rustc_mir_transform::pass_manager::validate_body 5: rustc_mir_transform::pass_manager::run_passes_inner 6: rustc_mir_transform::run_analysis_to_runtime_passes 7: rustc_mir_transform::mir_drops_elaborated_and_const_checked 8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 9: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 10: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace 11: rustc_interface::passes::analysis 12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 13: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 14: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 15: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 16: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 17: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 18: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 19: std::sys::unix::thread::Thread::new::thread_start at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/std/src/sys/unix/thread.rs:108:17 20: 21: --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ error: internal compiler error: broken MIR in Item(DefId(0:11 ~ 107346[3e7c]::foo)) (after pass CleanupPostBorrowck) at bb0[1]: Failed subtyping Alias( Opaque, AliasTy { args: [ ], def_id: DefId(0:14 ~ 107346[3e7c]::foo::{opaque#0}), }, ) and Closure( DefId(0:12 ~ 107346[3e7c]::foo::{closure#0}), [ i8, Binder(extern "RustCall" fn(()) -> i32, []), (), ], ) --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ | note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:96:25 0: ::emit_diagnostic 1: ::delay_span_bug:: 2: ::fail:: 3: ::run_pass 4: rustc_mir_transform::pass_manager::validate_body 5: rustc_mir_transform::pass_manager::run_passes_inner 6: rustc_mir_transform::run_analysis_to_runtime_passes 7: rustc_mir_transform::mir_drops_elaborated_and_const_checked 8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 9: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 10: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace 11: rustc_interface::passes::analysis 12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 13: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 14: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 15: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 16: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 17: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 18: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 19: std::sys::unix::thread::Thread::new::thread_start at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/std/src/sys/unix/thread.rs:108:17 20: 21: --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ error: internal compiler error: broken MIR in Item(DefId(0:11 ~ 107346[3e7c]::foo)) (before pass RemoveNoopLandingPads) at bb0[1]: Failed subtyping Alias( Opaque, AliasTy { args: [ ], def_id: DefId(0:14 ~ 107346[3e7c]::foo::{opaque#0}), }, ) and Closure( DefId(0:12 ~ 107346[3e7c]::foo::{closure#0}), [ i8, Binder(extern "RustCall" fn(()) -> i32, []), (), ], ) --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ | note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:96:25 0: ::emit_diagnostic 1: ::delay_span_bug:: 2: ::fail:: 3: ::run_pass 4: rustc_mir_transform::pass_manager::validate_body 5: rustc_mir_transform::pass_manager::run_passes_inner 6: rustc_mir_transform::run_analysis_to_runtime_passes 7: rustc_mir_transform::mir_drops_elaborated_and_const_checked 8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 9: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 10: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace 11: rustc_interface::passes::analysis 12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 13: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 14: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 15: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 16: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 17: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 18: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 19: std::sys::unix::thread::Thread::new::thread_start at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/std/src/sys/unix/thread.rs:108:17 20: 21: --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ error: internal compiler error: broken MIR in Item(DefId(0:11 ~ 107346[3e7c]::foo)) (after pass RemoveNoopLandingPads) at bb0[1]: Failed subtyping Alias( Opaque, AliasTy { args: [ ], def_id: DefId(0:14 ~ 107346[3e7c]::foo::{opaque#0}), }, ) and Closure( DefId(0:12 ~ 107346[3e7c]::foo::{closure#0}), [ i8, Binder(extern "RustCall" fn(()) -> i32, []), (), ], ) --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ | note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:96:25 0: ::emit_diagnostic 1: ::delay_span_bug:: 2: ::fail:: 3: ::run_pass 4: rustc_mir_transform::pass_manager::validate_body 5: rustc_mir_transform::pass_manager::run_passes_inner 6: rustc_mir_transform::run_analysis_to_runtime_passes 7: rustc_mir_transform::mir_drops_elaborated_and_const_checked 8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 9: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 10: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace 11: rustc_interface::passes::analysis 12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 13: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 14: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 15: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 16: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 17: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 18: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 19: std::sys::unix::thread::Thread::new::thread_start at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/std/src/sys/unix/thread.rs:108:17 20: 21: --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ error: internal compiler error: broken MIR in Item(DefId(0:11 ~ 107346[3e7c]::foo)) (before pass SimplifyCfg-early-opt) at bb0[1]: Failed subtyping Alias( Opaque, AliasTy { args: [ ], def_id: DefId(0:14 ~ 107346[3e7c]::foo::{opaque#0}), }, ) and Closure( DefId(0:12 ~ 107346[3e7c]::foo::{closure#0}), [ i8, Binder(extern "RustCall" fn(()) -> i32, []), (), ], ) --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ | note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:96:25 0: ::emit_diagnostic 1: ::delay_span_bug:: 2: ::fail:: 3: ::run_pass 4: rustc_mir_transform::pass_manager::validate_body 5: rustc_mir_transform::pass_manager::run_passes_inner 6: rustc_mir_transform::run_analysis_to_runtime_passes 7: rustc_mir_transform::mir_drops_elaborated_and_const_checked 8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 9: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 10: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace 11: rustc_interface::passes::analysis 12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 13: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 14: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 15: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 16: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 17: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 18: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 19: std::sys::unix::thread::Thread::new::thread_start at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/std/src/sys/unix/thread.rs:108:17 20: 21: --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ error: internal compiler error: broken MIR in Item(DefId(0:11 ~ 107346[3e7c]::foo)) (after pass SimplifyCfg-early-opt) at bb0[1]: Failed subtyping Alias( Opaque, AliasTy { args: [ ], def_id: DefId(0:14 ~ 107346[3e7c]::foo::{opaque#0}), }, ) and Closure( DefId(0:12 ~ 107346[3e7c]::foo::{closure#0}), [ i8, Binder(extern "RustCall" fn(()) -> i32, []), (), ], ) --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ | note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:96:25 0: ::emit_diagnostic 1: ::delay_span_bug:: 2: ::fail:: 3: ::run_pass 4: rustc_mir_transform::pass_manager::validate_body 5: rustc_mir_transform::pass_manager::run_passes_inner 6: rustc_mir_transform::run_analysis_to_runtime_passes 7: rustc_mir_transform::mir_drops_elaborated_and_const_checked 8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 9: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 10: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace 11: rustc_interface::passes::analysis 12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 13: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 14: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 15: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 16: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 17: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 18: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 19: std::sys::unix::thread::Thread::new::thread_start at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/std/src/sys/unix/thread.rs:108:17 20: 21: --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ error: internal compiler error: broken MIR in Item(DefId(0:11 ~ 107346[3e7c]::foo)) (before pass Derefer) at bb0[1]: Failed subtyping Alias( Opaque, AliasTy { args: [ ], def_id: DefId(0:14 ~ 107346[3e7c]::foo::{opaque#0}), }, ) and Closure( DefId(0:12 ~ 107346[3e7c]::foo::{closure#0}), [ i8, Binder(extern "RustCall" fn(()) -> i32, []), (), ], ) --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ | note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:96:25 0: ::emit_diagnostic 1: ::delay_span_bug:: 2: ::fail:: 3: ::run_pass 4: rustc_mir_transform::pass_manager::validate_body 5: rustc_mir_transform::pass_manager::run_passes_inner 6: rustc_mir_transform::run_analysis_to_runtime_passes 7: rustc_mir_transform::mir_drops_elaborated_and_const_checked 8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 9: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 10: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace 11: rustc_interface::passes::analysis 12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 13: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 14: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 15: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 16: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 17: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 18: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 19: std::sys::unix::thread::Thread::new::thread_start at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/std/src/sys/unix/thread.rs:108:17 20: 21: --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ error: internal compiler error: broken MIR in Item(DefId(0:11 ~ 107346[3e7c]::foo)) (after pass Derefer) at bb0[1]: Failed subtyping Alias( Opaque, AliasTy { args: [ ], def_id: DefId(0:14 ~ 107346[3e7c]::foo::{opaque#0}), }, ) and Closure( DefId(0:12 ~ 107346[3e7c]::foo::{closure#0}), [ i8, Binder(extern "RustCall" fn(()) -> i32, []), (), ], ) --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ | note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:96:25 0: ::emit_diagnostic 1: ::delay_span_bug:: 2: ::fail:: 3: ::run_pass 4: rustc_mir_transform::pass_manager::validate_body 5: rustc_mir_transform::pass_manager::run_passes_inner 6: rustc_mir_transform::run_analysis_to_runtime_passes 7: rustc_mir_transform::mir_drops_elaborated_and_const_checked 8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 9: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 10: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace 11: rustc_interface::passes::analysis 12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 13: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 14: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 15: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 16: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 17: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 18: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 19: std::sys::unix::thread::Thread::new::thread_start at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/std/src/sys/unix/thread.rs:108:17 20: 21: --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ error: internal compiler error: broken MIR in Item(DefId(0:11 ~ 107346[3e7c]::foo)) (after phase change to analysis-post-cleanup) at bb0[1]: Failed subtyping Alias( Opaque, AliasTy { args: [ ], def_id: DefId(0:14 ~ 107346[3e7c]::foo::{opaque#0}), }, ) and Closure( DefId(0:12 ~ 107346[3e7c]::foo::{closure#0}), [ i8, Binder(extern "RustCall" fn(()) -> i32, []), (), ], ) --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ | note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:96:25 0: ::emit_diagnostic 1: ::delay_span_bug:: 2: ::fail:: 3: ::run_pass 4: rustc_mir_transform::pass_manager::run_passes_inner 5: rustc_mir_transform::run_analysis_to_runtime_passes 6: rustc_mir_transform::mir_drops_elaborated_and_const_checked 7: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 8: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 9: rustc_query_impl::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace 10: rustc_interface::passes::analysis 11: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 12: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 13: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 14: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 15: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 16: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 17: as core::ops::function::FnOnce>::call_once at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/alloc/src/boxed.rs:2007:9 18: std::sys::unix::thread::Thread::new::thread_start at /rustc/eb0f3ed59c6508a37c6598bc9762987f053993a7/library/std/src/sys/unix/thread.rs:108:17 19: 20: --> 107346.rs:19:5 | 19 | || 42 | ^^^^^ 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 attach the file at `/tmp/im/rustc-ice-2023-10-03T13:49:46.115359487Z-2977928.txt` to your bug report note: compiler flags: -Z validate-mir query stack during panic: end of query stack error: aborting due to 11 previous errors; 1 warning emitted ```

matthiaskrgr commented 1 year ago

also with validate mir

fn test() -> impl Iterator<Item = impl Sized> {
    Box::new(0..) as Box<dyn Iterator<Item = _>>
}

pub fn main() {}
matthiaskrgr commented 1 year ago

--edition=2021 -Zvalidate-mir

#![feature(async_await)]
#![feature(unsized_locals)]

async fn f() {}

async fn g(x: Box<dyn core::fmt::Display>) {
    let _x = *x;
    f().await;
}

fn main() {
    let _a = g(Box::new(5));
}
matthiaskrgr commented 1 year ago

--edition=2021 -Zvalidate-mir

#![feature(type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]

type F = impl core::future::Future<Output = u8>;

struct Bug {
    V1: [(); {
        fn concrete_use() -> F {
            async {}
        }
        let f: F = async { 1 };
        1
    }],
}

fn main() {}
matthiaskrgr commented 1 year ago

Regression in eb0f3ed59c6508a37c6598bc9762987f053993a7 https://github.com/rust-lang/rust/pull/115025 cc @ouz-a

ouz-a commented 1 year ago

First two runs fine on #116378 (which contains ProjectionElem::Subtype and newly added fixes) but others err without ICE I think, that's intended/normal behaviour ?

So #116378 will fix this issue too