|
105 | 105 | //! stored when entering a macro definition starting from the state in which the meta-variable is |
106 | 106 | //! bound. |
107 | 107 |
|
108 | | -use std::iter; |
109 | | - |
110 | 108 | use rustc_ast::token::{Delimiter, IdentIsRaw, Token, TokenKind}; |
111 | 109 | use rustc_ast::{DUMMY_NODE_ID, NodeId}; |
112 | 110 | use rustc_data_structures::fx::FxHashMap; |
@@ -190,29 +188,22 @@ struct MacroState<'a> { |
190 | 188 | ops: SmallVec<[KleeneToken; 1]>, |
191 | 189 | } |
192 | 190 |
|
193 | | -/// Checks that meta-variables are used correctly in a macro definition. |
| 191 | +/// Checks that meta-variables are used correctly in one rule of a macro definition. |
194 | 192 | /// |
195 | 193 | /// Arguments: |
196 | 194 | /// - `psess` is used to emit diagnostics and lints |
197 | 195 | /// - `node_id` is used to emit lints |
198 | | -/// - `span` is used when no spans are available |
199 | | -/// - `lhses` and `rhses` should have the same length and represent the macro definition |
| 196 | +/// - `lhs` and `rhs` represent the rule |
200 | 197 | pub(super) fn check_meta_variables( |
201 | 198 | psess: &ParseSess, |
202 | 199 | node_id: NodeId, |
203 | | - span: Span, |
204 | | - lhses: &[TokenTree], |
205 | | - rhses: &[TokenTree], |
| 200 | + lhs: &TokenTree, |
| 201 | + rhs: &TokenTree, |
206 | 202 | ) -> Result<(), ErrorGuaranteed> { |
207 | | - if lhses.len() != rhses.len() { |
208 | | - psess.dcx().span_bug(span, "length mismatch between LHSes and RHSes") |
209 | | - } |
210 | 203 | let mut guar = None; |
211 | | - for (lhs, rhs) in iter::zip(lhses, rhses) { |
212 | | - let mut binders = Binders::default(); |
213 | | - check_binders(psess, node_id, lhs, &Stack::Empty, &mut binders, &Stack::Empty, &mut guar); |
214 | | - check_occurrences(psess, node_id, rhs, &Stack::Empty, &binders, &Stack::Empty, &mut guar); |
215 | | - } |
| 204 | + let mut binders = Binders::default(); |
| 205 | + check_binders(psess, node_id, lhs, &Stack::Empty, &mut binders, &Stack::Empty, &mut guar); |
| 206 | + check_occurrences(psess, node_id, rhs, &Stack::Empty, &binders, &Stack::Empty, &mut guar); |
216 | 207 | guar.map_or(Ok(()), Err) |
217 | 208 | } |
218 | 209 |
|
|
0 commit comments