diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 26b0faca258..8559ea1a058 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -1278,19 +1278,6 @@ pub(super) fn report_projection_error( let normalized_term = ocx.normalize(&obligation.cause, obligation.param_env, unnormalized_term); - let is_normalized_term_expected = !matches!( - obligation.cause.code().peel_derives(), - ObligationCauseCode::WhereClause(..) - | ObligationCauseCode::WhereClauseInExpr(..) - | ObligationCauseCode::Coercion { .. } - ); - - let (expected, actual) = if is_normalized_term_expected { - (normalized_term, data.term) - } else { - (data.term, normalized_term) - }; - // constrain inference variables a bit more to nested obligations from normalize so // we can have more helpful errors. // @@ -1299,12 +1286,12 @@ pub(super) fn report_projection_error( let _ = ocx.select_where_possible(); if let Err(new_err) = - ocx.eq(&obligation.cause, obligation.param_env, expected, actual) + ocx.eq(&obligation.cause, obligation.param_env, data.term, normalized_term) { ( Some(( data.projection_term, - is_normalized_term_expected, + false, self.resolve_vars_if_possible(normalized_term), data.term, )), @@ -1444,12 +1431,8 @@ pub(super) fn report_projection_error( &mut diag, &obligation.cause, secondary_span, - values.map(|(_, is_normalized_ty_expected, normalized_ty, expected_ty)| { - infer::ValuePairs::Terms(ExpectedFound::new( - is_normalized_ty_expected, - normalized_ty, - expected_ty, - )) + values.map(|(_, _, normalized_ty, expected_ty)| { + infer::ValuePairs::Terms(ExpectedFound::new(true, expected_ty, normalized_ty)) }), err, true, diff --git a/tests/ui/associated-types/impl-trait-return-missing-constraint.stderr b/tests/ui/associated-types/impl-trait-return-missing-constraint.stderr index 24409b32ad3..2c6c8ee5d19 100644 --- a/tests/ui/associated-types/impl-trait-return-missing-constraint.stderr +++ b/tests/ui/associated-types/impl-trait-return-missing-constraint.stderr @@ -2,18 +2,16 @@ error[E0271]: type mismatch resolving `::Item == i32` --> $DIR/impl-trait-return-missing-constraint.rs:25:13 | LL | fn bar() -> impl Bar { - | -------- the expected opaque type + | -------- the found opaque type ... LL | fn baz() -> impl Bar { - | ^^^^^^^^^^^^^^^^^^^^ expected associated type, found `i32` + | ^^^^^^^^^^^^^^^^^^^^ expected `i32`, found associated type LL | LL | bar() | ----- return type was inferred to be `impl Bar` here | - = note: expected associated type `::Item` - found type `i32` - = help: consider constraining the associated type `::Item` to `i32` or calling a method that returns `::Item` - = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + = note: expected type `i32` + found associated type `::Item` help: consider constraining the associated type `::Item` to `i32` | LL | fn bar() -> impl Bar { diff --git a/tests/ui/coroutine/type-mismatch-signature-deduction.stderr b/tests/ui/coroutine/type-mismatch-signature-deduction.stderr index 08927196037..64dc3a8b1f8 100644 --- a/tests/ui/coroutine/type-mismatch-signature-deduction.stderr +++ b/tests/ui/coroutine/type-mismatch-signature-deduction.stderr @@ -22,10 +22,10 @@ error[E0271]: type mismatch resolving `<{coroutine@$DIR/type-mismatch-signature- --> $DIR/type-mismatch-signature-deduction.rs:5:13 | LL | fn foo() -> impl Coroutine { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<{integer}, _>`, found `i32` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `Result<{integer}, _>` | - = note: expected enum `Result<{integer}, _>` - found type `i32` + = note: expected type `i32` + found enum `Result<{integer}, _>` error: aborting due to 2 previous errors diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr index a686b913c55..8c01b61191e 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr +++ b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr @@ -29,10 +29,7 @@ error[E0271]: type mismatch resolving `::SqlType == Tex --> $DIR/as_expression.rs:57:5 | LL | SelectInt.check("bar"); - | ^^^^^^^^^^^^^^^^^^^^^^ expected `Integer`, found `Text` - | - = note: expected struct `Integer` - found struct `Text` + | ^^^^^^^^^^^^^^^^^^^^^^ expected `Text`, found `Integer` error: aborting due to 3 previous errors diff --git a/tests/ui/impl-trait/bound-normalization-fail.stderr b/tests/ui/impl-trait/bound-normalization-fail.stderr index fcac9ac34db..fc124bd1171 100644 --- a/tests/ui/impl-trait/bound-normalization-fail.stderr +++ b/tests/ui/impl-trait/bound-normalization-fail.stderr @@ -7,13 +7,13 @@ LL | LL | Foo(()) | ------- return type was inferred to be `Foo<()>` here | -note: expected this to be `()` +note: expected this to be `::Assoc` --> $DIR/bound-normalization-fail.rs:14:19 | LL | type Output = T; | ^ - = note: expected unit type `()` - found associated type `::Assoc` + = note: expected associated type `::Assoc` + found unit type `()` help: consider constraining the associated type `::Assoc` to `()` | LL | fn foo_fail>() -> impl FooLike { @@ -28,13 +28,13 @@ LL | LL | Foo(()) | ------- return type was inferred to be `Foo<()>` here | -note: expected this to be `()` +note: expected this to be `>::Assoc` --> $DIR/bound-normalization-fail.rs:14:19 | LL | type Output = T; | ^ - = note: expected unit type `()` - found associated type `>::Assoc` + = note: expected associated type `>::Assoc` + found unit type `()` help: consider constraining the associated type `>::Assoc` to `()` | LL | fn foo2_fail<'a, T: Trait<'a, Assoc = ()>>() -> impl FooLike { diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err.stderr index 6f1ac4bce43..3c737f095ce 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err.stderr +++ b/tests/ui/impl-trait/in-trait/default-body-type-err.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String` --> $DIR/default-body-type-err.rs:4:22 | LL | fn lol(&self) -> impl Deref { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `String` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `String`, found `i32` LL | LL | &1i32 | ----- return type was inferred to be `&i32` here diff --git a/tests/ui/impl-trait/issues/issue-78722-2.stderr b/tests/ui/impl-trait/issues/issue-78722-2.stderr index 2cf6b94dd9d..27b4b712830 100644 --- a/tests/ui/impl-trait/issues/issue-78722-2.stderr +++ b/tests/ui/impl-trait/issues/issue-78722-2.stderr @@ -16,7 +16,7 @@ error[E0271]: expected `{async block@$DIR/issue-78722-2.rs:13:13: 13:18}` to be --> $DIR/issue-78722-2.rs:11:30 | LL | fn concrete_use() -> F { - | ^ expected `()`, found `u8` + | ^ expected `u8`, found `()` error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/issues/issue-78722.stderr b/tests/ui/impl-trait/issues/issue-78722.stderr index 3642000597f..109bda0c5cd 100644 --- a/tests/ui/impl-trait/issues/issue-78722.stderr +++ b/tests/ui/impl-trait/issues/issue-78722.stderr @@ -12,7 +12,7 @@ error[E0271]: expected `{async block@$DIR/issue-78722.rs:10:13: 10:18}` to be a --> $DIR/issue-78722.rs:8:30 | LL | fn concrete_use() -> F { - | ^ expected `()`, found `u8` + | ^ expected `u8`, found `()` error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr b/tests/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr index c4ea4474066..fa71adc6380 100644 --- a/tests/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr +++ b/tests/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr @@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<() as Super>::Assoc == ()` LL | fn test() -> impl Test { | ^^^^^^^^^ type mismatch resolving `<() as Super>::Assoc == ()` | -note: expected this to be `u8` +note: expected this to be `()` --> $DIR/projection-mismatch-in-impl-where-clause.rs:6:18 | LL | type Assoc = u8; diff --git a/tests/ui/issues/issue-33941.stderr b/tests/ui/issues/issue-33941.stderr index f1b6b6ba17e..9535ea57430 100644 --- a/tests/ui/issues/issue-33941.stderr +++ b/tests/ui/issues/issue-33941.stderr @@ -20,10 +20,10 @@ error[E0271]: expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but --> $DIR/issue-33941.rs:6:14 | LL | for _ in HashMap::new().iter().cloned() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(&_, &_)`, found `&_` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `(&_, &_)` | - = note: expected tuple `(&_, &_)` - found reference `&_` + = note: expected reference `&_` + found tuple `(&_, &_)` = note: required for `Cloned>` to implement `Iterator` = note: required for `Cloned>` to implement `IntoIterator` diff --git a/tests/ui/issues/issue-67039-unsound-pin-partialeq.stderr b/tests/ui/issues/issue-67039-unsound-pin-partialeq.stderr index 1ea2d48b474..9164e4696eb 100644 --- a/tests/ui/issues/issue-67039-unsound-pin-partialeq.stderr +++ b/tests/ui/issues/issue-67039-unsound-pin-partialeq.stderr @@ -2,10 +2,10 @@ error[E0271]: type mismatch resolving ` as Deref>::Target == Rc --> $DIR/issue-67039-unsound-pin-partialeq.rs:25:29 | LL | let _ = Pin::new(Apple) == Rc::pin(Apple); - | ^^ expected `Apple`, found `Rc` + | ^^ expected `Rc`, found `Apple` | - = note: expected struct `Apple` - found struct `Rc` + = note: expected struct `Rc` + found struct `Apple` = note: required for `Pin` to implement `PartialEq>>` error: aborting due to 1 previous error diff --git a/tests/ui/lint/issue-106991.stderr b/tests/ui/lint/issue-106991.stderr index 4704e9ef835..9b4fab68102 100644 --- a/tests/ui/lint/issue-106991.stderr +++ b/tests/ui/lint/issue-106991.stderr @@ -2,7 +2,7 @@ error[E0271]: expected `foo` to be a fn item that returns `i32`, but it returns --> $DIR/issue-106991.rs:5:13 | LL | fn bar() -> impl Iterator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `i32` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `()` | = note: required for `Map>, for<'a> fn(&'a mut Vec) {foo}>` to implement `Iterator` diff --git a/tests/ui/suggestions/trait-hidden-method.stderr b/tests/ui/suggestions/trait-hidden-method.stderr index 5dec2071846..729523cde55 100644 --- a/tests/ui/suggestions/trait-hidden-method.stderr +++ b/tests/ui/suggestions/trait-hidden-method.stderr @@ -8,14 +8,14 @@ error[E0271]: expected `Box` to be an iterator that yields `u32`, --> $DIR/trait-hidden-method.rs:3:32 | LL | pub fn i_can_has_iterator() -> impl Iterator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found `u32` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found associated type ... LL | Box::new(1..=10) as Box | ------------------------------------- return type was inferred to be `Box` here | - = note: expected associated type `::Item` - found type `u32` - = help: consider constraining the associated type `::Item` to `u32` or calling a method that returns `::Item` + = note: expected type `u32` + found associated type `::Item` + = help: consider constraining the associated type `::Item` to `u32` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to 2 previous errors diff --git a/tests/ui/traits/next-solver/async.fail.stderr b/tests/ui/traits/next-solver/async.fail.stderr index e47da338736..bc89842d16a 100644 --- a/tests/ui/traits/next-solver/async.fail.stderr +++ b/tests/ui/traits/next-solver/async.fail.stderr @@ -2,12 +2,10 @@ error[E0271]: expected `{async block@$DIR/async.rs:12:17: 12:22}` to be a future --> $DIR/async.rs:12:17 | LL | needs_async(async {}); - | ----------- ^^^^^^^^ expected `()`, found `i32` + | ----------- ^^^^^^^^ expected `i32`, found `()` | | | required by a bound introduced by this call | - = note: expected unit type `()` - found type `i32` note: required by a bound in `needs_async` --> $DIR/async.rs:8:31 | diff --git a/tests/ui/traits/next-solver/more-object-bound.stderr b/tests/ui/traits/next-solver/more-object-bound.stderr index 043cbdff9ab..39849d4c865 100644 --- a/tests/ui/traits/next-solver/more-object-bound.stderr +++ b/tests/ui/traits/next-solver/more-object-bound.stderr @@ -2,19 +2,14 @@ error[E0271]: type mismatch resolving ` as SuperTrait>:: --> $DIR/more-object-bound.rs:12:5 | LL | fn transmute(x: A) -> B { - | - - - | | | - | | expected type parameter - | | found type parameter + | - - expected type parameter + | | | found type parameter - | expected type parameter LL | foo::>(x) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `A`, found type parameter `B` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `B`, found type parameter `A` | - = note: expected type parameter `A` - found type parameter `B` - = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound - = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters + = note: expected type parameter `B` + found type parameter `A` = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters = note: required because it appears within the type `dyn Trait` diff --git a/tests/ui/try-block/try-block-bad-type.stderr b/tests/ui/try-block/try-block-bad-type.stderr index 6c41b42dc64..e9e6255cd2a 100644 --- a/tests/ui/try-block/try-block-bad-type.stderr +++ b/tests/ui/try-block/try-block-bad-type.stderr @@ -15,13 +15,13 @@ error[E0271]: type mismatch resolving ` as Try>::Output == &str --> $DIR/try-block-bad-type.rs:12:9 | LL | "" - | ^^ expected `i32`, found `&str` + | ^^ expected `&str`, found `i32` error[E0271]: type mismatch resolving ` as Try>::Output == ()` --> $DIR/try-block-bad-type.rs:15:39 | LL | let res: Result = try { }; - | ^ expected `i32`, found `()` + | ^ expected `()`, found `i32` error[E0277]: a `try` block must return `Result` or `Option` (or another type that implements `Try`) --> $DIR/try-block-bad-type.rs:17:25 diff --git a/tests/ui/try-block/try-block-type-error.stderr b/tests/ui/try-block/try-block-type-error.stderr index 2cdb5fdee79..07b1209de9d 100644 --- a/tests/ui/try-block/try-block-type-error.stderr +++ b/tests/ui/try-block/try-block-type-error.stderr @@ -2,18 +2,13 @@ error[E0271]: type mismatch resolving ` as Try>::Output == {integer} --> $DIR/try-block-type-error.rs:10:9 | LL | 42 - | ^^ expected `f32`, found integer - | -help: use a float literal - | -LL | 42.0 - | ++ + | ^^ expected integer, found `f32` error[E0271]: type mismatch resolving ` as Try>::Output == ()` --> $DIR/try-block-type-error.rs:16:5 | LL | }; - | ^ expected `i32`, found `()` + | ^ expected `()`, found `i32` error: aborting due to 2 previous errors diff --git a/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr index 21d9ed93366..b05121a489e 100644 --- a/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr +++ b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr @@ -2,18 +2,18 @@ error[E0271]: type mismatch resolving `<() as Proj>::Assoc == i32` --> $DIR/hidden_type_mismatch.rs:43:9 | LL | pub type Sep = impl Sized + std::fmt::Display; - | ------------------------------ the expected opaque type + | ------------------------------ the found opaque type ... LL | Bar { inner: 1i32, _marker: () } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<() as Proj>::Assoc == i32` | -note: expected this to be `Sep` +note: expected this to be `i32` --> $DIR/hidden_type_mismatch.rs:20:22 | LL | type Assoc = sus::Sep; | ^^^^^^^^ - = note: expected opaque type `Sep` - found type `i32` + = note: expected type `i32` + found opaque type `Sep` note: required for `Bar<()>` to implement `Copy` --> $DIR/hidden_type_mismatch.rs:32:39 | diff --git a/tests/ui/type-alias-impl-trait/issue-94429.stderr b/tests/ui/type-alias-impl-trait/issue-94429.stderr index 4c2020becbe..f41b781f963 100644 --- a/tests/ui/type-alias-impl-trait/issue-94429.stderr +++ b/tests/ui/type-alias-impl-trait/issue-94429.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<{coroutine@$DIR/issue-94429.rs:18:9: 18: --> $DIR/issue-94429.rs:15:26 | LL | fn run(&mut self) -> Self::Coro { - | ^^^^^^^^^^ expected integer, found `()` + | ^^^^^^^^^^ expected `()`, found integer error: aborting due to 1 previous error