about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2022-07-01 23:39:09 +0200
committerGitHub <noreply@github.com>2022-07-01 23:39:09 +0200
commitb0935b1ddf12f96546df32d805b7dd874459f4cb (patch)
treea65d54f984425280be478034cc92d7a53e75dc60 /src
parentbda659e873f25d8891c02c5a6fb7d07ecf1efe5f (diff)
parent6711313f76b712271b10080067ebd4e0034b6be8 (diff)
downloadrust-b0935b1ddf12f96546df32d805b7dd874459f4cb.tar.gz
rust-b0935b1ddf12f96546df32d805b7dd874459f4cb.zip
Rollup merge of #98497 - compiler-errors:span-inference-note, r=lcnr
Improve some inference diagnostics

- Properly point out point location where "type must be known at this point", or else omit the note if it's not associated with a useful span.
- Fix up some type ambiguity diagnostics, errors shouldn't say "cannot infer type for reference `&'a ()`" when the given type has no inference variables.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/array-slice-vec/infer_array_len.stderr1
-rw-r--r--src/test/ui/array-slice-vec/slice-pat-type-mismatches.stderr2
-rw-r--r--src/test/ui/cast/issue-85586.stderr2
-rw-r--r--src/test/ui/coherence/coherence-overlap-trait-alias.stderr4
-rw-r--r--src/test/ui/const-generics/generic_arg_infer/issue-91614.stderr2
-rw-r--r--src/test/ui/const-generics/generic_const_exprs/issue-72787.min.stderr8
-rw-r--r--src/test/ui/const-generics/generic_const_exprs/issue-72787.rs4
-rw-r--r--src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr4
-rw-r--r--src/test/ui/inference/cannot-infer-partial-try-return.stderr3
-rw-r--r--src/test/ui/inference/erase-type-params-in-label.stderr4
-rw-r--r--src/test/ui/inference/issue-72616.stderr4
-rw-r--r--src/test/ui/inference/issue-72690.stderr2
-rw-r--r--src/test/ui/inference/issue-86162-1.stderr4
-rw-r--r--src/test/ui/inference/issue-86162-2.stderr4
-rw-r--r--src/test/ui/issues/issue-12028.stderr10
-rw-r--r--src/test/ui/issues/issue-15965.stderr2
-rw-r--r--src/test/ui/issues/issue-20261.stderr2
-rw-r--r--src/test/ui/issues/issue-2151.stderr3
-rw-r--r--src/test/ui/issues/issue-21974.stderr4
-rw-r--r--src/test/ui/issues/issue-24424.stderr4
-rw-r--r--src/test/ui/issues/issue-51116.rs1
-rw-r--r--src/test/ui/issues/issue-51116.stderr2
-rw-r--r--src/test/ui/issues/issue-69455.stderr4
-rw-r--r--src/test/ui/issues/issue-69683.stderr10
-rw-r--r--src/test/ui/issues/issue-71584.stderr14
-rw-r--r--src/test/ui/issues/issue-7813.stderr2
-rw-r--r--src/test/ui/lazy-type-alias-impl-trait/branches3.stderr12
-rw-r--r--src/test/ui/lifetimes/issue-34979.stderr4
-rw-r--r--src/test/ui/marker_trait_attr/region-overlap.stderr8
-rw-r--r--src/test/ui/pattern/issue-88074-pat-range-type-inference-err.stderr2
-rw-r--r--src/test/ui/pattern/pat-tuple-bad-type.stderr4
-rw-r--r--src/test/ui/span/issue-42234-unknown-receiver-type.full.stderr4
-rw-r--r--src/test/ui/span/issue-42234-unknown-receiver-type.generic_arg.stderr4
-rw-r--r--src/test/ui/span/method-and-field-eager-resolution.stderr8
-rw-r--r--src/test/ui/span/type-annotations-needed-expr.stderr1
-rw-r--r--src/test/ui/suggestions/suggest-closure-return-type-1.stderr2
-rw-r--r--src/test/ui/suggestions/suggest-closure-return-type-2.stderr2
-rw-r--r--src/test/ui/suggestions/suggest-closure-return-type-3.stderr2
-rw-r--r--src/test/ui/traits/issue-77982.stderr12
-rw-r--r--src/test/ui/traits/issue-85735.rs2
-rw-r--r--src/test/ui/traits/issue-85735.stderr4
-rw-r--r--src/test/ui/type-alias-impl-trait/closures_in_branches.stderr6
-rw-r--r--src/test/ui/type-alias-impl-trait/fallback.stderr2
-rw-r--r--src/test/ui/type/type-check/cannot_infer_local_or_array.stderr2
-rw-r--r--src/test/ui/type/type-check/issue-40294.stderr4
-rw-r--r--src/test/ui/typeck/issue-65611.stderr2
-rw-r--r--src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr4
47 files changed, 108 insertions, 89 deletions
diff --git a/src/test/ui/array-slice-vec/infer_array_len.stderr b/src/test/ui/array-slice-vec/infer_array_len.stderr
index 8da6d97251b..919550cac30 100644
--- a/src/test/ui/array-slice-vec/infer_array_len.stderr
+++ b/src/test/ui/array-slice-vec/infer_array_len.stderr
@@ -4,7 +4,6 @@ error[E0282]: type annotations needed
 LL |     let [_, _] = a.into();
    |         ^^^^^^
    |
-   = note: type must be known at this point
 help: consider giving this pattern a type
    |
 LL |     let [_, _]: _ = a.into();
diff --git a/src/test/ui/array-slice-vec/slice-pat-type-mismatches.stderr b/src/test/ui/array-slice-vec/slice-pat-type-mismatches.stderr
index 20a5b99845b..70a4cbebeee 100644
--- a/src/test/ui/array-slice-vec/slice-pat-type-mismatches.stderr
+++ b/src/test/ui/array-slice-vec/slice-pat-type-mismatches.stderr
@@ -27,8 +27,6 @@ error[E0282]: type annotations needed
    |
 LL |         [] => {}
    |         ^^ cannot infer type
-   |
-   = note: type must be known at this point
 
 error: aborting due to 5 previous errors
 
diff --git a/src/test/ui/cast/issue-85586.stderr b/src/test/ui/cast/issue-85586.stderr
index 271885a133a..ed8a6fc62e9 100644
--- a/src/test/ui/cast/issue-85586.stderr
+++ b/src/test/ui/cast/issue-85586.stderr
@@ -3,8 +3,6 @@ error[E0282]: type annotations needed
    |
 LL |     let b = (a + 1) as usize;
    |             ^^^^^^^ cannot infer type
-   |
-   = note: type must be known at this point
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/coherence/coherence-overlap-trait-alias.stderr b/src/test/ui/coherence/coherence-overlap-trait-alias.stderr
index 421c86ee51a..e324c1e799f 100644
--- a/src/test/ui/coherence/coherence-overlap-trait-alias.stderr
+++ b/src/test/ui/coherence/coherence-overlap-trait-alias.stderr
@@ -1,8 +1,8 @@
-error[E0283]: type annotations needed
+error[E0283]: type annotations needed: cannot satisfy `u32: C`
   --> $DIR/coherence-overlap-trait-alias.rs:15:6
    |
 LL | impl C for u32 {}
-   |      ^ cannot infer type for type `u32`
+   |      ^
    |
 note: multiple `impl`s satisfying `u32: C` found
   --> $DIR/coherence-overlap-trait-alias.rs:14:1
diff --git a/src/test/ui/const-generics/generic_arg_infer/issue-91614.stderr b/src/test/ui/const-generics/generic_arg_infer/issue-91614.stderr
index 463605e2431..688db695fa8 100644
--- a/src/test/ui/const-generics/generic_arg_infer/issue-91614.stderr
+++ b/src/test/ui/const-generics/generic_arg_infer/issue-91614.stderr
@@ -2,7 +2,7 @@ error[E0283]: type annotations needed for `Mask<_, LANES>`
   --> $DIR/issue-91614.rs:6:9
    |
 LL |     let y = Mask::<_, _>::splat(false);
-   |         ^
+   |         ^   ------------------- type must be known at this point
    |
    = note: cannot satisfy `_: MaskElement`
 note: required by a bound in `Mask::<T, LANES>::splat`
diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-72787.min.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-72787.min.stderr
index 02dce4f7a97..41afaec86b6 100644
--- a/src/test/ui/const-generics/generic_const_exprs/issue-72787.min.stderr
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-72787.min.stderr
@@ -34,19 +34,19 @@ LL |     IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
    = help: const parameters may only be used as standalone arguments, i.e. `J`
    = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
 
-error[E0283]: type annotations needed
+error[E0283]: type annotations needed: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`
   --> $DIR/issue-72787.rs:21:26
    |
 LL |     IsLessOrEqual<I, 8>: True,
