RS.CLIPPY.IMPLICIT_RETURN

Use a return statement like `return expr` instead of an expression

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

What it does

Checks for missing return statements at the end of a block.

Why restrict this?

Omitting the return keyword whenever possible is idiomatic Rust code, but:

  • Programmers coming from other languages might prefer the expressiveness of return.
  • It's possible to miss the last returning statement because the only difference is a missing ;.
  • Especially in bigger code with multiple return paths, having a return keyword makes it easier to find the corresponding statements.

Example

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

add return

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