-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Parse pub(restricted)
visibilities on tuple struct fields
#33161
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Parse pub(restricted)
visibilities on tuple struct fields
#33161
Conversation
pub(restricted)
visibilities on tuple struct fields
Ha, I expected to implement this myself today. I'd like to see more tests for error messages for failed reinterpretation. |
Will do. Do you think there should be a different error message for failed reinterpretation?
Good point, I hadn't considered that. Will do. |
It just needs to be reasonable, I think the current one is ok. |
☔ The latest upstream changes (presumably #33179) made this pull request unmergeable. Please resolve the merge conflicts. |
0deeebf
to
1bfc50b
Compare
type T = (); | ||
struct S1(pub(foo) (), pub(T), pub(crate) (), pub(((), T))); | ||
struct S2(pub(id!(foo)) ()); //~ ERROR expected one of `+` or `,`, found `(` | ||
//~| ERROR expected one of `+`, `;`, or `where`, found `(` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cf #33188
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikomatsakis we have this test case, but the macro id
should be
#![feature(type_macros)]
macro_rules! id {
($t:ty) => { $t }
}
instead of how it is defined now.
Is this the type of test you had in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add more tests, but due to poor error recovery we need one test per parse error.
I rebased and addressed @petrochenkov's comments. |
let ty = p.parse_ty_sum()?; | ||
let mut vis = p.parse_visibility(false)?; | ||
let ty_is_interpolated = | ||
p.token.is_interpolated() || p.look_ahead(1, |t| t.is_interpolated()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any tests covering this interpolated case? I expected to see one where we substitute in a $t:ty
.
It is a bit of a shame that we have no $p:path
fragment specificier, though I guess rust-lang/rfcs#1575 would address the use case.
Yes, and maybe also having |
Good point, will do. |
r=me w/ a few more tests also, @jseyfried, you can I think use the revisions mechanism if you'd prefer to have multiple errors per file. You have to add
then write code with
or |
(Though maybe it doesn't work with that class of test yet) |
Interesting, I'll give it a try. |
The revisions mechanism won't work for parse errors since we always parse and expand unconfigured items (cf my comment in #25544). |
1bfc50b
to
d2ca7d0
Compare
d2ca7d0
to
78a8127
Compare
@bors r=nikomatsakis |
📌 Commit 78a8127 has been approved by |
…matsakis Parse `pub(restricted)` visibilities on tuple struct fields Parse `pub(restricted)` on tuple struct fields (cc #32409). r? @nikomatsakis
Parse
pub(restricted)
on tuple struct fields (cc #32409).r? @nikomatsakis