diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2021-07-17 11:13:50 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2021-07-19 08:43:35 -0700 |
| commit | ba052bd8de1459acb6809215b0bedf4ea476ef9a (patch) | |
| tree | f6ed28030012d73e09f041b7f94d78fced448771 /compiler/rustc_builtin_macros/src/derive.rs | |
| parent | c78ebb7bdcfc924a20fd069891ffe1364d6814e7 (diff) | |
| download | rust-ba052bd8de1459acb6809215b0bedf4ea476ef9a.tar.gz rust-ba052bd8de1459acb6809215b0bedf4ea476ef9a.zip | |
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.rs | 5 |
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(); } |
