@@ -178,6 +178,12 @@ fn item_parent_item(d: ebml::Doc) -> Option<ast::def_id> {
178
178
None
179
179
}
180
180
181
+ fn item_reqd_and_translated_parent_item ( cnum : ast:: crate_num ,
182
+ d : ebml:: Doc ) -> ast:: def_id {
183
+ let trait_did = item_parent_item ( d) . expect ( ~"item without parent") ;
184
+ { crate : cnum, node: trait_did. node }
185
+ }
186
+
181
187
fn item_def_id ( d : ebml:: Doc , cdata : cmd ) -> ast:: def_id {
182
188
let tagdoc = ebml:: get_doc ( d, tag_def_id) ;
183
189
return translate_def_id ( cdata, ebml:: with_doc_data ( tagdoc,
@@ -297,35 +303,39 @@ fn item_name(intr: @ident_interner, item: ebml::Doc) -> ast::ident {
297
303
}
298
304
299
305
fn item_to_def_like ( item : ebml:: Doc , did : ast:: def_id , cnum : ast:: crate_num )
300
- -> def_like {
306
+ -> def_like
307
+ {
301
308
let fam = item_family ( item) ;
302
309
match fam {
303
- Const => dl_def ( ast:: def_const ( did) ) ,
304
- Class => dl_def ( ast:: def_class ( did, true ) ) ,
305
- Struct => dl_def ( ast:: def_class ( did, false ) ) ,
306
- UnsafeFn => dl_def ( ast:: def_fn ( did, ast:: unsafe_fn) ) ,
307
- Fn => dl_def ( ast:: def_fn ( did, ast:: impure_fn) ) ,
308
- PureFn => dl_def ( ast:: def_fn ( did, ast:: pure_fn) ) ,
309
- ForeignFn => dl_def ( ast:: def_fn ( did, ast:: extern_fn) ) ,
310
- UnsafeStaticMethod => dl_def ( ast:: def_static_method ( did,
311
- ast:: unsafe_fn) ) ,
312
- StaticMethod => dl_def ( ast:: def_static_method ( did, ast:: impure_fn) ) ,
313
- PureStaticMethod => dl_def ( ast:: def_static_method ( did, ast:: pure_fn) ) ,
314
- Type | ForeignType => dl_def ( ast:: def_ty ( did) ) ,
315
- Mod => dl_def ( ast:: def_mod ( did) ) ,
316
- ForeignMod => dl_def ( ast:: def_foreign_mod ( did) ) ,
317
- Variant => {
318
- match item_parent_item ( item) {
319
- Some ( t) => {
320
- let tid = { crate : cnum, node: t. node } ;
321
- dl_def ( ast:: def_variant ( tid, did) )
322
- }
323
- None => fail ~"item_to_def_like: enum item has no parent"
324
- }
325
- }
326
- Trait | Enum => dl_def ( ast:: def_ty ( did) ) ,
327
- Impl => dl_impl ( did) ,
328
- PublicField | PrivateField | InheritedField => dl_field,
310
+ Const => dl_def ( ast:: def_const ( did) ) ,
311
+ Class => dl_def ( ast:: def_class ( did, true ) ) ,
312
+ Struct => dl_def ( ast:: def_class ( did, false ) ) ,
313
+ UnsafeFn => dl_def ( ast:: def_fn ( did, ast:: unsafe_fn) ) ,
314
+ Fn => dl_def ( ast:: def_fn ( did, ast:: impure_fn) ) ,
315
+ PureFn => dl_def ( ast:: def_fn ( did, ast:: pure_fn) ) ,
316
+ ForeignFn => dl_def ( ast:: def_fn ( did, ast:: extern_fn) ) ,
317
+ UnsafeStaticMethod => {
318
+ let trait_did = item_reqd_and_translated_parent_item ( cnum, item) ;
319
+ dl_def ( ast:: def_static_method ( did, trait_did, ast:: unsafe_fn) )
320
+ }
321
+ StaticMethod => {
322
+ let trait_did = item_reqd_and_translated_parent_item ( cnum, item) ;
323
+ dl_def ( ast:: def_static_method ( did, trait_did, ast:: impure_fn) )
324
+ }
325
+ PureStaticMethod => {
326
+ let trait_did = item_reqd_and_translated_parent_item ( cnum, item) ;
327
+ dl_def ( ast:: def_static_method ( did, trait_did, ast:: pure_fn) )
328
+ }
329
+ Type | ForeignType => dl_def ( ast:: def_ty ( did) ) ,
330
+ Mod => dl_def ( ast:: def_mod ( did) ) ,
331
+ ForeignMod => dl_def ( ast:: def_foreign_mod ( did) ) ,
332
+ Variant => {
333
+ let enum_did = item_reqd_and_translated_parent_item ( cnum, item) ;
334
+ dl_def ( ast:: def_variant ( enum_did, did) )
335
+ }
336
+ Trait | Enum => dl_def ( ast:: def_ty ( did) ) ,
337
+ Impl => dl_impl ( did) ,
338
+ PublicField | PrivateField | InheritedField => dl_field,
329
339
}
330
340
}
331
341
0 commit comments