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

Trait aliases #6315

Open
michaeljklein opened this issue Oct 22, 2024 · 1 comment · May be fixed by #6431
Open

Trait aliases #6315

michaeljklein opened this issue Oct 22, 2024 · 1 comment · May be fixed by #6431
Assignees
Labels
enhancement New feature or request

Comments

@michaeljklein
Copy link
Contributor

Problem

Trait inheritance allows traits to require other traits, but explicitly including all required traits in functions or impl's can become repetitive.

Happy Case

Once #6314 is fixed, support some version of trait aliases, e.g., by desugaring a trait alias declaration:

trait Baz = Foo + Bar;

into (approximately):

trait Baz: Foo + Bar {}

impl<T> Baz for T where T: Foo + Bar {}

Either support something similar to this experimental Rust feature or else ensure that it can be implemented with a simple Noir macro.

Workaround

Yes

Workaround Description

trait Baz: Foo + Bar {} can currently be defined, but currently needs an explicit impl Baz for MyStruct for each type

Additional Context

No response

Project Impact

None

Blocker Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@michaeljklein michaeljklein added the enhancement New feature or request label Oct 22, 2024
@michaeljklein
Copy link
Contributor Author

After discussing with Tom and Jake, we'd prefer to implement Rust-style trait aliases with the following notes:

  1. The error messages when a trait is missing should be clear
  2. Error messages when the trait alias is used in other places than intended should be clear
  3. ^ If these error messages are tricky, use a first-order enum variant for trait aliases

@michaeljklein michaeljklein linked a pull request Nov 1, 2024 that will close this issue
5 tasks
@michaeljklein michaeljklein self-assigned this Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 📋 Backlog
Development

Successfully merging a pull request may close this issue.

1 participant