]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/tabs_in_doc_comments.rs
Rollup merge of #83092 - petrochenkov:qspan, r=estebank
[rust.git] / clippy_lints / src / tabs_in_doc_comments.rs
index ccea700f3538d0d381e03b9d49a85b0865b6ba0e..74ccd9235de85d847daf593d4cc3a0018db586b1 100644 (file)
@@ -1,10 +1,10 @@
 use crate::utils::span_lint_and_sugg;
-use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
-use rustc::{declare_lint_pass, declare_tool_lint};
+use rustc_ast::ast;
 use rustc_errors::Applicability;
+use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_session::{declare_lint_pass, declare_tool_lint};
+use rustc_span::source_map::{BytePos, Span};
 use std::convert::TryFrom;
-use syntax::ast;
-use syntax::source_map::{BytePos, Span};
 
 declare_clippy_lint! {
     /// **What it does:** Checks doc comments for usage of tab characters.
@@ -35,7 +35,7 @@
     /// ```
     ///
     /// Will be converted to:
-     /// ```rust
+    /// ```rust
     /// ///
     /// /// Struct to hold two strings:
     /// ///     - first        one
 
 impl TabsInDocComments {
     fn warn_if_tabs_in_doc(cx: &EarlyContext<'_>, attr: &ast::Attribute) {
-        if let ast::AttrKind::DocComment(comment) = attr.kind {
+        if let ast::AttrKind::DocComment(_, comment) = attr.kind {
             let comment = comment.as_str();
 
             for (lo, hi) in get_chunks_of_tabs(&comment) {
+                // +3 skips the opening delimiter
                 let new_span = Span::new(
-                    attr.span.lo() + BytePos(lo),
-                    attr.span.lo() + BytePos(hi),
+                    attr.span.lo() + BytePos(3 + lo),
+                    attr.span.lo() + BytePos(3 + hi),
                     attr.span.ctxt(),
                 );
                 span_lint_and_sugg(