diff options
| author | Tim Neumann <mail@timnn.me> | 2017-04-12 14:45:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-12 14:45:41 +0200 |
| commit | 918e35a9bd95eab4d233aedc49168adb7c944f76 (patch) | |
| tree | 1a74b9e3e59d3701b848af08d4fffb6dea123983 /src/libsyntax/parse/parser.rs | |
| parent | 49082ae9f296f1f7d5dddd0ced550c94688fa13f (diff) | |
| parent | 44e414c4770ff0800c375ddbb8e0f46ee00bcab1 (diff) | |
| download | rust-918e35a9bd95eab4d233aedc49168adb7c944f76.tar.gz rust-918e35a9bd95eab4d233aedc49168adb7c944f76.zip | |
Rollup merge of #41087 - estebank:tuple-float-index, r=arielb1
Use proper span for tuple index parsed as float Fix diagnostic suggestion from: ```rust help: try parenthesizing the first index | (1, (2, 3)).((1, (2, 3)).1).1; ``` to the correct: ```rust help: try parenthesizing the first index | ((1, (2, 3)).1).1; ``` Fix #41081.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 58be43526fd..3b928ea93c7 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2552,10 +2552,10 @@ impl<'a> Parser<'a> { } token::Literal(token::Float(n), _suf) => { self.bump(); - let prev_span = self.prev_span; let fstr = n.as_str(); - let mut err = self.diagnostic().struct_span_err(prev_span, + let mut err = self.diagnostic().struct_span_err(self.prev_span, &format!("unexpected token: `{}`", n)); + err.span_label(self.prev_span, &"unexpected token"); if fstr.chars().all(|x| "0123456789.".contains(x)) { let float = match fstr.parse::<f64>().ok() { Some(f) => f, @@ -2573,7 +2573,7 @@ impl<'a> Parser<'a> { word(&mut s.s, fstr.splitn(2, ".").last().unwrap()) }); err.span_suggestion( - prev_span, + lo.to(self.prev_span), "try parenthesizing the first index", sugg); } |
