fix: better handling of SelfParam in inline_call

This commit is contained in:
roife 2024-01-17 13:49:07 +08:00
parent 7c94c29648
commit d48498f360
2 changed files with 49 additions and 6 deletions

View file

@ -595,6 +595,9 @@ pub fn expr_macro_call(f: ast::Expr, arg_list: ast::ArgList) -> ast::Expr {
pub fn expr_ref(expr: ast::Expr, exclusive: bool) -> ast::Expr {
expr_from_text(&if exclusive { format!("&mut {expr}") } else { format!("&{expr}") })
}
pub fn expr_reborrow(expr: ast::Expr) -> ast::Expr {
expr_from_text(&format!("&mut *{expr}"))
}
pub fn expr_closure(pats: impl IntoIterator<Item = ast::Param>, expr: ast::Expr) -> ast::Expr {
let params = pats.into_iter().join(", ");
expr_from_text(&format!("|{params}| {expr}"))