From f62ebb07b761e043d2a9d840a57c4a0ab92f1e8e Mon Sep 17 00:00:00 2001 From: lengyijun Date: Thu, 7 Nov 2024 17:21:50 +0800 Subject: [PATCH] cargo dev dogfood cargo uibless --- clippy_lints/src/use_crate_prefix_for_self_imports.rs | 6 +++--- .../use_crate_prefix_for_self_imports/fail/Cargo.stderr | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/use_crate_prefix_for_self_imports.rs b/clippy_lints/src/use_crate_prefix_for_self_imports.rs index d525a1cdc903..cbd25a25cc39 100644 --- a/clippy_lints/src/use_crate_prefix_for_self_imports.rs +++ b/clippy_lints/src/use_crate_prefix_for_self_imports.rs @@ -3,7 +3,7 @@ use clippy_utils::source::snippet_opt; use def_id::LOCAL_CRATE; use rustc_errors::Applicability; use rustc_hir::def::Res; -use rustc_hir::*; +use rustc_hir::{Item, ItemKind, def_id}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_session::declare_lint_pass; use rustc_span::{FileName, RealFileName}; @@ -75,10 +75,10 @@ impl LateLintPass<'_> for UseCratePrefixForSelfImports { span_lint_and_sugg( cx, USE_CRATE_PREFIX_FOR_SELF_IMPORTS, - use_path.span, + segment.ident.span, "this import is not clear", "prefix with `crate::`", - format!("crate::{}", snippet_opt(cx, use_path.span).unwrap()), + format!("crate::{}", snippet_opt(cx, segment.ident.span).unwrap()), Applicability::MachineApplicable, ); } diff --git a/tests/ui-cargo/use_crate_prefix_for_self_imports/fail/Cargo.stderr b/tests/ui-cargo/use_crate_prefix_for_self_imports/fail/Cargo.stderr index de315117be8e..6b336640e2c1 100644 --- a/tests/ui-cargo/use_crate_prefix_for_self_imports/fail/Cargo.stderr +++ b/tests/ui-cargo/use_crate_prefix_for_self_imports/fail/Cargo.stderr @@ -2,7 +2,7 @@ error: this import is not clear --> src/main.rs:1:5 | 1 | use foo::Foo; - | ^^^^^^^^ help: prefix with `crate::`: `crate::foo::Foo` + | ^^^ help: prefix with `crate::`: `crate::foo` | = note: `-D clippy::use-crate-prefix-for-self-imports` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::use_crate_prefix_for_self_imports)]`