aeneas icon indicating copy to clipboard operation
aeneas copied to clipboard

Add support for mutually recursive trait declarations

Open sonmarcho opened this issue 1 year ago • 2 comments

We need to add support for mutually recursive trait declarations in Aeneas. In the meantime, we should add a span to the error message.

sonmarcho avatar May 13 '24 11:05 sonmarcho

For example:

pub trait Trait1 {
    type T: Trait2;
}
pub trait Trait2: Trait1 {}

impl Trait1 for () {
    type T = ();
}
impl Trait2 for () {}

Even more to the point:

pub trait Trait {
    type T: Trait;
}
impl Trait for () {
    type T = ();
}

See also the rustc-internal docs on coinduction in the trait solver which could be related to this.

Nadrieril avatar May 28 '24 15:05 Nadrieril

Another (simply recursive) example of a different flavour, inspired by the mutual recursion between Iterator and IntoIterator:

pub trait Trait {
    fn f<T : Trait>(&self, other: &T);
}

sonmarcho avatar May 29 '24 06:05 sonmarcho