Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop mixing Result and Option with ? in inline_local_variable #7735

Merged
merged 1 commit into from
Feb 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/assists/src/handlers/inline_local_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O
usage_node.syntax().parent().and_then(ast::Expr::cast);
let usage_parent = match usage_parent_option {
Some(u) => u,
None => return Ok(false),
None => return Some(false),
};

Ok(!matches!(
Some(!matches!(
(&initializer_expr, usage_parent),
(ast::Expr::CallExpr(_), _)
| (ast::Expr::IndexExpr(_), _)
Expand All @@ -107,10 +107,10 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O
| (_, ast::Expr::MatchExpr(_))
))
})
.collect::<Result<_, _>>()
.collect::<Option<_>>()
.map(|b| (file_id, b))
})
.collect::<Result<FxHashMap<_, Vec<_>>, _>>()?;
.collect::<Option<FxHashMap<_, Vec<_>>>>()?;

let init_str = initializer_expr.syntax().text().to_string();
let init_in_paren = format!("({})", &init_str);
Expand Down