Skip to contentSlop Block

require-blank-line-before-return

Warning

Separate the final return of a function or closure body from the statements above it, even when the body has two statements. if bodies and match arms are skipped.

fn build() -> Settings {	let host = host();	let port = port();	return Settings { host, port };Leave a blank line before the final return}
fn query(request: Request) -> Response {	let query = request.into_inner();	return execute(query);Leave a blank line before the final return}
// ast-grep-ignore: require-blank-line-before-return-rust

How to fix

Even a two-statement function or closure body needs a blank line before its final return. In nested blocks such as if bodies and match arms, the return can stay next to the statement it belongs to.