diff --git a/crates/ruff/src/checkers/ast/mod.rs b/crates/ruff/src/checkers/ast/mod.rs index c4ea4e8b28..1fa7b362fe 100644 --- a/crates/ruff/src/checkers/ast/mod.rs +++ b/crates/ruff/src/checkers/ast/mod.rs @@ -528,11 +528,7 @@ where &self.semantic.definitions, ); self.semantic.push_definition(definition); - - self.semantic.push_scope(match &stmt { - Stmt::FunctionDef(stmt) => ScopeKind::Function(stmt), - _ => unreachable!("Expected Stmt::FunctionDef"), - }); + self.semantic.push_scope(ScopeKind::Function(function_def)); self.deferred.functions.push(self.semantic.snapshot());