Skip to content

Commit dbdbdb6

Browse files
committed
lint: port no-mangle diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
1 parent a13b70e commit dbdbdb6

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,9 @@ lint-builtin-unused-doc-comment = unused doc comment
343343
.label = rustdoc does not generate documentation for {$kind}
344344
.plain-help = use `//` for a plain comment
345345
.block-help = use `/* */` for a plain comment
346+
347+
lint-builtin-no-mangle-generic = functions generic over types or consts must be mangled
348+
.suggestion = remove this attribute
349+
350+
lint-builtin-const-no-mangle = const items should never be `#[no_mangle]`
351+
.suggestion = try a static value

compiler/rustc_lint/src/builtin.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,10 +1166,10 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {
11661166
GenericParamKind::Lifetime { .. } => {}
11671167
GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => {
11681168
cx.struct_span_lint(NO_MANGLE_GENERIC_ITEMS, span, |lint| {
1169-
lint.build("functions generic over types or consts must be mangled")
1169+
lint.build(fluent::lint::builtin_no_mangle_generic)
11701170
.span_suggestion_short(
11711171
no_mangle_attr.span,
1172-
"remove this attribute",
1172+
fluent::lint::suggestion,
11731173
"",
11741174
// Use of `#[no_mangle]` suggests FFI intent; correct
11751175
// fix may be to monomorphize source by hand
@@ -1193,8 +1193,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {
11931193
// Const items do not refer to a particular location in memory, and therefore
11941194
// don't have anything to attach a symbol to
11951195
cx.struct_span_lint(NO_MANGLE_CONST_ITEMS, it.span, |lint| {
1196-
let msg = "const items should never be `#[no_mangle]`";
1197-
let mut err = lint.build(msg);
1196+
let mut err = lint.build(fluent::lint::builtin_const_no_mangle);
11981197

11991198
// account for "pub const" (#45562)
12001199
let start = cx
@@ -1208,7 +1207,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {
12081207
let const_span = it.span.with_hi(BytePos(it.span.lo().0 + start + 5));
12091208
err.span_suggestion(
12101209
const_span,
1211-
"try a static value",
1210+
fluent::lint::suggestion,
12121211
"pub static",
12131212
Applicability::MachineApplicable,
12141213
);

0 commit comments

Comments
 (0)