From 4816e420d066d52c5de02a7318ca511809faffa9 Mon Sep 17 00:00:00 2001 From: Benjamin Brienen Date: Sun, 17 Aug 2025 01:37:36 +0200 Subject: [PATCH] Remove conflicting advice --- .../docs/book/src/contributing/style.md | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/tools/rust-analyzer/docs/book/src/contributing/style.md b/src/tools/rust-analyzer/docs/book/src/contributing/style.md index fe09fb6c2fd5..0c58a83a1d48 100644 --- a/src/tools/rust-analyzer/docs/book/src/contributing/style.md +++ b/src/tools/rust-analyzer/docs/book/src/contributing/style.md @@ -236,22 +236,6 @@ In the "Good" version, the precondition check and usage are checked in the same **Rationale:** non-local code properties degrade under change. -When checking a boolean precondition, prefer `if !invariant` to `if negated_invariant`: - -```rust -// GOOD -if !(idx < len) { - return None; -} - -// BAD -if idx >= len { - return None; -} -``` - -**Rationale:** it's useful to see the invariant relied upon by the rest of the function clearly spelled out. - ## Control Flow As a special case of the previous rule, do not hide control flow inside functions, push it to the caller: