@@ -60,11 +60,6 @@ use rustc_trait_selection::traits::ObligationCtxt;
6060use rustc_trait_selection:: traits:: { self , ObligationCauseCode } ;
6161
6262impl < ' a , ' tcx > FnCtxt < ' a , ' tcx > {
63- fn check_expr_eq_type ( & self , expr : & ' tcx hir:: Expr < ' tcx > , expected : Ty < ' tcx > ) {
64- let ty = self . check_expr_with_hint ( expr, expected) ;
65- self . demand_eqtype ( expr. span , expected, ty) ;
66- }
67-
6863 pub fn check_expr_has_type_or_error (
6964 & self ,
7065 expr : & ' tcx hir:: Expr < ' tcx > ,
@@ -331,9 +326,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
331326 }
332327 ExprKind :: Cast ( e, t) => self . check_expr_cast ( e, t, expr) ,
333328 ExprKind :: Type ( e, t) => {
334- let ty = self . to_ty_saving_user_provided_ty ( & t) ;
335- self . check_expr_eq_type ( & e, ty) ;
336- ty
329+ let ascribed_ty = self . to_ty_saving_user_provided_ty ( & t) ;
330+ let ty = self . check_expr_with_hint ( e, ascribed_ty) ;
331+ self . demand_eqtype ( e. span , ascribed_ty, ty) ;
332+ ascribed_ty
337333 }
338334 ExprKind :: If ( cond, then_expr, opt_else_expr) => {
339335 self . check_then_else ( cond, then_expr, opt_else_expr, expr. span , expected)
0 commit comments