-   |                          ^^^^ cannot infer type for struct `IsLessOrEqual<I, 8_u32>`
+   |                          ^^^^
    |
    = note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`
 
-error[E0283]: type annotations needed
+error[E0283]: type annotations needed: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`
   --> $DIR/issue-72787.rs:21:26
    |
 LL |     IsLessOrEqual<I, 8>: True,
-   |                          ^^^^ cannot infer type for struct `IsLessOrEqual<I, 8_u32>`
+   |                          ^^^^
    |
    = note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`
 
diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-72787.rs b/src/test/ui/const-generics/generic_const_exprs/issue-72787.rs
index 77ad57f0640..c651bf1c8de 100644
--- a/src/test/ui/const-generics/generic_const_exprs/issue-72787.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-72787.rs
@@ -19,8 +19,8 @@ struct S<const I: u32, const J: u32>;
 impl<const I: u32, const J: u32> S<I, J>
 where
     IsLessOrEqual<I, 8>: True,
-//[min]~^ Error type annotations needed [E0283]
-//[min]~| Error type annotations needed [E0283]
+//[min]~^ Error type annotations needed
+//[min]~| Error type annotations needed
     IsLessOrEqual<J, 8>: True,
     IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
 //[min]~^ Error generic parameters may not be used in const operations
diff --git a/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr b/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr
index 11ba5aa7867..957052feba9 100644
--- a/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr
+++ b/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr
@@ -3,16 +3,12 @@ error[E0282]: type annotations needed
    |
 LL |         cont.reify_as();
    |         ^^^^ cannot infer type
-   |
-   = note: type must be known at this point
 
 error[E0282]: type annotations needed
   --> $DIR/hidden-type-is-opaque-2.rs:18:9
    |
 LL |         cont.reify_as();
    |         ^^^^ cannot infer type
-   |
-   = note: type must be known at this point
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/inference/cannot-infer-partial-try-return.stderr b/src/test/ui/inference/cannot-infer-partial-try-return.stderr
index 220602c124c..c1e43f0b721 100644
--- a/src/test/ui/inference/cannot-infer-partial-try-return.stderr
+++ b/src/test/ui/inference/cannot-infer-partial-try-return.stderr
@@ -3,6 +3,9 @@ error[E0282]: type annotations needed for `Result<(), QualifiedError<_>>`
    |
 LL |     let x = || -> Result<_, QualifiedError<_>> {
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL |         infallible()?;
+   |         ------------- type must be known at this point
    |
 help: try giving this closure an explicit return type
    |
diff --git a/src/test/ui/inference/erase-type-params-in-label.stderr b/src/test/ui/inference/erase-type-params-in-label.stderr
index fd58844c238..7bb281802d2 100644
--- a/src/test/ui/inference/erase-type-params-in-label.stderr
+++ b/src/test/ui/inference/erase-type-params-in-label.stderr
@@ -2,7 +2,7 @@ error[E0283]: type annotations needed for `Foo<i32, &str, W, Z>`
   --> $DIR/erase-type-params-in-label.rs:2:9
    |
 LL |     let foo = foo(1, "");
-   |         ^^^
+   |         ^^^   --- type must be known at this point
    |
    = note: cannot satisfy `_: Default`
 note: required by a bound in `foo`
@@ -23,7 +23,7 @@ error[E0283]: type annotations needed for `Bar<i32, &str, Z>`
   --> $DIR/erase-type-params-in-label.rs:5:9
    |
 LL |     let bar = bar(1, "");
-   |         ^^^
+   |         ^^^   --- type must be known at this point
    |
    = note: cannot satisfy `_: Default`
 note: required by a bound in `bar`
diff --git a/src/test/ui/inference/issue-72616.stderr b/src/test/ui/inference/issue-72616.stderr
index 3c53d8126e7..a71ce9a8ef2 100644
--- a/src/test/ui/inference/issue-72616.stderr
+++ b/src/test/ui/inference/issue-72616.stderr
@@ -2,7 +2,9 @@ error[E0283]: type annotations needed
   --> $DIR/issue-72616.rs:20:37
    |
 LL |         if String::from("a") == "a".try_into().unwrap() {}
-   |                                     ^^^^^^^^
+   |                              --     ^^^^^^^^
+   |                              |
+   |                              type must be known at this point
    |
    = note: multiple `impl`s satisfying `String: PartialEq<_>` found in the `alloc` crate:
            - impl PartialEq for String;
diff --git a/src/test/ui/inference/issue-72690.stderr b/src/test/ui/inference/issue-72690.stderr
index 9edf14ef291..d4eeda07366 100644
--- a/src/test/ui/inference/issue-72690.stderr
+++ b/src/test/ui/inference/issue-72690.stderr
@@ -55,7 +55,7 @@ error[E0283]: type annotations needed for `&T`
   --> $DIR/issue-72690.rs:17:9
    |
 LL |     let _ = "x".as_ref();
-   |         ^
+   |         ^       ------ type must be known at this point
    |
    = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`:
            - impl AsRef<OsStr> for str;
diff --git a/src/test/ui/inference/issue-86162-1.stderr b/src/test/ui/inference/issue-86162-1.stderr
index 6641b29b30b..e395e65fad0 100644
--- a/src/test/ui/inference/issue-86162-1.stderr
+++ b/src/test/ui/inference/issue-86162-1.stderr
@@ -2,7 +2,9 @@ error[E0283]: type annotations needed
   --> $DIR/issue-86162-1.rs:7:9
    |
 LL |     foo(gen()); //<- Do not suggest `foo::<impl Clone>()`!
-   |         ^^^ cannot infer type of the type parameter `T` declared on the function `gen`
+   |     --- ^^^ cannot infer type of the type parameter `T` declared on the function `gen`
+   |     |
+   |     type must be known at this point
    |
    = note: cannot satisfy `_: Clone`
 note: required by a bound in `foo`
diff --git a/src/test/ui/inference/issue-86162-2.stderr b/src/test/ui/inference/issue-86162-2.stderr
index d2a026a9269..30e6e10eaa2 100644
--- a/src/test/ui/inference/issue-86162-2.stderr
+++ b/src/test/ui/inference/issue-86162-2.stderr
@@ -2,7 +2,9 @@ error[E0283]: type annotations needed
   --> $DIR/issue-86162-2.rs:12:14
    |
 LL |     Foo::bar(gen()); //<- Do not suggest `Foo::bar::<impl Clone>()`!
-   |              ^^^ cannot infer type of the type parameter `T` declared on the function `gen`
+   |     -------- ^^^ cannot infer type of the type parameter `T` declared on the function `gen`
+   |     |
+   |     type must be known at this point
    |
    = note: cannot satisfy `_: Clone`
 note: required by a bound in `Foo::bar`
diff --git a/src/test/ui/issues/issue-12028.stderr b/src/test/ui/issues/issue-12028.stderr
index 30cb7a1df80..8d6b81c24b6 100644
--- a/src/test/ui/issues/issue-12028.stderr
+++ b/src/test/ui/issues/issue-12028.stderr
@@ -1,8 +1,14 @@
-error[E0284]: type annotations needed: cannot satisfy `<_ as StreamHasher>::S == <H as StreamHasher>::S`
+error[E0284]: type annotations needed
   --> $DIR/issue-12028.rs:27:14
    |
 LL |         self.input_stream(&mut stream);
