From a9555d2ed0df9d3c3c4885a7ec547c5e897f69ae Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Tue, 20 Jan 2026 09:00:25 +0000 Subject: [PATCH] Pass `LexerKind` by reference. At the moment the code happens to work only because of an oversight in rustc: that oversight is likely to be fixed soon (https://github.com/rust-lang/rust/pull/150681). --- lrlex/src/lib/ctbuilder.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lrlex/src/lib/ctbuilder.rs b/lrlex/src/lib/ctbuilder.rs index 63c74066e..788ca782d 100644 --- a/lrlex/src/lib/ctbuilder.rs +++ b/lrlex/src/lib/ctbuilder.rs @@ -248,7 +248,7 @@ where show_warnings: bool, header: Header, #[cfg(test)] - inspect_lexerkind_cb: Option Result<(), Box>>>, + inspect_lexerkind_cb: Option Result<(), Box>>>, } impl CTLexerBuilder<'_, DefaultLexerTypes> { @@ -509,7 +509,7 @@ where }; #[cfg(test)] if let Some(inspect_lexerkind_cb) = self.inspect_lexerkind_cb { - inspect_lexerkind_cb(lexerkind)? + inspect_lexerkind_cb(&lexerkind)? } let (lexerdef, lex_flags): (LRNonStreamingLexerDef, LexFlags) = match lexerkind { @@ -1211,7 +1211,7 @@ where #[cfg(test)] pub fn inspect_lexerkind( mut self, - cb: Box Result<(), Box>>, + cb: Box Result<(), Box>>, ) -> Self { self.inspect_lexerkind_cb = Some(cb); self @@ -1481,7 +1481,7 @@ mod test { .output_path(format!("{}.rs", lex_path.clone())) .lexer_path(lex_path.clone()) .inspect_lexerkind(Box::new(move |lexerkind| { - assert!(matches!(lexerkind, LexerKind::LRNonStreamingLexer)); + assert!(matches!(lexerkind, &LexerKind::LRNonStreamingLexer)); Ok(()) })) .build()