Skip to content

Commit

Permalink
Remove noisy suggestion of hash_map rust-lang#72642
Browse files Browse the repository at this point in the history
Update src/librustc_resolve/diagnostics.rs

Co-authored-by: David Wood <Q0KPU0H1YOEPHRY1R2SN5B5RL@david.davidtw.co>

Minor refactoring rust-lang#72642

Fixed failing test-cases
  • Loading branch information
Ayush Kumar Mishra committed Jun 3, 2020
1 parent ff4aff6 commit 968594d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 58 deletions.
4 changes: 3 additions & 1 deletion src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,9 @@ impl<'a> Resolver<'a> {
Res::Def(DefKind::Ctor(..), did) => this.parent(did),
_ => res.opt_def_id(),
};
candidates.push(ImportSuggestion { did, descr: res.descr(), path });
if candidates.iter().all(|v: &ImportSuggestion| v.did != did) {
candidates.push(ImportSuggestion { did, descr: res.descr(), path });
}
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions src/test/ui/issues/issue-17546.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ LL | use std::fmt::Result;
|
LL | use std::io::Result;
|
LL | use std::prelude::v1::Result;
|
LL | use std::result::Result;
|
and 1 other candidate
LL | use std::thread::Result;
|

error[E0573]: expected type, found variant `Result`
--> $DIR/issue-17546.rs:30:13
Expand All @@ -48,11 +47,10 @@ LL | use std::fmt::Result;
|
LL | use std::io::Result;
|
LL | use std::prelude::v1::Result;
|
LL | use std::result::Result;
|
and 1 other candidate
LL | use std::thread::Result;
|

error[E0573]: expected type, found variant `NoResult`
--> $DIR/issue-17546.rs:35:15
Expand Down
48 changes: 12 additions & 36 deletions src/test/ui/no-implicit-prelude-nested.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,29 @@ error[E0404]: expected trait, found derive macro `Clone`
LL | impl Clone for Test {}
| ^^^^^ not a trait
|
help: consider importing one of these items instead
help: consider importing this trait instead
|
LL | use std::clone::Clone;
|
LL | use std::prelude::v1::Clone;
|

error[E0405]: cannot find trait `Iterator` in this scope
--> $DIR/no-implicit-prelude-nested.rs:13:14
|
LL | impl Iterator for Test {}
| ^^^^^^^^ not found in this scope
|
help: consider importing one of these items
help: consider importing this trait
|
LL | use std::iter::Iterator;
|
LL | use std::prelude::v1::Iterator;
|

error[E0405]: cannot find trait `ToString` in this scope
--> $DIR/no-implicit-prelude-nested.rs:14:14
|
LL | impl ToString for Test {}
| ^^^^^^^^ not found in this scope
|
help: consider importing one of these items
|
LL | use std::prelude::v1::ToString;
help: consider importing this trait
|
LL | use std::string::ToString;
|
Expand All @@ -60,12 +54,10 @@ error[E0425]: cannot find function `drop` in this scope
LL | drop(2)
| ^^^^ not found in this scope
|
help: consider importing one of these items
help: consider importing this function
|
LL | use std::mem::drop;
|
LL | use std::prelude::v1::drop;
|

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

error[E0405]: cannot find trait `Iterator` in this scope
--> $DIR/no-implicit-prelude-nested.rs:25:10
|
LL | impl Iterator for Test {}
| ^^^^^^^^ not found in this scope
|
help: consider importing one of these items
help: consider importing this trait
|
LL | use std::iter::Iterator;
|
LL | use std::prelude::v1::Iterator;
|

error[E0405]: cannot find trait `ToString` in this scope
--> $DIR/no-implicit-prelude-nested.rs:26:10
|
LL | impl ToString for Test {}
| ^^^^^^^^ not found in this scope
|
help: consider importing one of these items
|
LL | use std::prelude::v1::ToString;
help: consider importing this trait
|
LL | use std::string::ToString;
|
Expand All @@ -129,12 +115,10 @@ error[E0425]: cannot find function `drop` in this scope
LL | drop(2)
| ^^^^ not found in this scope
|
help: consider importing one of these items
help: consider importing this function
|
LL | use std::mem::drop;
|
LL | use std::prelude::v1::drop;
|

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

error[E0405]: cannot find trait `Iterator` in this scope
--> $DIR/no-implicit-prelude-nested.rs:40:14
|
LL | impl Iterator for Test {}
| ^^^^^^^^ not found in this scope
|
help: consider importing one of these items
help: consider importing this trait
|
LL | use std::iter::Iterator;
|
LL | use std::prelude::v1::Iterator;
|

error[E0405]: cannot find trait `ToString` in this scope
--> $DIR/no-implicit-prelude-nested.rs:41:14
|
LL | impl ToString for Test {}
| ^^^^^^^^ not found in this scope
|
help: consider importing one of these items
|
LL | use std::prelude::v1::ToString;
help: consider importing this trait
|
LL | use std::string::ToString;
|
Expand All @@ -198,12 +176,10 @@ error[E0425]: cannot find function `drop` in this scope
LL | drop(2)
| ^^^^ not found in this scope
|
help: consider importing one of these items
help: consider importing this function
|
LL | use std::mem::drop;
|
LL | use std::prelude::v1::drop;
|

error: aborting due to 18 previous errors

Expand Down
16 changes: 4 additions & 12 deletions src/test/ui/no-implicit-prelude.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,29 @@ error[E0404]: expected trait, found derive macro `Clone`
LL | impl Clone for Test {}
| ^^^^^ not a trait
|
help: consider importing one of these items instead
help: consider importing this trait instead
|
LL | use std::clone::Clone;
|
LL | use std::prelude::v1::Clone;
|

error[E0405]: cannot find trait `Iterator` in this scope
--> $DIR/no-implicit-prelude.rs:12:6
|
LL | impl Iterator for Test {}
| ^^^^^^^^ not found in this scope
|
help: consider importing one of these items
help: consider importing this trait
|
LL | use std::iter::Iterator;
|
LL | use std::prelude::v1::Iterator;
|

error[E0405]: cannot find trait `ToString` in this scope
--> $DIR/no-implicit-prelude.rs:13:6
|
LL | impl ToString for Test {}
| ^^^^^^^^ not found in this scope
|
help: consider importing one of these items
|
LL | use std::prelude::v1::ToString;
help: consider importing this trait
|
LL | use std::string::ToString;
|
Expand All @@ -60,12 +54,10 @@ error[E0425]: cannot find function `drop` in this scope
LL | drop(2)
| ^^^^ not found in this scope
|
help: consider importing one of these items
help: consider importing this function
|
LL | use std::mem::drop;
|
LL | use std::prelude::v1::drop;
|

error: aborting due to 6 previous errors

Expand Down
4 changes: 1 addition & 3 deletions src/test/ui/resolve/use_suggestion_placement.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ error[E0412]: cannot find type `HashMap` in this scope
LL | type Dict<K, V> = HashMap<K, V>;
| ^^^^^^^ not found in this scope
|
help: consider importing one of these items
help: consider importing this struct
|
LL | use std::collections::HashMap;
|
LL | use std::collections::hash_map::HashMap;
|

error: aborting due to 3 previous errors

Expand Down

0 comments on commit 968594d

Please sign in to comment.