]> git.lizzy.rs Git - rust.git/commitdiff
Cleanup
authorAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 19 May 2020 19:40:47 +0000 (21:40 +0200)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 19 May 2020 23:23:05 +0000 (01:23 +0200)
crates/ra_assists/src/handlers/add_explicit_type.rs

index 0c7d5e355f7952f2490586399ebf9a62755aacbd..770049212d29d19d50e7e4339306a9996bf08391 100644 (file)
@@ -25,9 +25,8 @@ pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Optio
     let stmt = ctx.find_node_at_offset::<LetStmt>()?;
     let module = ctx.sema.scope(stmt.syntax()).module()?;
     let expr = stmt.initializer()?;
-    let pat = stmt.pat()?;
     // Must be a binding
-    let pat = match pat {
+    let pat = match stmt.pat()? {
         ast::Pat::BindPat(bind_pat) => bind_pat,
         _ => return None,
     };
@@ -46,7 +45,7 @@ pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Optio
     // Assist not applicable if the type has already been specified
     // and it has no placeholders
     let ascribed_ty = stmt.ascribed_type();
-    if let Some(ref ty) = ascribed_ty {
+    if let Some(ty) = &ascribed_ty {
         if ty.syntax().descendants().find_map(ast::PlaceholderType::cast).is_none() {
             return None;
         }