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

Importing from the wrong module leads to privacy error, which is unhelpful #57619

Closed
Manishearth opened this issue Jan 15, 2019 · 1 comment
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Path resolution C-enhancement Category: An issue proposing an enhancement or a PR with one. 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

@Manishearth
Copy link
Member

use crate::foo::Bar;

mod foo {use crate::bar::Bar;}
pub mod bar {pub struct Bar;}

this kind of thing happens pretty often for me, where I try importing from the wrong module.

This gives me the following error:

error[E0603]: struct `Bar` is private
 --> src/main.rs:3:17
  |
3 | use crate::foo::Bar;
  |                 ^^^

this is misleading because most Rust mental models don't consider use statements to be private instances, they just work that way.

Ideally, this error would notice that it's a private use statement, and instead backtrack it to find the actual path that should be used.

@Manishearth Manishearth added A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Path resolution labels Jan 15, 2019
@estebank estebank added 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 Jan 6, 2020
@crlf0710 crlf0710 added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jun 11, 2020
@jplatte
Copy link
Contributor

jplatte commented Jun 3, 2021

Duplicate of #42909?

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-resolve Area: Path resolution C-enhancement Category: An issue proposing an enhancement or a PR with one. 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

Successfully merging a pull request may close this issue.

4 participants