-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Error message’s hint pointing entirely at the wrong place. #77677
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
For reference, the errors now given look like the following:
This seems fixed in latest output?
This seems fixed in latest output?
This point still stands. Unsure what the best solution is. |
Thanks for noticing this @Enselic. It appears like the bug was “accidentally” fixed by changes / simplifications(?) to the suggestion logic, in #99249 I wonder if the code that originally did something wrong for figuring out the source location still exists for any other purposes, or if it’s gone entirely. I would ask for feedback from @cjgillot (:wave:), but I don’t know how much one can remember one year after the PR, and as long as there are no known issues (and this is a diagnostics problem to begin with, only), it’s likely not worth spending any time investigating. I think I will not keep this issue open for merely the suggestion to add a mention of the actual outer function
or perhaps even pointing to it? (Of course only in cases like this where the parameter is from the |
Reduced example:
(Playground)
Errors:
This came up during refactoring, while I was adding the parameter
T
toBar
(intentionally named the same as the outerT
because they are going to be instantiated to the same type anyways). This kind of error message (the first one,E0401
) had me puzzled for some time before figuring out that it was nonsensical. I’m referring to thetry adding a local generic parameter in this method instead
part. The real code of course was quite a bit longer, making the situation actually confusing, in particular:try adding ...
hint points to the wrong place entirely. It should suggest adding a parameter to theimpl TraitG
(even though such a suggestion might not always make sense, idk).type parameter from outer function
pointer is also somewhat confusing, since whenfoo
’s body is a few lines andbar
is super long and nested, it is quite nontrivial to even figure out that “outer function
” refers tobar()
. (As in: it is easy to forget that you’re even inside of a function body at all if you’ve been focusing on thisBar
struct and it’simpl
s for a while.) Also... what is the distinction between the wordsfunction
andmethod
here? (My original code hasbar(self)
but still called it “outer function
”.)@rustbot modify labels: A-diagnostics, T-compiler, D-confusing, C-bug.
The text was updated successfully, but these errors were encountered: