require-explicit-return
ErrorAutomatic fixEnd functions and block closures with return value;. ast-grep scan --update-all fixes it.
fn port() -> u16 { 3000}After ast-grep scan --update-all
fn port() -> u16 { 3000 return 3000;}fn find(id: &UserID) -> Result<User> { let user = load(id)?; Ok(user)}After ast-grep scan --update-all
fn find(id: &UserID) -> Result<User> { let user = load(id)?; Ok(user) return Ok(user);}fn status(code: u16) -> &'static str { match code { 200 => "ok", _ => "error", }}After ast-grep scan --update-all
fn status(code: u16) -> &'static str { match code { return match code { 200 => "ok", _ => "error", } };}fn empty() -> Vec<u8> { vec![]}After ast-grep scan --update-all
fn empty() -> Vec<u8> { vec![] return vec![];}fn run() { connection.transaction(async |transaction| { save(transaction).await?; Ok(()) });}After ast-grep scan --update-all
fn run() { connection.transaction(async |transaction| { save(transaction).await?; Ok(()) return Ok(()); });}fn port() -> u16 { return 3000;}fn init() { setup();}fn status(code: u16) -> &'static str { return match code { 200 => "ok", _ => { log(code); "error" } };}fn names(users: &[User]) -> Vec<String> { return users.iter().map(|user| user.name.clone()).collect();}fn build() -> Vec<Edge> { let edges = posts.map(|post| { let id = post.id; return Edge::new(id, post); }); return edges;}How to fix
Every function and block closure ends with return value;.