Skip to content

Commit 72d2884

Browse files
committed
refactor: don't visit expr_fn's in code action
They're not top level definitions, I added them by mistake, so removing
1 parent 253ed22 commit 72d2884

File tree

1 file changed

+0
-56
lines changed

1 file changed

+0
-56
lines changed

compiler-core/src/language_server/code_action.rs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,62 +1475,6 @@ impl<'ast> ast::visit::Visit<'ast> for AnnotateTopLevelTypeDefinitions<'_> {
14751475
);
14761476
}
14771477
}
1478-
1479-
fn visit_typed_expr_fn(
1480-
&mut self,
1481-
location: &'ast SrcSpan,
1482-
type_: &'ast Arc<Type>,
1483-
kind: &'ast FunctionLiteralKind,
1484-
arguments: &'ast [TypedArg],
1485-
body: &'ast Vec1<TypedStatement>,
1486-
return_annotation: &'ast Option<ast::TypeAst>,
1487-
) {
1488-
ast::visit::visit_typed_expr_fn(
1489-
self,
1490-
location,
1491-
type_,
1492-
kind,
1493-
arguments,
1494-
body,
1495-
return_annotation,
1496-
);
1497-
1498-
// If the function doesn't have a head, we can't annotate it
1499-
let location = match kind {
1500-
// Function captures don't need any type annotations
1501-
FunctionLiteralKind::Capture { .. } => return,
1502-
FunctionLiteralKind::Anonymous { head } => head,
1503-
FunctionLiteralKind::Use { location } => location,
1504-
};
1505-
1506-
let code_action_range = self.edits.src_span_to_lsp_range(*location);
1507-
1508-
if overlaps(code_action_range, self.params.range) {
1509-
self.is_hovering_definition = true;
1510-
}
1511-
1512-
// Annotate each argument separately
1513-
for argument in arguments.iter() {
1514-
// Don't annotate the argument if it's already annotated
1515-
if argument.annotation.is_some() {
1516-
continue;
1517-
}
1518-
1519-
self.edits.insert(
1520-
argument.location.end,
1521-
format!(": {}", self.printer.print_type(&argument.type_)),
1522-
);
1523-
}
1524-
1525-
// Annotate the return type if it isn't already annotated, and this is
1526-
// an anonymous function.
1527-
if return_annotation.is_none() && matches!(kind, FunctionLiteralKind::Anonymous { .. }) {
1528-
let return_type = &type_.return_type().expect("Type must be a function");
1529-
let pretty_type = self.printer.print_type(return_type);
1530-
self.edits
1531-
.insert(location.end, format!(" -> {pretty_type}"));
1532-
}
1533-
}
15341478
}
15351479

15361480
struct TypeVariableCollector<'a, 'b> {

0 commit comments

Comments
 (0)