-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Subpar error message on pub (ident) fn foo
#40599
Comments
#40627 proposes the following output for a given statement error: incorrect restriction in `pub`
--> file.rs:15:1
|
15 | pub (a) fn afn() {}
| ^^^
|
= help: valid visibility restrictions are:
`pub`: visible on every module that imports this module
`pub(crate)`: visible only on the current crate
`pub(super)`: visible only in the current module's parent
`pub(in path::to::module)`: visible only on the specified path
`pub(self)` or ``: visible only in the current module
help: to make this visible only to module `a`, add `in` before the path:
| pub (in a) fn afn() {} |
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this issue
Mar 23, 2017
…nkov Add diagnostic for incorrect `pub (restriction)` Given the following statement ```rust pub (a) fn afn() {} ``` Provide the following diagnostic: ```rust error: incorrect restriction in `pub` --> file.rs:15:1 | 15 | pub (a) fn afn() {} | ^^^ | = help: some valid visibility restrictions are: `pub(crate)`: visible only on the current crate `pub(super)`: visible only in the current module's parent `pub(in path::to::module)`: visible only on the specified path help: to make this visible only to module `a`, add `in` before the path: | pub (in a) fn afn() {} ``` Follow up to rust-lang#40340, fix rust-lang#40599, cc rust-lang#32409.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Someone who had code with the old
pub_restricted
feature is going to get pretty bad error message feedback:Here's the message you get (ever since
pub(in path)
was implemented, sometime after March 4th:(At the very least, it would be good if it highlighted
pub (a)
in its entirety, not justpub
...)Also, someone who doesn't know about pub restricted and just has a syntactic typo is also going to have problems here, since it is very confusing that the compiler seems to be saying that it doesn't know about the
pub
visibility, when that is one of the most fundamental visibilities.The text was updated successfully, but these errors were encountered: