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

ICE: `unexpected bound var resolution for HirId(DefId(` #113016

Closed matthiaskrgr closed 1 year ago

matthiaskrgr commented 1 year ago

Code

#![feature(non_lifetime_binders)]

trait Trait<Input> {}

fn main(x: impl for<f> Trait<'_, Assoc = impl Trait<f>  + '_>) {}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (f7ca9df69 2023-06-24)
binary: rustc
commit-hash: f7ca9df69549470541fbf542f87a03eb9ed024b6
commit-date: 2023-06-24
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5

Error output

warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
 --> treereduce.out:1:12
  |
1 | #![feature(non_lifetime_binders)]
  |            ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: type parameter `f` should have an upper camel case name
 --> treereduce.out:5:21
  |
5 | fn main(x: impl for<f> Trait<'_, Assoc = impl Trait<f>  + '_>) {}
  |                     ^ help: convert the identifier to upper camel case (notice the capitalization): `F`
  |
  = note: `#[warn(non_camel_case_types)]` on by default

error[E0658]: anonymous lifetimes in `impl Trait` are unstable
 --> treereduce.out:5:59
  |
5 | fn main(x: impl for<f> Trait<'_, Assoc = impl Trait<f>  + '_>) {}
  |                                                           ^^ expected named lifetime parameter
  |
  = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable
help: consider introducing a named lifetime parameter
  |
5 | fn main<'a>(x: impl for<f> Trait<'_, Assoc = impl Trait<f>  + 'a>) {}
  |        ++++                                                   ~~

error[E0658]: anonymous lifetimes in `impl Trait` are unstable
 --> treereduce.out:5:30
  |
5 | fn main(x: impl for<f> Trait<'_, Assoc = impl Trait<f>  + '_>) {}
  |                              ^^ expected named lifetime parameter
  |
  = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable
help: consider introducing a named lifetime parameter
  |
5 | fn main<'a>(x: impl for<f> Trait<'a, Assoc = impl Trait<f>  + '_>) {}
  |        ++++                      ~~
Backtrace

``` error: internal compiler error: compiler/rustc_hir_analysis/src/astconv/mod.rs:2571:28: unexpected bound var resolution for HirId(DefId(0:5 ~ treereduce[9f27]::main).11): None thread 'rustc' panicked at 'Box', /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/compiler/rustc_errors/src/lib.rs:1650:9 stack backtrace: 0: 0x7f038722be31 - std::backtrace_rs::backtrace::libunwind::trace::h5d192c9c54b15f60 at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7f038722be31 - std::backtrace_rs::backtrace::trace_unsynchronized::hc7d3204e467fac03 at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f038722be31 - std::sys_common::backtrace::_print_fmt::h2af83df47bc668bf at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/std/src/sys_common/backtrace.rs:65:5 3: 0x7f038722be31 - ::fmt::hf5a4fac06076e902 at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7f038728d5df - core::fmt::rt::Argument::fmt::h1f69f816cde54b71 at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/core/src/fmt/rt.rs:138:9 5: 0x7f038728d5df - core::fmt::write::h555ebd423ad27fc9 at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/core/src/fmt/mod.rs:1094:21 6: 0x7f038721e967 - std::io::Write::write_fmt::ha768284cce22c0d1 at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/std/src/io/mod.rs:1714:15 7: 0x7f038722bc45 - std::sys_common::backtrace::_print::hd74993f4555d3caf at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7f038722bc45 - std::sys_common::backtrace::print::h55223f11226300d1 at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7f038722e9f3 - std::panicking::default_hook::{{closure}}::h434fb03b0a8c72cd at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/std/src/panicking.rs:269:22 10: 0x7f038722e784 - std::panicking::default_hook::h26d4937b6653693a at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/std/src/panicking.rs:288:9 11: 0x7f0386001f4b - rustc_driver_impl[374d8943f7df2d38]::install_ice_hook::{closure#0} 12: 0x7f038722f21e - as core::ops::function::Fn>::call::h3bf5cd9997a69c0a at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/alloc/src/boxed.rs:2007:9 13: 0x7f038722f21e - std::panicking::rust_panic_with_hook::hb4f1f210fa9d7d78 at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/std/src/panicking.rs:709:13 14: 0x7f03865ca5e1 - std[dcf3549276dd02fc]::panicking::begin_panic::::{closure#0} 15: 0x7f03865c8226 - std[dcf3549276dd02fc]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 16: 0x7f03865b8776 - std[dcf3549276dd02fc]::panicking::begin_panic:: 17: 0x7f038651b374 - ::bug:: 18: 0x7f038651b1f6 - ::bug:: 19: 0x7f038653bb9c - rustc_middle[7578aedf3d8ae35a]::util::bug::opt_span_bug_fmt::::{closure#0} 20: 0x7f038653b49a - rustc_middle[7578aedf3d8ae35a]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 21: 0x7f038653b46a - rustc_middle[7578aedf3d8ae35a]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 22: 0x7f038427404d - rustc_middle[7578aedf3d8ae35a]::util::bug::bug_fmt 23: 0x7f0384e5d0dc - ::res_to_ty 24: 0x7f0384e55d02 - ::ast_ty_to_ty_inner 25: 0x7f0385166ffe - rustc_hir_analysis[12ff737570cd8dab]::astconv::generics::create_substs_for_generic_args::<::create_substs_for_ast_path::{closure#0}::SubstsForAstPathCtxt> 26: 0x7f038536765e - ::instantiate_poly_trait_ref_inner 27: 0x7f0385366425 - ::instantiate_poly_trait_ref 28: 0x7f0384adcb6d - rustc_hir_analysis[12ff737570cd8dab]::collect::predicates_of::gather_explicit_predicates_of 29: 0x7f0384ad9f58 - rustc_query_impl[6d34ccc9082d3cbf]::plumbing::__rust_begin_short_backtrace::> 30: 0x7f03840f71a6 - rustc_query_system[8ef922b68c9e8ac6]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[6d34ccc9082d3cbf]::plumbing::QueryCtxt, false> 31: 0x7f03840f6e2f - rustc_query_impl[6d34ccc9082d3cbf]::query_impl::explicit_predicates_of::get_query_non_incr::__rust_end_short_backtrace 32: 0x7f038588b62a - rustc_hir_analysis[12ff737570cd8dab]::collect::predicates_defined_on 33: 0x7f0383ffaefd - rustc_query_impl[6d34ccc9082d3cbf]::plumbing::__rust_begin_short_backtrace::> 34: 0x7f03840f7490 - rustc_query_system[8ef922b68c9e8ac6]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[6d34ccc9082d3cbf]::plumbing::QueryCtxt, false> 35: 0x7f038597bfaf - rustc_query_impl[6d34ccc9082d3cbf]::query_impl::predicates_defined_on::get_query_non_incr::__rust_end_short_backtrace 36: 0x7f0385886dea - rustc_hir_analysis[12ff737570cd8dab]::collect::predicates_of::predicates_of 37: 0x7f0383ffaf6d - rustc_query_impl[6d34ccc9082d3cbf]::plumbing::__rust_begin_short_backtrace::> 38: 0x7f03840f717a - rustc_query_system[8ef922b68c9e8ac6]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[6d34ccc9082d3cbf]::plumbing::QueryCtxt, false> 39: 0x7f03859b3dbf - rustc_query_impl[6d34ccc9082d3cbf]::query_impl::predicates_of::get_query_non_incr::__rust_end_short_backtrace 40: 0x7f0384947e01 - ::visit_item 41: 0x7f0384945f33 - rustc_hir_analysis[12ff737570cd8dab]::collect::collect_mod_item_types 42: 0x7f0384cbe61c - rustc_query_impl[6d34ccc9082d3cbf]::plumbing::__rust_begin_short_backtrace::> 43: 0x7f0384cbe5fe - >::call_once 44: 0x7f038471498f - rustc_query_system[8ef922b68c9e8ac6]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[6d34ccc9082d3cbf]::plumbing::QueryCtxt, false> 45: 0x7f03859ab3a4 - rustc_query_impl[6d34ccc9082d3cbf]::query_impl::collect_mod_item_types::get_query_non_incr::__rust_end_short_backtrace 46: 0x7f03854af117 - ::for_each_module:: 47: 0x7f03854aecf2 - ::track_errors:: 48: 0x7f03854ad501 - rustc_hir_analysis[12ff737570cd8dab]::check_crate 49: 0x7f03854a613a - rustc_interface[25e9143dc71174ae]::passes::analysis 50: 0x7f03854edf3a - rustc_query_impl[6d34ccc9082d3cbf]::plumbing::__rust_begin_short_backtrace::> 51: 0x7f03854edf29 - >::call_once 52: 0x7f038567bfa8 - rustc_query_system[8ef922b68c9e8ac6]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[6d34ccc9082d3cbf]::plumbing::QueryCtxt, false> 53: 0x7f038567bd79 - rustc_query_impl[6d34ccc9082d3cbf]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 54: 0x7f0385634465 - ::enter::> 55: 0x7f03851b7c9b - ::enter::, rustc_span[59b12f7e70a4d344]::ErrorGuaranteed>> 56: 0x7f03851b3ae9 - rustc_span[59b12f7e70a4d344]::set_source_map::, rustc_interface[25e9143dc71174ae]::interface::run_compiler, rustc_driver_impl[374d8943f7df2d38]::run_compiler::{closure#1}>::{closure#0}::{closure#0}> 57: 0x7f03851b3615 - >::set::, rustc_driver_impl[374d8943f7df2d38]::run_compiler::{closure#1}>::{closure#0}, core[6907b49ead676d89]::result::Result<(), rustc_span[59b12f7e70a4d344]::ErrorGuaranteed>> 58: 0x7f03851b2c36 - std[dcf3549276dd02fc]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[374d8943f7df2d38]::run_compiler::{closure#1}>::{closure#0}, core[6907b49ead676d89]::result::Result<(), rustc_span[59b12f7e70a4d344]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6907b49ead676d89]::result::Result<(), rustc_span[59b12f7e70a4d344]::ErrorGuaranteed>> 59: 0x7f038587aff5 - <::spawn_unchecked_, rustc_driver_impl[374d8943f7df2d38]::run_compiler::{closure#1}>::{closure#0}, core[6907b49ead676d89]::result::Result<(), rustc_span[59b12f7e70a4d344]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6907b49ead676d89]::result::Result<(), rustc_span[59b12f7e70a4d344]::ErrorGuaranteed>>::{closure#1} as core[6907b49ead676d89]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 60: 0x7f0387239695 - as core::ops::function::FnOnce>::call_once::h7bd6d94c21941047 at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/alloc/src/boxed.rs:1993:9 61: 0x7f0387239695 - as core::ops::function::FnOnce>::call_once::h16cbf2f6802b7a97 at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/alloc/src/boxed.rs:1993:9 62: 0x7f0387239695 - std::sys::unix::thread::Thread::new::thread_start::h654b71fdae4d62c8 at /rustc/f7ca9df69549470541fbf542f87a03eb9ed024b6/library/std/src/sys/unix/thread.rs:108:17 63: 0x7f0382c9d44b - 64: 0x7f0382d20e40 - 65: 0x0 - 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.72.0-nightly (f7ca9df69 2023-06-24) running on x86_64-unknown-linux-gnu query stack during panic: #0 [explicit_predicates_of] computing explicit predicates of `main` #1 [predicates_defined_on] computing predicates of `main` #2 [predicates_of] computing predicates of `main` #3 [collect_mod_item_types] collecting item types in top-level module #4 [analysis] running analysis passes on this crate end of query stack error: aborting due to 3 previous errors; 2 warnings emitted For more information about this error, try `rustc --explain E0658`. ```

asquared31415 commented 1 year ago

minimized

#![feature(non_lifetime_binders)]

trait Trait<Input> {}

fn uwu(_: impl for<T> Trait<impl Trait<T>>) {}
matthiaskrgr commented 1 year ago

Bisected to https://github.com/rust-lang/rust/pull/107489 surprised_pikachu.png :sweat_smile: