Skip to content

False positive with new_ret_no_self if new is an async fn that returns a wrapper around Self. #4359

Closed
@lukas-code

Description

@lukas-code

This code

#![feature(async_await)]

struct S;

impl S {
    async fn new() -> Result<Self, ()> {
        Ok(S)
    }
}

causes the following warning

warning: methods called `new` usually return `Self`
 --> src/lib.rs:7:5
  |
7 | /     async fn new() -> Result<Self, ()> {
8 | |         Ok(S)
9 | |     }
  | |_____^
  |
  = note: `#[warn(clippy::new_ret_no_self)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_ret_no_self

cargo clippy -V

clippy 0.0.212 (b041511 2019-08-07)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingT-async-awaitType: Issues related to async/await

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions