about summary refs log tree commit diff
diff options
context:
space:
mode:
authormark <markm@cs.wisc.edu>2020-03-21 21:32:35 -0500
committermark <markm@cs.wisc.edu>2020-03-21 21:32:35 -0500
commitcdb2c3c36819870e155f4711e67e8b417356c8a4 (patch)
treeab0d8a6780b29b5a7bc71b9a4a6b553febb7d9b4
parent1661a0a99ba09ff0b2cce8ad99c4f18150165b80 (diff)
downloadrust-cdb2c3c36819870e155f4711e67e8b417356c8a4.tar.gz
rust-cdb2c3c36819870e155f4711e67e8b417356c8a4.zip
use static strs
-rw-r--r--src/librustc_lint/builtin.rs32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs
index 9a02bebb235..24529db48aa 100644
--- a/src/librustc_lint/builtin.rs
+++ b/src/librustc_lint/builtin.rs
@@ -349,7 +349,8 @@ impl MissingDoc {
         id: Option<hir::HirId>,
         attrs: &[ast::Attribute],
         sp: Span,
-        desc: &str,
+        article: &'static str,
+        desc: &'static str,
     ) {
         // If we're building a test harness, then warning about
         // documentation is probably not really relevant right now.
@@ -374,7 +375,7 @@ impl MissingDoc {
         let has_doc = attrs.iter().any(|a| has_doc(a));
         if !has_doc {
             cx.struct_span_lint(MISSING_DOCS, cx.tcx.sess.source_map().def_span(sp), |lint| {
-                lint.build(&format!("missing documentation for {}", desc)).emit()
+                lint.build(&format!("missing documentation for {} {}", article, desc)).emit()
             });
         }
     }
@@ -398,7 +399,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
     }
 
     fn check_crate(&mut self, cx: &LateContext<'_, '_>, krate: &hir::Crate<'_>) {
-        self.check_missing_docs_attrs(cx, None, &krate.item.attrs, krate.item.span, "crate");
+        self.check_missing_docs_attrs(cx, None, &krate.item.attrs, krate.item.span, "a", "crate");
 
         for macro_def in krate.exported_macros {
             let has_doc = macro_def.attrs.iter().any(|a| has_doc(a));
@@ -455,13 +456,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
         let def_id = cx.tcx.hir().local_def_id(it.hir_id);
         let (article, desc) = cx.tcx.article_and_description(def_id);
 
-        self.check_missing_docs_attrs(
-            cx,
-            Some(it.hir_id),
-            &it.attrs,
-            it.span,
-            &format!("{} {}", article, desc),
-        );
+        self.check_missing_docs_attrs(cx, Some(it.hir_id), &it.attrs, it.span, article, desc);
     }
 
     fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, trait_item: &hir::TraitItem<'_>) {
@@ -477,7 +472,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
             Some(trait_item.hir_id),
             &trait_item.attrs,
             trait_item.span,
-            &format!("{} {}", article, desc),
+            article,
+            desc,
         );
     }
 
@@ -494,18 +490,26 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
             Some(impl_item.hir_id),
             &impl_item.attrs,
             impl_item.span,
-            &format!("{} {}", article, desc),
+            article,
+            desc,
         );
     }
 
     fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, sf: &hir::StructField<'_>) {
         if !sf.is_positional() {
-            self.check_missing_docs_attrs(cx, Some(sf.hir_id), &sf.attrs, sf.span, "a struct field")
+            self.check_missing_docs_attrs(
+                cx,
+                Some(sf.hir_id),
+                &sf.attrs,
+                sf.span,
+                "a",
+                "struct field",
+            )
         }
     }
 
     fn check_variant(&mut self, cx: &LateContext<'_, '_>, v: &hir::Variant<'_>) {
-        self.check_missing_docs_attrs(cx, Some(v.id), &v.attrs, v.span, "a variant");
+        self.check_missing_docs_attrs(cx, Some(v.id), &v.attrs, v.span, "a", "variant");
     }
 }