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: Where clause ... was applicable to ... but now is not in compiler/rustc_trait_selection/src/traits/select/confirmation.rs #126944

Open
Naserume opened this issue Jun 25, 2024 · 5 comments
Labels
C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Naserume
Copy link

Naserume commented Jun 25, 2024

Code

(original code. over 100 lines)

trait BufMut {}
struct Bytes;
struct BytesMut;

pub trait Future {
    type Item;
}

pub trait Service {
    type Response;
    type Future: Future<Item = Self::Response>;
}

pub trait ThriftService<F>:
    Service<
        Response = FramingEncoded<F>,
        Future = Box<Future<Item = FramingEncodedFinal<F>>>,
    >
where
    F: Framing,
{
    fn get_service(
        &self,
    ) -> &Service<
        Response = Self::Response,
        Future = Self::Future,
    >;
}

pub trait BufMutExt: BufMut {
    type Final;
}

impl BufMutExt for BytesMut {
    type Final = Bytes;
}

pub type FramingEncoded<F> = <F as Framing>::EncBuf;
pub type FramingEncodedFinal<F> = <<F as Framing>::EncBuf as BufMutExt>::Final;

pub trait Framing {
    type EncBuf: BufMut;
}

pub struct SRHeaderTransport;
impl Framing for SRHeaderTransport {
    type EncBuf = BytesMut;
}

pub type BoxService<H> = Box<
    ThriftService<
            SRHeaderTransport,
            Response = Bytes,
            Future = Box<Future<Item = Bytes>>,
        >,
>;

use std::pin::Pin;
use std::task::*;

pub trait Stream {
    type Item;

    fn poll_next(self: Pin<&mut Self>) -> Poll<Option<Self::Item>>;
}

pub trait FnOnce1<A> {
    type Output;
    fn call_once(self, arg: A) -> Self::Output;
}

impl<T, A, R> FnOnce1<A> for T
where
    T: FnOnce(A) -> R,
{
    type Output = R;
    fn call_once(self, arg: A) -> R {
        self(arg)
    }
}

pub trait FnMut1<A>: FnOnce1<A> {
    fn call_mut(&mut self, arg: A) -> Self::Output;
}


struct Map<St, F>(St, F);

impl<St, F> Stream for Map<St, F>
where
    St: Stream,
    F: FnMut1<BoxService>,
{
    type Item = F::Output;

    fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
        todo!()
    }
}
fn main() {}

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (bcf94dec5 2024-06-23)
binary: rustc
commit-hash: bcf94dec5ba6838e435902120c0384c360126a26
commit-date: 2024-06-23
host: x86_64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7

Error output

Output

warning: trait objects without an explicit `dyn` are deprecated
  --> ./9079C.rs:17:22
   |
17 |         Future = Box<Future<Item = FramingEncodedFinal<F>>>,
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
   = note: `#[warn(bare_trait_objects)]` on by default
help: if this is an object-safe trait, use `dyn`
   |
17 |         Future = Box<dyn Future<Item = FramingEncodedFinal<F>>>,
   |                      +++

error[E0277]: the trait bound `<F as Framing>::EncBuf: BufMutExt` is not satisfied
  --> ./9079C.rs:14:1
   |
14 | / pub trait ThriftService<F>:
15 | |     Service<
16 | |         Response = FramingEncoded<F>,
17 | |         Future = Box<Future<Item = FramingEncodedFinal<F>>>,
18 | |     >
   | |_____^ the trait `BufMutExt` is not implemented for `<F as Framing>::EncBuf`
   |
help: consider further restricting the associated type
   |
20 |     F: Framing, <F as Framing>::EncBuf: BufMutExt
   |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0277]: the trait bound `<F as Framing>::EncBuf: BufMutExt` is not satisfied
  --> ./9079C.rs:14:1
   |
14 | / pub trait ThriftService<F>:
15 | |     Service<
16 | |         Response = FramingEncoded<F>,
17 | |         Future = Box<Future<Item = FramingEncodedFinal<F>>>,
...  |
27 | |     >;
28 | | }
   | |_^ the trait `BufMutExt` is not implemented for `<F as Framing>::EncBuf`
   |
help: consider further restricting the associated type
   |
20 |     F: Framing, <F as Framing>::EncBuf: BufMutExt
   |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

warning: trait objects without an explicit `dyn` are deprecated
  --> ./9079C.rs:24:11
   |
24 |       ) -> &Service<
   |  ___________^
25 | |         Response = Self::Response,
26 | |         Future = Self::Future,
27 | |     >;
   | |_____^
   |
   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: if this is an object-safe trait, use `dyn`
   |
24 |     ) -> &dyn Service<
   |           +++

error[E0277]: the trait bound `BytesMut: BufMut` is not satisfied
  --> ./9079C.rs:34:20
   |
34 | impl BufMutExt for BytesMut {
   |                    ^^^^^^^^ the trait `BufMut` is not implemented for `BytesMut`
   |
help: this trait has no implementations, consider adding one
  --> ./9079C.rs:1:1
   |
1  | trait BufMut {}
   | ^^^^^^^^^^^^
note: required by a bound in `BufMutExt`
  --> ./9079C.rs:30:22
   |
30 | pub trait BufMutExt: BufMut {
   |                      ^^^^^^ required by this bound in `BufMutExt`

error[E0277]: the trait bound `BytesMut: BufMut` is not satisfied
  --> ./9079C.rs:47:19
   |
47 |     type EncBuf = BytesMut;
   |                   ^^^^^^^^ the trait `BufMut` is not implemented for `BytesMut`
   |
help: this trait has no implementations, consider adding one
  --> ./9079C.rs:1:1
   |
1  | trait BufMut {}
   | ^^^^^^^^^^^^
note: required by a bound in `Framing::EncBuf`
  --> ./9079C.rs:42:18
   |
42 |     type EncBuf: BufMut;
   |                  ^^^^^^ required by this bound in `Framing::EncBuf`

warning: trait objects without an explicit `dyn` are deprecated
  --> ./9079C.rs:51:5
   |
51 | /     ThriftService<
52 | |             SRHeaderTransport,
53 | |             Response = Bytes,
54 | |             Future = Box<Future<Item = Bytes>>,
55 | |         >,
   | |_________^
   |
   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: if this is an object-safe trait, use `dyn`
   |
51 |     dyn ThriftService<
   |     +++

warning: trait objects without an explicit `dyn` are deprecated
  --> ./9079C.rs:54:26
   |
54 |             Future = Box<Future<Item = Bytes>>,
   |                          ^^^^^^^^^^^^^^^^^^^^
   |
   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: if this is an object-safe trait, use `dyn`
   |
54 |             Future = Box<dyn Future<Item = Bytes>>,
   |                          +++

error[E0091]: type parameter `H` is never used
  --> ./9079C.rs:50:21
   |
50 | pub type BoxService<H> = Box<
   |                     ^ unused type parameter
   |
   = help: consider removing `H` or referring to it in the body of the type alias
   = help: if you intended `H` to be a const parameter, use `const H: /* Type */` instead

error[E0107]: missing generics for type alias `BoxService`
  --> ./9079C.rs:92:15
   |
92 |     F: FnMut1<BoxService>,
   |               ^^^^^^^^^^ expected 1 generic argument
   |
note: type alias defined here, with 1 generic parameter: `H`
  --> ./9079C.rs:50:10
   |
50 | pub type BoxService<H> = Box<
   |          ^^^^^^^^^^ -
help: add missing generic argument
   |
92 |     F: FnMut1<BoxService<H>>,
   |                         +++

error[E0277]: the trait bound `<F as Framing>::EncBuf: BufMutExt` is not satisfied
  --> ./9079C.rs:22:5
   |
22 | /     fn get_service(
23 | |         &self,
24 | |     ) -> &Service<
25 | |         Response = Self::Response,
26 | |         Future = Self::Future,
27 | |     >;
   | |______^ the trait `BufMutExt` is not implemented for `<F as Framing>::EncBuf`
   |
help: consider further restricting the associated type
   |
27 |     > where <F as Framing>::EncBuf: BufMutExt;
   |       +++++++++++++++++++++++++++++++++++++++

error[E0050]: method `poll_next` has 2 parameters but the declaration in trait `Stream::poll_next` has 1
  --> ./9079C.rs:96:24
   |
64 |     fn poll_next(self: Pin<&mut Self>) -> Poll<Option<Self::Item>>;
   |                        -------------- trait requires 1 parameter
...
96 |     fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 parameter, found 2

error[E0277]: the trait bound `<F as Framing>::EncBuf: BufMutExt` is not satisfied
  --> ./9079C.rs:24:10
   |
24 |       ) -> &Service<
   |  __________^
25 | |         Response = Self::Response,
26 | |         Future = Self::Future,
27 | |     >;
   | |_____^ the trait `BufMutExt` is not implemented for `<F as Framing>::EncBuf`
   |
help: consider further restricting the associated type
   |
27 |     > where <F as Framing>::EncBuf: BufMutExt;
   |       +++++++++++++++++++++++++++++++++++++++

warning: unused variable: `cx`
  --> ./9079C.rs:96:40
   |
96 |     fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
   |                                        ^^ help: if this is intentional, prefix it with an underscore: `_cx`
   |
   = note: `#[warn(unused_variables)]` on by default

Backtrace

error: internal compiler error: compiler/rustc_trait_selection/src/traits/select/confirmation.rs:242:17: Where clause `Binder { value: <F as FnOnce1<std::boxed::Box<(dyn ThriftService<SRHeaderTransport, Future = std::boxed::Box<(dyn Future<Item = Bytes> + 'static)>, Future = std::boxed::Box<(dyn Future<Item = Bytes> + 'static)>, Response = Bytes, Response = BytesMut> + 'static)>>>, bound_vars: [] }` was applicable to `Obligation(predicate=Binder { value: TraitPredicate(<F as FnOnce1<std::boxed::Box<dyn ThriftService<SRHeaderTransport, Future = std::boxed::Box<dyn Future<Item = Bytes>>, Future = std::boxed::Box<dyn Future<Item = Bytes>>, Response = Bytes, Response = BytesMut>>>>, polarity:Positive), bound_vars: [] }, depth=0)` but now is not

thread 'rustc' panicked at compiler/rustc_trait_selection/src/traits/select/confirmation.rs:242:17:
Box<dyn Any>
stack backtrace:
   0:        0x10e1e6b43 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he71f7af0ddafc64d
   1:        0x10e23225b - core::fmt::write::h30d0e266faff29b6
   2:        0x10e1dcace - std::io::Write::write_fmt::he666ca78eb4b8406
   3:        0x10e1e6931 - std::sys::backtrace::print::h22721f9ab9a2749a
   4:        0x10e1e9709 - std::panicking::default_hook::{{closure}}::h145e29ed875d8021
   5:        0x10e1e948a - std::panicking::default_hook::h5d437c7e6bf0e3b5
   6:        0x11748147c - std[8efa578c02603ef9]::panicking::update_hook::<alloc[135510a28be92df]::boxed::Box<rustc_driver_impl[63f2171535a6fe49]::install_ice_hook::{closure#0}>>::{closure#0}
   7:        0x10e1ea326 - std::panicking::rust_panic_with_hook::h6889093a56e48d04
   8:        0x1174f0337 - std[8efa578c02603ef9]::panicking::begin_panic::<rustc_errors[8995f93e9c4bcc9a]::ExplicitBug>::{closure#0}
   9:        0x1174dc949 - std[8efa578c02603ef9]::sys::backtrace::__rust_end_short_backtrace::<std[8efa578c02603ef9]::panicking::begin_panic<rustc_errors[8995f93e9c4bcc9a]::ExplicitBug>::{closure#0}, !>
  10:        0x11bee2f09 - std[8efa578c02603ef9]::panicking::begin_panic::<rustc_errors[8995f93e9c4bcc9a]::ExplicitBug>
  11:        0x117502276 - <rustc_errors[8995f93e9c4bcc9a]::diagnostic::BugAbort as rustc_errors[8995f93e9c4bcc9a]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:        0x11819c95e - rustc_middle[4384e439927f71dd]::util::bug::opt_span_bug_fmt::<rustc_span[aed5394308446158]::span_encoding::Span>::{closure#0}
  13:        0x1181522b7 - rustc_middle[4384e439927f71dd]::ty::context::tls::with_opt::<rustc_middle[4384e439927f71dd]::util::bug::opt_span_bug_fmt<rustc_span[aed5394308446158]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:        0x118151d75 - rustc_middle[4384e439927f71dd]::ty::context::tls::with_context_opt::<rustc_middle[4384e439927f71dd]::ty::context::tls::with_opt<rustc_middle[4384e439927f71dd]::util::bug::opt_span_bug_fmt<rustc_span[aed5394308446158]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:        0x11bfa57eb - rustc_middle[4384e439927f71dd]::util::bug::bug_fmt
  16:        0x11917d658 - <rustc_trait_selection[2bb3b73d2222b57e]::traits::select::SelectionContext>::confirm_candidate
  17:        0x119180f86 - <rustc_trait_selection[2bb3b73d2222b57e]::traits::select::SelectionContext>::poly_select::{closure#0}
  18:        0x1190e7ced - <rustc_trait_selection[2bb3b73d2222b57e]::traits::select::SelectionContext>::select
  19:        0x11916cf75 - rustc_trait_selection[2bb3b73d2222b57e]::traits::project::opt_normalize_projection_term
  20:        0x1190d6772 - rustc_trait_selection[2bb3b73d2222b57e]::traits::project::normalize_projection_ty
  21:        0x119211b7d - rustc_traits[94d294c4931cbf40]::normalize_projection_ty::normalize_canonicalized_projection_ty
  22:        0x118b226b5 - rustc_query_impl[a24e9023943e74ab]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a24e9023943e74ab]::query_impl::normalize_canonicalized_projection_ty::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 8usize]>>
  23:        0x118aeb507 - <rustc_query_impl[a24e9023943e74ab]::query_impl::normalize_canonicalized_projection_ty::dynamic_query::{closure#2} as core[9412a59d758dca42]::ops::function::FnOnce<(rustc_middle[4384e439927f71dd]::ty::context::TyCtxt, rustc_type_ir[d9be17c5337dd5fe]::canonical::Canonical<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt, rustc_middle[4384e439927f71dd]::ty::ParamEnvAnd<rustc_type_ir[d9be17c5337dd5fe]::ty_kind::AliasTy<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt>>>)>>::call_once
  24:        0x118922d6d - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::<rustc_query_impl[a24e9023943e74ab]::DynamicConfig<rustc_query_system[30bd0146b5104221]::query::caches::DefaultCache<rustc_type_ir[d9be17c5337dd5fe]::canonical::Canonical<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt, rustc_middle[4384e439927f71dd]::ty::ParamEnvAnd<rustc_type_ir[d9be17c5337dd5fe]::ty_kind::AliasTy<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt>>>, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a24e9023943e74ab]::plumbing::QueryCtxt, false>
  25:        0x118b7b42c - rustc_query_impl[a24e9023943e74ab]::query_impl::normalize_canonicalized_projection_ty::get_query_non_incr::__rust_end_short_backtrace
  26:        0x118fc002b - rustc_middle[4384e439927f71dd]::query::plumbing::query_get_at::<rustc_query_system[30bd0146b5104221]::query::caches::DefaultCache<rustc_type_ir[d9be17c5337dd5fe]::canonical::Canonical<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt, rustc_middle[4384e439927f71dd]::ty::ParamEnvAnd<rustc_type_ir[d9be17c5337dd5fe]::ty_kind::AliasTy<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt>>>, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 8usize]>>>
  27:        0x1191725f5 - <rustc_trait_selection[2bb3b73d2222b57e]::traits::query::normalize::QueryNormalizer as rustc_type_ir[d9be17c5337dd5fe]::fold::FallibleTypeFolder<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt>>::try_fold_ty
  28:        0x118ffc2c1 - <&rustc_middle[4384e439927f71dd]::ty::list::RawList<(), rustc_middle[4384e439927f71dd]::ty::generic_args::GenericArg> as rustc_type_ir[d9be17c5337dd5fe]::fold::TypeFoldable<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt>>::try_fold_with::<rustc_trait_selection[2bb3b73d2222b57e]::traits::query::normalize::QueryNormalizer>
  29:        0x1190125fd - <rustc_middle[4384e439927f71dd]::ty::Ty as rustc_type_ir[d9be17c5337dd5fe]::fold::TypeSuperFoldable<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt>>::try_super_fold_with::<rustc_trait_selection[2bb3b73d2222b57e]::traits::query::normalize::QueryNormalizer>
  30:        0x11917225d - <rustc_trait_selection[2bb3b73d2222b57e]::traits::query::normalize::QueryNormalizer as rustc_type_ir[d9be17c5337dd5fe]::fold::FallibleTypeFolder<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt>>::try_fold_ty
  31:        0x118ffc2c1 - <&rustc_middle[4384e439927f71dd]::ty::list::RawList<(), rustc_middle[4384e439927f71dd]::ty::generic_args::GenericArg> as rustc_type_ir[d9be17c5337dd5fe]::fold::TypeFoldable<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt>>::try_fold_with::<rustc_trait_selection[2bb3b73d2222b57e]::traits::query::normalize::QueryNormalizer>
  32:        0x1190125fd - <rustc_middle[4384e439927f71dd]::ty::Ty as rustc_type_ir[d9be17c5337dd5fe]::fold::TypeSuperFoldable<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt>>::try_super_fold_with::<rustc_trait_selection[2bb3b73d2222b57e]::traits::query::normalize::QueryNormalizer>
  33:        0x11917225d - <rustc_trait_selection[2bb3b73d2222b57e]::traits::query::normalize::QueryNormalizer as rustc_type_ir[d9be17c5337dd5fe]::fold::FallibleTypeFolder<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt>>::try_fold_ty
  34:        0x1192149dd - rustc_traits[94d294c4931cbf40]::type_op::type_op_normalize_ty
  35:        0x118b1ff9d - rustc_query_impl[a24e9023943e74ab]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a24e9023943e74ab]::query_impl::type_op_normalize_ty::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 8usize]>>
  36:        0x118ad2e1f - <rustc_query_impl[a24e9023943e74ab]::query_impl::type_op_normalize_ty::dynamic_query::{closure#2} as core[9412a59d758dca42]::ops::function::FnOnce<(rustc_middle[4384e439927f71dd]::ty::context::TyCtxt, rustc_type_ir[d9be17c5337dd5fe]::canonical::Canonical<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt, rustc_middle[4384e439927f71dd]::ty::ParamEnvAnd<rustc_middle[4384e439927f71dd]::traits::query::type_op::Normalize<rustc_middle[4384e439927f71dd]::ty::Ty>>>)>>::call_once
  37:        0x11892b2ee - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::<rustc_query_impl[a24e9023943e74ab]::DynamicConfig<rustc_query_system[30bd0146b5104221]::query::caches::DefaultCache<rustc_type_ir[d9be17c5337dd5fe]::canonical::Canonical<rustc_middle[4384e439927f71dd]::ty::context::TyCtxt, rustc_middle[4384e439927f71dd]::ty::ParamEnvAnd<rustc_middle[4384e439927f71dd]::traits::query::type_op::Normalize<rustc_middle[4384e439927f71dd]::ty::Ty>>>, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a24e9023943e74ab]::plumbing::QueryCtxt, false>
  38:        0x118b848d1 - rustc_query_impl[a24e9023943e74ab]::query_impl::type_op_normalize_ty::get_query_non_incr::__rust_end_short_backtrace
  39:        0x1190e2121 - <rustc_middle[4384e439927f71dd]::ty::Ty as rustc_trait_selection[2bb3b73d2222b57e]::traits::query::type_op::normalize::Normalizable>::type_op_method
  40:        0x116e889e5 - <rustc_middle[4384e439927f71dd]::ty::ParamEnvAnd<rustc_middle[4384e439927f71dd]::traits::query::type_op::Normalize<rustc_middle[4384e439927f71dd]::ty::Ty>> as rustc_trait_selection[2bb3b73d2222b57e]::traits::query::type_op::TypeOp>::fully_perform
  41:        0x116fa47d1 - <rustc_borrowck[89ec071876429d81]::type_check::TypeChecker>::fully_perform_op::<rustc_middle[4384e439927f71dd]::ty::Ty, rustc_middle[4384e439927f71dd]::ty::ParamEnvAnd<rustc_middle[4384e439927f71dd]::traits::query::type_op::Normalize<rustc_middle[4384e439927f71dd]::ty::Ty>>>
  42:        0x116fb307a - <rustc_borrowck[89ec071876429d81]::type_check::TypeChecker>::equate_normalized_input_or_output
  43:        0x116f6ecad - rustc_borrowck[89ec071876429d81]::type_check::type_check
  44:        0x116f417e8 - rustc_borrowck[89ec071876429d81]::nll::compute_regions
  45:        0x116fc65fa - rustc_borrowck[89ec071876429d81]::do_mir_borrowck
  46:        0x116f82b78 - rustc_borrowck[89ec071876429d81]::mir_borrowck
  47:        0x118b1c6dc - rustc_query_impl[a24e9023943e74ab]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a24e9023943e74ab]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 8usize]>>
  48:        0x11899939e - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::<rustc_query_impl[a24e9023943e74ab]::DynamicConfig<rustc_query_system[30bd0146b5104221]::query::caches::VecCache<rustc_hir[ae2456c39d7f6170]::hir_id::OwnerId, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a24e9023943e74ab]::plumbing::QueryCtxt, false>
  49:        0x118b4686b - rustc_query_impl[a24e9023943e74ab]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  50:        0x117d466b1 - <rustc_middle[4384e439927f71dd]::hir::map::Map>::par_body_owners::<rustc_interface[73216d77aad0c3a5]::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
  51:        0x117dda7fc - rustc_interface[73216d77aad0c3a5]::passes::run_required_analyses
  52:        0x117ddccb3 - rustc_interface[73216d77aad0c3a5]::passes::analysis
  53:        0x118b22dec - rustc_query_impl[a24e9023943e74ab]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a24e9023943e74ab]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 1usize]>>
  54:        0x11890249e - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::<rustc_query_impl[a24e9023943e74ab]::DynamicConfig<rustc_query_system[30bd0146b5104221]::query::caches::SingleCache<rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a24e9023943e74ab]::plumbing::QueryCtxt, false>
  55:        0x118b2d307 - rustc_query_impl[a24e9023943e74ab]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  56:        0x1174258d7 - <rustc_interface[73216d77aad0c3a5]::queries::QueryResult<&rustc_middle[4384e439927f71dd]::ty::context::GlobalCtxt>>::enter::<core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>, rustc_driver_impl[63f2171535a6fe49]::run_compiler::{closure#0}::{closure#1}::{closure#3}>
  57:        0x11747fc94 - rustc_interface[73216d77aad0c3a5]::interface::run_compiler::<core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>, rustc_driver_impl[63f2171535a6fe49]::run_compiler::{closure#0}>::{closure#1}
  58:        0x11746ec91 - std[8efa578c02603ef9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[73216d77aad0c3a5]::util::run_in_thread_with_globals<rustc_interface[73216d77aad0c3a5]::util::run_in_thread_pool_with_globals<rustc_interface[73216d77aad0c3a5]::interface::run_compiler<core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>, rustc_driver_impl[63f2171535a6fe49]::run_compiler::{closure#0}>::{closure#1}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#0}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>
  59:        0x11748a3a6 - <<std[8efa578c02603ef9]::thread::Builder>::spawn_unchecked_<rustc_interface[73216d77aad0c3a5]::util::run_in_thread_with_globals<rustc_interface[73216d77aad0c3a5]::util::run_in_thread_pool_with_globals<rustc_interface[73216d77aad0c3a5]::interface::run_compiler<core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>, rustc_driver_impl[63f2171535a6fe49]::run_compiler::{closure#0}>::{closure#1}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#0}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#2} as core[9412a59d758dca42]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  60:        0x10e1f352b - std::sys::pal::unix::thread::Thread::new::thread_start::h68d49fa26efc1659
  61:     0x7ff801f5318b - __pthread_start

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/Users/Documents/240624-58194.txt` to your bug report

query stack during panic:
#0 [normalize_canonicalized_projection_ty] normalizing `<F as FnOnce1<alloc::boxed::Box<dyn ThriftService<SRHeaderTransport, Future = alloc::boxed::Box<dyn Future<Item = Bytes>>, Future = alloc::boxed::Box<dyn Future<Item = Bytes>>, Response = Bytes, Response = BytesMut>>>>::Output`
#1 [type_op_normalize_ty] normalizing `core::task::poll::Poll<core::option::Option<<F as FnOnce1<alloc::boxed::Box<dyn ThriftService<SRHeaderTransport, Future = alloc::boxed::Box<dyn Future<Item = Bytes>>, Future = alloc::boxed::Box<dyn Future<Item = Bytes>>, Response = Bytes, Response = BytesMut>>>>::Output>>`
end of query stack
error: aborting due to 10 previous errors; 5 warnings emitted

Some errors have detailed explanations: E0050, E0091, E0107, E0277.
For more information about an error, try `rustc --explain E0050`.
@Naserume Naserume 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 25, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 25, 2024
@compiler-errors compiler-errors added the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Jun 25, 2024
@matthiaskrgr matthiaskrgr added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Jun 25, 2024
@theemathas
Copy link
Contributor

My attempt at minimizing and explaining what's going on:

// Step 1: Create two names for a single type: `Thing` and `AlsoThing`

struct Thing;
struct Dummy;
pub trait DummyTrait {
    type DummyType;
}
impl DummyTrait for Dummy {
    type DummyType = Thing;
}
type AlsoThing = <Dummy as DummyTrait>::DummyType;

// Step 2: Create names for a single trait object type: `TraitObject` and `AlsoTraitObject`

pub trait SomeTrait {
    type Item;
}
type TraitObject = dyn SomeTrait<Item = AlsoThing>;
type AlsoTraitObject = dyn SomeTrait<Item = Thing>;

// Step 3: Force the compiler to check whether the two names are the same type

pub trait Supertrait {
    type Foo;
}
pub trait Subtrait: Supertrait<Foo = TraitObject> {}

pub trait HasOutput<A: ?Sized> {
    type Output;
}

fn foo<F>() -> F::Output
where
    F: HasOutput<dyn Subtrait<Foo = AlsoTraitObject>>,
{
    todo!()
}
Error output
   Compiling playground v0.0.1 (/playground)
error: internal compiler error: compiler/rustc_trait_selection/src/traits/select/confirmation.rs:244:17: Where clause `Binder { value: <F as HasOutput<(dyn Subtrait<Foo = (dyn SomeTrait<Item = Thing> + 'static), Foo = (dyn SomeTrait<Item = Thing> + 'static)> + 'static)>>, bound_vars: [] }` was applicable to `Obligation(predicate=Binder { value: TraitPredicate(<F as HasOutput<dyn Subtrait<Foo = dyn SomeTrait<Item = Thing>, Foo = dyn SomeTrait<Item = Thing>>>>, polarity:Positive), bound_vars: [] }, depth=0)` but now is not

thread 'rustc' panicked at compiler/rustc_trait_selection/src/traits/select/confirmation.rs:244:17:
Box<dyn Any>
stack backtrace:
   0:     0x7f23d7219035 - std::backtrace_rs::backtrace::libunwind::trace::h1a07e5dba0da0cd2
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7f23d7219035 - std::backtrace_rs::backtrace::trace_unsynchronized::h61b9b8394328c0bc
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f23d7219035 - std::sys_common::backtrace::_print_fmt::h1c5e18b460934cff
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f23d7219035 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1e1a1972118942ad
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f23d726829b - core::fmt::rt::Argument::fmt::h07af2b4071d536cd
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/rt.rs:165:63
   5:     0x7f23d726829b - core::fmt::write::hc090a2ffd6b28c4a
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/mod.rs:1157:21
   6:     0x7f23d720dbdf - std::io::Write::write_fmt::h8898bac6ff039a23
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/io/mod.rs:1832:15
   7:     0x7f23d7218e0e - std::sys_common::backtrace::_print::h4e80c5803d4ee35b
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f23d7218e0e - std::sys_common::backtrace::print::ha96650907276675e
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f23d721b779 - std::panicking::default_hook::{{closure}}::h215c2a0a8346e0e0
  10:     0x7f23d721b4bd - std::panicking::default_hook::h207342be97478370
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:298:9
  11:     0x7f23da1161b7 - std[3c8ba8ebcf555201]::panicking::update_hook::<alloc[bfbae7e348dce413]::boxed::Box<rustc_driver_impl[c88438ade88661f4]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f23d721be76 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::ha9c3bc81d312fd83
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2036:9
  13:     0x7f23d721be76 - std::panicking::rust_panic_with_hook::hac8bdceee1e4fe2c
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:799:13
  14:     0x7f23da143b44 - std[3c8ba8ebcf555201]::panicking::begin_panic::<rustc_errors[80cf825e20fac581]::ExplicitBug>::{closure#0}
  15:     0x7f23da1404f6 - std[3c8ba8ebcf555201]::sys_common::backtrace::__rust_end_short_backtrace::<std[3c8ba8ebcf555201]::panicking::begin_panic<rustc_errors[80cf825e20fac581]::ExplicitBug>::{closure#0}, !>
  16:     0x7f23da13bb66 - std[3c8ba8ebcf555201]::panicking::begin_panic::<rustc_errors[80cf825e20fac581]::ExplicitBug>
  17:     0x7f23da14cf01 - <rustc_errors[80cf825e20fac581]::diagnostic::BugAbort as rustc_errors[80cf825e20fac581]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7f23da5c6b1c - rustc_middle[3ff731b746e7b038]::util::bug::opt_span_bug_fmt::<rustc_span[8c7415e9d33ddd75]::span_encoding::Span>::{closure#0}
  19:     0x7f23da5adc2a - rustc_middle[3ff731b746e7b038]::ty::context::tls::with_opt::<rustc_middle[3ff731b746e7b038]::util::bug::opt_span_bug_fmt<rustc_span[8c7415e9d33ddd75]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7f23da5adacb - rustc_middle[3ff731b746e7b038]::ty::context::tls::with_context_opt::<rustc_middle[3ff731b746e7b038]::ty::context::tls::with_opt<rustc_middle[3ff731b746e7b038]::util::bug::opt_span_bug_fmt<rustc_span[8c7415e9d33ddd75]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x7f23d831e740 - rustc_middle[3ff731b746e7b038]::util::bug::bug_fmt
  22:     0x7f23dbf14a30 - <rustc_trait_selection[173dcaf5d960508e]::traits::select::SelectionContext>::poly_select::{closure#0}
  23:     0x7f23dbb2be89 - rustc_trait_selection[173dcaf5d960508e]::traits::project::opt_normalize_projection_type
  24:     0x7f23db9cc1f8 - rustc_traits[32e5563bcf83713]::normalize_projection_ty::normalize_canonicalized_projection_ty
  25:     0x7f23db9cbf77 - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::normalize_canonicalized_projection_ty::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 8usize]>>
  26:     0x7f23db8bd6f4 - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::DefaultCache<rustc_type_ir[a145be3c51398263]::canonical::Canonical<rustc_middle[3ff731b746e7b038]::ty::context::TyCtxt, rustc_middle[3ff731b746e7b038]::ty::ParamEnvAnd<rustc_middle[3ff731b746e7b038]::ty::sty::AliasTy>>, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  27:     0x7f23db8bd3ef - rustc_query_impl[a12402620de91e8]::query_impl::normalize_canonicalized_projection_ty::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7f23db8c0c39 - <rustc_trait_selection[173dcaf5d960508e]::traits::query::normalize::QueryNormalizer as rustc_type_ir[a145be3c51398263]::fold::FallibleTypeFolder<rustc_middle[3ff731b746e7b038]::ty::context::TyCtxt>>::try_fold_ty
  29:     0x7f23d8af1906 - rustc_traits[32e5563bcf83713]::type_op::type_op_normalize_ty
  30:     0x7f23dbfbee69 - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::type_op_normalize_ty::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 8usize]>>
  31:     0x7f23dbfbee2b - <rustc_query_impl[a12402620de91e8]::query_impl::type_op_normalize_ty::dynamic_query::{closure#2} as core[868bc93c3f2beb33]::ops::function::FnOnce<(rustc_middle[3ff731b746e7b038]::ty::context::TyCtxt, rustc_type_ir[a145be3c51398263]::canonical::Canonical<rustc_middle[3ff731b746e7b038]::ty::context::TyCtxt, rustc_middle[3ff731b746e7b038]::ty::ParamEnvAnd<rustc_middle[3ff731b746e7b038]::traits::query::type_op::Normalize<rustc_middle[3ff731b746e7b038]::ty::Ty>>>)>>::call_once
  32:     0x7f23dbfbec0b - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::DefaultCache<rustc_type_ir[a145be3c51398263]::canonical::Canonical<rustc_middle[3ff731b746e7b038]::ty::context::TyCtxt, rustc_middle[3ff731b746e7b038]::ty::ParamEnvAnd<rustc_middle[3ff731b746e7b038]::traits::query::type_op::Normalize<rustc_middle[3ff731b746e7b038]::ty::Ty>>>, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  33:     0x7f23dbfbe9b1 - rustc_query_impl[a12402620de91e8]::query_impl::type_op_normalize_ty::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7f23db792de6 - <rustc_borrowck[e21d1bf4e0a96488]::type_check::TypeChecker>::fully_perform_op::<rustc_middle[3ff731b746e7b038]::ty::Ty, rustc_middle[3ff731b746e7b038]::ty::ParamEnvAnd<rustc_middle[3ff731b746e7b038]::traits::query::type_op::Normalize<rustc_middle[3ff731b746e7b038]::ty::Ty>>>
  35:     0x7f23d8e1851e - rustc_borrowck[e21d1bf4e0a96488]::type_check::type_check
  36:     0x7f23d8e52b31 - rustc_borrowck[e21d1bf4e0a96488]::nll::compute_regions
  37:     0x7f23dc215d04 - rustc_borrowck[e21d1bf4e0a96488]::do_mir_borrowck
  38:     0x7f23dc2070ea - rustc_borrowck[e21d1bf4e0a96488]::mir_borrowck
  39:     0x7f23dc206be3 - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 8usize]>>
  40:     0x7f23db5a2f2d - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::VecCache<rustc_span[8c7415e9d33ddd75]::def_id::LocalDefId, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  41:     0x7f23db5a29ce - rustc_query_impl[a12402620de91e8]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  42:     0x7f23dbe161f9 - rustc_interface[640972162e3c086f]::passes::analysis
  43:     0x7f23dbe15aef - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>
  44:     0x7f23dc16f022 - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::SingleCache<rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  45:     0x7f23dc16edc9 - rustc_query_impl[a12402620de91e8]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  46:     0x7f23dc010149 - rustc_interface[640972162e3c086f]::interface::run_compiler::<core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>, rustc_driver_impl[c88438ade88661f4]::run_compiler::{closure#0}>::{closure#1}
  47:     0x7f23dbfcdf8b - std[3c8ba8ebcf555201]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[640972162e3c086f]::util::run_in_thread_with_globals<rustc_interface[640972162e3c086f]::interface::run_compiler<core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>, rustc_driver_impl[c88438ade88661f4]::run_compiler::{closure#0}>::{closure#1}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>
  48:     0x7f23dbfcdd80 - <<std[3c8ba8ebcf555201]::thread::Builder>::spawn_unchecked_<rustc_interface[640972162e3c086f]::util::run_in_thread_with_globals<rustc_interface[640972162e3c086f]::interface::run_compiler<core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>, rustc_driver_impl[c88438ade88661f4]::run_compiler::{closure#0}>::{closure#1}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>::{closure#2} as core[868bc93c3f2beb33]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7f23d7225cab - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h09e5a4c541afa800
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9
  50:     0x7f23d7225cab - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9c8b03c22f4e7026
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9
  51:     0x7f23d7225cab - std::sys::pal::unix::thread::Thread::new::thread_start::h522bc89a54da820a
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys/pal/unix/thread.rs:108:17
  52:     0x7f23d7133609 - start_thread
  53:     0x7f23d7056353 - clone
  54:                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.79.0 (129f3b996 2024-06-10) 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 [normalize_canonicalized_projection_ty] normalizing `<F as HasOutput<dyn Subtrait<Foo = dyn SomeTrait<Item = Thing>, Foo = dyn SomeTrait<Item = Thing>>>>::Output`
#1 [type_op_normalize_ty] normalizing `<F as HasOutput<dyn Subtrait<Foo = dyn SomeTrait<Item = Thing>, Foo = dyn SomeTrait<Item = Thing>>>>::Output`
#2 [mir_borrowck] borrow-checking `foo`
#3 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `playground` (lib)

@Noratrieb Noratrieb added fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Jun 25, 2024
@Noratrieb
Copy link
Member

errors with the new solver

error[E0277]: the trait bound `F: HasOutput<(dyn Subtrait<Foo = (dyn SomeTrait<Item = Thing> + 'static)> + 'static)>` is not satisfied
  --> <source>:35:1
   |
35 | / {
36 | |     todo!()
37 | | }
   | |_^ the trait `HasOutput<(dyn Subtrait<Foo = (dyn SomeTrait<Item = Thing> + 'static)> + 'static)>` is not implemented for `F`
   |
help: consider further restricting this bound
   |
34 |     F: HasOutput<dyn Subtrait<Foo = AlsoTraitObject>> + HasOutput<(dyn Subtrait<Foo = (dyn SomeTrait<Item = Thing> + 'static)> + 'static)>,
   |                                                       ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.

<Compilation failed>

@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 25, 2024
@theemathas
Copy link
Contributor

I'd argue that next-solver doesn't fix this, since this code should compile. (Note that the code currently compiles if we replace the AlsoThing definition with type AlsoThing = Thing;)

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Jul 5, 2024
@theemathas
Copy link
Contributor

I found a different ICE which has similar code (broken MIR):

#![allow(dead_code)]

// Step 1: Create two names for a single type: `Thing` and `AlsoThing`

struct Thing;
struct Dummy;
trait DummyTrait {
    type DummyType;
}
impl DummyTrait for Dummy {
    type DummyType = Thing;
}
type AlsoThing = <Dummy as DummyTrait>::DummyType;

// Step 2: Create two names for a single trait object type: `TraitObject` and `AlsoTraitObject`

trait SomeTrait<T> {}
type TraitObject = dyn SomeTrait<Thing>;
type AlsoTraitObject = dyn SomeTrait<AlsoThing>;

// Step 3: Force the compiler to check whether the two names are the same type

trait Supertrait {
    type Foo: ?Sized;
    fn do_thing(&self);
}
trait Subtrait: Supertrait<Foo = TraitObject> {}

fn foo(x: &dyn Subtrait<Foo = AlsoTraitObject>) {
    x.do_thing();
}
Error output
   Compiling playground v0.0.1 (/playground)
note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: broken MIR in DefId(0:20 ~ playground[8102]::foo) (_3 = &(*_1)): bad assignment (&'?10 dyn [Binder(Trait(Subtrait), []), Binder(Projection(ExistentialProjection { def_id: DefId(0:17 ~ playground[8102]::Supertrait::Foo), args: [], term: Term::Ty(dyn [Binder(Trait(SomeTrait<Thing>), [])] + '?11) }), [])] + '?12 = &'?3 dyn [Binder(Trait(Subtrait), []), Binder(Projection(ExistentialProjection { def_id: DefId(0:17 ~ playground[8102]::Supertrait::Foo), args: [], term: Term::Ty(dyn [Binder(Trait(SomeTrait<Thing>), [])] + '?7) }), []), Binder(Projection(ExistentialProjection { def_id: DefId(0:17 ~ playground[8102]::Supertrait::Foo), args: [], term: Term::Ty(dyn [Binder(Trait(SomeTrait<Thing>), [])] + '?8) }), [])] + '?9): NoSolution
  --> src/lib.rs:30:5
   |
30 |     x.do_thing();
   |     ^
   |
note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:1313:21
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxt>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_borrowck::type_check::TypeChecker>::typeck_mir
         4: rustc_borrowck::type_check::type_check
         5: rustc_borrowck::nll::compute_regions
         6: rustc_borrowck::do_mir_borrowck
         7: rustc_borrowck::mir_borrowck
         8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        10: rustc_query_impl::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
        11: rustc_interface::passes::analysis
        12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        14: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        15: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        16: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        17: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#2} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        18: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9
        19: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9
        20: std::sys::pal::unix::thread::Thread::new::thread_start
                   at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys/pal/unix/thread.rs:108:17
        21: start_thread
        22: clone
  --> src/lib.rs:30:5
   |
30 |     x.do_thing();
   |     ^

error: internal compiler error: broken MIR in DefId(0:20 ~ playground[8102]::foo) (bb0[0]): equate_normalized_input_or_output: `&'?1 dyn [Binder(Trait(Subtrait), []), Binder(Projection(ExistentialProjection { def_id: DefId(0:17 ~ playground[8102]::Supertrait::Foo), args: [], term: Term::Ty(dyn [Binder(Trait(SomeTrait<Thing>), [])] + '?0) }), []), Binder(Projection(ExistentialProjection { def_id: DefId(0:17 ~ playground[8102]::Supertrait::Foo), args: [], term: Term::Ty(dyn [Binder(Trait(SomeTrait<Thing>), [])] + '?0) }), [])] + '?1==&'?6 dyn [Binder(Trait(Subtrait), []), Binder(Projection(ExistentialProjection { def_id: DefId(0:17 ~ playground[8102]::Supertrait::Foo), args: [], term: Term::Ty(dyn [Binder(Trait(SomeTrait<Thing>), [])] + '?7) }), []), Binder(Projection(ExistentialProjection { def_id: DefId(0:17 ~ playground[8102]::Supertrait::Foo), args: [], term: Term::Ty(dyn [Binder(Trait(SomeTrait<Thing>), [])] + '?8) }), [])] + '?9` failed with `NoSolution`
  --> src/lib.rs:29:1
   |
29 | / fn foo(x: &dyn Subtrait<Foo = AlsoTraitObject>) {
30 | |     x.do_thing();
31 | | }
   | |_^
   |
note: delayed at compiler/rustc_borrowck/src/type_check/input_output.rs:209:17
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxt>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: rustc_borrowck::type_check::type_check
         4: rustc_borrowck::nll::compute_regions
         5: rustc_borrowck::do_mir_borrowck
         6: rustc_borrowck::mir_borrowck
         7: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
         9: rustc_query_impl::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
        10: rustc_interface::passes::analysis
        11: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        12: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        13: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        14: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        15: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        16: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#2} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        17: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9
        18: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9
        19: std::sys::pal::unix::thread::Thread::new::thread_start
                   at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys/pal/unix/thread.rs:108:17
        20: start_thread
        21: clone
  --> src/lib.rs:29:1
   |
29 | / fn foo(x: &dyn Subtrait<Foo = AlsoTraitObject>) {
30 | |     x.do_thing();
31 | | }
   | |_^

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 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:
end of query stack
error: could not compile `playground` (lib)

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. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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

7 participants