@@ -70,7 +70,7 @@ impl crate_metadata {
70
70
71
71
fn lookup_item ( & self , item_id : DefIndex ) -> rbml:: Doc {
72
72
match self . get_item ( item_id) {
73
- None => panic ! ( "lookup_item: id not found: {:?}" , item_id) ,
73
+ None => bug ! ( "lookup_item: id not found: {:?}" , item_id) ,
74
74
Some ( d) => d
75
75
}
76
76
}
@@ -136,7 +136,7 @@ fn item_family(item: rbml::Doc) -> Family {
136
136
'u' => Struct ( VariantKind :: Unit ) ,
137
137
'g' => PublicField ,
138
138
'N' => InheritedField ,
139
- c => panic ! ( "unexpected family char: {}" , c)
139
+ c => bug ! ( "unexpected family char: {}" , c)
140
140
}
141
141
}
142
142
@@ -147,7 +147,7 @@ fn item_visibility(item: rbml::Doc) -> hir::Visibility {
147
147
match reader:: doc_as_u8 ( visibility_doc) as char {
148
148
'y' => hir:: Public ,
149
149
'i' => hir:: Inherited ,
150
- _ => panic ! ( "unknown visibility character" )
150
+ _ => bug ! ( "unknown visibility character" )
151
151
}
152
152
}
153
153
}
@@ -160,7 +160,7 @@ fn fn_constness(item: rbml::Doc) -> hir::Constness {
160
160
match reader:: doc_as_u8 ( constness_doc) as char {
161
161
'c' => hir:: Constness :: Const ,
162
162
'n' => hir:: Constness :: NotConst ,
163
- _ => panic ! ( "unknown constness character" )
163
+ _ => bug ! ( "unknown constness character" )
164
164
}
165
165
}
166
166
}
@@ -173,7 +173,7 @@ fn item_defaultness(item: rbml::Doc) -> hir::Defaultness {
173
173
match reader:: doc_as_u8 ( defaultness_doc) as char {
174
174
'd' => hir:: Defaultness :: Default ,
175
175
'f' => hir:: Defaultness :: Final ,
176
- _ => panic ! ( "unknown defaultness character" )
176
+ _ => bug ! ( "unknown defaultness character" )
177
177
}
178
178
}
179
179
}
@@ -387,16 +387,15 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
387
387
item_id : DefIndex ,
388
388
tcx : & TyCtxt < ' tcx > ) -> ty:: AdtDefMaster < ' tcx >
389
389
{
390
- fn expect_variant_kind < ' tcx > ( family : Family , tcx : & TyCtxt < ' tcx > ) -> ty:: VariantKind {
390
+ fn expect_variant_kind ( family : Family ) -> ty:: VariantKind {
391
391
match family_to_variant_kind ( family) {
392
392
Some ( kind) => kind,
393
- _ => tcx . sess . bug ( & format ! ( "unexpected family: {:?}" , family) ) ,
393
+ _ => bug ! ( "unexpected family: {:?}" , family) ,
394
394
}
395
395
}
396
396
fn get_enum_variants < ' tcx > ( intr : & IdentInterner ,
397
397
cdata : Cmd ,
398
- doc : rbml:: Doc ,
399
- tcx : & TyCtxt < ' tcx > ) -> Vec < ty:: VariantDefData < ' tcx , ' tcx > > {
398
+ doc : rbml:: Doc ) -> Vec < ty:: VariantDefData < ' tcx , ' tcx > > {
400
399
let mut disr_val = 0 ;
401
400
reader:: tagged_docs ( doc, tag_items_data_item_variant) . map ( |p| {
402
401
let did = translated_def_id ( cdata, p) ;
@@ -411,22 +410,21 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
411
410
ty:: VariantDefData {
412
411
did : did,
413
412
name : item_name ( intr, item) ,
414
- fields : get_variant_fields ( intr, cdata, item, tcx ) ,
413
+ fields : get_variant_fields ( intr, cdata, item) ,
415
414
disr_val : ConstInt :: Infer ( disr) ,
416
- kind : expect_variant_kind ( item_family ( item) , tcx ) ,
415
+ kind : expect_variant_kind ( item_family ( item) ) ,
417
416
}
418
417
} ) . collect ( )
419
418
}
420
419
fn get_variant_fields < ' tcx > ( intr : & IdentInterner ,
421
420
cdata : Cmd ,
422
- doc : rbml:: Doc ,
423
- tcx : & TyCtxt < ' tcx > ) -> Vec < ty:: FieldDefData < ' tcx , ' tcx > > {
421
+ doc : rbml:: Doc ) -> Vec < ty:: FieldDefData < ' tcx , ' tcx > > {
424
422
let mut index = 0 ;
425
423
reader:: tagged_docs ( doc, tag_item_field) . map ( |f| {
426
424
let ff = item_family ( f) ;
427
425
match ff {
428
426
PublicField | InheritedField => { } ,
429
- _ => tcx . sess . bug ( & format ! ( "expected field, found {:?}" , ff) )
427
+ _ => bug ! ( "expected field, found {:?}" , ff)
430
428
} ;
431
429
ty:: FieldDefData :: new ( item_def_id ( f, cdata) ,
432
430
item_name ( intr, f) ,
@@ -442,14 +440,13 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
442
440
fn get_struct_variant < ' tcx > ( intr : & IdentInterner ,
443
441
cdata : Cmd ,
444
442
doc : rbml:: Doc ,
445
- did : DefId ,
446
- tcx : & TyCtxt < ' tcx > ) -> ty:: VariantDefData < ' tcx , ' tcx > {
443
+ did : DefId ) -> ty:: VariantDefData < ' tcx , ' tcx > {
447
444
ty:: VariantDefData {
448
445
did : did,
449
446
name : item_name ( intr, doc) ,
450
- fields : get_variant_fields ( intr, cdata, doc, tcx ) ,
447
+ fields : get_variant_fields ( intr, cdata, doc) ,
451
448
disr_val : ConstInt :: Infer ( 0 ) ,
452
- kind : expect_variant_kind ( item_family ( doc) , tcx ) ,
449
+ kind : expect_variant_kind ( item_family ( doc) ) ,
453
450
}
454
451
}
455
452
@@ -458,18 +455,17 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
458
455
let ( kind, variants) = match item_family ( doc) {
459
456
Enum => {
460
457
( ty:: AdtKind :: Enum ,
461
- get_enum_variants ( intr, cdata, doc, tcx ) )
458
+ get_enum_variants ( intr, cdata, doc) )
462
459
}
463
460
Struct ( ..) => {
464
461
let ctor_did =
465
462
reader:: maybe_get_doc ( doc, tag_items_data_item_struct_ctor) .
466
463
map_or ( did, |ctor_doc| translated_def_id ( cdata, ctor_doc) ) ;
467
464
( ty:: AdtKind :: Struct ,
468
- vec ! [ get_struct_variant( intr, cdata, doc, ctor_did, tcx ) ] )
465
+ vec ! [ get_struct_variant( intr, cdata, doc, ctor_did) ] )
469
466
}
470
- _ => tcx. sess . bug (
471
- & format ! ( "get_adt_def called on a non-ADT {:?} - {:?}" ,
472
- item_family( doc) , did) )
467
+ _ => bug ! ( "get_adt_def called on a non-ADT {:?} - {:?}" ,
468
+ item_family( doc) , did)
473
469
} ;
474
470
475
471
let adt = tcx. intern_adt_def ( did, kind, variants) ;
@@ -495,7 +491,7 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
495
491
assert ! ( !inputs. has_escaping_regions( ) ) ;
496
492
inputs
497
493
} ,
498
- _ => tcx . sess . bug ( "tuple-variant ctor is not an ADT" )
494
+ _ => bug ! ( "tuple-variant ctor is not an ADT" )
499
495
} ;
500
496
for ( field, & ty) in variant. fields . iter ( ) . zip ( field_tys. iter ( ) ) {
501
497
field. fulfill_ty ( ty) ;
@@ -915,7 +911,7 @@ fn get_explicit_self(item: rbml::Doc) -> ty::ExplicitSelfCategory {
915
911
match ch as char {
916
912
'i' => hir:: MutImmutable ,
917
913
'm' => hir:: MutMutable ,
918
- _ => panic ! ( "unknown mutability character: `{}`" , ch as char ) ,
914
+ _ => bug ! ( "unknown mutability character: `{}`" , ch as char ) ,
919
915
}
920
916
}
921
917
@@ -933,7 +929,7 @@ fn get_explicit_self(item: rbml::Doc) -> ty::ExplicitSelfCategory {
933
929
ty:: ReEmpty ,
934
930
get_mutability ( string. as_bytes ( ) [ 1 ] ) )
935
931
}
936
- _ => panic ! ( "unknown self type code: `{}`" , explicit_self_kind as char )
932
+ _ => bug ! ( "unknown self type code: `{}`" , explicit_self_kind as char )
937
933
}
938
934
}
939
935
@@ -946,7 +942,7 @@ pub fn get_impl_items(cdata: Cmd, impl_id: DefIndex)
946
942
Some ( 'C' ) | Some ( 'c' ) => ty:: ConstTraitItemId ( def_id) ,
947
943
Some ( 'r' ) | Some ( 'p' ) => ty:: MethodTraitItemId ( def_id) ,
948
944
Some ( 't' ) => ty:: TypeTraitItemId ( def_id) ,
949
- _ => panic ! ( "unknown impl item sort" ) ,
945
+ _ => bug ! ( "unknown impl item sort" ) ,
950
946
}
951
947
} ) . collect ( )
952
948
}
@@ -1012,9 +1008,9 @@ pub fn get_impl_or_trait_item<'tcx>(intr: Rc<IdentInterner>,
1012
1008
let ity = tcx. lookup_item_type ( def_id) . ty ;
1013
1009
let fty = match ity. sty {
1014
1010
ty:: TyFnDef ( _, _, fty) => fty. clone ( ) ,
1015
- _ => tcx . sess . bug ( & format ! (
1011
+ _ => bug ! (
1016
1012
"the type {:?} of the method {:?} is not a function?" ,
1017
- ity, name) )
1013
+ ity, name)
1018
1014
} ;
1019
1015
let explicit_self = get_explicit_self ( item_doc) ;
1020
1016
@@ -1052,7 +1048,7 @@ pub fn get_trait_item_def_ids(cdata: Cmd, id: DefIndex)
1052
1048
Some ( 'C' ) | Some ( 'c' ) => ty:: ConstTraitItemId ( def_id) ,
1053
1049
Some ( 'r' ) | Some ( 'p' ) => ty:: MethodTraitItemId ( def_id) ,
1054
1050
Some ( 't' ) => ty:: TypeTraitItemId ( def_id) ,
1055
- _ => panic ! ( "unknown trait item sort" ) ,
1051
+ _ => bug ! ( "unknown trait item sort" ) ,
1056
1052
}
1057
1053
} ) . collect ( )
1058
1054
}
@@ -1172,7 +1168,7 @@ fn struct_field_family_to_visibility(family: Family) -> hir::Visibility {
1172
1168
match family {
1173
1169
PublicField => hir:: Public ,
1174
1170
InheritedField => hir:: Inherited ,
1175
- _ => panic ! ( )
1171
+ _ => bug ! ( )
1176
1172
}
1177
1173
}
1178
1174
@@ -1354,7 +1350,7 @@ pub fn translate_def_id(cdata: Cmd, did: DefId) -> DefId {
1354
1350
index : did. index ,
1355
1351
}
1356
1352
}
1357
- None => panic ! ( "didn't find a crate in the cnum_map" )
1353
+ None => bug ! ( "didn't find a crate in the cnum_map" )
1358
1354
}
1359
1355
}
1360
1356
@@ -1544,7 +1540,7 @@ pub fn get_dylib_dependency_formats(cdata: Cmd)
1544
1540
let cnum: ast:: CrateNum = cnum. parse ( ) . unwrap ( ) ;
1545
1541
let cnum = match cdata. cnum_map . borrow ( ) . get ( & cnum) {
1546
1542
Some ( & n) => n,
1547
- None => panic ! ( "didn't find a crate in the cnum_map" )
1543
+ None => bug ! ( "didn't find a crate in the cnum_map" )
1548
1544
} ;
1549
1545
result. push ( ( cnum, if link == "d" {
1550
1546
LinkagePreference :: RequireDynamic
@@ -1772,7 +1768,7 @@ pub fn def_key(cdata: Cmd, id: DefIndex) -> hir_map::DefKey {
1772
1768
hir_map:: DefKey :: decode ( & mut decoder) . unwrap ( )
1773
1769
}
1774
1770
None => {
1775
- panic ! ( "failed to find block with tag {:?} for item with family {:?}" ,
1771
+ bug ! ( "failed to find block with tag {:?} for item with family {:?}" ,
1776
1772
tag_def_key,
1777
1773
item_family( item_doc) )
1778
1774
}
0 commit comments