Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
self
} }

with_fn! { with_span_suggestion_with_style,
/// [`Diag::span_suggestion()`] but you can set the [`SuggestionStyle`].
pub fn span_suggestion_with_style(
&mut self,
Expand All @@ -956,7 +957,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
applicability,
});
self
}
} }

with_fn! { with_span_suggestion_verbose,
/// Always show the suggested change.
Expand Down
44 changes: 20 additions & 24 deletions src/librustdoc/passes/lint/redundant_explicit_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ fn check_inline_or_reference_unknown_redundancy(
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
let Self { explicit_span, display_span, link_span, display_link } = self;

let mut diag = Diag::new(dcx, level, "redundant explicit link target")
Diag::new(dcx, level, "redundant explicit link target")
.with_span_label(
explicit_span,
"explicit target is redundant",
Expand All @@ -176,17 +176,15 @@ fn check_inline_or_reference_unknown_redundancy(
)
.with_note(
"when a link's destination is not specified,\nthe label is used to resolve intra-doc links"
);
// FIXME (GuillaumeGomez): We cannot use `derive(Diagnostic)` because of this method.
// FIXME2 (GuillaumeGomez): Why isn't there a `with_` equivalent for this method?
diag.span_suggestion_with_style(
link_span,
"remove explicit link target",
format!("[{}]", display_link),
Applicability::MaybeIncorrect,
SuggestionStyle::ShowAlways,
);
diag
)
// FIXME (GuillaumeGomez): We cannot use `derive(Diagnostic)` because of this method.
.with_span_suggestion_with_style(
link_span,
"remove explicit link target",
format!("[{}]", display_link),
Applicability::MaybeIncorrect,
SuggestionStyle::ShowAlways,
)
}
}

Expand Down Expand Up @@ -267,7 +265,7 @@ fn check_reference_redundancy(
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
let Self { explicit_span, display_span, def_span, link_span, display_link } = self;

let mut diag = Diag::new(dcx, level, "redundant explicit link target")
Diag::new(dcx, level, "redundant explicit link target")
.with_span_label(explicit_span, "explicit target is redundant")
.with_span_label(
display_span,
Expand All @@ -276,17 +274,15 @@ fn check_reference_redundancy(
.with_span_note(def_span, "referenced explicit link target defined here")
.with_note(
"when a link's destination is not specified,\nthe label is used to resolve intra-doc links"
);
// FIXME (GuillaumeGomez): We cannot use `derive(Diagnostic)` because of this method.
// FIXME2 (GuillaumeGomez): Why isn't there a `with_` equivalent for this method?
diag.span_suggestion_with_style(
link_span,
"remove explicit link target",
format!("[{}]", display_link),
Applicability::MaybeIncorrect,
SuggestionStyle::ShowAlways,
);
diag
)
// FIXME (GuillaumeGomez): We cannot use `derive(Diagnostic)` because of this method.
.with_span_suggestion_with_style(
link_span,
"remove explicit link target",
format!("[{}]", display_link),
Applicability::MaybeIncorrect,
SuggestionStyle::ShowAlways,
)
}
}

Expand Down
Loading