Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE when selecting param-env inherent method with non-lifetime binder #108836

Closed
compiler-errors opened this issue Mar 7, 2023 · 0 comments · Fixed by #108843
Closed

ICE when selecting param-env inherent method with non-lifetime binder #108836

compiler-errors opened this issue Mar 7, 2023 · 0 comments · Fixed by #108843
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@compiler-errors
Copy link
Member

I tried this code:

#![feature(non_lifetime_binders)]

trait Foo: for<T> Bar<T> {}

trait Bar<T> {
    fn method() -> T;
}

fn x<T: Foo>() {
    let _: i32 = T::method();
}

fn main() {}

I expected to see this happen: Works

Instead, this happened: ICEs

Backtrace

error: internal compiler error: /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/compiler/rustc_middle/src/ty/fold.rs:297:33: unexpected bound ty in binder: BoundTy { var: 0, kind: Param(DefId(0:4 ~ test2[3490]::Foo::T), "T") }

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/compiler/rustc_errors/src/lib.rs:1644:9
stack backtrace:
   0:     0x7f75392f1afa - std::backtrace_rs::backtrace::libunwind::trace::h03465bf7db0a5bcb
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f75392f1afa - std::backtrace_rs::backtrace::trace_unsynchronized::hbbaffc0ea2e34ac1
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f75392f1afa - std::sys_common::backtrace::_print_fmt::h1d5b1e20ba71cca1
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f75392f1afa - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h165ce139917464b9
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f753935527e - core::fmt::write::h2792ed374dfffc16
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/core/src/fmt/mod.rs:1232:17
   5:     0x7f75392e4a65 - std::io::Write::write_fmt::h2cc74f32d7d965fd
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/std/src/io/mod.rs:1684:15
   6:     0x7f75392f18c5 - std::sys_common::backtrace::_print::h0f11964b8176847a
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f75392f18c5 - std::sys_common::backtrace::print::h470b2efe95139481
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f75392f463f - std::panicking::default_hook::{{closure}}::h5390a93f85440547
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/std/src/panicking.rs:271:22
   9:     0x7f75392f437b - std::panicking::default_hook::h55ab5fc49931b8c6
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/std/src/panicking.rs:290:9
  10:     0x7f7538034a65 - rustc_driver_impl[d015eba24dbec9f4]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f75392f4e7d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hf5a4865832d21b27
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/alloc/src/boxed.rs:2001:9
  12:     0x7f75392f4e7d - std::panicking::rust_panic_with_hook::h2cb5caacebd97de6
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/std/src/panicking.rs:696:13
  13:     0x7f7538590361 - std[ca26bff2e1d562d1]::panicking::begin_panic::<rustc_errors[c20b44f3691483b8]::ExplicitBug>::{closure#0}
  14:     0x7f7538588c96 - std[ca26bff2e1d562d1]::sys_common::backtrace::__rust_end_short_backtrace::<std[ca26bff2e1d562d1]::panicking::begin_panic<rustc_errors[c20b44f3691483b8]::ExplicitBug>::{closure#0}, !>
  15:     0x7f75385ffad6 - std[ca26bff2e1d562d1]::panicking::begin_panic::<rustc_errors[c20b44f3691483b8]::ExplicitBug>
  16:     0x7f75385dd196 - std[ca26bff2e1d562d1]::panic::panic_any::<rustc_errors[c20b44f3691483b8]::ExplicitBug>
  17:     0x7f75385d8bf6 - <rustc_errors[c20b44f3691483b8]::HandlerInner>::bug::<&alloc[7e0ac51c68d25960]::string::String>
  18:     0x7f75385d88c0 - <rustc_errors[c20b44f3691483b8]::Handler>::bug::<&alloc[7e0ac51c68d25960]::string::String>
  19:     0x7f75385cfaab - rustc_middle[5d26472a27b225ef]::util::bug::opt_span_bug_fmt::<rustc_span[9d0cfc316ec6e1cb]::span_encoding::Span>::{closure#0}
  20:     0x7f75385ce3fa - rustc_middle[5d26472a27b225ef]::ty::context::tls::with_opt::<rustc_middle[5d26472a27b225ef]::util::bug::opt_span_bug_fmt<rustc_span[9d0cfc316ec6e1cb]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f75385ce3c6 - rustc_middle[5d26472a27b225ef]::ty::context::tls::with_context_opt::<rustc_middle[5d26472a27b225ef]::ty::context::tls::with_opt<rustc_middle[5d26472a27b225ef]::util::bug::opt_span_bug_fmt<rustc_span[9d0cfc316ec6e1cb]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f75385cf9f6 - rustc_middle[5d26472a27b225ef]::util::bug::opt_span_bug_fmt::<rustc_span[9d0cfc316ec6e1cb]::span_encoding::Span>
  23:     0x7f753673bc83 - rustc_middle[5d26472a27b225ef]::util::bug::bug_fmt
  24:     0x7f7538295bcc - <rustc_middle[5d26472a27b225ef]::ty::context::TyCtxt>::replace_late_bound_regions_uncached::<rustc_middle[5d26472a27b225ef]::ty::sty::FnSig, <rustc_middle[5d26472a27b225ef]::ty::context::TyCtxt>::replace_late_bound_regions<rustc_middle[5d26472a27b225ef]::ty::sty::FnSig, <rustc_middle[5d26472a27b225ef]::ty::context::TyCtxt>::erase_late_bound_regions<rustc_middle[5d26472a27b225ef]::ty::sty::FnSig>::{closure#0}>::{closure#0}>::{closure#0}
  25:     0x7f753647b9fc - <&rustc_middle[5d26472a27b225ef]::ty::list::List<rustc_middle[5d26472a27b225ef]::ty::subst::GenericArg> as rustc_type_ir[8a1cfb389b230c51]::fold::TypeFoldable<rustc_middle[5d26472a27b225ef]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[5d26472a27b225ef]::ty::fold::BoundVarReplacer<rustc_middle[5d26472a27b225ef]::ty::fold::FnMutDelegate>>
  26:     0x7f753647b405 - <rustc_middle[5d26472a27b225ef]::ty::sty::AliasTy as rustc_type_ir[8a1cfb389b230c51]::fold::TypeFoldable<rustc_middle[5d26472a27b225ef]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[5d26472a27b225ef]::ty::fold::BoundVarReplacer<rustc_middle[5d26472a27b225ef]::ty::fold::FnMutDelegate>>
  27:     0x7f753641a5aa - <rustc_hir_typeck[f02af9c3a020a3d4]::method::probe::ProbeContext>::assemble_inherent_candidates
  28:     0x7f75364126bb - <rustc_infer[7c33ae0544901c48]::infer::InferCtxt>::probe::<core[7c472ba66930c5d6]::result::Result<rustc_hir_typeck[f02af9c3a020a3d4]::method::probe::Pick, rustc_hir_typeck[f02af9c3a020a3d4]::method::MethodError>, <rustc_hir_typeck[f02af9c3a020a3d4]::fn_ctxt::FnCtxt>::probe_op<<rustc_hir_typeck[f02af9c3a020a3d4]::fn_ctxt::FnCtxt>::probe_for_name::{closure#0}, rustc_hir_typeck[f02af9c3a020a3d4]::method::probe::Pick>::{closure#4}>
  29:     0x7f7536440bf5 - <rustc_hir_typeck[f02af9c3a020a3d4]::fn_ctxt::FnCtxt>::resolve_fully_qualified_call
  30:     0x7f753642cf41 - <rustc_hir_typeck[f02af9c3a020a3d4]::fn_ctxt::FnCtxt>::check_expr_path
  31:     0x7f75363d9378 - <rustc_hir_typeck[f02af9c3a020a3d4]::fn_ctxt::FnCtxt>::check_call
  32:     0x7f75363f8be3 - <rustc_hir_typeck[f02af9c3a020a3d4]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  33:     0x7f753642bc28 - <rustc_hir_typeck[f02af9c3a020a3d4]::fn_ctxt::FnCtxt>::check_decl
  34:     0x7f75364282bb - <rustc_hir_typeck[f02af9c3a020a3d4]::fn_ctxt::FnCtxt>::check_block_with_expected
  35:     0x7f75363f9116 - <rustc_hir_typeck[f02af9c3a020a3d4]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  36:     0x7f7536fceb74 - <rustc_hir_typeck[f02af9c3a020a3d4]::fn_ctxt::FnCtxt>::check_return_expr
  37:     0x7f7536fc6f67 - rustc_hir_typeck[f02af9c3a020a3d4]::check::check_fn
  38:     0x7f7536fb1377 - rustc_hir_typeck[f02af9c3a020a3d4]::typeck
  39:     0x7f753649738c - rustc_query_system[b004d522c7f04025]::query::plumbing::try_execute_query::<rustc_query_impl[90210f7f475d36bc]::queries::typeck, rustc_query_impl[90210f7f475d36bc]::plumbing::QueryCtxt>
  40:     0x7f753780e74f - rustc_data_structures[f58a2cf4d4a4a31d]::sync::par_for_each_in::<&[rustc_span[9d0cfc316ec6e1cb]::def_id::LocalDefId], <rustc_middle[5d26472a27b225ef]::hir::map::Map>::par_body_owners<rustc_hir_typeck[f02af9c3a020a3d4]::typeck_item_bodies::{closure#0}>::{closure#0}>
  41:     0x7f753780e50f - rustc_hir_typeck[f02af9c3a020a3d4]::typeck_item_bodies
  42:     0x7f75376872dd - rustc_query_system[b004d522c7f04025]::query::plumbing::try_execute_query::<rustc_query_impl[90210f7f475d36bc]::queries::typeck_item_bodies, rustc_query_impl[90210f7f475d36bc]::plumbing::QueryCtxt>
  43:     0x7f7537686fcb - <rustc_query_impl[90210f7f475d36bc]::Queries as rustc_middle[5d26472a27b225ef]::ty::query::QueryEngine>::typeck_item_bodies
  44:     0x7f7536331153 - <rustc_session[80e90e186d06c1cb]::session::Session>::time::<(), rustc_hir_analysis[3ca3b9af3da40c63]::check_crate::{closure#7}>
  45:     0x7f753632dc0d - rustc_hir_analysis[3ca3b9af3da40c63]::check_crate
  46:     0x7f7536321e62 - rustc_interface[26c5cf3d4e6d8495]::passes::analysis
  47:     0x7f753789365d - rustc_query_system[b004d522c7f04025]::query::plumbing::try_execute_query::<rustc_query_impl[90210f7f475d36bc]::queries::analysis, rustc_query_impl[90210f7f475d36bc]::plumbing::QueryCtxt>
  48:     0x7f753789335f - <rustc_query_impl[90210f7f475d36bc]::Queries as rustc_middle[5d26472a27b225ef]::ty::query::QueryEngine>::analysis
  49:     0x7f75376bc876 - <rustc_middle[5d26472a27b225ef]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[d015eba24dbec9f4]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[7c472ba66930c5d6]::result::Result<(), rustc_span[9d0cfc316ec6e1cb]::ErrorGuaranteed>>
  50:     0x7f75372a5c18 - rustc_span[9d0cfc316ec6e1cb]::with_source_map::<core[7c472ba66930c5d6]::result::Result<(), rustc_span[9d0cfc316ec6e1cb]::ErrorGuaranteed>, rustc_interface[26c5cf3d4e6d8495]::interface::run_compiler<core[7c472ba66930c5d6]::result::Result<(), rustc_span[9d0cfc316ec6e1cb]::ErrorGuaranteed>, rustc_driver_impl[d015eba24dbec9f4]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  51:     0x7f753729d29c - std[ca26bff2e1d562d1]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[26c5cf3d4e6d8495]::util::run_in_thread_pool_with_globals<rustc_interface[26c5cf3d4e6d8495]::interface::run_compiler<core[7c472ba66930c5d6]::result::Result<(), rustc_span[9d0cfc316ec6e1cb]::ErrorGuaranteed>, rustc_driver_impl[d015eba24dbec9f4]::run_compiler::{closure#1}>::{closure#0}, core[7c472ba66930c5d6]::result::Result<(), rustc_span[9d0cfc316ec6e1cb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7c472ba66930c5d6]::result::Result<(), rustc_span[9d0cfc316ec6e1cb]::ErrorGuaranteed>>
  52:     0x7f753729ccca - <<std[ca26bff2e1d562d1]::thread::Builder>::spawn_unchecked_<rustc_interface[26c5cf3d4e6d8495]::util::run_in_thread_pool_with_globals<rustc_interface[26c5cf3d4e6d8495]::interface::run_compiler<core[7c472ba66930c5d6]::result::Result<(), rustc_span[9d0cfc316ec6e1cb]::ErrorGuaranteed>, rustc_driver_impl[d015eba24dbec9f4]::run_compiler::{closure#1}>::{closure#0}, core[7c472ba66930c5d6]::result::Result<(), rustc_span[9d0cfc316ec6e1cb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7c472ba66930c5d6]::result::Result<(), rustc_span[9d0cfc316ec6e1cb]::ErrorGuaranteed>>::{closure#1} as core[7c472ba66930c5d6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  53:     0x7f75392fecb3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h53b8e926121c1b9a
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/alloc/src/boxed.rs:1987:9
  54:     0x7f75392fecb3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he5a7c9fb3937128b
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/alloc/src/boxed.rs:1987:9
  55:     0x7f75392fecb3 - std::sys::unix::thread::Thread::new::thread_start::hadeb8936ad30fb42
                               at /rustc/44cfafe2fafe816395d3acc434663a45d5178c41/library/std/src/sys/unix/thread.rs:108:17
  56:     0x7f753484344b - start_thread
  57:     0x7f753457e52f - __clone
  58:                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: rustc 1.69.0-nightly (44cfafe2f 2023-03-03) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `x`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error; 1 warning emitted

@compiler-errors compiler-errors added the C-bug Category: This is a bug. label Mar 7, 2023
@compiler-errors compiler-errors self-assigned this Mar 7, 2023
@Noratrieb Noratrieb added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 5, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 9, 2023
…rs-method-probe, r=jackh726

Instantiate instead of erasing binder when probing param methods

Fixes rust-lang#108836

There is a really old comment saying that a `WhereClauseCandidate` probe candidate "should not contain any inference variables", but I'm not really confident that that comment applies anymore. In contrast, other candidates that we assemble during method probe contain inference variables in their substitutions (e.g. `InherentImplCandidate`)...

Since this change is made only to support a nightly feature, I'm happy to gate the new behavior behind this feature flag or discuss it further.

r? types
@bors bors closed this as completed in 4e165c1 Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants