diff options
| author | David Wood <david.wood@huawei.com> | 2022-06-28 14:40:11 +0100 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2022-06-30 08:59:22 +0100 |
| commit | bd8fe82138ba24f1c9f27bb64bf4269aabf9d54a (patch) | |
| tree | 772ce54092e2d8a7257c59f5b23a9cc567e4538a | |
| parent | acea23e79617fd269dfa2ef3caca9225e87e9452 (diff) | |
| download | rust-bd8fe82138ba24f1c9f27bb64bf4269aabf9d54a.tar.gz rust-bd8fe82138ba24f1c9f27bb64bf4269aabf9d54a.zip | |
lint: port incomplete features diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
| -rw-r--r-- | compiler/rustc_error_messages/locales/en-US/lint.ftl | 4 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/builtin.rs | 19 |
3 files changed, 15 insertions, 14 deletions
diff --git a/compiler/rustc_error_messages/locales/en-US/lint.ftl b/compiler/rustc_error_messages/locales/en-US/lint.ftl index d21e3de1c4f..a1ad0320999 100644 --- a/compiler/rustc_error_messages/locales/en-US/lint.ftl +++ b/compiler/rustc_error_messages/locales/en-US/lint.ftl @@ -382,3 +382,7 @@ lint-builtin-explicit-outlives = outlives requirements can be inferred [one] this bound *[other] these bounds } + +lint-builtin-incomplete-features = the feature `{$name}` is incomplete and may not be safe to use and/or cause compiler crashes + .note = see issue #{$n} <https://github.com/rust-lang/rust/issues/{$n}> for more information + .help = consider using `min_{$name}` instead, which is more stable and complete diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index fc619ad54cf..3043ae827f9 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -115,6 +115,12 @@ impl IntoDiagnosticArg for String { } } +impl IntoDiagnosticArg for std::num::NonZeroU32 { + fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { + DiagnosticArgValue::Str(Cow::Owned(self.to_string())) + } +} + impl IntoDiagnosticArg for Edition { fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { DiagnosticArgValue::Str(Cow::Owned(self.to_string())) diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 1205b1c5e46..035cd358a91 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -2347,23 +2347,14 @@ impl EarlyLintPass for IncompleteFeatures { .filter(|(&name, _)| features.incomplete(name)) .for_each(|(&name, &span)| { cx.struct_span_lint(INCOMPLETE_FEATURES, span, |lint| { - let mut builder = lint.build(&format!( - "the feature `{}` is incomplete and may not be safe to use \ - and/or cause compiler crashes", - name, - )); + let mut builder = lint.build(fluent::lint::builtin_incomplete_features); + builder.set_arg("name", name); if let Some(n) = rustc_feature::find_feature_issue(name, GateIssue::Language) { - builder.note(&format!( - "see issue #{} <https://github.com/rust-lang/rust/issues/{}> \ - for more information", - n, n, - )); + builder.set_arg("n", n); + builder.note(fluent::lint::note); } if HAS_MIN_FEATURES.contains(&name) { - builder.help(&format!( - "consider using `min_{}` instead, which is more stable and complete", - name, - )); + builder.help(fluent::lint::help); } builder.emit(); }) |
