Skip to content

Commit b1ea261

Browse files
committed
Auto merge of #83839 - ldm0:deref, r=petrochenkov
Remove unneeded type resolving small optimization.
2 parents f98135b + 3982ac2 commit b1ea261

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

compiler/rustc_typeck/src/check/expectation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ impl<'a, 'tcx> Expectation<'tcx> {
104104
/// for the program to type-check). `only_has_type` will return
105105
/// such a constraint, if it exists.
106106
pub(super) fn only_has_type(self, fcx: &FnCtxt<'a, 'tcx>) -> Option<Ty<'tcx>> {
107-
match self.resolve(fcx) {
108-
ExpectHasType(ty) => Some(ty),
107+
match self {
108+
ExpectHasType(ty) => Some(fcx.resolve_vars_if_possible(ty)),
109109
NoExpectation | ExpectCastableToType(_) | ExpectRvalueLikeUnsized(_) | IsLast(_) => {
110110
None
111111
}

compiler/rustc_typeck/src/check/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
161161
expr: &'tcx hir::Expr<'tcx>,
162162
expected: Expectation<'tcx>,
163163
) -> Ty<'tcx> {
164-
debug!(">> type-checking: expr={:?} expected={:?}", expr, expected);
164+
debug!(">> type-checking: expected={:?}, expr={:?} ", expected, expr);
165165

166166
// True if `expr` is a `Try::from_ok(())` that is a result of desugaring a try block
167167
// without the final expr (e.g. `try { return; }`). We don't want to generate an
@@ -224,7 +224,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
224224
expr: &'tcx hir::Expr<'tcx>,
225225
expected: Expectation<'tcx>,
226226
) -> Ty<'tcx> {
227-
debug!("check_expr_kind(expr={:?}, expected={:?})", expr, expected);
227+
debug!("check_expr_kind(expected={:?}, expr={:?})", expected, expr);
228228

229229
let tcx = self.tcx;
230230
match expr.kind {

0 commit comments

Comments
 (0)