diff options
author | Alan Du <[email protected]> | 2019-06-03 15:27:51 +0100 |
---|---|---|
committer | Alan Du <[email protected]> | 2019-06-04 23:05:07 +0100 |
commit | b28ca32db22d5e2ed34db556c6fd50a5fc2d679c (patch) | |
tree | 7e86e3f6ffdbc972b2ac968503f2b3671fd9b3a5 /crates/ra_mbe/src | |
parent | 40424d4222d4630bc53294d10f1718f2d3d300de (diff) |
Fix clippy::or_fun_call
Diffstat (limited to 'crates/ra_mbe/src')
-rw-r--r-- | crates/ra_mbe/src/mbe_expander.rs | 14 | ||||
-rw-r--r-- | crates/ra_mbe/src/mbe_parser.rs | 4 |
2 files changed, 8 insertions, 10 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 `{}`", |
diff --git a/crates/ra_mbe/src/mbe_parser.rs b/crates/ra_mbe/src/mbe_parser.rs index d8fe293c7..dca16b537 100644 --- a/crates/ra_mbe/src/mbe_parser.rs +++ b/crates/ra_mbe/src/mbe_parser.rs | |||
@@ -125,8 +125,8 @@ fn parse_repeat(p: &mut TtCursor, transcriber: bool) -> Result<crate::Repeat, Pa | |||
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | let sep = p.eat_seperator().ok_or(ParseError::Expected(String::from("separator")))?; | 128 | let sep = p.eat_seperator().ok_or_else(|| ParseError::Expected(String::from("separator")))?; |
129 | let rep = p.eat_punct().ok_or(ParseError::Expected(String::from("repeat")))?; | 129 | let rep = p.eat_punct().ok_or_else(|| ParseError::Expected(String::from("repeat")))?; |
130 | 130 | ||
131 | mk_repeat(rep.char, subtree, Some(sep)) | 131 | mk_repeat(rep.char, subtree, Some(sep)) |
132 | } | 132 | } |