-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Associated types bug related to trait objects #30833
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
Comments
I've discovered something alike on the same code sample. impl Deref for Foobar {
type Target = DoesStuff;
fn deref(&self) -> &DoesStuff {
self as &DoesStuff
}
} fails with <anon>:22:5: 24:6 error: method `deref` has an incompatible type for trait:
expected bound lifetime parameter ,
found concrete lifetime [E0053]
<anon>:22 fn deref(&self) -> &DoesStuff {
<anon>:23 self as &DoesStuff
<anon>:24 }
<anon>:22:5: 24:6 help: see the detailed explanation for E0053
error: aborting due to previous error
playpen: application terminated with error code 101 Note the space before the comma here - |
This is caused by the implicit lifetime bound in trait objects: |
The second one, right? The first one does not seem to be related to implicit lifetime bound. |
|
The first one says <anon>:28:17: 28:37 note: ...so that trait type parameters matches those specified on the impl (expected `core::ops::CoerceUnsized<&DoesStuff + 'static>`, found `core::ops::CoerceUnsized<&DoesStuff + 'static>`) so I don't see type mismatch here. |
It is not a bug. The type on the trait is We might want to improve the diagnostics (especially, the "bound lifetime parameter ," sucks), but the compile error is for real. |
Triage: the first example currently compiles. Checking godbolt, it has compiled since The second playground link, posted by defyrlt, has an error that now looks like the following:
|
The first bug was fixed in rustc 1.16, the second (diagnostic bug, which I thought was the only bug) was fixed in 1.11. It might be worth seeing whether the first bug is covered by our test-suite and which PR fixed it. |
That appears to be #38624 |
So the first bug was that The diagnostics bug is probably covered by quite a few diagnostics tests, so there isn't much more to check. Closing. |
Playpen
Relevant code (note that
DoesStuff
is a trait):Error text:
cc @mbrubeck since on the IRC you've told me that it's worthy filing an issue :)
The text was updated successfully, but these errors were encountered: