diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-06 17:45:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-06 17:45:22 -0700 |
| commit | e74ab50d07a8b21e8d03ebfb0da8dae6583b1e67 (patch) | |
| tree | 168e729a30abda7528a52c811ea689fc14ed8f5e /src/librustc_parse/parser | |
| parent | 7942d9a65a1100c840c7d55172c7e9588066719d (diff) | |
| parent | 84282fd6f17235ca52613bbfd1cb6be301897836 (diff) | |
Rollup merge of #73953 - JohnTitor:audit-hidden-sugg, r=estebank
Audit hidden/short code suggestions Should fix #73641. Audit uses of `span_suggestion_short` and `tool_only_span_suggestion` (`span_suggestion_hidden` is already tested with `run-rustfix`). Leave some FIXMEs for futher improvements/fixes. r? @estebank
Diffstat (limited to 'src/librustc_parse/parser')
| -rw-r--r-- | src/librustc_parse/parser/diagnostics.rs | 7 | ||||
| -rw-r--r-- | src/librustc_parse/parser/mod.rs | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/librustc_parse/parser/diagnostics.rs b/src/librustc_parse/parser/diagnostics.rs index 16a118cb48c..7822c097390 100644 --- a/src/librustc_parse/parser/diagnostics.rs +++ b/src/librustc_parse/parser/diagnostics.rs @@ -1228,10 +1228,13 @@ impl<'a> Parser<'a> { if let Some(sp) = unmatched.unclosed_span { err.span_label(sp, "unclosed delimiter"); } + // Backticks should be removed to apply suggestions. + let mut delim = delim.to_string(); + delim.retain(|c| c != '`'); err.span_suggestion_short( self.prev_token.span.shrink_to_hi(), - &format!("{} may belong here", delim.to_string()), - delim.to_string(), + &format!("`{}` may belong here", delim), + delim, Applicability::MaybeIncorrect, ); if unmatched.found_delim.is_none() { diff --git a/src/librustc_parse/parser/mod.rs b/src/librustc_parse/parser/mod.rs index 7811d5fb741..61c680469f0 100644 --- a/src/librustc_parse/parser/mod.rs +++ b/src/librustc_parse/parser/mod.rs @@ -699,7 +699,7 @@ impl<'a> Parser<'a> { // misses a separator. expect_err .span_suggestion_short( - sp, + self.sess.source_map().next_point(sp), &format!("missing `{}`", token_str), token_str, Applicability::MaybeIncorrect, |
