Repository: astral-sh/ruff
File: crates/ruff_linter/src/checkers/ast/mod.rs (Rust)

Code before:
                    self.report_diagnostic(pyflakes::rules::BreakOutsideLoop, error.range);
                }
            }
            SemanticSyntaxErrorKind::ContinueOutsideLoop => {
                // F702
                if self.is_rule_enabled(Rule::ContinueOutsideLoop) {
                    self.report_diagnostic(pyflakes::rules::ContinueOutsideLoop, error.range);
                }
            }
            SemanticSyntaxErrorKind::NonlocalWithoutBinding(name) => {
                // PLE0117
                if self.is_rule_enabled(Rule::NonlocalWithoutBinding) {
                    self.report_diagnostic(NonlocalWithoutBinding { name }, error.range);
                }
            }
            SemanticSyntaxErrorKind::ReboundComprehensionVariable
            | SemanticSyntaxErrorKind::DuplicateTypeParameter
            | SemanticSyntaxErrorKind::MultipleCaseAssignment(_)
            | SemanticSyntaxErrorKind::IrrefutableCasePattern(_)
            | SemanticSyntaxErrorKind::SingleStarredAssignment
            | SemanticSyntaxErrorKind::WriteToDebug(_)
            | SemanticSyntaxErrorKind::DifferentMatchPatternBindings
            | SemanticSyntaxErrorKind::InvalidExpression(..)
            | SemanticSyntaxErrorKind::GlobalParameter(_)
            | SemanticSyntaxErrorKind::DuplicateMatchKey(_)
            | SemanticSyntaxErrorKind::ReturnInAsyncGenerator
            | SemanticSyntaxErrorKind::DuplicateMatchClassAttribute(_)
            | SemanticSyntaxErrorKind::InvalidStarExpression
            | SemanticSyntaxErrorKind::AsyncComprehensionInSyncComprehension(_)
            | SemanticSyntaxErrorKind::DuplicateParameter(_)
            | SemanticSyntaxErrorKind::NonlocalDeclarationAtModuleLevel
            | SemanticSyntaxErrorKind::LoadBeforeNonlocalDeclaration { .. }
            | SemanticSyntaxErrorKind::NonlocalAndGlobal(_)
            | SemanticSyntaxErrorKind::AnnotatedGlobal(_)
            | SemanticSyntaxErrorKind::AnnotatedNonlocal(_) => {
                self.semantic_errors.borrow_mut().push(error);
            }
        }
    }

    fn source(&self) -> &str {
        self.source()
    }

    fn future_annotations_or_stub(&self) -> bool {
        self.semantic.future_annotations_or_stub()
    }

    fn in_async_context(&self) -> bool {
        for scope in self.semantic.current_scopes() {
            match scope.kind {

Review comment (bug):
We need to convert this into a B901 error right? It looks like we actually don't have any B901 test cases with async functions (that trigger the lint), otherwise I would have expected tests to fail. We should probably add one of those as well.

Code after:
                // F701
                if self.is_rule_enabled(Rule::BreakOutsideLoop) {
                    self.report_diagnostic(pyflakes::rules::BreakOutsideLoop, error.range);
                }
            }
            SemanticSyntaxErrorKind::ContinueOutsideLoop => {
                // F702
                if self.is_rule_enabled(Rule::ContinueOutsideLoop) {
                    self.report_diagnostic(pyflakes::rules::ContinueOutsideLoop, error.range);
                }
            }
            SemanticSyntaxErrorKind::NonlocalWithoutBinding(name) => {
                // PLE0117
                if self.is_rule_enabled(Rule::NonlocalWithoutBinding) {
                    self.report_diagnostic(NonlocalWithoutBinding { name }, error.range);
                }
            }
            SemanticSyntaxErrorKind::ReturnInGenerator => {
                // B901
                if self.is_rule_enabled(Rule::ReturnInGenerator) {
                    self.report_diagnostic(ReturnInGenerator, error.range);
                }
            }
            SemanticSyntaxErrorKind::ReboundComprehensionVariable
            | SemanticSyntaxErrorKind::DuplicateTypeParameter
            | SemanticSyntaxErrorKind::MultipleCaseAssignment(_)
            | SemanticSyntaxErrorKind::IrrefutableCasePattern(_)
            | SemanticSyntaxErrorKind::SingleStarredAssignment
            | SemanticSyntaxErrorKind::WriteToDebug(_)
            | SemanticSyntaxErrorKind::DifferentMatchPatternBindings
            | SemanticSyntaxErrorKind::InvalidExpression(..)
            | SemanticSyntaxErrorKind::GlobalParameter(_)
            | SemanticSyntaxErrorKind::DuplicateMatchKey(_)
            | SemanticSyntaxErrorKind::DuplicateMatchClassAttribute(_)
            | SemanticSyntaxErrorKind::InvalidStarExpression
            | SemanticSyntaxErrorKind::AsyncComprehensionInSyncComprehension(_)
            | SemanticSyntaxErrorKind::DuplicateParameter(_)
            | SemanticSyntaxErrorKind::NonlocalDeclarationAtModuleLevel
            | SemanticSyntaxErrorKind::LoadBeforeNonlocalDeclaration { .. }
            | SemanticSyntaxErrorKind::NonlocalAndGlobal(_)
            | SemanticSyntaxErrorKind::AnnotatedGlobal(_)
            | SemanticSyntaxErrorKind::TypeParameterDefaultOrder(_)
            | SemanticSyntaxErrorKind::AnnotatedNonlocal(_) => {
                self.semantic_errors.borrow_mut().push(error);
            }
        }
    }

    fn source(&self) -> &str {
        self.source()
    }