@@ -9,7 +9,7 @@ use ra_ap_hir::{Crate, Module, ModuleDef};
99use ra_ap_hir_def:: body:: { Body , BodySourceMap } ;
1010use ra_ap_hir_def:: hir:: { CaptureBy , ExprId , LabelId , MatchArm , PatId , Statement } ;
1111use ra_ap_ide_db:: line_index:: LineIndex ;
12- use ra_ap_ide_db:: { LineIndexDatabase , RootDatabase } ;
12+ use ra_ap_ide_db:: { label , LineIndexDatabase , RootDatabase } ;
1313use ra_ap_syntax:: ast:: RangeOp ;
1414use ra_ap_syntax:: { AstNode , Edition } ;
1515use ra_ap_vfs:: { FileId , Vfs } ;
@@ -137,8 +137,9 @@ impl CrateTranslator<'_> {
137137 label_id : ra_ap_hir_def:: hir:: LabelId ,
138138 source_map : & BodySourceMap ,
139139 ) -> Option < trap:: Label > {
140- let source = source_map. label_syntax ( label_id) ;
141- self . emit_location_ast_ptr ( source)
140+ // 'catch' a panic if the source map is incomplete
141+ let source = std:: panic:: catch_unwind ( || source_map. label_syntax ( label_id) ) . ok ( ) ;
142+ source. and_then ( |source| self . emit_location_ast_ptr ( source) )
142143 }
143144 fn emit_location < T : HasSource > ( & mut self , entity : T ) -> Option < trap:: Label >
144145 where
0 commit comments