@@ -335,9 +335,9 @@ impl<'ast> Map<'ast> {
335335 return self . opt_local_def_id ( id)
336336 . map ( |def_id| DepNode :: Hir ( def_id) )
337337 . 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)
341341 } ) ,
342342 }
343343 }
@@ -363,8 +363,8 @@ impl<'ast> Map<'ast> {
363363
364364 pub fn local_def_id ( & self , node : NodeId ) -> DefId {
365365 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) )
368368 } )
369369 }
370370
@@ -402,7 +402,7 @@ impl<'ast> Map<'ast> {
402402 pub fn get ( & self , id : NodeId ) -> Node < ' ast > {
403403 match self . find ( id) {
404404 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)
406406 }
407407 }
408408
@@ -576,22 +576,22 @@ impl<'ast> Map<'ast> {
576576 self . read ( id) ; // reveals some of the content of a node
577577 abi
578578 }
579- None => panic ! ( "expected foreign mod or inlined parent, found {}" ,
579+ None => bug ! ( "expected foreign mod or inlined parent, found {}" ,
580580 self . node_to_string( parent) )
581581 }
582582 }
583583
584584 pub fn expect_item ( & self , id : NodeId ) -> & ' ast Item {
585585 match self . find ( id) { // read recorded by `find`
586586 Some ( NodeItem ( item) ) => item,
587- _ => panic ! ( "expected item, found {}" , self . node_to_string( id) )
587+ _ => bug ! ( "expected item, found {}" , self . node_to_string( id) )
588588 }
589589 }
590590
591591 pub fn expect_trait_item ( & self , id : NodeId ) -> & ' ast TraitItem {
592592 match self . find ( id) {
593593 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) )
595595 }
596596 }
597597
@@ -600,38 +600,38 @@ impl<'ast> Map<'ast> {
600600 Some ( NodeItem ( i) ) => {
601601 match i. node {
602602 ItemStruct ( ref struct_def, _) => struct_def,
603- _ => panic ! ( "struct ID bound to non-struct" )
603+ _ => bug ! ( "struct ID bound to non-struct" )
604604 }
605605 }
606606 Some ( NodeVariant ( variant) ) => {
607607 if variant. node . data . is_struct ( ) {
608608 & variant. node . data
609609 } 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" )
611611 }
612612 }
613- _ => panic ! ( format! ( "expected struct, found {}" , self . node_to_string( id) ) ) ,
613+ _ => bug ! ( "expected struct, found {}" , self . node_to_string( id) ) ,
614614 }
615615 }
616616
617617 pub fn expect_variant ( & self , id : NodeId ) -> & ' ast Variant {
618618 match self . find ( id) {
619619 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) ) ,
621621 }
622622 }
623623
624624 pub fn expect_foreign_item ( & self , id : NodeId ) -> & ' ast ForeignItem {
625625 match self . find ( id) {
626626 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) )
628628 }
629629 }
630630
631631 pub fn expect_expr ( & self , id : NodeId ) -> & ' ast Expr {
632632 match self . find ( id) { // read recorded by find
633633 Some ( NodeExpr ( expr) ) => expr,
634- _ => panic ! ( "expected expr, found {}" , self . node_to_string( id) )
634+ _ => bug ! ( "expected expr, found {}" , self . node_to_string( id) )
635635 }
636636 }
637637
@@ -656,7 +656,7 @@ impl<'ast> Map<'ast> {
656656 NodeLocal ( & Pat { node : PatKind :: Ident ( _, l, _) , .. } ) => {
657657 PathName ( l. node . name )
658658 } ,
659- _ => panic ! ( "no path elem for {:?}" , node)
659+ _ => bug ! ( "no path elem for {:?}" , node)
660660 }
661661 }
662662
@@ -773,7 +773,7 @@ impl<'ast> Map<'ast> {
773773 pub fn span ( & self , id : NodeId ) -> Span {
774774 self . read ( id) ; // reveals span from node
775775 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) )
777777 }
778778
779779 pub fn span_if_local ( & self , id : DefId ) -> Option < Span > {
@@ -1019,12 +1019,12 @@ impl<'a> NodePrinter for pprust::State<'a> {
10191019 NodePat ( a) => self . print_pat ( & a) ,
10201020 NodeBlock ( a) => self . print_block ( & a) ,
10211021 NodeLifetime ( a) => self . print_lifetime ( & a) ,
1022- NodeTyParam ( _) => panic ! ( "cannot print TyParam" ) ,
1022+ NodeTyParam ( _) => bug ! ( "cannot print TyParam" ) ,
10231023 // these cases do not carry enough information in the
10241024 // ast_map to reconstruct their full structure for pretty
10251025 // 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" ) ,
10281028 }
10291029 }
10301030}
0 commit comments