This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +7
-6
lines changed
rustc_smir/src/rustc_smir Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -322,9 +322,9 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
322322 matches ! ( instance. def, ty:: InstanceDef :: DropGlue ( _, None ) )
323323 }
324324
325- fn mono_instance ( & self , item : stable_mir:: CrateItem ) -> stable_mir:: mir:: mono:: Instance {
325+ fn mono_instance ( & self , def_id : stable_mir:: DefId ) -> stable_mir:: mir:: mono:: Instance {
326326 let mut tables = self . 0 . borrow_mut ( ) ;
327- let def_id = tables[ item . 0 ] ;
327+ let def_id = tables[ def_id ] ;
328328 Instance :: mono ( tables. tcx , def_id) . stable ( & mut * tables)
329329 }
330330
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ pub trait Context {
125125
126126 /// Convert a non-generic crate item into an instance.
127127 /// This function will panic if the item is generic.
128- fn mono_instance ( & self , item : CrateItem ) -> Instance ;
128+ fn mono_instance ( & self , def_id : DefId ) -> Instance ;
129129
130130 /// Item requires monomorphization.
131131 fn requires_monomorphization ( & self , def_id : DefId ) -> bool ;
Original file line number Diff line number Diff line change @@ -143,8 +143,9 @@ impl TryFrom<CrateItem> for Instance {
143143
144144 fn try_from ( item : CrateItem ) -> Result < Self , Self :: Error > {
145145 with ( |context| {
146- if !context. requires_monomorphization ( item. 0 ) {
147- Ok ( context. mono_instance ( item) )
146+ let def_id = item. def_id ( ) ;
147+ if !context. requires_monomorphization ( def_id) {
148+ Ok ( context. mono_instance ( def_id) )
148149 } else {
149150 Err ( Error :: new ( "Item requires monomorphization" . to_string ( ) ) )
150151 }
@@ -223,7 +224,7 @@ impl TryFrom<Instance> for StaticDef {
223224impl From < StaticDef > for Instance {
224225 fn from ( value : StaticDef ) -> Self {
225226 // A static definition should always be convertible to an instance.
226- Instance :: try_from ( CrateItem :: from ( value) ) . unwrap ( )
227+ with ( |cx| cx . mono_instance ( value. def_id ( ) ) )
227228 }
228229}
229230
You can’t perform that action at this time.
0 commit comments