Skip to content

Commit 9701e59

Browse files
bors[bot]matklad
andauthored
Merge #3124
3124: Simplify r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 5bf6698 + 6ec982d commit 9701e59

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

crates/ra_ide/src/goto_type_definition.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,16 @@ pub(crate) fn goto_type_definition(
1616
let token = pick_best(file.token_at_offset(position.offset))?;
1717
let token = descend_into_macros(db, position.file_id, token);
1818

19-
let node = token.value.ancestors().find_map(|token| {
20-
token
21-
.ancestors()
22-
.find(|n| ast::Expr::cast(n.clone()).is_some() || ast::Pat::cast(n.clone()).is_some())
23-
})?;
19+
let node = token
20+
.value
21+
.ancestors()
22+
.find(|n| ast::Expr::cast(n.clone()).is_some() || ast::Pat::cast(n.clone()).is_some())?;
2423

2524
let analyzer = hir::SourceAnalyzer::new(db, token.with_value(&node), None);
2625

27-
let ty: hir::Type = if let Some(ty) =
28-
ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e))
29-
{
30-
ty
31-
} else if let Some(ty) = ast::Pat::cast(node.clone()).and_then(|p| analyzer.type_of_pat(db, &p))
32-
{
33-
ty
34-
} else {
35-
return None;
36-
};
26+
let ty: hir::Type = ast::Expr::cast(node.clone())
27+
.and_then(|e| analyzer.type_of(db, &e))
28+
.or_else(|| ast::Pat::cast(node.clone()).and_then(|p| analyzer.type_of_pat(db, &p)))?;
3729

3830
let adt_def = ty.autoderef(db).find_map(|ty| ty.as_adt())?;
3931

0 commit comments

Comments
 (0)