diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-31 13:03:24 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-31 13:03:24 +0100 |
commit | 5579ba8af5a31591a16b8f0f43053f73d07fb8b8 (patch) | |
tree | 2a0f7e55e01edc9edb2c49c3a94d07da172b1b40 /crates/ra_hir_ty/src/infer.rs | |
parent | d7071eae2cb78547b8345d4c6ba2731a5151c049 (diff) | |
parent | cc6ba84c400417af873462364ba5cd4f6b5ab1f6 (diff) |
Merge #4667
4667: Infer labelled breaks correctly r=flodiebold a=robojumper
Fixes #4663.
Co-authored-by: robojumper <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/infer.rs')
-rw-r--r-- | crates/ra_hir_ty/src/infer.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index 957d6e0b5..dc77e88e5 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs | |||
@@ -219,6 +219,17 @@ struct InferenceContext<'a> { | |||
219 | struct BreakableContext { | 219 | struct BreakableContext { |
220 | pub may_break: bool, | 220 | pub may_break: bool, |
221 | pub break_ty: Ty, | 221 | pub break_ty: Ty, |
222 | pub label: Option<name::Name>, | ||
223 | } | ||
224 | |||
225 | fn find_breakable<'c>( | ||
226 | ctxs: &'c mut [BreakableContext], | ||
227 | label: Option<&name::Name>, | ||
228 | ) -> Option<&'c mut BreakableContext> { | ||
229 | match label { | ||
230 | Some(_) => ctxs.iter_mut().rev().find(|ctx| ctx.label.as_ref() == label), | ||
231 | None => ctxs.last_mut(), | ||
232 | } | ||
222 | } | 233 | } |
223 | 234 | ||
224 | impl<'a> InferenceContext<'a> { | 235 | impl<'a> InferenceContext<'a> { |