about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-08-20 12:52:56 +0100
committervarkor <github@varkor.com>2018-08-20 16:16:39 +0100
commitaa3b5c58e44beca0e96b46deb24f1bcb8d8c98a1 (patch)
tree67e6274e5ad004cdc1d1168f2d6fb36c07bd96a5 /src
parentae81fc61d0ec0978a4b67a1c2627cf99f9c1d653 (diff)
downloadrust-aa3b5c58e44beca0e96b46deb24f1bcb8d8c98a1.tar.gz
rust-aa3b5c58e44beca0e96b46deb24f1bcb8d8c98a1.zip
Fix diagnostic regression
Diffstat (limited to 'src')
-rw-r--r--src/librustc_passes/ast_validation.rs4
-rw-r--r--src/librustc_typeck/astconv.rs73
-rw-r--r--src/librustc_typeck/check/method/confirm.rs15
-rw-r--r--src/librustc_typeck/check/mod.rs38
-rw-r--r--src/test/ui/bad/bad-mid-path-type-params.stderr16
-rw-r--r--src/test/ui/constructor-lifetime-args.stderr8
-rw-r--r--src/test/ui/error-codes/E0087.stderr8
-rw-r--r--src/test/ui/error-codes/E0088.stderr8
-rw-r--r--src/test/ui/error-codes/E0107.stderr4
-rw-r--r--src/test/ui/issue-53251.stderr4
-rw-r--r--src/test/ui/issues/issue-18423.stderr4
-rw-r--r--src/test/ui/issues/issue-3214.stderr4
-rw-r--r--src/test/ui/methods/method-call-lifetime-args-fail.stderr8
-rw-r--r--src/test/ui/seq-args.stderr8
-rw-r--r--src/test/ui/structs/structure-constructor-type-mismatch.stderr8
-rw-r--r--src/test/ui/traits/trait-object-vs-lifetime.stderr4
-rw-r--r--src/test/ui/traits/trait-test-2.stderr8
-rw-r--r--src/test/ui/typeck/typeck-builtin-bound-type-parameters.stderr24
-rw-r--r--src/test/ui/typeck/typeck_type_placeholder_lifetime_1.stderr4
-rw-r--r--src/test/ui/typeck/typeck_type_placeholder_lifetime_2.stderr4
-rw-r--r--src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr4
-rw-r--r--src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr4
22 files changed, 129 insertions, 133 deletions
diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs
index 110797a59cb..87504299e4b 100644
--- a/src/librustc_passes/ast_validation.rs
+++ b/src/librustc_passes/ast_validation.rs
@@ -539,7 +539,9 @@ impl<'a> Visitor<'a> for NestedImplTraitVisitor<'a> {
     fn visit_generic_args(&mut self, _: Span, generic_args: &'a GenericArgs) {
         match *generic_args {
             GenericArgs::AngleBracketed(ref data) => {
-                data.args.iter().for_each(|arg| self.visit_generic_arg(arg));
+                for arg in &data.args {
+                    self.visit_generic_arg(arg)
+                }
                 for type_binding in &data.bindings {
                     // Type bindings such as `Item=impl Debug` in `Iterator<Item=Debug>`
                     // are allowed to contain nested `impl Trait`.
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index c7926cbaa69..ccdb751bc4e 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -94,11 +94,12 @@ struct ConvertedBinding<'tcx> {
 
 #[derive(PartialEq)]
 enum GenericArgPosition {
-    Datatype,
-    Function,
-    Method,
+    Type,
+    Value, // e.g. functions
+    MethodCall,
 }
 
+// FIXME(#53525): these error codes should all be unified.
 struct GenericArgMismatchErrorCode {
     lifetimes: (&'static str, &'static str),
     types: (&'static str, &'static str),
@@ -255,9 +256,9 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
                 &empty_args
             },
             if is_method_call {
-                GenericArgPosition::Method
+                GenericArgPosition::MethodCall
             } else {
-                GenericArgPosition::Function
+                GenericArgPosition::Value
             },
             def.parent.is_none() && def.has_self, // `has_self`
             seg.infer_types || suppress_mismatch, // `infer_types`
@@ -285,7 +286,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
         // arguments in order to validate them with respect to the generic parameters.
         let param_counts = def.own_counts();
         let arg_counts = args.own_counts();
-        let infer_lifetimes = position != GenericArgPosition::Datatype && arg_counts.lifetimes == 0;
+        let infer_lifetimes = position != GenericArgPosition::Type && arg_counts.lifetimes == 0;
 
         let mut defaults: ty::GenericParamCount = Default::default();
         for param in &def.params {
@@ -297,7 +298,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
             };
         }
 
-        if position != GenericArgPosition::Datatype && !args.bindings.is_empty() {
+        if position != GenericArgPosition::Type && !args.bindings.is_empty() {
             AstConv::prohibit_assoc_ty_binding(tcx, args.bindings[0].span);
         }
 
@@ -308,7 +309,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
                            if late bound lifetime parameters are present";
                 let note = "the late bound lifetime parameter is introduced here";
                 let span = args.args[0].span();
-                if position == GenericArgPosition::Function
+                if position == GenericArgPosition::Value
                     && arg_counts.lifetimes != param_counts.lifetimes {
                     let mut err = tcx.sess.struct_span_err(span, msg);
                     err.span_note(span_late, note);
@@ -328,7 +329,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
                                 kind,
                                 required,
                                 permitted,
-                                provided| {
+                                provided,
+                                offset| {
             // We enforce the following: `required` <= `provided` <= `permitted`.
             // For kinds without defaults (i.e. lifetimes), `required == permitted`.
             // For other kinds (i.e. types), `permitted` may be greater than `required`.
@@ -348,8 +350,15 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
                 (required, "")
             };
 
+            let mut span = span;
             let label = if required == permitted && provided > permitted {
                 let diff = provided - permitted;
+                if diff == 1 {
+                    // In the case when the user has provided too many arguments,
+                    // we want to point to the first unexpected argument.
+                    let first_superfluous_arg: &GenericArg = &args.args[offset + permitted];
+                    span = first_superfluous_arg.span();
+                }
                 format!(
                     "{}unexpected {} argument{}",
                     if diff != 1 { format!("{} ", diff) } else { String::new() },
@@ -394,6 +403,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
                 param_counts.lifetimes,
                 param_counts.lifetimes,
                 arg_counts.lifetimes,
+                0,
             );
         }
         if !infer_types
@@ -404,6 +414,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
                 param_counts.types - defaults.types - has_self as usize,
                 param_counts.types - has_self as usize,
                 arg_counts.types,
+                arg_counts.lifetimes,
             )
         } else {
             false
@@ -491,32 +502,27 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
                 // provided, matching them with the generic parameters we expect.
                 // Mismatches can occur as a result of elided lifetimes, or for malformed
                 // input. We try to handle both sensibly.
-                let mut progress_arg = true;
                 match (args.peek(), params.peek()) {
                     (Some(&arg), Some(&param)) => {
                         match (arg, &param.kind) {
-                            (GenericArg::Lifetime(_), GenericParamDefKind::Lifetime) => {
+                            (GenericArg::Lifetime(_), GenericParamDefKind::Lifetime)
+                            | (GenericArg::Type(_), GenericParamDefKind::Type { .. }) => {
                                 push_kind(&mut substs, provided_kind(param, arg));
+                                args.next();
                                 params.next();
                             }
                             (GenericArg::Lifetime(_), GenericParamDefKind::Type { .. }) => {
                                 // We expected a type argument, but got a lifetime
                                 // argument. This is an error, but we need to handle it
                                 // gracefully so we can report sensible errors. In this
-                                // case, we're simply going to infer the remaining
-                                // arguments.
-                                args.by_ref().for_each(drop); // Exhaust the iterator.
-                            }
-                            (GenericArg::Type(_), GenericParamDefKind::Type { .. }) => {
-                                push_kind(&mut substs, provided_kind(param, arg));
-                                params.next();
+                                // case, we're simply going to infer this argument.
+                                args.next();
                             }
                             (GenericArg::Type(_), GenericParamDefKind::Lifetime) => {
                                 // We expected a lifetime argument, but got a type
                                 // argument. That means we're inferring the lifetimes.
                                 push_kind(&mut substs, inferred_kind(None, param, infer_types));
                                 params.next();
-                                progress_arg = false;
                             }
                         }
                     }
@@ -524,26 +530,22 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
                         // We should never be able to reach this point with well-formed input.
                         // Getting to this point means the user supplied more arguments than
                         // there are parameters.
+                        args.next();
                     }
                     (None, Some(&param)) => {
                         // If there are fewer arguments than parameters, it means
                         // we're inferring the remaining arguments.
                         match param.kind {
-                            GenericParamDefKind::Lifetime => {
-                                push_kind(&mut substs, inferred_kind(None, param, infer_types));
-                            }
-                            GenericParamDefKind::Type { .. } => {
+                            GenericParamDefKind::Lifetime | GenericParamDefKind::Type { .. } => {
                                 let kind = inferred_kind(Some(&substs), param, infer_types);
                                 push_kind(&mut substs, kind);
                             }
                         }
+                        args.next();
                         params.next();
                     }
                     (None, None) => break,
                 }
-                if progress_arg {
-                    args.next();
-                }
             }
         }
 
@@ -582,12 +584,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
             span,
             &generic_params,
             &generic_args,
-            GenericArgPosition::Datatype,
+            GenericArgPosition::Type,
             has_self,
             infer_types,
             GenericArgMismatchErrorCode {
                 lifetimes: ("E0107", "E0107"),
-                types: ("E0243", "E0244"), // FIXME: E0243 and E0244 should be unified.
+                types: ("E0243", "E0244"),
             },
         );
 
@@ -616,17 +618,14 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
             |_| (Some(generic_args), infer_types),
             // Provide substitutions for parameters for which (valid) arguments have been provided.
             |param, arg| {
-                match param.kind {
-                    GenericParamDefKind::Lifetime => match arg {
-                        GenericArg::Lifetime(lt) => {
-                            self.ast_region_to_region(&lt, Some(param)).into()
-                        }
-                        _ => unreachable!(),
+                match (&param.kind, arg) {
+                    (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => {
+                        self.ast_region_to_region(&lt, Some(param)).into()
                     }
-                    GenericParamDefKind::Type { .. } => match arg {
-                        GenericArg::Type(ty) => self.ast_ty_to_ty(&ty).into(),
-                        _ => unreachable!(),
+                    (GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => {
+                        self.ast_ty_to_ty(&ty).into()
                     }
+                    _ => unreachable!(),
                 }
             },
             // Provide substitutions for parameters for which arguments are inferred.
diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs
index e848508b8c0..fbb49c95edf 100644
--- a/src/librustc_typeck/check/method/confirm.rs
+++ b/src/librustc_typeck/check/method/confirm.rs
@@ -344,17 +344,14 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
             },
             // Provide substitutions for parameters for which (valid) arguments have been provided.
             |param, arg| {
-                match param.kind {
-                    GenericParamDefKind::Lifetime => match arg {
-                        GenericArg::Lifetime(lt) => {
-                            AstConv::ast_region_to_region(self.fcx, lt, Some(param)).into()
-                        }
-                        _ => unreachable!(),
+                match (&param.kind, arg) {
+                    (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => {
+                        AstConv::ast_region_to_region(self.fcx, lt, Some(param)).into()
                     }
-                    GenericParamDefKind::Type { .. } => match arg {
-                        GenericArg::Type(ty) => self.to_ty(ty).into(),
-                        _ => unreachable!(),
+                    (GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => {
+                        self.to_ty(ty).into()
                     }
+                    _ => unreachable!(),
                 }
             },
             // Provide substitutions for parameters for which arguments are inferred.
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 8703b99b959..6f0c42f48c0 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -109,11 +109,11 @@ use session::{CompileIncomplete, config, Session};
 use TypeAndSubsts;
 use lint;
 use util::common::{ErrorReported, indenter};
-use util::nodemap::{DefIdMap, DefIdSet, FxHashMap, NodeMap};
+use util::nodemap::{DefIdMap, DefIdSet, FxHashMap, FxHashSet, NodeMap};
 
 use std::cell::{Cell, RefCell, Ref, RefMut};
 use rustc_data_structures::sync::Lrc;
-use std::collections::{hash_map::Entry, HashSet};
+use std::collections::hash_map::Entry;
 use std::cmp;
 use std::fmt::Display;
 use std::iter;
@@ -4908,7 +4908,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
         // provided (if any) into their appropriate spaces. We'll also report
         // errors if type parameters are provided in an inappropriate place.
 
-        let mut generic_segs = HashSet::new();
+        let mut generic_segs = FxHashSet::default();
         for PathSeg(_, index) in &path_segs {
             generic_segs.insert(index);
         }
@@ -4937,24 +4937,25 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
         // to add defaults. If the user provided *too many* types, that's
         // a problem.
 
-        let mut suppress_errors = FxHashMap();
+        let mut infer_args_for_err = FxHashSet::default();
         for &PathSeg(def_id, index) in &path_segs {
             let seg = &segments[index];
             let generics = self.tcx.generics_of(def_id);
-            // `impl Trait` is treated as a normal generic parameter internally,
-            // but we don't allow users to specify the parameter's value
-            // explicitly, so we have to do some error-checking here.
-            let suppress = AstConv::check_generic_arg_count_for_call(
+            // Argument-position `impl Trait` is treated as a normal generic
+            // parameter internally, but we don't allow users to specify the
+            // parameter's value explicitly, so we have to do some error-
+            // checking here.
+            let suppress_errors = AstConv::check_generic_arg_count_for_call(
                 self.tcx,
                 span,
                 &generics,
                 &seg,
                 false, // `is_method_call`
             );
-            if suppress {
+            if suppress_errors {
+                infer_args_for_err.insert(index);
                 self.set_tainted_by_errors(); // See issue #53251.
             }
-            suppress_errors.insert(index, suppress);
         }
 
         let has_self = path_segs.last().map(|PathSeg(def_id, _)| {
@@ -4976,7 +4977,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                 }) {
                     // If we've encountered an `impl Trait`-related error, we're just
                     // going to infer the arguments for better error messages.
-                    if !suppress_errors[&index] {
+                    if !infer_args_for_err.contains(&index) {
                         // Check whether the user has provided generic arguments.
                         if let Some(ref data) = segments[index].args {
                             return (Some(data), segments[index].infer_types);
@@ -4989,17 +4990,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
             },
             // Provide substitutions for parameters for which (valid) arguments have been provided.
             |param, arg| {
-                match param.kind {
-                    GenericParamDefKind::Lifetime => match arg {
-                        GenericArg::Lifetime(lt) => {
-                            AstConv::ast_region_to_region(self, lt, Some(param)).into()
-                        }
-                        _ => unreachable!(),
+                match (&param.kind, arg) {
+                    (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => {
+                        AstConv::ast_region_to_region(self, lt, Some(param)).into()
                     }
-                    GenericParamDefKind::Type { .. } => match arg {
-                        GenericArg::Type(ty) => self.to_ty(ty).into(),
-                        _ => unreachable!(),
+                    (GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => {
+                        self.to_ty(ty).into()
                     }
+                    _ => unreachable!(),
                 }
             },
             // Provide substitutions for parameters for which arguments are inferred.
diff --git a/src/test/ui/bad/bad-mid-path-type-params.stderr b/src/test/ui/bad/bad-mid-path-type-params.stderr
index f0998b23c1c..7901f1f0fba 100644
--- a/src/test/ui/bad/bad-mid-path-type-params.stderr
+++ b/src/test/ui/bad/bad-mid-path-type-params.stderr
@@ -1,26 +1,26 @@
 error[E0087]: wrong number of type arguments: expected 1, found 2
-  --> $DIR/bad-mid-path-type-params.rs:40:13
+  --> $DIR/bad-mid-path-type-params.rs:40:28
    |
 LL |     let _ = S::new::<isize,f64>(1, 1.0);
-   |             ^^^^^^^^^^^^^^^^^^^ unexpected type argument
+   |                            ^^^ unexpected type argument
 
 error[E0107]: wrong number of lifetime arguments: expected 0, found 1
-  --> $DIR/bad-mid-path-type-params.rs:43:13
+  --> $DIR/bad-mid-path-type-params.rs:43:17
    |
 LL |     let _ = S::<'a,isize>::new::<f64>(1, 1.0);
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^ unexpected lifetime argument
+   |                 ^^ unexpected lifetime argument
 
 error[E0087]: wrong number of type arguments: expected 1, found 2
-  --> $DIR/bad-mid-path-type-params.rs:46:17
+  --> $DIR/bad-mid-path-type-params.rs:46:36
    |
 LL |     let _: S2 = Trait::new::<isize,f64>(1, 1.0);
-   |                 ^^^^^^^^^^^^^^^^^^^^^^^ unexpected type argument
+   |                                    ^^^ unexpected type argument
 
 error[E0088]: wrong number of lifetime arguments: expected 0, found 1
-  --> $DIR/bad-mid-path-type-params.rs:49:17
+  --> $DIR/bad-mid-path-type-params.rs:49:25
    |
 LL |     let _: S2 = Trait::<'a,isize>::new::<f64>(1, 1.0);
-   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unexpected lifetime argument
+   |                         ^^ unexpected lifetime argument
 
 error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/constructor-lifetime-args.stderr b/src/test/ui/constructor-lifetime-args.stderr
index 930d90c70bd..cf3ad9ae8ec 100644
--- a/src/test/ui/constructor-lifetime-args.stderr
+++ b/src/test/ui/constructor-lifetime-args.stderr
@@ -5,10 +5,10 @@ LL |     S::<'static>(&0, &0);
    |     ^^^^^^^^^^^^ expected 2 lifetime arguments
 
 error[E0088]: wrong number of lifetime arguments: expected 2, found 3
-  --> $DIR/constructor-lifetime-args.rs:29:5
+  --> $DIR/constructor-lifetime-args.rs:29:27
    |
 LL |     S::<'static, 'static, 'static>(&0, &0);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unexpected lifetime argument
+   |                           ^^^^^^^ unexpected lifetime argument
 
 error[E0090]: wrong number of lifetime arguments: expected 2, found 1
   --> $DIR/constructor-lifetime-args.rs:32:5
@@ -17,10 +17,10 @@ LL |     E::V::<'static>(&0);
    |     ^^^^^^^^^^^^^^^ expected 2 lifetime arguments
 
 error[E0088]: wrong number of lifetime arguments: expected 2, found 3
-  --> $DIR/constructor-lifetime-args.rs:34:5
+  --> $DIR/constructor-lifetime-args.rs:34:30
    |
 LL |     E::V::<'static, 'static, 'static>(&0);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unexpected lifetime argument
+   |                              ^^^^^^^ unexpected lifetime argument
 
 error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/error-codes/E0087.stderr b/src/test/ui/error-codes/E0087.stderr
index 7170a6f2cda..a07f1bbf39a 100644
--- a/src/test/ui/error-codes/E0087.stderr
+++ b/src/test/ui/error-codes/E0087.stderr
@@ -1,14 +1,14 @@
 error[E0087]: wrong number of type arguments: expected 0, found 1
-  --> $DIR/E0087.rs:15:5
+  --> $DIR/E0087.rs:15:11
    |
 LL |     foo::<f64>(); //~ ERROR wrong number of type arguments: expected 0, found 1 [E0087]
-   |     ^^^^^^^^^^ unexpected type argument
+   |           ^^^ unexpected type argument
 
 error[E0087]: wrong number of type arguments: expected 1, found 2
-  --> $DIR/E0087.rs:17:5
+  --> $DIR/E0087.rs:17:16
    |
 LL |     bar::<f64, u64>(); //~ ERROR wrong number of type arguments: expected 1, found 2 [E0087]
-   |     ^^^^^^^^^^^^^^^ unexpected type argument
+   |                ^^^ unexpected type argument
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/error-codes/E0088.stderr b/src/test/ui/error-codes/E0088.stderr
index 4666702e1eb..6b956023e05 100644
--- a/src/test/ui/error-codes/E0088.stderr
+++ b/src/test/ui/error-codes/E0088.stderr
@@ -1,14 +1,14 @@
 error[E0088]: wrong number of lifetime arguments: expected 0, found 1
-  --> $DIR/E0088.rs:15:5
+  --> $DIR/E0088.rs:15:9
    |
 LL |     f::<'static>(); //~ ERROR E0088
-   |     ^^^^^^^^^^^^ unexpected lifetime argument
+   |         ^^^^^^^ unexpected lifetime argument
 
 error[E0088]: wrong number of lifetime arguments: expected 1, found 2
-  --> $DIR/E0088.rs:16:5
+  --> $DIR/E0088.rs:16:18
    |
 LL |     g::<'static, 'static>(); //~ ERROR E0088
-   |     ^^^^^^^^^^^^^^^^^^^^^ unexpected lifetime argument
+   |                  ^^^^^^^ unexpected lifetime argument
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/error-codes/E0107.stderr b/src/test/ui/error-codes/E0107.stderr
index 07f4f322695..497fa91bd4f 100644
--- a/src/test/ui/error-codes/E0107.stderr
+++ b/src/test/ui/error-codes/E0107.stderr
@@ -5,10 +5,10 @@ LL |     buzz: Buzz<'a>,
    |           ^^^^^^^^ expected 2 lifetime arguments
 
 error[E0107]: wrong number of lifetime arguments: expected 0, found 1
-  --> $DIR/E0107.rs:24:10
+  --> $DIR/E0107.rs:24:14
    |
 LL |     bar: Bar<'a>,
-   |          ^^^^^^^ unexpected lifetime argument
+   |              ^^ unexpected lifetime argument
 
 error[E0107]: wrong number of lifetime arguments: expected 1, found 3
   --> $DIR/E0107.rs:27:11
diff --git a/src/test/ui/issue-53251.stderr b/src/test/ui/issue-53251.stderr
index b36e9645e17..f12afa4a792 100644
--- a/src/test/ui/issue-53251.stderr
+++ b/src/test/ui/issue-53251.stderr
@@ -1,8 +1,8 @@
 error[E0087]: wrong number of type arguments: expected 0, found 1
-  --> $DIR/issue-53251.rs:21:17
+  --> $DIR/issue-53251.rs:21:24
    |
 LL |                 S::f::<i64>();
-   |                 ^^^^^^^^^^^ unexpected type argument
+   |                        ^^^ unexpected type argument
 ...
 LL | impl_add!(a b);
    | --------------- in this macro invocation
diff --git a/src/test/ui/issues/issue-18423.stderr b/src/test/ui/issues/issue-18423.stderr
index 35063f3d3ad..49afd513092 100644
--- a/src/test/ui/issues/issue-18423.stderr
+++ b/src/test/ui/issues/issue-18423.stderr
@@ -1,8 +1,8 @@
 error[E0107]: wrong number of lifetime arguments: expected 0, found 1
-  --> $DIR/issue-18423.rs:14:8
+  --> $DIR/issue-18423.rs:14:12
    |
 LL |     x: Box<'a, isize> //~ ERROR wrong number of lifetime arguments
-   |        ^^^^^^^^^^^^^^ unexpected lifetime argument
+   |            ^^ unexpected lifetime argument
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-3214.stderr b/src/test/ui/issues/issue-3214.stderr
index d1b846eb2aa..2c4b9f84105 100644
--- a/src/test/ui/issues/issue-3214.stderr
+++ b/src/test/ui/issues/issue-3214.stderr
@@ -10,10 +10,10 @@ LL |         x: T, //~ ERROR can't use type parameters from outer function
    |            ^ use of type variable from outer function
 
 error[E0244]: wrong number of type arguments: expected 0, found 1
-  --> $DIR/issue-3214.rs:16:22
+  --> $DIR/issue-3214.rs:16:26
    |
 LL |     impl<T> Drop for foo<T> {
-   |                      ^^^^^^ unexpected type argument
+   |                          ^ unexpected type argument
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/methods/method-call-lifetime-args-fail.stderr b/src/test/ui/methods/method-call-lifetime-args-fail.stderr
index 849fa574e12..d86a9f48e00 100644
--- a/src/test/ui/methods/method-call-lifetime-args-fail.stderr
+++ b/src/test/ui/methods/method-call-lifetime-args-fail.stderr
@@ -5,10 +5,10 @@ LL |     S.early::<'static>();
    |       ^^^^^ expected 2 lifetime arguments
 
 error[E0088]: wrong number of lifetime arguments: expected 2, found 3
-  --> $DIR/method-call-lifetime-args-fail.rs:28:7
+  --> $DIR/method-call-lifetime-args-fail.rs:28:33
    |
 LL |     S.early::<'static, 'static, 'static>();
-   |       ^^^^^ unexpected lifetime argument
+   |                                 ^^^^^^^ unexpected lifetime argument
 
 error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
   --> $DIR/method-call-lifetime-args-fail.rs:37:15
@@ -185,10 +185,10 @@ LL |     S::early::<'static>(S);
    |     ^^^^^^^^^^^^^^^^^^^ expected 2 lifetime arguments
 
 error[E0088]: wrong number of lifetime arguments: expected 2, found 3
-  --> $DIR/method-call-lifetime-args-fail.rs:75:5
+  --> $DIR/method-call-lifetime-args-fail.rs:75:34
    |
 LL |     S::early::<'static, 'static, 'static>(S);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unexpected lifetime argument
+   |                                  ^^^^^^^ unexpected lifetime argument
 
 error: aborting due to 18 previous errors
 
diff --git a/src/test/ui/seq-args.stderr b/src/test/ui/seq-args.stderr
index 0a68c9b917f..068f08eebe7 100644
--- a/src/test/ui/seq-args.stderr
+++ b/src/test/ui/seq-args.stderr
@@ -1,14 +1,14 @@
 error[E0244]: wrong number of type arguments: expected 0, found 1
-  --> $DIR/seq-args.rs:14:9
+  --> $DIR/seq-args.rs:14:13
    |
 LL | impl<T> seq<T> for Vec<T> { //~ ERROR wrong number of type arguments
-   |         ^^^^^^ unexpected type argument
+   |             ^ unexpected type argument
 
 error[E0244]: wrong number of type arguments: expected 0, found 1
-  --> $DIR/seq-args.rs:17:6
+  --> $DIR/seq-args.rs:17:10
    |
 LL | impl seq<bool> for u32 { //~ ERROR wrong number of type arguments
-   |      ^^^^^^^^^ unexpected type argument
+   |          ^^^^ unexpected type argument
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/structs/structure-constructor-type-mismatch.stderr b/src/test/ui/structs/structure-constructor-type-mismatch.stderr
index 88e3b85bca5..dfa219e0872 100644
--- a/src/test/ui/structs/structure-constructor-type-mismatch.stderr
+++ b/src/test/ui/structs/structure-constructor-type-mismatch.stderr
@@ -71,10 +71,10 @@ LL |         x: 7,
               found type `{integer}`
 
 error[E0244]: wrong number of type arguments: expected 0, found 1
-  --> $DIR/structure-constructor-type-mismatch.rs:58:15
+  --> $DIR/structure-constructor-type-mismatch.rs:58:24
    |
 LL |     let pt3 = PointF::<i32> { //~ ERROR wrong number of type arguments
-   |               ^^^^^^^^^^^^^ unexpected type argument
+   |                        ^^^ unexpected type argument
 
 error[E0308]: mismatched types
   --> $DIR/structure-constructor-type-mismatch.rs:59:12
@@ -101,10 +101,10 @@ LL |         y: 10, //~ ERROR mismatched types
               found type `{integer}`
 
 error[E0244]: wrong number of type arguments: expected 0, found 1
-  --> $DIR/structure-constructor-type-mismatch.rs:64:9
+  --> $DIR/structure-constructor-type-mismatch.rs:64:18
    |
 LL |         PointF::<u32> { .. } => {} //~ ERROR wrong number of type arguments
-   |         ^^^^^^^^^^^^^ unexpected type argument
+   |                  ^^^ unexpected type argument
 
 error[E0308]: mismatched types
   --> $DIR/structure-constructor-type-mismatch.rs:64:9
diff --git a/src/test/ui/traits/trait-object-vs-lifetime.stderr b/src/test/ui/traits/trait-object-vs-lifetime.stderr
index ac9158dc287..c0b65a7aa5c 100644
--- a/src/test/ui/traits/trait-object-vs-lifetime.stderr
+++ b/src/test/ui/traits/trait-object-vs-lifetime.stderr
@@ -11,10 +11,10 @@ LL |     let _: S<'static, 'static +>;
    |                       ^^^^^^^^^
 
 error[E0107]: wrong number of lifetime arguments: expected 1, found 2
-  --> $DIR/trait-object-vs-lifetime.rs:23:12
+  --> $DIR/trait-object-vs-lifetime.rs:23:23
    |
 LL |     let _: S<'static, 'static>;
-   |            ^^^^^^^^^^^^^^^^^^^ unexpected lifetime argument
+   |                       ^^^^^^^ unexpected lifetime argument
 
 error[E0243]: wrong number of type arguments: expected 1, found 0
   --> $DIR/trait-object-vs-lifetime.rs:23:12
diff --git a/src/test/ui/traits/trait-test-2.stderr b/src/test/ui/traits/trait-test-2.stderr
index 820c9a4d835..fb9cd701922 100644
--- a/src/test/ui/traits/trait-test-2.stderr
+++ b/src/test/ui/traits/trait-test-2.stderr
@@ -1,14 +1,14 @@
 error[E0087]: wrong number of type arguments: expected 0, found 1
-  --> $DIR/trait-test-2.rs:18:8
+  --> $DIR/trait-test-2.rs:18:14
    |
 LL |     10.dup::<i32>(); //~ ERROR wrong number of type arguments: expected 0, found 1
-   |        ^^^ unexpected type argument
+   |              ^^^ unexpected type argument
 
 error[E0087]: wrong number of type arguments: expected 1, found 2
-  --> $DIR/trait-test-2.rs:19:8
+  --> $DIR/trait-test-2.rs:19:20
    |
 LL |     10.blah::<i32, i32>(); //~ ERROR wrong number of type arguments: expected 1, found 2
-   |        ^^^^ unexpected type argument
+   |                    ^^^ unexpected type argument
 
 error[E0277]: the trait bound `dyn bar: bar` is not satisfied
   --> $DIR/trait-test-2.rs:20:26
diff --git a/src/test/ui/typeck/typeck-builtin-bound-type-parameters.stderr b/src/test/ui/typeck/typeck-builtin-bound-type-parameters.stderr
index d3481882629..b6444181dd8 100644
--- a/src/test/ui/typeck/typeck-builtin-bound-type-parameters.stderr
+++ b/src/test/ui/typeck/typeck-builtin-bound-type-parameters.stderr
@@ -1,38 +1,38 @@
 error[E0244]: wrong number of type arguments: expected 0, found 1
-  --> $DIR/typeck-builtin-bound-type-parameters.rs:11:11
+  --> $DIR/typeck-builtin-bound-type-parameters.rs:11:16
    |
 LL | fn foo1<T:Copy<U>, U>(x: T) {}
-   |           ^^^^^^^ unexpected type argument
+   |                ^ unexpected type argument
 
 error[E0244]: wrong number of type arguments: expected 0, found 1
-  --> $DIR/typeck-builtin-bound-type-parameters.rs:14:14
+  --> $DIR/typeck-builtin-bound-type-parameters.rs:14:19
    |
 LL | trait Trait: Copy<Send> {}
-   |              ^^^^^^^^^^ unexpected type argument
+   |                   ^^^^ unexpected type argument
 
 error[E0244]: wrong number of type arguments: expected 0, found 1
-  --> $DIR/typeck-builtin-bound-type-parameters.rs:17:21
+  --> $DIR/typeck-builtin-bound-type-parameters.rs:17:26
    |
 LL | struct MyStruct1<T: Copy<T>>;
-   |                     ^^^^^^^ unexpected type argument
+   |                          ^ unexpected type argument
 
 error[E0107]: wrong number of lifetime arguments: expected 0, found 1
-  --> $DIR/typeck-builtin-bound-type-parameters.rs:20:25
+  --> $DIR/typeck-builtin-bound-type-parameters.rs:20:30
    |
 LL | struct MyStruct2<'a, T: Copy<'a>>;
-   |                         ^^^^^^^^ unexpected lifetime argument
+   |                              ^^ unexpected lifetime argument
 
 error[E0107]: wrong number of lifetime arguments: expected 0, found 1
-  --> $DIR/typeck-builtin-bound-type-parameters.rs:24:15
+  --> $DIR/typeck-builtin-bound-type-parameters.rs:24:20
    |
 LL | fn foo2<'a, T:Copy<'a, U>, U>(x: T) {}
-   |               ^^^^^^^^^^^ unexpected lifetime argument
+   |                    ^^ unexpected lifetime argument
 
 error[E0244]: wrong number of type arguments: expected 0, found 1
-  --> $DIR/typeck-builtin-bound-type-parameters.rs:24:15
+  --> $DIR/typeck-builtin-bound-type-parameters.rs:24:24
    |
 LL | fn foo2<'a, T:Copy<'a, U>, U>(x: T) {}
-   |               ^^^^^^^^^^^ unexpected type argument
+   |                        ^ unexpected type argument
 
 error: aborting due to 6 previous errors
 
diff --git a/src/test/ui/typeck/typeck_type_placeholder_lifetime_1.stderr b/src/test/ui/typeck/typeck_type_placeholder_lifetime_1.stderr
index 597fbc6d8b1..a49839b7310 100644
--- a/src/test/ui/typeck/typeck_type_placeholder_lifetime_1.stderr
+++ b/src/test/ui/typeck/typeck_type_placeholder_lifetime_1.stderr
@@ -1,8 +1,8 @@
 error[E0244]: wrong number of type arguments: expected 1, found 2
-  --> $DIR/typeck_type_placeholder_lifetime_1.rs:19:12
+  --> $DIR/typeck_type_placeholder_lifetime_1.rs:19:19
    |
 LL |     let c: Foo<_, _> = Foo { r: &5 };
-   |            ^^^^^^^^^ unexpected type argument
+   |                   ^ unexpected type argument
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/typeck/typeck_type_placeholder_lifetime_2.stderr b/src/test/ui/typeck/typeck_type_placeholder_lifetime_2.stderr
index 1b7c60441e1..cafb6f507a0 100644
--- a/src/test/ui/typeck/typeck_type_placeholder_lifetime_2.stderr
+++ b/src/test/ui/typeck/typeck_type_placeholder_lifetime_2.stderr
@@ -1,8 +1,8 @@
 error[E0244]: wrong number of type arguments: expected 1, found 2
-  --> $DIR/typeck_type_placeholder_lifetime_2.rs:19:12
+  --> $DIR/typeck_type_placeholder_lifetime_2.rs:19:19
    |
 LL |     let c: Foo<_, usize> = Foo { r: &5 };
-   |            ^^^^^^^^^^^^^ unexpected type argument
+   |                   ^^^^^ unexpected type argument
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr
index 74faa69918e..89587c47cf6 100644
--- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr
+++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr
@@ -1,8 +1,8 @@
 error[E0244]: wrong number of type arguments: expected 0, found 1
-  --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:15:11
+  --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:15:15
    |
 LL | fn foo(_: Zero())
-   |           ^^^^^^ unexpected type argument
+   |               ^^ unexpected type argument
 
 error[E0220]: associated type `Output` not found for `Zero`
   --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:15:15
diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr
index a993928bc31..5d8c86f5a58 100644
--- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr
+++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr
@@ -1,8 +1,8 @@
 error[E0244]: wrong number of type arguments: expected 0, found 1
-  --> $DIR/unboxed-closure-sugar-wrong-trait.rs:15:8
+  --> $DIR/unboxed-closure-sugar-wrong-trait.rs:15:13
    |
 LL | fn f<F:Trait(isize) -> isize>(x: F) {}
-   |        ^^^^^^^^^^^^^^^^^^^^^ unexpected type argument
+   |             ^^^^^^^^^^^^^^^^ unexpected type argument
 
 error[E0220]: associated type `Output` not found for `Trait`
   --> $DIR/unboxed-closure-sugar-wrong-trait.rs:15:24