Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate lifetime requirement on inline test_case #90

Closed
luke-biel opened this issue Mar 21, 2022 · 1 comment
Closed

Investigate lifetime requirement on inline test_case #90

luke-biel opened this issue Mar 21, 2022 · 1 comment

Comments

@luke-biel
Copy link
Collaborator

I'm using test_case in my prod code (outside of #[cfg(test)])

#[test_case(br#""abc""#, Ok(b"", TokenUnicodeString("abc".to_string())))]
fn parse_token_unicode_string<'a>(input: &'a [u8]) -> Result<(&'a [u8], TokenUnicodeString), Error> {

returns

error[E0261]: use of undeclared lifetime name `'a`
  --> crates/kami-schema/src/unicode_string.rs:11:64
   |
11 | fn parse_token_unicode_string<'a>(input: &'a [u8]) -> Result<(&'a [u8], TokenUnicodeString), Error> {
   |                                                                ^^ undeclared lifetime

and for

#[test_case(br#""abc""#, Ok(b"", TokenUnicodeString("abc".to_string())))]
fn parse_token_unicode_string(input: &[u8]) -> Result<(&[u8], TokenUnicodeString), Error> {

it prints out

error[E0106]: missing lifetime specifier
  --> crates/kami-schema/src/unicode_string.rs:11:56
   |
11 | fn parse_token_unicode_string(input: &[u8]) -> Result<(&[u8], TokenUnicodeString), Error> {
   |                                                        ^ expected named lifetime parameter
   |
   = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
   |
11 | fn parse_token_unicode_string(input: &[u8]) -> Result<(&'static [u8], TokenUnicodeString), Error> {
   |                                                        ~~~~~~~~

Without test_case() attribute it compiles. I'd expect this to work after changes made in 2.0.

@luke-biel
Copy link
Collaborator Author

My bad, forgot =>. I must be tired

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant