@@ -75,15 +75,15 @@ impl CrateTranslator<'_> {
75
75
) where
76
76
T : AstNode ,
77
77
{
78
- source
78
+ if let Some ( data ) = source
79
79
. file_id
80
80
. file_id ( )
81
81
. map ( |f| f. file_id ( ) )
82
82
. and_then ( |file_id| self . emit_file ( file_id) )
83
- . map ( |data| {
84
- let range = source. value . text_range ( ) ;
85
- self . emit_location_for_textrange ( label, data, range)
86
- } ) ;
83
+ {
84
+ let range = source. value . text_range ( ) ;
85
+ self . emit_location_for_textrange ( label, data, range)
86
+ }
87
87
}
88
88
89
89
fn emit_location_for_expr (
@@ -113,7 +113,7 @@ impl CrateTranslator<'_> {
113
113
pat : & ra_ap_hir_def:: hir:: LiteralOrConst ,
114
114
body : & Body ,
115
115
source_map : & BodySourceMap ,
116
- mut emit_location : impl FnMut ( & mut CrateTranslator < ' _ > , trap:: Label ) -> ( ) ,
116
+ mut emit_location : impl FnMut ( & mut CrateTranslator < ' _ > , trap:: Label ) ,
117
117
) -> trap:: Label {
118
118
match pat {
119
119
ra_ap_hir_def:: hir:: LiteralOrConst :: Literal ( _literal) => {
@@ -147,14 +147,14 @@ impl CrateTranslator<'_> {
147
147
where
148
148
T :: Ast : AstNode ,
149
149
{
150
- entity
150
+ if let Some ( ( data , source ) ) = entity
151
151
. source ( self . db )
152
152
. and_then ( |source| source. file_id . file_id ( ) . map ( |f| ( f. file_id ( ) , source) ) )
153
153
. and_then ( |( file_id, source) | self . emit_file ( file_id) . map ( |data| ( data, source) ) )
154
- . map ( | ( data , source ) | {
155
- let range = source. value . syntax ( ) . text_range ( ) ;
156
- self . emit_location_for_textrange ( label, data, range) ;
157
- } ) ;
154
+ {
155
+ let range = source. value . syntax ( ) . text_range ( ) ;
156
+ self . emit_location_for_textrange ( label, data, range) ;
157
+ }
158
158
}
159
159
fn emit_location_for_textrange (
160
160
& mut self ,
@@ -260,7 +260,9 @@ impl CrateTranslator<'_> {
260
260
ellipsis,
261
261
} => {
262
262
let path = path. as_ref ( ) . map ( |path| self . emit_path ( path) ) ;
263
- path. map ( |p| self . emit_location_for_pat ( p, pat_id, source_map) ) ;
263
+ if let Some ( p) = path {
264
+ self . emit_location_for_pat ( p, pat_id, source_map)
265
+ }
264
266
let flds = args
265
267
. into_iter ( )
266
268
. map ( |arg| self . emit_record_field_pat ( arg, body, source_map) )
@@ -340,7 +342,9 @@ impl CrateTranslator<'_> {
340
342
ellipsis,
341
343
} => {
342
344
let path = path. as_ref ( ) . map ( |path| self . emit_path ( path) ) ;
343
- path. map ( |p| self . emit_location_for_pat ( p, pat_id, source_map) ) ;
345
+ if let Some ( p) = path {
346
+ self . emit_location_for_pat ( p, pat_id, source_map)
347
+ }
344
348
345
349
let args = args
346
350
. into_iter ( )
@@ -666,7 +670,9 @@ impl CrateTranslator<'_> {
666
670
is_assignee_expr,
667
671
} => {
668
672
let path = path. as_ref ( ) . map ( |path| self . emit_path ( path) ) ;
669
- path. map ( |p| self . emit_location_for_expr ( p, expr_id, source_map) ) ;
673
+ if let Some ( p) = path {
674
+ self . emit_location_for_expr ( p, expr_id, source_map)
675
+ }
670
676
671
677
let flds = fields
672
678
. into_iter ( )
0 commit comments