Rename DiagnosticBuilder as Diag.
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#![allow(rustc::untranslatable_diagnostic)]
|
||||
|
||||
use rustc_ast::util::unicode::TEXT_FLOW_CONTROL_CHARS;
|
||||
use rustc_errors::{add_elided_lifetime_in_path_suggestion, DiagnosticBuilder};
|
||||
use rustc_errors::{add_elided_lifetime_in_path_suggestion, Diag};
|
||||
use rustc_errors::{Applicability, SuggestionStyle};
|
||||
use rustc_middle::middle::stability;
|
||||
use rustc_session::config::ExpectedValues;
|
||||
@@ -12,11 +12,7 @@ use rustc_span::edit_distance::find_best_match_for_name;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::BytePos;
|
||||
|
||||
pub(super) fn builtin(
|
||||
sess: &Session,
|
||||
diagnostic: BuiltinLintDiagnostics,
|
||||
db: &mut DiagnosticBuilder<'_, ()>,
|
||||
) {
|
||||
pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag: &mut Diag<'_, ()>) {
|
||||
match diagnostic {
|
||||
BuiltinLintDiagnostics::UnicodeTextFlow(span, content) => {
|
||||
let spans: Vec<_> = content
|
||||
@@ -32,22 +28,22 @@ pub(super) fn builtin(
|
||||
1 => ("an ", ""),
|
||||
_ => ("", "s"),
|
||||
};
|
||||
db.span_label(
|
||||
diag.span_label(
|
||||
span,
|
||||
format!(
|
||||
"this comment contains {an}invisible unicode text flow control codepoint{s}",
|
||||
),
|
||||
);
|
||||
for (c, span) in &spans {
|
||||
db.span_label(*span, format!("{c:?}"));
|
||||
diag.span_label(*span, format!("{c:?}"));
|
||||
}
|
||||
db.note(
|
||||
diag.note(
|
||||
"these kind of unicode codepoints change the way text flows on \
|
||||
applications that support them, but can cause confusion because they \
|
||||
change the order of characters on the screen",
|
||||
);
|
||||
if !spans.is_empty() {
|
||||
db.multipart_suggestion_with_style(
|
||||
diag.multipart_suggestion_with_style(
|
||||
"if their presence wasn't intentional, you can remove them",
|
||||
spans.into_iter().map(|(_, span)| (span, "".to_string())).collect(),
|
||||
Applicability::MachineApplicable,
|
||||
@@ -67,16 +63,16 @@ pub(super) fn builtin(
|
||||
}
|
||||
Err(_) => ("crate::<path>".to_string(), Applicability::HasPlaceholders),
|
||||
};
|
||||
db.span_suggestion(span, "use `crate`", sugg, app);
|
||||
diag.span_suggestion(span, "use `crate`", sugg, app);
|
||||
}
|
||||
BuiltinLintDiagnostics::ProcMacroDeriveResolutionFallback(span) => {
|
||||
db.span_label(
|
||||
diag.span_label(
|
||||
span,
|
||||
"names from parent modules are not accessible without an explicit import",
|
||||
);
|
||||
}
|
||||
BuiltinLintDiagnostics::MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def) => {
|
||||
db.span_note(span_def, "the macro is defined here");
|
||||
diag.span_note(span_def, "the macro is defined here");
|
||||
}
|
||||
BuiltinLintDiagnostics::ElidedLifetimesInPaths(
|
||||
n,
|
||||
@@ -86,7 +82,7 @@ pub(super) fn builtin(
|
||||
) => {
|
||||
add_elided_lifetime_in_path_suggestion(
|
||||
sess.source_map(),
|
||||
db,
|
||||
diag,
|
||||
n,
|
||||
path_span,
|
||||
incl_angl_brckt,
|
||||
@@ -94,11 +90,11 @@ pub(super) fn builtin(
|
||||
);
|
||||
}
|
||||
BuiltinLintDiagnostics::UnknownCrateTypes(span, note, sugg) => {
|
||||
db.span_suggestion(span, note, sugg, Applicability::MaybeIncorrect);
|
||||
diag.span_suggestion(span, note, sugg, Applicability::MaybeIncorrect);
|
||||
}
|
||||
BuiltinLintDiagnostics::UnusedImports(message, replaces, in_test_module) => {
|
||||
if !replaces.is_empty() {
|
||||
db.tool_only_multipart_suggestion(
|
||||
diag.tool_only_multipart_suggestion(
|
||||
message,
|
||||
replaces,
|
||||
Applicability::MachineApplicable,
|
||||
@@ -106,7 +102,7 @@ pub(super) fn builtin(
|
||||
}
|
||||
|
||||
if let Some(span) = in_test_module {
|
||||
db.span_help(
|
||||
diag.span_help(
|
||||
sess.source_map().guess_head_span(span),
|
||||
"consider adding a `#[cfg(test)]` to the containing module",
|
||||
);
|
||||
@@ -115,19 +111,19 @@ pub(super) fn builtin(
|
||||
BuiltinLintDiagnostics::RedundantImport(spans, ident) => {
|
||||
for (span, is_imported) in spans {
|
||||
let introduced = if is_imported { "imported" } else { "defined" };
|
||||
db.span_label(span, format!("the item `{ident}` is already {introduced} here"));
|
||||
diag.span_label(span, format!("the item `{ident}` is already {introduced} here"));
|
||||
}
|
||||
}
|
||||
BuiltinLintDiagnostics::DeprecatedMacro(suggestion, span) => {
|
||||
stability::deprecation_suggestion(db, "macro", suggestion, span)
|
||||
stability::deprecation_suggestion(diag, "macro", suggestion, span)
|
||||
}
|
||||
BuiltinLintDiagnostics::UnusedDocComment(span) => {
|
||||
db.span_label(span, "rustdoc does not generate documentation for macro invocations");
|
||||
db.help("to document an item produced by a macro, \
|
||||
diag.span_label(span, "rustdoc does not generate documentation for macro invocations");
|
||||
diag.help("to document an item produced by a macro, \
|
||||
the macro must produce the documentation as part of its expansion");
|
||||
}
|
||||
BuiltinLintDiagnostics::PatternsInFnsWithoutBody(span, ident) => {
|
||||
db.span_suggestion(
|
||||
diag.span_suggestion(
|
||||
span,
|
||||
"remove `mut` from the parameter",
|
||||
ident,
|
||||
@@ -135,17 +131,17 @@ pub(super) fn builtin(
|
||||
);
|
||||
}
|
||||
BuiltinLintDiagnostics::MissingAbi(span, default_abi) => {
|
||||
db.span_label(span, "ABI should be specified here");
|
||||
db.help(format!("the default ABI is {}", default_abi.name()));
|
||||
diag.span_label(span, "ABI should be specified here");
|
||||
diag.help(format!("the default ABI is {}", default_abi.name()));
|
||||
}
|
||||
BuiltinLintDiagnostics::LegacyDeriveHelpers(span) => {
|
||||
db.span_label(span, "the attribute is introduced here");
|
||||
diag.span_label(span, "the attribute is introduced here");
|
||||
}
|
||||
BuiltinLintDiagnostics::ProcMacroBackCompat(note) => {
|
||||
db.note(note);
|
||||
diag.note(note);
|
||||
}
|
||||
BuiltinLintDiagnostics::OrPatternsBackCompat(span, suggestion) => {
|
||||
db.span_suggestion(
|
||||
diag.span_suggestion(
|
||||
span,
|
||||
"use pat_param to preserve semantics",
|
||||
suggestion,
|
||||
@@ -153,8 +149,8 @@ pub(super) fn builtin(
|
||||
);
|
||||
}
|
||||
BuiltinLintDiagnostics::ReservedPrefix(span) => {
|
||||
db.span_label(span, "unknown prefix");
|
||||
db.span_suggestion_verbose(
|
||||
diag.span_label(span, "unknown prefix");
|
||||
diag.span_suggestion_verbose(
|
||||
span.shrink_to_hi(),
|
||||
"insert whitespace here to avoid this being parsed as a prefix in Rust 2021",
|
||||
" ",
|
||||
@@ -162,19 +158,19 @@ pub(super) fn builtin(
|
||||
);
|
||||
}
|
||||
BuiltinLintDiagnostics::UnusedBuiltinAttribute { attr_name, macro_name, invoc_span } => {
|
||||
db.span_note(
|
||||
diag.span_note(
|
||||
invoc_span,
|
||||
format!("the built-in attribute `{attr_name}` will be ignored, since it's applied to the macro invocation `{macro_name}`")
|
||||
);
|
||||
}
|
||||
BuiltinLintDiagnostics::TrailingMacro(is_trailing, name) => {
|
||||
if is_trailing {
|
||||
db.note("macro invocations at the end of a block are treated as expressions");
|
||||
db.note(format!("to ignore the value produced by the macro, add a semicolon after the invocation of `{name}`"));
|
||||
diag.note("macro invocations at the end of a block are treated as expressions");
|
||||
diag.note(format!("to ignore the value produced by the macro, add a semicolon after the invocation of `{name}`"));
|
||||
}
|
||||
}
|
||||
BuiltinLintDiagnostics::BreakWithLabelAndLoop(span) => {
|
||||
db.multipart_suggestion(
|
||||
diag.multipart_suggestion(
|
||||
"wrap this expression in parentheses",
|
||||
vec![
|
||||
(span.shrink_to_lo(), "(".to_string()),
|
||||
@@ -184,8 +180,8 @@ pub(super) fn builtin(
|
||||
);
|
||||
}
|
||||
BuiltinLintDiagnostics::NamedAsmLabel(help) => {
|
||||
db.help(help);
|
||||
db.note("see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information");
|
||||
diag.help(help);
|
||||
diag.note("see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information");
|
||||
}
|
||||
BuiltinLintDiagnostics::UnexpectedCfgName((name, name_span), value) => {
|
||||
#[allow(rustc::potential_query_instability)]
|
||||
@@ -212,7 +208,7 @@ pub(super) fn builtin(
|
||||
let mut is_feature_cfg = name == sym::feature;
|
||||
|
||||
if is_feature_cfg && is_from_cargo {
|
||||
db.help("consider defining some features in `Cargo.toml`");
|
||||
diag.help("consider defining some features in `Cargo.toml`");
|
||||
// Suggest the most probable if we found one
|
||||
} else if let Some(best_match) = find_best_match_for_name(&possibilities, name, None) {
|
||||
if let Some(ExpectedValues::Some(best_match_values)) =
|
||||
@@ -227,7 +223,7 @@ pub(super) fn builtin(
|
||||
let mut should_print_possibilities = true;
|
||||
if let Some((value, value_span)) = value {
|
||||
if best_match_values.contains(&Some(value)) {
|
||||
db.span_suggestion(
|
||||
diag.span_suggestion(
|
||||
name_span,
|
||||
"there is a config with a similar name and value",
|
||||
best_match,
|
||||
@@ -235,7 +231,7 @@ pub(super) fn builtin(
|
||||
);
|
||||
should_print_possibilities = false;
|
||||
} else if best_match_values.contains(&None) {
|
||||
db.span_suggestion(
|
||||
diag.span_suggestion(
|
||||
name_span.to(value_span),
|
||||
"there is a config with a similar name and no value",
|
||||
best_match,
|
||||
@@ -243,14 +239,14 @@ pub(super) fn builtin(
|
||||
);
|
||||
should_print_possibilities = false;
|
||||
} else if let Some(first_value) = possibilities.first() {
|
||||
db.span_suggestion(
|
||||
diag.span_suggestion(
|
||||
name_span.to(value_span),
|
||||
"there is a config with a similar name and different values",
|
||||
format!("{best_match} = \"{first_value}\""),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
} else {
|
||||
db.span_suggestion(
|
||||
diag.span_suggestion(
|
||||
name_span.to(value_span),
|
||||
"there is a config with a similar name and different values",
|
||||
best_match,
|
||||
@@ -258,7 +254,7 @@ pub(super) fn builtin(
|
||||
);
|
||||
};
|
||||
} else {
|
||||
db.span_suggestion(
|
||||
diag.span_suggestion(
|
||||
name_span,
|
||||
"there is a config with a similar name",
|
||||
best_match,
|
||||
@@ -268,12 +264,12 @@ pub(super) fn builtin(
|
||||
|
||||
if !possibilities.is_empty() && should_print_possibilities {
|
||||
let possibilities = possibilities.join("`, `");
|
||||
db.help(format!(
|
||||
diag.help(format!(
|
||||
"expected values for `{best_match}` are: `{possibilities}`"
|
||||
));
|
||||
}
|
||||
} else {
|
||||
db.span_suggestion(
|
||||
diag.span_suggestion(
|
||||
name_span,
|
||||
"there is a config with a similar name",
|
||||
best_match,
|
||||
@@ -286,7 +282,7 @@ pub(super) fn builtin(
|
||||
if !names_possibilities.is_empty() && names_possibilities.len() <= 3 {
|
||||
names_possibilities.sort();
|
||||
for cfg_name in names_possibilities.iter() {
|
||||
db.span_suggestion(
|
||||
diag.span_suggestion(
|
||||
name_span,
|
||||
"found config with similar value",
|
||||
format!("{cfg_name} = \"{name}\""),
|
||||
@@ -304,7 +300,7 @@ pub(super) fn builtin(
|
||||
// so the diagnostic produced can take a lot of space. To avoid
|
||||
// cloging the user output we only want to print that diagnostic
|
||||
// once.
|
||||
db.help_once(format!("expected names are: `{possibilities}`"));
|
||||
diag.help_once(format!("expected names are: `{possibilities}`"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,12 +313,12 @@ pub(super) fn builtin(
|
||||
|
||||
if is_from_cargo {
|
||||
if !is_feature_cfg {
|
||||
db.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo:rustc-check-cfg={inst}\");` to the top of a `build.rs`"));
|
||||
diag.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo:rustc-check-cfg={inst}\");` to the top of a `build.rs`"));
|
||||
}
|
||||
db.note("see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration");
|
||||
diag.note("see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration");
|
||||
} else {
|
||||
db.help(format!("to expect this configuration use `--check-cfg={inst}`"));
|
||||
db.note("see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration");
|
||||
diag.help(format!("to expect this configuration use `--check-cfg={inst}`"));
|
||||
diag.note("see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration");
|
||||
}
|
||||
}
|
||||
BuiltinLintDiagnostics::UnexpectedCfgValue((name, name_span), value) => {
|
||||
@@ -356,14 +352,14 @@ pub(super) fn builtin(
|
||||
let possibilities = possibilities.join("`, `");
|
||||
let none = if have_none_possibility { "(none), " } else { "" };
|
||||
|
||||
db.note(format!("expected values for `{name}` are: {none}`{possibilities}`"));
|
||||
diag.note(format!("expected values for `{name}` are: {none}`{possibilities}`"));
|
||||
}
|
||||
|
||||
if let Some((value, value_span)) = value {
|
||||
// Suggest the most probable if we found one
|
||||
if let Some(best_match) = find_best_match_for_name(&possibilities, value, None)
|
||||
{
|
||||
db.span_suggestion(
|
||||
diag.span_suggestion(
|
||||
value_span,
|
||||
"there is a expected value with a similar name",
|
||||
format!("\"{best_match}\""),
|
||||
@@ -371,7 +367,7 @@ pub(super) fn builtin(
|
||||
);
|
||||
}
|
||||
} else if let &[first_possibility] = &possibilities[..] {
|
||||
db.span_suggestion(
|
||||
diag.span_suggestion(
|
||||
name_span.shrink_to_hi(),
|
||||
"specify a config value",
|
||||
format!(" = \"{first_possibility}\""),
|
||||
@@ -379,9 +375,9 @@ pub(super) fn builtin(
|
||||
);
|
||||
}
|
||||
} else if have_none_possibility {
|
||||
db.note(format!("no expected value for `{name}`"));
|
||||
diag.note(format!("no expected value for `{name}`"));
|
||||
if let Some((_value, value_span)) = value {
|
||||
db.span_suggestion(
|
||||
diag.span_suggestion(
|
||||
name_span.shrink_to_hi().to(value_span),
|
||||
"remove the value",
|
||||
"",
|
||||
@@ -389,14 +385,14 @@ pub(super) fn builtin(
|
||||
);
|
||||
}
|
||||
} else {
|
||||
db.note(format!("no expected values for `{name}`"));
|
||||
diag.note(format!("no expected values for `{name}`"));
|
||||
|
||||
let sp = if let Some((_value, value_span)) = value {
|
||||
name_span.to(value_span)
|
||||
} else {
|
||||
name_span
|
||||
};
|
||||
db.span_suggestion(sp, "remove the condition", "", Applicability::MaybeIncorrect);
|
||||
diag.span_suggestion(sp, "remove the condition", "", Applicability::MaybeIncorrect);
|
||||
}
|
||||
|
||||
// We don't want to suggest adding values to well known names
|
||||
@@ -415,28 +411,30 @@ pub(super) fn builtin(
|
||||
if is_from_cargo {
|
||||
if name == sym::feature {
|
||||
if let Some((value, _value_span)) = value {
|
||||
db.help(format!("consider adding `{value}` as a feature in `Cargo.toml`"));
|
||||
diag.help(format!(
|
||||
"consider adding `{value}` as a feature in `Cargo.toml`"
|
||||
));
|
||||
} else {
|
||||
db.help("consider defining some features in `Cargo.toml`");
|
||||
diag.help("consider defining some features in `Cargo.toml`");
|
||||
}
|
||||
} else if !is_cfg_a_well_know_name {
|
||||
db.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo:rustc-check-cfg={inst}\");` to the top of a `build.rs`"));
|
||||
diag.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo:rustc-check-cfg={inst}\");` to the top of a `build.rs`"));
|
||||
}
|
||||
db.note("see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration");
|
||||
diag.note("see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration");
|
||||
} else {
|
||||
if !is_cfg_a_well_know_name {
|
||||
db.help(format!("to expect this configuration use `--check-cfg={inst}`"));
|
||||
diag.help(format!("to expect this configuration use `--check-cfg={inst}`"));
|
||||
}
|
||||
db.note("see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration");
|
||||
diag.note("see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration");
|
||||
}
|
||||
}
|
||||
BuiltinLintDiagnostics::DeprecatedWhereclauseLocation(new_span, suggestion) => {
|
||||
db.multipart_suggestion(
|
||||
diag.multipart_suggestion(
|
||||
"move it to the end of the type declaration",
|
||||
vec![(db.span.primary_span().unwrap(), "".to_string()), (new_span, suggestion)],
|
||||
vec![(diag.span.primary_span().unwrap(), "".to_string()), (new_span, suggestion)],
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
db.note(
|
||||
diag.note(
|
||||
"see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information",
|
||||
);
|
||||
}
|
||||
@@ -446,8 +444,8 @@ pub(super) fn builtin(
|
||||
deletion_span,
|
||||
} => {
|
||||
debug!(?param_span, ?use_span, ?deletion_span);
|
||||
db.span_label(param_span, "this lifetime...");
|
||||
db.span_label(use_span, "...is used only here");
|
||||
diag.span_label(param_span, "this lifetime...");
|
||||
diag.span_label(use_span, "...is used only here");
|
||||
if let Some(deletion_span) = deletion_span {
|
||||
let msg = "elide the single-use lifetime";
|
||||
let (use_span, replace_lt) = if elide {
|
||||
@@ -468,7 +466,7 @@ pub(super) fn builtin(
|
||||
} else {
|
||||
vec![(deletion_span, String::new()), (use_span, replace_lt)]
|
||||
};
|
||||
db.multipart_suggestion(msg, suggestions, Applicability::MachineApplicable);
|
||||
diag.multipart_suggestion(msg, suggestions, Applicability::MachineApplicable);
|
||||
}
|
||||
}
|
||||
BuiltinLintDiagnostics::SingleUseLifetime {
|
||||
@@ -478,7 +476,7 @@ pub(super) fn builtin(
|
||||
} => {
|
||||
debug!(?deletion_span);
|
||||
if let Some(deletion_span) = deletion_span {
|
||||
db.span_suggestion(
|
||||
diag.span_suggestion(
|
||||
deletion_span,
|
||||
"elide the unused lifetime",
|
||||
"",
|
||||
@@ -493,7 +491,7 @@ pub(super) fn builtin(
|
||||
named_arg_name,
|
||||
is_formatting_arg,
|
||||
} => {
|
||||
db.span_label(
|
||||
diag.span_label(
|
||||
named_arg_sp,
|
||||
"this named argument is referred to by position in formatting string",
|
||||
);
|
||||
@@ -501,7 +499,7 @@ pub(super) fn builtin(
|
||||
let msg = format!(
|
||||
"this formatting argument uses named argument `{named_arg_name}` by position"
|
||||
);
|
||||
db.span_label(positional_arg_for_msg, msg);
|
||||
diag.span_label(positional_arg_for_msg, msg);
|
||||
}
|
||||
|
||||
if let Some(positional_arg_to_replace) = position_sp_to_replace {
|
||||
@@ -514,7 +512,7 @@ pub(super) fn builtin(
|
||||
} else {
|
||||
positional_arg_to_replace
|
||||
};
|
||||
db.span_suggestion_verbose(
|
||||
diag.span_suggestion_verbose(
|
||||
span_to_replace,
|
||||
"use the named argument by name to avoid ambiguity",
|
||||
name,
|
||||
@@ -523,22 +521,22 @@ pub(super) fn builtin(
|
||||
}
|
||||
}
|
||||
BuiltinLintDiagnostics::ByteSliceInPackedStructWithDerive => {
|
||||
db.help("consider implementing the trait by hand, or remove the `packed` attribute");
|
||||
diag.help("consider implementing the trait by hand, or remove the `packed` attribute");
|
||||
}
|
||||
BuiltinLintDiagnostics::UnusedExternCrate { removal_span } => {
|
||||
db.span_suggestion(removal_span, "remove it", "", Applicability::MachineApplicable);
|
||||
diag.span_suggestion(removal_span, "remove it", "", Applicability::MachineApplicable);
|
||||
}
|
||||
BuiltinLintDiagnostics::ExternCrateNotIdiomatic { vis_span, ident_span } => {
|
||||
let suggestion_span = vis_span.between(ident_span);
|
||||
db.span_suggestion_verbose(
|
||||
diag.span_suggestion_verbose(
|
||||
suggestion_span,
|
||||
"convert it to a `use`",
|
||||
if vis_span.is_empty() { "use " } else { " use " },
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
BuiltinLintDiagnostics::AmbiguousGlobImports { diag } => {
|
||||
rustc_errors::report_ambiguity_error(db, diag);
|
||||
BuiltinLintDiagnostics::AmbiguousGlobImports { diag: ambiguity } => {
|
||||
rustc_errors::report_ambiguity_error(diag, ambiguity);
|
||||
}
|
||||
BuiltinLintDiagnostics::AmbiguousGlobReexports {
|
||||
name,
|
||||
@@ -546,11 +544,11 @@ pub(super) fn builtin(
|
||||
first_reexport_span,
|
||||
duplicate_reexport_span,
|
||||
} => {
|
||||
db.span_label(
|
||||
diag.span_label(
|
||||
first_reexport_span,
|
||||
format!("the name `{name}` in the {namespace} namespace is first re-exported here"),
|
||||
);
|
||||
db.span_label(
|
||||
diag.span_label(
|
||||
duplicate_reexport_span,
|
||||
format!(
|
||||
"but the name `{name}` in the {namespace} namespace is also re-exported here"
|
||||
@@ -563,11 +561,11 @@ pub(super) fn builtin(
|
||||
glob_reexport_span,
|
||||
private_item_span,
|
||||
} => {
|
||||
db.span_note(glob_reexport_span, format!("the name `{name}` in the {namespace} namespace is supposed to be publicly re-exported here"));
|
||||
db.span_note(private_item_span, "but the private item here shadows it".to_owned());
|
||||
diag.span_note(glob_reexport_span, format!("the name `{name}` in the {namespace} namespace is supposed to be publicly re-exported here"));
|
||||
diag.span_note(private_item_span, "but the private item here shadows it".to_owned());
|
||||
}
|
||||
BuiltinLintDiagnostics::UnusedQualifications { removal_span } => {
|
||||
db.span_suggestion_verbose(
|
||||
diag.span_suggestion_verbose(
|
||||
removal_span,
|
||||
"remove the unnecessary path segments",
|
||||
"",
|
||||
@@ -575,7 +573,7 @@ pub(super) fn builtin(
|
||||
);
|
||||
}
|
||||
BuiltinLintDiagnostics::AssociatedConstElidedLifetime { elided, span } => {
|
||||
db.span_suggestion_verbose(
|
||||
diag.span_suggestion_verbose(
|
||||
if elided { span.shrink_to_hi() } else { span },
|
||||
"use the `'static` lifetime",
|
||||
if elided { "'static " } else { "'static" },
|
||||
@@ -583,8 +581,10 @@ pub(super) fn builtin(
|
||||
);
|
||||
}
|
||||
BuiltinLintDiagnostics::RedundantImportVisibility { max_vis, span } => {
|
||||
db.span_note(span, format!("the most public imported item is `{max_vis}`"));
|
||||
db.help("reduce the glob import's visibility or increase visibility of imported items");
|
||||
diag.span_note(span, format!("the most public imported item is `{max_vis}`"));
|
||||
diag.help(
|
||||
"reduce the glob import's visibility or increase visibility of imported items",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user