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

Relating different kinds: '?1 Bar #126129

Closed
HubertK05 opened this issue Jun 7, 2024 · 1 comment · Fixed by #126142
Closed

Relating different kinds: '?1 Bar #126129

HubertK05 opened this issue Jun 7, 2024 · 1 comment · Fixed by #126142
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

@HubertK05
Copy link

Code

trait Foo<'s> {}

impl<'s> Foo<'s> for () {}

struct Bar;

impl<'s, T: Foo<'s>> From<T> for Bar {
    fn from(_: T) -> Self {
        Bar
    }
}

fn main() {
    let _: Bar = ((),).into();
}

Meta

rustc --version --verbose:

rustc 1.80.0-nightly (98489f248 2024-06-06)
binary: rustc
commit-hash: 98489f2487465f3765e5dd28d7305ebfd40f0865
commit-date: 2024-06-06
host: x86_64-pc-windows-msvc
release: 1.80.0-nightly
LLVM version: 18.1.7

Error output

error: internal compiler error: compiler\rustc_infer\src\infer\at.rs:364:21: relating different kinds: '?1 Bar
Backtrace

thread 'rustc' panicked at compiler\rustc_infer\src\infer\at.rs:364:21:
Box<dyn Any>
stack backtrace:
   0:     0x7ff8840dd5c3 - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/98489f2487465f3765e5dd28d7305ebfd40f0865/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ff8840dd5c3 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/98489f2487465f3765e5dd28d7305ebfd40f0865/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff8840dd5c3 - std::backtrace::Backtrace::create
                               at /rustc/98489f2487465f3765e5dd28d7305ebfd40f0865/library\std\src\backtrace.rs:331
   3:     0x7ff8840dd50a - std::backtrace::Backtrace::force_capture
                               at /rustc/98489f2487465f3765e5dd28d7305ebfd40f0865/library\std\src\backtrace.rs:312
   4:     0x7ff86553eeb0 - memchr
   5:     0x7ff8840f7127 - alloc::boxed::impl$50::call
                               at /rustc/98489f2487465f3765e5dd28d7305ebfd40f0865/library\alloc\src\boxed.rs:2077
   6:     0x7ff8840f7127 - std::panicking::rust_panic_with_hook
                               at /rustc/98489f2487465f3765e5dd28d7305ebfd40f0865/library\std\src\panicking.rs:799
   7:     0x7ff8669442b8 - <rustc_hir_pretty[4c0de44792ef1cfb]::State>::print_variant
   8:     0x7ff866940c69 - <rustc_hir_pretty[4c0de44792ef1cfb]::State>::print_variant
   9:     0x7ff866940959 - <rustc_hir_pretty[4c0de44792ef1cfb]::State>::print_variant
  10:     0x7ff866950c95 - <rustc_errors[99fd697b917f4736]::diagnostic::BugAbort as rustc_errors[99fd697b917f4736]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7ff86686cde7 - rustc_middle[5dc078e192a68ea9]::util::bug::bug_fmt
  12:     0x7ff86684f7fd - rustc_middle[5dc078e192a68ea9]::ty::consts::const_param_default
  13:     0x7ff86684f636 - rustc_middle[5dc078e192a68ea9]::ty::consts::const_param_default
  14:     0x7ff86686ccf2 - rustc_middle[5dc078e192a68ea9]::util::bug::bug_fmt
  15:     0x7ff863e6536c - <rustc_middle[5dc078e192a68ea9]::ty::generic_args::GenericArg as rustc_infer[a6d3d17cf94ac3b1]::infer::at::ToTrace>::to_trace
  16:     0x7ff86616e75e - <rustc_const_eval[7ec54cfaef628c24]::errors::WriteThroughImmutablePointer as rustc_errors[99fd697b917f4736]::diagnostic::LintDiagnostic<()>>::decorate_lint
  17:     0x7ff866280c98 - <rustc_infer[a6d3d17cf94ac3b1]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[b8bc7545bfc5c697]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_similar_impl_candidates
  18:     0x7ff86628c459 - <rustc_infer[a6d3d17cf94ac3b1]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[b8bc7545bfc5c697]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::try_to_add_help_message
  19:     0x7ff86627b369 - <rustc_infer[a6d3d17cf94ac3b1]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[b8bc7545bfc5c697]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_selection_error
  20:     0x7ff86628f7d1 - <rustc_infer[a6d3d17cf94ac3b1]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[b8bc7545bfc5c697]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_fulfillment_error
  21:     0x7ff866275f16 - <rustc_infer[a6d3d17cf94ac3b1]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[b8bc7545bfc5c697]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
  22:     0x7ff8642b3792 - <rustc_codegen_llvm[5c8af4c302afe308]::builder::Builder as rustc_codegen_ssa[1683cac83e930815]::traits::builder::BuilderMethods>::load_operand
  23:     0x7ff8643238c5 - rustc_hir_typeck[1794d65660cbff74]::typeck
  24:     0x7ff864bc303a - rustc_query_impl[6ec7f1b502ec4006]::plumbing::query_key_hash_verify_all
  25:     0x7ff864b15b89 - rustc_ty_utils[87d1b6c5c188bb5e]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  26:     0x7ff864bcb104 - rustc_query_impl[6ec7f1b502ec4006]::plumbing::query_key_hash_verify_all
  27:     0x7ff86438dba5 - <rustc_hir_typeck[1794d65660cbff74]::upvar::InferBorrowKind as rustc_hir_typeck[1794d65660cbff74]::expr_use_visitor::Delegate>::borrow
  28:     0x7ff864403c5d - rustc_hir_analysis[47701f7ab1204fd1]::check_crate
  29:     0x7ff864160352 - rustc_interface[64758328f8f95d43]::passes::resolver_for_lowering_raw
  30:     0x7ff8613a7e57 - rustc_interface[64758328f8f95d43]::passes::analysis
  31:     0x7ff863d4a6ea - <dyn std[f65618803adafc2b]::io::Write as nu_ansi_term[8940d970465991f5]::write::AnyWrite>::write_str
  32:     0x7ff863c6adc9 - rustc_ty_utils[87d1b6c5c188bb5e]::ty::adt_sized_constraint
  33:     0x7ff863d4fc53 - rustc_query_impl[6ec7f1b502ec4006]::query_system
  34:     0x7ff8613651ad - _LNan_C
  35:     0x7ff86136256f - _LNan_C
  36:     0x7ff86136a269 - _LNan_C
  37:     0x7ff88410832d - alloc::boxed::impl$48::call_once
                               at /rustc/98489f2487465f3765e5dd28d7305ebfd40f0865/library\alloc\src\boxed.rs:2063
  38:     0x7ff88410832d - alloc::boxed::impl$48::call_once
                               at /rustc/98489f2487465f3765e5dd28d7305ebfd40f0865/library\alloc\src\boxed.rs:2063
  39:     0x7ff88410832d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/98489f2487465f3765e5dd28d7305ebfd40f0865/library\std\src\sys\pal\windows\thread.rs:52
  40:     0x7ff8f3c37344 - BaseThreadInitThunk
  41:     0x7ff8f4b026b1 - RtlUserThreadStart


