Skip to content

Commit

Permalink
Suppress the clippy::ref_option warning in generated code (#618)
Browse files Browse the repository at this point in the history
Fixes #617
  • Loading branch information
asomers authored Nov 6, 2024
1 parent d5b3b46 commit e1ac2e1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- Suppress the `#[clippy::ref_option]` warning, new in Rust 1.83.0, in
generated code.
([#618](https://github.com/asomers/mockall/pull/618))

- When mocking functions with a closure argument, but not using
`#[concretize]`, include any additional trait bounds in the trait object
argument passed to `.with` and `.returning.
Expand Down
7 changes: 7 additions & 0 deletions mockall/tests/ref_option.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//! Mockall should suppress clippy::ref_option warnings in generated code.
#![warn(clippy::ref_option)]

#[mockall::automock]
pub trait Store {
fn find(&self, name: Option<String>) -> bool;
}
3 changes: 3 additions & 0 deletions mockall_derive/src/mock_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,7 @@ impl ToTokens for Common<'_> {
}

#[allow(clippy::ptr_arg)]
#[allow(clippy::ref_option)]
fn matches #lg (&self, #( #argnames: &#predty, )*) -> bool {
self.matcher.lock().unwrap().matches(#(#argnames, )*)
}
Expand Down Expand Up @@ -1118,6 +1119,7 @@ impl ToTokens for CommonExpectationMethods<'_> {

/// Validate this expectation's matcher.
#[allow(clippy::ptr_arg)]
#[allow(clippy::ref_option)]
fn matches #lg (&self, #(#argnames: &#predty, )*) -> bool {
self.common.matches(#(#argnames, )*)
}
Expand Down Expand Up @@ -1719,6 +1721,7 @@ impl ToTokens for Matcher<'_> {
}
impl #ig Matcher #tg #wc {
#[allow(clippy::ptr_arg)]
#[allow(clippy::ref_option)]
fn matches #lg (&self, #( #argnames: &#predty, )*) -> bool {
match self {
Matcher::Always => true,
Expand Down

0 comments on commit e1ac2e1

Please sign in to comment.