Skip to content

ICE: compiler/rustc_infer/src/infer/at.rs:400:21: relating different kinds: '?20 utoipa::openapi::RefOr<utoipa::openapi::Schema> #127761

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

Closed
RocketRace opened this issue Jul 15, 2024 · 1 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.

Comments

@RocketRace
Copy link

RocketRace commented Jul 15, 2024

Code

I hit this ICE while at work. I was unfortunately not able to reduce this example further as it was behaving unpredictably based on the toolchain and the version of utoipa installed (either =4.2.2 or =4.2.3).

use utoipa::ToSchema;

#[derive(ToSchema)]
struct A {
    #[schema(schema_with = B::schema)]
    b: B,
}
#[derive(ToSchema)]
struct B;
[package]
name = "example"
version = "0.1.0"
edition = "2021"

[dependencies]
utoipa = "=4.2.2"

Meta

I could repro the issue in beta but not in nightly.

rustc --version --verbose:

rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: aarch64-apple-darwin
release: 1.79.0
LLVM version: 18.1.7

Error output

The ICE itself:

error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:364:21: relating different kinds: '?6 utoipa::openapi::RefOr<utoipa::openapi::Schema>

Sometimes (in some toolchains and with some versions of the crate), instead of the ICE I get ~2000 lines of type errors:
https://pastebin.com/9hR6ruWY

On nightly (1.81.0-nightly (d8a38b000 2024-06-19)), and with utoipa = "=4.2.2", I managed to get the somewhat sane:

error[E0277]: the trait bound `(&str, utoipa::openapi::RefOr<Schema>): Into<utoipa::openapi::RefOr<Schema>>` is not satisfied
   --> src/lib.rs:3:10
    |
3   | #[derive(ToSchema)]
    |          ^^^^^^^^ the trait `ToSchema<'_>` is not implemented for `(&str, utoipa::openapi::RefOr<Schema>)`, which is required by `(&str, utoipa::openapi::RefOr<Schema>): Into<utoipa::openapi::RefOr<Schema>>`
    |
    = help: the trait `ToSchema<'_>` is implemented for `()`
    = help: for that trait implementation, expected `()`, found `(&str, utoipa::openapi::RefOr<Schema>)`
    = note: required for `utoipa::openapi::RefOr<Schema>` to implement `From<(&str, utoipa::openapi::RefOr<Schema>)>`
    = note: required for `(&str, utoipa::openapi::RefOr<Schema>)` to implement `Into<utoipa::openapi::RefOr<Schema>>`
note: required by a bound in `ObjectBuilder::property`
   --> /<home>/.cargo/registry/src/index.crates.io-6f17d22bba15001f/utoipa-4.2.2/src/openapi/schema.rs:876:41
    |
