-
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
GAT lifetime mismatch with type parametrised over dyn trait object with restricted lifetime #78113
Comments
I don't think this is a bug. What happens here is that the implementation of A for |
The second example can be "fixed" in the same way: But, by that logic, |
In the functions the lifetime in the trait object is resolved to the lifetime supplied by the function What behaviour would you expect here, i.e. what lifetime would you expect 'a to be in the associated type? I'd agree that it's inconsistent though that the lifetimes in Edit: No actually I think |
Well then I have two questions:
Then you may be right and this is no more than unclear |
I'm not completely sure, but to me it seems most plausible that in I think But I could be wrong since I'm not that familiar with the trait system, the right person to answer this would be @matthewjasper |
This argument doesn't make sense to me since the associated types have a lifetime supplied in the same way — the key difference, assuming that associated types are resolved in the same way as other types, is the lack of a bound. Note that this also works (no bound, not associated): type X<'a> = Box<dyn A + 'a>; |
BTW I wrote these test cases which may/may not be of use here. |
Error:
Note also that a few months back, the nightly available did accept this type of code.
The text was updated successfully, but these errors were encountered: