Skip to content

Commit 86cbce3

Browse files
committed
Add a test for the last entry
1 parent 3b33d69 commit 86cbce3

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

clippy_lints/src/std_instead_of_core.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,9 @@ impl<'tcx> LateLintPass<'tcx> for StdReexports {
283283

284284
}
285285

286-
#[inline]
287-
fn check_item_post(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
288-
self.suggest_for_open_use_item_if_after(cx, item.span);
289-
}
286+
// Essentially, check every other parsable thing's start (except for attributes),
287+
// If it starts, wrap up the last path lint. Lookahead would be nice but I don't
288+
// know if that's possible.
290289

291290
#[inline]
292291
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'tcx>) {

tests/ui/std_instead_of_core.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,6 @@ fn main() {
117117
std_instead_of_alloc();
118118
alloc_instead_of_core();
119119
}
120+
121+
use std::fmt::{Debug as _, Result as _};
122+
//~^ ERROR: used import from `std` instead of `core`

tests/ui/std_instead_of_core.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,11 @@ LL | use alloc::slice::from_ref;
175175
= note: `-D clippy::alloc-instead-of-core` implied by `-D warnings`
176176
= help: to override `-D warnings` add `#[allow(clippy::alloc_instead_of_core)]`
177177

178-
error: aborting due to 24 previous errors
178+
error: used import from `std` instead of `core`
179+
--> tests/ui/std_instead_of_core.rs:121:5
180+
|
181+
LL | use std::fmt::{Debug as _, Result as _};
182+
| ^^^ help: consider importing the item from `core`: `core`
183+
184+
error: aborting due to 25 previous errors
179185

0 commit comments

Comments
 (0)