-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Using an out-of-scope trait item on a boxed trait object should suggest use-ing the trait #105159
Comments
Note: A sign there may be a problem worth fixing here is the code I wrote is a near copypaste of a top stack overflow answer for a common problem :) |
So, after some investigating, this appears to be a regression of #35976, which added essentially the same suggestion I proposed here: adding a When generating the error when the lookup fails, the trait is initially included in the list of candidates, but it's filtered out by this
This was introduced in 88f2140 by @compiler-errors, which also removed the corresponding suggestion from the #35976 test's expected output. It's not immediately clear to me from the PR (#99146) why this change was necessary. If the (cc @estebank, with whom I was discussing this on Mastodon) |
Haven't look at this yet, maybe I misinterpreted what 88f4120 was achieving, and that commit just needs a revert 🤷 -- can't recall why I did that. |
Yeah, lol, I totally overlooked that the |
…er, r=estebank Restore `use` suggestion for `dyn` method call requiring `Sized` Add the suggestion back that I accidentally removed in 88f2140 because I didn't understand that suggestion was actually useful... Fixes rust-lang#105159
Given the following code:
The current output is:
Ideally the output should suggest
use
-ing the out-of-scope trait, similar to E0599:Someone tried to do dynamic dispatch between two underlying
BufReaders
used a boxed trait object (with the type spelledBox<dyn io::BufRead>
, soBufRead
wasn't in scope) and call thelines
method on the boxed reader, and it was unclear from the error why the method wasn't accessible:https://mastodon.social/@mcc/109441482880682856
This is reproducible on nightly (rustc 1.67.0-nightly (c090c68 2022-12-01)).
The text was updated successfully, but these errors were encountered: