rust-lang / rust

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

ICE: 'Ok([Binder {..}, ...) is not fully resolved' #113846

Open gpace1 opened 1 year ago

gpace1 commented 1 year ago

Code

trait Www {
    type W;
}

trait Xxx: Www<W = Self::X> {
    type X;
}

trait Yyy: Xxx {}

trait Zzz<'a>: Yyy + Xxx<X = Self::Z> {
    type Z;
}

trait Aaa {
    type Y: Yyy;
}

trait Bbb: Aaa<Y = Self::B> {
    type B: for<'a> Zzz<'a>;
}

impl<T> Bbb for T
where
    T: Aaa,
    T::Y: for<'a> Zzz<'a>,
{
    type B = T::Y;
}

The example will compile if the lifetime 'a of Zzz and all the associated HRTBs for Zzz are removed.

Meta

Error occurs for both stable, beta, and nightly. Code was tested in the playground.

Tested Versions: stable: rustc 1.71.0 (8ede3aae2 2023-07-12) running on x86_64-unknown-linux-gnu nightly: rustc 1.73.0-nightly (0e8e857b1 2023-07-16) running on x86_64-unknown-linux-gnu

Error output

'`Ok([Binder(TraitPredicate(<<T as Aaa>::Y as Zzz<'a>>, polarity:Positive), [Region(BrNamed(DefId(0:18 ~ playground[90b5]::{impl#0}::'a), 'a))]), Binder(ProjectionPredicate(AliasTy { substs: [<T as Aaa>::Y], def_id: DefId(0:6 ~ playground[90b5]::Xxx::X) }, Term::Ty(<<T as Aaa>::Y as Zzz<'a>>::Z)), [Region(BrNamed(DefId(0:18 ~ playground[90b5]::{impl#0}::'a), 'a))]), Binder(TraitPredicate(<<T as Aaa>::Y as Xxx>, polarity:Positive), [Region(BrNamed(DefId(0:18 ~ playground[90b5]::{impl#0}::'a), 'a))]), Binder(ProjectionPredicate(AliasTy { substs: [<T as Aaa>::Y], def_id: DefId(0:4 ~ playground[90b5]::Www::W) }, Term::Ty(<<T as Aaa>::Y as Zzz<'_>>::Z)), [Region(BrNamed(DefId(0:18 ~ playground[90b5]::{impl#0}::'a), 'a))]), Binder(TraitPredicate(<<T as Aaa>::Y as Www>, polarity:Positive), [Region(BrNamed(DefId(0:18 ~ playground[90b5]::{impl#0}::'a), 'a))]), Binder(TraitPredicate(<<T as Aaa>::Y as Yyy>, polarity:Positive), [Region(BrNamed(DefId(0:18 ~ playground[90b5]::{impl#0}::'a), 'a))]), Binder(TraitPredicate(<T as Aaa>, polarity:Positive), []), Binder(TraitPredicate(<T as std::marker::Sized>, polarity:Positive), [])])` is not fully resolved', /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/compiler/rustc_infer/src/infer/mod.rs:1350:9
Backtrace

``` Compiling playground v0.0.1 (/playground) thread 'rustc' panicked at '`Ok([Binder { value: TraitPredicate(<::Y as Zzz<'a>>, polarity:Positive), bound_vars: [Region(BrNamed(DefId(0:18 ~ playground[4866]::{impl#0}::'a), 'a))] }, Binder { value: ProjectionPredicate(AliasTy { args: [::Y], def_id: DefId(0:6 ~ playground[4866]::Xxx::X) }, Term::Ty(<::Y as Zzz<'a>>::Z)), bound_vars: [Region(BrNamed(DefId(0:18 ~ playground[4866]::{impl#0}::'a), 'a))] }, Binder { value: TraitPredicate(<::Y as Xxx>, polarity:Positive), bound_vars: [Region(BrNamed(DefId(0:18 ~ playground[4866]::{impl#0}::'a), 'a))] }, Binder { value: ProjectionPredicate(AliasTy { args: [::Y], def_id: DefId(0:4 ~ playground[4866]::Www::W) }, Term::Ty(<::Y as Zzz<'_>>::Z)), bound_vars: [Region(BrNamed(DefId(0:18 ~ playground[4866]::{impl#0}::'a), 'a))] }, Binder { value: TraitPredicate(<::Y as Www>, polarity:Positive), bound_vars: [Region(BrNamed(DefId(0:18 ~ playground[4866]::{impl#0}::'a), 'a))] }, Binder { value: TraitPredicate(<::Y as Yyy>, polarity:Positive), bound_vars: [Region(BrNamed(DefId(0:18 ~ playground[4866]::{impl#0}::'a), 'a))] }, Binder { value: TraitPredicate(, polarity:Positive), bound_vars: [] }, Binder { value: TraitPredicate(, polarity:Positive), bound_vars: [] }])` is not fully resolved', /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/compiler/rustc_infer/src/infer/mod.rs:1379:9 stack backtrace: 0: 0x7f6a8800b1e1 - std::backtrace_rs::backtrace::libunwind::trace::h5f856d2c12cc6674 at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7f6a8800b1e1 - std::backtrace_rs::backtrace::trace_unsynchronized::h8449257397d4b934 at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f6a8800b1e1 - std::sys_common::backtrace::_print_fmt::hc0c3bab7873ac244 at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/sys_common/backtrace.rs:65:5 3: 0x7f6a8800b1e1 - ::fmt::h3787c35683fa4233 at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7f6a8807119c - core::fmt::rt::Argument::fmt::hae0c3aa49888479e at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/core/src/fmt/rt.rs:138:9 5: 0x7f6a8807119c - core::fmt::write::h0f833d45d904ecbb at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/core/src/fmt/mod.rs:1094:21 6: 0x7f6a87ffdb8e - std::io::Write::write_fmt::h6fd13360259fea22 at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/io/mod.rs:1714:15 7: 0x7f6a8800aff5 - std::sys_common::backtrace::_print::h715af68f97f33bd8 at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7f6a8800aff5 - std::sys_common::backtrace::print::h292b9e4a1d37eead at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7f6a8800dda3 - std::panicking::default_hook::{{closure}}::hab7084ecbd5f7152 at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/panicking.rs:269:22 10: 0x7f6a8800db34 - std::panicking::default_hook::hfbb8ba894af6577e at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/panicking.rs:288:9 11: 0x7f6a8b2d143b - rustc_driver_impl[5bf76b44b01c010b]::install_ice_hook::{closure#0} 12: 0x7f6a8800e5ce - as core::ops::function::Fn>::call::hc6428110305b5cbe at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/alloc/src/boxed.rs:2021:9 13: 0x7f6a8800e5ce - std::panicking::rust_panic_with_hook::h8a8f983a7c12e89b at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/panicking.rs:709:13 14: 0x7f6a8800e357 - std::panicking::begin_panic_handler::{{closure}}::hcbc604b49027ff32 at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/panicking.rs:597:13 15: 0x7f6a8800b646 - std::sys_common::backtrace::__rust_end_short_backtrace::hb85256103978a5ea at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/sys_common/backtrace.rs:151:18 16: 0x7f6a8800e0a2 - rust_begin_unwind at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/panicking.rs:593:5 17: 0x7f6a8806d543 - core::panicking::panic_fmt::h3cc36a41bb894309 at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/core/src/panicking.rs:67:14 18: 0x7f6a89be7ee2 - rustc_trait_selection[4828e09977927b86]::traits::normalize_param_env_or_error 19: 0x7f6a89be2e0c - rustc_ty_utils[ff0a06d2a6228635]::ty::param_env 20: 0x7f6a892f2474 - rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::__rust_begin_short_backtrace::> 21: 0x7f6a892f2440 - >::call_once 22: 0x7f6a893197f5 - rustc_query_system[95ed59712a59403e]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::QueryCtxt, false> 23: 0x7f6a8ac3e601 - rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::param_env::get_query_non_incr::__rust_end_short_backtrace 24: 0x7f6a89ece0d0 - rustc_middle[835d091ebc4d05d9]::query::plumbing::query_get_at::>> 25: 0x7f6a89ecc312 - rustc_hir_analysis[dc7bd52400bbf8cf]::check::wfcheck::check_well_formed 26: 0x7f6a892e065c - rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::__rust_begin_short_backtrace::> 27: 0x7f6a89d0a7f6 - rustc_query_system[95ed59712a59403e]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::QueryCtxt, false> 28: 0x7f6a89d0a562 - rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace 29: 0x7f6a8a6a0cdc - rustc_data_structures[d2b76f525e315882]::sync::par_for_each_in::<&[rustc_hir[9bd7153587c508c5]::hir::ImplItemId], ::par_impl_items::{closure#0}> 30: 0x7f6a8a6a0b7a - rustc_hir_analysis[dc7bd52400bbf8cf]::check::wfcheck::check_mod_type_wf 31: 0x7f6a89ff6bbc - rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::__rust_begin_short_backtrace::> 32: 0x7f6a89ff6b9e - >::call_once 33: 0x7f6a89c2b2ff - rustc_query_system[95ed59712a59403e]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::QueryCtxt, false> 34: 0x7f6a8ac1a662 - rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace 35: 0x7f6a8a6f1f27 - rustc_data_structures[d2b76f525e315882]::sync::par_for_each_in::<&[rustc_hir[9bd7153587c508c5]::hir_id::OwnerId], ::par_for_each_module::{closure#0}> 36: 0x7f6a8a6f1cf7 - ::track_errors:: 37: 0x7f6a8a6f0aa8 - rustc_hir_analysis[dc7bd52400bbf8cf]::check_crate 38: 0x7f6a8a6f026a - rustc_interface[950bb6185283f172]::passes::analysis 39: 0x7f6a8a752f2a - rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::__rust_begin_short_backtrace::> 40: 0x7f6a8a752f19 - >::call_once 41: 0x7f6a8a91df48 - rustc_query_system[95ed59712a59403e]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[2a0ca4be8ec05b8b]::plumbing::QueryCtxt, false> 42: 0x7f6a8a91dd27 - rustc_query_impl[2a0ca4be8ec05b8b]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 43: 0x7f6a8a5a2e85 - ::enter::> 44: 0x7f6a8a5a24b2 - ::enter::, rustc_span[a69db53e102135]::ErrorGuaranteed>> 45: 0x7f6a8a59b825 - rustc_span[a69db53e102135]::set_source_map::, rustc_interface[950bb6185283f172]::interface::run_compiler, rustc_driver_impl[5bf76b44b01c010b]::run_compiler::{closure#1}>::{closure#0}::{closure#0}> 46: 0x7f6a8a59b296 - >::set::, rustc_driver_impl[5bf76b44b01c010b]::run_compiler::{closure#1}>::{closure#0}, core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>> 47: 0x7f6a8a59a85c - std[c0adc0b90f4efda2]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[5bf76b44b01c010b]::run_compiler::{closure#1}>::{closure#0}, core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>> 48: 0x7f6a8a59a61e - <::spawn_unchecked_, rustc_driver_impl[5bf76b44b01c010b]::run_compiler::{closure#1}>::{closure#0}, core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ef917bd033b821fa]::result::Result<(), rustc_span[a69db53e102135]::ErrorGuaranteed>>::{closure#1} as core[ef917bd033b821fa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 49: 0x7f6a88018c55 - as core::ops::function::FnOnce>::call_once::hee3992ac1361b768 at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/alloc/src/boxed.rs:2007:9 50: 0x7f6a88018c55 - as core::ops::function::FnOnce>::call_once::h98eb33f4039b4e2e at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/alloc/src/boxed.rs:2007:9 51: 0x7f6a88018c55 - std::sys::unix::thread::Thread::new::thread_start::h4a5bbbf722280c2f at /rustc/0e8e857b11f60a785aea24a84f280f6dad7a4d42/library/std/src/sys/unix/thread.rs:108:17 52: 0x7f6a87edf609 - start_thread 53: 0x7f6a87e02133 - clone 54: 0x0 - error: 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.73.0-nightly (0e8e857b1 2023-07-16) running on x86_64-unknown-linux-gnu note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [param_env] computing normalized predicates of `` #1 [check_well_formed] checking that `` is well-formed #2 [check_mod_type_wf] checking that types are well-formed in top-level module #3 [analysis] running analysis passes on this crate end of query stack ```

Jules-Bertholet commented 1 year ago

Regressed from error in 1.65: https://rust.godbolt.org/z/ra4nMa31W

@rustbot label regression-from-stable-to-stable

matthiaskrgr commented 1 year ago

probably duplicate of https://github.com/rust-lang/rust/issues/103708 in some way?

I have another 20-30 code snippets around thal all trigger the ice if anyone is interested

lukas-code commented 1 year ago

Regressed in https://github.com/rust-lang/rust/pull/98559.

apiraino commented 1 year ago

@lukas-code cool! how did trace back to that PR? I was bisecting but ended in this bunch of commits for nightly-2022-12-18

commit[0] 2022-12-16: Auto merge of #105018 - zertosh:path_buf_deref_mut, r=dtolnay
  commit[1] 2022-12-16: Auto merge of #102318 - Amanieu:default_alloc_error_handler, r=oli-obk
  commit[2] 2022-12-17: Auto merge of #105804 - matthiaskrgr:rollup-iaqlbl3, r=matthiaskrgr
  commit[3] 2022-12-17: Auto merge of #105811 - ojeda:Dwarnings-no_fp_fmt_parse, r=Mark-Simulacrum
  commit[4] 2022-12-17: Auto merge of #105794 - ChrisDenton:internal-doc, r=jyn514
  commit[5] 2022-12-17: Auto merge of #105820 - matthiaskrgr:rollup-uzm1l8f, r=matthiaskrgr
  commit[6] 2022-12-17: Auto merge of #105421 - jacobbramley:jb/branch-prot-check, r=nagisa
  commit[7] 2022-12-17: Auto merge of #105800 - lqd:dylib-thinlto, r=bjorn3
  commit[8] 2022-12-17: Auto merge of #105827 - flip1995:clippyup, r=matthiaskrgr
  commit[9] 2022-12-17: Auto merge of #105145 - Ayush1325:sequential-remote-server, r=Mark-Simulacrum

Same result for #103708. But now I suspect my results are wrong (the ICE blurb changed the output, maybe that's the reason)

Tentatively closing in favor of #103708?

lukas-code commented 1 year ago

@apiraino I got the same results at first, but none of the changes looked related. Then I manually checked nightly-2022-12-17 and saw that it still ICEed. I continued bisecting with this script:

#!/bin/sh
E=$(cargo check 2>&1)
! grep "panicked" <<< "$E"

... and got these results:

found 10 bors merge commits in the specified range
  commit[0] 2022-09-09: Auto merge of #101611 - GuillaumeGomez:rollup-yw3qtug, r=GuillaumeGomez
  commit[1] 2022-09-09: Auto merge of #101617 - Dylan-DPC:rollup-iiy4ipc, r=Dylan-DPC
  commit[2] 2022-09-10: Auto merge of #101609 - flip1995:clippyup, r=Manishearth
  commit[3] 2022-09-10: Auto merge of #99916 - dpaoliello:stablizerawdylib, r=wesleywiser
  commit[4] 2022-09-10: Auto merge of #101639 - matthiaskrgr:rollup-sewkrgm, r=matthiaskrgr
  commit[5] 2022-09-10: Auto merge of #101483 - oli-obk:guaranteed_opt, r=fee1-dead
  commit[6] 2022-09-10: Auto merge of #100968 - cjgillot:mir-upvar-vec, r=wesleywiser
  commit[7] 2022-09-10: Auto merge of #101652 - Dylan-DPC:rollup-f4atky0, r=Dylan-DPC
  commit[8] 2022-09-10: Auto merge of #101647 - crlf0710:test_for_99551, r=bjorn3
  commit[9] 2022-09-10: Auto merge of #98559 - jackh726:remove-reempty, r=oli-obk

Given the error message from https://rust.godbolt.org/z/ra4nMa31W, the remove-reempty looked suspicious to me and so I manually built from the bors merge (2287107588d92889d282e6cd3c1ca5df34cd34a5) and it's parent (4a6ac3c225d6322caaf0ef86623cddc74e5260c6) to verify that it is indeed caused by that PR.

apiraino commented 1 year ago

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium