Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add support for mutually recursive trait declarations #176

Open
sonmarcho opened this issue May 13, 2024 · 2 comments
Open

Add support for mutually recursive trait declarations #176

sonmarcho opened this issue May 13, 2024 · 2 comments
Assignees

Comments

@sonmarcho
Copy link
Member

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

@Nadrieril
Copy link
Member

Nadrieril commented May 28, 2024

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.

@sonmarcho
Copy link
Member Author

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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants