@@ -1161,8 +1161,9 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1161
1161
// Re-export lists automatically contain constructors when necessary.
1162
1162
match kind {
1163
1163
DefKind :: Struct => {
1164
- if let Some ( ctor_def_id) = self . get_ctor_def_id ( child_index) {
1165
- let ctor_kind = self . get_ctor_kind ( child_index) ;
1164
+ if let Some ( ( ctor_def_id, ctor_kind) ) =
1165
+ self . get_ctor_def_id_and_kind ( child_index)
1166
+ {
1166
1167
let ctor_res =
1167
1168
Res :: Def ( DefKind :: Ctor ( CtorOf :: Struct , ctor_kind) , ctor_def_id) ;
1168
1169
let vis = self . get_visibility ( ctor_def_id. index ) ;
@@ -1174,8 +1175,9 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1174
1175
// value namespace, they are reserved for possible future use.
1175
1176
// It's ok to use the variant's id as a ctor id since an
1176
1177
// error will be reported on any use of such resolution anyway.
1177
- let ctor_def_id = self . get_ctor_def_id ( child_index) . unwrap_or ( def_id) ;
1178
- let ctor_kind = self . get_ctor_kind ( child_index) ;
1178
+ let ( ctor_def_id, ctor_kind) = self
1179
+ . get_ctor_def_id_and_kind ( child_index)
1180
+ . unwrap_or ( ( def_id, CtorKind :: Fictive ) ) ;
1179
1181
let ctor_res =
1180
1182
Res :: Def ( DefKind :: Ctor ( CtorOf :: Variant , ctor_kind) , ctor_def_id) ;
1181
1183
let mut vis = self . get_visibility ( ctor_def_id. index ) ;
@@ -1296,6 +1298,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1296
1298
}
1297
1299
}
1298
1300
1301
+ fn get_fn_has_self_parameter ( & self , id : DefIndex ) -> bool {
1302
+ match self . kind ( id) {
1303
+ EntryKind :: AssocFn ( data) => data. decode ( self ) . has_self ,
1304
+ _ => false ,
1305
+ }
1306
+ }
1307
+
1299
1308
fn get_associated_item ( & self , id : DefIndex , sess : & Session ) -> ty:: AssocItem {
1300
1309
let def_key = self . def_key ( id) ;
1301
1310
let parent = self . local_def_id ( def_key. parent . unwrap ( ) ) ;
@@ -1326,22 +1335,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1326
1335
self . root . tables . variances . get ( self , id) . unwrap_or_else ( Lazy :: empty) . decode ( self )
1327
1336
}
1328
1337
1329
- fn get_ctor_kind ( & self , node_id : DefIndex ) -> CtorKind {
1338
+ fn get_ctor_def_id_and_kind ( & self , node_id : DefIndex ) -> Option < ( DefId , CtorKind ) > {
1330
1339
match self . kind ( node_id) {
1331
- EntryKind :: Struct ( data, _) | EntryKind :: Union ( data, _) | EntryKind :: Variant ( data) => {
1332
- data. decode ( self ) . ctor_kind
1333
- }
1334
- _ => CtorKind :: Fictive ,
1335
- }
1336
- }
1337
-
1338
- fn get_ctor_def_id ( & self , node_id : DefIndex ) -> Option < DefId > {
1339
- match self . kind ( node_id) {
1340
- EntryKind :: Struct ( data, _) => {
1341
- data. decode ( self ) . ctor . map ( |index| self . local_def_id ( index) )
1342
- }
1343
- EntryKind :: Variant ( data) => {
1344
- data. decode ( self ) . ctor . map ( |index| self . local_def_id ( index) )
1340
+ EntryKind :: Struct ( data, _) | EntryKind :: Variant ( data) => {
1341
+ let vdata = data. decode ( self ) ;
1342
+ vdata. ctor . map ( |index| ( self . local_def_id ( index) , vdata. ctor_kind ) )
1345
1343
}
1346
1344
_ => None ,
1347
1345
}
0 commit comments