Skip to content

implicit_return false positive inside tauri::command macro #12872

@jsimonrichard

Description

@jsimonrichard

Summary

I'm denying implicit_return (for readability) with a Tauri project which includes async commands. Somewhere inside the tauri::command macro or the tauri::generate_handler macro, there's an implicit return that clippy is picking up on (but only when the command function is async).

But it's my understanding that clippy lints like this one should not be applied to the code inside macros (especially external ones). And obviously I can't control the code style of an external crate.

Lint Name

implicit_return

Reproducer

I've provided a minimal reproducible example repo here: https://github.com/jsimonrichard/clippy-implicit_return-tauri-command-macro-issue-mre

I saw this happen:

error: missing `return` statement
  --> src/main.rs:5:1
   |
5  | #[tauri::command]
   | ^^^^^^^^^^^^^^^^^ help: add `return` as shown: `return #[tauri::command]`
...
12 |         .invoke_handler(tauri::generate_handler![greet])
   |                         ------------------------------- in this macro invocation

I expected to see this happen: no error.

Version

rustc 1.78.0 (9b00956e5 2024-04-29)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-unknown-linux-gnu
release: 1.78.0
LLVM version: 18.1.2

Additional Labels

No response

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveL-restrictionLint: Belongs in the restriction lint groupT-macrosType: Issues with macros and macro expansion

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions