diff options
| author | Ryan Levick <me@ryanlevick.com> | 2021-07-07 14:25:40 +0200 |
|---|---|---|
| committer | Ryan Levick <me@ryanlevick.com> | 2021-07-07 15:02:20 +0200 |
| commit | 04a9c10fc27fcf7c4a4415401c7653a361177631 (patch) | |
| tree | e140a54552ebedb7a95c5ab11738330e1fd98f1b /compiler/rustc_parse/src/parser | |
| parent | c5e344f7747dbd7e7d4b209e3c480deb5979a56f (diff) | |
| download | rust-04a9c10fc27fcf7c4a4415401c7653a361177631.tar.gz rust-04a9c10fc27fcf7c4a4415401c7653a361177631.zip | |
Fix ICE when misplaced visibility cannot be properly parsed
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 2daa9e2485b..2ce63d011f4 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1791,7 +1791,13 @@ impl<'a> Parser<'a> { if self.check_keyword(kw::Pub) { let sp = sp_start.to(self.prev_token.span); if let Ok(snippet) = self.span_to_snippet(sp) { - let vis = self.parse_visibility(FollowedByType::No)?; + let vis = match self.parse_visibility(FollowedByType::No) { + Ok(v) => v, + Err(mut d) => { + d.cancel(); + return Err(err); + } + }; let vs = pprust::vis_to_string(&vis); let vs = vs.trim_end(); err.span_suggestion( |
