Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a2e4ef2

Browse files
committed
dump bugged fix
1 parent 74cba63 commit a2e4ef2

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

clippy_lints/src/std_instead_of_core.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,13 @@ 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;
113112
return;
114113
},
115114
},
116115
sym::alloc => {
117116
if cx.tcx.crate_name(def_id.krate) == sym::core {
118117
(ALLOC_INSTEAD_OF_CORE, "alloc", "core")
119118
} else {
120-
self.prev_span = first_segment.ident.span;
121119
return;
122120
}
123121
},

tests/ui/std_instead_of_core.fixed

Lines changed: 6 additions & 2 deletions
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 std::env;
20+
use core::env;
2121

2222
// Multiple imports
2323
use core::fmt::{Debug, Result};
@@ -27,10 +27,14 @@ fn std_instead_of_core() {
2727
#[rustfmt::skip]
2828
use core::{
2929
//~^ ERROR: used import from `std` instead of `core`
30-
fmt::Write,
30+
fmt::Write as _,
3131
ptr::read_unaligned,
3232
};
3333

34+
// Multiline mixed imports
35+
use core::{io::Write, fmt::Display};
36+
//~^ ERROR: used import from `std` instead of `core`
37+
3438
// Function calls
3539
let ptr = core::ptr::null::<u32>();
3640
//~^ ERROR: used import from `std` instead of `core`

tests/ui/std_instead_of_core.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ fn std_instead_of_core() {
2727
#[rustfmt::skip]
2828
use std::{
2929
//~^ ERROR: used import from `std` instead of `core`
30-
fmt::Write,
30+
fmt::Write as _,
3131
ptr::read_unaligned,
3232
};
3333

34+
// Multiline mixed imports
35+
use std::{io::Write, fmt::Display};
36+
//~^ ERROR: used import from `std` instead of `core`
37+
3438
// Function calls
3539
let ptr = std::ptr::null::<u32>();
3640
//~^ ERROR: used import from `std` instead of `core`

tests/ui/std_instead_of_core.stderr

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ 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+
1622
error: used import from `std` instead of `core`
1723
--> tests/ui/std_instead_of_core.rs:23:9
1824
|
@@ -26,37 +32,43 @@ LL | use std::{
2632
| ^^^ help: consider importing the item from `core`: `core`
2733

2834
error: used import from `std` instead of `core`
29-
--> tests/ui/std_instead_of_core.rs:35:15
35+
--> tests/ui/std_instead_of_core.rs:35:9
36+
|
37+
LL | use std::{io::Write, fmt::Display};
38+
| ^^^ help: consider importing the item from `core`: `core`
39+
40+
error: used import from `std` instead of `core`
41+
--> tests/ui/std_instead_of_core.rs:39:15
3042
|
3143
LL | let ptr = std::ptr::null::<u32>();
3244
| ^^^ help: consider importing the item from `core`: `core`
3345

3446
error: used import from `std` instead of `core`
35-
--> tests/ui/std_instead_of_core.rs:37:21
47+
--> tests/ui/std_instead_of_core.rs:41:21
3648
|
3749
LL | let ptr_mut = ::std::ptr::null_mut::<usize>();
3850
| ^^^ help: consider importing the item from `core`: `core`
3951

4052
error: used import from `std` instead of `core`
41-
--> tests/ui/std_instead_of_core.rs:41:16
53+
--> tests/ui/std_instead_of_core.rs:45:16
4254
|
4355
LL | let cell = std::cell::Cell::new(8u32);
4456
| ^^^ help: consider importing the item from `core`: `core`
4557

4658
error: used import from `std` instead of `core`
47-
--> tests/ui/std_instead_of_core.rs:43:27
59+
--> tests/ui/std_instead_of_core.rs:47:27
4860
|
4961
LL | let cell_absolute = ::std::cell::Cell::new(8u32);
5062
| ^^^ help: consider importing the item from `core`: `core`
5163

5264
error: used import from `std` instead of `core`
53-
--> tests/ui/std_instead_of_core.rs:52:9
65+
--> tests/ui/std_instead_of_core.rs:56:9
5466
|
5567
LL | use std::iter::Iterator;
5668
| ^^^ help: consider importing the item from `core`: `core`
5769

5870
error: used import from `std` instead of `alloc`
59-
--> tests/ui/std_instead_of_core.rs:59:9
71+
--> tests/ui/std_instead_of_core.rs:63:9
6072
|
6173
LL | use std::vec;
6274
| ^^^ help: consider importing the item from `alloc`: `alloc`
@@ -65,19 +77,19 @@ LL | use std::vec;
6577
= help: to override `-D warnings` add `#[allow(clippy::std_instead_of_alloc)]`
6678

6779
error: used import from `std` instead of `alloc`
68-
--> tests/ui/std_instead_of_core.rs:61:9
80+
--> tests/ui/std_instead_of_core.rs:65:9
6981
|
7082
LL | use std::vec::Vec;
7183
| ^^^ help: consider importing the item from `alloc`: `alloc`
7284

7385
error: used import from `alloc` instead of `core`
74-
--> tests/ui/std_instead_of_core.rs:67:9
86+
--> tests/ui/std_instead_of_core.rs:71:9
7587
|
7688
LL | use alloc::slice::from_ref;
7789
| ^^^^^ help: consider importing the item from `core`: `core`
7890
|
7991
= note: `-D clippy::alloc-instead-of-core` implied by `-D warnings`
8092
= help: to override `-D warnings` add `#[allow(clippy::alloc_instead_of_core)]`
8193

82-
error: aborting due to 12 previous errors
94+
error: aborting due to 14 previous errors
8395

0 commit comments

Comments
 (0)