Skip to content

Commit a96a23e

Browse files
authored
Suppress #[expect] attributes in the generated code (#619)
Fixes #614
1 parent dee7bcb commit a96a23e

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
77

88
### Fixed
99

10+
- Suppress warnings about the `#[expect]` lint, new in Rust 1.81.0, in
11+
generated code.
12+
([#619](https://github.com/asomers/mockall/pull/619))
13+
1014
- Suppress the `#[clippy::ref_option]` warning, new in Rust 1.83.0, in
1115
generated code.
1216
([#618](https://github.com/asomers/mockall/pull/618))
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//! It should be possible to use #[expect::clippy] within an #[automock] block
2+
3+
use mockall::automock;
4+
5+
pub struct Foo {}
6+
7+
#[automock]
8+
impl Foo {
9+
#[expect(unused_variables)]
10+
pub fn foo(&self) {
11+
let a = 0;
12+
}
13+
}

mockall_derive/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,11 @@ impl<'a> AttrFormatter<'a> {
820820
self.doc
821821
} else if *i.as_ref().unwrap() == "async_trait" {
822822
self.async_trait
823+
} else if *i.as_ref().unwrap() == "expect" {
824+
// This probably means that there's a lint that needs to be
825+
// surpressed for the real code, but not for the mock code.
826+
// Skip it.
827+
false
823828
} else if *i.as_ref().unwrap() == "inline" {
824829
// No need to inline mock functions.
825830
false

0 commit comments

Comments
 (0)