Skip to content

Commit 968594d

Browse files
author
Ayush Kumar Mishra
committed
Remove noisy suggestion of hash_map #72642
Update src/librustc_resolve/diagnostics.rs Co-authored-by: David Wood <Q0KPU0H1YOEPHRY1R2SN5B5RL@david.davidtw.co> Minor refactoring #72642 Fixed failing test-cases
1 parent ff4aff6 commit 968594d

File tree

5 files changed

+24
-58
lines changed

5 files changed

+24
-58
lines changed

src/librustc_resolve/diagnostics.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,9 @@ impl<'a> Resolver<'a> {
680680
Res::Def(DefKind::Ctor(..), did) => this.parent(did),
681681
_ => res.opt_def_id(),
682682
};
683-
candidates.push(ImportSuggestion { did, descr: res.descr(), path });
683+
if candidates.iter().all(|v: &ImportSuggestion| v.did != did) {
684+
candidates.push(ImportSuggestion { did, descr: res.descr(), path });
685+
}
684686
}
685687
}
686688
}

src/test/ui/issues/issue-17546.stderr

+4-6
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ LL | use std::fmt::Result;
3030
|
3131
LL | use std::io::Result;
3232
|
33-
LL | use std::prelude::v1::Result;
34-
|
3533
LL | use std::result::Result;
3634
|
37-
and 1 other candidate
35+
LL | use std::thread::Result;
36+
|
3837

3938
error[E0573]: expected type, found variant `Result`
4039
--> $DIR/issue-17546.rs:30:13
@@ -48,11 +47,10 @@ LL | use std::fmt::Result;
4847
|
4948
LL | use std::io::Result;
5049
|
51-
LL | use std::prelude::v1::Result;
52-
|
5350
LL | use std::result::Result;
5451
|
55-
and 1 other candidate
52+
LL | use std::thread::Result;
53+
|
5654

5755
error[E0573]: expected type, found variant `NoResult`
5856
--> $DIR/issue-17546.rs:35:15

src/test/ui/no-implicit-prelude-nested.stderr

+12-36
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,29 @@ error[E0404]: expected trait, found derive macro `Clone`
1515
LL | impl Clone for Test {}
1616
| ^^^^^ not a trait
1717
|
18-
help: consider importing one of these items instead
18+
help: consider importing this trait instead
1919
|
2020
LL | use std::clone::Clone;
2121
|
22-
LL | use std::prelude::v1::Clone;
23-
|
2422

2523
error[E0405]: cannot find trait `Iterator` in this scope
2624
--> $DIR/no-implicit-prelude-nested.rs:13:14
2725
|
2826
LL | impl Iterator for Test {}
2927
| ^^^^^^^^ not found in this scope
3028
|
31-
help: consider importing one of these items
29+
help: consider importing this trait
3230
|
3331
LL | use std::iter::Iterator;
3432
|
35-
LL | use std::prelude::v1::Iterator;
36-
|
3733

3834
error[E0405]: cannot find trait `ToString` in this scope
3935
--> $DIR/no-implicit-prelude-nested.rs:14:14
4036
|
4137
LL | impl ToString for Test {}
4238
| ^^^^^^^^ not found in this scope
4339
|
44-
help: consider importing one of these items
45-
|
46-
LL | use std::prelude::v1::ToString;
40+
help: consider importing this trait
4741
|
4842
LL | use std::string::ToString;
4943
|
@@ -60,12 +54,10 @@ error[E0425]: cannot find function `drop` in this scope
6054
LL | drop(2)
6155
| ^^^^ not found in this scope
6256
|
63-
help: consider importing one of these items
57+
help: consider importing this function
6458
|
6559
LL | use std::mem::drop;
6660
|
67-
LL | use std::prelude::v1::drop;
68-
|
6961

7062
error[E0405]: cannot find trait `Add` in this scope
7163
--> $DIR/no-implicit-prelude-nested.rs:23:10
@@ -84,35 +76,29 @@ error[E0404]: expected trait, found derive macro `Clone`
8476
LL | impl Clone for Test {}
8577
| ^^^^^ not a trait
8678
|
87-
help: consider importing one of these items instead
79+
help: consider importing this trait instead
8880
|
8981
LL | use std::clone::Clone;
9082
|
91-
LL | use std::prelude::v1::Clone;
92-
|
9383

9484
error[E0405]: cannot find trait `Iterator` in this scope
9585
--> $DIR/no-implicit-prelude-nested.rs:25:10
9686
|
9787
LL | impl Iterator for Test {}
9888
| ^^^^^^^^ not found in this scope
9989
|
100-
help: consider importing one of these items
90+
help: consider importing this trait
10191
|
10292
LL | use std::iter::Iterator;
10393
|
104-
LL | use std::prelude::v1::Iterator;
105-
|
10694

