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
|
[one] this bound
|
||||||
*[other] these bounds
|
*[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 {
|
impl IntoDiagnosticArg for Edition {
|
||||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||||
DiagnosticArgValue::Str(Cow::Owned(self.to_string()))
|
DiagnosticArgValue::Str(Cow::Owned(self.to_string()))
|
||||||
|
|
|
@ -2347,23 +2347,14 @@ impl EarlyLintPass for IncompleteFeatures {
|
||||||
.filter(|(&name, _)| features.incomplete(name))
|
.filter(|(&name, _)| features.incomplete(name))
|
||||||
.for_each(|(&name, &span)| {
|
.for_each(|(&name, &span)| {
|
||||||
cx.struct_span_lint(INCOMPLETE_FEATURES, span, |lint| {
|
cx.struct_span_lint(INCOMPLETE_FEATURES, span, |lint| {
|
||||||
let mut builder = lint.build(&format!(
|
let mut builder = lint.build(fluent::lint::builtin_incomplete_features);
|
||||||
"the feature `{}` is incomplete and may not be safe to use \
|
builder.set_arg("name", name);
|
||||||
and/or cause compiler crashes",
|
|
||||||
name,
|
|
||||||
));
|
|
||||||
if let Some(n) = rustc_feature::find_feature_issue(name, GateIssue::Language) {
|
if let Some(n) = rustc_feature::find_feature_issue(name, GateIssue::Language) {
|
||||||
builder.note(&format!(
|
builder.set_arg("n", n);
|
||||||
"see issue #{} <https://github.com/rust-lang/rust/issues/{}> \
|
builder.note(fluent::lint::note);
|
||||||
for more information",
|
|
||||||
n, n,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
if HAS_MIN_FEATURES.contains(&name) {
|
if HAS_MIN_FEATURES.contains(&name) {
|
||||||
builder.help(&format!(
|
builder.help(fluent::lint::help);
|
||||||
"consider using `min_{}` instead, which is more stable and complete",
|
|
||||||
name,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
builder.emit();
|
builder.emit();
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue