@@ -73,7 +73,7 @@ macro_rules! span_mirbug {
73
73
$context. last_span,
74
74
& format!(
75
75
"broken MIR in {:?} ({:?}): {}" ,
76
- $context. mir_def_id ,
76
+ $context. body . source . def_id ( ) ,
77
77
$elem,
78
78
format_args!( $( $message) * ) ,
79
79
) ,
@@ -113,7 +113,6 @@ mod relate_tys;
113
113
/// - `param_env` -- parameter environment to use for trait solving
114
114
/// - `body` -- MIR body to type-check
115
115
/// - `promoted` -- map of promoted constants within `body`
116
- /// - `mir_def_id` -- `LocalDefId` from which the MIR is derived
117
116
/// - `universal_regions` -- the universal regions from `body`s function signature
118
117
/// - `location_table` -- MIR location map of `body`
119
118
/// - `borrow_set` -- information about borrows occurring in `body`
@@ -126,7 +125,6 @@ pub(crate) fn type_check<'mir, 'tcx>(
126
125
param_env : ty:: ParamEnv < ' tcx > ,
127
126
body : & Body < ' tcx > ,
128
127
promoted : & IndexVec < Promoted , Body < ' tcx > > ,
129
- mir_def_id : LocalDefId ,
130
128
universal_regions : & Rc < UniversalRegions < ' tcx > > ,
131
129
location_table : & LocationTable ,
132
130
borrow_set : & BorrowSet < ' tcx > ,
@@ -170,7 +168,6 @@ pub(crate) fn type_check<'mir, 'tcx>(
170
168
171
169
let opaque_type_values = type_check_internal (
172
170
infcx,
173
- mir_def_id,
174
171
param_env,
175
172
body,
176
173
promoted,
@@ -192,7 +189,6 @@ pub(crate) fn type_check<'mir, 'tcx>(
192
189
193
190
fn type_check_internal < ' a , ' tcx , R > (
194
191
infcx : & ' a InferCtxt < ' a , ' tcx > ,
195
- mir_def_id : LocalDefId ,
196
192
param_env : ty:: ParamEnv < ' tcx > ,
197
193
body : & ' a Body < ' tcx > ,
198
194
promoted : & ' a IndexVec < Promoted , Body < ' tcx > > ,
@@ -205,7 +201,6 @@ fn type_check_internal<'a, 'tcx, R>(
205
201
let mut checker = TypeChecker :: new (
206
202
infcx,
207
203
body,
208
- mir_def_id,
209
204
param_env,
210
205
region_bound_pairs,
211
206
implicit_region_bound,
@@ -272,7 +267,6 @@ struct TypeVerifier<'a, 'b, 'tcx> {
272
267
body : & ' b Body < ' tcx > ,
273
268
promoted : & ' b IndexVec < Promoted , Body < ' tcx > > ,
274
269
last_span : Span ,
275
- mir_def_id : LocalDefId ,
276
270
errors_reported : bool ,
277
271
}
278
272
@@ -460,14 +454,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
460
454
body : & ' b Body < ' tcx > ,
461
455
promoted : & ' b IndexVec < Promoted , Body < ' tcx > > ,
462
456
) -> 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 }
471
458
}
472
459
473
460
fn tcx ( & self ) -> TyCtxt < ' tcx > {
@@ -816,7 +803,6 @@ struct TypeChecker<'a, 'tcx> {
816
803
/// User type annotations are shared between the main MIR and the MIR of
817
804
/// all of the promoted items.
818
805
user_type_annotations : & ' a CanonicalUserTypeAnnotations < ' tcx > ,
819
- mir_def_id : LocalDefId ,
820
806
region_bound_pairs : & ' a RegionBoundPairs < ' tcx > ,
821
807
implicit_region_bound : ty:: Region < ' tcx > ,
822
808
reported_errors : FxHashSet < ( Ty < ' tcx > , Span ) > ,
@@ -965,7 +951,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
965
951
fn new (
966
952
infcx : & ' a InferCtxt < ' a , ' tcx > ,
967
953
body : & ' a Body < ' tcx > ,
968
- mir_def_id : LocalDefId ,
969
954
param_env : ty:: ParamEnv < ' tcx > ,
970
955
region_bound_pairs : & ' a RegionBoundPairs < ' tcx > ,
971
956
implicit_region_bound : ty:: Region < ' tcx > ,
@@ -975,7 +960,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
975
960
let mut checker = Self {
976
961
infcx,
977
962
last_span : DUMMY_SP ,
978
- mir_def_id,
979
963
body,
980
964
user_type_annotations : & body. user_type_annotations ,
981
965
param_env,
@@ -1145,7 +1129,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1145
1129
// the resulting inferend values are stored with the
1146
1130
// def-id of the base function.
1147
1131
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 ( ) ;
1149
1133
return self . eq_opaque_type_and_type ( sub, sup, parent_def_id, locations, category) ;
1150
1134
} else {
1151
1135
return Err ( terr) ;
@@ -1242,7 +1226,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1242
1226
let concrete_opaque_types = & tcx. typeck ( anon_owner_def_id) . concrete_opaque_types ;
1243
1227
let mut opaque_type_values = Vec :: new ( ) ;
1244
1228
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 ( ) ) ;
1246
1230
let opaque_type_map = self . fully_perform_op (
1247
1231
locations,
1248
1232
category,
@@ -2001,12 +1985,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2001
1985
let span = body. source_info ( location) . span ;
2002
1986
let ty = operand. ty ( body, tcx) ;
2003
1987
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 ) ;
2010
1989
// To determine if `const_in_array_repeat_expressions` feature gate should
2011
1990
// be mentioned, need to check if the rvalue is promotable.
2012
1991
let should_suggest =
@@ -2015,11 +1994,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2015
1994
) ;
2016
1995
debug ! ( "check_rvalue: should_suggest={:?}" , should_suggest) ;
2017
1996
1997
+ let def_id = body. source . def_id ( ) . expect_local ( ) ;
2018
1998
self . infcx . report_selection_error (
2019
1999
& traits:: Obligation :: new (
2020
2000
ObligationCause :: new (
2021
2001
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 ) ,
2023
2003
traits:: ObligationCauseCode :: RepeatVec ( should_suggest) ,
2024
2004
) ,
2025
2005
self . param_env ,
0 commit comments