about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-05-21 17:47:23 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-05-25 11:55:50 -0700
commit609ffa1a890fd6b8b0364cd7b35bf1d45abf82d0 (patch)
treedbd09e2fa625c27c100cb21e6b196c9f45b5ec27 /src/libsyntax/ext
parent02f5786a324c40b2d8b2d0df98456e48fb45d30c (diff)
downloadrust-609ffa1a890fd6b8b0364cd7b35bf1d45abf82d0.tar.gz
rust-609ffa1a890fd6b8b0364cd7b35bf1d45abf82d0.zip
Reword malformed attribute input diagnostics
- Handle empty `cfg_attr` attribute
- Reword empty `derive` attribute error
- Use consistend error message: "malformed `attrname` attribute input"
- Provide suggestions when possible
- Move note/help to label/suggestion
- Use consistent wording "ill-formed" -> "malformed"
- Move diagnostic logic out of parser
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/derive.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libsyntax/ext/derive.rs b/src/libsyntax/ext/derive.rs
index 6e789c4c708..4db206094d3 100644
--- a/src/libsyntax/ext/derive.rs
+++ b/src/libsyntax/ext/derive.rs
@@ -5,6 +5,7 @@ use crate::ext::base::ExtCtxt;
 use crate::ext::build::AstBuilder;
 use crate::parse::parser::PathStyle;
 use crate::symbol::{Symbol, sym};
+use crate::errors::Applicability;
 
 use syntax_pos::Span;
 
@@ -17,8 +18,13 @@ pub fn collect_derives(cx: &mut ExtCtxt<'_>, attrs: &mut Vec<ast::Attribute>) ->
             return true;
         }
         if !attr.is_meta_item_list() {
-            cx.span_err(attr.span,
-                        "attribute must be of the form `#[derive(Trait1, Trait2, ...)]`");
+            cx.struct_span_err(attr.span, "malformed `derive` attribute input")
+                .span_suggestion(
+                    attr.span,
+                    "missing traits to be derived",
+                    "#[derive(Trait1, Trait2, ...)]".to_owned(),
+                    Applicability::HasPlaceholders,
+                ).emit();
             return false;
         }