@@ -210,18 +210,18 @@ fn trace_macros_note(cx_expansions: &mut FxIndexMap<Span, Vec<String>>, sp: Span
210210}
211211
212212pub ( super ) trait Tracker < ' matcher > {
213- /// This is called before trying to match next MatcherLoc on the current token
213+ /// This is called before trying to match next MatcherLoc on the current token.
214214 fn before_match_loc ( & mut self , parser : & TtParser , matcher : & ' matcher MatcherLoc ) ;
215215
216216 /// This is called after an arm has been parsed, either successfully or unsuccessfully. When this is called,
217- /// `before_match_loc` was called at least once (with a `MatcherLoc::Eof`)
217+ /// `before_match_loc` was called at least once (with a `MatcherLoc::Eof`).
218218 fn after_arm ( & mut self , result : & NamedParseResult ) ;
219219
220- /// For tracing
220+ /// For tracing.
221221 fn description ( ) -> & ' static str ;
222222}
223223
224- /// A noop tracker that is used in the hot path of the expansion, has zero overhead thanks to monomorphization
224+ /// A noop tracker that is used in the hot path of the expansion, has zero overhead thanks to monomorphization.
225225struct NoopTracker ;
226226
227227impl < ' matcher > Tracker < ' matcher > for NoopTracker {
@@ -256,7 +256,7 @@ fn expand_macro<'cx>(
256256 trace_macros_note ( & mut cx. expansions , sp, msg) ;
257257 }
258258
259- // Track nothing for the best performance
259+ // Track nothing for the best performance.
260260 let try_success_result = try_match_macro ( sess, name, & arg, lhses, & mut NoopTracker ) ;
261261
262262 match try_success_result {
@@ -326,7 +326,7 @@ fn expand_macro<'cx>(
326326 }
327327 }
328328
329- // An error occured , try the expansion again, tracking the expansion closely for better diagnostics
329+ // An error occurred , try the expansion again, tracking the expansion closely for better diagnostics.
330330 let mut tracker = CollectTrackerAndEmitter :: new ( cx, sp) ;
331331
332332 let try_success_result = try_match_macro ( sess, name, & arg, lhses, & mut tracker) ;
@@ -378,7 +378,7 @@ fn expand_macro<'cx>(
378378 DummyResult :: any ( sp)
379379}
380380
381- /// The tracker used for the slow error path that collects useful info for diagnostics
381+ /// The tracker used for the slow error path that collects useful info for diagnostics.
382382struct CollectTrackerAndEmitter < ' a , ' cx > {
383383 cx : & ' a mut ExtCtxt < ' cx > ,
384384 /// Which arm's failure should we report? (the one furthest along)
@@ -427,7 +427,7 @@ enum CanRetry {
427427 No ( ErrorGuaranteed ) ,
428428}
429429
430- /// Try expanding the macro. Returns the index of the sucessful arm and its named_matches if it was successful,
430+ /// Try expanding the macro. Returns the index of the successful arm and its named_matches if it was successful,
431431/// and nothing if it failed. On failure, it's the callers job to use `track` accordingly to record all errors
432432/// correctly.
433433#[ instrument( level = "debug" , skip( sess, arg, lhses, track) , fields( tracking = %T :: description( ) ) ) ]
@@ -485,15 +485,16 @@ fn try_match_macro<'matcher, T: Tracker<'matcher>>(
485485 }
486486 Failure ( _, _) => {
487487 trace ! ( "Failed to match arm, trying the next one" ) ;
488- // Try the next arm
488+ // Try the next arm.
489489 }
490490 Error ( _, _) => {
491491 debug ! ( "Fatal error occurred during matching" ) ;
492- // We haven't emitted an error yet
492+ // We haven't emitted an error yet, so we can retry.
493493 return Err ( CanRetry :: Yes ) ;
494494 }
495495 ErrorReported ( guarantee) => {
496496 debug ! ( "Fatal error occurred and was reported during matching" ) ;
497+ // An error has been reported already, we cannot retry as that would cause duplicate errors.
497498 return Err ( CanRetry :: No ( guarantee) ) ;
498499 }
499500 }
0 commit comments