diff options
| author | leonardo.yvens <leoyvens@gmail.com> | 2017-12-12 14:50:09 -0200 |
|---|---|---|
| committer | leonardo.yvens <leoyvens@gmail.com> | 2018-01-27 15:42:53 -0200 |
| commit | c01bfbd02b57a1aa9d8a39cd907f799d23c2a230 (patch) | |
| tree | a9577c28f646092a5b7dc7b40e12b299441cc7bc /src | |
| parent | 6b99adeb11313197f409b4f7c4083c2ceca8a4fe (diff) | |
| download | rust-c01bfbd02b57a1aa9d8a39cd907f799d23c2a230.tar.gz rust-c01bfbd02b57a1aa9d8a39cd907f799d23c2a230.zip | |
refactor `structurally_resolve_type`
the `or_else` part was dead code.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 6147743437b..cb80498f3e2 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4954,41 +4954,23 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }); } - fn structurally_resolve_type_or_else<F>(&self, sp: Span, ty: Ty<'tcx>, f: F) - -> Ty<'tcx> - where F: Fn() -> Ty<'tcx> - { + // Resolves `typ` by a single level if `typ` is a type variable. If no + // resolution is possible, then an error is reported. + pub fn structurally_resolved_type(&self, sp: Span, ty: Ty<'tcx>) -> 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() { - type_error_struct!(self.tcx.sess, sp, ty, E0619, - "the type of this value must be known in this context") - .emit(); - } - self.demand_suptype(sp, self.tcx.types.err, ty); - ty = self.tcx.types.err; - } else { - self.demand_suptype(sp, alternative, ty); - ty = alternative; + 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.demand_suptype(sp, self.tcx.types.err, ty); + ty = self.tcx.types.err; } - ty } - // Resolves `typ` by a single level if `typ` is a type variable. If no - // resolution is possible, then an error is reported. - pub fn structurally_resolved_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx> { - self.structurally_resolve_type_or_else(sp, ty, || { - self.tcx.types.err - }) - } - fn with_breakable_ctxt<F: FnOnce() -> R, R>(&self, id: ast::NodeId, ctxt: BreakableCtxt<'gcx, 'tcx>, f: F) -> (BreakableCtxt<'gcx, 'tcx>, R) { |
