diff options
| author | varkor <github@varkor.com> | 2018-08-07 17:01:12 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-08-19 20:02:34 +0100 |
| commit | 7c9f7c2fa3b48f8bfefa148dc425db68684cf953 (patch) | |
| tree | 30e9a24a2a00e966f19f369db94f0fb092cc4366 | |
| parent | 9d3d4b1a19f57c57caa1803bc05b5619eb0df964 (diff) | |
| download | rust-7c9f7c2fa3b48f8bfefa148dc425db68684cf953.tar.gz rust-7c9f7c2fa3b48f8bfefa148dc425db68684cf953.zip | |
Args first, then params
| -rw-r--r-- | src/librustc_typeck/astconv.rs | 46 | ||||
| -rw-r--r-- | src/librustc_typeck/check/method/confirm.rs | 2 | ||||
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 2 |
3 files changed, 15 insertions, 35 deletions
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index a95f4c6c941..30f1ed1317d 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -196,8 +196,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { /// corresponding to a set of generic parameters. pub fn create_substs_for_generic_args<'a, 'b, A, P, I>( tcx: TyCtxt<'a, 'gcx, 'tcx>, - span: Span, - err_if_invalid: bool, def_id: DefId, parent_substs: &[Kind<'tcx>], has_self: bool, @@ -279,37 +277,29 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { let mut progress_arg = true; match (next_arg, next_param) { (Some(arg), Some(param)) => { - match (¶m.kind, arg) { - (GenericParamDefKind::Lifetime, GenericArg::Lifetime(_)) => { + match (arg, ¶m.kind) { + (GenericArg::Lifetime(_), GenericParamDefKind::Lifetime) => { push_kind(&mut substs, provided_kind(param, arg)); next_param = params.next(); } - (GenericParamDefKind::Lifetime, GenericArg::Type(_)) => { - // 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)); - next_param = params.next(); - progress_arg = false; - } - (GenericParamDefKind::Type { .. }, GenericArg::Type(_)) => { - push_kind(&mut substs, provided_kind(param, arg)); - next_param = params.next(); - } - (GenericParamDefKind::Type { .. }, GenericArg::Lifetime(_)) => { + (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. - if err_if_invalid { - tcx.sess.delay_span_bug(span, - "found a GenericArg::Lifetime where a \ - GenericArg::Type was expected"); - } - // Exhaust the iterator. - while next_arg.is_some() { - next_arg = args.next(); - } + args.by_ref().for_each(drop); // Exhaust the iterator. + } + (GenericArg::Type(_), GenericParamDefKind::Type { .. }) => { + push_kind(&mut substs, provided_kind(param, arg)); + next_param = params.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)); + next_param = params.next(); + progress_arg = false; } } } @@ -317,10 +307,6 @@ 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. - if err_if_invalid { - tcx.sess.delay_span_bug(span, - "GenericArg did not have matching GenericParamDef"); - } } (None, Some(param)) => { // If there are fewer arguments than parameters, it means @@ -428,8 +414,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { let substs = Self::create_substs_for_generic_args( self.tcx(), - span, - false, def_id, &[][..], self_ty.is_some(), diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 0acbd803103..739c2013950 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -325,8 +325,6 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { AstConv::create_substs_for_generic_args( self.tcx, - self.span, - false, pick.item.def_id, parent_substs, false, diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 141d0aea462..f37ea819122 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4957,8 +4957,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let substs = AstConv::create_substs_for_generic_args( self.tcx, - span, - true, def_id, &[][..], has_self, |
