From f479e262d68271c1190dba6560923aff026d32fe Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Sun, 27 Mar 2022 02:40:07 +0000 Subject: [PATCH] review comments and rebase --- .../rustc_infer/src/infer/error_reporting/mod.rs | 2 +- compiler/rustc_infer/src/infer/mod.rs | 16 ++++++++-------- compiler/rustc_typeck/src/astconv/generics.rs | 4 +--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 78b21a235cb8..238145c5c6ee 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -334,7 +334,7 @@ pub fn same_type_modulo_infer<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool { | (&ty::Infer(ty::InferTy::TyVar(_)), _) | (_, &ty::Infer(ty::InferTy::TyVar(_))) => true, (&ty::Ref(reg_a, ty_a, mut_a), &ty::Ref(reg_b, ty_b, mut_b)) => { - reg_a == reg_b && mut_a == mut_b && same_type_modulo_infer(ty_a, ty_b) + reg_a == reg_b && mut_a == mut_b && same_type_modulo_infer(*ty_a, *ty_b) } _ => a == b, } diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 5878cfdf0b7f..83ba9c96978d 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -1441,7 +1441,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { if !value.needs_infer() { return value; // Avoid duplicated subst-folding. } - let mut r = InferenceLiteralEraser { infcx: self }; + let mut r = InferenceLiteralEraser { tcx: self.tcx }; value.fold_with(&mut r) } @@ -1798,19 +1798,19 @@ impl<'tcx> TyOrConstInferVar<'tcx> { /// Replace `{integer}` with `i32` and `{float}` with `f64`. /// Used only for diagnostics. -struct InferenceLiteralEraser<'a, 'tcx> { - infcx: &'a InferCtxt<'a, 'tcx>, +struct InferenceLiteralEraser<'tcx> { + tcx: TyCtxt<'tcx>, } -impl<'a, 'tcx> TypeFolder<'tcx> for InferenceLiteralEraser<'a, 'tcx> { - fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { - self.infcx.tcx +impl<'tcx> TypeFolder<'tcx> for InferenceLiteralEraser<'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { + self.tcx } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { match ty.kind() { - ty::Infer(ty::IntVar(_) | ty::FreshIntTy(_)) => self.tcx().types.i32, - ty::Infer(ty::FloatVar(_) | ty::FreshFloatTy(_)) => self.tcx().types.f64, + ty::Infer(ty::IntVar(_) | ty::FreshIntTy(_)) => self.tcx.types.i32, + ty::Infer(ty::FloatVar(_) | ty::FreshFloatTy(_)) => self.tcx.types.f64, _ => ty.super_fold_with(self), } } diff --git a/compiler/rustc_typeck/src/astconv/generics.rs b/compiler/rustc_typeck/src/astconv/generics.rs index 451e1e05d145..a07700aa9f5b 100644 --- a/compiler/rustc_typeck/src/astconv/generics.rs +++ b/compiler/rustc_typeck/src/astconv/generics.rs @@ -85,9 +85,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let param_hir_id = tcx.hir().local_def_id_to_hir_id(param_local_id); let param_name = tcx.hir().ty_param_name(param_hir_id); let param_type = tcx.infer_ctxt().enter(|infcx| { - infcx.resolve_numeric_literals_with_default( - infcx.resolve_vars_if_possible(tcx.type_of(param.def_id)), - ) + infcx.resolve_numeric_literals_with_default(tcx.type_of(param.def_id)) }); if param_type.is_suggestable() { err.span_suggestion(