Auto merge of #83839 - ldm0:deref, r=petrochenkov

Remove unneeded type resolving

small optimization.
This commit is contained in:
bors 2021-04-04 11:15:17 +00:00
commit b1ea2618d3
2 changed files with 4 additions and 4 deletions

View File

@ -104,8 +104,8 @@ pub(super) fn to_option(self, fcx: &FnCtxt<'a, 'tcx>) -> Option<Ty<'tcx>> {
/// for the program to type-check). `only_has_type` will return /// for the program to type-check). `only_has_type` will return
/// such a constraint, if it exists. /// such a constraint, if it exists.
pub(super) fn only_has_type(self, fcx: &FnCtxt<'a, 'tcx>) -> Option<Ty<'tcx>> { pub(super) fn only_has_type(self, fcx: &FnCtxt<'a, 'tcx>) -> Option<Ty<'tcx>> {
match self.resolve(fcx) { match self {
ExpectHasType(ty) => Some(ty), ExpectHasType(ty) => Some(fcx.resolve_vars_if_possible(ty)),
NoExpectation | ExpectCastableToType(_) | ExpectRvalueLikeUnsized(_) | IsLast(_) => { NoExpectation | ExpectCastableToType(_) | ExpectRvalueLikeUnsized(_) | IsLast(_) => {
None None
} }

View File

@ -161,7 +161,7 @@ pub(super) fn check_expr_with_expectation(
expr: &'tcx hir::Expr<'tcx>, expr: &'tcx hir::Expr<'tcx>,
expected: Expectation<'tcx>, expected: Expectation<'tcx>,
) -> Ty<'tcx> { ) -> Ty<'tcx> {
debug!(">> type-checking: expr={:?} expected={:?}", expr, expected); debug!(">> type-checking: expected={:?}, expr={:?} ", expected, expr);
// True if `expr` is a `Try::from_ok(())` that is a result of desugaring a try block // True if `expr` is a `Try::from_ok(())` that is a result of desugaring a try block
// without the final expr (e.g. `try { return; }`). We don't want to generate an // without the final expr (e.g. `try { return; }`). We don't want to generate an
@ -224,7 +224,7 @@ fn check_expr_kind(
expr: &'tcx hir::Expr<'tcx>, expr: &'tcx hir::Expr<'tcx>,
expected: Expectation<'tcx>, expected: Expectation<'tcx>,
) -> Ty<'tcx> { ) -> Ty<'tcx> {
debug!("check_expr_kind(expr={:?}, expected={:?})", expr, expected); debug!("check_expr_kind(expected={:?}, expr={:?})", expected, expr);
let tcx = self.tcx; let tcx = self.tcx;
match expr.kind { match expr.kind {