diff options
| author | bors <bors@rust-lang.org> | 2019-01-21 08:32:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-01-21 08:32:19 +0000 |
| commit | 33b0b7148fa4eacf43c204b2505867a4cd8e4735 (patch) | |
| tree | 5fbc9f7aa1ea1c430548853e5c3bf13f643b9a25 /src/libsyntax/parse | |
| parent | b5f5a2715ed8685bc19fd589a23c7c658c2fe6bd (diff) | |
| parent | 00c60d115cfb979c4ca39bb1ce3afc7bf0548d79 (diff) | |
| download | rust-33b0b7148fa4eacf43c204b2505867a4cd8e4735.tar.gz rust-33b0b7148fa4eacf43c204b2505867a4cd8e4735.zip | |
Auto merge of #57792 - Centril:rollup, r=Centril
Rollup of 5 pull requests Successful merges: - #56796 (Change bounds on `TryFrom` blanket impl to use `Into` instead of `From`) - #57768 (Continue parsing after parent type args and suggest using angle brackets) - #57769 (Suggest correct cast for struct fields with shorthand syntax) - #57783 (Add "dereference boxed value" suggestion.) - #57784 (Add span for bad doc comment) Failed merges: r? @ghost
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7e15b231276..439eec5b0c4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2176,11 +2176,11 @@ impl<'a> Parser<'a> { style != PathStyle::Mod && self.check(&token::ModSep) && self.look_ahead(1, |t| is_args_start(t)) { // Generic arguments are found - `<`, `(`, `::<` or `::(`. - let lo = self.span; if self.eat(&token::ModSep) && style == PathStyle::Type && enable_warning { self.diagnostic().struct_span_warn(self.prev_span, "unnecessary path disambiguator") .span_label(self.prev_span, "try removing `::`").emit(); } + let lo = self.span; let args = if self.eat_lt() { // `<'a, T, A = U>` @@ -4483,13 +4483,17 @@ impl<'a> Parser<'a> { } /// Emit an expected item after attributes error. - fn expected_item_err(&self, attrs: &[Attribute]) { + fn expected_item_err(&mut self, attrs: &[Attribute]) -> PResult<'a, ()> { let message = match attrs.last() { Some(&Attribute { is_sugared_doc: true, .. }) => "expected item after doc comment", _ => "expected item after attributes", }; - self.span_err(self.prev_span, message); + let mut err = self.diagnostic().struct_span_err(self.prev_span, message); + if attrs.last().unwrap().is_sugared_doc { + err.span_label(self.prev_span, "this doc comment doesn't document anything"); + } + Err(err) } /// Parse a statement. This stops just before trailing semicolons on everything but items. @@ -7636,7 +7640,7 @@ impl<'a> Parser<'a> { } None => { if !attrs.is_empty() { - self.expected_item_err(&attrs); + self.expected_item_err(&attrs)?; } self.unexpected() @@ -7699,7 +7703,7 @@ impl<'a> Parser<'a> { } if !attributes_allowed && !attrs.is_empty() { - self.expected_item_err(&attrs); + self.expected_item_err(&attrs)?; } Ok(None) } |
