Skip to content

expect_fun_call does not trigger to references #4912

Closed
@TethysSvensson

Description

@TethysSvensson

The lint expect_fun_call does not trigger for references. This code should output the warning for both foo and bar, but it only outputs it for bar.

fn foo(x: &Option<[u8; 32]>) -> [u8; 32] {
    x.expect(&format!("Call to format: {:?}", x))
}

fn bar(x: Option<[u8; 32]>) -> [u8; 32] {
    x.expect(&format!("Call to format: {:?}", x))
}

fn main() {
    foo(&Some([0; 32]));
    bar(Some([0; 32]));
}

As a fun side-note, this was found by profiling our code and noticing that 50% of it was spent inside a call to format!().

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