Auto merge of #12836 - hamirmahal:feat/quick-fix-for-bare-urls, r=y21
feat: `Quick Fix` for `bare URLs` closes #12835. *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: [`clippy::doc_markdown`]: `Quick Fix` for `bare URLs`
This commit is contained in:
commit
674c641ecf
@ -1,4 +1,4 @@
|
||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_then};
|
||||
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
|
||||
use clippy_utils::source::snippet_with_applicability;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::{Applicability, SuggestionStyle};
|
||||
@ -92,13 +92,15 @@ fn has_hyphen(s: &str) -> bool {
|
||||
if let Ok(url) = Url::parse(word) {
|
||||
// try to get around the fact that `foo::bar` parses as a valid URL
|
||||
if !url.cannot_be_a_base() {
|
||||
span_lint(
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
DOC_MARKDOWN,
|
||||
span,
|
||||
"you should put bare URLs between `<`/`>` or make a proper Markdown link",
|
||||
"try",
|
||||
format!("<{word}>"),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -240,3 +240,6 @@ extern {
|
||||
/// `foo()`
|
||||
fn in_extern();
|
||||
}
|
||||
|
||||
/// <https://github.com/rust-lang/rust-clippy/pull/12836>
|
||||
fn check_autofix_for_base_urls() {}
|
||||
|
@ -240,3 +240,6 @@ fn plural_acronym_test() {}
|
||||
/// foo()
|
||||
fn in_extern();
|
||||
}
|
||||
|
||||
/// https://github.com/rust-lang/rust-clippy/pull/12836
|
||||
fn check_autofix_for_base_urls() {}
|
||||
|
@ -363,5 +363,11 @@ help: try
|
||||
LL | /// `foo()`
|
||||
| ~~~~~~~
|
||||
|
||||
error: aborting due to 33 previous errors
|
||||
error: you should put bare URLs between `<`/`>` or make a proper Markdown link
|
||||
--> tests/ui/doc/doc-fixable.rs:244:5
|
||||
|
|
||||
LL | /// https://github.com/rust-lang/rust-clippy/pull/12836
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `<https://github.com/rust-lang/rust-clippy/pull/12836>`
|
||||
|
||||
error: aborting due to 34 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user