diff options
Diffstat (limited to 'crates/ra_mbe')
-rw-r--r-- | crates/ra_mbe/src/mbe_expander/matcher.rs | 2 | ||||
-rw-r--r-- | crates/ra_mbe/src/parser.rs | 12 | ||||
-rw-r--r-- | crates/ra_mbe/src/subtree_source.rs | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_mbe/src/mbe_expander/matcher.rs b/crates/ra_mbe/src/mbe_expander/matcher.rs index e36b5a412..2bdea11e1 100644 --- a/crates/ra_mbe/src/mbe_expander/matcher.rs +++ b/crates/ra_mbe/src/mbe_expander/matcher.rs | |||
@@ -101,7 +101,7 @@ fn match_subtree( | |||
101 | tt::Leaf::Literal(tt::Literal { text: lhs, .. }), | 101 | tt::Leaf::Literal(tt::Literal { text: lhs, .. }), |
102 | tt::Leaf::Literal(tt::Literal { text: rhs, .. }), | 102 | tt::Leaf::Literal(tt::Literal { text: rhs, .. }), |
103 | ) if lhs == rhs => (), | 103 | ) if lhs == rhs => (), |
104 | _ => Err(ExpandError::UnexpectedToken)?, | 104 | _ => return Err(ExpandError::UnexpectedToken), |
105 | } | 105 | } |
106 | } | 106 | } |
107 | Op::TokenTree(tt::TokenTree::Subtree(lhs)) => { | 107 | Op::TokenTree(tt::TokenTree::Subtree(lhs)) => { |
diff --git a/crates/ra_mbe/src/parser.rs b/crates/ra_mbe/src/parser.rs index 50b8011a9..1cdebc216 100644 --- a/crates/ra_mbe/src/parser.rs +++ b/crates/ra_mbe/src/parser.rs | |||
@@ -100,7 +100,7 @@ fn next_op<'a>( | |||
100 | Op::Repeat { subtree, separator, kind } | 100 | Op::Repeat { subtree, separator, kind } |
101 | } | 101 | } |
102 | tt::TokenTree::Leaf(leaf) => match leaf { | 102 | tt::TokenTree::Leaf(leaf) => match leaf { |
103 | tt::Leaf::Punct(..) => Err(ExpandError::UnexpectedToken)?, | 103 | tt::Leaf::Punct(..) => return Err(ExpandError::UnexpectedToken), |
104 | tt::Leaf::Ident(ident) => { | 104 | tt::Leaf::Ident(ident) => { |
105 | let name = &ident.text; | 105 | let name = &ident.text; |
106 | let kind = eat_fragment_kind(src, mode)?; | 106 | let kind = eat_fragment_kind(src, mode)?; |
@@ -147,15 +147,15 @@ fn parse_repeat(src: &mut TtIter) -> Result<(Option<Separator>, RepeatKind), Exp | |||
147 | for tt in src { | 147 | for tt in src { |
148 | let tt = match tt { | 148 | let tt = match tt { |
149 | tt::TokenTree::Leaf(leaf) => leaf, | 149 | tt::TokenTree::Leaf(leaf) => leaf, |
150 | tt::TokenTree::Subtree(_) => Err(ExpandError::InvalidRepeat)?, | 150 | tt::TokenTree::Subtree(_) => return Err(ExpandError::InvalidRepeat), |
151 | }; | 151 | }; |
152 | let has_sep = match &separator { | 152 | let has_sep = match &separator { |
153 | Separator::Puncts(puncts) => puncts.len() != 0, | 153 | Separator::Puncts(puncts) => !puncts.is_empty(), |
154 | _ => true, | 154 | _ => true, |
155 | }; | 155 | }; |
156 | match tt { | 156 | match tt { |
157 | tt::Leaf::Ident(_) | tt::Leaf::Literal(_) if has_sep => { | 157 | tt::Leaf::Ident(_) | tt::Leaf::Literal(_) if has_sep => { |
158 | Err(ExpandError::InvalidRepeat)? | 158 | return Err(ExpandError::InvalidRepeat) |
159 | } | 159 | } |
160 | tt::Leaf::Ident(ident) => separator = Separator::Ident(ident.clone()), | 160 | tt::Leaf::Ident(ident) => separator = Separator::Ident(ident.clone()), |
161 | tt::Leaf::Literal(lit) => separator = Separator::Literal(lit.clone()), | 161 | tt::Leaf::Literal(lit) => separator = Separator::Literal(lit.clone()), |
@@ -168,11 +168,11 @@ fn parse_repeat(src: &mut TtIter) -> Result<(Option<Separator>, RepeatKind), Exp | |||
168 | match &mut separator { | 168 | match &mut separator { |
169 | Separator::Puncts(puncts) => { | 169 | Separator::Puncts(puncts) => { |
170 | if puncts.len() == 3 { | 170 | if puncts.len() == 3 { |
171 | Err(ExpandError::InvalidRepeat)? | 171 | return Err(ExpandError::InvalidRepeat); |
172 | } | 172 | } |
173 | puncts.push(punct.clone()) | 173 | puncts.push(punct.clone()) |
174 | } | 174 | } |
175 | _ => Err(ExpandError::InvalidRepeat)?, | 175 | _ => return Err(ExpandError::InvalidRepeat), |
176 | } | 176 | } |
177 | continue; | 177 | continue; |
178 | } | 178 | } |
diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs index c9f42b3dd..eb8b79e9a 100644 --- a/crates/ra_mbe/src/subtree_source.rs +++ b/crates/ra_mbe/src/subtree_source.rs | |||
@@ -124,7 +124,7 @@ fn convert_delim(d: Option<tt::DelimiterKind>, closing: bool) -> TtToken { | |||
124 | 124 | ||
125 | let idx = closing as usize; | 125 | let idx = closing as usize; |
126 | let kind = kinds[idx]; | 126 | let kind = kinds[idx]; |
127 | let text = if texts.len() > 0 { &texts[idx..texts.len() - (1 - idx)] } else { "" }; | 127 | let text = if !texts.is_empty() { &texts[idx..texts.len() - (1 - idx)] } else { "" }; |
128 | TtToken { kind, is_joint_to_next: false, text: SmolStr::new(text) } | 128 | TtToken { kind, is_joint_to_next: false, text: SmolStr::new(text) } |
129 | } | 129 | } |
130 | 130 | ||