lint: port incomplete features diagnostics
Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
acea23e796
commit
bd8fe82138
3 changed files with 15 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -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();
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue