mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 05:26:47 +00:00
rustdoc(rustdoc::bare_urls): apply code review suggestions
This commit is contained in:
parent
c6d769601f
commit
fe5bccbb24
@ -504,9 +504,12 @@ pub fn span_of_fragments(fragments: &[DocFragment]) -> Option<Span> {
|
||||
/// This method will return `Some` only if one of the following is true:
|
||||
///
|
||||
/// - The doc is made entirely from sugared doc comments, which cannot contain escapes
|
||||
/// - The doc is entirely from a single doc fragment, with a string literal, exactly equal
|
||||
/// - The doc is entirely from a single doc fragment with a string literal exactly equal to `markdown`.
|
||||
/// - The doc comes from `include_str!`
|
||||
/// - The doc includes exactly one substring matching `markdown[md_range]` which is contained in a single doc fragment.
|
||||
///
|
||||
/// This function is defined in the compiler so it can be used by
|
||||
/// both `rustdoc` and `clippy`.
|
||||
pub fn source_span_for_markdown_range(
|
||||
tcx: TyCtxt<'_>,
|
||||
markdown: &str,
|
||||
|
@ -23,7 +23,7 @@ pub(super) fn visit_item(cx: &DocContext<'_>, item: &Item, hir_id: HirId, dox: &
|
||||
cx.tcx.node_span_lint(crate::lint::BARE_URLS, hir_id, sp, |lint| {
|
||||
lint.primary_message(msg)
|
||||
.note("bare URLs are not automatically turned into clickable links");
|
||||
// the fallback of using the item span is suitible for
|
||||
// the fallback of using the attribute span is suitable for
|
||||
// highlighting where the error is, but not for placing the < and >
|
||||
if let Some(sp) = maybe_sp {
|
||||
lint.multipart_suggestion(
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// examples of bare urls that are beyond our ability to generate suggestions for
|
||||
|
||||
// this falls through every heirustic in `source_span_for_markdown_range`,
|
||||
// this falls through every heuristic in `source_span_for_markdown_range`,
|
||||
// and thus does not get any suggestion.
|
||||
#[doc = "good: <https://example.com/> \n\n"]
|
||||
//~^ ERROR this URL is not a hyperlink
|
||||
|
Loading…
Reference in New Issue
Block a user