Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle #[expect] in automock #614

Closed
Rosdf opened this issue Oct 21, 2024 · 1 comment · Fixed by #619
Closed

Handle #[expect] in automock #614

Rosdf opened this issue Oct 21, 2024 · 1 comment · Fixed by #619
Labels
enhancement New feature or request

Comments

@Rosdf
Copy link

Rosdf commented Oct 21, 2024

#[mockall::automock]
pub trait MyTrait {
    #[expect(
        clippy::needless_lifetimes,
        single_use_lifetimes,
        reason = "required for mocking"
    )]
    fn get<'a>(
        &mut self,
        string: &'a str,
    ) -> String;
}

clippy produces warnings

warning: this lint expectation is unfulfilled
 --> src/main.rs:8:9
  |
8 |         clippy::needless_lifetimes,
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: required for mocking
  = note: `#[warn(unfulfilled_lint_expectations)]` on by default

warning: this lint expectation is unfulfilled
 --> src/main.rs:9:9
  |
9 |         single_use_lifetimes,
  |         ^^^^^^^^^^^^^^^^^^^^
  |
  = note: required for mocking

without #[mockall::automock] no warnings produced

@asomers
Copy link
Owner

asomers commented Oct 21, 2024

If you use #[allow] instead of #[expect] it will work. The expect is undoubtedly failing because it gets expanded too many places. I'll fix it when I have the time.

@asomers asomers added the enhancement New feature or request label Oct 21, 2024
@asomers asomers changed the title allowing lints does not work with automock Handle #[expect] in automock Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants