Skip to content

Commit d6abdf5

Browse files
committed
rename pass, check for " in doc_link_with_quotes
1 parent 1daf572 commit d6abdf5

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

clippy_lints/src/doc/link_with_quotes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use rustc_lint::LateContext;
66
use super::{Fragments, DOC_LINK_WITH_QUOTES};
77

88
pub fn check(cx: &LateContext<'_>, trimmed_text: &str, range: Range<usize>, fragments: Fragments<'_>) {
9-
if trimmed_text.starts_with('\'')
10-
&& trimmed_text.ends_with('\'')
9+
if ((trimmed_text.starts_with('\'') && trimmed_text.ends_with('\''))
10+
|| (trimmed_text.starts_with('"') && trimmed_text.ends_with('"')))
1111
&& let Some(span) = fragments.span(cx, range)
1212
{
1313
span_lint(

clippy_lints/src/doc/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,14 @@ declare_clippy_lint! {
305305
"suspicious usage of (outer) doc comments"
306306
}
307307

308+
#[expect(clippy::module_name_repetitions)]
308309
#[derive(Clone)]
309-
pub struct Doc {
310+
pub struct DocMarkdown {
310311
valid_idents: FxHashSet<String>,
311312
in_trait_impl: bool,
312313
}
313314

314-
impl Doc {
315+
impl DocMarkdown {
315316
pub fn new(valid_idents: &[String]) -> Self {
316317
Self {
317318
valid_idents: valid_idents.iter().cloned().collect(),
@@ -320,7 +321,7 @@ impl Doc {
320321
}
321322
}
322323

323-
impl_lint_pass!(Doc => [
324+
impl_lint_pass!(DocMarkdown => [
324325
DOC_LINK_WITH_QUOTES,
325326
DOC_MARKDOWN,
326327
MISSING_SAFETY_DOC,
@@ -331,7 +332,7 @@ impl_lint_pass!(Doc => [
331332
SUSPICIOUS_DOC_COMMENTS
332333
]);
333334

334-
impl<'tcx> LateLintPass<'tcx> for Doc {
335+
impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
335336
fn check_crate(&mut self, cx: &LateContext<'tcx>) {
336337
let attrs = cx.tcx.hir().attrs(hir::CRATE_HIR_ID);
337338
check_attrs(cx, &self.valid_idents, attrs);

clippy_lints/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
745745
avoid_breaking_exported_api,
746746
))
747747
});
748-
store.register_late_pass(move |_| Box::new(doc::Doc::new(doc_valid_idents)));
748+
store.register_late_pass(move |_| Box::new(doc::DocMarkdown::new(doc_valid_idents)));
749749
store.register_late_pass(|_| Box::new(neg_multiply::NegMultiply));
750750
store.register_late_pass(|_| Box::new(let_if_seq::LetIfSeq));
751751
store.register_late_pass(|_| Box::new(mixed_read_write_in_expression::EvalOrderDependence));

tests/ui/doc_link_with_quotes.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ pub fn foo() {
1111
bar()
1212
}
1313

14+
/// Calls ["bar"] uselessly
15+
//~^ ERROR: possible intra-doc link using quotes instead of backticks
16+
pub fn foo2() {
17+
bar()
18+
}
19+
1420
/// # Examples
1521
/// This demonstrates issue \#8961
1622
/// ```

tests/ui/doc_link_with_quotes.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@ LL | /// Calls ['bar'] uselessly
77
= note: `-D clippy::doc-link-with-quotes` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::doc_link_with_quotes)]`
99

10-
error: aborting due to previous error
10+
error: possible intra-doc link using quotes instead of backticks
11+
--> $DIR/doc_link_with_quotes.rs:14:12
12+
|
13+
LL | /// Calls ["bar"] uselessly
14+
| ^^^^^
15+
16+
error: aborting due to 2 previous errors
1117

0 commit comments

Comments
 (0)