From 0fb59c9fa583fddc452ebe73665a3f0511bbeb5d Mon Sep 17 00:00:00 2001 From: David Szotten Date: Wed, 21 Jun 2023 20:17:04 +0100 Subject: [PATCH] check we don't have comments without the node --- crates/ruff_python_formatter/src/statement/stmt_for.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ruff_python_formatter/src/statement/stmt_for.rs b/crates/ruff_python_formatter/src/statement/stmt_for.rs index 7b03569c11e5a..39ff33378ebf4 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_for.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_for.rs @@ -47,7 +47,9 @@ impl FormatNodeRule for FormatStmtFor { ] )?; - if !orelse.is_empty() { + if orelse.is_empty() { + debug_assert!(or_else_comments.is_empty()); + } else { // Split between leading comments before the `else` keyword and end of line comments at the end of // the `else:` line. let trailing_start =