-   |              ^^^^^^^^^^^^ cannot satisfy `<_ as StreamHasher>::S == <H as StreamHasher>::S`
+   |              ^^^^^^^^^^^^
+   |
+   = note: cannot satisfy `<_ as StreamHasher>::S == <H as StreamHasher>::S`
+help: try using a fully qualified path to specify the expected types
+   |
+LL |         <u8 as StreamHash<H>>::input_stream(self, &mut stream);
+   |         ++++++++++++++++++++++++++++++++++++    ~
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-15965.stderr b/src/test/ui/issues/issue-15965.stderr
index 90377c19dee..fe06810b8df 100644
--- a/src/test/ui/issues/issue-15965.stderr
+++ b/src/test/ui/issues/issue-15965.stderr
@@ -5,8 +5,6 @@ LL | /         { return () }
 LL | |
 LL | |     ()
    | |______^ cannot infer type
-   |
-   = note: type must be known at this point
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-20261.stderr b/src/test/ui/issues/issue-20261.stderr
index 73468c7ca16..9ac751e4dc4 100644
--- a/src/test/ui/issues/issue-20261.stderr
+++ b/src/test/ui/issues/issue-20261.stderr
@@ -3,8 +3,6 @@ error[E0282]: type annotations needed
    |
 LL |         i.clone();
    |           ^^^^^ cannot infer type
-   |
-   = note: type must be known at this point
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-2151.stderr b/src/test/ui/issues/issue-2151.stderr
index e0d946205ad..31a8ca5fbfa 100644
--- a/src/test/ui/issues/issue-2151.stderr
+++ b/src/test/ui/issues/issue-2151.stderr
@@ -3,8 +3,9 @@ error[E0282]: type annotations needed
    |
 LL |     let x = panic!();
    |         ^
+LL |     x.clone();
+   |     - type must be known at this point
    |
-   = note: type must be known at this point
 help: consider giving `x` an explicit type
    |
 LL |     let x: _ = panic!();
diff --git a/src/test/ui/issues/issue-21974.stderr b/src/test/ui/issues/issue-21974.stderr
index dfabde9abc9..4e010a13653 100644
--- a/src/test/ui/issues/issue-21974.stderr
+++ b/src/test/ui/issues/issue-21974.stderr
@@ -1,8 +1,8 @@
-error[E0283]: type annotations needed
+error[E0283]: type annotations needed: cannot satisfy `&'a T: Foo`
   --> $DIR/issue-21974.rs:11:19
    |
 LL |     where &'a T : Foo,
-   |                   ^^^ cannot infer type for reference `&'a T`
+   |                   ^^^
    |
    = note: cannot satisfy `&'a T: Foo`
 
diff --git a/src/test/ui/issues/issue-24424.stderr b/src/test/ui/issues/issue-24424.stderr
index fa59da852f9..8f3b2ac7319 100644
--- a/src/test/ui/issues/issue-24424.stderr
+++ b/src/test/ui/issues/issue-24424.stderr
@@ -1,8 +1,8 @@
-error[E0283]: type annotations needed
+error[E0283]: type annotations needed: cannot satisfy `T0: Trait0<'l0>`
   --> $DIR/issue-24424.rs:4:57
    |
 LL | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {}
-   |                                                         ^^^^^^^^^^^ cannot infer type for type parameter `T0`
+   |                                                         ^^^^^^^^^^^
    |
    = note: cannot satisfy `T0: Trait0<'l0>`
 
diff --git a/src/test/ui/issues/issue-51116.rs b/src/test/ui/issues/issue-51116.rs
index c979c7b2cdd..4c21cbfc61d 100644
--- a/src/test/ui/issues/issue-51116.rs
+++ b/src/test/ui/issues/issue-51116.rs
@@ -5,7 +5,6 @@ fn main() {
             *tile = 0;
             //~^ ERROR type annotations needed
             //~| NOTE cannot infer type
-            //~| NOTE type must be known at this point
         }
     }
 
diff --git a/src/test/ui/issues/issue-51116.stderr b/src/test/ui/issues/issue-51116.stderr
index 399b421ab16..c07f8735eb2 100644
--- a/src/test/ui/issues/issue-51116.stderr
+++ b/src/test/ui/issues/issue-51116.stderr
@@ -3,8 +3,6 @@ error[E0282]: type annotations needed
    |
 LL |             *tile = 0;
    |             ^^^^^ cannot infer type
-   |
-   = note: type must be known at this point
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-69455.stderr b/src/test/ui/issues/issue-69455.stderr
index 6c4eafbc8b3..9be6c2f8564 100644
--- a/src/test/ui/issues/issue-69455.stderr
+++ b/src/test/ui/issues/issue-69455.stderr
@@ -14,7 +14,9 @@ error[E0283]: type annotations needed
   --> $DIR/issue-69455.rs:29:41
    |
 LL |     println!("{}", 23u64.test(xs.iter().sum()));
-   |                                         ^^^ cannot infer type of the type parameter `S` declared on the associated function `sum`
+   |                          ----           ^^^ cannot infer type of the type parameter `S` declared on the associated function `sum`
+   |                          |
+   |                          type must be known at this point
    |
 note: multiple `impl`s satisfying `u64: Test<_>` found
   --> $DIR/issue-69455.rs:11:1
