Skip to content

Inconsistent "overflow evaluating the requirement" error for adding impl in another crate #77446

New issue

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

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

Already on GitHub? # to your account

Open
weiznich opened this issue Oct 2, 2020 · 6 comments
Labels
A-coherence Area: Coherence A-trait-system Area: Trait system C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. S-has-bisection Status: a bisection has been found for this issue T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@weiznich
Copy link
Contributor

weiznich commented Oct 2, 2020

I tried this code:

(lib.rs)

pub trait SqlType {
    type IsNull;
}

pub trait IntoNullable {
    type Nullable;
}

pub trait IntoNotNullable {
    type NotNullable;
}

pub trait Expression {
    type SqlType: SqlType;
}

pub trait AsExpression<T>
where
    T: SqlType,
{
    type Expression: Expression<SqlType = T>;
}

pub mod is_nullable {
    pub struct NotNull;
    pub struct IsNullable;
}

pub struct Bool;

impl SqlType for Bool {
    type IsNull = is_nullable::NotNull;
}

impl<T> IntoNotNullable for T
where
    T: SqlType<IsNull = is_nullable::NotNull>,
{
    type NotNullable = T;
}

impl<T, ST> AsExpression<ST> for T
where
    ST: SqlType + IntoNotNullable,
    ST::NotNullable: SqlType,
    ExpressionImplHelper<T, ST::IsNull, <T::SqlType as SqlType>::IsNull>: AsExpression<ST>,
    T: Expression,
    T::SqlType: SqlType,
{
    type Expression =
        <ExpressionImplHelper<T, ST::IsNull, <T::SqlType as SqlType>::IsNull> as AsExpression<
            ST,
        >>::Expression;
}

pub struct Bound<T>(std::marker::PhantomData<T>);

impl<T> Expression for Bound<T>
where
    T: SqlType,
{
    type SqlType = T;
}

#[allow(missing_debug_implementations)]
pub struct ExpressionImplHelper<T, IsNullExpr, IsNullAsExpr>(
    pub T,
    pub std::marker::PhantomData<(IsNullExpr, IsNullAsExpr)>,
);

(main.rs)

use a::*;

struct MyType(bool);

impl AsExpression<Bool> for MyType {
    type Expression = Bound<Bool>;
}

struct MyMarkerType;

impl SqlType for MyMarkerType {
    type IsNull = is_nullable::NotNull;
}

impl AsExpression<MyMarkerType> for MyType {
    type Expression = Bound<MyMarkerType>;
}

I expected this code to compile without any issue or a clear error message why I cannot implment that AsExpression there, but instead I got a compilation error:

error[E0275]: overflow evaluating the requirement `a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::Expresa::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, sionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<MyType, _, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>: a::AsExpression<MyMarkerType>`
  |
  = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`a`)
  = note: required because of the requirements on the impl of `a::AsExpression<MyMarkerType>` for `a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::Expresa::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, sionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<MyType, _, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>`
  = note: required because of the requirements on the impl of `a::AsExpression<MyMarkerType>` for `a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<a::ExpressionImplHelper<MyType, _, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>, a::is_nullable::NotNull, _>`

As an intresting side note: This happens for the following impl:

impl AsExpression<MyMarkerType> for MyType {
    type Expression = Bound<MyMarkerType>;
}

removing it results in a successful compilation.

Meta

rustc --version --verbose: rustc 1.48.0-nightly (fc2daaae6 2020-09-28)

@weiznich weiznich added the C-bug Category: This is a bug. label Oct 2, 2020
@jonas-schievink jonas-schievink added A-trait-system Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 2, 2020
@fmease fmease added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-types Relevant to the types team, which will review and decide on the PR/issue. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. labels Feb 11, 2025
@fmease
Copy link
Member

fmease commented Feb 11, 2025

This now compiles successfully. Bisecting…

@fmease
Copy link
Member

fmease commented Feb 11, 2025

Ah, right. #130654 (stabilize -Znext-solver=coherence) fixed this, makes sense. I do wonder though if we need an extra regression test 🤔 I doubt it.

@fmease fmease added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. S-has-bisection Status: a bisection has been found for this issue A-coherence Area: Coherence and removed E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc labels Feb 11, 2025
@weiznich
Copy link
Contributor Author

@fmease As this is marked with E-needs-mcvc: Isn't the example provided above sufficient?

@compiler-errors
Copy link
Member

It's best if whoever's analyzing this tries to simplify it further. It definitely doesn't look minimal.

@moxian
Copy link
Contributor

moxian commented Mar 11, 2025

minimized, somewhat:

// src/lib.rs
pub trait TraitUnrelated {
    type AssTypeUnrelated;
}


pub trait TraitA {
    type AssTypeA;
}

pub trait TraitB<T>
where
    T: TraitA,
{
    type AssTypeB;
}

impl<T, ST> TraitB<ST> for T
where
    ST: TraitA,
    // reordering the following two lines makes it compile
    ExpressionImplHelper<T::AssTypeUnrelated>: TraitB<ST>,
    T: TraitUnrelated,
{
    type AssTypeB = <ExpressionImplHelper<T::AssTypeUnrelated> as TraitB<ST>>::AssTypeB;
}

pub struct ExpressionImplHelper<B>(pub B);
// src/bin/foo.rs
use mycrate::*;

struct MyTypeA;

struct MyTypeB;

impl TraitA for MyTypeA {
    type AssTypeA = ();
}

impl TraitB<MyTypeA> for MyTypeB {
    type AssTypeB = ();
}

fn main(){}

The fact that the ordering of the where clauses (both in the original, and in the reduced version) makes the error go away makes me think that the bug is due to a minor implementation detail, and a test is unlikely to catch future problems(?)...

Opportunistically
@rustbot labels: -E-needs-mcve +fixed-by-next-solver

@rustbot rustbot removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Mar 11, 2025
@rustbot
Copy link
Collaborator

rustbot commented Mar 11, 2025

Error: Label fixed-by-next-solver can only be set by Rust team members

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-coherence Area: Coherence A-trait-system Area: Trait system C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. S-has-bisection Status: a bisection has been found for this issue T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants