parameterized icon indicating copy to clipboard operation
parameterized copied to clipboard

unused import for function used in `#[parametrized]`

Open h1alexbel opened this issue 1 year ago • 7 comments

Consider this example:

fn foo(s: &str) -> String { format!("foo: {}", s) };

#[cfg(test)]
mod tests {
  
  #[allow(unused_imports)]
  // required for usage in #parametrized.
  use crate::foo::foo;
  use anyhow::Result;

   #[parameterized(
        input = {
            &foo("foo"),
            &foo("bar")
        }
      )
    ]
  fn checks_foo(input: &str) -> Result<()> {
    // some assertion
    Ok(())
  }
}

Here, #[parametrized] obviously uses foo in order to prepare input. However, import of foo function is treated as unused. I do understand that #[parametrized] generates code for test, but is it possible to signal that import is used? Current behaviour confuses me. Please fix this

h1alexbel avatar Sep 25 '24 13:09 h1alexbel