Skip to content

Commit cb9bcaf

Browse files
authored
Rollup merge of rust-lang#105715 - estebank:unsatisfied-bounds-label, r=compiler-errors
Do not mention long types in E0599 label The type is already mentioned in the main message and the list of unmet bounds.
2 parents a6337d3 + 2a0d712 commit cb9bcaf

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

compiler/rustc_hir_typeck/src/method/suggest.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
893893
}
894894
}
895895
} else {
896-
err.span_label(span, format!("{item_kind} cannot be called on `{ty_str}` due to unsatisfied trait bounds"));
896+
let ty_str = if ty_str.len() > 50 {
897+
String::new()
898+
} else {
899+
format!("on `{ty_str}` ")
900+
};
901+
err.span_label(span, format!(
902+
"{item_kind} cannot be called {ty_str}due to unsatisfied trait bounds"
903+
));
897904
}
898905
};
899906

src/test/ui/higher-rank-trait-bounds/issue-30786.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | pub struct Map<S, F> {
88
| doesn't satisfy `_: StreamExt`
99
...
1010
LL | let filter = map.filterx(|x: &_| true);
11-
| ^^^^^^^ method cannot be called on `Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>` due to unsatisfied trait bounds
11+
| ^^^^^^^ method cannot be called due to unsatisfied trait bounds
1212
|
1313
note: the following trait bounds were not satisfied:
1414
`&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>: Stream`
@@ -29,7 +29,7 @@ LL | pub struct Filter<S, F> {
2929
| doesn't satisfy `_: StreamExt`
3030
...
3131
LL | let count = filter.countx();
32-
| ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>` due to unsatisfied trait bounds
32+
| ^^^^^^ method cannot be called due to unsatisfied trait bounds
3333
|
3434
note: the following trait bounds were not satisfied:
3535
`&'a mut &Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream`

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut std:
1313
--> $DIR/issue-31173.rs:12:10
1414
|
1515
LL | .collect();
16-
| ^^^^^^^ method cannot be called on `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>` due to unsatisfied trait bounds
16+
| ^^^^^^^ method cannot be called due to unsatisfied trait bounds
1717
--> $SRC_DIR/core/src/iter/adapters/take_while.rs:LL:COL
1818
|
1919
= note: doesn't satisfy `<_ as Iterator>::Item = &_`

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ error[E0599]: the method `count` exists for struct `Filter<Fuse<std::iter::Once<
1717
--> $DIR/issue-36053-2.rs:7:55
1818
|
1919
LL | once::<&str>("str").fuse().filter(|a: &str| true).count();
20-
| --------- ^^^^^ method cannot be called on `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:48]>` due to unsatisfied trait bounds
20+
| --------- ^^^^^ method cannot be called due to unsatisfied trait bounds
2121
| |
2222
| doesn't satisfy `<_ as FnOnce<(&&str,)>>::Output = bool`
2323
| doesn't satisfy `_: FnMut<(&&str,)>`

0 commit comments

Comments
 (0)