diff --git a/src/test/ui/issues/issue-69683.stderr b/src/test/ui/issues/issue-69683.stderr
index 9c71ecffa26..193de1a35cf 100644
--- a/src/test/ui/issues/issue-69683.stderr
+++ b/src/test/ui/issues/issue-69683.stderr
@@ -1,8 +1,14 @@
-error[E0284]: type annotations needed: cannot satisfy `<u8 as Element<_>>::Array == [u8; 3]`
+error[E0284]: type annotations needed
   --> $DIR/issue-69683.rs:30:10
    |
 LL |     0u16.foo(b);
-   |          ^^^ cannot satisfy `<u8 as Element<_>>::Array == [u8; 3]`
+   |          ^^^
+   |
+   = note: cannot satisfy `<u8 as Element<_>>::Array == [u8; 3]`
+help: try using a fully qualified path to specify the expected types
+   |
+LL |     <u16 as Foo<I>>::foo(0u16, b);
+   |     +++++++++++++++++++++    ~
 
 error[E0283]: type annotations needed
   --> $DIR/issue-69683.rs:30:10
diff --git a/src/test/ui/issues/issue-71584.stderr b/src/test/ui/issues/issue-71584.stderr
index 1c216e64982..6ddb7657301 100644
--- a/src/test/ui/issues/issue-71584.stderr
+++ b/src/test/ui/issues/issue-71584.stderr
@@ -1,8 +1,16 @@
-error[E0284]: type annotations needed: cannot satisfy `<u64 as Rem<_>>::Output == u64`
-  --> $DIR/issue-71584.rs:4:11
+error[E0284]: type annotations needed
+  --> $DIR/issue-71584.rs:4:15
    |
 LL |     d = d % n.into();
-   |           ^ cannot satisfy `<u64 as Rem<_>>::Output == u64`
+   |           -   ^^^^
+   |           |
+   |           type must be known at this point
+   |
+   = note: cannot satisfy `<u64 as Rem<_>>::Output == u64`
+help: try using a fully qualified path to specify the expected types
+   |
+LL |     d = d % <u32 as Into<T>>::into(n);
+   |             +++++++++++++++++++++++ ~
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-7813.stderr b/src/test/ui/issues/issue-7813.stderr
index 3aee61bd5a5..2a747f679a8 100644
--- a/src/test/ui/issues/issue-7813.stderr
+++ b/src/test/ui/issues/issue-7813.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `&[_; 0]`
   --> $DIR/issue-7813.rs:2:9
    |
 LL |     let v = &[];
-   |         ^
+   |         ^   --- type must be known at this point
    |
 help: consider giving `v` an explicit type, where the placeholders `_` are specified
    |
diff --git a/src/test/ui/lazy-type-alias-impl-trait/branches3.stderr b/src/test/ui/lazy-type-alias-impl-trait/branches3.stderr
index 77ce1d48480..420104e526d 100644
--- a/src/test/ui/lazy-type-alias-impl-trait/branches3.stderr
+++ b/src/test/ui/lazy-type-alias-impl-trait/branches3.stderr
@@ -2,9 +2,8 @@ error[E0282]: type annotations needed
   --> $DIR/branches3.rs:8:10
    |
 LL |         |s| s.len()
-   |          ^
+   |          ^  - type must be known at this point
    |
-   = note: type must be known at this point
 help: consider giving this closure parameter an explicit type
    |
 LL |         |s: _| s.len()
@@ -14,9 +13,8 @@ error[E0282]: type annotations needed
   --> $DIR/branches3.rs:15:10
    |
 LL |         |s| s.len()
-   |          ^
+   |          ^  - type must be known at this point
    |
-   = note: type must be known at this point
 help: consider giving this closure parameter an explicit type
    |
 LL |         |s: _| s.len()
@@ -26,9 +24,8 @@ error[E0282]: type annotations needed
   --> $DIR/branches3.rs:23:10
    |
 LL |         |s| s.len()
-   |          ^
+   |          ^  - type must be known at this point
    |
-   = note: type must be known at this point
 help: consider giving this closure parameter an explicit type
    |
 LL |         |s: _| s.len()
@@ -38,9 +35,8 @@ error[E0282]: type annotations needed
   --> $DIR/branches3.rs:30:10
    |
 LL |         |s| s.len()
-   |          ^
+   |          ^  - type must be known at this point
    |
-   = note: type must be known at this point
 help: consider giving this closure parameter an explicit type
    |
 LL |         |s: _| s.len()
diff --git a/src/test/ui/lifetimes/issue-34979.stderr b/src/test/ui/lifetimes/issue-34979.stderr
index 1b97f8d818a..5832c4d173c 100644
--- a/src/test/ui/lifetimes/issue-34979.stderr
+++ b/src/test/ui/lifetimes/issue-34979.stderr
@@ -1,8 +1,8 @@
-error[E0283]: type annotations needed
+error[E0283]: type annotations needed: cannot satisfy `&'a (): Foo`
   --> $DIR/issue-34979.rs:6:13
    |
 LL |     &'a (): Foo,
-   |             ^^^ cannot infer type for reference `&'a ()`
+   |             ^^^
    |
    = note: cannot satisfy `&'a (): Foo`
 
