diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index b833fb55157d..a56334dc150f 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -3275,7 +3275,7 @@ fn lint_filetype_is_file(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, args: & then { let lint_msg = "`!FileType::is_file()` does not deny all readable file types"; let help_msg = "use `FileType::is_dir()` instead"; - span_help_and_lint(cx, FILETYPE_IS_FILE, expr.span, lint_msg, help_msg); + span_help_and_lint(cx, FILETYPE_IS_FILE, parent.span, lint_msg, help_msg); } else { let lint_msg = "`FileType::is_file()` does not cover all readable file types"; let help_msg = "use `!FileType::is_dir()` instead"; diff --git a/tests/ui/filetype_is_file.stderr b/tests/ui/filetype_is_file.stderr index 298cb5ad0657..08bebbd796ed 100644 --- a/tests/ui/filetype_is_file.stderr +++ b/tests/ui/filetype_is_file.stderr @@ -8,10 +8,10 @@ LL | if fs::metadata("foo.txt")?.file_type().is_file() { = help: use `!FileType::is_dir()` instead error: `!FileType::is_file()` does not deny all readable file types - --> $DIR/filetype_is_file.rs:13:9 + --> $DIR/filetype_is_file.rs:13:8 | LL | if !fs::metadata("foo.txt")?.file_type().is_file() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: use `FileType::is_dir()` instead