mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Respect coercions in inline_call
This commit is contained in:
parent
7e6f40b6f1
commit
9e1eb77f6b
5 changed files with 67 additions and 19 deletions
|
@ -492,10 +492,19 @@ pub fn where_clause(preds: impl IntoIterator<Item = ast::WherePred>) -> ast::Whe
|
|||
}
|
||||
}
|
||||
|
||||
pub fn let_stmt(pattern: ast::Pat, initializer: Option<ast::Expr>) -> ast::LetStmt {
|
||||
let text = match initializer {
|
||||
Some(it) => format!("let {} = {};", pattern, it),
|
||||
None => format!("let {};", pattern),
|
||||
pub fn let_stmt(
|
||||
pattern: ast::Pat,
|
||||
ty: Option<ast::Type>,
|
||||
initializer: Option<ast::Expr>,
|
||||
) -> ast::LetStmt {
|
||||
let mut text = String::new();
|
||||
format_to!(text, "let {}", pattern);
|
||||
if let Some(ty) = ty {
|
||||
format_to!(text, ": {}", ty);
|
||||
}
|
||||
match initializer {
|
||||
Some(it) => format_to!(text, " = {};", it),
|
||||
None => format_to!(text, ";"),
|
||||
};
|
||||
ast_from_text(&format!("fn f() {{ {} }}", text))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue