mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 21:13:37 +00:00
Apply suggestion of @flodiebold: Get rid of multiple unwraps
This commit is contained in:
parent
da09f96746
commit
45021cae55
1 changed files with 10 additions and 12 deletions
|
@ -238,25 +238,23 @@ impl<'a> InferenceContext<'a> {
|
||||||
Ty::unit()
|
Ty::unit()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut has_brkctx = false;
|
let last_ty = if let Some(ctxt) = self.breakables.last() {
|
||||||
|
ctxt.break_ty.clone()
|
||||||
|
} else {
|
||||||
|
Ty::Unknown
|
||||||
|
};
|
||||||
|
|
||||||
if self.breakables.last().is_some() {
|
let merged_type = self.coerce_merge_branch(&last_ty, &val_ty);
|
||||||
has_brkctx = true;
|
|
||||||
|
if let Some(ctxt) = self.breakables.last_mut() {
|
||||||
|
ctxt.break_ty = merged_type;
|
||||||
|
ctxt.may_break = true;
|
||||||
} else {
|
} else {
|
||||||
self.push_diagnostic(InferenceDiagnostic::BreakOutsideOfLoop {
|
self.push_diagnostic(InferenceDiagnostic::BreakOutsideOfLoop {
|
||||||
expr: tgt_expr,
|
expr: tgt_expr,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if has_brkctx {
|
|
||||||
let last_ty = self.breakables.last().expect("This is a bug").break_ty.clone();
|
|
||||||
let merged_type = self.coerce_merge_branch(&last_ty, &val_ty);
|
|
||||||
|
|
||||||
let ctxt = self.breakables.last_mut().expect("This is a bug");
|
|
||||||
ctxt.may_break = true;
|
|
||||||
ctxt.break_ty = merged_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ty::simple(TypeCtor::Never)
|
Ty::simple(TypeCtor::Never)
|
||||||
}
|
}
|
||||||
Expr::Return { expr } => {
|
Expr::Return { expr } => {
|
||||||
|
|
Loading…
Reference in a new issue