Skip to content

Commit 2838b8e

Browse files
committed
Point at method call when it is the source of the bound error
1 parent ce486d5 commit 2838b8e

29 files changed

+96
-164
lines changed

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,11 @@ impl Diagnostic {
370370
self.set_span(after);
371371
for span_label in before.span_labels() {
372372
if let Some(label) = span_label.label {
373-
self.span.push_span_label(after, label);
373+
if span_label.is_primary {
374+
self.span.push_span_label(after, label);
375+
} else {
376+
self.span.push_span_label(span_label.span, label);
377+
}
374378
}
375379
}
376380
self

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3108,6 +3108,16 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
31083108
point_at_chain(expr);
31093109
}
31103110
}
3111+
let call_node = hir.find(call_hir_id);
3112+
if let Some(Node::Expr(hir::Expr {
3113+
kind: hir::ExprKind::MethodCall(path, rcvr, ..),
3114+
..
3115+
})) = call_node
3116+
{
3117+
if Some(rcvr.span) == err.span.primary_span() {
3118+
err.replace_span_with(path.ident.span);
3119+
}
3120+
}
31113121
if let Some(Node::Expr(hir::Expr {
31123122
kind:
31133123
hir::ExprKind::Call(hir::Expr { span, .. }, _)

src/test/ui/generic-associated-types/issue-101020.stderr

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
error[E0277]: the trait bound `for<'a> &'a mut (): Foo<&'a mut ()>` is not satisfied
2-
--> $DIR/issue-101020.rs:31:5
2+
--> $DIR/issue-101020.rs:31:22
33
|
44
LL | (&mut EmptyIter).consume(());
5-
| ^^^^^^^^^^^^^^^^ ------- required by a bound introduced by this call
6-
| |
7-
| the trait `for<'a> Foo<&'a mut ()>` is not implemented for `&'a mut ()`
5+
| ^^^^^^^ the trait `for<'a> Foo<&'a mut ()>` is not implemented for `&'a mut ()`
86
|
97
note: required for `&'a mut ()` to implement `for<'a> FuncInput<'a, &'a mut ()>`
108
--> $DIR/issue-101020.rs:27:20

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
error[E0277]: the trait bound `X: Ord` is not satisfied
2-
--> $DIR/issue-20162.rs:5:5
2+
--> $DIR/issue-20162.rs:5:7
33
|
44
LL | b.sort();
5-
| ^ ---- required by a bound introduced by this call
6-
| |
7-
| the trait `Ord` is not implemented for `X`
5+
| ^^^^ the trait `Ord` is not implemented for `X`
86
|
97
note: required by a bound in `slice::<impl [T]>::sort`
108
--> $SRC_DIR/alloc/src/slice.rs:LL:COL

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ pub fn get_tok(it: &mut IntoIter<u8>) {
44
let mut found_e = false;
55

66
let temp: Vec<u8> = it
7-
//~^ ERROR to be an iterator that yields `&_`, but it yields `u8`
87
.take_while(|&x| {
98
found_e = true;
109
false
1110
})
12-
.cloned()
11+
.cloned() //~ ERROR to be an iterator that yields `&_`, but it yields `u8`
1312
.collect(); //~ ERROR the method
1413
}
1514

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

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
error[E0271]: expected `TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:8:21: 8:25]>` to be an iterator that yields `&_`, but it yields `u8`
2-
--> $DIR/issue-31173.rs:6:25
3-
|
4-
LL | let temp: Vec<u8> = it
5-
| _________________________^
6-
LL | |
7-
LL | | .take_while(|&x| {
8-
LL | | found_e = true;
9-
LL | | false
10-
LL | | })
11-
| |__________^ expected reference, found `u8`
12-
LL | .cloned()
13-
| ------ required by a bound introduced by this call
1+
error[E0271]: expected `TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:7:21: 7:25]>` to be an iterator that yields `&_`, but it yields `u8`
2+
--> $DIR/issue-31173.rs:11:10
3+
|
4+
LL | .cloned()
5+
| ^^^^^^ expected reference, found `u8`
146
|
157
= note: expected reference `&_`
168
found type `u8`
@@ -20,11 +12,11 @@ note: required by a bound in `cloned`
2012
LL | Self: Sized + Iterator<Item = &'a T>,
2113
| ^^^^^^^^^^^^ required by this bound in `Iterator::cloned`
2214

23-
error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:8:21: 8:25]>>`, but its trait bounds were not satisfied
24-
--> $DIR/issue-31173.rs:13:10
15+
error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>`, but its trait bounds were not satisfied
16+
--> $DIR/issue-31173.rs:12:10
2517
|
2618
LL | .collect();
27-
| ^^^^^^^ method cannot be called on `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:8:21: 8:25]>>` due to unsatisfied trait bounds
19+
| ^^^^^^^ 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
2820
|
2921
::: $SRC_DIR/core/src/iter/adapters/take_while.rs:LL:COL
3022
|
@@ -37,10 +29,10 @@ LL | pub struct Cloned<I> {
3729
| -------------------- doesn't satisfy `_: Iterator`
3830
|
3931
= note: the following trait bounds were not satisfied:
40-
`<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:8:21: 8:25]> as Iterator>::Item = &_`
41-
which is required by `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:8:21: 8:25]>>: Iterator`
42-
`Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:8:21: 8:25]>>: Iterator`
43-
which is required by `&mut Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:8:21: 8:25]>>: Iterator`
32+
`<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:7:21: 7:25]> as Iterator>::Item = &_`
33+
which is required by `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>: Iterator`
34+
`Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>: Iterator`
35+
which is required by `&mut Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>: Iterator`
4436

4537
error: aborting due to 2 previous errors
4638

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
error[E0271]: expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)`
2-
--> $DIR/issue-33941.rs:6:14
2+
--> $DIR/issue-33941.rs:6:36
33
|
44
LL | for _ in HashMap::new().iter().cloned() {}
5-
| ^^^^^^^^^^^^^^^^^^^^^ ------ required by a bound introduced by this call
6-
| |
7-
| expected reference, found tuple
5+
| ^^^^^^ expected reference, found tuple
86
|
97
= note: expected reference `&_`
108
found tuple `(&_, &_)`

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ LL | let sr: Vec<(u32, _, _)> = vec![];
1313
| +
1414

1515
error[E0277]: a value of type `Vec<(u32, _, _)>` cannot be built from an iterator over elements of type `()`
16-
--> $DIR/issue-34334.rs:5:33
16+
--> $DIR/issue-34334.rs:5:87
1717
|
1818
LL | let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect();
19-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------- required by a bound introduced by this call
20-
| |
21-
| value of type `Vec<(u32, _, _)>` cannot be built from `std::iter::Iterator<Item=()>`
19+
| ^^^^^^^ value of type `Vec<(u32, _, _)>` cannot be built from `std::iter::Iterator<Item=()>`
2220
|
2321
= help: the trait `FromIterator<()>` is not implemented for `Vec<(u32, _, _)>`
2422
= help: the trait `FromIterator<T>` is implemented for `Vec<T>`

src/test/ui/issues/issue-66923-show-error-for-correct-call.stderr

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
error[E0277]: a value of type `Vec<f64>` cannot be built from an iterator over elements of type `&f64`
2-
--> $DIR/issue-66923-show-error-for-correct-call.rs:8:24
2+
--> $DIR/issue-66923-show-error-for-correct-call.rs:8:39
33
|
44
LL | let x2: Vec<f64> = x1.into_iter().collect();
5-
| ^^^^^^^^^^^^^^ ------- required by a bound introduced by this call
6-
| |
7-
| value of type `Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>`
5+
| ^^^^^^^ value of type `Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>`
86
|
97
= help: the trait `FromIterator<&f64>` is not implemented for `Vec<f64>`
108
= help: the trait `FromIterator<T>` is implemented for `Vec<T>`
@@ -22,12 +20,10 @@ LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
2220
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Iterator::collect`
2321

2422
error[E0277]: a value of type `Vec<f64>` cannot be built from an iterator over elements of type `&f64`
25-
--> $DIR/issue-66923-show-error-for-correct-call.rs:12:14
23+
--> $DIR/issue-66923-show-error-for-correct-call.rs:12:29
2624
|
2725
LL | let x3 = x1.into_iter().collect::<Vec<f64>>();
28-
| ^^^^^^^^^^^^^^ ------- required by a bound introduced by this call
29-
| |
30-
| value of type `Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>`
26+
| ^^^^^^^ value of type `Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>`
3127
|
3228
= help: the trait `FromIterator<&f64>` is not implemented for `Vec<f64>`
3329
= help: the trait `FromIterator<T>` is implemented for `Vec<T>`

src/test/ui/iterators/collect-into-array.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ fn main() {
33
//~^ ERROR an array of type `[u32; 10]` cannot be built directly from an iterator
44
//~| NOTE try collecting into a `Vec<{integer}>`, then using `.try_into()`
55
//~| NOTE required by a bound in `collect`
6-
//~| NOTE required by a bound introduced by this call
76
}

src/test/ui/iterators/collect-into-array.stderr

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
error[E0277]: an array of type `[u32; 10]` cannot be built directly from an iterator
2-
--> $DIR/collect-into-array.rs:2:31
2+
--> $DIR/collect-into-array.rs:2:39
33
|
44
LL | let whatever: [u32; 10] = (0..10).collect();
5-
| ^^^^^^^ ------- required by a bound introduced by this call
6-
| |
7-
| try collecting into a `Vec<{integer}>`, then using `.try_into()`
5+
| ^^^^^^^ try collecting into a `Vec<{integer}>`, then using `.try_into()`
86
|
97
= help: the trait `FromIterator<{integer}>` is not implemented for `[u32; 10]`
108
note: required by a bound in `collect`

src/test/ui/iterators/collect-into-slice.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ fn main() {
1313
//~| NOTE all local variables must have a statically known size
1414
//~| NOTE doesn't have a size known at compile-time
1515
//~| NOTE doesn't have a size known at compile-time
16-
//~| NOTE required by a bound introduced by this call
1716
process_slice(&some_generated_vec);
1817
}

src/test/ui/iterators/collect-into-slice.stderr

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
2222
| ^ required by this bound in `Iterator::collect`
2323

2424
error[E0277]: a slice of type `[i32]` cannot be built since `[i32]` has no definite size
25-
--> $DIR/collect-into-slice.rs:6:30
25+
--> $DIR/collect-into-slice.rs:6:38
2626
|
2727
LL | let some_generated_vec = (0..10).collect();
28-
| ^^^^^^^ ------- required by a bound introduced by this call
29-
| |
30-
| try explicitly collecting into a `Vec<{integer}>`
28+
| ^^^^^^^ try explicitly collecting into a `Vec<{integer}>`
3129
|
3230
= help: the trait `FromIterator<{integer}>` is not implemented for `[i32]`
3331
note: required by a bound in `collect`

src/test/ui/iterators/invalid-iterator-chain.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ fn main() {
77
println!("{}", scores.sum::<i32>()); //~ ERROR E0277
88
println!(
99
"{}",
10-
vec![0, 1] //~ ERROR E0277
10+
vec![0, 1]
1111
.iter()
1212
.map(|x| x * 2)
1313
.map(|x| x as f64)
1414
.map(|x| x as i64)
1515
.filter(|x| *x > 0)
1616
.map(|x| { x + 1 })
1717
.map(|x| { x; })
18-
.sum::<i32>(),
18+
.sum::<i32>(), //~ ERROR E0277
1919
);
2020
println!(
2121
"{}",
22-
vec![0, 1] //~ ERROR E0277
22+
vec![0, 1]
2323
.iter()
2424
.map(|x| x * 2)
2525
.map(|x| x as f64)
2626
.filter(|x| *x > 0.0)
2727
.map(|x| { x + 1.0 })
28-
.sum::<i32>(),
28+
.sum::<i32>(), //~ ERROR E0277
2929
);
3030
println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>()); //~ ERROR E0277
3131
println!("{}", vec![(), ()].iter().sum::<i32>()); //~ ERROR E0277

src/test/ui/iterators/invalid-iterator-chain.stderr

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
2-
--> $DIR/invalid-iterator-chain.rs:7:20
2+
--> $DIR/invalid-iterator-chain.rs:7:27
33
|
44
LL | println!("{}", scores.sum::<i32>());
5-
| ^^^^^^ --- required by a bound introduced by this call
6-
| |
7-
| value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
5+
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
86
|
97
= help: the trait `Sum<()>` is not implemented for `i32`
108
= help: the following other types implement trait `Sum<A>`:
@@ -29,18 +27,10 @@ LL | S: Sum<Self::Item>,
2927
| ^^^^^^^^^^^^^^^ required by this bound in `Iterator::sum`
3028

3129
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
32-
--> $DIR/invalid-iterator-chain.rs:10:9
33-
|
34-
LL | / vec![0, 1]
35-
LL | | .iter()
36-
LL | | .map(|x| x * 2)
37-
LL | | .map(|x| x as f64)
38-
... |
39-
LL | | .map(|x| { x + 1 })
40-
LL | | .map(|x| { x; })
41-
| |____________________________^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
42-
LL | .sum::<i32>(),
43-
| --- required by a bound introduced by this call
30+
--> $DIR/invalid-iterator-chain.rs:18:14
31+
|
32+
LL | .sum::<i32>(),
33+
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
4434
|
4535
= help: the trait `Sum<()>` is not implemented for `i32`
4636
= help: the following other types implement trait `Sum<A>`:
@@ -72,17 +62,10 @@ LL | S: Sum<Self::Item>,
7262
| ^^^^^^^^^^^^^^^ required by this bound in `Iterator::sum`
7363

7464
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `f64`
75-
--> $DIR/invalid-iterator-chain.rs:22:9
76-
|
77-
LL | / vec![0, 1]
78-
LL | | .iter()
79-
LL | | .map(|x| x * 2)
80-
LL | | .map(|x| x as f64)
81-
LL | | .filter(|x| *x > 0.0)
82-
LL | | .map(|x| { x + 1.0 })
83-
| |_________________________________^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>`
84-
LL | .sum::<i32>(),
85-
| --- required by a bound introduced by this call
65+
--> $DIR/invalid-iterator-chain.rs:28:14
66+
|
67+
LL | .sum::<i32>(),
68+
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>`
8669
|
8770
= help: the trait `Sum<f64>` is not implemented for `i32`
8871
= help: the following other types implement trait `Sum<A>`:
@@ -110,12 +93,10 @@ LL | S: Sum<Self::Item>,
11093
| ^^^^^^^^^^^^^^^ required by this bound in `Iterator::sum`
11194

11295
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
113-
--> $DIR/invalid-iterator-chain.rs:30:20
96+
--> $DIR/invalid-iterator-chain.rs:30:54
11497
|
11598
LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
116-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --- required by a bound introduced by this call
117-
| |
118-
| value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
99+
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
119100
|
120101
= help: the trait `Sum<()>` is not implemented for `i32`
121102
= help: the following other types implement trait `Sum<A>`:
@@ -136,12 +117,10 @@ LL | S: Sum<Self::Item>,
136117
| ^^^^^^^^^^^^^^^ required by this bound in `Iterator::sum`
137118

138119
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()`
139-
--> $DIR/invalid-iterator-chain.rs:31:20
120+
--> $DIR/invalid-iterator-chain.rs:31:40
140121
|
141122
LL | println!("{}", vec![(), ()].iter().sum::<i32>());
142-
| ^^^^^^^^^^^^^^^^^^^ --- required by a bound introduced by this call
143-
| |
144-
| value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
123+
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
145124
|
146125
= help: the trait `Sum<&()>` is not implemented for `i32`
147126
= help: the following other types implement trait `Sum<A>`:
@@ -161,12 +140,10 @@ LL | S: Sum<Self::Item>,
161140
| ^^^^^^^^^^^^^^^ required by this bound in `Iterator::sum`
162141

163142
error[E0277]: a value of type `Vec<i32>` cannot be built from an iterator over elements of type `()`
164-
--> $DIR/invalid-iterator-chain.rs:40:23
143+
--> $DIR/invalid-iterator-chain.rs:40:25
165144
|
166145
LL | let g: Vec<i32> = f.collect();
167-
| ^ ------- required by a bound introduced by this call
168-
| |
169-
| value of type `Vec<i32>` cannot be built from `std::iter::Iterator<Item=()>`
146+
| ^^^^^^^ value of type `Vec<i32>` cannot be built from `std::iter::Iterator<Item=()>`
170147
|
171148
= help: the trait `FromIterator<()>` is not implemented for `Vec<i32>`
172149
= help: the trait `FromIterator<T>` is implemented for `Vec<T>`

src/test/ui/lazy-type-alias-impl-trait/branches.stderr

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
error[E0277]: a value of type `Bar` cannot be built from an iterator over elements of type `_`
2-
--> $DIR/branches.rs:19:9
2+
--> $DIR/branches.rs:19:28
33
|
44
LL | std::iter::empty().collect()
5-
| ^^^^^^^^^^^^^^^^^^ ------- required by a bound introduced by this call
6-
| |
7-
| value of type `Bar` cannot be built from `std::iter::Iterator<Item=_>`
5+
| ^^^^^^^ value of type `Bar` cannot be built from `std::iter::Iterator<Item=_>`
86
|
97
= help: the trait `FromIterator<_>` is not implemented for `Bar`
108
note: required by a bound in `collect`

src/test/ui/lazy-type-alias-impl-trait/recursion4.stderr

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
error[E0277]: a value of type `Foo` cannot be built from an iterator over elements of type `_`
2-
--> $DIR/recursion4.rs:10:9
2+
--> $DIR/recursion4.rs:10:28
33
|
44
LL | x = std::iter::empty().collect();
5-
| ^^^^^^^^^^^^^^^^^^ ------- required by a bound introduced by this call
6-
| |
7-
| value of type `Foo` cannot be built from `std::iter::Iterator<Item=_>`
5+
| ^^^^^^^ value of type `Foo` cannot be built from `std::iter::Iterator<Item=_>`
86
|
97
= help: the trait `FromIterator<_>` is not implemented for `Foo`
108
note: required by a bound in `collect`
@@ -14,12 +12,10 @@ LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
1412
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Iterator::collect`
1513

1614
error[E0277]: a value of type `impl Debug` cannot be built from an iterator over elements of type `_`
17-
--> $DIR/recursion4.rs:19:9
15+
--> $DIR/recursion4.rs:19:28
1816
|
1917
LL | x = std::iter::empty().collect();
20-
| ^^^^^^^^^^^^^^^^^^ ------- required by a bound introduced by this call
21-
| |
22-
| value of type `impl Debug` cannot be built from `std::iter::Iterator<Item=_>`
18+
| ^^^^^^^ value of type `impl Debug` cannot be built from `std::iter::Iterator<Item=_>`
2319
|
2420
= help: the trait `FromIterator<_>` is not implemented for `impl Debug`
2521
note: required by a bound in `collect`

0 commit comments

Comments
 (0)