Skip to content

Commit c01bfbd

Browse files
committed
refactor structurally_resolve_type
the `or_else` part was dead code.
1 parent 6b99ade commit c01bfbd

File tree

1 file changed

+9
-27
lines changed
  • src/librustc_typeck/check

1 file changed

+9
-27
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4954,41 +4954,23 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
49544954
});
49554955
}
49564956

4957-
fn structurally_resolve_type_or_else<F>(&self, sp: Span, ty: Ty<'tcx>, f: F)
4958-
-> Ty<'tcx>
4959-
where F: Fn() -> Ty<'tcx>
4960-
{
4957+
// Resolves `typ` by a single level if `typ` is a type variable. If no
4958+
// resolution is possible, then an error is reported.
4959+
pub fn structurally_resolved_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx> {
49614960
let mut ty = self.resolve_type_vars_with_obligations(ty);
4962-
49634961
if ty.is_ty_var() {
4964-
let alternative = f();
4965-
49664962
// If not, error.
4967-
if alternative.is_ty_var() || alternative.references_error() {
4968-
if !self.is_tainted_by_errors() {
4969-
type_error_struct!(self.tcx.sess, sp, ty, E0619,
4970-
"the type of this value must be known in this context")
4971-
.emit();
4972-
}
4973-
self.demand_suptype(sp, self.tcx.types.err, ty);
4974-
ty = self.tcx.types.err;
4975-
} else {
4976-
self.demand_suptype(sp, alternative, ty);
4977-
ty = alternative;
4963+
if !self.is_tainted_by_errors() {
4964+
type_error_struct!(self.tcx.sess, sp, ty, E0619,
4965+
"the type of this value must be known in this context")
4966+
.emit();
49784967
}
4968+
self.demand_suptype(sp, self.tcx.types.err, ty);
4969+
ty = self.tcx.types.err;
49794970
}
4980-
49814971
ty
49824972
}
49834973

4984-
// Resolves `typ` by a single level if `typ` is a type variable. If no
4985-
// resolution is possible, then an error is reported.
4986-
pub fn structurally_resolved_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx> {
4987-
self.structurally_resolve_type_or_else(sp, ty, || {
4988-
self.tcx.types.err
4989-
})
4990-
}
4991-
49924974
fn with_breakable_ctxt<F: FnOnce() -> R, R>(&self, id: ast::NodeId,
49934975
ctxt: BreakableCtxt<'gcx, 'tcx>, f: F)
49944976
-> (BreakableCtxt<'gcx, 'tcx>, R) {

0 commit comments

Comments
 (0)