Skip to content

Commit

Permalink
Rollup merge of rust-lang#56760 - estebank:dedup-bounds, r=oli-obk
Browse files Browse the repository at this point in the history
Deduplicate unsatisfied trait bounds

Fix rust-lang#35677.
  • Loading branch information
kennytm authored Dec 14, 2018
2 parents 9c56672 + a39f184 commit 9d5f554
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
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

0 comments on commit 9d5f554

Please sign in to comment.