diff --git a/src/test/ui/marker_trait_attr/region-overlap.stderr b/src/test/ui/marker_trait_attr/region-overlap.stderr
index 2eeab801e3d..6631fe987e2 100644
--- a/src/test/ui/marker_trait_attr/region-overlap.stderr
+++ b/src/test/ui/marker_trait_attr/region-overlap.stderr
@@ -1,8 +1,8 @@
-error[E0283]: type annotations needed
+error[E0283]: type annotations needed: cannot satisfy `(&'static (), &'a ()): A`
   --> $DIR/region-overlap.rs:5:10
    |
 LL | impl<'a> A for (&'static (), &'a ()) {}
-   |          ^ cannot infer type for tuple `(&'static (), &'a ())`
+   |          ^
    |
 note: multiple `impl`s satisfying `(&'static (), &'a ()): A` found
   --> $DIR/region-overlap.rs:5:1
@@ -12,11 +12,11 @@ LL | impl<'a> A for (&'static (), &'a ()) {}
 LL | impl<'a> A for (&'a (), &'static ()) {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error[E0283]: type annotations needed
+error[E0283]: type annotations needed: cannot satisfy `(&'a (), &'static ()): A`
   --> $DIR/region-overlap.rs:6:10
    |
 LL | impl<'a> A for (&'a (), &'static ()) {}
-   |          ^ cannot infer type for tuple `(&'a (), &'static ())`
+   |          ^
    |
 note: multiple `impl`s satisfying `(&'a (), &'static ()): A` found
   --> $DIR/region-overlap.rs:5:1
diff --git a/src/test/ui/pattern/issue-88074-pat-range-type-inference-err.stderr b/src/test/ui/pattern/issue-88074-pat-range-type-inference-err.stderr
index 06a279925ed..8e528f8c1db 100644
--- a/src/test/ui/pattern/issue-88074-pat-range-type-inference-err.stderr
+++ b/src/test/ui/pattern/issue-88074-pat-range-type-inference-err.stderr
@@ -12,8 +12,6 @@ error[E0282]: type annotations needed
    |
 LL |         Zero::ZERO ..= Zero::ZERO => {},
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
-   |
-   = note: type must be known at this point
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/pattern/pat-tuple-bad-type.stderr b/src/test/ui/pattern/pat-tuple-bad-type.stderr
index 11b28987848..3342b8e4002 100644
--- a/src/test/ui/pattern/pat-tuple-bad-type.stderr
+++ b/src/test/ui/pattern/pat-tuple-bad-type.stderr
@@ -3,8 +3,10 @@ error[E0282]: type annotations needed
    |
 LL |     let x;
    |         ^
+...
+LL |         (..) => {}
+   |         ---- type must be known at this point
    |
-   = note: type must be known at this point
 help: consider giving `x` an explicit type
    |
 LL |     let x: _;
diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.full.stderr b/src/test/ui/span/issue-42234-unknown-receiver-type.full.stderr
index cd3ffdc6f9d..2b178990850 100644
--- a/src/test/ui/span/issue-42234-unknown-receiver-type.full.stderr
+++ b/src/test/ui/span/issue-42234-unknown-receiver-type.full.stderr
@@ -3,8 +3,9 @@ error[E0282]: type annotations needed
    |
 LL |     let x: Option<_> = None;
    |                        ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
+LL |     x.unwrap().method_that_could_exist_on_some_type();
+   |     ---------- type must be known at this point
    |
-   = note: type must be known at this point
 help: consider specifying the generic argument
    |
 LL |     let x: Option<_> = None::<T>;
@@ -16,7 +17,6 @@ error[E0282]: type annotations needed
 LL |         .sum::<_>()
    |          ^^^ cannot infer type of the type parameter `S` declared on the associated function `sum`
    |
-   = note: type must be known at this point
 help: consider specifying the generic argument
    |
 LL |         .sum::<_>()
diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.generic_arg.stderr b/src/test/ui/span/issue-42234-unknown-receiver-type.generic_arg.stderr
index b6a3f07f571..d93d54e878b 100644
--- a/src/test/ui/span/issue-42234-unknown-receiver-type.generic_arg.stderr
+++ b/src/test/ui/span/issue-42234-unknown-receiver-type.generic_arg.stderr
@@ -3,8 +3,9 @@ error[E0282]: type annotations needed
    |
 LL |     let x: Option<_> = None;
    |                        ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
+LL |     x.unwrap().method_that_could_exist_on_some_type();
+   |     ---------- type must be known at this point
    |
-   = note: type must be known at this point
 help: consider specifying the generic argument
    |
 LL |     let x: Option<_> = None::<T>;
@@ -16,7 +17,6 @@ error[E0282]: type annotations needed
 LL |         .sum::<_>()
    |          ^^^ cannot infer type of the type parameter `S` declared on the associated function `sum`
    |
-   = note: type must be known at this point
 help: consider specifying the generic argument
    |
 LL |         .sum::<S>()
diff --git a/src/test/ui/span/method-and-field-eager-resolution.stderr b/src/test/ui/span/method-and-field-eager-resolution.stderr
index 2dd650f38ce..7d240589a3f 100644
--- a/src/test/ui/span/method-and-field-eager-resolution.stderr
+++ b/src/test/ui/span/method-and-field-eager-resolution.stderr
@@ -3,8 +3,10 @@ error[E0282]: type annotations needed
    |
 LL |     let mut x = Default::default();
    |         ^^^^^
+LL |
+LL |     x.0;
+   |     - type must be known at this point
    |
