diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 9e32a85e361a..25b6d992ab36 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1523,16 +1523,17 @@ impl HumanEmitter { label_width += 2; } let mut line = 0; + let mut pad = false; for (text, style) in msgs.iter() { let text = self.translator.translate_message(text, args).map_err(Report::new).unwrap(); // Account for newlines to align output to its label. - for text in normalize_whitespace(&text).lines() { + for text in normalize_whitespace(&text).split('\n') { buffer.append( line, &format!( "{}{}", - if line == 0 { String::new() } else { " ".repeat(label_width) }, + if pad { " ".repeat(label_width) } else { String::new() }, text ), match style { @@ -1541,7 +1542,9 @@ impl HumanEmitter { }, ); line += 1; + pad = true; } + pad = false; // We add lines above, but if the last line has no explicit newline (which would // yield an empty line), then we revert one line up to continue with the next // styled text chunk on the same line as the last one from the prior one. Otherwise 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 373819d96f4a..7cd0eba29b64 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 @@ -2191,7 +2191,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { msg.extend(types.1.0); msg.push(StringPart::normal("`")); } - err.highlighted_help(msg); + err.highlighted_span_help(self.tcx.def_span(single.impl_def_id), msg); if let [TypeError::Sorts(exp_found)] = &terrs[..] { let exp_found = self.resolve_vars_if_possible(*exp_found); diff --git a/tests/ui/const-generics/associated-type-bound-fail.stderr b/tests/ui/const-generics/associated-type-bound-fail.stderr index e92aad7cec32..86e667408c73 100644 --- a/tests/ui/const-generics/associated-type-bound-fail.stderr +++ b/tests/ui/const-generics/associated-type-bound-fail.stderr @@ -4,8 +4,12 @@ error[E0277]: the trait bound `u16: Bar` is not satisfied LL | type Assoc = u16; | ^^^ the trait `Bar` is not implemented for `u16` | - = help: the trait `Bar` is not implemented for `u16` - but trait `Bar<3>` is implemented for it +help: the trait `Bar` is not implemented for `u16` + but trait `Bar<3>` is implemented for it + --> $DIR/associated-type-bound-fail.rs:7:1 + | +LL | impl Bar<3> for u16 {} + | ^^^^^^^^^^^^^^^^^^^ note: required by a bound in `Foo::Assoc` --> $DIR/associated-type-bound-fail.rs:4:17 | diff --git a/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr b/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr index 65c480d7c494..48e246f92774 100644 --- a/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr +++ b/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr @@ -23,8 +23,12 @@ LL | LL | 1_u32 | ----- return type was inferred to be `u32` here | - = help: the trait `Traitor` is not implemented for `u32` - but trait `Traitor` is implemented for it +help: the trait `Traitor` is not implemented for `u32` + but trait `Traitor` is implemented for it + --> $DIR/rp_impl_trait_fail.rs:13:1 + | +LL | impl Traitor for u32 {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `u64: Traitor` is not satisfied --> $DIR/rp_impl_trait_fail.rs:21:13 @@ -35,8 +39,12 @@ LL | LL | 1_u64 | ----- return type was inferred to be `u64` here | - = help: the trait `Traitor<1, 1>` is not implemented for `u64` - but trait `Traitor<1, 2>` is implemented for it +help: the trait `Traitor<1, 1>` is not implemented for `u64` + but trait `Traitor<1, 2>` is implemented for it + --> $DIR/rp_impl_trait_fail.rs:14:1 + | +LL | impl Traitor<1, 2> for u64 {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0284]: type annotations needed --> $DIR/rp_impl_trait_fail.rs:28:5 diff --git a/tests/ui/const-generics/defaults/trait_objects_fail.stderr b/tests/ui/const-generics/defaults/trait_objects_fail.stderr index 2390dfeadb90..f79d45dc8cf0 100644 --- a/tests/ui/const-generics/defaults/trait_objects_fail.stderr +++ b/tests/ui/const-generics/defaults/trait_objects_fail.stderr @@ -4,8 +4,12 @@ error[E0277]: the trait bound `u32: Trait` is not satisfied LL | foo(&10_u32); | ^^^^^^^ the trait `Trait` is not implemented for `u32` | - = help: the trait `Trait<12>` is not implemented for `u32` - but trait `Trait<2>` is implemented for it +help: the trait `Trait<12>` is not implemented for `u32` + but trait `Trait<2>` is implemented for it + --> $DIR/trait_objects_fail.rs:7:1 + | +LL | impl Trait<2> for u32 {} + | ^^^^^^^^^^^^^^^^^^^^^ = note: required for the cast from `&u32` to `&dyn Trait` error[E0277]: the trait bound `bool: Traitor<_>` is not satisfied @@ -14,8 +18,12 @@ error[E0277]: the trait bound `bool: Traitor<_>` is not satisfied LL | bar(&true); | ^^^^^ the trait `Traitor<_>` is not implemented for `bool` | - = help: the trait `Traitor<_, _>` is not implemented for `bool` - but trait `Traitor<2, 3>` is implemented for it +help: the trait `Traitor<_, _>` is not implemented for `bool` + but trait `Traitor<2, 3>` is implemented for it + --> $DIR/trait_objects_fail.rs:19:1 + | +LL | impl Traitor<2, 3> for bool {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: required for the cast from `&bool` to `&dyn Traitor<_>` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/defaults/wfness.stderr b/tests/ui/const-generics/defaults/wfness.stderr index 7098850e978a..860449939220 100644 --- a/tests/ui/const-generics/defaults/wfness.stderr +++ b/tests/ui/const-generics/defaults/wfness.stderr @@ -10,8 +10,12 @@ error[E0277]: the trait bound `(): Trait<2>` is not satisfied LL | (): Trait; | ^^^^^^^^ the trait `Trait<2>` is not implemented for `()` | - = help: the trait `Trait<2>` is not implemented for `()` - but trait `Trait<3>` is implemented for it +help: the trait `Trait<2>` is not implemented for `()` + but trait `Trait<3>` is implemented for it + --> $DIR/wfness.rs:5:1 + | +LL | impl Trait<3> for () {} + | ^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `WhereClause` --> $DIR/wfness.rs:8:9 | @@ -27,8 +31,12 @@ error[E0277]: the trait bound `(): Trait<1>` is not satisfied LL | fn foo() -> DependentDefaultWfness { | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<1>` is not implemented for `()` | - = help: the trait `Trait<1>` is not implemented for `()` - but trait `Trait<3>` is implemented for it +help: the trait `Trait<1>` is not implemented for `()` + but trait `Trait<3>` is implemented for it + --> $DIR/wfness.rs:5:1 + | +LL | impl Trait<3> for () {} + | ^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `WhereClause` --> $DIR/wfness.rs:8:9 | diff --git a/tests/ui/const-generics/occurs-check/unused-substs-1.stderr b/tests/ui/const-generics/occurs-check/unused-substs-1.stderr index 70fc71c99b91..9fd48b1472e4 100644 --- a/tests/ui/const-generics/occurs-check/unused-substs-1.stderr +++ b/tests/ui/const-generics/occurs-check/unused-substs-1.stderr @@ -4,8 +4,12 @@ error[E0277]: the trait bound `A<_>: Bar<_>` is not satisfied LL | let _ = A; | ^ unsatisfied trait bound | - = help: the trait `Bar<_>` is not implemented for `A<_>` - but it is implemented for `A<{ 6 + 1 }>` +help: the trait `Bar<_>` is not implemented for `A<_>` + but it is implemented for `A<{ 6 + 1 }>` + --> $DIR/unused-substs-1.rs:5:1 + | +LL | impl Bar for A<{ 6 + 1 }> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `A` --> $DIR/unused-substs-1.rs:9:11 | diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.current.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.current.stderr index 305fbbd275f1..46dd21ceb00a 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.current.stderr +++ b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.current.stderr @@ -4,8 +4,12 @@ error[E0277]: the trait bound `&str: AsExpression` is not satisfied LL | SelectInt.check("bar"); | ^^^^^ the trait `AsExpression` is not implemented for `&str` | - = help: the trait `AsExpression` is not implemented for `&str` - but trait `AsExpression` is implemented for it +help: the trait `AsExpression` is not implemented for `&str` + but trait `AsExpression` is implemented for it + --> $DIR/as_expression.rs:40:1 + | +LL | impl AsExpression for &'_ str { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for that trait implementation, expected `Text`, found `Integer` error: aborting due to 1 previous error 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 8178f54b2aab..445aeb469476 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 @@ -6,8 +6,12 @@ LL | SelectInt.check("bar"); | | | required by a bound introduced by this call | - = help: the trait `AsExpression` is not implemented for `&str` - but trait `AsExpression` is implemented for it +help: the trait `AsExpression` is not implemented for `&str` + but trait `AsExpression` is implemented for it + --> $DIR/as_expression.rs:40:1 + | +LL | impl AsExpression for &'_ str { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for that trait implementation, expected `Text`, found `Integer` note: required by a bound in `Foo::check` --> $DIR/as_expression.rs:47:12 @@ -24,8 +28,12 @@ error[E0277]: the trait bound `&str: AsExpression` is not satisfied LL | SelectInt.check("bar"); | ^^^^^^^^^^^^^^^^^^^^^^ the trait `AsExpression` is not implemented for `&str` | - = help: the trait `AsExpression` is not implemented for `&str` - but trait `AsExpression` is implemented for it +help: the trait `AsExpression` is not implemented for `&str` + but trait `AsExpression` is implemented for it + --> $DIR/as_expression.rs:40:1 + | +LL | impl AsExpression for &'_ str { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for that trait implementation, expected `Text`, found `Integer` error: aborting due to 2 previous errors diff --git a/tests/ui/did_you_mean/casting-fn-item-to-fn-pointer.stderr b/tests/ui/did_you_mean/casting-fn-item-to-fn-pointer.stderr index d069d39514dc..2b08a9563fa0 100644 --- a/tests/ui/did_you_mean/casting-fn-item-to-fn-pointer.stderr +++ b/tests/ui/did_you_mean/casting-fn-item-to-fn-pointer.stderr @@ -4,8 +4,9 @@ error[E0277]: a value of type `Vec<(&str, fn())>` cannot be built from an iterat LL | let _: Vec<(&str, fn())> = [("foo", foo)].into_iter().collect(); | ^^^^^^^ value of type `Vec<(&str, fn())>` cannot be built from `std::iter::Iterator` | - = help: the trait `FromIterator<(&_, fn() {foo})>` is not implemented for `Vec<(&str, fn())>` - but trait `FromIterator<(&_, fn())>` is implemented for it +help: the trait `FromIterator<(&_, fn() {foo})>` is not implemented for `Vec<(&str, fn())>` + but trait `FromIterator<(&_, fn())>` is implemented for it + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL = help: for that trait implementation, expected `fn()`, found `fn() {foo}` = note: fn items are distinct from fn pointers = help: consider casting the fn item to a fn pointer: `foo as fn()` @@ -25,8 +26,9 @@ error[E0277]: a value of type `Vec` cannot be built from an iterator over LL | let _: Vec = [foo].into_iter().collect(); | ^^^^^^^ value of type `Vec` cannot be built from `std::iter::Iterator` | - = help: the trait `FromIterator` is not implemented for `Vec` - but trait `FromIterator` is implemented for it +help: the trait `FromIterator` is not implemented for `Vec` + but trait `FromIterator` is implemented for it + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL = help: for that trait implementation, expected `fn()`, found `fn() {foo}` = note: fn items are distinct from fn pointers = help: consider casting the fn item to a fn pointer: `foo as fn()` diff --git a/tests/ui/generic-const-items/unsatisfied-bounds.stderr b/tests/ui/generic-const-items/unsatisfied-bounds.stderr index de252b816e58..dc243e342dd9 100644 --- a/tests/ui/generic-const-items/unsatisfied-bounds.stderr +++ b/tests/ui/generic-const-items/unsatisfied-bounds.stderr @@ -16,8 +16,9 @@ error[E0277]: the trait bound `Infallible: From<()>` is not satisfied LL | let () = K::<()>; | ^^ the trait `From<()>` is not implemented for `Infallible` | - = help: the trait `From<()>` is not implemented for `Infallible` - but trait `From` is implemented for it +help: the trait `From<()>` is not implemented for `Infallible` + but trait `From` is implemented for it + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = help: for that trait implementation, expected `!`, found `()` note: required by a bound in `K` --> $DIR/unsatisfied-bounds.rs:12:17 @@ -49,8 +50,9 @@ error[E0277]: the trait bound `Infallible: From<()>` is not satisfied LL | let _ = <() as Trait<&'static str>>::B::<()>; | ^^ the trait `From<()>` is not implemented for `Infallible` | - = help: the trait `From<()>` is not implemented for `Infallible` - but trait `From` is implemented for it +help: the trait `From<()>` is not implemented for `Infallible` + but trait `From` is implemented for it + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = help: for that trait implementation, expected `!`, found `()` note: required by a bound in `Trait::B` --> $DIR/unsatisfied-bounds.rs:21:21 diff --git a/tests/ui/impl-trait/diagnostics/highlight-difference-between-expected-trait-and-found-trait.svg b/tests/ui/impl-trait/diagnostics/highlight-difference-between-expected-trait-and-found-trait.svg index 8c2713c5ecb0..6e68356c4813 100644 --- a/tests/ui/impl-trait/diagnostics/highlight-difference-between-expected-trait-and-found-trait.svg +++ b/tests/ui/impl-trait/diagnostics/highlight-difference-between-expected-trait-and-found-trait.svg @@ -1,8 +1,9 @@ - + diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr index 374176f041ad..24c15144a2ab 100644 --- a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr +++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr @@ -29,8 +29,12 @@ LL | fn foo>(self) -> impl Foo { LL | self | ---- return type was inferred to be `Bar` here | - = help: the trait `Foo` is not implemented for `Bar` - but trait `Foo` is implemented for it +help: the trait `Foo` is not implemented for `Bar` + but trait `Foo` is implemented for it + --> $DIR/return-dont-satisfy-bounds.rs:7:1 + | +LL | impl Foo for Bar { + | ^^^^^^^^^^^^^^^^^^^^^^ = help: for that trait implementation, expected `char`, found `u8` error: aborting due to 3 previous errors diff --git a/tests/ui/impl-trait/issues/issue-62742.stderr b/tests/ui/impl-trait/issues/issue-62742.stderr index 7ded3519d85a..a1fedb8fb7b8 100644 --- a/tests/ui/impl-trait/issues/issue-62742.stderr +++ b/tests/ui/impl-trait/issues/issue-62742.stderr @@ -4,8 +4,12 @@ error[E0277]: the trait bound `RawImpl<_>: Raw<_>` is not satisfied LL | WrongImpl::foo(0i32); | ^^^^^^^^^ unsatisfied trait bound | - = help: the trait `Raw<_>` is not implemented for `RawImpl<_>` - but trait `Raw<[_]>` is implemented for it +help: the trait `Raw<_>` is not implemented for `RawImpl<_>` + but trait `Raw<[_]>` is implemented for it + --> $DIR/issue-62742.rs:29:1 + | +LL | impl Raw<[T]> for RawImpl { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `SafeImpl` --> $DIR/issue-62742.rs:33:35 | @@ -43,8 +47,12 @@ error[E0277]: the trait bound `RawImpl<()>: Raw<()>` is not satisfied LL | WrongImpl::<()>::foo(0i32); | ^^^^^^^^^^^^^^^ unsatisfied trait bound | - = help: the trait `Raw<()>` is not implemented for `RawImpl<()>` - but trait `Raw<[()]>` is implemented for it +help: the trait `Raw<()>` is not implemented for `RawImpl<()>` + but trait `Raw<[()]>` is implemented for it + --> $DIR/issue-62742.rs:29:1 + | +LL | impl Raw<[T]> for RawImpl { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for that trait implementation, expected `[()]`, found `()` note: required by a bound in `SafeImpl` --> $DIR/issue-62742.rs:33:35 diff --git a/tests/ui/impl-trait/nested-rpit-hrtb.stderr b/tests/ui/impl-trait/nested-rpit-hrtb.stderr index 2e95ef370c7f..a15f400fc2a7 100644 --- a/tests/ui/impl-trait/nested-rpit-hrtb.stderr +++ b/tests/ui/impl-trait/nested-rpit-hrtb.stderr @@ -83,8 +83,12 @@ error[E0277]: the trait bound `for<'a> &'a (): Qux<'b>` is not satisfied LL | fn one_hrtb_mention_fn_trait_param_uses<'b>() -> impl for<'a> Bar<'a, Assoc = impl Qux<'b>> {} | ^^^^^^^^^^^^ the trait `for<'a> Qux<'b>` is not implemented for `&'a ()` | - = help: the trait `Qux<'b>` is not implemented for `&'a ()` - but trait `Qux<'_>` is implemented for `()` +help: the trait `Qux<'b>` is not implemented for `&'a ()` + but trait `Qux<'_>` is implemented for `()` + --> $DIR/nested-rpit-hrtb.rs:22:1 + | +LL | impl Qux<'_> for () {} + | ^^^^^^^^^^^^^^^^^^^ = help: for that trait implementation, expected `()`, found `&'a ()` error: implementation of `Bar` is not general enough @@ -102,8 +106,12 @@ error[E0277]: the trait bound `for<'a, 'b> &'a (): Qux<'b>` is not satisfied LL | fn two_htrb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl for<'b> Qux<'b>> {} | ^^^^^^^^^^^^^^^^^^^^ the trait `for<'a, 'b> Qux<'b>` is not implemented for `&'a ()` | - = help: the trait `Qux<'b>` is not implemented for `&'a ()` - but trait `Qux<'_>` is implemented for `()` +help: the trait `Qux<'b>` is not implemented for `&'a ()` + but trait `Qux<'_>` is implemented for `()` + --> $DIR/nested-rpit-hrtb.rs:22:1 + | +LL | impl Qux<'_> for () {} + | ^^^^^^^^^^^^^^^^^^^ = help: for that trait implementation, expected `()`, found `&'a ()` error: aborting due to 9 previous errors diff --git a/tests/ui/impl-trait/non-defining-uses/avoid-inference-constraints-from-blanket-3.stderr b/tests/ui/impl-trait/non-defining-uses/avoid-inference-constraints-from-blanket-3.stderr index a5d19b484811..f4b60aa9b205 100644 --- a/tests/ui/impl-trait/non-defining-uses/avoid-inference-constraints-from-blanket-3.stderr +++ b/tests/ui/impl-trait/non-defining-uses/avoid-inference-constraints-from-blanket-3.stderr @@ -4,8 +4,12 @@ error[E0277]: the trait bound `String: Trait` is not satisfied LL | impls_trait(x); | ^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | - = help: the trait `Trait` is not implemented for `String` - but trait `Trait` is implemented for it +help: the trait `Trait` is not implemented for `String` + but trait `Trait` is implemented for it + --> $DIR/avoid-inference-constraints-from-blanket-3.rs:17:1 + | +LL | impl Trait for String {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for that trait implementation, expected `u64`, found `u32` note: required for `String` to implement `Trait` --> $DIR/avoid-inference-constraints-from-blanket-3.rs:16:15 diff --git a/tests/ui/indexing/point-at-index-for-obligation-failure.stderr b/tests/ui/indexing/point-at-index-for-obligation-failure.stderr index 0752231356cf..a221e4337891 100644 --- a/tests/ui/indexing/point-at-index-for-obligation-failure.stderr +++ b/tests/ui/indexing/point-at-index-for-obligation-failure.stderr @@ -4,8 +4,9 @@ error[E0277]: the trait bound `String: Borrow<&str>` is not satisfied LL | &s | ^^ the trait `Borrow<&str>` is not implemented for `String` | - = help: the trait `Borrow<&_>` is not implemented for `String` - but trait `Borrow<_>` is implemented for it +help: the trait `Borrow<&_>` is not implemented for `String` + but trait `Borrow<_>` is implemented for it + --> $SRC_DIR/alloc/src/str.rs:LL:COL = help: for that trait implementation, expected `str`, found `&str` = note: required for `HashMap` to implement `Index<&&str>` diff --git a/tests/ui/issues/issue-34334.stderr b/tests/ui/issues/issue-34334.stderr index 6562ccfdcd28..6bf6732311fc 100644 --- a/tests/ui/issues/issue-34334.stderr +++ b/tests/ui/issues/issue-34334.stderr @@ -17,8 +17,9 @@ error[E0277]: a value of type `Vec<(u32, _, _)>` cannot be built from an iterato LL | let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect(); | ^^^^^^^ value of type `Vec<(u32, _, _)>` cannot be built from `std::iter::Iterator` | - = help: the trait `FromIterator<()>` is not implemented for `Vec<(u32, _, _)>` - but trait `FromIterator<(u32, _, _)>` is implemented for it +help: the trait `FromIterator<()>` is not implemented for `Vec<(u32, _, _)>` + but trait `FromIterator<(u32, _, _)>` is implemented for it + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL = help: for that trait implementation, expected `(u32, _, _)`, found `()` note: the method call chain might not have had the expected associated types --> $DIR/issue-34334.rs:5:43 diff --git a/tests/ui/issues/issue-45801.stderr b/tests/ui/issues/issue-45801.stderr index 9f7c822f1658..8a4ac85bf872 100644 --- a/tests/ui/issues/issue-45801.stderr +++ b/tests/ui/issues/issue-45801.stderr @@ -4,8 +4,12 @@ error[E0277]: the trait bound `Params: Plugin` is not satisfied LL | req.get_ref::(); | ^^^^^^^ unsatisfied trait bound | - = help: the trait `Plugin` is not implemented for `Params` - but trait `Plugin` is implemented for it +help: the trait `Plugin` is not implemented for `Params` + but trait `Plugin` is implemented for it + --> $DIR/issue-45801.rs:14:1 + | +LL | impl Plugin for Params { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for that trait implementation, expected `Foo`, found `i32` error: aborting due to 1 previous error diff --git a/tests/ui/iterators/invalid-iterator-chain-fixable.stderr b/tests/ui/iterators/invalid-iterator-chain-fixable.stderr index 09439fe8fbd6..72874471b028 100644 --- a/tests/ui/iterators/invalid-iterator-chain-fixable.stderr +++ b/tests/ui/iterators/invalid-iterator-chain-fixable.stderr @@ -6,8 +6,9 @@ LL | let i = i.map(|x| x.clone()); LL | i.collect() | ^^^^^^^ value of type `Vec` cannot be built from `std::iter::Iterator` | - = help: the trait `FromIterator<&_>` is not implemented for `Vec` - but trait `FromIterator<_>` is implemented for it +help: the trait `FromIterator<&_>` is not implemented for `Vec` + but trait `FromIterator<_>` is implemented for it + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL = help: for that trait implementation, expected `X`, found `&X` note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain-fixable.rs:5:26 @@ -123,8 +124,9 @@ error[E0277]: a value of type `Vec` cannot be built from an iterator over e LL | let g: Vec = f.collect(); | ^^^^^^^ value of type `Vec` cannot be built from `std::iter::Iterator` | - = help: the trait `FromIterator<()>` is not implemented for `Vec` - but trait `FromIterator` is implemented for it +help: the trait `FromIterator<()>` is not implemented for `Vec` + but trait `FromIterator` is implemented for it + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL = help: for that trait implementation, expected `i32`, found `()` note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain-fixable.rs:32:15 diff --git a/tests/ui/iterators/invalid-iterator-chain.stderr b/tests/ui/iterators/invalid-iterator-chain.stderr index b810e06d0f7e..3add164fbcaf 100644 --- a/tests/ui/iterators/invalid-iterator-chain.stderr +++ b/tests/ui/iterators/invalid-iterator-chain.stderr @@ -6,8 +6,9 @@ LL | let i = i.map(|x| x.clone()); LL | i.collect() | ^^^^^^^ value of type `Vec` cannot be built from `std::iter::Iterator` | - = help: the trait `FromIterator<&_>` is not implemented for `Vec` - but trait `FromIterator<_>` is implemented for it +help: the trait `FromIterator<&_>` is not implemented for `Vec` + but trait `FromIterator<_>` is implemented for it + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL = help: for that trait implementation, expected `X`, found `&X` note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:4:26 @@ -180,8 +181,9 @@ error[E0277]: a value of type `Vec` cannot be built from an iterator over e LL | let g: Vec = f.collect(); | ^^^^^^^ value of type `Vec` cannot be built from `std::iter::Iterator` | - = help: the trait `FromIterator<()>` is not implemented for `Vec` - but trait `FromIterator` is implemented for it +help: the trait `FromIterator<()>` is not implemented for `Vec` + but trait `FromIterator` is implemented for it + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL = help: for that trait implementation, expected `i32`, found `()` note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:44:15 diff --git a/tests/ui/mismatched_types/collect-method-type-mismatch-66923.stderr b/tests/ui/mismatched_types/collect-method-type-mismatch-66923.stderr index 89c755cdf47a..a789ae0f5494 100644 --- a/tests/ui/mismatched_types/collect-method-type-mismatch-66923.stderr +++ b/tests/ui/mismatched_types/collect-method-type-mismatch-66923.stderr @@ -4,8 +4,9 @@ error[E0277]: a value of type `Vec` cannot be built from an iterator over e LL | let x2: Vec = x1.into_iter().collect(); | ^^^^^^^ value of type `Vec` cannot be built from `std::iter::Iterator` | - = help: the trait `FromIterator<&_>` is not implemented for `Vec` - but trait `FromIterator<_>` is implemented for it +help: the trait `FromIterator<&_>` is not implemented for `Vec` + but trait `FromIterator<_>` is implemented for it + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL = help: for that trait implementation, expected `f64`, found `&f64` note: the method call chain might not have had the expected associated types --> $DIR/collect-method-type-mismatch-66923.rs:9:27 @@ -25,8 +26,9 @@ LL | let x3 = x1.into_iter().collect::>(); | | | required by a bound introduced by this call | - = help: the trait `FromIterator<&_>` is not implemented for `Vec` - but trait `FromIterator<_>` is implemented for it +help: the trait `FromIterator<&_>` is not implemented for `Vec` + but trait `FromIterator<_>` is implemented for it + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL = help: for that trait implementation, expected `f64`, found `&f64` note: the method call chain might not have had the expected associated types --> $DIR/collect-method-type-mismatch-66923.rs:13:17 diff --git a/tests/ui/never_type/from_infer_breaking_with_unit_fallback.unit.stderr b/tests/ui/never_type/from_infer_breaking_with_unit_fallback.unit.stderr index 891b6ea8046d..da44d72d2cff 100644 --- a/tests/ui/never_type/from_infer_breaking_with_unit_fallback.unit.stderr +++ b/tests/ui/never_type/from_infer_breaking_with_unit_fallback.unit.stderr @@ -4,8 +4,12 @@ error[E0277]: the trait bound `E: From<()>` is not satisfied LL | >::from(never); // Should the inference fail? | ^ unsatisfied trait bound | - = help: the trait `From<()>` is not implemented for `E` - but trait `From` is implemented for it +help: the trait `From<()>` is not implemented for `E` + but trait `From` is implemented for it + --> $DIR/from_infer_breaking_with_unit_fallback.rs:16:1 + | +LL | impl From for E { + | ^^^^^^^^^^^^^^^^^^ = help: for that trait implementation, expected `!`, found `()` error: aborting due to 1 previous error diff --git a/tests/ui/never_type/never-value-fallback-issue-66757.nofallback.stderr b/tests/ui/never_type/never-value-fallback-issue-66757.nofallback.stderr index cd34cd9e88ee..199f113ddc49 100644 --- a/tests/ui/never_type/never-value-fallback-issue-66757.nofallback.stderr +++ b/tests/ui/never_type/never-value-fallback-issue-66757.nofallback.stderr @@ -4,8 +4,12 @@ error[E0277]: the trait bound `E: From<()>` is not satisfied LL | >::from(never); | ^ unsatisfied trait bound | - = help: the trait `From<()>` is not implemented for `E` - but trait `From` is implemented for it +help: the trait `From<()>` is not implemented for `E` + but trait `From` is implemented for it + --> $DIR/never-value-fallback-issue-66757.rs:17:1 + | +LL | impl From for E { + | ^^^^^^^^^^^^^^^^^^ = help: for that trait implementation, expected `!`, found `()` error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/issue-101623.stderr b/tests/ui/suggestions/issue-101623.stderr index 0733e67ea029..56858cdbe8a5 100644 --- a/tests/ui/suggestions/issue-101623.stderr +++ b/tests/ui/suggestions/issue-101623.stderr @@ -7,8 +7,12 @@ LL | Trait::do_stuff({ fun(&mut *inner) }); | | the trait `Trait<'_>` is not implemented for `*mut ()` | required by a bound introduced by this call | - = help: the trait `Trait<'_>` is not implemented for `*mut ()` - but it is implemented for `()` +help: the trait `Trait<'_>` is not implemented for `*mut ()` + but it is implemented for `()` + --> $DIR/issue-101623.rs:15:1 + | +LL | impl<'a> Trait<'a> for () { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for that trait implementation, expected `()`, found `*mut ()` error: aborting due to 1 previous error diff --git a/tests/ui/traits/coercion-generic-bad.stderr b/tests/ui/traits/coercion-generic-bad.stderr index 6af96b9daf7e..947e76af4183 100644 --- a/tests/ui/traits/coercion-generic-bad.stderr +++ b/tests/ui/traits/coercion-generic-bad.stderr @@ -4,8 +4,12 @@ error[E0277]: the trait bound `Struct: Trait` is not satisfied LL | let s: Box> = Box::new(Struct { person: "Fred" }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound | - = help: the trait `Trait` is not implemented for `Struct` - but trait `Trait<&'static str>` is implemented for it +help: the trait `Trait` is not implemented for `Struct` + but trait `Trait<&'static str>` is implemented for it + --> $DIR/coercion-generic-bad.rs:9:1 + | +LL | impl Trait<&'static str> for Struct { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for that trait implementation, expected `&'static str`, found `isize` = note: required for the cast from `Box` to `Box>` diff --git a/tests/ui/try-block/try-block-bad-type.stderr b/tests/ui/try-block/try-block-bad-type.stderr index 818ab499306f..cf1cd60a7d5e 100644 --- a/tests/ui/try-block/try-block-bad-type.stderr +++ b/tests/ui/try-block/try-block-bad-type.stderr @@ -7,8 +7,9 @@ LL | Err("")?; | this can't be annotated with `?` because it has type `Result<_, &str>` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait - = help: the trait `From<&str>` is not implemented for `TryFromSliceError` - but trait `From` is implemented for it +help: the trait `From<&str>` is not implemented for `TryFromSliceError` + but trait `From` is implemented for it + --> $SRC_DIR/core/src/array/mod.rs:LL:COL = help: for that trait implementation, expected `Infallible`, found `&str` error[E0271]: type mismatch resolving ` as Try>::Output == &str` diff --git a/tests/ui/try-trait/bad-interconversion.stderr b/tests/ui/try-trait/bad-interconversion.stderr index 6df05747f32c..c598448ca8f5 100644 --- a/tests/ui/try-trait/bad-interconversion.stderr +++ b/tests/ui/try-trait/bad-interconversion.stderr @@ -53,8 +53,9 @@ LL | fn result_to_control_flow() -> ControlFlow { LL | ControlFlow::Continue(Err("hello")?) | ^ this `?` produces `Result`, which is incompatible with `ControlFlow` | - = help: the trait `FromResidual>` is not implemented for `ControlFlow` - but trait `FromResidual>` is implemented for it +help: the trait `FromResidual>` is not implemented for `ControlFlow` + but trait `FromResidual>` is implemented for it + --> $SRC_DIR/core/src/ops/control_flow.rs:LL:COL = help: for that trait implementation, expected `ControlFlow`, found `Result` error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow` @@ -65,8 +66,9 @@ LL | fn option_to_control_flow() -> ControlFlow { LL | Some(3)?; | ^ this `?` produces `Option`, which is incompatible with `ControlFlow` | - = help: the trait `FromResidual>` is not implemented for `ControlFlow` - but trait `FromResidual>` is implemented for it +help: the trait `FromResidual>` is not implemented for `ControlFlow` + but trait `FromResidual>` is implemented for it + --> $SRC_DIR/core/src/ops/control_flow.rs:LL:COL = help: for that trait implementation, expected `ControlFlow`, found `Option` error[E0277]: the `?` operator in a function that returns `ControlFlow` can only be used on other `ControlFlow`s (with the same Break type) @@ -78,8 +80,9 @@ LL | ControlFlow::Break(4_u8)?; | ^ this `?` produces `ControlFlow`, which is incompatible with `ControlFlow` | = note: unlike `Result`, there's no `From`-conversion performed for `ControlFlow` - = help: the trait `FromResidual>` is not implemented for `ControlFlow` - but trait `FromResidual>` is implemented for it +help: the trait `FromResidual>` is not implemented for `ControlFlow` + but trait `FromResidual>` is implemented for it + --> $SRC_DIR/core/src/ops/control_flow.rs:LL:COL = help: for that trait implementation, expected `i64`, found `u8` error: aborting due to 8 previous errors diff --git a/tests/ui/type-alias-impl-trait/constrain_in_projection.current.stderr b/tests/ui/type-alias-impl-trait/constrain_in_projection.current.stderr index 955ba69d3b6f..fa36f58b9a35 100644 --- a/tests/ui/type-alias-impl-trait/constrain_in_projection.current.stderr +++ b/tests/ui/type-alias-impl-trait/constrain_in_projection.current.stderr @@ -4,8 +4,12 @@ error[E0277]: the trait bound `Foo: Trait` is not satisfied LL | let x = >::Assoc::default(); | ^^^ unsatisfied trait bound | - = help: the trait `Trait` is not implemented for `Foo` - but trait `Trait<()>` is implemented for it +help: the trait `Trait` is not implemented for `Foo` + but trait `Trait<()>` is implemented for it + --> $DIR/constrain_in_projection.rs:19:1 + | +LL | impl Trait<()> for Foo { + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `Foo: Trait` is not satisfied --> $DIR/constrain_in_projection.rs:25:13 @@ -13,8 +17,12 @@ error[E0277]: the trait bound `Foo: Trait` is not satisfied LL | let x = >::Assoc::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound | - = help: the trait `Trait` is not implemented for `Foo` - but trait `Trait<()>` is implemented for it +help: the trait `Trait` is not implemented for `Foo` + but trait `Trait<()>` is implemented for it + --> $DIR/constrain_in_projection.rs:19:1 + | +LL | impl Trait<()> for Foo { + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/type-alias-impl-trait/nested-tait-inference.current.stderr b/tests/ui/type-alias-impl-trait/nested-tait-inference.current.stderr index b19f34a67ff7..7c611e35ff39 100644 --- a/tests/ui/type-alias-impl-trait/nested-tait-inference.current.stderr +++ b/tests/ui/type-alias-impl-trait/nested-tait-inference.current.stderr @@ -7,8 +7,12 @@ LL | fn foo() -> impl Foo { LL | () | -- return type was inferred to be `()` here | - = help: the trait `Foo` is not implemented for `()` - but trait `Foo<()>` is implemented for it +help: the trait `Foo` is not implemented for `()` + but trait `Foo<()>` is implemented for it + --> $DIR/nested-tait-inference.rs:15:1 + | +LL | impl Foo<()> for () {} + | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/self-referential-2.current.stderr b/tests/ui/type-alias-impl-trait/self-referential-2.current.stderr index dca3ae05bb0e..2855c90234d2 100644 --- a/tests/ui/type-alias-impl-trait/self-referential-2.current.stderr +++ b/tests/ui/type-alias-impl-trait/self-referential-2.current.stderr @@ -6,8 +6,10 @@ LL | fn bar() -> Bar { LL | 42_i32 | ------ return type was inferred to be `i32` here | - = help: the trait `PartialEq` is not implemented for `i32` - but trait `PartialEq` is implemented for it +help: the trait `PartialEq` is not implemented for `i32` + but trait `PartialEq` is implemented for it + --> $SRC_DIR/core/src/cmp.rs:LL:COL + = note: this error originates in the macro `partial_eq_impl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/typeck/suggestions/suggest-similar-impls-for-root-obligation.stderr b/tests/ui/typeck/suggestions/suggest-similar-impls-for-root-obligation.stderr index 5c0d98735f7f..e271f8df55ff 100644 --- a/tests/ui/typeck/suggestions/suggest-similar-impls-for-root-obligation.stderr +++ b/tests/ui/typeck/suggestions/suggest-similar-impls-for-root-obligation.stderr @@ -4,8 +4,12 @@ error[E0277]: the trait bound `((),): Into` is not satisfied LL | let _: Bar = ((),).into(); | ^^^^ the trait `Foo<'_>` is not implemented for `((),)` | - = help: the trait `Foo<'_>` is not implemented for `((),)` - but it is implemented for `()` +help: the trait `Foo<'_>` is not implemented for `((),)` + but it is implemented for `()` + --> $DIR/suggest-similar-impls-for-root-obligation.rs:3:1 + | +LL | impl<'s> Foo<'s> for () {} + | ^^^^^^^^^^^^^^^^^^^^^^^ = help: for that trait implementation, expected `()`, found `((),)` note: required for `Bar` to implement `From<((),)>` --> $DIR/suggest-similar-impls-for-root-obligation.rs:7:22