mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-23 00:33:12 +00:00
Not suggest type in closure parameter
This commit is contained in:
parent
6e85d5a47e
commit
4d08b922b7
1 changed files with 5 additions and 3 deletions
|
@ -563,10 +563,10 @@ fn analyze<'db>(
|
||||||
/// Calculate the expected type and name of the cursor position.
|
/// Calculate the expected type and name of the cursor position.
|
||||||
fn expected_type_and_name<'db>(
|
fn expected_type_and_name<'db>(
|
||||||
sema: &Semantics<'db, RootDatabase>,
|
sema: &Semantics<'db, RootDatabase>,
|
||||||
token: &SyntaxToken,
|
self_token: &SyntaxToken,
|
||||||
name_like: &ast::NameLike,
|
name_like: &ast::NameLike,
|
||||||
) -> (Option<Type<'db>>, Option<NameOrNameRef>) {
|
) -> (Option<Type<'db>>, Option<NameOrNameRef>) {
|
||||||
let token = prev_special_biased_token_at_trivia(token.clone());
|
let token = prev_special_biased_token_at_trivia(self_token.clone());
|
||||||
let mut node = match token.parent() {
|
let mut node = match token.parent() {
|
||||||
Some(it) => it,
|
Some(it) => it,
|
||||||
None => return (None, None),
|
None => return (None, None),
|
||||||
|
@ -758,7 +758,9 @@ fn expected_type_and_name<'db>(
|
||||||
},
|
},
|
||||||
ast::ParamList(it) => {
|
ast::ParamList(it) => {
|
||||||
let closure = it.syntax().parent().and_then(ast::ClosureExpr::cast);
|
let closure = it.syntax().parent().and_then(ast::ClosureExpr::cast);
|
||||||
let ty = closure.and_then(|it| sema.type_of_expr(&it.into()));
|
let ty = closure
|
||||||
|
.filter(|_| it.syntax().text_range().end() <= self_token.text_range().start())
|
||||||
|
.and_then(|it| sema.type_of_expr(&it.into()));
|
||||||
ty.and_then(|ty| ty.original.as_callable(sema.db))
|
ty.and_then(|ty| ty.original.as_callable(sema.db))
|
||||||
.map(|c| (Some(c.return_type()), None))
|
.map(|c| (Some(c.return_type()), None))
|
||||||
.unwrap_or((None, None))
|
.unwrap_or((None, None))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue