Skip to content

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

Closed

Description

@weiznich

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)

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Oct 2, 2020
  2. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    T-typesRelevant to the types team, which will review and decide on the PR/issue.
    E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
    and removed
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Feb 11, 2025
  3. fmease commented on Feb 11, 2025

    @fmease
    Member

    This now compiles successfully. Bisecting…

  4. fmease commented on Feb 11, 2025

    @fmease
    Member

    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.

  5. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    S-has-bisectionStatus: A bisection has been found for this issue
    and removed
    E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
    on Feb 11, 2025
  6. weiznich commented on Feb 11, 2025

    @weiznich
    ContributorAuthor

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

  7. compiler-errors commented on Feb 11, 2025

    @compiler-errors
    Contributor

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

  8. moxian commented on Mar 11, 2025

    @moxian
    Contributor

    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

  9. removed
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    on Mar 11, 2025
  10. rustbot commented on Mar 11, 2025

    @rustbot
    Collaborator

    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.

  11. lcnr commented on Aug 11, 2026

    @lcnr
    Contributor

    this minimization looks like the "overflowing obligation order dependence" issue we already added test for with coherence. closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-coherenceArea: CoherenceA-trait-systemArea: Trait systemC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.S-has-bisectionStatus: A bisection has been found for this issueT-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions