-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
The compiler should be more helpful when trait bounds are not met. #64417
Comments
Come to think of it, it's more general than #26925. One could hit a similar error with custom impls of any trait and the information why the generic impl doesn't match would be valuable in those cases too. |
I'd honestly go one step further and consider implementing impl<T> Clone for Arc<T>
where
T: ?Sized, (not sure how feasible that is [or whether I missed something in my reasoning], but it may be something worth shooting for) |
When using an auto derive to implement a trait such as Clone on a generic object, the code emitted will contain a constraint like: T: Clone. That is a problem for our SharedObserver, because our inner Observer does not implement Clone, and that is fine and desired. In order to work around this problem (known upstream as [issue 64417][]) we need to implement Clone for SharedObserver manually. [issue 64417]: rust-lang/rust#64417
Add more context to E0599 errors Point at the intermediary unfulfilled trait bounds. Fix rust-lang#52523, fix rust-lang#61661, cc rust-lang#36513, fix rust-lang#68131, fix rust-lang#64417, fix rust-lang#61768, cc rust-lang#57457, cc rust-lang#9082, fix rust-lang#57994, cc rust-lang#64934, cc rust-lang#65149.
Add more context to E0599 errors Point at the intermediary unfulfilled trait bounds. Fix rust-lang#52523, fix rust-lang#61661, cc rust-lang#36513, fix rust-lang#68131, fix rust-lang#64417, fix rust-lang#61768, cc rust-lang#57457, cc rust-lang#9082, fix rust-lang#57994, cc rust-lang#64934, cc rust-lang#65149.
Here's a reduced testcase:
This fails to compile with:
The way
#[derive]
works (#26925), and with 20/20 hindsight, it's obvious what's wrong. But even when you know about #26925 it takes a mental effort to go from that error message to "oh, right,#[derive(Clone)]
addsT: Clone
".It would be useful if the compiler went further, and, considering there is an
impl Clone for Bar<T>
, detailed why that impl doesn't apply toFoo
.The text was updated successfully, but these errors were encountered: