Skip to content

Commit 7f8bb7e

Browse files
committed
Apply clippy fixes
1 parent 90537f9 commit 7f8bb7e

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

rust/extractor/src/translate.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ impl CrateTranslator<'_> {
7575
) where
7676
T: AstNode,
7777
{
78-
source
78+
if let Some(data) = source
7979
.file_id
8080
.file_id()
8181
.map(|f| f.file_id())
8282
.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+
}
8787
}
8888

8989
fn emit_location_for_expr(
@@ -113,7 +113,7 @@ impl CrateTranslator<'_> {
113113
pat: &ra_ap_hir_def::hir::LiteralOrConst,
114114
body: &Body,
115115
source_map: &BodySourceMap,
116-
mut emit_location: impl FnMut(&mut CrateTranslator<'_>, trap::Label) -> (),
116+
mut emit_location: impl FnMut(&mut CrateTranslator<'_>, trap::Label),
117117
) -> trap::Label {
118118
match pat {
119119
ra_ap_hir_def::hir::LiteralOrConst::Literal(_literal) => {
@@ -147,14 +147,14 @@ impl CrateTranslator<'_> {
147147
where
148148
T::Ast: AstNode,
149149
{
150-
entity
150+
if let Some((data, source)) = entity
151151
.source(self.db)
152152
.and_then(|source| source.file_id.file_id().map(|f| (f.file_id(), source)))
153153
.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+
}
158158
}
159159
fn emit_location_for_textrange(
160160
&mut self,
@@ -260,7 +260,9 @@ impl CrateTranslator<'_> {
260260
ellipsis,
261261
} => {
262262
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+
}
264266
let flds = args
265267
.into_iter()
266268
.map(|arg| self.emit_record_field_pat(arg, body, source_map))
@@ -340,7 +342,9 @@ impl CrateTranslator<'_> {
340342
ellipsis,
341343
} => {
342344
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+
}
344348

345349
let args = args
346350
.into_iter()
@@ -666,7 +670,9 @@ impl CrateTranslator<'_> {
666670
is_assignee_expr,
667671
} => {
668672
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+
}
670676

671677
let flds = fields
672678
.into_iter()

0 commit comments

Comments
 (0)