876 |     pub fn property<S: Into<String>, I: Into<RefOr<Schema>>>(
    |                                         ^^^^^^^^^^^^^^^^^^^ required by this bound in `ObjectBuilder::property`
    = note: this error originates in the derive macro `ToSchema` (in Nightly builds, run with -Z macro-backtrace for more info)
 
For more information about this error, try `rustc --explain E0277`.
error: could not compile `example` (lib) due to 1 previous error
Backtrace

thread 'rustc' panicked at compiler/rustc_infer/src/infer/at.rs:400:21:
Box<dyn Any>
stack backtrace:
   0:        0x103165750 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1f3776e0b5c7517d
   1:        0x1031a8470 - core::fmt::write::heedef092c8c0962e
   2:        0x10315ba1c - std::io::Write::write_fmt::h7178e8e2ea928914
   3:        0x1031655a8 - std::sys_common::backtrace::print::h417292deb95532ed
   4:        0x103167b2c - std::panicking::default_hook::{{closure}}::h0cb68f1228c4613a
   5:        0x103167820 - std::panicking::default_hook::h24535936bc1f51de
   6:        0x10c633828 - <alloc[d07bc629de031c28]::boxed::Box<rustc_driver_impl[17630cf877ef70bb]::install_ice_hook::{closure#0}> as core[fca7800875c611c6]::ops::function::Fn<(&dyn for<'a, 'b> core[fca7800875c611c6]::ops::function::Fn<(&'a core[fca7800875c611c6]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[fca7800875c611c6]::marker::Sync + core[fca7800875c611c6]::marker::Send, &core[fca7800875c611c6]::panic::panic_info::PanicInfo)>>::call
   7:        0x103168524 - std::panicking::rust_panic_with_hook::h5db4d2345b297bed
   8:        0x10c6bf198 - std[e84bc52996b8b382]::panicking::begin_panic::<rustc_errors[3520987c35dd2513]::ExplicitBug>::{closure#0}
   9:        0x10c6bdce0 - std[e84bc52996b8b382]::sys_common::backtrace::__rust_end_short_backtrace::<std[e84bc52996b8b382]::panicking::begin_panic<rustc_errors[3520987c35dd2513]::ExplicitBug>::{closure#0}, !>
  10:        0x11068b750 - std[e84bc52996b8b382]::panicking::begin_panic::<rustc_errors[3520987c35dd2513]::ExplicitBug>
  11:        0x10c6c00c0 - <rustc_errors[3520987c35dd2513]::diagnostic::BugAbort as rustc_errors[3520987c35dd2513]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:        0x10d123970 - rustc_middle[e187904418cf7088]::util::bug::opt_span_bug_fmt::<rustc_span[984a238feadb13f5]::span_encoding::Span>::{closure#0}
  13:        0x10d114d14 - rustc_middle[e187904418cf7088]::ty::context::tls::with_opt::<rustc_middle[e187904418cf7088]::util::bug::opt_span_bug_fmt<rustc_span[984a238feadb13f5]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:        0x10d114ce0 - rustc_middle[e187904418cf7088]::ty::context::tls::with_context_opt::<rustc_middle[e187904418cf7088]::ty::context::tls::with_opt<rustc_middle[e187904418cf7088]::util::bug::opt_span_bug_fmt<rustc_span[984a238feadb13f5]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:        0x110724fdc - rustc_middle[e187904418cf7088]::util::bug::bug_fmt
  16:        0x10cc647a0 - <rustc_middle[e187904418cf7088]::ty::generic_args::GenericArg as rustc_infer[88fe184f288a0526]::infer::at::ToTrace>::to_trace
  17:        0x10deaf9b0 - <rustc_infer[88fe184f288a0526]::infer::at::At>::eq::<rustc_middle[e187904418cf7088]::ty::generic_args::GenericArg>
  18:        0x10debe430 - <rustc_trait_selection[67ea6c3922506dc7]::traits::engine::ObligationCtxt>::eq::<rustc_middle[e187904418cf7088]::ty::generic_args::GenericArg>
  19:        0x10df13fa4 - <rustc_infer[88fe184f288a0526]::infer::InferCtxt>::probe::<bool, <rustc_infer[88fe184f288a0526]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[67ea6c3922506dc7]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_similar_impl_candidates::{closure#0}>
  20:        0x10dd6b30c - <rustc_infer[88fe184f288a0526]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[67ea6c3922506dc7]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_similar_impl_candidates
  21:        0x10dd71444 - <rustc_infer[88fe184f288a0526]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[67ea6c3922506dc7]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::try_to_add_help_message
  22:        0x10dd67fa4 - <rustc_infer[88fe184f288a0526]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[67ea6c3922506dc7]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_selection_error
  23:        0x10dd739b4 - <rustc_infer[88fe184f288a0526]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[67ea6c3922506dc7]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_fulfillment_error
  24:        0x10dd652c4 - <rustc_infer[88fe184f288a0526]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[67ea6c3922506dc7]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
  25:        0x10ca310d4 - <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_argument_types
  26:        0x10ca309c8 - <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_method_argument_types
  27:        0x10ca77f40 - <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_expr_kind
  28:        0x10ca1c228 - <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  29:        0x10ca6f874 - <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_expr_kind
  30:        0x10ca1c228 - <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  31:        0x10ca6f874 - <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_expr_kind
  32:        0x10ca1c228 - <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  33:        0x10cb82ccc - <&mut <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_expr_tuple::{closure#1} as core[fca7800875c611c6]::ops::function::FnOnce<((usize, &rustc_hir[8f63456841fca8c8]::hir::Expr),)>>::call_once
  34:        0x10cbacf68 - <rustc_middle[e187904418cf7088]::ty::Ty as rustc_type_ir[a6f4416129910f14]::interner::CollectAndApply<rustc_middle[e187904418cf7088]::ty::Ty, rustc_middle[e187904418cf7088]::ty::Ty>>::collect_and_apply::<core[fca7800875c611c6]::iter::adapters::map::Map<core[fca7800875c611c6]::iter::adapters::enumerate::Enumerate<core[fca7800875c611c6]::slice::iter::Iter<rustc_hir[8f63456841fca8c8]::hir::Expr>>, <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_expr_tuple::{closure#1}>, <rustc_middle[e187904418cf7088]::ty::Ty>::new_tup_from_iter<core[fca7800875c611c6]::iter::adapters::map::Map<core[fca7800875c611c6]::iter::adapters::enumerate::Enumerate<core[fca7800875c611c6]::slice::iter::Iter<rustc_hir[8f63456841fca8c8]::hir::Expr>>, <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_expr_tuple::{closure#1}>, rustc_middle[e187904418cf7088]::ty::Ty>::{closure#0}>
  35:        0x10ca73724 - <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_expr_kind
  36:        0x10ca1c228 - <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  37:        0x10ca389e8 - <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_block_with_expected
  38:        0x10ca1c228 - <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  39:        0x10ca1ccac - <rustc_hir_typeck[8fa4488aa1bca511]::fn_ctxt::FnCtxt>::check_return_expr
  40:        0x10cb38fc8 - rustc_hir_typeck[8fa4488aa1bca511]::check::check_fn
  41:        0x10cad49e4 - rustc_hir_typeck[8fa4488aa1bca511]::typeck
  42:        0x10d869804 - rustc_query_impl[a9dcee21c1ea9187]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a9dcee21c1ea9187]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e187904418cf7088]::query::erase::Erased<[u8; 8usize]>>
  43:        0x10d9527d0 - <rustc_query_impl[a9dcee21c1ea9187]::query_impl::typeck::dynamic_query::{closure#2} as core[fca7800875c611c6]::ops::function::FnOnce<(rustc_middle[e187904418cf7088]::ty::context::TyCtxt, rustc_span[984a238feadb13f5]::def_id::LocalDefId)>>::call_once
  44:        0x10d818ef8 - rustc_query_system[3fe282a48bd1d9e8]::query::plumbing::try_execute_query::<rustc_query_impl[a9dcee21c1ea9187]::DynamicConfig<rustc_query_system[3fe282a48bd1d9e8]::query::caches::VecCache<rustc_span[984a238feadb13f5]::def_id::LocalDefId, rustc_middle[e187904418cf7088]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a9dcee21c1ea9187]::plumbing::QueryCtxt, true>
  45:        0x10d8ca8c4 - rustc_query_impl[a9dcee21c1ea9187]::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
  46:        0x10c914ec8 - std[e84bc52996b8b382]::panicking::try::<(), core[fca7800875c611c6]::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures[d96e6b3ae716122c]::sync::parallel::disabled::par_for_each_in<&[rustc_span[984a238feadb13f5]::def_id::LocalDefId], <rustc_middle[e187904418cf7088]::hir::map::Map>::par_body_owners<rustc_hir_analysis[c1c0f42cf391c6f]::check_crate::{closure#4}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>>
  47:        0x10c86d944 - rustc_data_structures[d96e6b3ae716122c]::sync::parallel::disabled::par_for_each_in::<&[rustc_span[984a238feadb13f5]::def_id::LocalDefId], <rustc_middle[e187904418cf7088]::hir::map::Map>::par_body_owners<rustc_hir_analysis[c1c0f42cf391c6f]::check_crate::{closure#4}>::{closure#0}>
  48:        0x10c98bbf0 - rustc_hir_analysis[c1c0f42cf391c6f]::check_crate
  49:        0x10cd8de3c - rustc_interface[617d4417f0fbb0b3]::passes::analysis
  50:        0x10d86989c - rustc_query_impl[a9dcee21c1ea9187]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a9dcee21c1ea9187]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e187904418cf7088]::query::erase::Erased<[u8; 1usize]>>
  51:        0x10d937bf4 - <rustc_query_impl[a9dcee21c1ea9187]::query_impl::analysis::dynamic_query::{closure#2} as core[fca7800875c611c6]::ops::function::FnOnce<(rustc_middle[e187904418cf7088]::ty::context::TyCtxt, ())>>::call_once
  52:        0x10d7cf194 - rustc_query_system[3fe282a48bd1d9e8]::query::plumbing::try_execute_query::<rustc_query_impl[a9dcee21c1ea9187]::DynamicConfig<rustc_query_system[3fe282a48bd1d9e8]::query::caches::SingleCache<rustc_middle[e187904418cf7088]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a9dcee21c1ea9187]::plumbing::QueryCtxt, true>
  53:        0x10d8bca94 - rustc_query_impl[a9dcee21c1ea9187]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  54:        0x10c624e38 - <rustc_middle[e187904418cf7088]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[17630cf877ef70bb]::run_compiler::{closure#0}::{closure#1}::{closure#3}, core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>>
  55:        0x10c5f7a88 - <rustc_interface[617d4417f0fbb0b3]::interface::Compiler>::enter::<rustc_driver_impl[17630cf877ef70bb]::run_compiler::{closure#0}::{closure#1}, core[fca7800875c611c6]::result::Result<core[fca7800875c611c6]::option::Option<rustc_interface[617d4417f0fbb0b3]::queries::Linker>, rustc_span[984a238feadb13f5]::ErrorGuaranteed>>
  56:        0x10c63b85c - <scoped_tls[710a08ee67d076ea]::ScopedKey<rustc_span[984a238feadb13f5]::SessionGlobals>>::set::<rustc_interface[617d4417f0fbb0b3]::util::run_in_thread_with_globals<rustc_interface[617d4417f0fbb0b3]::interface::run_compiler<core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>, rustc_driver_impl[17630cf877ef70bb]::run_compiler::{closure#0}>::{closure#1}, core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>>
  57:        0x10c5f71d8 - rustc_span[984a238feadb13f5]::create_session_globals_then::<core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>, rustc_interface[617d4417f0fbb0b3]::util::run_in_thread_with_globals<rustc_interface[617d4417f0fbb0b3]::interface::run_compiler<core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>, rustc_driver_impl[17630cf877ef70bb]::run_compiler::{closure#0}>::{closure#1}, core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}>
  58:        0x10c610400 - std[e84bc52996b8b382]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[617d4417f0fbb0b3]::util::run_in_thread_with_globals<rustc_interface[617d4417f0fbb0b3]::interface::run_compiler<core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>, rustc_driver_impl[17630cf877ef70bb]::run_compiler::{closure#0}>::{closure#1}, core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>>
  59:        0x10c643808 - <<std[e84bc52996b8b382]::thread::Builder>::spawn_unchecked_<rustc_interface[617d4417f0fbb0b3]::util::run_in_thread_with_globals<rustc_interface[617d4417f0fbb0b3]::interface::run_compiler<core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>, rustc_driver_impl[17630cf877ef70bb]::run_compiler::{closure#0}>::{closure#1}, core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[fca7800875c611c6]::result::Result<(), rustc_span[984a238feadb13f5]::ErrorGuaranteed>>::{closure#2} as core[fca7800875c611c6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  60:        0x103170edc - std::sys::pal::unix::thread::Thread::new::thread_start::h50a0ef5291b272f3
  61:        0x194a0ef94 - __pthread_joiner_wake

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.79.0 (129f3b996 2024-06-10) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED]

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

query stack during panic:
#0 [typeck] type-checking `<impl at src/lib.rs:3:10: 3:18>::schema`
#1 [analysis] running analysis passes on this crate
end of query stack

@RocketRace RocketRace 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 Jul 15, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 15, 2024
@RocketRace
Copy link
Author

Found this: Probably duplicate. #127163

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 19, 2024
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

No branches or pull requests

3 participants