Skip to content

Commit f03ce30

Browse files
committed
Auto merge of rust-lang#98863 - compiler-errors:projection-msg, r=estebank
Implement special-cased projection error message for some common traits Not sure what the best phrasing is, but I feel like these are more clear than the plain `<Type as Iterator>::Output == Type` messages. If this is actually a good idea, are there any other traits this could benefit?
2 parents 9b8cfc1 + 3fdf3cb commit f03ce30

25 files changed

+124
-78
lines changed

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

+49-13
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,13 @@ trait InferCtxtPrivExt<'hir, 'tcx> {
13151315
error: &MismatchedProjectionTypes<'tcx>,
13161316
);
13171317

1318+
fn maybe_detailed_projection_msg(
1319+
&self,
1320+
pred: ty::ProjectionPredicate<'tcx>,
1321+
normalized_ty: ty::Term<'tcx>,
1322+
expected_ty: ty::Term<'tcx>,
1323+
) -> Option<String>;
1324+
13181325
fn fuzzy_match_tys(
13191326
&self,
13201327
a: Ty<'tcx>,
@@ -1542,23 +1549,19 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
15421549
normalized_ty,
15431550
data.term,
15441551
) {
1545-
values = Some(infer::ValuePairs::Terms(ExpectedFound::new(
1546-
is_normalized_ty_expected,
1547-
normalized_ty,
1548-
data.term,
1549-
)));
1552+
values = Some((data, is_normalized_ty_expected, normalized_ty, data.term));
15501553
err_buf = error;
15511554
err = &err_buf;
15521555
}
15531556
}
15541557

1555-
let mut diag = struct_span_err!(
1556-
self.tcx.sess,
1557-
obligation.cause.span,
1558-
E0271,
1559-
"type mismatch resolving `{}`",
1560-
predicate
1561-
);
1558+
let msg = values
1559+
.and_then(|(predicate, _, normalized_ty, expected_ty)| {
1560+
self.maybe_detailed_projection_msg(predicate, normalized_ty, expected_ty)
1561+
})
1562+
.unwrap_or_else(|| format!("type mismatch resolving `{}`", predicate));
1563+
let mut diag = struct_span_err!(self.tcx.sess, obligation.cause.span, E0271, "{msg}");
1564+
15621565
let secondary_span = match predicate.kind().skip_binder() {
15631566
ty::PredicateKind::Projection(proj) => self
15641567
.tcx
@@ -1596,7 +1599,13 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
15961599
&mut diag,
15971600
&obligation.cause,
15981601
secondary_span,
1599-
values,
1602+
values.map(|(_, is_normalized_ty_expected, normalized_ty, term)| {
1603+
infer::ValuePairs::Terms(ExpectedFound::new(
1604+
is_normalized_ty_expected,
1605+
normalized_ty,
1606+
term,
1607+
))
1608+
}),
16001609
err,
16011610
true,
16021611
false,
@@ -1606,6 +1615,33 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
16061615
});
16071616
}
16081617

1618+
fn maybe_detailed_projection_msg(
1619+
&self,
1620+
pred: ty::ProjectionPredicate<'tcx>,
1621+
normalized_ty: ty::Term<'tcx>,
1622+
expected_ty: ty::Term<'tcx>,
1623+
) -> Option<String> {
1624+
let trait_def_id = pred.projection_ty.trait_def_id(self.tcx);
1625+
let self_ty = pred.projection_ty.self_ty();
1626+
1627+
if Some(pred.projection_ty.item_def_id) == self.tcx.lang_items().fn_once_output() {
1628+
Some(format!(
1629+
"expected `{self_ty}` to be a {fn_kind} that returns `{expected_ty}`, but it returns `{normalized_ty}`",
1630+
fn_kind = self_ty.prefix_string(self.tcx)
1631+
))
1632+
} else if Some(trait_def_id) == self.tcx.lang_items().future_trait() {
1633+
Some(format!(
1634+
"expected `{self_ty}` to be a future that resolves to `{expected_ty}`, but it resolves to `{normalized_ty}`"
1635+
))
1636+
} else if Some(trait_def_id) == self.tcx.get_diagnostic_item(sym::Iterator) {
1637+
Some(format!(
1638+
"expected `{self_ty}` to be an iterator that yields `{expected_ty}`, but it yields `{normalized_ty}`"
1639+
))
1640+
} else {
1641+
None
1642+
}
1643+
}
1644+
16091645
fn fuzzy_match_tys(
16101646
&self,
16111647
mut a: Ty<'tcx>,

src/test/ui/associated-types/associated-types-overridden-binding-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ trait I32Iterator = Iterator<Item = i32>;
44

55
fn main() {
66
let _: &dyn I32Iterator<Item = u32> = &vec![42].into_iter();
7-
//~^ ERROR type mismatch
7+
//~^ ERROR expected `std::vec::IntoIter<u32>` to be an iterator that yields `i32`, but it yields `u32`
88
}

src/test/ui/associated-types/associated-types-overridden-binding-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0271]: type mismatch resolving `<std::vec::IntoIter<u32> as Iterator>::Item == i32`
1+
error[E0271]: expected `std::vec::IntoIter<u32>` to be an iterator that yields `i32`, but it yields `u32`
22
--> $DIR/associated-types-overridden-binding-2.rs:6:43
33
|
44
LL | let _: &dyn I32Iterator<Item = u32> = &vec![42].into_iter();

