From 175cb10ef66e3c4b5e64383554de30305103d0e7 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 30 Mar 2026 22:22:48 +0700 Subject: [PATCH] [ai] Add trailing return type rule to review. --- REVIEW.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/REVIEW.md b/REVIEW.md index 0623131f0f..87e23dbe3c 100644 --- a/REVIEW.md +++ b/REVIEW.md @@ -470,6 +470,20 @@ struct State { const auto state = lifetime.make_state(); ``` +## Use trailing return type when the return type doesn't fit on one line + +When a function's return type is long enough that the declaration would need a line break between the return type and the function name, use trailing return type syntax (`auto ... -> Type`) to keep the function name on the opening line. + +```cpp +// BAD - return type orphaned on its own line: +not_null +SetupCaptionAiButton(SetupCaptionAiButtonArgs &&args); + +// GOOD - trailing return type keeps name visible: +auto SetupCaptionAiButton(SetupCaptionAiButtonArgs &&args) +-> not_null; +``` + ## Static member functions use PascalCase Non-static member functions use camelCase (`startBatch`, `finalize`). Static member functions use PascalCase (`ShouldTrack`, `Parse`, `Create`), matching the convention for free functions.