diff options
| author | bors <bors@rust-lang.org> | 2014-11-04 03:36:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-11-04 03:36:55 +0000 |
| commit | ec28b4a6c8c0a249fe341afde55d026177aabac6 (patch) | |
| tree | d233ebf5c906947f53f370bd8039bb004a5cbbdb /src/libsyntax/parse/parser.rs | |
| parent | 0a5e7f35949d18f312dca90af73e56aced6f2b0e (diff) | |
| parent | 5bf9ef2122e2d9c872ea551d0561c9326940446f (diff) | |
| download | rust-ec28b4a6c8c0a249fe341afde55d026177aabac6.tar.gz rust-ec28b4a6c8c0a249fe341afde55d026177aabac6.zip | |
auto merge of #18132 : P1start/rust/more-help, r=jakub-
Closes #18126. At the moment this mostly only changes notes that are particularly help-oriented or directly suggest the user to do something to help messages, and does not change messages that simply explain an error message further. If it is decided that those messages should also be help messages, I can add them to this PR, but for now I’m excluding them as I believe that changing those messages might leave very few places where notes would be appropriate.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -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; |
