Skip to content

normalization no longer prefers object bound over user written impls #253

@lcnr

Description

@lcnr
pub trait Hook {
    type Value;
    fn use_hook(&mut self);
}

pub trait ValueGat {
    type Value;
}

pub trait ErasedHook {
    type ValueGat: ?Sized + ValueGat;
    fn erased_use_hook(&mut self) -> <Self::ValueGat as ValueGat>::Value {
        unimplemented!()
    }
}

impl<H: ?Sized + Hook> ErasedHook for H {
    type ValueGat = dyn ValueGat<Value = <H as Hook>::Value>;
}

impl<V: ?Sized + ValueGat> Hook for dyn '_ + ErasedHook<ValueGat = V> {
    type Value = <V as ValueGat>::Value;
    fn use_hook(&mut self) {
        Self::erased_use_hook(self);
    }
}

compiles with the old solver by preferring the builtin object impl over the user written impl for ErasedHook.

The new solver fails with ambiguity. Affects hooks-core, thx @lqd. https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/crater.20triage.3A.20.60hooks-core.60.20cannot.20normalize/with/547829505

Metadata

Metadata

Assignees

No one assigned

    Labels

    from-craterA regression found via a crater run, not part of our test suite

    Type

    No type

    Projects

    Status

    intended breakage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions