about summary refs log tree commit diff
path: root/compiler/rustc_passes/src
diff options
context:
space:
mode:
authorCamelid <camelidcamel@gmail.com>2021-03-14 14:00:02 -0700
committerCamelid <camelidcamel@gmail.com>2021-03-14 14:00:02 -0700
commit13076f90d2febedd44d395561b0ec844cac64f8b (patch)
tree951f89bbd21411243441fd76362ae3b05e182ee5 /compiler/rustc_passes/src
parent13884dc2af3d993629eec4a5489dc99bd0a00a71 (diff)
downloadrust-13076f90d2febedd44d395561b0ec844cac64f8b.tar.gz
rust-13076f90d2febedd44d395561b0ec844cac64f8b.zip
Tweak diagnostics
- Tweak lint message
- Display multi-segment paths correctly
Diffstat (limited to 'compiler/rustc_passes/src')
-rw-r--r--compiler/rustc_passes/src/check_attr.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs
index c89518df007..2edc2315f05 100644
--- a/compiler/rustc_passes/src/check_attr.rs
+++ b/compiler/rustc_passes/src/check_attr.rs
@@ -597,11 +597,14 @@ impl CheckAttrVisitor<'tcx> {
                                 hir_id,
                                 i_meta.span,
                                 |lint| {
-                                    lint.build(&format!(
-                                        "unknown `doc` attribute `{}`",
-                                        i_meta.name_or_empty()
-                                    ))
-                                    .emit();
+                                    let msg = if let Ok(snippet) =
+                                        self.tcx.sess.source_map().span_to_snippet(i_meta.path.span)
+                                    {
+                                        format!("unknown `doc` attribute `{}`", snippet,)
+                                    } else {
+                                        String::from("unknown `doc` attribute")
+                                    };
+                                    lint.build(&msg).emit();
                                 },
                             );
                             is_valid = false;
@@ -613,7 +616,7 @@ impl CheckAttrVisitor<'tcx> {
                         hir_id,
                         meta.span(),
                         |lint| {
-                            lint.build(&format!("unknown `doc` attribute")).emit();
+                            lint.build(&format!("invalid `doc` attribute")).emit();
                         },
                     );
                     is_valid = false;