about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-08-17 00:21:40 +0000
committerMichael Goulet <michael@errs.io>2022-08-21 02:35:11 +0000
commitc8746766cb2e375c8b9eeb1bab656aca4cc2a9d1 (patch)
tree5d445492be1b740eaee20d4dc667cbe8221ba8b3
parent70b29f7c2d6d4b86d5b1492f3aa63969a62b25bf (diff)
downloadrust-c8746766cb2e375c8b9eeb1bab656aca4cc2a9d1.tar.gz
rust-c8746766cb2e375c8b9eeb1bab656aca4cc2a9d1.zip
Rework ambiguity errors
-rw-r--r--compiler/rustc_middle/src/ty/generics.rs11
-rw-r--r--compiler/rustc_typeck/src/check/fn_ctxt/checks.rs40
-rw-r--r--src/test/ui/error-codes/E0283.stderr21
-rw-r--r--src/test/ui/inference/issue-72690.stderr36
-rw-r--r--src/test/ui/issues/issue-69455.stderr7
-rw-r--r--src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr4
-rw-r--r--src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr4
-rw-r--r--src/test/ui/traits/issue-77982.stderr31
-rw-r--r--src/test/ui/traits/multidispatch-convert-ambig-dest.stderr2
-rw-r--r--src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr4
-rw-r--r--src/test/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr36
-rw-r--r--src/test/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr44
12 files changed, 95 insertions, 145 deletions
diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs
index add2df25884..6e8afd4d539 100644
--- a/compiler/rustc_middle/src/ty/generics.rs
+++ b/compiler/rustc_middle/src/ty/generics.rs
@@ -122,6 +122,17 @@ pub struct Generics {
 }
 
 impl<'tcx> Generics {
