Qualify paths in 'fill match arms' assist

This commit is contained in:
Florian Diebold 2020-01-10 21:42:04 +01:00
parent 86d2af9f7b
commit 2c11a9b42d
3 changed files with 55 additions and 19 deletions

View file

@ -117,10 +117,11 @@ pub fn record_pat(path: ast::Path, pats: impl IntoIterator<Item = ast::Pat>) ->
}
}
pub fn path_pat(path: ast::Path) -> ast::PathPat {
/// Returns a `BindPat` if the path has just one segment, a `PathPat` otherwise.
pub fn path_pat(path: ast::Path) -> ast::Pat {
let path_str = path.syntax().text().to_string();
return from_text(path_str.as_str());
fn from_text(text: &str) -> ast::PathPat {
fn from_text(text: &str) -> ast::Pat {
ast_from_text(&format!("fn f({}: ())", text))
}
}