Rollup merge of #56760 - estebank:dedup-bounds, r=oli-obk

Deduplicate unsatisfied trait bounds

Fix #35677.
This commit is contained in:
Pietro Albini 2018-12-15 10:17:38 +01:00 committed by GitHub
commit e433da7ea0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 5 deletions

View File

@ -424,10 +424,12 @@ macro_rules! report_function {
}
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,

View File

@ -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

View File

@ -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
}

View File

@ -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`.

View File

@ -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