lint: port unreachable pub
diagnostic
Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
23ee3e0914
commit
dbced105db
2 changed files with 8 additions and 3 deletions
|
@ -354,3 +354,7 @@ lint-builtin-mutable-transmutes =
|
||||||
transmuting &T to &mut T is undefined behavior, even if the reference is unused, consider instead using an UnsafeCell
|
transmuting &T to &mut T is undefined behavior, even if the reference is unused, consider instead using an UnsafeCell
|
||||||
|
|
||||||
lint-builtin-unstable-features = unstable feature
|
lint-builtin-unstable-features = unstable feature
|
||||||
|
|
||||||
|
lint-builtin-unreachable-pub = unreachable `pub` {$what}
|
||||||
|
.suggestion = consider restricting its visibility
|
||||||
|
.help = or consider exporting it for use by other crates
|
||||||
|
|
|
@ -1385,16 +1385,17 @@ impl UnreachablePub {
|
||||||
}
|
}
|
||||||
let def_span = cx.tcx.sess.source_map().guess_head_span(span);
|
let def_span = cx.tcx.sess.source_map().guess_head_span(span);
|
||||||
cx.struct_span_lint(UNREACHABLE_PUB, def_span, |lint| {
|
cx.struct_span_lint(UNREACHABLE_PUB, def_span, |lint| {
|
||||||
let mut err = lint.build(&format!("unreachable `pub` {}", what));
|
let mut err = lint.build(fluent::lint::builtin_unreachable_pub);
|
||||||
|
err.set_arg("what", what);
|
||||||
|
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
vis_span,
|
vis_span,
|
||||||
"consider restricting its visibility",
|
fluent::lint::suggestion,
|
||||||
"pub(crate)",
|
"pub(crate)",
|
||||||
applicability,
|
applicability,
|
||||||
);
|
);
|
||||||
if exportable {
|
if exportable {
|
||||||
err.help("or consider exporting it for use by other crates");
|
err.help(fluent::lint::help);
|
||||||
}
|
}
|
||||||
err.emit();
|
err.emit();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue