@@ -73,7 +73,7 @@ macro_rules! span_mirbug {
7373 $context. last_span,
7474 & format!(
7575 "broken MIR in {:?} ({:?}): {}" ,
76- $context. mir_def_id ,
76+ $context. body . source . def_id ( ) ,
7777 $elem,
7878 format_args!( $( $message) * ) ,
7979 ) ,
@@ -113,7 +113,6 @@ mod relate_tys;
113113/// - `param_env` -- parameter environment to use for trait solving
114114/// - `body` -- MIR body to type-check
115115/// - `promoted` -- map of promoted constants within `body`
116- /// - `mir_def_id` -- `LocalDefId` from which the MIR is derived
117116/// - `universal_regions` -- the universal regions from `body`s function signature
118117/// - `location_table` -- MIR location map of `body`
119118/// - `borrow_set` -- information about borrows occurring in `body`
@@ -126,7 +125,6 @@ pub(crate) fn type_check<'mir, 'tcx>(
126125 param_env : ty:: ParamEnv < ' tcx > ,
127126 body : & Body < ' tcx > ,
128127 promoted : & IndexVec < Promoted , Body < ' tcx > > ,
129- mir_def_id : LocalDefId ,
130128 universal_regions : & Rc < UniversalRegions < ' tcx > > ,
131129 location_table : & LocationTable ,
132130 borrow_set : & BorrowSet < ' tcx > ,
@@ -170,7 +168,6 @@ pub(crate) fn type_check<'mir, 'tcx>(
170168
171169 let opaque_type_values = type_check_internal (
172170 infcx,
173- mir_def_id,
174171 param_env,
175172 body,
176173 promoted,
@@ -192,7 +189,6 @@ pub(crate) fn type_check<'mir, 'tcx>(
192189
193190fn type_check_internal < ' a , ' tcx , R > (
194191 infcx : & ' a InferCtxt < ' a , ' tcx > ,
195- mir_def_id : LocalDefId ,
196192 param_env : ty:: ParamEnv < ' tcx > ,
197193 body : & ' a Body < ' tcx > ,
198194 promoted : & ' a IndexVec < Promoted , Body < ' tcx > > ,
@@ -205,7 +201,6 @@ fn type_check_internal<'a, 'tcx, R>(
205201 let mut checker = TypeChecker :: new (
206202 infcx,
207203 body,
208- mir_def_id,
209204 param_env,
210205 region_bound_pairs,
211206 implicit_region_bound,
@@ -272,7 +267,6 @@ struct TypeVerifier<'a, 'b, 'tcx> {
272267 body : & ' b Body < ' tcx > ,
273268 promoted : & ' b IndexVec < Promoted , Body < ' tcx > > ,
274269 last_span : Span ,
275- mir_def_id : LocalDefId ,
276270 errors_reported : bool ,
277271}
278272
@@ -460,14 +454,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
460454 body : & ' b Body < ' tcx > ,
461455 promoted : & ' b IndexVec < Promoted , Body < ' tcx > > ,
462456 ) -> Self {
463- TypeVerifier {
464- body,
465- promoted,
466- mir_def_id : cx. mir_def_id ,
467- cx,
468- last_span : body. span ,
469- errors_reported : false ,
470- }
457+ TypeVerifier { body, promoted, cx, last_span : body. span , errors_reported : false }
471458 }
472459
473460 fn tcx ( & self ) -> TyCtxt < ' tcx > {
@@ -816,7 +803,6 @@ struct TypeChecker<'a, 'tcx> {
816803 /// User type annotations are shared between the main MIR and the MIR of
817804 /// all of the promoted items.
818805 user_type_annotations : & ' a CanonicalUserTypeAnnotations < ' tcx > ,
819- mir_def_id : LocalDefId ,
820806 region_bound_pairs : & ' a RegionBoundPairs < ' tcx > ,
821807 implicit_region_bound : ty:: Region < ' tcx > ,
822808 reported_errors : FxHashSet < ( Ty < ' tcx > , Span ) > ,
@@ -965,7 +951,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
965951 fn new (
966952 infcx : & ' a InferCtxt < ' a , ' tcx > ,
967953 body : & ' a Body < ' tcx > ,
968- mir_def_id : LocalDefId ,
969954 param_env : ty:: ParamEnv < ' tcx > ,
970955 region_bound_pairs : & ' a RegionBoundPairs < ' tcx > ,
971956 implicit_region_bound : ty:: Region < ' tcx > ,
@@ -975,7 +960,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
975960 let mut checker = Self {
976961 infcx,
977962 last_span : DUMMY_SP ,
978- mir_def_id,
979963 body,
980964 user_type_annotations : & body. user_type_annotations ,
981965 param_env,
@@ -1145,7 +1129,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
11451129 // the resulting inferend values are stored with the
11461130 // def-id of the base function.
11471131 let parent_def_id =
1148- self . tcx ( ) . closure_base_def_id ( self . mir_def_id . to_def_id ( ) ) . expect_local ( ) ;
1132+ self . tcx ( ) . closure_base_def_id ( self . body . source . def_id ( ) ) . expect_local ( ) ;
11491133 return self . eq_opaque_type_and_type ( sub, sup, parent_def_id, locations, category) ;
11501134 } else {
11511135 return Err ( terr) ;
@@ -1242,7 +1226,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
12421226 let concrete_opaque_types = & tcx. typeck ( anon_owner_def_id) . concrete_opaque_types ;
12431227 let mut opaque_type_values = Vec :: new ( ) ;
12441228
1245- debug ! ( "eq_opaque_type_and_type: mir_def_id={:?}" , self . mir_def_id ) ;
1229+ debug ! ( "eq_opaque_type_and_type: mir_def_id={:?}" , body . source . def_id ( ) ) ;
12461230 let opaque_type_map = self . fully_perform_op (
12471231 locations,
12481232 category,
@@ -2001,12 +1985,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20011985 let span = body. source_info ( location) . span ;
20021986 let ty = operand. ty ( body, tcx) ;
20031987 if !self . infcx . type_is_copy_modulo_regions ( self . param_env , ty, span) {
2004- let ccx = ConstCx :: new_with_param_env (
2005- tcx,
2006- self . mir_def_id ,
2007- body,
2008- self . param_env ,
2009- ) ;
1988+ let ccx = ConstCx :: new_with_param_env ( tcx, body, self . param_env ) ;
20101989 // To determine if `const_in_array_repeat_expressions` feature gate should
20111990 // be mentioned, need to check if the rvalue is promotable.
20121991 let should_suggest =
@@ -2015,11 +1994,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20151994 ) ;
20161995 debug ! ( "check_rvalue: should_suggest={:?}" , should_suggest) ;
20171996
1997+ let def_id = body. source . def_id ( ) . expect_local ( ) ;
20181998 self . infcx . report_selection_error (
20191999 & traits:: Obligation :: new (
20202000 ObligationCause :: new (
20212001 span,
2022- self . tcx ( ) . hir ( ) . local_def_id_to_hir_id ( self . mir_def_id ) ,
2002+ self . tcx ( ) . hir ( ) . local_def_id_to_hir_id ( def_id ) ,
20232003 traits:: ObligationCauseCode :: RepeatVec ( should_suggest) ,
20242004 ) ,
20252005 self . param_env ,
0 commit comments