rust-lang / rust

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

Compiler crash with type_alias_impl_trait on the very latest version #100818

Closed BattyBoopers closed 1 year ago

BattyBoopers commented 2 years ago

Code

#![feature(type_alias_impl_trait)]
use std::future::Future;

fn main() {
    type SomeFuture<'t> = impl 't + Future<Output = ()>;
    type SomeClosure = impl for<'t> FnOnce(&'t str) -> SomeFuture<'t>;
    fn coerce_closure(f: SomeClosure) {}
    coerce_closure(|x: &str| async move {});
}

This crashes with the very latest version (cargo +nightly-2022-08-19 run), but not with the previous version (cargo +nightly-2022-08-18 run)

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (e1b28cd2f 2022-08-19)
binary: rustc
commit-hash: e1b28cd2f16bd5b832183d7968cae3bb9213e78d
commit-date: 2022-08-19
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0

Error output

   Compiling testing_stuff v0.1.0 (/tmp/testing_stuff)
thread 'rustc' panicked at 'assertion failed: self.scc_universes[scc] == ty::UniverseIndex::ROOT', compiler/rustc_borrowck/src/region_infer/mod.rs:718:9
stack backtrace:
   0:     0x7f09ef36e6d0 - std::backtrace_rs::backtrace::libunwind::trace::h850ff1a0c3d9fdd7
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f09ef36e6d0 - std::backtrace_rs::backtrace::trace_unsynchronized::hb027726a633b9940
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f09ef36e6d0 - std::sys_common::backtrace::_print_fmt::h5caab733d2f6988a
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f09ef36e6d0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdde469ef2c900889
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f09ef3c976e - core::fmt::write::h652f9c882cd915d6
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f09ef35f5d5 - std::io::Write::write_fmt::hc86f310f58407a21
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/io/mod.rs:1672:15
   6:     0x7f09ef371393 - std::sys_common::backtrace::_print::he3151b9612f2cb1c
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f09ef371393 - std::sys_common::backtrace::print::h4ec5b0bf2cf6801f
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f09ef371393 - std::panicking::default_hook::{{closure}}::h0eea56e2b7a0583d
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/panicking.rs:295:22
   9:     0x7f09ef37107f - std::panicking::default_hook::h9faf2b89120c3ca0
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/panicking.rs:314:9
  10:     0x7f09f1bab494 - rustc_driver[8170f2effe76d0b1]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f09ef371bcd - std::panicking::rust_panic_with_hook::h41881d4c2e288663
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/panicking.rs:702:17
  12:     0x7f09ef3719e1 - std::panicking::begin_panic_handler::{{closure}}::h7434a1ed3ac56100
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/panicking.rs:586:13
  13:     0x7f09ef36ebdc - std::sys_common::backtrace::__rust_end_short_backtrace::hbf29cadbfa104d7f
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f09ef371742 - rust_begin_unwind
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/panicking.rs:584:5
  15:     0x7f09ef3c6283 - core::panicking::panic_fmt::hb36dfafe85614116
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/core/src/panicking.rs:142:14
  16:     0x7f09ef3c60cd - core::panicking::panic::hd4b68b0dd41a23c9
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/core/src/panicking.rs:48:5
  17:     0x7f09f09940e4 - <rustc_borrowck[3abe5495380e92d7]::region_infer::RegionInferenceContext>::solve
  18:     0x7f09f09675b9 - rustc_borrowck[3abe5495380e92d7]::nll::compute_regions
  19:     0x7f09f090cb16 - rustc_borrowck[3abe5495380e92d7]::do_mir_borrowck
  20:     0x7f09f153f85c - rustc_borrowck[3abe5495380e92d7]::mir_borrowck
  21:     0x7f09f153f011 - <rustc_borrowck[3abe5495380e92d7]::provide::{closure#0} as core[ca3ac0430488f954]::ops::function::FnOnce<(rustc_middle[f312dfbcb803dd41]::ty::context::TyCtxt, rustc_span[3aa3f8a4aae1164f]::def_id::LocalDefId)>>::call_once
  22:     0x7f09f0f3053d - <rustc_query_system[c671b936ad850e7d]::dep_graph::graph::DepGraph<rustc_middle[f312dfbcb803dd41]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[f312dfbcb803dd41]::ty::context::TyCtxt, rustc_span[3aa3f8a4aae1164f]::def_id::LocalDefId, &rustc_middle[f312dfbcb803dd41]::mir::query::BorrowCheckResult>
  23:     0x7f09f0f2f80d - rustc_query_system[c671b936ad850e7d]::query::plumbing::try_execute_query::<rustc_query_impl[f43bacc242a2796b]::plumbing::QueryCtxt, rustc_query_system[c671b936ad850e7d]::query::caches::DefaultCache<rustc_span[3aa3f8a4aae1164f]::def_id::LocalDefId, &rustc_middle[f312dfbcb803dd41]::mir::query::BorrowCheckResult>>
  24:     0x7f09f1ab060a - <rustc_query_impl[f43bacc242a2796b]::Queries as rustc_middle[f312dfbcb803dd41]::ty::query::QueryEngine>::mir_borrowck
  25:     0x7f09f1f66e42 - <rustc_typeck[3f43e31030e845d6]::collect::type_of::find_opaque_ty_constraints_for_tait::ConstraintLocator>::check
  26:     0x7f09f1f667be - rustc_typeck[3f43e31030e845d6]::collect::type_of::find_opaque_ty_constraints_for_tait
  27:     0x7f09f181cc6d - rustc_typeck[3f43e31030e845d6]::collect::type_of::type_of
  28:     0x7f09f0f99177 - <rustc_query_system[c671b936ad850e7d]::dep_graph::graph::DepGraph<rustc_middle[f312dfbcb803dd41]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[f312dfbcb803dd41]::ty::context::TyCtxt, rustc_span[3aa3f8a4aae1164f]::def_id::DefId, rustc_middle[f312dfbcb803dd41]::ty::Ty>
  29:     0x7f09f0f971eb - rustc_query_system[c671b936ad850e7d]::query::plumbing::get_query::<rustc_query_impl[f43bacc242a2796b]::queries::type_of, rustc_query_impl[f43bacc242a2796b]::plumbing::QueryCtxt>
  30:     0x7f09f149edcb - rustc_typeck[3f43e31030e845d6]::check::check::check_item_type
  31:     0x7f09f149b10e - rustc_typeck[3f43e31030e845d6]::check::check::check_mod_item_types
  32:     0x7f09f0a8c8f1 - <rustc_query_system[c671b936ad850e7d]::dep_graph::graph::DepGraph<rustc_middle[f312dfbcb803dd41]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[f312dfbcb803dd41]::ty::context::TyCtxt, rustc_span[3aa3f8a4aae1164f]::def_id::LocalDefId, ()>
  33:     0x7f09f0a8b992 - rustc_query_system[c671b936ad850e7d]::query::plumbing::try_execute_query::<rustc_query_impl[f43bacc242a2796b]::plumbing::QueryCtxt, rustc_query_system[c671b936ad850e7d]::query::caches::DefaultCache<rustc_span[3aa3f8a4aae1164f]::def_id::LocalDefId, ()>>
  34:     0x7f09f15f2b13 - rustc_query_system[c671b936ad850e7d]::query::plumbing::get_query::<rustc_query_impl[f43bacc242a2796b]::queries::check_mod_item_types, rustc_query_impl[f43bacc242a2796b]::plumbing::QueryCtxt>
  35:     0x7f09f188e24c - <rustc_middle[f312dfbcb803dd41]::hir::map::Map>::for_each_module::<rustc_typeck[3f43e31030e845d6]::check_crate::{closure#6}::{closure#0}>
  36:     0x7f09f1582b15 - rustc_typeck[3f43e31030e845d6]::check_crate
  37:     0x7f09f1582557 - rustc_interface[3d10aad4a167cf18]::passes::analysis
  38:     0x7f09f1943452 - <rustc_query_system[c671b936ad850e7d]::dep_graph::graph::DepGraph<rustc_middle[f312dfbcb803dd41]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[f312dfbcb803dd41]::ty::context::TyCtxt, (), core[ca3ac0430488f954]::result::Result<(), rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>>
  39:     0x7f09f1942bd7 - rustc_query_system[c671b936ad850e7d]::query::plumbing::try_execute_query::<rustc_query_impl[f43bacc242a2796b]::plumbing::QueryCtxt, rustc_query_system[c671b936ad850e7d]::query::caches::DefaultCache<(), core[ca3ac0430488f954]::result::Result<(), rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>>>
  40:     0x7f09f19426ce - rustc_query_system[c671b936ad850e7d]::query::plumbing::get_query::<rustc_query_impl[f43bacc242a2796b]::queries::analysis, rustc_query_impl[f43bacc242a2796b]::plumbing::QueryCtxt>
  41:     0x7f09f12c6d5e - <rustc_interface[3d10aad4a167cf18]::passes::QueryContext>::enter::<rustc_driver[8170f2effe76d0b1]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[ca3ac0430488f954]::result::Result<(), rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>>
  42:     0x7f09f12c2e1e - <rustc_interface[3d10aad4a167cf18]::interface::Compiler>::enter::<rustc_driver[8170f2effe76d0b1]::run_compiler::{closure#1}::{closure#2}, core[ca3ac0430488f954]::result::Result<core[ca3ac0430488f954]::option::Option<rustc_interface[3d10aad4a167cf18]::queries::Linker>, rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>>
  43:     0x7f09f12be91c - rustc_span[3aa3f8a4aae1164f]::with_source_map::<core[ca3ac0430488f954]::result::Result<(), rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>, rustc_interface[3d10aad4a167cf18]::interface::create_compiler_and_run<core[ca3ac0430488f954]::result::Result<(), rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>, rustc_driver[8170f2effe76d0b1]::run_compiler::{closure#1}>::{closure#1}>
  44:     0x7f09f12be302 - rustc_interface[3d10aad4a167cf18]::interface::create_compiler_and_run::<core[ca3ac0430488f954]::result::Result<(), rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>, rustc_driver[8170f2effe76d0b1]::run_compiler::{closure#1}>
  45:     0x7f09f12bcea1 - <scoped_tls[a31a4b7c7b1b4a01]::ScopedKey<rustc_span[3aa3f8a4aae1164f]::SessionGlobals>>::set::<rustc_interface[3d10aad4a167cf18]::interface::run_compiler<core[ca3ac0430488f954]::result::Result<(), rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>, rustc_driver[8170f2effe76d0b1]::run_compiler::{closure#1}>::{closure#0}, core[ca3ac0430488f954]::result::Result<(), rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>>
  46:     0x7f09f12bcb8f - std[6176ebdb849c2141]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3d10aad4a167cf18]::util::run_in_thread_pool_with_globals<rustc_interface[3d10aad4a167cf18]::interface::run_compiler<core[ca3ac0430488f954]::result::Result<(), rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>, rustc_driver[8170f2effe76d0b1]::run_compiler::{closure#1}>::{closure#0}, core[ca3ac0430488f954]::result::Result<(), rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>>::{closure#0}, core[ca3ac0430488f954]::result::Result<(), rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>>
  47:     0x7f09f19d42c9 - <<std[6176ebdb849c2141]::thread::Builder>::spawn_unchecked_<rustc_interface[3d10aad4a167cf18]::util::run_in_thread_pool_with_globals<rustc_interface[3d10aad4a167cf18]::interface::run_compiler<core[ca3ac0430488f954]::result::Result<(), rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>, rustc_driver[8170f2effe76d0b1]::run_compiler::{closure#1}>::{closure#0}, core[ca3ac0430488f954]::result::Result<(), rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>>::{closure#0}, core[ca3ac0430488f954]::result::Result<(), rustc_errors[28a60eca1a08eed5]::ErrorGuaranteed>>::{closure#1} as core[ca3ac0430488f954]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  48:     0x7f09ef37b9c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h20aa7f83790b6d6c
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/alloc/src/boxed.rs:1935:9
  49:     0x7f09ef37b9c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h082931b1ec2f572d
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/alloc/src/boxed.rs:1935:9
  50:     0x7f09ef37b9c3 - std::sys::unix::thread::Thread::new::thread_start::h5e56cc2c93616735
                               at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/sys/unix/thread.rs:108:17
  51:     0x7f09ef087b27 - <unknown>
  52:     0x7f09ef10a78c - <unknown>
  53:                0x0 - <unknown>

error: internal compiler error: unexpected panic

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

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.65.0-nightly (e1b28cd2f 2022-08-19) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental

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

query stack during panic:
#0 [mir_borrowck] borrow-checking `main`
#1 [type_of] computing type of `main::SomeFuture::{opaque#0}`
#2 [check_mod_item_types] checking item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `testing_stuff`
Backtrace

``` Compiling testing_stuff v0.1.0 (/tmp/testing_stuff) thread 'rustc' panicked at 'assertion failed: self.scc_universes[scc] == ty::UniverseIndex::ROOT', compiler/rustc_borrowck/src/region_infer/mod.rs:718:9 stack backtrace: 0: rust_begin_unwind at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/std/src/panicking.rs:584:5 1: core::panicking::panic_fmt at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/core/src/panicking.rs:142:14 2: core::panicking::panic at /rustc/e1b28cd2f16bd5b832183d7968cae3bb9213e78d/library/core/src/panicking.rs:48:5 3: ::solve 4: rustc_borrowck::nll::compute_regions 5: rustc_borrowck::do_mir_borrowck 6: rustc_borrowck::mir_borrowck 7: >::call_once 8: >::with_task:: 9: rustc_query_system::query::plumbing::try_execute_query::> 10: ::mir_borrowck 11: ::check 12: rustc_typeck::collect::type_of::find_opaque_ty_constraints_for_tait 13: rustc_typeck::collect::type_of::type_of 14: >::with_task:: 15: rustc_query_system::query::plumbing::get_query:: 16: rustc_typeck::check::check::check_item_type 17: rustc_typeck::check::check::check_mod_item_types 18: >::with_task:: 19: rustc_query_system::query::plumbing::try_execute_query::> 20: rustc_query_system::query::plumbing::get_query:: 21: ::for_each_module:: 22: rustc_typeck::check_crate 23: rustc_interface::passes::analysis 24: >::with_task::> 25: rustc_query_system::query::plumbing::try_execute_query::>> 26: rustc_query_system::query::plumbing::get_query:: 27: ::enter::> 28: ::enter::, rustc_errors::ErrorGuaranteed>> 29: rustc_span::with_source_map::, rustc_interface::interface::create_compiler_and_run, rustc_driver::run_compiler::{closure#1}>::{closure#1}> 30: rustc_interface::interface::create_compiler_and_run::, rustc_driver::run_compiler::{closure#1}> 31: >::set::, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>> note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. 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.65.0-nightly (e1b28cd2f 2022-08-19) running on x86_64-unknown-linux-gnu note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [mir_borrowck] borrow-checking `main` #1 [type_of] computing type of `main::SomeFuture::{opaque#0}` #2 [check_mod_item_types] checking item types in top-level module #3 [analysis] running analysis passes on this crate end of query stack error: could not compile `testing_stuff` ```

matthiaskrgr commented 2 years ago

This is probably a duplicate of https://github.com/rust-lang/rust/issues/97099 of which the fix was reverted recently

Noratrieb commented 2 years ago

Yes, bisection points at the revert

searched nightlies: from nightly-2022-08-01 to nightly-2022-08-20 regressed nightly: nightly-2022-08-19 searched commit range: https://github.com/rust-lang/rust/compare/9c20b2a8cc7588decb6de25ac6a7912dcef24d65...0b79f758c9aa6646606662a6d623a0752286cd17 regressed commit: https://github.com/rust-lang/rust/commit/8064a495086c2e63c0ef77e8e82fe3b9b5dc535f

bisected with cargo-bisect-rustc v0.6.4 Host triple: x86_64-unknown-linux-gnu Reproduce with: ```bash cargo bisect-rustc --end=2022-08-20 --access=github ```
JohnTitor commented 1 year ago

Triage: Fixed on the latest nightly, @rustbot labels: +E-needs-test