Add diagnostic for incorrect pub (restriction)#40627
Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
2daec2f to
280fd71
Compare
src/libsyntax/parse/parser.rs
Outdated
There was a problem hiding this comment.
Looks like this is always true, we have already checked for ( in the outer condition.
|
Looks like |
19fd6b3 to
f682709
Compare
|
It's pretty chatty, but I admit it also looks very helpful. I'm good with it as a message. |
|
regarding the chattiness, do we really need to keep these two lines: It seems like these cases are obvious enough, if one assumes that someone using parentheses after |
|
@pnkfelix that's a reasonable. I'll modify it tonight. |
|
If we're not going to make it an exhaustive listing, then I would change the heading text from "valid restrictions are" to "some example restrictions are" or something like that. |
|
The code looks good to me, modulo tweaking the message. I agree it's chatty but also that it seems helpful. |
src/libsyntax/parse/parser.rs
Outdated
There was a problem hiding this comment.
Ah, that reminds me. Seems like we should have some tests exercising these paths (i.e., tests that would fail with this being true)...
src/libsyntax/parse/parser.rs
Outdated
There was a problem hiding this comment.
It's not fully on-topic, but could you remove all this cruft remaining from the old visibility syntax, I've missed it somehow.
It should be "parse_visibility" -> "parse_ty" -> "return the result" now, no extra magic.
|
☔ The latest upstream changes (presumably #40043) made this pull request unmergeable. Please resolve the merge conflicts. |
4d89d2e to
c93ccb5
Compare
|
LGTM, but couple of tests fail after rebase. |
c93ccb5 to
ce52345
Compare
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() {}
```
Remove cruft from old `pub(path)` syntax.
ce52345 to
769b95d
Compare
|
@petrochenkov fixed. |
|
@bors r+ |
|
📌 Commit 769b95d has been approved by |
…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.

Given the following statement
Provide the following diagnostic:
Follow up to #40340, fix #40599, cc #32409.