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

Unergonomic pub(in path) error message #40691

Closed
est31 opened this issue Mar 21, 2017 · 2 comments
Closed

Unergonomic pub(in path) error message #40691

est31 opened this issue Mar 21, 2017 · 2 comments

Comments

@est31
Copy link
Member

est31 commented Mar 21, 2017

The pub(in path) error message is very unergonomic when it comes to paths that don't exist, or don't exist yet. Take this example, its how the error was intented:

pub mod baa {}
pub mod boo {
	pub (in baa) fn foo() {}
}

gives an error "visibilities can only be restricted to ancestor modules". Now take this example:

pub mod boo {
	pub (in baa) fn foo() {}
}
pub mod baa {}

This gives an error "cannot find module baa in the crate root".

And this code:

pub mod boo {
	pub (in baa::baa) fn foo() {}
}

even gives an error "failed to resolve. Maybe a missing extern crate baa;?".

What should happen instead is that in the second and third case, it should output an error similar to the first one. As it seems to not know about modules declared after the code yet (see second case), adding a note to the existing error is not enough, as clearly an error "cannot find module baa in the crate root" is misleading in this case. So unless it can be taught to know modules declared after the current code, I'd suggest to have an error similar to the first case in all three cases.

@est31
Copy link
Member Author

est31 commented Mar 21, 2017

Seems this is already pointed out in src/test/compile-fail/resolve-bad-visibility.rs. Still, I consider this a bug.

@petrochenkov
Copy link
Contributor

Duplicate of #40066

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants