Skip to content
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

use suggestions corrupted w/ nearby code when inside items #43769

Closed
durka opened this issue Aug 9, 2017 · 6 comments · Fixed by #43929
Closed

use suggestions corrupted w/ nearby code when inside items #43769

durka opened this issue Aug 9, 2017 · 6 comments · Fixed by #43929
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@durka
Copy link
Contributor

durka commented Aug 9, 2017

This is... bizarre.

STR

fn main() {
    type Dict<K, V> = HashMap<K, V>;
}

Expected

help: possible candidates are found in other modules, you can import them into scope
  | use std::collections::HashMap;
  | use std::collections::hash_map::HashMap;

Actual

help: possible candidates are found in other modules, you can import them into scope
  | fn main() use std::collections::HashMap;
  | fn main() use std::collections::hash_map::HashMap;

The issue seems to arise from the erroneous code being inside another block. I originally encountered this with code generated by `lazy_static!`.
@oli-obk
Copy link
Contributor

oli-obk commented Aug 9, 2017

Duplicate of #42835

@durka
Copy link
Contributor Author

durka commented Aug 9, 2017

Is it a duplicate? Issue here is the suggestion text is invalid.

@Mark-Simulacrum Mark-Simulacrum added A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Aug 10, 2017
@Mark-Simulacrum
Copy link
Member

I don't think this is a duplicate of that issue; the diagnostic here needs to be enhanced to not be mangled with surrounding context, which isn't related to updating the message to note where to add the import.

cc @estebank, I seem to recall you doing something with this diagnostic recently that was potentially relevant, but I could be wrong.

@oli-obk
Copy link
Contributor

oli-obk commented Aug 10, 2017

It is 100% related. I changed the suggestion placement and screwed up. The suggestions are placed at the beginning of the current module/function, but that just doesn't work in the presence of desugarings. So the suggestion you see doesn't mangle with surrounding context, it is actually placed there!

@oli-obk
Copy link
Contributor

oli-obk commented Aug 10, 2017

Anyway, the original issue that's more related is #42548, but they are all caused by the same underlying problem

@estebank
Copy link
Contributor

estebank commented Aug 10, 2017

@Mark-Simulacrum I think the closest PRs I've worked on recently have been #42383 and #42904, but I doubt they affected the current issue given that I'm seeing the problem in the stable compiler as well. #42835 might be related (which sparked my urgency on completing #42904, so that it'd be more obvious when it happens).

bors added a commit that referenced this issue Aug 21, 2017
Improve placement of `use` suggestions

r? @nrc

cc @estebank @Mark-Simulacrum

fixes #42835
fixes #42548
fixes #43769
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants