-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
covariant method return types on trait impls? #15687
Comments
((The semi-good news is that whatever the oddity is that leads us to accept the second example in the description, whatever that oddity is, I have not yet been able to construct an example via that oddity that breaks type soundness. Not yet.)) |
@pnkfelix there is a subtyping relationship, but I don't think it properly takes the relationships between free lifetimes into account. |
Triage: another very old ticket. @nikomatsakis @pnkfelix has this question been resolved over the past few years? |
Do trait method signatures have to match exactly, or is there some subtyping relationship that is supposed to hold between an impl's methods and the methods of the trait definition itself?
If there is a subtyping relationship, then I would expect the following to compile:
(it currently does not compile; it complains of the mismatch between the lifetime parameters.)
If there is not a subtyping relationship, then I would not expect the following to compile:
(it currently does compile.)
Note that the latter case seems sound to me, but the fact that this works in the latter case but does not for the former case just makes me worry about what the rules actually are that we are enforcing with respect to how much an
impl
needs to conform with its correspondingtrait
.The text was updated successfully, but these errors were encountered: