Skip to content

Commit dbced10

Browse files
committed
lint: port unreachable pub diagnostic
Signed-off-by: David Wood <[email protected]>
1 parent 23ee3e0 commit dbced10

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,7 @@ lint-builtin-mutable-transmutes =
354354
transmuting &T to &mut T is undefined behavior, even if the reference is unused, consider instead using an UnsafeCell
355355
356356
lint-builtin-unstable-features = unstable feature
357+
358+
lint-builtin-unreachable-pub = unreachable `pub` {$what}
359+
.suggestion = consider restricting its visibility
360+
.help = or consider exporting it for use by other crates

compiler/rustc_lint/src/builtin.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,16 +1385,17 @@ impl UnreachablePub {
13851385
}
13861386
let def_span = cx.tcx.sess.source_map().guess_head_span(span);
13871387
cx.struct_span_lint(UNREACHABLE_PUB, def_span, |lint| {
1388-
let mut err = lint.build(&format!("unreachable `pub` {}", what));
1388+
let mut err = lint.build(fluent::lint::builtin_unreachable_pub);
1389+
err.set_arg("what", what);
13891390

13901391
err.span_suggestion(
13911392
vis_span,
1392-
"consider restricting its visibility",
1393+
fluent::lint::suggestion,
13931394
"pub(crate)",
13941395
applicability,
13951396
);
13961397
if exportable {
1397-
err.help("or consider exporting it for use by other crates");
1398+
err.help(fluent::lint::help);
13981399
}
13991400
err.emit();
14001401
});

0 commit comments

Comments
 (0)