-   = note: type must be known at this point
 help: consider giving `x` an explicit type
    |
 LL |     let mut x: _ = Default::default();
@@ -15,8 +17,10 @@ error[E0282]: type annotations needed
    |
 LL |     let mut x = Default::default();
    |         ^^^^^
+LL |
+LL |     x[0];
+   |     - type must be known at this point
    |
-   = note: type must be known at this point
 help: consider giving `x` an explicit type
    |
 LL |     let mut x: _ = Default::default();
diff --git a/src/test/ui/span/type-annotations-needed-expr.stderr b/src/test/ui/span/type-annotations-needed-expr.stderr
index e4a8f746462..9dff6c64db4 100644
--- a/src/test/ui/span/type-annotations-needed-expr.stderr
+++ b/src/test/ui/span/type-annotations-needed-expr.stderr
@@ -4,7 +4,6 @@ error[E0282]: type annotations needed
 LL |     let _ = (vec![1,2,3]).into_iter().sum() as f64;
    |                                       ^^^ cannot infer type of the type parameter `S` declared on the associated function `sum`
    |
-   = note: type must be known at this point
 help: consider specifying the generic argument
    |
 LL |     let _ = (vec![1,2,3]).into_iter().sum::<S>() as f64;
diff --git a/src/test/ui/suggestions/suggest-closure-return-type-1.stderr b/src/test/ui/suggestions/suggest-closure-return-type-1.stderr
index 3116211b52c..f4c2eb7ff34 100644
--- a/src/test/ui/suggestions/suggest-closure-return-type-1.stderr
+++ b/src/test/ui/suggestions/suggest-closure-return-type-1.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `[_; 0]`
   --> $DIR/suggest-closure-return-type-1.rs:4:18
    |
 LL |     unbound_drop(|| -> _ { [] });
-   |                  ^^^^^^^
+   |                  ^^^^^^^   -- type must be known at this point
    |
 help: try giving this closure an explicit return type
    |
diff --git a/src/test/ui/suggestions/suggest-closure-return-type-2.stderr b/src/test/ui/suggestions/suggest-closure-return-type-2.stderr
index f368e7de467..88bf263043d 100644
--- a/src/test/ui/suggestions/suggest-closure-return-type-2.stderr
+++ b/src/test/ui/suggestions/suggest-closure-return-type-2.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `[_; 0]`
   --> $DIR/suggest-closure-return-type-2.rs:4:18
    |
 LL |     unbound_drop(|| { [] })
-   |                  ^^
+   |                  ^^   -- type must be known at this point
    |
 help: try giving this closure an explicit return type
    |
diff --git a/src/test/ui/suggestions/suggest-closure-return-type-3.stderr b/src/test/ui/suggestions/suggest-closure-return-type-3.stderr
index 41769321533..bc4107528d2 100644
--- a/src/test/ui/suggestions/suggest-closure-return-type-3.stderr
+++ b/src/test/ui/suggestions/suggest-closure-return-type-3.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `[_; 0]`
   --> $DIR/suggest-closure-return-type-3.rs:4:18
    |
 LL |     unbound_drop(|| []);
-   |                  ^^
+   |                  ^^ -- type must be known at this point
    |
 help: try giving this closure an explicit return type
    |
diff --git a/src/test/ui/traits/issue-77982.stderr b/src/test/ui/traits/issue-77982.stderr
index 5aa42b5b1d3..a2d23c4e9df 100644
--- a/src/test/ui/traits/issue-77982.stderr
+++ b/src/test/ui/traits/issue-77982.stderr
@@ -26,7 +26,9 @@ error[E0283]: type annotations needed
   --> $DIR/issue-77982.rs:8:10
    |
 LL |     opts.get(opt.as_ref());
-   |          ^^^ cannot infer type of the type parameter `Q` declared on the associated function `get`
+   |          ^^^     ------ type must be known at this point
+   |          |
+   |          cannot infer type of the type parameter `Q` declared on the associated function `get`
    |
    = note: multiple `impl`s satisfying `String: AsRef<_>` found in the following crates: `alloc`, `std`:
            - impl AsRef<OsStr> for String;
@@ -42,7 +44,9 @@ error[E0283]: type annotations needed
   --> $DIR/issue-77982.rs:13:59
    |
 LL |     let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect();
-   |                                                           ^^^^
+   |                                            ---------      ^^^^
+   |                                            |
+   |                                            type must be known at this point
    |
    = note: multiple `impl`s satisfying `u32: From<_>` found in the following crates: `core`, `std`:
            - impl From<Ipv4Addr> for u32;
@@ -59,7 +63,7 @@ error[E0283]: type annotations needed for `Box<T>`
   --> $DIR/issue-77982.rs:36:9
    |
 LL |     let _ = ().foo();
-   |         ^
+   |         ^      --- type must be known at this point
    |
 note: multiple `impl`s satisfying `(): Foo<'_, _>` found
   --> $DIR/issue-77982.rs:29:1
@@ -77,7 +81,7 @@ error[E0283]: type annotations needed for `Box<T>`
   --> $DIR/issue-77982.rs:40:9
    |
 LL |     let _ = (&()).bar();
-   |         ^
+   |         ^         --- type must be known at this point
    |
 note: multiple `impl`s satisfying `&(): Bar<'_, _>` found
   --> $DIR/issue-77982.rs:32:1
