diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-06-07 12:53:33 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-06-07 18:01:50 +0300 |
| commit | 2af47facc3fd7eda3fb4e52f0589bb6f48eff15c (patch) | |
| tree | 46549007a191f5676a28704a3da1cfbd5eacdf7d /src/libsyntax/parse | |
| parent | c1c60d292e2dd2deff7084208274f9a02f750d43 (diff) | |
| download | rust-2af47facc3fd7eda3fb4e52f0589bb6f48eff15c.tar.gz rust-2af47facc3fd7eda3fb4e52f0589bb6f48eff15c.zip | |
syntax: Treat error literals in more principled way
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/literal.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libsyntax/parse/literal.rs b/src/libsyntax/parse/literal.rs index 7d5356ffe4d..467ad6ccfbe 100644 --- a/src/libsyntax/parse/literal.rs +++ b/src/libsyntax/parse/literal.rs @@ -311,7 +311,11 @@ impl<'a> Parser<'a> { let (lit, span) = (token.expect_lit(), token.span); self.bump(); err.report(&self.sess.span_diagnostic, lit, span); - let lit = token::Lit::new(token::Err, lit.symbol, lit.suffix); + // Pack possible quotes and prefixes from the original literal into + // the error literal's symbol so they can be pretty-printed faithfully. + let suffixless_lit = token::Lit::new(lit.kind, lit.symbol, None); + let symbol = Symbol::intern(&pprust::literal_to_string(suffixless_lit)); + let lit = token::Lit::new(token::Err, symbol, lit.suffix); Lit::from_lit_token(lit, span).map_err(|_| unreachable!()) } } |
