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

[ER] Help for unresolved super::X imports too. #85249

Open
leonardo-m opened this issue May 13, 2021 · 3 comments
Open

[ER] Help for unresolved super::X imports too. #85249

leonardo-m opened this issue May 13, 2021 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@leonardo-m
Copy link

This code:

mod foo {
    use super::NonZeroU8;

    pub(crate) fn bar() -> NonZeroU8 {
        NonZeroU8::new(1).unwrap()
    }
}

use foo::bar;

fn main() {
    let y = NonZeroU8::new(2).unwrap();
}

Trying to compile it with rustc (1.54.0-nightly 5c02926 2021-05-11), it gives:

error[E0432]: unresolved import `super::NonZeroU8`
 --> ...\test.rs:2:9
  |
2 |     use super::NonZeroU8;
  |         ^^^^^^^^^^^^^^^^ no `NonZeroU8` in the root

error[E0433]: failed to resolve: use of undeclared type `NonZeroU8`
  --> ...\test.rs:12:13
   |
12 |     let y = NonZeroU8::new(2).unwrap();
   |             ^^^^^^^^^ not found in this scope
   |
help: consider importing one of these items
   |
9  | use core::num::NonZeroU8;
   |
9  | use std::num::NonZeroU8;
   |

I'd like to see the 'use std::num::NonZeroU8;' help for the first unresolved import in the module too.

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 18, 2021
@TaKO8Ki
Copy link
Member

TaKO8Ki commented Sep 26, 2021

I think this problem was solved in #89224.

@leonardo-m
Copy link
Author

I think this problem was solved in #89224.

I'll take a look in the next Nightly.

@leonardo-m
Copy link
Author

89224 doesn't solve the problem of this ER:

error[E0432]: unresolved import `super::NonZeroU8`
 --> ...\test.rs:2:9
  |
2 |     use super::NonZeroU8;
  |         ^^^^^^^^^^^^^^^^^ no `NonZeroU8` in the root

error[E0433]: failed to resolve: use of undeclared type `NonZeroU8`
  --> ...\test.rs:12:13
   |
12 |     let y = NonZeroU8::new(2).unwrap();
   |             ^^^^^^^^^ not found in this scope
   |
help: consider importing one of these items
   |
9  | use std::num::NonZeroU8;
   |
9  | use core::num::NonZeroU8;
   |

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-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants