diff options
Diffstat (limited to 'crates/ra_mbe/src/mbe_expander.rs')
-rw-r--r-- | crates/ra_mbe/src/mbe_expander.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index 7cfb47f7a..55a6ecf58 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs | |||
@@ -105,17 +105,15 @@ impl Bindings { | |||
105 | } | 105 | } |
106 | 106 | ||
107 | fn get(&self, name: &SmolStr, nesting: &[usize]) -> Result<&tt::TokenTree, ExpandError> { | 107 | fn get(&self, name: &SmolStr, nesting: &[usize]) -> Result<&tt::TokenTree, ExpandError> { |
108 | let mut b = self | 108 | let mut b = self.inner.get(name).ok_or_else(|| { |
109 | .inner | 109 | ExpandError::BindingError(format!("could not find binding `{}`", name)) |
110 | .get(name) | 110 | })?; |
111 | .ok_or(ExpandError::BindingError(format!("could not find binding `{}`", name)))?; | ||
112 | for &idx in nesting.iter() { | 111 | for &idx in nesting.iter() { |
113 | b = match b { | 112 | b = match b { |
114 | Binding::Simple(_) => break, | 113 | Binding::Simple(_) => break, |
115 | Binding::Nested(bs) => bs.get(idx).ok_or(ExpandError::BindingError(format!( | 114 | Binding::Nested(bs) => bs.get(idx).ok_or_else(|| { |
116 | "could not find nested binding `{}`", | 115 | ExpandError::BindingError(format!("could not find nested binding `{}`", name)) |
117 | name | 116 | })?, |
118 | )))?, | ||
119 | Binding::Empty => { | 117 | Binding::Empty => { |
120 | return Err(ExpandError::BindingError(format!( | 118 | return Err(ExpandError::BindingError(format!( |
121 | "could not find empty binding `{}`", | 119 | "could not find empty binding `{}`", |