Skip to content

Commit c635ffe

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

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,12 @@ declare_clippy_lint! {
306306
}
307307

308308
#[derive(Clone)]
309-
pub struct Doc {
309+
pub struct DocMarkdown {
310310
valid_idents: FxHashSet<String>,
311311
in_trait_impl: bool,
312312
}
313313

314-
impl Doc {
314+
impl DocMarkdown {
315315
pub fn new(valid_idents: &[String]) -> Self {
316316
Self {
317317
valid_idents: valid_idents.iter().cloned().collect(),
@@ -320,7 +320,7 @@ impl Doc {
320320
}
321321
}
322322

323-
impl_lint_pass!(Doc => [
323+
impl_lint_pass!(DocMarkdown => [
324324
DOC_LINK_WITH_QUOTES,
325325
DOC_MARKDOWN,
326326
MISSING_SAFETY_DOC,
@@ -331,7 +331,7 @@ impl_lint_pass!(Doc => [
331331
SUSPICIOUS_DOC_COMMENTS
332332
]);
333333

334-
impl<'tcx> LateLintPass<'tcx> for Doc {
334+
impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
335335
fn check_crate(&mut self, cx: &LateContext<'tcx>) {
336336
let attrs = cx.tcx.hir().attrs(hir::CRATE_HIR_ID);
337337
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)