From 750f04d30973b5615e54ee27c7336846d19943ee Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 3 Jul 2022 20:17:08 +0000 Subject: [PATCH 1/2] Implement special-cased projection error message for some common traits --- .../src/traits/error_reporting/mod.rs | 62 +++++++++++++++---- .../associated-types-overridden-binding-2.rs | 2 +- ...sociated-types-overridden-binding-2.stderr | 2 +- ...ync-block-control-flow-static-semantics.rs | 4 +- ...block-control-flow-static-semantics.stderr | 4 +- src/test/ui/hrtb/issue-62203-hrtb-ice.rs | 2 +- src/test/ui/hrtb/issue-62203-hrtb-ice.stderr | 2 +- src/test/ui/impl-trait/issues/issue-78722.rs | 2 +- .../ui/impl-trait/issues/issue-78722.stderr | 2 +- .../ui/intrinsics/const-eval-select-bad.rs | 2 +- .../intrinsics/const-eval-select-bad.stderr | 2 +- src/test/ui/issues/issue-31173.rs | 2 +- src/test/ui/issues/issue-31173.stderr | 2 +- src/test/ui/issues/issue-33941.rs | 6 +- src/test/ui/issues/issue-33941.stderr | 6 +- .../fallback-closure-wrap.fallback.stderr | 2 +- .../ui/never_type/fallback-closure-wrap.rs | 2 +- src/test/ui/traits/assoc-type-in-superbad.rs | 3 +- .../ui/traits/assoc-type-in-superbad.stderr | 2 +- .../ui/type-alias-impl-trait/issue-57961.rs | 2 +- .../type-alias-impl-trait/issue-57961.stderr | 2 +- .../ui/type-alias-impl-trait/issue-98604.rs | 2 +- .../type-alias-impl-trait/issue-98604.stderr | 2 +- .../ui/type-alias-impl-trait/issue-98608.rs | 2 +- .../type-alias-impl-trait/issue-98608.stderr | 2 +- 25 files changed, 80 insertions(+), 43 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index e442c5c9189ac..911fb094b0cbe 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1315,6 +1315,13 @@ trait InferCtxtPrivExt<'hir, 'tcx> { error: &MismatchedProjectionTypes<'tcx>, ); + fn maybe_detailed_projection_msg( + &self, + pred: ty::ProjectionPredicate<'tcx>, + normalized_ty: ty::Term<'tcx>, + expected_ty: ty::Term<'tcx>, + ) -> Option; + fn fuzzy_match_tys( &self, a: Ty<'tcx>, @@ -1542,23 +1549,19 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { normalized_ty, data.term, ) { - values = Some(infer::ValuePairs::Terms(ExpectedFound::new( - is_normalized_ty_expected, - normalized_ty, - data.term, - ))); + values = Some((data, is_normalized_ty_expected, normalized_ty, data.term)); err_buf = error; err = &err_buf; } } - let mut diag = struct_span_err!( - self.tcx.sess, - obligation.cause.span, - E0271, - "type mismatch resolving `{}`", - predicate - ); + let msg = values + .and_then(|(predicate, _, normalized_ty, expected_ty)| { + self.maybe_detailed_projection_msg(predicate, normalized_ty, expected_ty) + }) + .unwrap_or_else(|| format!("type mismatch resolving `{}`", predicate)); + let mut diag = struct_span_err!(self.tcx.sess, obligation.cause.span, E0271, "{msg}"); + let secondary_span = match predicate.kind().skip_binder() { ty::PredicateKind::Projection(proj) => self .tcx @@ -1596,7 +1599,13 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { &mut diag, &obligation.cause, secondary_span, - values, + values.map(|(_, is_normalized_ty_expected, normalized_ty, term)| { + infer::ValuePairs::Terms(ExpectedFound::new( + is_normalized_ty_expected, + normalized_ty, + term, + )) + }), err, true, false, @@ -1606,6 +1615,33 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { }); } + fn maybe_detailed_projection_msg( + &self, + pred: ty::ProjectionPredicate<'tcx>, + normalized_ty: ty::Term<'tcx>, + expected_ty: ty::Term<'tcx>, + ) -> Option { + let trait_def_id = pred.projection_ty.trait_def_id(self.tcx); + let self_ty = pred.projection_ty.self_ty(); + + if Some(pred.projection_ty.item_def_id) == self.tcx.lang_items().fn_once_output() { + Some(format!( + "expected `{self_ty}` to be a {fn_kind} that returns `{expected_ty}`, but it actually returns `{normalized_ty}`", + fn_kind = self_ty.prefix_string(self.tcx) + )) + } else if Some(trait_def_id) == self.tcx.lang_items().future_trait() { + Some(format!( + "expected `{self_ty}` to be a future that yields `{expected_ty}`, but it actually yields `{normalized_ty}`" + )) + } else if Some(trait_def_id) == self.tcx.get_diagnostic_item(sym::Iterator) { + Some(format!( + "expected `{self_ty}` to be an iterator of `{expected_ty}`, but it actually returns items of `{normalized_ty}`" + )) + } else { + None + } + } + fn fuzzy_match_tys( &self, mut a: Ty<'tcx>, diff --git a/src/test/ui/associated-types/associated-types-overridden-binding-2.rs b/src/test/ui/associated-types/associated-types-overridden-binding-2.rs index 109feb8e969a5..525c4c81ed978 100644 --- a/src/test/ui/associated-types/associated-types-overridden-binding-2.rs +++ b/src/test/ui/associated-types/associated-types-overridden-binding-2.rs @@ -4,5 +4,5 @@ trait I32Iterator = Iterator; fn main() { let _: &dyn I32Iterator = &vec![42].into_iter(); - //~^ ERROR type mismatch + //~^ ERROR expected `std::vec::IntoIter` to be an iterator of `i32`, but it actually returns items of `u32` } diff --git a/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr b/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr index dbd9a44ed9774..f7a1603844be7 100644 --- a/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr +++ b/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving ` as Iterator>::Item == i32` +error[E0271]: expected `std::vec::IntoIter` to be an iterator of `i32`, but it actually returns items of `u32` --> $DIR/associated-types-overridden-binding-2.rs:6:43 | LL | let _: &dyn I32Iterator = &vec![42].into_iter(); diff --git a/src/test/ui/async-await/async-block-control-flow-static-semantics.rs b/src/test/ui/async-await/async-block-control-flow-static-semantics.rs index b831d61023277..3f8cb7a529174 100644 --- a/src/test/ui/async-await/async-block-control-flow-static-semantics.rs +++ b/src/test/ui/async-await/async-block-control-flow-static-semantics.rs @@ -15,7 +15,7 @@ fn return_targets_async_block_not_fn() -> u8 { return 0u8; }; let _: &dyn Future = █ - //~^ ERROR type mismatch + //~^ ERROR expected `impl Future` to be a future that yields `()`, but it actually yields `u8` } async fn return_targets_async_block_not_async_fn() -> u8 { @@ -24,7 +24,7 @@ async fn return_targets_async_block_not_async_fn() -> u8 { return 0u8; }; let _: &dyn Future = █ - //~^ ERROR type mismatch resolving ` as Future>::Output == ()` + //~^ ERROR expected `impl Future` to be a future that yields `()`, but it actually yields `u8` } fn no_break_in_async_block() { diff --git a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr index e5887689690e7..3d9adc04e17b3 100644 --- a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr +++ b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr @@ -31,7 +31,7 @@ LL | | LL | | } | |_^ expected `u8`, found `()` -error[E0271]: type mismatch resolving ` as Future>::Output == ()` +error[E0271]: expected `impl Future` to be a future that yields `()`, but it actually yields `u8` --> $DIR/async-block-control-flow-static-semantics.rs:26:39 | LL | let _: &dyn Future = █ @@ -47,7 +47,7 @@ LL | fn return_targets_async_block_not_fn() -> u8 { | | | implicitly returns `()` as its body has no tail or `return` expression -error[E0271]: type mismatch resolving ` as Future>::Output == ()` +error[E0271]: expected `impl Future` to be a future that yields `()`, but it actually yields `u8` --> $DIR/async-block-control-flow-static-semantics.rs:17:39 | LL | let _: &dyn Future = █ diff --git a/src/test/ui/hrtb/issue-62203-hrtb-ice.rs b/src/test/ui/hrtb/issue-62203-hrtb-ice.rs index 80f099ce3c802..19d7ff804e40c 100644 --- a/src/test/ui/hrtb/issue-62203-hrtb-ice.rs +++ b/src/test/ui/hrtb/issue-62203-hrtb-ice.rs @@ -38,7 +38,7 @@ fn main() { let v = Unit2.m( //~^ ERROR type mismatch L { - //~^ ERROR type mismatch + //~^ ERROR to be a closure that returns `Unit3`, but it actually returns `Unit4` f : |x| { drop(x); Unit4 } }); } diff --git a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr index 79ef56b9fa5cb..e3055c1265eb7 100644 --- a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr +++ b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr @@ -22,7 +22,7 @@ LL | where LL | F: for<'r> T0<'r, (>::V,), O = >::V>, | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m` -error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20] as FnOnce<((&'r u8,),)>>::Output == Unit3` +error[E0271]: expected `[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20]` to be a closure that returns `Unit3`, but it actually returns `Unit4` --> $DIR/issue-62203-hrtb-ice.rs:40:9 | LL | let v = Unit2.m( diff --git a/src/test/ui/impl-trait/issues/issue-78722.rs b/src/test/ui/impl-trait/issues/issue-78722.rs index 002e4cde40abe..2d2b8192adc05 100644 --- a/src/test/ui/impl-trait/issues/issue-78722.rs +++ b/src/test/ui/impl-trait/issues/issue-78722.rs @@ -7,7 +7,7 @@ type F = impl core::future::Future; struct Bug { V1: [(); { fn concrete_use() -> F { - //~^ ERROR type mismatch + //~^ ERROR expected `impl Future` to be a future that yields `u8`, but it actually yields `()` async {} } let f: F = async { 1 }; diff --git a/src/test/ui/impl-trait/issues/issue-78722.stderr b/src/test/ui/impl-trait/issues/issue-78722.stderr index 690d6abc76663..f98655e9dffce 100644 --- a/src/test/ui/impl-trait/issues/issue-78722.stderr +++ b/src/test/ui/impl-trait/issues/issue-78722.stderr @@ -16,7 +16,7 @@ LL | let f: F = async { 1 }; LL | }], | - value is dropped here -error[E0271]: type mismatch resolving ` as Future>::Output == u8` +error[E0271]: expected `impl Future` to be a future that yields `u8`, but it actually yields `()` --> $DIR/issue-78722.rs:9:30 | LL | fn concrete_use() -> F { diff --git a/src/test/ui/intrinsics/const-eval-select-bad.rs b/src/test/ui/intrinsics/const-eval-select-bad.rs index 52f4e594f1a0a..23b3f4fd82507 100644 --- a/src/test/ui/intrinsics/const-eval-select-bad.rs +++ b/src/test/ui/intrinsics/const-eval-select-bad.rs @@ -27,7 +27,7 @@ fn baz(n: bool) -> i32 { const fn return_ty_mismatch() { const_eval_select((1,), foo, bar); - //~^ ERROR type mismatch + //~^ ERROR expected `fn(i32) -> bool {bar}` to be a fn item that returns `i32`, but it actually returns `bool` } const fn args_ty_mismatch() { diff --git a/src/test/ui/intrinsics/const-eval-select-bad.stderr b/src/test/ui/intrinsics/const-eval-select-bad.stderr index 89dba12c818c8..efdb5c86508dc 100644 --- a/src/test/ui/intrinsics/const-eval-select-bad.stderr +++ b/src/test/ui/intrinsics/const-eval-select-bad.stderr @@ -51,7 +51,7 @@ note: required by a bound in `const_eval_select` LL | G: FnOnce + ~const Destruct, | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select` -error[E0271]: type mismatch resolving ` bool {bar} as FnOnce<(i32,)>>::Output == i32` +error[E0271]: expected `fn(i32) -> bool {bar}` to be a fn item that returns `i32`, but it actually returns `bool` --> $DIR/const-eval-select-bad.rs:29:5 | LL | const_eval_select((1,), foo, bar); diff --git a/src/test/ui/issues/issue-31173.rs b/src/test/ui/issues/issue-31173.rs index 48061ae54ae20..04e19c41756c7 100644 --- a/src/test/ui/issues/issue-31173.rs +++ b/src/test/ui/issues/issue-31173.rs @@ -8,7 +8,7 @@ pub fn get_tok(it: &mut IntoIter) { false }) .cloned() - //~^ ERROR type mismatch resolving + //~^ ERROR to be an iterator of `&_`, but it actually returns items of `u8` .collect(); //~ ERROR the method } diff --git a/src/test/ui/issues/issue-31173.stderr b/src/test/ui/issues/issue-31173.stderr index 68337a715e14f..43011d0d3554b 100644 --- a/src/test/ui/issues/issue-31173.stderr +++ b/src/test/ui/issues/issue-31173.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving `, [closure@$DIR/issue-31173.rs:6:39: 6:43]> as Iterator>::Item == &_` +error[E0271]: expected `TakeWhile<&mut std::vec::IntoIter, [closure@$DIR/issue-31173.rs:6:39: 6:43]>` to be an iterator of `&_`, but it actually returns items of `u8` --> $DIR/issue-31173.rs:10:10 | LL | .cloned() diff --git a/src/test/ui/issues/issue-33941.rs b/src/test/ui/issues/issue-33941.rs index a1213623e6f94..906f77559b4f0 100644 --- a/src/test/ui/issues/issue-33941.rs +++ b/src/test/ui/issues/issue-33941.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; fn main() { - for _ in HashMap::new().iter().cloned() {} //~ ERROR type mismatch - //~^ ERROR type mismatch - //~| ERROR type mismatch + for _ in HashMap::new().iter().cloned() {} //~ ERROR expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator of `&_`, but it actually returns items of `(&_, &_)` + //~^ ERROR expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator of `&_`, but it actually returns items of `(&_, &_)` + //~| ERROR expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator of `&_`, but it actually returns items of `(&_, &_)` } diff --git a/src/test/ui/issues/issue-33941.stderr b/src/test/ui/issues/issue-33941.stderr index e1ce6eed98efb..750f14c823901 100644 --- a/src/test/ui/issues/issue-33941.stderr +++ b/src/test/ui/issues/issue-33941.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving ` as Iterator>::Item == &_` +error[E0271]: expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator of `&_`, but it actually returns items of `(&_, &_)` --> $DIR/issue-33941.rs:6:36 | LL | for _ in HashMap::new().iter().cloned() {} @@ -12,7 +12,7 @@ note: required by a bound in `cloned` LL | Self: Sized + Iterator, | ^^^^^^^^^^^^ required by this bound in `cloned` -error[E0271]: type mismatch resolving ` as Iterator>::Item == &_` +error[E0271]: expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator of `&_`, but it actually returns items of `(&_, &_)` --> $DIR/issue-33941.rs:6:14 | LL | for _ in HashMap::new().iter().cloned() {} @@ -23,7 +23,7 @@ LL | for _ in HashMap::new().iter().cloned() {} = note: required because of the requirements on the impl of `Iterator` for `Cloned>` = note: required because of the requirements on the impl of `IntoIterator` for `Cloned>` -error[E0271]: type mismatch resolving ` as Iterator>::Item == &_` +error[E0271]: expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator of `&_`, but it actually returns items of `(&_, &_)` --> $DIR/issue-33941.rs:6:14 | LL | for _ in HashMap::new().iter().cloned() {} diff --git a/src/test/ui/never_type/fallback-closure-wrap.fallback.stderr b/src/test/ui/never_type/fallback-closure-wrap.fallback.stderr index 2acf44432c65f..e1b6fee2cccbe 100644 --- a/src/test/ui/never_type/fallback-closure-wrap.fallback.stderr +++ b/src/test/ui/never_type/fallback-closure-wrap.fallback.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving `<[closure@$DIR/fallback-closure-wrap.rs:18:40: 18:47] as FnOnce<()>>::Output == ()` +error[E0271]: expected `[closure@$DIR/fallback-closure-wrap.rs:18:40: 18:47]` to be a closure that returns `()`, but it actually returns `!` --> $DIR/fallback-closure-wrap.rs:18:31 | LL | let error = Closure::wrap(Box::new(move || { diff --git a/src/test/ui/never_type/fallback-closure-wrap.rs b/src/test/ui/never_type/fallback-closure-wrap.rs index af0577ac0609f..e9c343efb66d2 100644 --- a/src/test/ui/never_type/fallback-closure-wrap.rs +++ b/src/test/ui/never_type/fallback-closure-wrap.rs @@ -16,7 +16,7 @@ use std::marker::PhantomData; fn main() { let error = Closure::wrap(Box::new(move || { - //[fallback]~^ ERROR type mismatch resolving + //[fallback]~^ to be a closure that returns `()`, but it actually returns `!` panic!("Can't connect to server."); }) as Box); } diff --git a/src/test/ui/traits/assoc-type-in-superbad.rs b/src/test/ui/traits/assoc-type-in-superbad.rs index 579ce7cf70669..925f84db37ad0 100644 --- a/src/test/ui/traits/assoc-type-in-superbad.rs +++ b/src/test/ui/traits/assoc-type-in-superbad.rs @@ -9,7 +9,8 @@ pub trait Foo: Iterator::Key> { } impl Foo for IntoIter { - type Key = u32; //~ ERROR type mismatch + type Key = u32; + //~^ ERROR expected `std::vec::IntoIter` to be an iterator of `u32`, but it actually returns items of `i32` } fn main() { diff --git a/src/test/ui/traits/assoc-type-in-superbad.stderr b/src/test/ui/traits/assoc-type-in-superbad.stderr index f36947914179c..db691210b9c17 100644 --- a/src/test/ui/traits/assoc-type-in-superbad.stderr +++ b/src/test/ui/traits/assoc-type-in-superbad.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving ` as Iterator>::Item == u32` +error[E0271]: expected `std::vec::IntoIter` to be an iterator of `u32`, but it actually returns items of `i32` --> $DIR/assoc-type-in-superbad.rs:12:16 | LL | type Key = u32; diff --git a/src/test/ui/type-alias-impl-trait/issue-57961.rs b/src/test/ui/type-alias-impl-trait/issue-57961.rs index 472886c9caa23..639f3b7216503 100644 --- a/src/test/ui/type-alias-impl-trait/issue-57961.rs +++ b/src/test/ui/type-alias-impl-trait/issue-57961.rs @@ -8,7 +8,7 @@ trait Foo { impl Foo for () { type Bar = std::vec::IntoIter; - //~^ ERROR type mismatch resolving ` as Iterator>::Item == X + //~^ ERROR expected `std::vec::IntoIter` to be an iterator of `X`, but it actually returns items of `u32` } fn incoherent() { diff --git a/src/test/ui/type-alias-impl-trait/issue-57961.stderr b/src/test/ui/type-alias-impl-trait/issue-57961.stderr index ed4caf6ce68d6..907f10cc9a5f4 100644 --- a/src/test/ui/type-alias-impl-trait/issue-57961.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-57961.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving ` as Iterator>::Item == X` +error[E0271]: expected `std::vec::IntoIter` to be an iterator of `X`, but it actually returns items of `u32` --> $DIR/issue-57961.rs:10:16 | LL | type X = impl Sized; diff --git a/src/test/ui/type-alias-impl-trait/issue-98604.rs b/src/test/ui/type-alias-impl-trait/issue-98604.rs index a4fd8a82a04fd..a2f29afd94c46 100644 --- a/src/test/ui/type-alias-impl-trait/issue-98604.rs +++ b/src/test/ui/type-alias-impl-trait/issue-98604.rs @@ -9,5 +9,5 @@ async fn test() {} #[allow(unused_must_use)] fn main() { Box::new(test) as AsyncFnPtr; - //~^ ERROR type mismatch + //~^ ERROR expected `fn() -> impl Future {test}` to be a fn item that returns `Pin + 'static)>>`, but it actually returns `impl Future` } diff --git a/src/test/ui/type-alias-impl-trait/issue-98604.stderr b/src/test/ui/type-alias-impl-trait/issue-98604.stderr index f04d1b4d7877e..5c8aae0da2e77 100644 --- a/src/test/ui/type-alias-impl-trait/issue-98604.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-98604.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving ` impl Future {test} as FnOnce<()>>::Output == Pin + 'static)>>` +error[E0271]: expected `fn() -> impl Future {test}` to be a fn item that returns `Pin + 'static)>>`, but it actually returns `impl Future` --> $DIR/issue-98604.rs:11:5 | LL | Box::new(test) as AsyncFnPtr; diff --git a/src/test/ui/type-alias-impl-trait/issue-98608.rs b/src/test/ui/type-alias-impl-trait/issue-98608.rs index d75762a8b62f0..2f4cf7a052146 100644 --- a/src/test/ui/type-alias-impl-trait/issue-98608.rs +++ b/src/test/ui/type-alias-impl-trait/issue-98608.rs @@ -2,7 +2,7 @@ fn hi() -> impl Sized { std::ptr::null::() } fn main() { let b: Box Box> = Box::new(hi); - //~^ ERROR type mismatch resolving ` impl Sized {hi} as FnOnce<()>>::Output == Box` + //~^ ERROR expected `fn() -> impl Sized {hi}` to be a fn item that returns `Box`, but it actually returns `impl Sized` let boxed = b(); let null = *boxed; println!("{null:?}"); diff --git a/src/test/ui/type-alias-impl-trait/issue-98608.stderr b/src/test/ui/type-alias-impl-trait/issue-98608.stderr index 8f3ec7d9d1616..c5eed7561c0df 100644 --- a/src/test/ui/type-alias-impl-trait/issue-98608.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-98608.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving ` impl Sized {hi} as FnOnce<()>>::Output == Box` +error[E0271]: expected `fn() -> impl Sized {hi}` to be a fn item that returns `Box`, but it actually returns `impl Sized` --> $DIR/issue-98608.rs:4:39 | LL | fn hi() -> impl Sized { std::ptr::null::() } From 3fdf3cb80cc262e71461b6809b0e320a1958b03c Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 8 Aug 2022 00:13:41 +0000 Subject: [PATCH 2/2] Adjust wording --- .../src/traits/error_reporting/mod.rs | 6 +++--- .../associated-types-overridden-binding-2.rs | 2 +- ...ssociated-types-overridden-binding-2.stderr | 2 +- ...sync-block-control-flow-static-semantics.rs | 8 +++++--- ...-block-control-flow-static-semantics.stderr | 8 ++++---- src/test/ui/hrtb/issue-62203-hrtb-ice.rs | 10 +++++++--- src/test/ui/hrtb/issue-62203-hrtb-ice.stderr | 15 +++++++++------ src/test/ui/impl-trait/issues/issue-78722.rs | 2 +- .../ui/impl-trait/issues/issue-78722.stderr | 2 +- .../ui/intrinsics/const-eval-select-bad.rs | 2 +- .../ui/intrinsics/const-eval-select-bad.stderr | 2 +- src/test/ui/issues/issue-31173.rs | 11 ++++++----- src/test/ui/issues/issue-31173.stderr | 18 +++++++++--------- src/test/ui/issues/issue-33941.rs | 6 +++--- src/test/ui/issues/issue-33941.stderr | 6 +++--- .../fallback-closure-wrap.fallback.stderr | 2 +- .../ui/never_type/fallback-closure-wrap.rs | 2 +- src/test/ui/traits/assoc-type-in-superbad.rs | 7 +++---- .../ui/traits/assoc-type-in-superbad.stderr | 6 +++--- .../ui/type-alias-impl-trait/issue-57961.rs | 2 +- .../type-alias-impl-trait/issue-57961.stderr | 2 +- .../ui/type-alias-impl-trait/issue-98604.rs | 6 ++---- .../type-alias-impl-trait/issue-98604.stderr | 6 +++--- .../ui/type-alias-impl-trait/issue-98608.rs | 6 ++++-- .../type-alias-impl-trait/issue-98608.stderr | 6 +++--- 25 files changed, 77 insertions(+), 68 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 911fb094b0cbe..e4f918b4b0eae 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1626,16 +1626,16 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { if Some(pred.projection_ty.item_def_id) == self.tcx.lang_items().fn_once_output() { Some(format!( - "expected `{self_ty}` to be a {fn_kind} that returns `{expected_ty}`, but it actually returns `{normalized_ty}`", + "expected `{self_ty}` to be a {fn_kind} that returns `{expected_ty}`, but it returns `{normalized_ty}`", fn_kind = self_ty.prefix_string(self.tcx) )) } else if Some(trait_def_id) == self.tcx.lang_items().future_trait() { Some(format!( - "expected `{self_ty}` to be a future that yields `{expected_ty}`, but it actually yields `{normalized_ty}`" + "expected `{self_ty}` to be a future that resolves to `{expected_ty}`, but it resolves to `{normalized_ty}`" )) } else if Some(trait_def_id) == self.tcx.get_diagnostic_item(sym::Iterator) { Some(format!( - "expected `{self_ty}` to be an iterator of `{expected_ty}`, but it actually returns items of `{normalized_ty}`" + "expected `{self_ty}` to be an iterator that yields `{expected_ty}`, but it yields `{normalized_ty}`" )) } else { None diff --git a/src/test/ui/associated-types/associated-types-overridden-binding-2.rs b/src/test/ui/associated-types/associated-types-overridden-binding-2.rs index 525c4c81ed978..26b9f4b3a9266 100644 --- a/src/test/ui/associated-types/associated-types-overridden-binding-2.rs +++ b/src/test/ui/associated-types/associated-types-overridden-binding-2.rs @@ -4,5 +4,5 @@ trait I32Iterator = Iterator; fn main() { let _: &dyn I32Iterator = &vec![42].into_iter(); - //~^ ERROR expected `std::vec::IntoIter` to be an iterator of `i32`, but it actually returns items of `u32` + //~^ ERROR expected `std::vec::IntoIter` to be an iterator that yields `i32`, but it yields `u32` } diff --git a/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr b/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr index f7a1603844be7..2d25f68de44ad 100644 --- a/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr +++ b/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `std::vec::IntoIter` to be an iterator of `i32`, but it actually returns items of `u32` +error[E0271]: expected `std::vec::IntoIter` to be an iterator that yields `i32`, but it yields `u32` --> $DIR/associated-types-overridden-binding-2.rs:6:43 | LL | let _: &dyn I32Iterator = &vec![42].into_iter(); diff --git a/src/test/ui/async-await/async-block-control-flow-static-semantics.rs b/src/test/ui/async-await/async-block-control-flow-static-semantics.rs index 3f8cb7a529174..446212ca767c4 100644 --- a/src/test/ui/async-await/async-block-control-flow-static-semantics.rs +++ b/src/test/ui/async-await/async-block-control-flow-static-semantics.rs @@ -15,7 +15,7 @@ fn return_targets_async_block_not_fn() -> u8 { return 0u8; }; let _: &dyn Future = █ - //~^ ERROR expected `impl Future` to be a future that yields `()`, but it actually yields `u8` + //~^ ERROR expected `impl Future` to be a future that resolves to `()`, but it resolves to `u8` } async fn return_targets_async_block_not_async_fn() -> u8 { @@ -24,7 +24,7 @@ async fn return_targets_async_block_not_async_fn() -> u8 { return 0u8; }; let _: &dyn Future = █ - //~^ ERROR expected `impl Future` to be a future that yields `()`, but it actually yields `u8` + //~^ ERROR expected `impl Future` to be a future that resolves to `()`, but it resolves to `u8` } fn no_break_in_async_block() { @@ -42,7 +42,9 @@ fn no_break_in_async_block_even_with_outer_loop() { } struct MyErr; -fn err() -> Result { Err(MyErr) } +fn err() -> Result { + Err(MyErr) +} fn rethrow_targets_async_block_not_fn() -> Result { //~^ ERROR mismatched types diff --git a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr index 3d9adc04e17b3..2a08d5d6ce5f8 100644 --- a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr +++ b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr @@ -31,7 +31,7 @@ LL | | LL | | } | |_^ expected `u8`, found `()` -error[E0271]: expected `impl Future` to be a future that yields `()`, but it actually yields `u8` +error[E0271]: expected `impl Future` to be a future that resolves to `()`, but it resolves to `u8` --> $DIR/async-block-control-flow-static-semantics.rs:26:39 | LL | let _: &dyn Future = █ @@ -47,7 +47,7 @@ LL | fn return_targets_async_block_not_fn() -> u8 { | | | implicitly returns `()` as its body has no tail or `return` expression -error[E0271]: expected `impl Future` to be a future that yields `()`, but it actually yields `u8` +error[E0271]: expected `impl Future` to be a future that resolves to `()`, but it resolves to `u8` --> $DIR/async-block-control-flow-static-semantics.rs:17:39 | LL | let _: &dyn Future = █ @@ -56,7 +56,7 @@ LL | let _: &dyn Future = █ = note: required for the cast from `impl Future` to the object type `dyn Future` error[E0308]: mismatched types - --> $DIR/async-block-control-flow-static-semantics.rs:47:44 + --> $DIR/async-block-control-flow-static-semantics.rs:49:44 | LL | fn rethrow_targets_async_block_not_fn() -> Result { | ---------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `Result`, found `()` @@ -67,7 +67,7 @@ LL | fn rethrow_targets_async_block_not_fn() -> Result { found unit type `()` error[E0308]: mismatched types - --> $DIR/async-block-control-flow-static-semantics.rs:56:50 + --> $DIR/async-block-control-flow-static-semantics.rs:58:50 | LL | fn rethrow_targets_async_block_not_async_fn() -> Result { | ---------------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `Result`, found `()` diff --git a/src/test/ui/hrtb/issue-62203-hrtb-ice.rs b/src/test/ui/hrtb/issue-62203-hrtb-ice.rs index 19d7ff804e40c..ae21dbce01139 100644 --- a/src/test/ui/hrtb/issue-62203-hrtb-ice.rs +++ b/src/test/ui/hrtb/issue-62203-hrtb-ice.rs @@ -38,9 +38,13 @@ fn main() { let v = Unit2.m( //~^ ERROR type mismatch L { - //~^ ERROR to be a closure that returns `Unit3`, but it actually returns `Unit4` - f : |x| { drop(x); Unit4 } - }); + //~^ ERROR to be a closure that returns `Unit3`, but it returns `Unit4` + f: |x| { + drop(x); + Unit4 + }, + }, + ); } impl<'a> Ty<'a> for Unit2 { diff --git a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr index e3055c1265eb7..8365fd0c79e1b 100644 --- a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr +++ b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr @@ -1,8 +1,8 @@ -error[E0271]: type mismatch resolving `for<'r> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V` +error[E0271]: type mismatch resolving `for<'r> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V` --> $DIR/issue-62203-hrtb-ice.rs:38:19 | LL | let v = Unit2.m( - | ^ type mismatch resolving `for<'r> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V` + | ^ type mismatch resolving `for<'r> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V` | note: expected this to be `<_ as Ty<'_>>::V` --> $DIR/issue-62203-hrtb-ice.rs:21:14 @@ -22,7 +22,7 @@ LL | where LL | F: for<'r> T0<'r, (>::V,), O = >::V>, | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m` -error[E0271]: expected `[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20]` to be a closure that returns `Unit3`, but it actually returns `Unit4` +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` --> $DIR/issue-62203-hrtb-ice.rs:40:9 | LL | let v = Unit2.m( @@ -30,11 +30,14 @@ LL | let v = Unit2.m( LL | LL | / L { LL | | -LL | | f : |x| { drop(x); Unit4 } -LL | | }); +LL | | f: |x| { +LL | | drop(x); +LL | | Unit4 +LL | | }, +LL | | }, | |_________^ expected struct `Unit3`, found struct `Unit4` | -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]>` +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]>` --> $DIR/issue-62203-hrtb-ice.rs:17:16 | LL | impl<'a, A, T> T0<'a, A> for L diff --git a/src/test/ui/impl-trait/issues/issue-78722.rs b/src/test/ui/impl-trait/issues/issue-78722.rs index 2d2b8192adc05..90d1cd3798a83 100644 --- a/src/test/ui/impl-trait/issues/issue-78722.rs +++ b/src/test/ui/impl-trait/issues/issue-78722.rs @@ -7,7 +7,7 @@ type F = impl core::future::Future; struct Bug { V1: [(); { fn concrete_use() -> F { - //~^ ERROR expected `impl Future` to be a future that yields `u8`, but it actually yields `()` + //~^ ERROR expected `impl Future` to be a future that resolves to `u8`, but it resolves to `()` async {} } let f: F = async { 1 }; diff --git a/src/test/ui/impl-trait/issues/issue-78722.stderr b/src/test/ui/impl-trait/issues/issue-78722.stderr index f98655e9dffce..9a0ffbc89d92e 100644 --- a/src/test/ui/impl-trait/issues/issue-78722.stderr +++ b/src/test/ui/impl-trait/issues/issue-78722.stderr @@ -16,7 +16,7 @@ LL | let f: F = async { 1 }; LL | }], | - value is dropped here -error[E0271]: expected `impl Future` to be a future that yields `u8`, but it actually yields `()` +error[E0271]: expected `impl Future` to be a future that resolves to `u8`, but it resolves to `()` --> $DIR/issue-78722.rs:9:30 | LL | fn concrete_use() -> F { diff --git a/src/test/ui/intrinsics/const-eval-select-bad.rs b/src/test/ui/intrinsics/const-eval-select-bad.rs index 23b3f4fd82507..e5640f5ab53b1 100644 --- a/src/test/ui/intrinsics/const-eval-select-bad.rs +++ b/src/test/ui/intrinsics/const-eval-select-bad.rs @@ -27,7 +27,7 @@ fn baz(n: bool) -> i32 { const fn return_ty_mismatch() { const_eval_select((1,), foo, bar); - //~^ ERROR expected `fn(i32) -> bool {bar}` to be a fn item that returns `i32`, but it actually returns `bool` + //~^ ERROR expected `fn(i32) -> bool {bar}` to be a fn item that returns `i32`, but it returns `bool` } const fn args_ty_mismatch() { diff --git a/src/test/ui/intrinsics/const-eval-select-bad.stderr b/src/test/ui/intrinsics/const-eval-select-bad.stderr index efdb5c86508dc..e7b7e4a4a910c 100644 --- a/src/test/ui/intrinsics/const-eval-select-bad.stderr +++ b/src/test/ui/intrinsics/const-eval-select-bad.stderr @@ -51,7 +51,7 @@ note: required by a bound in `const_eval_select` LL | G: FnOnce + ~const Destruct, | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select` -error[E0271]: expected `fn(i32) -> bool {bar}` to be a fn item that returns `i32`, but it actually returns `bool` +error[E0271]: expected `fn(i32) -> bool {bar}` to be a fn item that returns `i32`, but it returns `bool` --> $DIR/const-eval-select-bad.rs:29:5 | LL | const_eval_select((1,), foo, bar); diff --git a/src/test/ui/issues/issue-31173.rs b/src/test/ui/issues/issue-31173.rs index 04e19c41756c7..472a95d4636bc 100644 --- a/src/test/ui/issues/issue-31173.rs +++ b/src/test/ui/issues/issue-31173.rs @@ -3,12 +3,13 @@ use std::vec::IntoIter; pub fn get_tok(it: &mut IntoIter) { let mut found_e = false; - let temp: Vec = it.take_while(|&x| { - found_e = true; - false - }) + let temp: Vec = it + .take_while(|&x| { + found_e = true; + false + }) .cloned() - //~^ ERROR to be an iterator of `&_`, but it actually returns items of `u8` + //~^ ERROR to be an iterator that yields `&_`, but it yields `u8` .collect(); //~ ERROR the method } diff --git a/src/test/ui/issues/issue-31173.stderr b/src/test/ui/issues/issue-31173.stderr index 43011d0d3554b..e89105540dfb2 100644 --- a/src/test/ui/issues/issue-31173.stderr +++ b/src/test/ui/issues/issue-31173.stderr @@ -1,5 +1,5 @@ -error[E0271]: expected `TakeWhile<&mut std::vec::IntoIter, [closure@$DIR/issue-31173.rs:6:39: 6:43]>` to be an iterator of `&_`, but it actually returns items of `u8` - --> $DIR/issue-31173.rs:10:10 +error[E0271]: expected `TakeWhile<&mut std::vec::IntoIter, [closure@$DIR/issue-31173.rs:7:21: 7:25]>` to be an iterator that yields `&_`, but it yields `u8` + --> $DIR/issue-31173.rs:11:10 | LL | .cloned() | ^^^^^^ expected reference, found `u8` @@ -12,11 +12,11 @@ note: required by a bound in `cloned` LL | Self: Sized + Iterator, | ^^^^^^^^^^^^ required by this bound in `cloned` -error[E0599]: the method `collect` exists for struct `Cloned, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>`, but its trait bounds were not satisfied - --> $DIR/issue-31173.rs:12:10 +error[E0599]: the method `collect` exists for struct `Cloned, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>`, but its trait bounds were not satisfied + --> $DIR/issue-31173.rs:13:10 | LL | .collect(); - | ^^^^^^^ method cannot be called on `Cloned, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>` due to unsatisfied trait bounds + | ^^^^^^^ method cannot be called on `Cloned, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>` due to unsatisfied trait bounds | ::: $SRC_DIR/core/src/iter/adapters/cloned.rs:LL:COL | @@ -29,10 +29,10 @@ LL | pub struct TakeWhile { | -------------------------- doesn't satisfy `<_ as Iterator>::Item = &_` | = note: the following trait bounds were not satisfied: - `, [closure@$DIR/issue-31173.rs:6:39: 6:43]> as Iterator>::Item = &_` - which is required by `Cloned, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>: Iterator` - `Cloned, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>: Iterator` - which is required by `&mut Cloned, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>: Iterator` + `, [closure@$DIR/issue-31173.rs:7:21: 7:25]> as Iterator>::Item = &_` + which is required by `Cloned, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>: Iterator` + `Cloned, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>: Iterator` + which is required by `&mut Cloned, [closure@$DIR/issue-31173.rs:7:21: 7:25]>>: Iterator` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-33941.rs b/src/test/ui/issues/issue-33941.rs index 906f77559b4f0..8430e85df8715 100644 --- a/src/test/ui/issues/issue-33941.rs +++ b/src/test/ui/issues/issue-33941.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; fn main() { - for _ in HashMap::new().iter().cloned() {} //~ ERROR expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator of `&_`, but it actually returns items of `(&_, &_)` - //~^ ERROR expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator of `&_`, but it actually returns items of `(&_, &_)` - //~| ERROR expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator of `&_`, but it actually returns items of `(&_, &_)` + for _ in HashMap::new().iter().cloned() {} //~ ERROR expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` + //~^ ERROR expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` + //~| ERROR expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` } diff --git a/src/test/ui/issues/issue-33941.stderr b/src/test/ui/issues/issue-33941.stderr index 750f14c823901..565a7fef37941 100644 --- a/src/test/ui/issues/issue-33941.stderr +++ b/src/test/ui/issues/issue-33941.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator of `&_`, but it actually returns items of `(&_, &_)` +error[E0271]: expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` --> $DIR/issue-33941.rs:6:36 | LL | for _ in HashMap::new().iter().cloned() {} @@ -12,7 +12,7 @@ note: required by a bound in `cloned` LL | Self: Sized + Iterator, | ^^^^^^^^^^^^ required by this bound in `cloned` -error[E0271]: expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator of `&_`, but it actually returns items of `(&_, &_)` +error[E0271]: expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` --> $DIR/issue-33941.rs:6:14 | LL | for _ in HashMap::new().iter().cloned() {} @@ -23,7 +23,7 @@ LL | for _ in HashMap::new().iter().cloned() {} = note: required because of the requirements on the impl of `Iterator` for `Cloned>` = note: required because of the requirements on the impl of `IntoIterator` for `Cloned>` -error[E0271]: expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator of `&_`, but it actually returns items of `(&_, &_)` +error[E0271]: expected `std::collections::hash_map::Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` --> $DIR/issue-33941.rs:6:14 | LL | for _ in HashMap::new().iter().cloned() {} diff --git a/src/test/ui/never_type/fallback-closure-wrap.fallback.stderr b/src/test/ui/never_type/fallback-closure-wrap.fallback.stderr index e1b6fee2cccbe..45cf3723483f3 100644 --- a/src/test/ui/never_type/fallback-closure-wrap.fallback.stderr +++ b/src/test/ui/never_type/fallback-closure-wrap.fallback.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `[closure@$DIR/fallback-closure-wrap.rs:18:40: 18:47]` to be a closure that returns `()`, but it actually returns `!` +error[E0271]: expected `[closure@$DIR/fallback-closure-wrap.rs:18:40: 18:47]` to be a closure that returns `()`, but it returns `!` --> $DIR/fallback-closure-wrap.rs:18:31 | LL | let error = Closure::wrap(Box::new(move || { diff --git a/src/test/ui/never_type/fallback-closure-wrap.rs b/src/test/ui/never_type/fallback-closure-wrap.rs index e9c343efb66d2..35052da6760b6 100644 --- a/src/test/ui/never_type/fallback-closure-wrap.rs +++ b/src/test/ui/never_type/fallback-closure-wrap.rs @@ -16,7 +16,7 @@ use std::marker::PhantomData; fn main() { let error = Closure::wrap(Box::new(move || { - //[fallback]~^ to be a closure that returns `()`, but it actually returns `!` + //[fallback]~^ to be a closure that returns `()`, but it returns `!` panic!("Can't connect to server."); }) as Box); } diff --git a/src/test/ui/traits/assoc-type-in-superbad.rs b/src/test/ui/traits/assoc-type-in-superbad.rs index 925f84db37ad0..d7d6241ef708c 100644 --- a/src/test/ui/traits/assoc-type-in-superbad.rs +++ b/src/test/ui/traits/assoc-type-in-superbad.rs @@ -4,14 +4,13 @@ use std::vec::IntoIter; -pub trait Foo: Iterator::Key> { +pub trait Foo: Iterator::Key> { type Key; } impl Foo for IntoIter { type Key = u32; - //~^ ERROR expected `std::vec::IntoIter` to be an iterator of `u32`, but it actually returns items of `i32` + //~^ ERROR expected `std::vec::IntoIter` to be an iterator that yields `u32`, but it yields `i32` } -fn main() { -} +fn main() {} diff --git a/src/test/ui/traits/assoc-type-in-superbad.stderr b/src/test/ui/traits/assoc-type-in-superbad.stderr index db691210b9c17..3e2d9d9038aa7 100644 --- a/src/test/ui/traits/assoc-type-in-superbad.stderr +++ b/src/test/ui/traits/assoc-type-in-superbad.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `std::vec::IntoIter` to be an iterator of `u32`, but it actually returns items of `i32` +error[E0271]: expected `std::vec::IntoIter` to be an iterator that yields `u32`, but it yields `i32` --> $DIR/assoc-type-in-superbad.rs:12:16 | LL | type Key = u32; @@ -7,8 +7,8 @@ LL | type Key = u32; note: required by a bound in `Foo` --> $DIR/assoc-type-in-superbad.rs:7:25 | -LL | pub trait Foo: Iterator::Key> { - | ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo` +LL | pub trait Foo: Iterator::Key> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo` error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/issue-57961.rs b/src/test/ui/type-alias-impl-trait/issue-57961.rs index 639f3b7216503..24b3a045856a6 100644 --- a/src/test/ui/type-alias-impl-trait/issue-57961.rs +++ b/src/test/ui/type-alias-impl-trait/issue-57961.rs @@ -8,7 +8,7 @@ trait Foo { impl Foo for () { type Bar = std::vec::IntoIter; - //~^ ERROR expected `std::vec::IntoIter` to be an iterator of `X`, but it actually returns items of `u32` + //~^ ERROR expected `std::vec::IntoIter` to be an iterator that yields `X`, but it yields `u32` } fn incoherent() { diff --git a/src/test/ui/type-alias-impl-trait/issue-57961.stderr b/src/test/ui/type-alias-impl-trait/issue-57961.stderr index 907f10cc9a5f4..fb40895c49f15 100644 --- a/src/test/ui/type-alias-impl-trait/issue-57961.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-57961.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `std::vec::IntoIter` to be an iterator of `X`, but it actually returns items of `u32` +error[E0271]: expected `std::vec::IntoIter` to be an iterator that yields `X`, but it yields `u32` --> $DIR/issue-57961.rs:10:16 | LL | type X = impl Sized; diff --git a/src/test/ui/type-alias-impl-trait/issue-98604.rs b/src/test/ui/type-alias-impl-trait/issue-98604.rs index a2f29afd94c46..32c2f9ed51edf 100644 --- a/src/test/ui/type-alias-impl-trait/issue-98604.rs +++ b/src/test/ui/type-alias-impl-trait/issue-98604.rs @@ -1,13 +1,11 @@ // edition:2018 -type AsyncFnPtr = Box< - dyn Fn() -> std::pin::Pin>>, ->; +type AsyncFnPtr = Box std::pin::Pin>>>; async fn test() {} #[allow(unused_must_use)] fn main() { Box::new(test) as AsyncFnPtr; - //~^ ERROR expected `fn() -> impl Future {test}` to be a fn item that returns `Pin + 'static)>>`, but it actually returns `impl Future` + //~^ ERROR expected `fn() -> impl Future {test}` to be a fn item that returns `Pin + 'static)>>`, but it returns `impl Future` } diff --git a/src/test/ui/type-alias-impl-trait/issue-98604.stderr b/src/test/ui/type-alias-impl-trait/issue-98604.stderr index 5c8aae0da2e77..92d01eb0d3d5e 100644 --- a/src/test/ui/type-alias-impl-trait/issue-98604.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-98604.stderr @@ -1,11 +1,11 @@ -error[E0271]: expected `fn() -> impl Future {test}` to be a fn item that returns `Pin + 'static)>>`, but it actually returns `impl Future` - --> $DIR/issue-98604.rs:11:5 +error[E0271]: expected `fn() -> impl Future {test}` to be a fn item that returns `Pin + 'static)>>`, but it returns `impl Future` + --> $DIR/issue-98604.rs:9:5 | LL | Box::new(test) as AsyncFnPtr; | ^^^^^^^^^^^^^^ expected struct `Pin`, found opaque type | note: while checking the return type of the `async fn` - --> $DIR/issue-98604.rs:7:17 + --> $DIR/issue-98604.rs:5:17 | LL | async fn test() {} | ^ checked the `Output` of this `async fn`, found opaque type diff --git a/src/test/ui/type-alias-impl-trait/issue-98608.rs b/src/test/ui/type-alias-impl-trait/issue-98608.rs index 2f4cf7a052146..1f89af0457653 100644 --- a/src/test/ui/type-alias-impl-trait/issue-98608.rs +++ b/src/test/ui/type-alias-impl-trait/issue-98608.rs @@ -1,8 +1,10 @@ -fn hi() -> impl Sized { std::ptr::null::() } +fn hi() -> impl Sized { + std::ptr::null::() +} fn main() { let b: Box Box> = Box::new(hi); - //~^ ERROR expected `fn() -> impl Sized {hi}` to be a fn item that returns `Box`, but it actually returns `impl Sized` + //~^ ERROR expected `fn() -> impl Sized {hi}` to be a fn item that returns `Box`, but it returns `impl Sized` let boxed = b(); let null = *boxed; println!("{null:?}"); diff --git a/src/test/ui/type-alias-impl-trait/issue-98608.stderr b/src/test/ui/type-alias-impl-trait/issue-98608.stderr index c5eed7561c0df..916a58451baa2 100644 --- a/src/test/ui/type-alias-impl-trait/issue-98608.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-98608.stderr @@ -1,7 +1,7 @@ -error[E0271]: expected `fn() -> impl Sized {hi}` to be a fn item that returns `Box`, but it actually returns `impl Sized` - --> $DIR/issue-98608.rs:4:39 +error[E0271]: expected `fn() -> impl Sized {hi}` to be a fn item that returns `Box`, but it returns `impl Sized` + --> $DIR/issue-98608.rs:6:39 | -LL | fn hi() -> impl Sized { std::ptr::null::() } +LL | fn hi() -> impl Sized { | ---------- the found opaque type ... LL | let b: Box Box> = Box::new(hi);