about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src/derive.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-07-19 18:44:27 +0000
committerbors <bors@rust-lang.org>2021-07-19 18:44:27 +0000
commitd5af63480fb08b5276a608a8cd4865fa92d4b2bc (patch)
tree4dafbbc941ca3ed032a8bdb4c90c36aeab752152 /compiler/rustc_builtin_macros/src/derive.rs
parentfad295b299d9e93950c27acd6a12026d100185fe (diff)
parentba052bd8de1459acb6809215b0bedf4ea476ef9a (diff)
downloadrust-d5af63480fb08b5276a608a8cd4865fa92d4b2bc.tar.gz
rust-d5af63480fb08b5276a608a8cd4865fa92d4b2bc.zip
Auto merge of #87225 - estebank:cleanup, r=oli-obk
Various diagnostics clean ups/tweaks

* Always point at macros, including derive macros
* Point at non-local items that introduce a trait requirement
* On private associated item, point at definition
Diffstat (limited to 'compiler/rustc_builtin_macros/src/derive.rs')
-rw-r--r--compiler/rustc_builtin_macros/src/derive.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_builtin_macros/src/derive.rs b/compiler/rustc_builtin_macros/src/derive.rs
index 60d6bae38b5..e0389f448eb 100644
--- a/compiler/rustc_builtin_macros/src/derive.rs
+++ b/compiler/rustc_builtin_macros/src/derive.rs
@@ -84,8 +84,10 @@ fn report_bad_target(sess: &Session, item: &Annotatable, span: Span) -> bool {
             sess,
             span,
             E0774,
-            "`derive` may only be applied to structs, enums and unions",
+            "`derive` may only be applied to `struct`s, `enum`s and `union`s",
         )
+        .span_label(span, "not applicable here")
+        .span_label(item.span(), "not a `struct`, `enum` or `union`")
         .emit();
     }
     bad_target
@@ -99,6 +101,7 @@ fn report_unexpected_literal(sess: &Session, lit: &ast::Lit) {
         _ => "for example, write `#[derive(Debug)]` for `Debug`".to_string(),
     };
     struct_span_err!(sess, lit.span, E0777, "expected path to a trait, found literal",)
+        .span_label(lit.span, "not a trait")
         .help(&help_msg)
         .emit();
 }