-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Inconsistency in type checking where clauses in trait definition #28055
Comments
This is how supertraits work. not a bug. |
Could you give me some references to understanding this behavior? |
Supertraits: from the reference:
The issue (elaboration) - this is part of the trait-system and mostly documented by the code comments. The thing is that we don't want too many bounds to be implicitly available for functions, as this can lead to fragility with distant changes causing functions to stop compiling. There are basically 3 kinds of bounds available to a function:
If your bound isn't in the list, you will have to add it explicitly if you want to use it. I guess this should be a FAQ entry. |
Trait bounds on Self are considered "supertraits". These are required to be acyclic. Supertraits are somewhat different from other constraints in that they affect what methods are available in the vtable when the trait is used as a trait object. Referencing rust-lang/rust#28055 and rust-lang/rust#34106
While the description of how bounds are added to a function makes sense, and is very useful, I'm still left with the question "why?" If I have some |
In this example, function
f
compiles, butg
does not. To makeg
compiles it's necessary to repeat theC
definition bound. For functionf
this is not necessary. This seems to be an inconsistency.The text was updated successfully, but these errors were encountered: