Conflicting implementations for Borrow (revisited)

There’s a thread from two years ago with a very similar problem, but unfortunately the workaround presented there is not possible for me: I’m writing an interner for some type T and requiring the implementation of a dummy trait will kill ergonomics.

The issue in a nutshell: this works

struct A<T>(T);

impl<T> Borrow<T> for A<T> {
    fn borrow(&self) -> &T {

while this does not:

trait X {
    type Y;
impl<T: X> Borrow<T::Y> for A<T> {
    fn borrow(&self) -> &T::Y {

Is there a way for me to explain to Rust that T::Y will never be A<T>? Something like saying type Y: !Self or so.

(For the curious: A is the Interned struct while X is the Interner trait with Y being the interned value type. The fallback solution would be to duplicate a lot of code …)


Okay, thanks for confirming.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.