Skip to content

suggest declaring modules when file found but module not defined #142730

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bend-n
Copy link
Contributor

@bend-n bend-n commented Jun 19, 2025

suggests declaring modules when a module is found but not defined, i.e

├── main.rs: `use thing::thang;`
└── thing.rs: `struct thang`

or

├── main.rs: `use thing::thang;`
└── thing
    └── mod.rs: `struct thang`

which currently is just

error[E0432]: unresolved import `yeah`
 --> src/main.rs:1:1
  |
1 | use thing::thang;
  |     ^^^^^ use of unresolved module or unlinked crate `thing`
  |

but now would have this nice help:

= help: you may have forgotten to declare the module `thing`. use `mod thing` in this file to declare this module.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 19, 2025
@bend-n
Copy link
Contributor Author

bend-n commented Jun 19, 2025

@rustbot label A-diagnostics

@rustbot rustbot added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 19, 2025
@rust-log-analyzer

This comment has been minimized.

@bend-n bend-n marked this pull request as ready for review June 20, 2025 12:00
@rustbot
Copy link
Collaborator

rustbot commented Jun 20, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 20, 2025
@rust-log-analyzer

This comment has been minimized.

@bend-n bend-n force-pushed the suggest_declaring_modules_when_file_found_but_module_not_defined branch from 7174cb4 to 397c51b Compare June 20, 2025 13:41
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 S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants