about summary refs log tree commit diff
path: root/src/librustc_parse/parser
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-04-03 03:17:40 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2020-04-03 03:17:40 +0200
commit5cb5ddeb3c8463ecb9472bea03b69a9521e87c5c (patch)
tree6a9f617217f76f83cc6557e1a93c93534fabd2f6 /src/librustc_parse/parser
parent08a724967ede178052f43049248b647a9feab806 (diff)
downloadrust-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.rs6
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)
                 }
             }