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

Empty super::{} and self::{} imports gives an error. #119776

Open
JeanCASPAR opened this issue Jan 9, 2024 · 3 comments
Open

Empty super::{} and self::{} imports gives an error. #119776

JeanCASPAR opened this issue Jan 9, 2024 · 3 comments
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@JeanCASPAR
Copy link
Contributor

Code

mod foo {
    use super::{};
}

Current output

error[E0432]: unresolved import `super`
 --> src/lib.rs:2:9
  |
2 |     use super::{};
  |         ^^^^^^^^^ no `super` in the root

warning: unused import: `super::{}`
 --> src/lib.rs:2:9
  |
2 |     use super::{};
  |         ^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

Desired output

warning: unused import: `super::{}`
 --> src/lib.rs:2:9
  |
2 |     use super::{};
  |         ^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

Rationale and extra context

The same problem exists with an empty use self::{}; import.

There is no reason for empty self and super imports gives an error when empty crate::{}, some_crate::{} and path::to::a::module::{} imports are perfectly valid. The compiler should of course emit a warning.

If they should be forbidden nonetheless, the error message could be clearer.

It should be noted that the following code if perfectly valid:

mod bar {}
mod foo {
    use super::bar::{};
}
use self::bar::{};

I obtained such a code with empty super imports with macros.

Other cases

No response

Rust Version

rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-unknown-linux-gnu
release: 1.75.0
LLVM version: 17.0.6

Anything else?

No response

@JeanCASPAR JeanCASPAR 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 Jan 9, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 9, 2024
@saethlin saethlin added C-bug Category: This is a bug. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 9, 2024
@Noratrieb
Copy link
Member

@petrochenkov

@petrochenkov
Copy link
Contributor

The relevant code is messy, I have a bunch of similar issues assigned to me (#29036, #35612, #37156, #39401) but never got to fixing them due to low priority.

@mj10021
Copy link
Contributor

mj10021 commented Jan 9, 2024

Is this a good issue if I'll need some help/mentoring or would that be too annoying?

@fmease fmease added A-resolve Area: Name/path resolution done by `rustc_resolve` specifically and removed A-diagnostics Area: Messages for errors, warnings, and lints labels Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-bug Category: This is a bug. 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

7 participants