10795
error[E0405]: cannot find trait `ToString` in this scope
10896
--> $DIR/no-implicit-prelude-nested.rs:26:10
10997
|
11098
LL | impl ToString for Test {}
11199
| ^^^^^^^^ not found in this scope
112100
|
113-
help: consider importing one of these items
114-
|
115-
LL | use std::prelude::v1::ToString;
101+
help: consider importing this trait
116102
|
117103
LL | use std::string::ToString;
118104
|
@@ -129,12 +115,10 @@ error[E0425]: cannot find function `drop` in this scope
129115
LL | drop(2)
130116
| ^^^^ not found in this scope
131117
|
132-
help: consider importing one of these items
118+
help: consider importing this function
133119
|
134120
LL | use std::mem::drop;
135121
|
136-
LL | use std::prelude::v1::drop;
137-
|
138122

139123
error[E0405]: cannot find trait `Add` in this scope
140124
--> $DIR/no-implicit-prelude-nested.rs:38:14
@@ -153,35 +137,29 @@ error[E0404]: expected trait, found derive macro `Clone`
153137
LL | impl Clone for Test {}
154138
| ^^^^^ not a trait
155139
|
156-
help: consider importing one of these items instead
140+
help: consider importing this trait instead
157141
|
158142
LL | use std::clone::Clone;
159143
|
160-
LL | use std::prelude::v1::Clone;
161-
|
162144

163145
error[E0405]: cannot find trait `Iterator` in this scope
164146
--> $DIR/no-implicit-prelude-nested.rs:40:14
165147
|
166148
LL | impl Iterator for Test {}
167149
| ^^^^^^^^ not found in this scope
168150
|
169-
help: consider importing one of these items
151+
help: consider importing this trait
170152
|
171153
LL | use std::iter::Iterator;
172154
|
173-
LL | use std::prelude::v1::Iterator;
174-
|
175155

176156
error[E0405]: cannot find trait `ToString` in this scope
177157
--> $DIR/no-implicit-prelude-nested.rs:41:14
178158
|
179159
LL | impl ToString for Test {}
180160
| ^^^^^^^^ not found in this scope
181161
|
182-
help: consider importing one of these items
183-
|
184-
LL | use std::prelude::v1::ToString;
162+
help: consider importing this trait
185163
|
186164
LL | use std::string::ToString;
187165
|
@@ -198,12 +176,10 @@ error[E0425]: cannot find function `drop` in this scope
198176
LL | drop(2)
199177
| ^^^^ not found in this scope
200178
|
201-
help: consider importing one of these items
179+
help: consider importing this function
202180
|
203181
LL | use std::mem::drop;
204182
|
205-
LL | use std::prelude::v1::drop;
206-
|
207183

208184
error: aborting due to 18 previous errors
209185

src/test/ui/no-implicit-prelude.stderr

+4-12
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,29 @@ error[E0404]: expected trait, found derive macro `Clone`
1515
LL | impl Clone for Test {}
1616
| ^^^^^ not a trait
1717
|
18-
help: consider importing one of these items instead
18+
help: consider importing this trait instead
1919
|
2020
LL | use std::clone::Clone;
2121
|
22-
LL | use std::prelude::v1::Clone;
23-
|
2422

2523
error[E0405]: cannot find trait `Iterator` in this scope
2624
--> $DIR/no-implicit-prelude.rs:12:6
2725
|
2826
LL | impl Iterator for Test {}
2927
| ^^^^^^^^ not found in this scope
3028
|
31-
help: consider importing one of these items
29+
help: consider importing this trait
3230
|
3331
LL | use std::iter::Iterator;
3432
|
35-
LL | use std::prelude::v1::Iterator;
36-
|
3733

3834
error[E0405]: cannot find trait `ToString` in this scope
3935
--> $DIR/no-implicit-prelude.rs:13:6
4036
|
4137
LL | impl ToString for Test {}
4238
| ^^^^^^^^ not found in this scope
4339
|
44-
help: consider importing one of these items
45-
|
46-
LL | use std::prelude::v1::ToString;
40+
help: consider importing this trait
4741
|
4842
LL | use std::string::ToString;
4943
|
@@ -60,12 +54,10 @@ error[E0425]: cannot find function `drop` in this scope
6054
LL | drop(2)
6155
| ^^^^ not found in this scope
6256
|
63-
help: consider importing one of these items
57+
help: consider importing this function
6458
|
6559
LL | use std::mem::drop;
6660
|
67-
LL | use std::prelude::v1::drop;
68-
|
6961

7062
error: aborting due to 6 previous errors
7163

src/test/ui/resolve/use_suggestion_placement.stderr

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ error[E0412]: cannot find type `HashMap` in this scope
2626
LL | type Dict<K, V> = HashMap<K, V>;
2727
| ^^^^^^^ not found in this scope
2828
|
29-
help: consider importing one of these items
29+
help: consider importing this struct
3030
|
3131
LL | use std::collections::HashMap;
3232
|
33-
LL | use std::collections::hash_map::HashMap;
34-
|
3533

3634
error: aborting due to 3 previous errors
3735

0 commit comments

Comments
 (0)