Skip to content

Commit 9fa81f5

Browse files
authored
Rollup merge of rust-lang#56760 - estebank:dedup-bounds, r=oli-obk
Deduplicate unsatisfied trait bounds Fix rust-lang#35677.
2 parents da30d51 + a39f184 commit 9fa81f5

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

src/librustc_typeck/check/method/suggest.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
424424
}
425425

426426
if !unsatisfied_predicates.is_empty() {
427-
let bound_list = unsatisfied_predicates.iter()
427+
let mut bound_list = unsatisfied_predicates.iter()
428428
.map(|p| format!("`{} : {}`", p.self_ty(), p))
429-
.collect::<Vec<_>>()
430-
.join("\n");
429+
.collect::<Vec<_>>();
430+
bound_list.sort();
431+
bound_list.dedup(); // #35677
432+
let bound_list = bound_list.join("\n");
431433
err.note(&format!("the method `{}` exists but the following trait bounds \
432434
were not satisfied:\n{}",
433435
item_name,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ LL | .collect(); //~ ERROR no method named `collect`
1414
| ^^^^^^^
1515
|
1616
= note: the method `collect` exists but the following trait bounds were not satisfied:
17-
`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`
1817
`&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`
18+
`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`
1919

2020
error: aborting due to 2 previous errors
2121

src/test/ui/issues/issue-35677.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use std::collections::HashMap;
2+
fn intersect_map<K, V>(this: &mut HashMap<K, V>, other: HashMap<K, V>) -> bool {
3+
this.drain()
4+
//~^ ERROR no method named
5+
}

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

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0601]: `main` function not found in crate `issue_35677`
2+
|
3+
= note: consider adding a `main` function to `$DIR/issue-35677.rs`
4+
5+
error[E0599]: no method named `drain` found for type `&mut std::collections::HashMap<K, V>` in the current scope
6+
--> $DIR/issue-35677.rs:3:10
7+
|
8+
LL | this.drain()
9+
| ^^^^^
10+
|
11+
= note: the method `drain` exists but the following trait bounds were not satisfied:
12+
`K : std::cmp::Eq`
13+
`K : std::hash::Hash`
14+
15+
error: aborting due to 2 previous errors
16+
17+
Some errors occurred: E0599, E0601.
18+
For more information about an error, try `rustc --explain E0599`.

src/test/ui/mismatched_types/issue-36053-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ LL | once::<&str>("str").fuse().filter(|a: &str| true).count();
55
| ^^^^^
66
|
77
= note: the method `count` exists but the following trait bounds were not satisfied:
8-
`std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:17:39: 17:53]> : std::iter::Iterator`
98
`&mut std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:17:39: 17:53]> : std::iter::Iterator`
9+
`std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:17:39: 17:53]> : std::iter::Iterator`
1010

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

0 commit comments

Comments
 (0)