Skip to content

Commit bd8fe82

Browse files
committed
lint: port incomplete features diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
1 parent acea23e commit bd8fe82

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
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
@@ -382,3 +382,7 @@ lint-builtin-explicit-outlives = outlives requirements can be inferred
382382
[one] this bound
383383
*[other] these bounds
384384
}
385+
386+
lint-builtin-incomplete-features = the feature `{$name}` is incomplete and may not be safe to use and/or cause compiler crashes
387+
.note = see issue #{$n} <https://github.com/rust-lang/rust/issues/{$n}> for more information
388+
.help = consider using `min_{$name}` instead, which is more stable and complete

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ impl IntoDiagnosticArg for String {
115115
}
116116
}
117117

118+
impl IntoDiagnosticArg for std::num::NonZeroU32 {
119+
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
120+
DiagnosticArgValue::Str(Cow::Owned(self.to_string()))
121+
}
122+
}
123+
118124
impl IntoDiagnosticArg for Edition {
119125
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
120126
DiagnosticArgValue::Str(Cow::Owned(self.to_string()))

compiler/rustc_lint/src/builtin.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,23 +2347,14 @@ impl EarlyLintPass for IncompleteFeatures {
23472347
.filter(|(&name, _)| features.incomplete(name))
23482348
.for_each(|(&name, &span)| {
23492349
cx.struct_span_lint(INCOMPLETE_FEATURES, span, |lint| {
2350-
let mut builder = lint.build(&format!(
2351-
"the feature `{}` is incomplete and may not be safe to use \
2352-
and/or cause compiler crashes",
2353-
name,
2354-
));
2350+
let mut builder = lint.build(fluent::lint::builtin_incomplete_features);
2351+
builder.set_arg("name", name);
23552352
if let Some(n) = rustc_feature::find_feature_issue(name, GateIssue::Language) {
2356-
builder.note(&format!(
2357-
"see issue #{} <https://github.com/rust-lang/rust/issues/{}> \
2358-
for more information",
2359-
n, n,
2360-
));
2353+
builder.set_arg("n", n);
2354+
builder.note(fluent::lint::note);
23612355
}
23622356
if HAS_MIN_FEATURES.contains(&name) {
2363-
builder.help(&format!(
2364-
"consider using `min_{}` instead, which is more stable and complete",
2365-
name,
2366-
));
2357+
builder.help(fluent::lint::help);
23672358
}
23682359
builder.emit();
23692360
})

0 commit comments

Comments
 (0)