+    pub fn param_def_id_to_index(&self, tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<u32> {
+        if let Some(idx) = self.param_def_id_to_index.get(&def_id) {
+            Some(*idx)
+        } else if let Some(parent) = self.parent {
+            let parent = tcx.generics_of(parent);
+            parent.param_def_id_to_index(tcx, def_id)
+        } else {
+            None
+        }
+    }
+
     #[inline]
     pub fn count(&self) -> usize {
         self.parent_count + self.params.len()
diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
index 204bb6a532d..35a3ae3ebf7 100644
--- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
+++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
@@ -27,13 +27,14 @@ use rustc_infer::infer::InferOk;
 use rustc_infer::infer::TypeTrace;
 use rustc_middle::ty::adjustment::AllowTwoPhase;
 use rustc_middle::ty::visit::TypeVisitable;
-use rustc_middle::ty::{self, DefIdTree, IsSuggestable, Ty};
+use rustc_middle::ty::{self, DefIdTree, IsSuggestable, Ty, TypeSuperVisitable, TypeVisitor};
 use rustc_session::Session;
 use rustc_span::symbol::Ident;
 use rustc_span::{self, Span};
 use rustc_trait_selection::traits::{self, ObligationCauseCode, SelectionContext};
 
 use std::iter;
+use std::ops::ControlFlow;
 use std::slice;
 
 impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
@@ -1649,7 +1650,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             ty::PredicateKind::Projection(pred) => pred.projection_ty.substs,
             _ => ty::List::empty(),
         };
-        let param_to_point_at = predicate_substs.types().find_map(|ty| {
+        let mut param_to_point_at = predicate_substs.types().find_map(|ty| {
             ty.walk().find_map(|arg| {
                 if let ty::GenericArgKind::Type(ty) = arg.unpack()
                     && let ty::Param(param_ty) = ty.kind()
@@ -1663,7 +1664,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 }
             })
         });
-        let fallback_param_to_point_at = predicate_substs.types().find_map(|ty| {
+        let mut fallback_param_to_point_at = predicate_substs.types().find_map(|ty| {
             ty.walk().find_map(|arg| {
                 if let ty::GenericArgKind::Type(ty) = arg.unpack()
                     && let ty::Param(param_ty) = ty.kind()
@@ -1676,6 +1677,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             })
         });
 
+        // Also skip over ambiguity errors, which have their own machinery
+        // to print a relevant error.
+        if let traits::FulfillmentErrorCode::CodeAmbiguity = error.code {
+            fallback_param_to_point_at = None;
+            param_to_point_at =
+                self.find_ambiguous_parameter_in(def_id, error.root_obligation.predicate);
+        }
+
         let hir = self.tcx.hir();
 
         match hir.get(hir_id) {
@@ -1737,6 +1746,31 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         }
     }
 
+    fn find_ambiguous_parameter_in<T: TypeVisitable<'tcx>>(
+        &self,
+        item_def_id: DefId,
+        t: T,
+    ) -> Option<ty::GenericArg<'tcx>> {
+        struct FindAmbiguousParameter<'a, 'tcx>(&'a FnCtxt<'a, 'tcx>, DefId);
+        impl<'tcx> TypeVisitor<'tcx> for FindAmbiguousParameter<'_, 'tcx> {
+            type BreakTy = ty::GenericArg<'tcx>;
+            fn visit_ty(&mut self, ty: Ty<'tcx>) -> std::ops::ControlFlow<Self::BreakTy> {
+                if let Some(origin) = self.0.type_var_origin(ty)
+                    && let TypeVariableOriginKind::TypeParameterDefinition(_, Some(def_id))
+                        = origin.kind
+                    && let generics = self.0.tcx.generics_of(self.1)
+                    && let Some(index) = generics.param_def_id_to_index(self.0.tcx, def_id)
+                    && let Some(subst) = ty::InternalSubsts::identity_for_item(self.0.tcx, self.1).get(index as usize)
+                {
+                    ControlFlow::Break(*subst)
+                } else {
+                    ty.super_visit_with(self)
+                }
+            }
+        }
+        t.visit_with(&mut FindAmbiguousParameter(self, item_def_id)).break_value()
+    }
+
     fn point_at_args_if_possible(
         &self,
         error: &mut traits::FulfillmentError<'tcx>,
diff --git a/src/test/ui/error-codes/E0283.stderr b/src/test/ui/error-codes/E0283.stderr
index 162d4922d00..90a28874ead 100644
--- a/src/test/ui/error-codes/E0283.stderr
+++ b/src/test/ui/error-codes/E0283.stderr
@@ -12,24 +12,11 @@ help: use a fully-qualified path to a specific available implementation (2 found
 LL |     let cont: u32 = <::Impl as Generator>::create();
    |                     ++++++++++          +
 
-error[E0282]: type annotations needed
-  --> $DIR/E0283.rs:35:24
-   |
-LL |     let bar = foo_impl.into() * 1u32;
-   |                        ^^^^
-   |
-help: try using a fully qualified path to specify the expected types
-   |
-LL |     let bar = <Impl as Into<T>>::into(foo_impl) * 1u32;
-   |               ++++++++++++++++++++++++        ~
-
 error[E0283]: type annotations needed
   --> $DIR/E0283.rs:35:24
    |
 LL |     let bar = foo_impl.into() * 1u32;
-   |               -------- ^^^^
-   |               |
-   |               type must be known at this point
+   |                        ^^^^
    |
 note: multiple `impl`s satisfying `Impl: Into<_>` found
   --> $DIR/E0283.rs:17:1
@@ -44,7 +31,7 @@ help: try using a fully qualified path to specify the expected types
 LL |     let bar = <Impl as Into<T>>::into(foo_impl) * 1u32;
    |               ++++++++++++++++++++++++        ~
 
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
 
-Some errors have detailed explanations: E0282, E0283, E0790.
-For more information about an error, try `rustc --explain E0282`.
+Some errors have detailed explanations: E0283, E0790.
+For more information about an error, try `rustc --explain E0283`.
diff --git a/src/test/ui/inference/issue-72690.stderr b/src/test/ui/inference/issue-72690.stderr
index 3504b294ab2..d4eeda07366 100644
--- a/src/test/ui/inference/issue-72690.stderr
+++ b/src/test/ui/inference/issue-72690.stderr
@@ -12,9 +12,7 @@ error[E0283]: type annotations needed
   --> $DIR/issue-72690.rs:7:22
    |
 LL |     String::from("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;
@@ -41,9 +39,7 @@ error[E0283]: type annotations needed
   --> $DIR/issue-72690.rs:12:26
    |
 LL |     |x| String::from("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;
@@ -59,9 +55,7 @@ error[E0283]: type annotations needed for `&T`
   --> $DIR/issue-72690.rs:17:9
    |
 LL |     let _ = "x".as_ref();
-   |         ^   --- ------ required by a bound introduced by this call
-   |             |
-   |             type must be known at this point
+   |         ^       ------ 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;
@@ -87,9 +81,7 @@ error[E0283]: type annotations needed
   --> $DIR/issue-72690.rs:21:22
    |
 LL |     String::from("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;
@@ -115,9 +107,7 @@ error[E0283]: type annotations needed
   --> $DIR/issue-72690.rs:28:22
    |
 LL |     String::from("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;
@@ -143,9 +133,7 @@ error[E0283]: type annotations needed
   --> $DIR/issue-72690.rs:37:22
    |
 LL |     String::from("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;
@@ -171,9 +159,7 @@ error[E0283]: type annotations needed
   --> $DIR/issue-72690.rs:46:22
    |
 LL |     String::from("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;
@@ -199,9 +185,7 @@ error[E0283]: type annotations needed
   --> $DIR/issue-72690.rs:53:22
    |
 LL |     String::from("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;
@@ -227,9 +211,7 @@ error[E0283]: type annotations needed
   --> $DIR/issue-72690.rs:62:22
    |
 LL |     String::from("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/issues/issue-69455.stderr b/src/test/ui/issues/issue-69455.stderr
index 3e40777c8d0..9d11cf19ea7 100644
--- a/src/test/ui/issues/issue-69455.stderr
+++ b/src/test/ui/issues/issue-69455.stderr
@@ -14,10 +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`
-   |                    |     |
-   |                    |     required by a bound introduced by this call
-   |                    type must be known at this point
+   |                          ----           ^^^ cannot infer type of the type parameter `S` declared on the associated function `sum`
+   |                          |
+   |                          required by a bound introduced by this call
    |
 note: multiple `impl`s satisfying `u64: Test<_>` found
   --> $DIR/issue-69455.rs:11:1
diff --git a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr
index 754735988e4..e0f8a5447b0 100644
--- a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr
+++ b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr
@@ -13,9 +13,7 @@ error[E0283]: type annotations needed
   --> $DIR/method-ambig-one-trait-unknown-int-type.rs:26:7
    |
 LL |     x.foo();
-   |     - ^^^
-   |     |
-   |     type must be known at this point
+   |       ^^^
    |
 note: multiple `impl`s satisfying `Vec<_>: Foo` found
   --> $DIR/method-ambig-one-trait-unknown-int-type.rs:9:1
diff --git a/src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr b/src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr
index e8d90fb336e..57b2587ae5c 100644
--- a/src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr
+++ b/src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr
@@ -13,9 +13,7 @@ error[E0283]: type annotations needed
   --> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:17:11
    |
 LL |     thing.method(42);
-   |     ----- ^^^^^^
-   |     |
-   |     type must be known at this point
+   |           ^^^^^^
    |
 note: multiple `impl`s satisfying `Thing<bool>: Method<_>` found
   --> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:7:1
diff --git a/src/test/ui/traits/issue-77982.stderr b/src/test/ui/traits/issue-77982.stderr
index 93a36a22874..e210f11b3e0 100644
--- a/src/test/ui/traits/issue-77982.stderr
+++ b/src/test/ui/traits/issue-77982.stderr
@@ -24,9 +24,8 @@ error[E0283]: type annotations needed
   --> $DIR/issue-77982.rs:8:10
    |
 LL |     opts.get(opt.as_ref());
-   |          ^^^ --- ------ required by a bound introduced by this call
-   |          |   |
-   |          |   type must be known at this point
+   |          ^^^     ------ 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`:
@@ -39,24 +38,13 @@ help: consider specifying the generic argument
 LL |     opts.get::<Q>(opt.as_ref());
    |             +++++
 
-error[E0282]: type annotations needed
-  --> $DIR/issue-77982.rs:13:59
-   |
-LL |     let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect();
-   |                                                           ^^^^
-   |
-help: try using a fully qualified path to specify the expected types
-   |
-LL |     let ips: Vec<_> = (0..100_000).map(|_| u32::from(<u32 as Into<T>>::into(0u32))).collect();
-   |                                                      +++++++++++++++++++++++    ~
-
 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
+   |                                            required by a bound introduced by this call
    |
    = note: multiple `impl`s satisfying `u32: From<_>` found in the following crates: `core`, `std`:
            - impl From<Ipv4Addr> for u32;
@@ -73,9 +61,7 @@ error[E0283]: type annotations needed for `Box<T>`
   --> $DIR/issue-77982.rs:36:9
    |
 LL |     let _ = ().foo();
-   |         ^   -- --- required by a bound introduced by this call
-   |             |
-   |             type must be known at this point
+   |         ^      --- type must be known at this point
    |
 note: multiple `impl`s satisfying `(): Foo<'_, _>` found
   --> $DIR/issue-77982.rs:29:1
@@ -93,9 +79,7 @@ error[E0283]: type annotations needed for `Box<T>`
   --> $DIR/issue-77982.rs:40:9
    |
 LL |     let _ = (&()).bar();
-   |         ^   ----- --- required by a bound introduced by this call
-   |             |
-   |             type must be known at this point
+   |         ^         --- type must be known at this point
    |
 note: multiple `impl`s satisfying `&(): Bar<'_, _>` found
   --> $DIR/issue-77982.rs:32:1
@@ -109,7 +93,6 @@ help: consider giving this pattern a type, where the type for type parameter `T`
 LL |     let _: Box<T> = (&()).bar();
    |          ++++++++
 
-error: aborting due to 6 previous errors
+error: aborting due to 5 previous errors
 
-Some errors have detailed explanations: E0282, E0283.
-For more information about an error, try `rustc --explain E0282`.
+For more information about this error, try `rustc --explain E0283`.
diff --git a/src/test/ui/traits/multidispatch-convert-ambig-dest.stderr b/src/test/ui/traits/multidispatch-convert-ambig-dest.stderr
index 83fb04646c5..6e6172eea47 100644
--- a/src/test/ui/traits/multidispatch-convert-ambig-dest.stderr
+++ b/src/test/ui/traits/multidispatch-convert-ambig-dest.stderr
@@ -13,7 +13,7 @@ error[E0283]: type annotations needed
   --> $DIR/multidispatch-convert-ambig-dest.rs:26:5
    |
 LL |     test(22, std::default::Default::default());
-   |     ^^^^ -- type must be known at this point
+   |     ^^^^     -------------------------------- type must be known at this point
    |     |
    |     cannot infer type of the type parameter `U` declared on the function `test`
    |
diff --git a/src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr b/src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr
index 294af653475..53178328c56 100644
--- a/src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr
+++ b/src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr
@@ -13,9 +13,7 @@ error[E0283]: type annotations needed
   --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:21:7
    |
 LL |     a.method();
-   |     - ^^^^^^
-   |     |
-   |     type must be known at this point
+   |       ^^^^^^
    |
 note: multiple `impl`s satisfying `B: I<_>` found
   --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:5:1
diff --git a/src/test/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr b/src/test/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr
index 07f7bfb7cb4..68b31a1ca34 100644
--- a/src/test/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr
+++ b/src/test/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr
@@ -13,9 +13,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:45:11
    |
 LL |     thing.method();
-   |     ----- ^^^^^^
-   |     |
-   |     type must be known at this point
+   |           ^^^^^^
    |
 note: multiple `impl`s satisfying `Thing: Method<_>` found
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1
@@ -34,9 +32,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:48:11
    |
 LL |     thing.mut_method();
-   |     ----- ^^^^^^^^^^
-   |     |
-   |     type must be known at this point
+   |           ^^^^^^^^^^
    |
 note: multiple `impl`s satisfying `Thing: Method<_>` found
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1
@@ -55,9 +51,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:49:11
    |
 LL |     thing.by_self();
-   |     ----- ^^^^^^^
-   |     |
-   |     type must be known at this point
+   |           ^^^^^^^
    |
 note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:22:1
@@ -76,9 +70,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:52:14
    |
 LL |     deref_to.method();
-   |     -------- ^^^^^^
-   |     |
-   |     type must be known at this point
+   |              ^^^^^^
    |
 note: multiple `impl`s satisfying `Thing: Method<_>` found
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1
@@ -97,9 +89,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:53:14
    |
 LL |     deref_to.mut_method();
-   |     -------- ^^^^^^^^^^
-   |     |
-   |     type must be known at this point
+   |              ^^^^^^^^^^
    |
 note: multiple `impl`s satisfying `Thing: Method<_>` found
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1
@@ -118,9 +108,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:54:14
    |
 LL |     deref_to.by_self();
-   |     -------- ^^^^^^^
-   |     |
-   |     type must be known at this point
+   |              ^^^^^^^
    |
 note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:22:1
@@ -139,9 +127,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:57:20
    |
 LL |     deref_deref_to.method();
-   |     -------------- ^^^^^^
-   |     |
-   |     type must be known at this point
+   |                    ^^^^^^
    |
 note: multiple `impl`s satisfying `Thing: Method<_>` found
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1
@@ -160,9 +146,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:58:20
    |
 LL |     deref_deref_to.mut_method();
-   |     -------------- ^^^^^^^^^^
-   |     |
-   |     type must be known at this point
+   |                    ^^^^^^^^^^
    |
 note: multiple `impl`s satisfying `Thing: Method<_>` found
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1
@@ -181,9 +165,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:59:20
    |
 LL |     deref_deref_to.by_self();
-   |     -------------- ^^^^^^^
-   |     |
-   |     type must be known at this point
+   |                    ^^^^^^^
    |
 note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found
   --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:22:1
diff --git a/src/test/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr b/src/test/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr
index bcc25e103b1..27518a54e75 100644
--- a/src/test/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr
+++ b/src/test/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr
@@ -13,9 +13,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:45:15
    |
 LL |     ref_thing.method();
-   |     --------- ^^^^^^
-   |     |
-   |     type must be known at this point
+   |               ^^^^^^
    |
 note: multiple `impl`s satisfying `Thing: Method<_>` found
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1
@@ -34,9 +32,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:48:15
    |
 LL |     ref_thing.by_self();
-   |     --------- ^^^^^^^
-   |     |
-   |     type must be known at this point
+   |               ^^^^^^^
    |
 note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:23:1
@@ -55,9 +51,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:51:15
    |
 LL |     mut_thing.method();
-   |     --------- ^^^^^^
-   |     |
-   |     type must be known at this point
+   |               ^^^^^^
    |
 note: multiple `impl`s satisfying `Thing: Method<_>` found
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1
@@ -76,9 +70,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:52:15
    |
 LL |     mut_thing.mut_method();
-   |     --------- ^^^^^^^^^^
-   |     |
-   |     type must be known at this point
+   |               ^^^^^^^^^^
    |
 note: multiple `impl`s satisfying `Thing: Method<_>` found
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1
@@ -97,9 +89,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:53:15
    |
 LL |     mut_thing.by_self();
-   |     --------- ^^^^^^^
-   |     |
-   |     type must be known at this point
+   |               ^^^^^^^
    |
 note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:23:1
@@ -118,9 +108,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:56:14
    |
 LL |     deref_to.method();
-   |     -------- ^^^^^^
-   |     |
-   |     type must be known at this point
+   |              ^^^^^^
    |
 note: multiple `impl`s satisfying `Thing: Method<_>` found
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1
@@ -139,9 +127,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:57:14
    |
 LL |     deref_to.mut_method();
-   |     -------- ^^^^^^^^^^
-   |     |
-   |     type must be known at this point
+   |              ^^^^^^^^^^
    |
 note: multiple `impl`s satisfying `Thing: Method<_>` found
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1
@@ -160,9 +146,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:58:14
    |
 LL |     deref_to.by_self();
-   |     -------- ^^^^^^^
-   |     |
-   |     type must be known at this point
+   |              ^^^^^^^
    |
 note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:23:1
@@ -181,9 +165,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:61:20
    |
 LL |     deref_deref_to.method();
-   |     -------------- ^^^^^^
-   |     |
-   |     type must be known at this point
+   |                    ^^^^^^
    |
 note: multiple `impl`s satisfying `Thing: Method<_>` found
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1
@@ -202,9 +184,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:62:20
    |
 LL |     deref_deref_to.mut_method();
-   |     -------------- ^^^^^^^^^^
-   |     |
-   |     type must be known at this point
+   |                    ^^^^^^^^^^
    |
 note: multiple `impl`s satisfying `Thing: Method<_>` found
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1
@@ -223,9 +203,7 @@ error[E0283]: type annotations needed
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:63:20
    |
 LL |     deref_deref_to.by_self();
-   |     -------------- ^^^^^^^
-   |     |
-   |     type must be known at this point
+   |                    ^^^^^^^
    |
 note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found
   --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:23:1