diff options
| author | David Wood <david.wood@huawei.com> | 2022-06-28 13:40:59 +0100 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2022-06-30 08:59:22 +0100 |
| commit | dbdbdb68740dd3be9cea059dd5cb6067c45f38d7 (patch) | |
| tree | 8da1066b5203950ef9358ed04e3e2e1c4a306148 | |
| parent | a13b70ea83f1f3781cba2dbdc990520bdbb6a740 (diff) | |
| download | rust-dbdbdb68740dd3be9cea059dd5cb6067c45f38d7.tar.gz rust-dbdbdb68740dd3be9cea059dd5cb6067c45f38d7.zip | |
lint: port no-mangle diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
| -rw-r--r-- | compiler/rustc_error_messages/locales/en-US/lint.ftl | 6 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/builtin.rs | 9 |
2 files changed, 10 insertions, 5 deletions
diff --git a/compiler/rustc_error_messages/locales/en-US/lint.ftl b/compiler/rustc_error_messages/locales/en-US/lint.ftl index 3de652e3093..cbe7e15a723 100644 --- a/compiler/rustc_error_messages/locales/en-US/lint.ftl +++ b/compiler/rustc_error_messages/locales/en-US/lint.ftl @@ -343,3 +343,9 @@ lint-builtin-unused-doc-comment = unused doc comment .label = rustdoc does not generate documentation for {$kind} .plain-help = use `//` for a plain comment .block-help = use `/* */` for a plain comment + +lint-builtin-no-mangle-generic = functions generic over types or consts must be mangled + .suggestion = remove this attribute + +lint-builtin-const-no-mangle = const items should never be `#[no_mangle]` + .suggestion = try a static value diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index a31936f376a..6dfcc0eec49 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -1166,10 +1166,10 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems { GenericParamKind::Lifetime { .. } => {} GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => { cx.struct_span_lint(NO_MANGLE_GENERIC_ITEMS, span, |lint| { - lint.build("functions generic over types or consts must be mangled") + lint.build(fluent::lint::builtin_no_mangle_generic) .span_suggestion_short( no_mangle_attr.span, - "remove this attribute", + fluent::lint::suggestion, "", // Use of `#[no_mangle]` suggests FFI intent; correct // fix may be to monomorphize source by hand @@ -1193,8 +1193,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems { // Const items do not refer to a particular location in memory, and therefore // don't have anything to attach a symbol to cx.struct_span_lint(NO_MANGLE_CONST_ITEMS, it.span, |lint| { - let msg = "const items should never be `#[no_mangle]`"; - let mut err = lint.build(msg); + let mut err = lint.build(fluent::lint::builtin_const_no_mangle); // account for "pub const" (#45562) let start = cx @@ -1208,7 +1207,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems { let const_span = it.span.with_hi(BytePos(it.span.lo().0 + start + 5)); err.span_suggestion( const_span, - "try a static value", + fluent::lint::suggestion, "pub static", Applicability::MachineApplicable, ); |
