File tree 3 files changed +7
-6
lines changed
rustc_smir/src/rustc_smir
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> {
322
322
matches ! ( instance. def, ty:: InstanceDef :: DropGlue ( _, None ) )
323
323
}
324
324
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 {
326
326
let mut tables = self . 0 . borrow_mut ( ) ;
327
- let def_id = tables[ item . 0 ] ;
327
+ let def_id = tables[ def_id ] ;
328
328
Instance :: mono ( tables. tcx , def_id) . stable ( & mut * tables)
329
329
}
330
330
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ pub trait Context {
125
125
126
126
/// Convert a non-generic crate item into an instance.
127
127
/// 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 ;
129
129
130
130
/// Item requires monomorphization.
131
131
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 {
143
143
144
144
fn try_from ( item : CrateItem ) -> Result < Self , Self :: Error > {
145
145
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) )
148
149
} else {
149
150
Err ( Error :: new ( "Item requires monomorphization" . to_string ( ) ) )
150
151
}
@@ -223,7 +224,7 @@ impl TryFrom<Instance> for StaticDef {
223
224
impl From < StaticDef > for Instance {
224
225
fn from ( value : StaticDef ) -> Self {
225
226
// 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 ( ) ) )
227
228
}
228
229
}
229
230
You can’t perform that action at this time.
0 commit comments