Skip to content

Weird import suggestion #105373

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

Closed
GuillaumeGomez opened this issue Dec 6, 2022 · 1 comment · Fixed by #106175
Closed

Weird import suggestion #105373

GuillaumeGomez opened this issue Dec 6, 2022 · 1 comment · Fixed by #106175
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@GuillaumeGomez
Copy link
Member

I think it'll be pretty explicit by itself:

error[E0432]: unresolved import `rustc_infer::traits::ObligationCtxt`
  --> src/librustdoc/clean/mod.rs:21:56
   |
21 | use rustc_infer::traits::{Obligation, ObligationCause, ObligationCtxt};
   |                                                        ^^^^^^^^^^^^^^ no `ObligationCtxt` in `traits`
   |
help: a similar name exists in the module
   |
21 | use rustc_infer::traits::{Obligation, ObligationCause, Obligation};
   |                                                        ~~~~~~~~~~
help: consider importing this struct instead
   |
21 | use rustc_infer::traits::{Obligation, ObligationCause, rustc_trait_selection::traits::ObligationCtxt;
   |                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It is suggesting to add an item from another dependency directly inside the current one, which is obviously wrong.

@GuillaumeGomez GuillaumeGomez added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 6, 2022
@estebank estebank added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. labels Dec 13, 2022
@compiler-errors compiler-errors self-assigned this Dec 27, 2022
@est31
Copy link
Member

est31 commented Dec 29, 2022

Dupe of #103943

compiler-errors added a commit to compiler-errors/rust that referenced this issue Jan 9, 2023
…=oli-obk

Fix bad import suggestion with nested `use` tree

Fixes rust-lang#105566
Fixes rust-lang#105373

Ideally, we'd find some way to turn these into structured suggestions -- perhaps on a separate line as a different `use` statement, but I have no idea how to access the span for the whole `use` from this point in the import resolution code.
@bors bors closed this as completed in 684a371 Jan 10, 2023
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 A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants