Skip to content

Commit b44ab66

Browse files
committed
Fix #12438 false positive regression
1 parent c173ea6 commit b44ab66

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

clippy_lints/src/std_instead_of_core.rs

+2
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,15 @@ impl<'tcx> LateLintPass<'tcx> for StdReexports {
109109
sym::core => (STD_INSTEAD_OF_CORE, "std", "core"),
110110
sym::alloc => (STD_INSTEAD_OF_ALLOC, "std", "alloc"),
111111
_ => {
112+
self.prev_span = first_segment.ident.span;
112113
return;
113114
},
114115
},
115116
sym::alloc => {
116117
if cx.tcx.crate_name(def_id.krate) == sym::core {
117118
(ALLOC_INSTEAD_OF_CORE, "alloc", "core")
118119
} else {
120+
self.prev_span = first_segment.ident.span;
119121
return;
120122
}
121123
},

tests/ui/std_instead_of_core.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn std_instead_of_core() {
1717
use ::core::hash::Hash;
1818
//~^ ERROR: used import from `std` instead of `core`
1919
// Don't lint on `env` macro
20-
use core::env;
20+
use std::env;
2121

2222
// Multiple imports
2323
use core::fmt::{Debug, Result};

tests/ui/std_instead_of_core.stderr

+1-7
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ error: used import from `std` instead of `core`
1313
LL | use ::std::hash::Hash;
1414
| ^^^ help: consider importing the item from `core`: `core`
1515

16-
error: used import from `std` instead of `core`
17-
--> tests/ui/std_instead_of_core.rs:20:9
18-
|
19-
LL | use std::env;
20-
| ^^^ help: consider importing the item from `core`: `core`
21-
2216
error: used import from `std` instead of `core`
2317
--> tests/ui/std_instead_of_core.rs:23:9
2418
|
@@ -85,5 +79,5 @@ LL | use alloc::slice::from_ref;
8579
= note: `-D clippy::alloc-instead-of-core` implied by `-D warnings`
8680
= help: to override `-D warnings` add `#[allow(clippy::alloc_instead_of_core)]`
8781

88-
error: aborting due to 13 previous errors
82+
error: aborting due to 12 previous errors
8983

0 commit comments

Comments
 (0)