@@ -160,8 +160,8 @@ impl<'tcx> Instance<'tcx> {
160
160
self . substs . non_erasable_generics ( ) . next ( ) ?;
161
161
162
162
match self . def {
163
- InstanceDef :: Item ( def_id , _ ) => tcx
164
- . upstream_monomorphizations_for ( def_id )
163
+ InstanceDef :: Item ( def ) => tcx
164
+ . upstream_monomorphizations_for ( def . did )
165
165
. and_then ( |monos| monos. get ( & self . substs ) . cloned ( ) ) ,
166
166
InstanceDef :: DropGlue ( _, Some ( _) ) => tcx. upstream_drop_glue_for ( self . substs ) ,
167
167
_ => None ,
@@ -173,8 +173,8 @@ impl<'tcx> InstanceDef<'tcx> {
173
173
#[ inline]
174
174
pub fn def_id ( & self ) -> DefId {
175
175
match * self {
176
- InstanceDef :: Item ( def_id , _ )
177
- | InstanceDef :: VtableShim ( def_id)
176
+ InstanceDef :: Item ( def ) => def . did ,
177
+ InstanceDef :: VtableShim ( def_id)
178
178
| InstanceDef :: ReifyShim ( def_id)
179
179
| InstanceDef :: FnPtrShim ( def_id, _)
180
180
| InstanceDef :: Virtual ( def_id, _)
@@ -186,12 +186,8 @@ impl<'tcx> InstanceDef<'tcx> {
186
186
}
187
187
188
188
#[ inline]
189
- pub fn with_opt_param ( & self , tcx : TyCtxt < ' tcx > ) -> ty:: WithOptParam < DefId > {
190
- ty:: WithOptParam {
191
- did : self . def_id ( ) ,
192
- param_did : if let InstanceDef :: Item ( _, param_did) = * self { param_did } else { None }
193
- . or_else ( || tcx. const_param_of ( self . def_id ( ) ) ) ,
194
- }
189
+ pub fn with_opt_param ( self ) -> ty:: WithOptParam < DefId > {
190
+ if let InstanceDef :: Item ( def) = self { def } else { ty:: WithOptParam :: dummy ( self . def_id ( ) ) }
195
191
}
196
192
197
193
#[ inline]
@@ -207,7 +203,7 @@ impl<'tcx> InstanceDef<'tcx> {
207
203
pub fn requires_inline ( & self , tcx : TyCtxt < ' tcx > ) -> bool {
208
204
use rustc_hir:: definitions:: DefPathData ;
209
205
let def_id = match * self {
210
- ty:: InstanceDef :: Item ( def_id , _ ) => def_id ,
206
+ ty:: InstanceDef :: Item ( def ) => def . did ,
211
207
ty:: InstanceDef :: DropGlue ( _, Some ( _) ) => return false ,
212
208
_ => return true ,
213
209
} ;
@@ -253,8 +249,8 @@ impl<'tcx> InstanceDef<'tcx> {
253
249
254
250
pub fn requires_caller_location ( & self , tcx : TyCtxt < ' _ > ) -> bool {
255
251
match * self {
256
- InstanceDef :: Item ( def_id , _ ) => {
257
- tcx. codegen_fn_attrs ( def_id ) . flags . contains ( CodegenFnAttrFlags :: TRACK_CALLER )
252
+ InstanceDef :: Item ( def ) => {
253
+ tcx. codegen_fn_attrs ( def . did ) . flags . contains ( CodegenFnAttrFlags :: TRACK_CALLER )
258
254
}
259
255
_ => false ,
260
256
}
@@ -271,7 +267,7 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
271
267
} ) ?;
272
268
273
269
match self . def {
274
- InstanceDef :: Item ( _, _ ) => Ok ( ( ) ) ,
270
+ InstanceDef :: Item ( _) => Ok ( ( ) ) ,
275
271
InstanceDef :: VtableShim ( _) => write ! ( f, " - shim(vtable)" ) ,
276
272
InstanceDef :: ReifyShim ( _) => write ! ( f, " - shim(reify)" ) ,
277
273
InstanceDef :: Intrinsic ( _) => write ! ( f, " - intrinsic" ) ,
@@ -292,7 +288,7 @@ impl<'tcx> Instance<'tcx> {
292
288
did,
293
289
substs
294
290
) ;
295
- Instance { def : InstanceDef :: Item ( did, None ) , substs }
291
+ Instance { def : InstanceDef :: Item ( ty :: WithOptParam :: dummy ( did) ) , substs }
296
292
}
297
293
298
294
pub fn mono ( tcx : TyCtxt < ' tcx > , def_id : DefId ) -> Instance < ' tcx > {
@@ -304,11 +300,6 @@ impl<'tcx> Instance<'tcx> {
304
300
self . def . def_id ( )
305
301
}
306
302
307
- #[ inline]
308
- pub fn with_opt_param ( & self , tcx : TyCtxt < ' tcx > ) -> ty:: WithOptParam < DefId > {
309
- self . def . with_opt_param ( tcx)
310
- }
311
-
312
303
/// Identical to `resolve`, but may also take an optional `param_def_id` for
313
304
/// generic const arguments.
314
305
pub fn resolve_const_arg (
@@ -378,9 +369,9 @@ impl<'tcx> Instance<'tcx> {
378
369
debug ! ( "resolve(def_id={:?}, substs={:?})" , def_id, substs) ;
379
370
Instance :: resolve ( tcx, param_env, def_id, substs) . ok ( ) . flatten ( ) . map ( |mut resolved| {
380
371
match resolved. def {
381
- InstanceDef :: Item ( def_id , _ ) if resolved. def . requires_caller_location ( tcx) => {
372
+ InstanceDef :: Item ( def ) if resolved. def . requires_caller_location ( tcx) => {
382
373
debug ! ( " => fn pointer created for function with #[track_caller]" ) ;
383
- resolved. def = InstanceDef :: ReifyShim ( def_id ) ;
374
+ resolved. def = InstanceDef :: ReifyShim ( def . did ) ;
384
375
}
385
376
InstanceDef :: Virtual ( def_id, _) => {
386
377
debug ! ( " => fn pointer created for virtual call" ) ;
@@ -476,7 +467,7 @@ impl<'tcx> Instance<'tcx> {
476
467
| InstanceDef :: DropGlue ( ..)
477
468
// FIXME(#69925): `FnPtrShim` should be in the other branch.
478
469
| InstanceDef :: FnPtrShim ( ..)
479
- | InstanceDef :: Item ( _, _ )
470
+ | InstanceDef :: Item ( _)
480
471
| InstanceDef :: Intrinsic ( ..)
481
472
| InstanceDef :: ReifyShim ( ..)
482
473
| InstanceDef :: Virtual ( ..)
0 commit comments