diff --git a/src/test/ui/traits/issue-85735.rs b/src/test/ui/traits/issue-85735.rs
index 16e874ee21e..fb387a9c909 100644
--- a/src/test/ui/traits/issue-85735.rs
+++ b/src/test/ui/traits/issue-85735.rs
@@ -5,7 +5,7 @@ trait Foo {}
 impl<'a, 'b, T> Foo for T
 where
     T: FnMut(&'a ()),
-    //~^ ERROR: type annotations needed [E0283]
+    //~^ ERROR: type annotations needed
     T: FnMut(&'b ()),
 {
 }
diff --git a/src/test/ui/traits/issue-85735.stderr b/src/test/ui/traits/issue-85735.stderr
index 33b12ef09ec..fa280135beb 100644
--- a/src/test/ui/traits/issue-85735.stderr
+++ b/src/test/ui/traits/issue-85735.stderr
@@ -1,8 +1,8 @@
-error[E0283]: type annotations needed
+error[E0283]: type annotations needed: cannot satisfy `T: FnMut<(&'a (),)>`
   --> $DIR/issue-85735.rs:7:8
    |
 LL |     T: FnMut(&'a ()),
-   |        ^^^^^^^^^^^^^ cannot infer type for type parameter `T`
+   |        ^^^^^^^^^^^^^
    |
    = note: cannot satisfy `T: FnMut<(&'a (),)>`
 
diff --git a/src/test/ui/type-alias-impl-trait/closures_in_branches.stderr b/src/test/ui/type-alias-impl-trait/closures_in_branches.stderr
index b7a7871143c..48b7946ea82 100644
--- a/src/test/ui/type-alias-impl-trait/closures_in_branches.stderr
+++ b/src/test/ui/type-alias-impl-trait/closures_in_branches.stderr
@@ -2,9 +2,8 @@ error[E0282]: type annotations needed
   --> $DIR/closures_in_branches.rs:7:10
    |
 LL |         |x| x.len()
-   |          ^
+   |          ^  - type must be known at this point
    |
-   = note: type must be known at this point
 help: consider giving this closure parameter an explicit type
    |
 LL |         |x: _| x.len()
@@ -14,9 +13,8 @@ error[E0282]: type annotations needed
   --> $DIR/closures_in_branches.rs:21:10
    |
 LL |         |x| x.len()
-   |          ^
+   |          ^  - type must be known at this point
    |
-   = note: type must be known at this point
 help: consider giving this closure parameter an explicit type
    |
 LL |         |x: _| x.len()
diff --git a/src/test/ui/type-alias-impl-trait/fallback.stderr b/src/test/ui/type-alias-impl-trait/fallback.stderr
index e009399a60a..e767bfdb08b 100644
--- a/src/test/ui/type-alias-impl-trait/fallback.stderr
+++ b/src/test/ui/type-alias-impl-trait/fallback.stderr
@@ -1,6 +1,8 @@
 error[E0283]: type annotations needed
   --> $DIR/fallback.rs:24:5
    |
+LL | fn unconstrained_foo() -> Wrapper<Foo> {
+   |                           ------------ type must be known at this point
 LL |     Wrapper::Second
    |     ^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the enum `Wrapper`
    |
diff --git a/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr b/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr
index d68d5e5d40b..e823bad2668 100644
--- a/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr
+++ b/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `[_; 0]`
   --> $DIR/cannot_infer_local_or_array.rs:2:9
    |
 LL |     let x = [];
-   |         ^
+   |         ^   -- type must be known at this point
    |
 help: consider giving `x` an explicit type, where the placeholders `_` are specified
    |
diff --git a/src/test/ui/type/type-check/issue-40294.stderr b/src/test/ui/type/type-check/issue-40294.stderr
index 6d1e490bcf3..75feb5698eb 100644
--- a/src/test/ui/type/type-check/issue-40294.stderr
+++ b/src/test/ui/type/type-check/issue-40294.stderr
@@ -1,8 +1,8 @@
-error[E0283]: type annotations needed
+error[E0283]: type annotations needed: cannot satisfy `&'a T: Foo`
   --> $DIR/issue-40294.rs:6:19
    |
 LL |     where &'a T : Foo,
-   |                   ^^^ cannot infer type for reference `&'a T`
+   |                   ^^^
    |
    = note: cannot satisfy `&'a T: Foo`
 
diff --git a/src/test/ui/typeck/issue-65611.stderr b/src/test/ui/typeck/issue-65611.stderr
index 5f831291a38..003c630790d 100644
--- a/src/test/ui/typeck/issue-65611.stderr
+++ b/src/test/ui/typeck/issue-65611.stderr
@@ -3,8 +3,6 @@ error[E0282]: type annotations needed
    |
 LL |     let x = buffer.last().unwrap().0.clone();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`
-   |
-   = note: type must be known at this point
 
 error[E0609]: no field `0` on type `&_`
   --> $DIR/issue-65611.rs:59:36
diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr
index 666ab79b65c..ff2a597bed0 100644
--- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr
+++ b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr
@@ -3,8 +3,10 @@ error[E0282]: type annotations needed for `Option<T>`
    |
 LL |     let mut closure0 = None;
    |         ^^^^^^^^^^^^
+...
+LL |                         return c();
+   |                                --- type must be known at this point
    |
-   = note: type must be known at this point
 help: consider giving `closure0` an explicit type, where the placeholders `_` are specified
    |
 LL |     let mut closure0: Option<T> = None;