Skip to content

Commit a13b70e

Browse files
committed
lint: port unused doc comment diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
1 parent e151d66 commit a13b70e

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

compiler/rustc_error_messages/locales/en-US/lint.ftl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,8 @@ lint-builtin-anonymous-params = anonymous parameters are deprecated and will be
338338
lint-builtin-deprecated-attr-link = use of deprecated attribute `{$name}`: {$reason}. See {$link}
339339
lint-builtin-deprecated-attr-used = use of deprecated attribute `{$name}`: no longer used.
340340
lint-builtin-deprecated-attr-default-suggestion = remove this attribute
341+
342+
lint-builtin-unused-doc-comment = unused doc comment
343+
.label = rustdoc does not generate documentation for {$kind}
344+
.plain-help = use `//` for a plain comment
345+
.block-help = use `/* */` for a plain comment

compiler/rustc_lint/src/builtin.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,17 +1039,15 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &
10391039

10401040
if is_doc_comment || attr.has_name(sym::doc) {
10411041
cx.struct_span_lint(UNUSED_DOC_COMMENTS, span, |lint| {
1042-
let mut err = lint.build("unused doc comment");
1043-
err.span_label(
1044-
node_span,
1045-
format!("rustdoc does not generate documentation for {}", node_kind),
1046-
);
1042+
let mut err = lint.build(fluent::lint::builtin_unused_doc_comment);
1043+
err.set_arg("kind", node_kind);
1044+
err.span_label(node_span, fluent::lint::label);
10471045
match attr.kind {
10481046
AttrKind::DocComment(CommentKind::Line, _) | AttrKind::Normal(..) => {
1049-
err.help("use `//` for a plain comment");
1047+
err.help(fluent::lint::plain_help);
10501048
}
10511049
AttrKind::DocComment(CommentKind::Block, _) => {
1052-
err.help("use `/* */` for a plain comment");
1050+
err.help(fluent::lint::block_help);
10531051
}
10541052
}
10551053
err.emit();

0 commit comments

Comments
 (0)