parse full visibility when recovering
This commit is contained in:
parent
b2b9555f95
commit
1aa43af370
@ -8623,11 +8623,15 @@ impl<'a> Parser<'a> {
|
||||
/// Recover from `pub` keyword in places where it seems _reasonable_ but isn't valid.
|
||||
fn eat_bad_pub(&mut self) {
|
||||
if self.token.is_keyword(keywords::Pub) {
|
||||
self.bump();
|
||||
let mut err = self.diagnostic()
|
||||
.struct_span_err(self.prev_span, "unnecessary visibility qualifier");
|
||||
err.span_label(self.prev_span, "`pub` not permitted here");
|
||||
err.emit();
|
||||
match self.parse_visibility(false) {
|
||||
Ok(vis) => {
|
||||
let mut err = self.diagnostic()
|
||||
.struct_span_err(vis.span, "unnecessary visibility qualifier");
|
||||
err.span_label(vis.span, "`pub` not permitted here");
|
||||
err.emit();
|
||||
}
|
||||
Err(mut err) => err.emit(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,9 @@
|
||||
enum Bird {
|
||||
pub Duck,
|
||||
//~^ ERROR unnecessary visibility qualifier
|
||||
Goose
|
||||
Goose,
|
||||
pub(crate) Dove
|
||||
//~^ ERROR unnecessary visibility qualifier
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,5 +4,11 @@ error: unnecessary visibility qualifier
|
||||
LL | pub Duck,
|
||||
| ^^^ `pub` not permitted here
|
||||
|
||||
error: aborting due to previous error
|
||||
error: unnecessary visibility qualifier
|
||||
--> $DIR/issue-28433.rs:7:5
|
||||
|
|
||||
LL | pub(crate) Dove
|
||||
| ^^^^^^^^^^ `pub` not permitted here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user