@@ -160,8 +160,8 @@ impl<'tcx> Instance<'tcx> {
160160 self . substs . non_erasable_generics ( ) . next ( ) ?;
161161
162162 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 )
165165 . and_then ( |monos| monos. get ( & self . substs ) . cloned ( ) ) ,
166166 InstanceDef :: DropGlue ( _, Some ( _) ) => tcx. upstream_drop_glue_for ( self . substs ) ,
167167 _ => None ,
@@ -173,8 +173,8 @@ impl<'tcx> InstanceDef<'tcx> {
173173 #[ inline]
174174 pub fn def_id ( & self ) -> DefId {
175175 match * self {
176- InstanceDef :: Item ( def_id , _ )
177- | InstanceDef :: VtableShim ( def_id)
176+ InstanceDef :: Item ( def ) => def . did ,
177+ InstanceDef :: VtableShim ( def_id)
178178 | InstanceDef :: ReifyShim ( def_id)
179179 | InstanceDef :: FnPtrShim ( def_id, _)
180180 | InstanceDef :: Virtual ( def_id, _)
@@ -186,12 +186,8 @@ impl<'tcx> InstanceDef<'tcx> {
186186 }
187187
188188 #[ 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 ( ) ) }
195191 }
196192
197193 #[ inline]
@@ -207,7 +203,7 @@ impl<'tcx> InstanceDef<'tcx> {
207203 pub fn requires_inline ( & self , tcx : TyCtxt < ' tcx > ) -> bool {
208204 use rustc_hir:: definitions:: DefPathData ;
209205 let def_id = match * self {
210- ty:: InstanceDef :: Item ( def_id , _ ) => def_id ,
206+ ty:: InstanceDef :: Item ( def ) => def . did ,
211207 ty:: InstanceDef :: DropGlue ( _, Some ( _) ) => return false ,
212208 _ => return true ,
213209 } ;
@@ -253,8 +249,8 @@ impl<'tcx> InstanceDef<'tcx> {
253249
254250 pub fn requires_caller_location ( & self , tcx : TyCtxt < ' _ > ) -> bool {
255251 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 )
258254 }
259255 _ => false ,
260256 }
@@ -271,7 +267,7 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
271267 } ) ?;
272268
273269 match self . def {
274- InstanceDef :: Item ( _, _ ) => Ok ( ( ) ) ,
270+ InstanceDef :: Item ( _) => Ok ( ( ) ) ,
275271 InstanceDef :: VtableShim ( _) => write ! ( f, " - shim(vtable)" ) ,
276272 InstanceDef :: ReifyShim ( _) => write ! ( f, " - shim(reify)" ) ,
277273 InstanceDef :: Intrinsic ( _) => write ! ( f, " - intrinsic" ) ,
@@ -292,7 +288,7 @@ impl<'tcx> Instance<'tcx> {
292288 did,
293289 substs
294290 ) ;
295- Instance { def : InstanceDef :: Item ( did, None ) , substs }
291+ Instance { def : InstanceDef :: Item ( ty :: WithOptParam :: dummy ( did) ) , substs }
296292 }
297293
298294 pub fn mono ( tcx : TyCtxt < ' tcx > , def_id : DefId ) -> Instance < ' tcx > {
@@ -304,11 +300,6 @@ impl<'tcx> Instance<'tcx> {
304300 self . def . def_id ( )
305301 }
306302
307- #[ inline]
308- pub fn with_opt_param ( & self , tcx : TyCtxt < ' tcx > ) -> ty:: WithOptParam < DefId > {
309- self . def . with_opt_param ( tcx)
310- }
311-
312303 /// Identical to `resolve`, but may also take an optional `param_def_id` for
313304 /// generic const arguments.
314305 pub fn resolve_const_arg (
@@ -378,9 +369,9 @@ impl<'tcx> Instance<'tcx> {
378369 debug ! ( "resolve(def_id={:?}, substs={:?})" , def_id, substs) ;
379370 Instance :: resolve ( tcx, param_env, def_id, substs) . ok ( ) . flatten ( ) . map ( |mut resolved| {
380371 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) => {
382373 debug ! ( " => fn pointer created for function with #[track_caller]" ) ;
383- resolved. def = InstanceDef :: ReifyShim ( def_id ) ;
374+ resolved. def = InstanceDef :: ReifyShim ( def . did ) ;
384375 }
385376 InstanceDef :: Virtual ( def_id, _) => {
386377 debug ! ( " => fn pointer created for virtual call" ) ;
@@ -476,7 +467,7 @@ impl<'tcx> Instance<'tcx> {
476467 | InstanceDef :: DropGlue ( ..)
477468 // FIXME(#69925): `FnPtrShim` should be in the other branch.
478469 | InstanceDef :: FnPtrShim ( ..)
479- | InstanceDef :: Item ( _, _ )
470+ | InstanceDef :: Item ( _)
480471 | InstanceDef :: Intrinsic ( ..)
481472 | InstanceDef :: ReifyShim ( ..)
482473 | InstanceDef :: Virtual ( ..)
0 commit comments