@@ -335,9 +335,9 @@ impl<'ast> Map<'ast> {
335
335
return self . opt_local_def_id ( id)
336
336
. map ( |def_id| DepNode :: Hir ( def_id) )
337
337
. unwrap_or_else ( || {
338
- panic ! ( "Walking parents from `{}` \
339
- led to `NotPresent` at `{}`",
340
- id0, id)
338
+ bug ! ( "Walking parents from `{}` \
339
+ led to `NotPresent` at `{}`",
340
+ id0, id)
341
341
} ) ,
342
342
}
343
343
}
@@ -363,8 +363,8 @@ impl<'ast> Map<'ast> {
363
363
364
364
pub fn local_def_id ( & self , node : NodeId ) -> DefId {
365
365
self . opt_local_def_id ( node) . unwrap_or_else ( || {
366
- panic ! ( "local_def_id: no entry for `{}`, which has a map of `{:?}`" ,
367
- node, self . find_entry( node) )
366
+ bug ! ( "local_def_id: no entry for `{}`, which has a map of `{:?}`" ,
367
+ node, self . find_entry( node) )
368
368
} )
369
369
}
370
370
@@ -402,7 +402,7 @@ impl<'ast> Map<'ast> {
402
402
pub fn get ( & self , id : NodeId ) -> Node < ' ast > {
403
403
match self . find ( id) {
404
404
Some ( node) => node, // read recorded by `find`
405
- None => panic ! ( "couldn't find node id {} in the AST map" , id)
405
+ None => bug ! ( "couldn't find node id {} in the AST map" , id)
406
406
}
407
407
}
408
408
@@ -576,22 +576,22 @@ impl<'ast> Map<'ast> {
576
576
self . read ( id) ; // reveals some of the content of a node
577
577
abi
578
578
}
579
- None => panic ! ( "expected foreign mod or inlined parent, found {}" ,
579
+ None => bug ! ( "expected foreign mod or inlined parent, found {}" ,
580
580
self . node_to_string( parent) )
581
581
}
582
582
}
583
583
584
584
pub fn expect_item ( & self , id : NodeId ) -> & ' ast Item {
585
585
match self . find ( id) { // read recorded by `find`
586
586
Some ( NodeItem ( item) ) => item,
587
- _ => panic ! ( "expected item, found {}" , self . node_to_string( id) )
587
+ _ => bug ! ( "expected item, found {}" , self . node_to_string( id) )
588
588
}
589
589
}
590
590
591
591
pub fn expect_trait_item ( & self , id : NodeId ) -> & ' ast TraitItem {
592
592
match self . find ( id) {
593
593
Some ( NodeTraitItem ( item) ) => item,
594
- _ => panic ! ( "expected trait item, found {}" , self . node_to_string( id) )
594
+ _ => bug ! ( "expected trait item, found {}" , self . node_to_string( id) )
595
595
}
596
596
}
597
597
@@ -600,38 +600,38 @@ impl<'ast> Map<'ast> {
600
600
Some ( NodeItem ( i) ) => {
601
601
match i. node {
602
602
ItemStruct ( ref struct_def, _) => struct_def,
603
- _ => panic ! ( "struct ID bound to non-struct" )
603
+ _ => bug ! ( "struct ID bound to non-struct" )
604
604
}
605
605
}
606
606
Some ( NodeVariant ( variant) ) => {
607
607
if variant. node . data . is_struct ( ) {
608
608
& variant. node . data
609
609
} else {
610
- panic ! ( "struct ID bound to enum variant that isn't struct-like" )
610
+ bug ! ( "struct ID bound to enum variant that isn't struct-like" )
611
611
}
612
612
}
613
- _ => panic ! ( format! ( "expected struct, found {}" , self . node_to_string( id) ) ) ,
613
+ _ => bug ! ( "expected struct, found {}" , self . node_to_string( id) ) ,
614
614
}
615
615
}
616
616
617
617
pub fn expect_variant ( & self , id : NodeId ) -> & ' ast Variant {
618
618
match self . find ( id) {
619
619
Some ( NodeVariant ( variant) ) => variant,
620
- _ => panic ! ( format! ( "expected variant, found {}" , self . node_to_string( id) ) ) ,
620
+ _ => bug ! ( "expected variant, found {}" , self . node_to_string( id) ) ,
621
621
}
622
622
}
623
623
624
624
pub fn expect_foreign_item ( & self , id : NodeId ) -> & ' ast ForeignItem {
625
625
match self . find ( id) {
626
626
Some ( NodeForeignItem ( item) ) => item,
627
- _ => panic ! ( "expected foreign item, found {}" , self . node_to_string( id) )
627
+ _ => bug ! ( "expected foreign item, found {}" , self . node_to_string( id) )
628
628
}
629
629
}
630
630
631
631
pub fn expect_expr ( & self , id : NodeId ) -> & ' ast Expr {
632
632
match self . find ( id) { // read recorded by find
633
633
Some ( NodeExpr ( expr) ) => expr,
634
- _ => panic ! ( "expected expr, found {}" , self . node_to_string( id) )
634
+ _ => bug ! ( "expected expr, found {}" , self . node_to_string( id) )
635
635
}
636
636
}
637
637
@@ -656,7 +656,7 @@ impl<'ast> Map<'ast> {
656
656
NodeLocal ( & Pat { node : PatKind :: Ident ( _, l, _) , .. } ) => {
657
657
PathName ( l. node . name )
658
658
} ,
659
- _ => panic ! ( "no path elem for {:?}" , node)
659
+ _ => bug ! ( "no path elem for {:?}" , node)
660
660
}
661
661
}
662
662
@@ -773,7 +773,7 @@ impl<'ast> Map<'ast> {
773
773
pub fn span ( & self , id : NodeId ) -> Span {
774
774
self . read ( id) ; // reveals span from node
775
775
self . opt_span ( id)
776
- . unwrap_or_else ( || panic ! ( "AstMap.span: could not find span for id {:?}" , id) )
776
+ . unwrap_or_else ( || bug ! ( "AstMap.span: could not find span for id {:?}" , id) )
777
777
}
778
778
779
779
pub fn span_if_local ( & self , id : DefId ) -> Option < Span > {
@@ -1019,12 +1019,12 @@ impl<'a> NodePrinter for pprust::State<'a> {
1019
1019
NodePat ( a) => self . print_pat ( & a) ,
1020
1020
NodeBlock ( a) => self . print_block ( & a) ,
1021
1021
NodeLifetime ( a) => self . print_lifetime ( & a) ,
1022
- NodeTyParam ( _) => panic ! ( "cannot print TyParam" ) ,
1022
+ NodeTyParam ( _) => bug ! ( "cannot print TyParam" ) ,
1023
1023
// these cases do not carry enough information in the
1024
1024
// ast_map to reconstruct their full structure for pretty
1025
1025
// printing.
1026
- NodeLocal ( _) => panic ! ( "cannot print isolated Local" ) ,
1027
- NodeStructCtor ( _) => panic ! ( "cannot print isolated StructCtor" ) ,
1026
+ NodeLocal ( _) => bug ! ( "cannot print isolated Local" ) ,
1027
+ NodeStructCtor ( _) => bug ! ( "cannot print isolated StructCtor" ) ,
1028
1028
}
1029
1029
}
1030
1030
}
0 commit comments