diff --git a/crates/ruff_linter/src/checkers/ast/analyze/statement.rs b/crates/ruff_linter/src/checkers/ast/analyze/statement.rs index 2b6468bfd7..18326189b8 100644 --- a/crates/ruff_linter/src/checkers/ast/analyze/statement.rs +++ b/crates/ruff_linter/src/checkers/ast/analyze/statement.rs @@ -158,7 +158,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) { decorator_list, returns.as_ref().map(AsRef::as_ref), parameters, - type_params.as_ref(), + type_params.as_deref(), ); } if checker.source_type.is_stub() { diff --git a/crates/ruff_python_ast/src/nodes.rs b/crates/ruff_python_ast/src/nodes.rs index cbd140c6c3..8f8c334ccc 100644 --- a/crates/ruff_python_ast/src/nodes.rs +++ b/crates/ruff_python_ast/src/nodes.rs @@ -181,7 +181,7 @@ pub struct StmtFunctionDef { pub is_async: bool, pub decorator_list: Vec, pub name: Identifier, - pub type_params: Option, + pub type_params: Option>, pub parameters: Box, pub returns: Option>, pub body: Vec, @@ -4171,8 +4171,8 @@ mod tests { #[test] #[cfg(target_pointer_width = "64")] fn size() { - assert!(std::mem::size_of::() <= 144); - assert!(std::mem::size_of::() <= 144); + assert!(std::mem::size_of::() <= 120); + assert!(std::mem::size_of::() <= 120); assert!(std::mem::size_of::() <= 104); assert!(std::mem::size_of::() <= 112); assert!(std::mem::size_of::() <= 32); diff --git a/crates/ruff_python_formatter/src/statement/clause.rs b/crates/ruff_python_formatter/src/statement/clause.rs index e439caa330..7ca1d4b7eb 100644 --- a/crates/ruff_python_formatter/src/statement/clause.rs +++ b/crates/ruff_python_formatter/src/statement/clause.rs @@ -108,7 +108,7 @@ impl<'a> ClauseHeader<'a> { returns, body: _, }) => { - if let Some(type_params) = type_params.as_ref() { + if let Some(type_params) = type_params.as_deref() { visit(type_params, visitor); } visit(parameters.as_ref(), visitor); diff --git a/crates/ruff_python_parser/src/parser/statement.rs b/crates/ruff_python_parser/src/parser/statement.rs index 9a768bf917..09f779be04 100644 --- a/crates/ruff_python_parser/src/parser/statement.rs +++ b/crates/ruff_python_parser/src/parser/statement.rs @@ -1738,7 +1738,7 @@ impl<'src> Parser<'src> { ast::StmtFunctionDef { name, - type_params, + type_params: type_params.map(Box::new), parameters: Box::new(parameters), body, decorator_list,