Fix #12438 false positive regression

This commit is contained in:
MarcusGrass 2024-03-09 18:37:18 +01:00
parent c173ea64b7
commit b44ab66156
No known key found for this signature in database
GPG key ID: B3F995FE064E3AA9
3 changed files with 4 additions and 8 deletions

View file

@ -109,6 +109,7 @@ impl<'tcx> LateLintPass<'tcx> for StdReexports {
sym::core => (STD_INSTEAD_OF_CORE, "std", "core"), sym::core => (STD_INSTEAD_OF_CORE, "std", "core"),
sym::alloc => (STD_INSTEAD_OF_ALLOC, "std", "alloc"), sym::alloc => (STD_INSTEAD_OF_ALLOC, "std", "alloc"),
_ => { _ => {
self.prev_span = first_segment.ident.span;
return; return;
}, },
}, },
@ -116,6 +117,7 @@ impl<'tcx> LateLintPass<'tcx> for StdReexports {
if cx.tcx.crate_name(def_id.krate) == sym::core { if cx.tcx.crate_name(def_id.krate) == sym::core {
(ALLOC_INSTEAD_OF_CORE, "alloc", "core") (ALLOC_INSTEAD_OF_CORE, "alloc", "core")
} else { } else {
self.prev_span = first_segment.ident.span;
return; return;
} }
}, },

View file

@ -17,7 +17,7 @@ fn std_instead_of_core() {
use ::core::hash::Hash; use ::core::hash::Hash;
//~^ ERROR: used import from `std` instead of `core` //~^ ERROR: used import from `std` instead of `core`
// Don't lint on `env` macro // Don't lint on `env` macro
use core::env; use std::env;
// Multiple imports // Multiple imports
use core::fmt::{Debug, Result}; use core::fmt::{Debug, Result};

View file

@ -13,12 +13,6 @@ error: used import from `std` instead of `core`
LL | use ::std::hash::Hash; LL | use ::std::hash::Hash;
| ^^^ help: consider importing the item from `core`: `core` | ^^^ help: consider importing the item from `core`: `core`
error: used import from `std` instead of `core`
--> tests/ui/std_instead_of_core.rs:20:9
|
LL | use std::env;
| ^^^ help: consider importing the item from `core`: `core`
error: used import from `std` instead of `core` error: used import from `std` instead of `core`
--> tests/ui/std_instead_of_core.rs:23:9 --> tests/ui/std_instead_of_core.rs:23:9
| |
@ -85,5 +79,5 @@ LL | use alloc::slice::from_ref;
= note: `-D clippy::alloc-instead-of-core` implied by `-D warnings` = note: `-D clippy::alloc-instead-of-core` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::alloc_instead_of_core)]` = help: to override `-D warnings` add `#[allow(clippy::alloc_instead_of_core)]`
error: aborting due to 13 previous errors error: aborting due to 12 previous errors