about summary refs log tree commit diff
path: root/src/libsyntax/attr
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/attr
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/attr')
-rw-r--r--src/libsyntax/attr/builtin.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libsyntax/attr/builtin.rs b/src/libsyntax/attr/builtin.rs
index 65ca96afab1..b96f13335b2 100644
--- a/src/libsyntax/attr/builtin.rs
+++ b/src/libsyntax/attr/builtin.rs
@@ -92,7 +92,15 @@ pub fn find_unwind_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> Op
                     }
 
                     diagnostic.map(|d| {
-                        span_err!(d, attr.span, E0633, "malformed `#[unwind]` attribute");
+                        struct_span_err!(d, attr.span, E0633, "malformed `unwind` attribute input")
+                            .span_label(attr.span, "invalid argument")
+                            .span_suggestions(
+                                attr.span,
+                                "the allowed arguments are `allowed` and `aborts`",
+                                (vec!["allowed", "aborts"]).into_iter()
+                                    .map(|s| format!("#[unwind({})]", s)),
+                                Applicability::MachineApplicable,
+                            ).emit();
                     });
                 }
             }