Open
Description
I tried this code:
#[mockall::automock]
trait Bar {
fn foo(&self, value: Box<String>);
}
fn main() {
let mut mock_bar = MockBar::default();
mock_bar.expect_foo().with(mockall::predicate::function(|value: &Box<String>| **value == ""));
}
I expected clippy to give no warnings
Instead, this happened:
warning: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> src\main.rs:8:69
|
8 | mock_bar.expect_foo().with(mockall::predicate::function(|value: &Box<String>| **value == ""));
| ^^^^^^^^^^^^ help: try: `&String`
|
= note: `#[warn(clippy::borrowed_box)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrowed_box
The Mockall library predicate uses &T where T is the type of a function's parameter. In this case T is Box so the type in the predicate's closure is forced to be &Box and can't be change to &String.
Meta
cargo clippy -V
: clippy 0.0.212 (bb37a0f 2020-06-16)rustc -Vv
:
rustc 1.44.1 (c7087fe00 2020-06-17)
binary: rustc
commit-hash: c7087fe00d2ba919df1d813c040a5d47e43b0fe7
commit-date: 2020-06-17
host: x86_64-pc-windows-msvc
release: 1.44.1
LLVM version: 9.0