src/test/ui/async-await/async-block-control-flow-static-semantics.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn return_targets_async_block_not_fn() -> u8 {
1515
return 0u8;
1616
};
1717
let _: &dyn Future<Output = ()> = &block;
18-
//~^ ERROR type mismatch
18+
//~^ ERROR expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8`
1919
}
2020

2121
async fn return_targets_async_block_not_async_fn() -> u8 {
@@ -24,7 +24,7 @@ async fn return_targets_async_block_not_async_fn() -> u8 {
2424
return 0u8;
2525
};
2626
let _: &dyn Future<Output = ()> = &block;
27-
//~^ ERROR type mismatch resolving `<impl Future<Output = u8> as Future>::Output == ()`
27+
//~^ ERROR expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8`
2828
}
2929

3030
fn no_break_in_async_block() {
@@ -42,7 +42,9 @@ fn no_break_in_async_block_even_with_outer_loop() {
4242
}
4343

4444
struct MyErr;
45-
fn err() -> Result<u8, MyErr> { Err(MyErr) }
45+
fn err() -> Result<u8, MyErr> {
46+
Err(MyErr)
47+
}
4648

4749
fn rethrow_targets_async_block_not_fn() -> Result<u8, MyErr> {
4850
//~^ ERROR mismatched types

src/test/ui/async-await/async-block-control-flow-static-semantics.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LL | |
3131
LL | | }
3232
| |_^ expected `u8`, found `()`
3333

34-
error[E0271]: type mismatch resolving `<impl Future<Output = u8> as Future>::Output == ()`
34+
error[E0271]: expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8`
3535
--> $DIR/async-block-control-flow-static-semantics.rs:26:39
3636
|
3737
LL | let _: &dyn Future<Output = ()> = &block;
@@ -47,7 +47,7 @@ LL | fn return_targets_async_block_not_fn() -> u8 {
4747
| |
4848
| implicitly returns `()` as its body has no tail or `return` expression
4949

50-
error[E0271]: type mismatch resolving `<impl Future<Output = u8> as Future>::Output == ()`
50+
error[E0271]: expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8`
5151
--> $DIR/async-block-control-flow-static-semantics.rs:17:39
5252
|
5353
LL | let _: &dyn Future<Output = ()> = &block;
@@ -56,7 +56,7 @@ LL | let _: &dyn Future<Output = ()> = &block;
5656
= note: required for the cast from `impl Future<Output = u8>` to the object type `dyn Future<Output = ()>`
5757

5858
error[E0308]: mismatched types
59-
--> $DIR/async-block-control-flow-static-semantics.rs:47:44
59+
--> $DIR/async-block-control-flow-static-semantics.rs:49:44
6060
|
6161
LL | fn rethrow_targets_async_block_not_fn() -> Result<u8, MyErr> {
6262
| ---------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `Result`, found `()`
@@ -67,7 +67,7 @@ LL | fn rethrow_targets_async_block_not_fn() -> Result<u8, MyErr> {
6767
found unit type `()`
6868

6969
error[E0308]: mismatched types
70-
--> $DIR/async-block-control-flow-static-semantics.rs:56:50
70+
--> $DIR/async-block-control-flow-static-semantics.rs:58:50
7171
|
7272
LL | fn rethrow_targets_async_block_not_async_fn() -> Result<u8, MyErr> {
7373
| ---------------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `Result`, found `()`

src/test/ui/hrtb/issue-62203-hrtb-ice.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ fn main() {
3838
let v = Unit2.m(
3939
//~^ ERROR type mismatch
4040
L {
41-
//~^ ERROR type mismatch
42-
f : |x| { drop(x); Unit4 }
43-
});
41+
//~^ ERROR to be a closure that returns `Unit3`, but it returns `Unit4`
42+
f: |x| {
43+
drop(x);
44+
Unit4
45+
},
46+
},
47+
);
4448
}
4549

4650
impl<'a> Ty<'a> for Unit2 {

src/test/ui/hrtb/issue-62203-hrtb-ice.stderr

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0271]: type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V`
1+
error[E0271]: type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:16: 42:19]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V`
22
--> $DIR/issue-62203-hrtb-ice.rs:38:19
33
|
44
LL | let v = Unit2.m(
5-
| ^ type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V`
5+
| ^ type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:16: 42:19]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V`
66
|
77
note: expected this to be `<_ as Ty<'_>>::V`
88
--> $DIR/issue-62203-hrtb-ice.rs:21:14
@@ -22,19 +22,22 @@ LL | where
2222
LL | F: for<'r> T0<'r, (<Self as Ty<'r>>::V,), O = <B as Ty<'r>>::V>,
2323
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m`
2424

25-
error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20] as FnOnce<((&'r u8,),)>>::Output == Unit3`
25+
error[E0271]: expected `[closure@$DIR/issue-62203-hrtb-ice.rs:42:16: 42:19]` to be a closure that returns `Unit3`, but it returns `Unit4`
2626
--> $DIR/issue-62203-hrtb-ice.rs:40:9
2727
|
2828
LL | let v = Unit2.m(
2929
| - required by a bound introduced by this call
3030
LL |
3131
LL | / L {
3232
LL | |
33-
LL | | f : |x| { drop(x); Unit4 }
34-
LL | | });
33+
LL | | f: |x| {
34+
LL | | drop(x);
35+
LL | | Unit4
36+
LL | | },
37+
LL | | },
3538
| |_________^ expected struct `Unit3`, found struct `Unit4`
3639
|
37-
note: required because of the requirements on the impl of `for<'r> T0<'r, (&'r u8,)>` for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20]>`
40+
note: required because of the requirements on the impl of `for<'r> T0<'r, (&'r u8,)>` for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:16: 42:19]>`
3841
--> $DIR/issue-62203-hrtb-ice.rs:17:16
3942
|
4043
LL | impl<'a, A, T> T0<'a, A> for L<T>

src/test/ui/impl-trait/issues/issue-78722.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type F = impl core::future::Future<Output = u8>;
77
struct Bug {
88
V1: [(); {
99
fn concrete_use() -> F {
10-
//~^ ERROR type mismatch
10+
//~^ ERROR expected `impl Future<Output = ()>` to be a future that resolves to `u8`, but it resolves to `()`
1111
async {}
1212
}
1313
let f: F = async { 1 };

src/test/ui/impl-trait/issues/issue-78722.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LL | let f: F = async { 1 };
1616
LL | }],
1717
| - value is dropped here
1818

19-
error[E0271]: type mismatch resolving `<impl Future<Output = ()> as Future>::Output == u8`
19+
error[E0271]: expected `impl Future<Output = ()>` to be a future that resolves to `u8`, but it resolves to `()`
2020
--> $DIR/issue-78722.rs:9:30
2121
|
2222
LL | fn concrete_use() -> F {

src/test/ui/intrinsics/const-eval-select-bad.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn baz(n: bool) -> i32 {
2727

2828
const fn return_ty_mismatch() {
2929
const_eval_select((1,), foo, bar);
30-
//~^ ERROR type mismatch
30+
//~^ ERROR expected `fn(i32) -> bool {bar}` to be a fn item that returns `i32`, but it returns `bool`
3131
}
3232

3333
const fn args_ty_mismatch() {

src/test/ui/intrinsics/const-eval-select-bad.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ note: required by a bound in `const_eval_select`
5151
LL | G: FnOnce<ARG, Output = RET> + ~const Destruct,
5252
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select`
5353

54-
error[E0271]: type mismatch resolving `<fn(i32) -> bool {bar} as FnOnce<(i32,)>>::Output == i32`
54+
error[E0271]: expected `fn(i32) -> bool {bar}` to be a fn item that returns `i32`, but it returns `bool`
5555
--> $DIR/const-eval-select-bad.rs:29:5
5656
|
5757
LL | const_eval_select((1,), foo, bar);

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

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ use std::vec::IntoIter;
33
pub fn get_tok(it: &mut IntoIter<u8>) {
44
let mut found_e = false;
55

6-
let temp: Vec<u8> = it.take_while(|&x| {
7-
found_e = true;
8-
false
9-
})
6+
let temp: Vec<u8> = it
7+
.take_while(|&x| {
8+
found_e = true;
9+
false
10+
})
1011
.cloned()
11-
//~^ ERROR type mismatch resolving
12+
//~^ ERROR to be an iterator that yields `&_`, but it yields `u8`
1213
.collect(); //~ ERROR the method
1314
}
1415

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
error[E0271]: type mismatch resolving `<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]> as Iterator>::Item == &_`
2-
--> $DIR/issue-31173.rs:10:10
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
33
|
44
LL | .cloned()
55
| ^^^^^^ expected reference, found `u8`
@@ -12,11 +12,11 @@ note: required by a bound in `cloned`
1212
LL | Self: Sized + Iterator<Item = &'a T>,
1313
| ^^^^^^^^^^^^ required by this bound in `cloned`
1414

15-
error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>`, but its trait bounds were not satisfied
16-
--> $DIR/issue-31173.rs:12: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:13:10
1717
|
1818
LL | .collect();
19-
| ^^^^^^^ method cannot be called on `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>` 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
2020
|
2121
::: $SRC_DIR/core/src/iter/adapters/cloned.rs:LL:COL
2222
|
@@ -29,10 +29,10 @@ LL | pub struct TakeWhile<I, P> {
2929
| -------------------------- doesn't satisfy `<_ as Iterator>::Item = &_`
3030
|
3131
= note: the following trait bounds were not satisfied:
32-
`<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]> as Iterator>::Item = &_`
33-
which is required by `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>: Iterator`
34-
`Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>: Iterator`
35-
which is required by `&mut Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>: 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`
3636

3737
error: aborting due to 2 previous errors
3838

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::collections::HashMap;
44

55
fn main() {
6-
for _ in HashMap::new().iter().cloned() {} //~ ERROR type mismatch
7-
//~^ ERROR type mismatch
8-
//~| ERROR type mismatch
6+
for _ in HashMap::new().iter().cloned() {} //~ ERROR expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)`
7+
//~^ ERROR expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)`
8+
//~| ERROR expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)`
99
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as Iterator>::Item == &_`
1+
error[E0271]: expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)`
22
--> $DIR/issue-33941.rs:6:36
33
|
44
LL | for _ in HashMap::new().iter().cloned() {}
@@ -12,7 +12,7 @@ note: required by a bound in `cloned`
1212
LL | Self: Sized + Iterator<Item = &'a T>,
1313
| ^^^^^^^^^^^^ required by this bound in `cloned`
1414

15-
error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as Iterator>::Item == &_`
15+
error[E0271]: expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)`
1616
--> $DIR/issue-33941.rs:6:14
1717
|
1818
LL | for _ in HashMap::new().iter().cloned() {}
@@ -23,7 +23,7 @@ LL | for _ in HashMap::new().iter().cloned() {}
2323
= note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
2424
= note: required because of the requirements on the impl of `IntoIterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
2525

26-
error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as Iterator>::Item == &_`
26+
error[E0271]: expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)`
2727
--> $DIR/issue-33941.rs:6:14
2828
|
2929
LL | for _ in HashMap::new().iter().cloned() {}

src/test/ui/never_type/fallback-closure-wrap.fallback.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0271]: type mismatch resolving `<[closure@$DIR/fallback-closure-wrap.rs:18:40: 18:47] as FnOnce<()>>::Output == ()`
1+
error[E0271]: expected `[closure@$DIR/fallback-closure-wrap.rs:18:40: 18:47]` to be a closure that returns `()`, but it returns `!`
22
--> $DIR/fallback-closure-wrap.rs:18:31
33
|
44
LL | let error = Closure::wrap(Box::new(move || {

src/test/ui/never_type/fallback-closure-wrap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::marker::PhantomData;
1616

1717
fn main() {
1818
let error = Closure::wrap(Box::new(move || {
19-
//[fallback]~^ ERROR type mismatch resolving
19+
//[fallback]~^ to be a closure that returns `()`, but it returns `!`
2020
panic!("Can't connect to server.");
2121
}) as Box<dyn FnMut()>);
2222
}

src/test/ui/traits/assoc-type-in-superbad.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
use std::vec::IntoIter;
66

7-
pub trait Foo: Iterator<Item=<Self as Foo>::Key> {
7+
pub trait Foo: Iterator<Item = <Self as Foo>::Key> {
88
type Key;
99
}
1010

1111
impl Foo for IntoIter<i32> {
12-
type Key = u32; //~ ERROR type mismatch
12+
type Key = u32;
13+
//~^ ERROR expected `std::vec::IntoIter<i32>` to be an iterator that yields `u32`, but it yields `i32`
1314
}
1415

15-
fn main() {
16-
}
16+
fn main() {}

0 commit comments

Comments
 (0)