rustc version: 1.80.0-nightly (98489f248 2024-06-06)
platform: x86_64-pc-windows-msvc

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack

@HubertK05 HubertK05 added 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. labels Jun 7, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 7, 2024
@compiler-errors compiler-errors self-assigned this Jun 7, 2024
@rust-lang rust-lang deleted a comment Jun 7, 2024
@matthiaskrgr
Copy link
Member

Regression in nightly-2024-03-06
bisects to #121826

compiler-errors added a commit to compiler-errors/rust that referenced this issue Jun 13, 2024
…=jackh726

Harmonize using root or leaf obligation in trait error reporting

When rust-lang#121826 changed the error reporting to use root obligation and not the leafmost obligation, it didn't actually make sure that all the other diagnostics helper functions used the right obligation.

Specifically, when reporting similar impl candidates we are looking for impls of the root obligation, but trying to match them against the trait ref of the leaf obligation.

This does a few other miscellaneous changes. There's a lot more clean-up that could be done here, but working with this code is really grief-inducing due to how messy it has become over the years. Someone really needs to show it love. 😓

r? `@estebank`

Fixes rust-lang#126129
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Jun 13, 2024
…=jackh726

Harmonize using root or leaf obligation in trait error reporting

When rust-lang#121826 changed the error reporting to use root obligation and not the leafmost obligation, it didn't actually make sure that all the other diagnostics helper functions used the right obligation.

Specifically, when reporting similar impl candidates we are looking for impls of the root obligation, but trying to match them against the trait ref of the leaf obligation.

This does a few other miscellaneous changes. There's a lot more clean-up that could be done here, but working with this code is really grief-inducing due to how messy it has become over the years. Someone really needs to show it love. 😓

r? `@estebank`

Fixes rust-lang#126129
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 13, 2024
@bors bors closed this as completed in 25c55c5 Jun 13, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 13, 2024
Rollup merge of rust-lang#126142 - compiler-errors:trait-ref-split, r=jackh726

Harmonize using root or leaf obligation in trait error reporting

When rust-lang#121826 changed the error reporting to use root obligation and not the leafmost obligation, it didn't actually make sure that all the other diagnostics helper functions used the right obligation.

Specifically, when reporting similar impl candidates we are looking for impls of the root obligation, but trying to match them against the trait ref of the leaf obligation.

This does a few other miscellaneous changes. There's a lot more clean-up that could be done here, but working with this code is really grief-inducing due to how messy it has become over the years. Someone really needs to show it love. 😓

r? ``@estebank``

Fixes rust-lang#126129
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.

5 participants