From 75585b408fa3563188c3bffa8bb13ad1b1334414 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 15 Jul 2021 09:55:13 -0300 Subject: [PATCH] Move mir_def_id inside `eq_opaque_type_and_type` --- .../src/borrow_check/type_check/input_output.rs | 2 -- compiler/rustc_mir/src/borrow_check/type_check/mod.rs | 11 +++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_mir/src/borrow_check/type_check/input_output.rs b/compiler/rustc_mir/src/borrow_check/type_check/input_output.rs index 1bb447d105781..37e0643228acc 100644 --- a/compiler/rustc_mir/src/borrow_check/type_check/input_output.rs +++ b/compiler/rustc_mir/src/borrow_check/type_check/input_output.rs @@ -122,7 +122,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { if let Err(terr) = self.eq_opaque_type_and_type( mir_output_ty, normalized_output_ty, - mir_def_id, Locations::All(output_span), ConstraintCategory::BoringNoLocation, ) { @@ -145,7 +144,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { if let Err(err) = self.eq_opaque_type_and_type( mir_output_ty, user_provided_output_ty, - mir_def_id, Locations::All(output_span), ConstraintCategory::BoringNoLocation, ) { diff --git a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs index cbcf050c9b892..aa3ff98f7ff9f 100644 --- a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs @@ -1182,7 +1182,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } /// Equates a type `anon_ty` that may contain opaque types whose - /// values are to be inferred by the MIR with def-id `anon_owner_def_id`. + /// values are to be inferred by the MIR. /// /// The type `revealed_ty` contains the same type as `anon_ty`, but with the /// hidden types for impl traits revealed. @@ -1210,12 +1210,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { /// generics of `foo`). Note that `anon_ty` is not just the opaque type, /// but the entire return type (which may contain opaque types within it). /// * `revealed_ty` would be `Box<(T, u32)>` - /// * `anon_owner_def_id` would be the def-id of `foo` fn eq_opaque_type_and_type( &mut self, revealed_ty: Ty<'tcx>, anon_ty: Ty<'tcx>, - anon_owner_def_id: LocalDefId, locations: Locations, category: ConstraintCategory, ) -> Fallible<()> { @@ -1245,12 +1243,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let tcx = infcx.tcx; let param_env = self.param_env; let body = self.body; + let mir_def_id = body.source.def_id().expect_local(); // the "concrete opaque types" maps - let concrete_opaque_types = &tcx.typeck(anon_owner_def_id).concrete_opaque_types; + let concrete_opaque_types = &tcx.typeck(mir_def_id).concrete_opaque_types; let mut opaque_type_values = VecMap::new(); - debug!("eq_opaque_type_and_type: mir_def_id={:?}", body.source.def_id()); + debug!("eq_opaque_type_and_type: mir_def_id={:?}", mir_def_id); let opaque_type_map = self.fully_perform_op( locations, category, @@ -1268,7 +1267,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { // any generic parameters.) let (output_ty, opaque_type_map) = obligations.add(infcx.instantiate_opaque_types( - anon_owner_def_id, + mir_def_id, dummy_body_id, param_env, anon_ty,