]> git.lizzy.rs Git - rust.git/commitdiff
Merge branch 'master' into inform_type_annotations
authormoe <35686186+csmoe@users.noreply.github.com>
Sat, 17 Feb 2018 14:22:26 +0000 (22:22 +0800)
committerGitHub <noreply@github.com>
Sat, 17 Feb 2018 14:22:26 +0000 (22:22 +0800)
1  2 
src/librustc_typeck/check/mod.rs

index e760636230d1864a9fa570bb54440025eb554225,d21bfb674c7fc61c57f80fa1ec20fcbe7b99dfaa..91fa3c5da6991035e776c754f3a6a0ebc6d74616
@@@ -5074,37 -5043,22 +5043,20 @@@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, '
          });
      }
  
-     fn structurally_resolve_type_or_else<F>(&self, sp: Span, ty: Ty<'tcx>, f: F)
-                                             -> Ty<'tcx>
-         where F: Fn() -> Ty<'tcx>
-     {
-         let mut ty = self.resolve_type_vars_with_obligations(ty);
-         if ty.is_ty_var() {
-             let alternative = f();
-             // If not, error.
-             if alternative.is_ty_var() || alternative.references_error() {
-                 if !self.is_tainted_by_errors() {
-                     self.need_type_info((**self).body_id, sp, ty);
-                 }
-                 self.demand_suptype(sp, self.tcx.types.err, ty);
-                 ty = self.tcx.types.err;
-             } else {
-                 self.demand_suptype(sp, alternative, ty);
-                 ty = alternative;
-             }
-         }
-         ty
-     }
-     // Resolves `typ` by a single level if `typ` is a type variable.  If no
-     // resolution is possible, then an error is reported.
+     // Resolves `typ` by a single level if `typ` is a type variable.
+     // If no resolution is possible, then an error is reported.
+     // Numeric inference variables may be left unresolved.
      pub fn structurally_resolved_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx> {
-         self.structurally_resolve_type_or_else(sp, ty, || {
+         let ty = self.resolve_type_vars_with_obligations(ty);
+         if !ty.is_ty_var() {
+             ty
+         } else {
+             if !self.is_tainted_by_errors() {
 -                type_error_struct!(self.tcx.sess, sp, ty, E0619,
 -                                    "the type of this value must be known in this context")
 -                .emit();
++                self.need_type_info((**self).body_id, sp, ty);
+             }
+             self.demand_suptype(sp, self.tcx.types.err, ty);
              self.tcx.types.err
-         })
+         }
      }
  
      fn with_breakable_ctxt<F: FnOnce() -> R, R>(&self, id: ast::NodeId,