diff --git a/lrpar/cttests/src/lib.rs b/lrpar/cttests/src/lib.rs index aabd61d3d..34f9c8be9 100644 --- a/lrpar/cttests/src/lib.rs +++ b/lrpar/cttests/src/lib.rs @@ -34,6 +34,9 @@ lrpar_mod!("multitypes.y"); lrlex_mod!("parseparam.l"); lrpar_mod!("parseparam.y"); +lrlex_mod!("parseparam_copy.l"); +lrpar_mod!("parseparam_copy.y"); + lrlex_mod!("passthrough.l"); lrpar_mod!("passthrough.y"); @@ -247,6 +250,16 @@ fn test_parseparam() { } } +#[test] +fn test_parseparam_copy() { + let lexerdef = parseparam_copy_l::lexerdef(); + let lexer = lexerdef.lexer("101"); + match parseparam_copy_y::parse(&lexer, 3) { + (Some(104), _) => (), + _ => unreachable!(), + } +} + #[test] fn test_passthrough() { let lexerdef = passthrough_l::lexerdef(); diff --git a/lrpar/cttests/src/parseparam_copy.test b/lrpar/cttests/src/parseparam_copy.test new file mode 100644 index 000000000..ecf3b9648 --- /dev/null +++ b/lrpar/cttests/src/parseparam_copy.test @@ -0,0 +1,18 @@ +name: Test %parse-param copy +yacckind: Grmtools +grammar: | + %start S + %parse-param p: u64 + %% + S -> u64: + // Previously %parse-param required a `Copy` bounds. + // Since then we relaxed the bounds to require `Clone`. + // This tests backwards compatibility of actions that + // rely on the older copy bounds. + 'INT' { (move |_| {})(p); check_copy(p); p + $lexer.span_str($1.unwrap().span()).parse::().unwrap() } + ; + %% + fn check_copy(_: T){} +lexer: | + %% + [0-9]+ 'INT'