Skip to content

clippy::return_self_not_must_use is overreaching #8339

Open
@rkuhn

Description

@rkuhn

Using 1.59.0-beta.3, the following illustrates the point:

warning: missing `#[must_use]` attribute on a method returning `Self`
  --> libp2p-streaming-response/src/v2/behaviour.rs:32:5
   |
32 | /     pub fn with_request_timeout(self, request_timeout: Duration) -> Self {
33 | |         Self {
34 | |             request_timeout,
35 | |             ..self
36 | |         }
37 | |     }
   | |_____^
   |
   = note: `#[warn(clippy::return_self_not_must_use)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#return_self_not_must_use

I can see how a method that takes &self and produces Self may be misused (although I don’t think that is compelling enough to warrant a default lint), but the above method is not susceptible to programmer mistakes, thanks to Rust’s affine type system. If you deem this worthy of a fix, I may try my hand at it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions