RS.CLIPPY.NEEDLESS_RETURN

Using a return statement like `return expr;` where an expression would suffice

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: needless_return. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for return statements at the end of a block.

Why is this bad?

Removing the return and semicolon will make the code more rusty.

Example

fn foo(x: usize) -> usize {
    return x;
}

simplify to

fn foo(x: usize) -> usize {
    x
}