diff options
| author | varkor <github@varkor.com> | 2019-02-07 14:58:31 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2019-02-07 15:03:20 +0100 |
| commit | 9ad04b9960ed125d450fbf49f3c4c21702ab36ae (patch) | |
| tree | c34db887f1df73492adf28a8062576d8cc4612b0 /src/libsyntax/parse/parser.rs | |
| parent | dbc7924b3fbd9b9a0a206b16b4f00049948676c3 (diff) | |
| download | rust-9ad04b9960ed125d450fbf49f3c4c21702ab36ae.tar.gz rust-9ad04b9960ed125d450fbf49f3c4c21702ab36ae.zip | |
Add warning for a parameter list with an attribute but no parameters
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7640f0bdf06..d9195ebe312 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5545,13 +5545,25 @@ impl<'a> Parser<'a> { params.push(self.parse_ty_param(attrs)?); } else { // Check for trailing attributes and stop parsing. - if !attrs.is_empty() && !params.is_empty() { - self.struct_span_err( - attrs[0].span, - &format!("trailing attribute after generic parameter"), - ) - .span_label(attrs[0].span, "attributes must go before parameters") - .emit(); + if !attrs.is_empty() { + if !params.is_empty() { + self.struct_span_err( + attrs[0].span, + &format!("trailing attribute after generic parameter"), + ) + .span_label(attrs[0].span, "attributes must go before parameters") + .emit(); + } else { + self.struct_span_err( + attrs[0].span, + &format!("attribute without generic parameters"), + ) + .span_label( + attrs[0].span, + "attributes are only permitted when preceding parameters", + ) + .emit(); + } } break } |
