diff options
| author | P1start <rewi-github@whanau.org> | 2014-10-18 15:39:44 +1300 |
|---|---|---|
| committer | P1start <rewi-github@whanau.org> | 2014-11-02 16:12:23 +1300 |
| commit | 5bf9ef2122e2d9c872ea551d0561c9326940446f (patch) | |
| tree | 5495f6ba64b0a2f984de9fdd65d2e235a9b7c35d /src/libsyntax/parse | |
| parent | 3327ecca422046699315122345c6c050ab73804b (diff) | |
| download | rust-5bf9ef2122e2d9c872ea551d0561c9326940446f.tar.gz rust-5bf9ef2122e2d9c872ea551d0561c9326940446f.zip | |
Convert some notes to help messages
Closes #18126.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index aa3b9668d46..5e18c6bae48 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2371,10 +2371,19 @@ impl<'a> Parser<'a> { token::LitFloat(n) => { self.bump(); let last_span = self.last_span; + let fstr = n.as_str(); self.span_err(last_span, format!("unexpected token: `{}`", n.as_str()).as_slice()); - self.span_note(last_span, - "try parenthesizing the first index; e.g., `(foo.0).1`"); + if fstr.chars().all(|x| "0123456789.".contains_char(x)) { + let float = match from_str::<f64>(fstr) { + Some(f) => f, + None => continue, + }; + self.span_help(last_span, + format!("try parenthesizing the first index; e.g., `(foo.{}){}`", + float.trunc() as uint, + float.fract().to_string()[1..]).as_slice()); + } self.abort_if_errors(); } @@ -2578,7 +2587,7 @@ impl<'a> Parser<'a> { token::Eof => { let open_braces = self.open_braces.clone(); for sp in open_braces.iter() { - self.span_note(*sp, "Did you mean to close this delimiter?"); + self.span_help(*sp, "did you mean to close this delimiter?"); } // There shouldn't really be a span, but it's easier for the test runner // if we give it one @@ -5352,8 +5361,8 @@ impl<'a> Parser<'a> { self.bump(); if self.eat_keyword(keywords::Mut) { let last_span = self.last_span; - self.span_err(last_span, "const globals cannot be mutable, \ - did you mean to declare a static?"); + self.span_err(last_span, "const globals cannot be mutable"); + self.span_help(last_span, "did you mean to declare a static?"); } let (ident, item_, extra_attrs) = self.parse_item_const(None); let last_span = self.last_span; |
