diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_mbe/src/mbe_expander/transcriber.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/crates/ra_mbe/src/mbe_expander/transcriber.rs b/crates/ra_mbe/src/mbe_expander/transcriber.rs index 8bb1a25a3..7662020f3 100644 --- a/crates/ra_mbe/src/mbe_expander/transcriber.rs +++ b/crates/ra_mbe/src/mbe_expander/transcriber.rs | |||
@@ -18,16 +18,16 @@ impl Bindings { | |||
18 | let mut b = self.inner.get(name).ok_or_else(|| { | 18 | let mut b = self.inner.get(name).ok_or_else(|| { |
19 | ExpandError::BindingError(format!("could not find binding `{}`", name)) | 19 | ExpandError::BindingError(format!("could not find binding `{}`", name)) |
20 | })?; | 20 | })?; |
21 | for s in nesting.iter_mut() { | 21 | for nesting_state in nesting.iter_mut() { |
22 | s.hit = true; | 22 | nesting_state.hit = true; |
23 | b = match b { | 23 | b = match b { |
24 | Binding::Fragment(_) => break, | 24 | Binding::Fragment(_) => break, |
25 | Binding::Nested(bs) => bs.get(s.idx).ok_or_else(|| { | 25 | Binding::Nested(bs) => bs.get(nesting_state.idx).ok_or_else(|| { |
26 | s.at_end = true; | 26 | nesting_state.at_end = true; |
27 | ExpandError::BindingError(format!("could not find nested binding `{}`", name)) | 27 | ExpandError::BindingError(format!("could not find nested binding `{}`", name)) |
28 | })?, | 28 | })?, |
29 | Binding::Empty => { | 29 | Binding::Empty => { |
30 | s.at_end = true; | 30 | nesting_state.at_end = true; |
31 | return Err(ExpandError::BindingError(format!( | 31 | return Err(ExpandError::BindingError(format!( |
32 | "could not find empty binding `{}`", | 32 | "could not find empty binding `{}`", |
33 | name | 33 | name |
@@ -61,7 +61,11 @@ pub(super) fn transcribe( | |||
61 | #[derive(Debug)] | 61 | #[derive(Debug)] |
62 | struct NestingState { | 62 | struct NestingState { |
63 | idx: usize, | 63 | idx: usize, |
64 | /// `hit` is currently necessary to tell `expand_repeat` if it should stop | ||
65 | /// because there is no variable in use by the current repetition | ||
64 | hit: bool, | 66 | hit: bool, |
67 | /// `at_end` is currently necessary to tell `expand_repeat` if it should stop | ||
68 | /// because there is no more value avaible for the current repetition | ||
65 | at_end: bool, | 69 | at_end: bool, |
66 | } | 70 | } |
67 | 71 | ||
@@ -130,8 +134,7 @@ fn expand_var(ctx: &mut ExpandCtx, v: &SmolStr) -> Result<Fragment, ExpandError> | |||
130 | .into(); | 134 | .into(); |
131 | Fragment::Tokens(tt) | 135 | Fragment::Tokens(tt) |
132 | } else { | 136 | } else { |
133 | let fragment = ctx.bindings.get(&v, &mut ctx.nesting)?.clone(); | 137 | ctx.bindings.get(&v, &mut ctx.nesting)?.clone() |
134 | fragment | ||
135 | }; | 138 | }; |
136 | Ok(res) | 139 | Ok(res) |
137 | } | 140 | } |