diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-04-03 03:17:40 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-04-03 03:17:40 +0200 |
| commit | 5cb5ddeb3c8463ecb9472bea03b69a9521e87c5c (patch) | |
| tree | 6a9f617217f76f83cc6557e1a93c93534fabd2f6 /src/librustc_parse/parser | |
| parent | 08a724967ede178052f43049248b647a9feab806 (diff) | |
| download | rust-5cb5ddeb3c8463ecb9472bea03b69a9521e87c5c.tar.gz rust-5cb5ddeb3c8463ecb9472bea03b69a9521e87c5c.zip | |
.unwrap() less on .span_to_snippet()
Diffstat (limited to 'src/librustc_parse/parser')
| -rw-r--r-- | src/librustc_parse/parser/stmt.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/librustc_parse/parser/stmt.rs b/src/librustc_parse/parser/stmt.rs index fddfe48bf86..b3764d2d47b 100644 --- a/src/librustc_parse/parser/stmt.rs +++ b/src/librustc_parse/parser/stmt.rs @@ -165,9 +165,9 @@ impl<'a> Parser<'a> { // Rewind to before attempting to parse the type and continue parsing. let parser_snapshot_after_type = self.clone(); mem::replace(self, parser_snapshot_before_type); - - let snippet = self.span_to_snippet(pat.span).unwrap(); - err.span_label(pat.span, format!("while parsing the type for `{}`", snippet)); + if let Ok(snip) = self.span_to_snippet(pat.span) { + err.span_label(pat.span, format!("while parsing the type for `{}`", snip)); + } (Some((parser_snapshot_after_type, colon_sp, err)), None) } } |
