Skip to content

Commit efddc6a

Browse files
committed
Lint and update stderr
1 parent e0461e7 commit efddc6a

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

clippy_lints/src/std_instead_of_core.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_hir_and_then};
22
use clippy_utils::is_from_proc_macro;
3-
use rustc_ast::Attribute;
43
use rustc_data_structures::fx::FxIndexSet;
54
use rustc_errors::Applicability;
65
use rustc_hir::def::Res;
@@ -108,8 +107,8 @@ pub struct StdReexports {
108107

109108
impl_lint_pass!(StdReexports => [STD_INSTEAD_OF_CORE, STD_INSTEAD_OF_ALLOC, ALLOC_INSTEAD_OF_CORE]);
110109

111-
/// Save all members of a UseKind::ListStem `use std::fmt::{Debug, Result};`
112-
/// Lint when the ListStem closes. However, since there's no look-ahead (that I know of).
110+
/// Save all members of a `UseKind::ListStem` `use std::fmt::{Debug, Result};`
111+
/// Lint when the `ListStem` closes. However, since there's no look-ahead (that I know of).
113112
/// Close whenever something is encountered that's outside of the container `Span`.
114113
#[derive(Debug)]
115114
struct OpenUseSpan {
@@ -154,7 +153,7 @@ struct ReplaceLintData {
154153
}
155154

156155
impl StdReexports {
157-
fn suggest_for_open_use_item_if_after<'tcx>(&mut self, cx: &LateContext<'tcx>, span: Span) {
156+
fn suggest_for_open_use_item_if_after(&mut self, cx: &LateContext<'_>, span: Span) {
158157
if let Some(collected_use) = self.open_use.take() {
159158
// Still contains other span, throw it back
160159
if collected_use.container.contains(span) {
@@ -169,7 +168,7 @@ impl StdReexports {
169168
// If true after checking all members, the lint is 'fixable'.
170169
// Otherwise, just warn
171170
let mut all_same_valid_lint = true;
172-
for member in collected_use.members.iter() {
171+
for member in &collected_use.members {
173172
match &member.lint_data {
174173
LintData::CanReplace(lint_data) => {
175174
if let Some((_span, prev_lint_data)) = place_holder_unique_check.take() {
@@ -234,7 +233,7 @@ impl StdReexports {
234233
|diag| {
235234
diag.help(format!("consider importing the item from `{replace_with}`"));
236235
},
237-
)
236+
);
238237
}
239238
}
240239
}
@@ -319,7 +318,7 @@ impl<'tcx> LateLintPass<'tcx> for StdReexports {
319318
self.open_use = Some(OpenUseSpan {
320319
container: item.span,
321320
members: FxIndexSet::default(),
322-
})
321+
});
323322
}
324323
}
325324

tests/ui/std_instead_of_core.stderr

+21-21
Original file line numberDiff line numberDiff line change
@@ -26,133 +26,133 @@ LL | use std::{
2626
| ^^^ help: consider importing the item from `core`: `core`
2727

2828
error: used import from `std` instead of `core`
29-
--> tests/ui/std_instead_of_core.rs:36:31
29+
--> tests/ui/std_instead_of_core.rs:37:31
3030
|
3131
LL | use std::{io::Write as _, fmt::Debug as _, fmt::Alignment as _};
3232
| ^^^^^^^^^^
3333
|
3434
= help: consider importing the item from `core`
3535

3636
error: used import from `std` instead of `core`
37-
--> tests/ui/std_instead_of_core.rs:36:48
37+
--> tests/ui/std_instead_of_core.rs:37:48
3838
|
3939
LL | use std::{io::Write as _, fmt::Debug as _, fmt::Alignment as _};
4040
| ^^^^^^^^^^^^^^
4141
|
4242
= help: consider importing the item from `core`
4343

4444
error: used import from `std` instead of `core`
45-
--> tests/ui/std_instead_of_core.rs:40:15
45+
--> tests/ui/std_instead_of_core.rs:42:15
4646
|
4747
LL | use std::{fmt::Alignment as _, io::Write as _, fmt::Debug as _};
4848
| ^^^^^^^^^^^^^^
4949
|
5050
= help: consider importing the item from `core`
5151

5252
error: used import from `std` instead of `core`
53-
--> tests/ui/std_instead_of_core.rs:40:52
53+
--> tests/ui/std_instead_of_core.rs:42:52
5454
|
5555
LL | use std::{fmt::Alignment as _, io::Write as _, fmt::Debug as _};
5656
| ^^^^^^^^^^
5757
|
5858
= help: consider importing the item from `core`
5959

6060
error: used import from `std` instead of `core`
61-
--> tests/ui/std_instead_of_core.rs:44:15
61+
--> tests/ui/std_instead_of_core.rs:47:15
6262
|
6363
LL | use std::{fmt::Debug as _, fmt::Alignment as _, io::Write as _};
6464
| ^^^^^^^^^^
6565
|
6666
= help: consider importing the item from `core`
6767

6868
error: used import from `std` instead of `core`
69-
--> tests/ui/std_instead_of_core.rs:44:32
69+
--> tests/ui/std_instead_of_core.rs:47:32
7070
|
7171
LL | use std::{fmt::Debug as _, fmt::Alignment as _, io::Write as _};
7272
| ^^^^^^^^^^^^^^
7373
|
7474
= help: consider importing the item from `core`
7575

7676
error: used import from `std` instead of `core`
77-
--> tests/ui/std_instead_of_core.rs:51:9
77+
--> tests/ui/std_instead_of_core.rs:54:9
7878
|
7979
LL | fmt::Debug as _,
8080
| ^^^^^^^^^^
8181
|
8282
= help: consider importing the item from `core`
8383

8484
error: used import from `std` instead of `core`
85-
--> tests/ui/std_instead_of_core.rs:52:9
85+
--> tests/ui/std_instead_of_core.rs:55:9
8686
|
8787
LL | fmt::Alignment as _,
8888
| ^^^^^^^^^^^^^^
8989
|
9090
= help: consider importing the item from `core`
9191

9292
error: used import from `std` instead of `core`
93-
--> tests/ui/std_instead_of_core.rs:58:9
93+
--> tests/ui/std_instead_of_core.rs:61:9
9494
|
9595
LL | fmt::Alignment as _,
9696
| ^^^^^^^^^^^^^^
9797
|
9898
= help: consider importing the item from `core`
9999

100100
error: used import from `std` instead of `core`
101-
--> tests/ui/std_instead_of_core.rs:60:9
101+
--> tests/ui/std_instead_of_core.rs:63:9
102102
|
103103
LL | fmt::Debug as _,
104104
| ^^^^^^^^^^
105105
|
106106
= help: consider importing the item from `core`
107107

108108
error: used import from `std` instead of `core`
109-
--> tests/ui/std_instead_of_core.rs:66:9
109+
--> tests/ui/std_instead_of_core.rs:69:9
110110
|
111111
LL | fmt::Alignment as _,
112112
| ^^^^^^^^^^^^^^
113113
|
114114
= help: consider importing the item from `core`
115115

116116
error: used import from `std` instead of `core`
117-
--> tests/ui/std_instead_of_core.rs:67:9
117+
--> tests/ui/std_instead_of_core.rs:70:9
118118
|
119119
LL | fmt::Debug as _,
120120
| ^^^^^^^^^^
121121
|
122122
= help: consider importing the item from `core`
123123

124124
error: used import from `std` instead of `core`
125-
--> tests/ui/std_instead_of_core.rs:72:15
125+
--> tests/ui/std_instead_of_core.rs:75:15
126126
|
127127
LL | let ptr = std::ptr::null::<u32>();
128128
| ^^^ help: consider importing the item from `core`: `core`
129129

130130
error: used import from `std` instead of `core`
131-
--> tests/ui/std_instead_of_core.rs:74:21
131+
--> tests/ui/std_instead_of_core.rs:77:21
132132
|
133133
LL | let ptr_mut = ::std::ptr::null_mut::<usize>();
134134
| ^^^ help: consider importing the item from `core`: `core`
135135

136136
error: used import from `std` instead of `core`
137-
--> tests/ui/std_instead_of_core.rs:78:16
137+
--> tests/ui/std_instead_of_core.rs:81:16
138138
|
139139
LL | let cell = std::cell::Cell::new(8u32);
140140
| ^^^ help: consider importing the item from `core`: `core`
141141

142142
error: used import from `std` instead of `core`
143-
--> tests/ui/std_instead_of_core.rs:80:27
143+
--> tests/ui/std_instead_of_core.rs:83:27
144144
|
145145
LL | let cell_absolute = ::std::cell::Cell::new(8u32);
146146
| ^^^ help: consider importing the item from `core`: `core`
147147

148148
error: used import from `std` instead of `core`
149-
--> tests/ui/std_instead_of_core.rs:89:9
149+
--> tests/ui/std_instead_of_core.rs:92:9
150150
|
151151
LL | use std::iter::Iterator;
152152
| ^^^ help: consider importing the item from `core`: `core`
153153

154154
error: used import from `std` instead of `alloc`
155-
--> tests/ui/std_instead_of_core.rs:96:9
155+
--> tests/ui/std_instead_of_core.rs:99:9
156156
|
157157
LL | use std::vec;
158158
| ^^^ help: consider importing the item from `alloc`: `alloc`
@@ -161,13 +161,13 @@ LL | use std::vec;
161161
= help: to override `-D warnings` add `#[allow(clippy::std_instead_of_alloc)]`
162162

163163
error: used import from `std` instead of `alloc`
164-
--> tests/ui/std_instead_of_core.rs:98:9
164+
--> tests/ui/std_instead_of_core.rs:101:9
165165
|
166166
LL | use std::vec::Vec;
167167
| ^^^ help: consider importing the item from `alloc`: `alloc`
168168

169169
error: used import from `alloc` instead of `core`
170-
--> tests/ui/std_instead_of_core.rs:104:9
170+
--> tests/ui/std_instead_of_core.rs:107:9
171171
|
172172
LL | use alloc::slice::from_ref;
173173
| ^^^^^ help: consider importing the item from `core`: `core`
@@ -176,7 +176,7 @@ LL | use alloc::slice::from_ref;
176176
= help: to override `-D warnings` add `#[allow(clippy::alloc_instead_of_core)]`
177177

178178
error: used import from `std` instead of `core`
179-
--> tests/ui/std_instead_of_core.rs:121:5
179+
--> tests/ui/std_instead_of_core.rs:124:5
180180
|
181181
LL | use std::fmt::{Debug as _, Result as _};
182182
| ^^^ help: consider importing the item from `core`: `core`

0 commit comments

Comments
 (0)