Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate unsatisfied trait bounds #56760

Merged
merged 2 commits into from
Dec 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}

if !unsatisfied_predicates.is_empty() {
let bound_list = unsatisfied_predicates.iter()
let mut bound_list = unsatisfied_predicates.iter()
.map(|p| format!("`{} : {}`", p.self_ty(), p))
.collect::<Vec<_>>()
.join("\n");
.collect::<Vec<_>>();
bound_list.sort();
bound_list.dedup(); // #35677
let bound_list = bound_list.join("\n");
err.note(&format!("the method `{}` exists but the following trait bounds \
were not satisfied:\n{}",
item_name,
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-31173.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ LL | .collect(); //~ ERROR no method named `collect`
| ^^^^^^^
|
= note: the method `collect` exists but the following trait bounds were not satisfied:
`std::iter::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:16:39: 19:6 found_e:_]>> : std::iter::Iterator`
`&mut std::iter::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:16:39: 19:6 found_e:_]>> : std::iter::Iterator`
`std::iter::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:16:39: 19:6 found_e:_]>> : std::iter::Iterator`

error: aborting due to 2 previous errors

Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/issues/issue-35677.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use std::collections::HashMap;
fn intersect_map<K, V>(this: &mut HashMap<K, V>, other: HashMap<K, V>) -> bool {
this.drain()
//~^ ERROR no method named
}
18 changes: 18 additions & 0 deletions src/test/ui/issues/issue-35677.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error[E0601]: `main` function not found in crate `issue_35677`
|
= note: consider adding a `main` function to `$DIR/issue-35677.rs`

error[E0599]: no method named `drain` found for type `&mut std::collections::HashMap<K, V>` in the current scope
--> $DIR/issue-35677.rs:3:10
|
LL | this.drain()
| ^^^^^
|
= note: the method `drain` exists but the following trait bounds were not satisfied:
`K : std::cmp::Eq`
`K : std::hash::Hash`

error: aborting due to 2 previous errors

Some errors occurred: E0599, E0601.
For more information about an error, try `rustc --explain E0599`.
2 changes: 1 addition & 1 deletion src/test/ui/mismatched_types/issue-36053-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ LL | once::<&str>("str").fuse().filter(|a: &str| true).count();
| ^^^^^
|
= note: the method `count` exists but the following trait bounds were not satisfied:
`std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:17:39: 17:53]> : std::iter::Iterator`
`&mut std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:17:39: 17:53]> : std::iter::Iterator`
`std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:17:39: 17:53]> : std::iter::Iterator`

error[E0631]: type mismatch in closure arguments
--> $DIR/issue-36053-2.rs:17:32
Expand Down