Skip to content

Commit

Permalink
Suppress #[expect] attributes in the generated code (#619)
Browse files Browse the repository at this point in the history
Fixes #614
  • Loading branch information
asomers authored Nov 17, 2024
1 parent dee7bcb commit a96a23e
Show file tree
Hide file tree
Showing 3 changed files with 22 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 warnings about the `#[expect]` lint, new in Rust 1.81.0, in
generated code.
([#619](https://github.com/asomers/mockall/pull/619))

- Suppress the `#[clippy::ref_option]` warning, new in Rust 1.83.0, in
generated code.
([#618](https://github.com/asomers/mockall/pull/618))
Expand Down
13 changes: 13 additions & 0 deletions mockall/tests/automock_clippy_expect.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//! It should be possible to use #[expect::clippy] within an #[automock] block

use mockall::automock;

pub struct Foo {}

#[automock]
impl Foo {
#[expect(unused_variables)]
pub fn foo(&self) {
let a = 0;
}
}
5 changes: 5 additions & 0 deletions mockall_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,11 @@ impl<'a> AttrFormatter<'a> {
self.doc
} else if *i.as_ref().unwrap() == "async_trait" {
self.async_trait
} else if *i.as_ref().unwrap() == "expect" {
// This probably means that there's a lint that needs to be
// surpressed for the real code, but not for the mock code.
// Skip it.
false
} else if *i.as_ref().unwrap() == "inline" {
// No need to inline mock functions.
false
Expand Down

0 comments on commit a96a23e

Please sign in to comment.