From d2712c7669ef6be40db1ff028a288e6c0990d7de Mon Sep 17 00:00:00 2001 From: David Peter Date: Thu, 12 Dec 2024 20:49:54 +0100 Subject: [PATCH] ruff_python_ast: Make `Singleton` `Copy` (#14943) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Minor changed pulled out from #14759, as it seems to make sense in isolation. ## Test Plan — --- crates/ruff_python_ast/src/nodes.rs | 2 +- crates/ruff_python_codegen/src/generator.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ruff_python_ast/src/nodes.rs b/crates/ruff_python_ast/src/nodes.rs index 17d7797193..c2676da825 100644 --- a/crates/ruff_python_ast/src/nodes.rs +++ b/crates/ruff_python_ast/src/nodes.rs @@ -4061,7 +4061,7 @@ impl Ranged for Identifier { } } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq)] pub enum Singleton { None, True, diff --git a/crates/ruff_python_codegen/src/generator.rs b/crates/ruff_python_codegen/src/generator.rs index 68b4ff6064..a937130809 100644 --- a/crates/ruff_python_codegen/src/generator.rs +++ b/crates/ruff_python_codegen/src/generator.rs @@ -669,7 +669,7 @@ impl<'a> Generator<'a> { self.unparse_expr(value, precedence::MAX); } Pattern::MatchSingleton(ast::PatternMatchSingleton { value, range: _ }) => { - self.unparse_singleton(value); + self.unparse_singleton(*value); } Pattern::MatchSequence(ast::PatternMatchSequence { patterns, range: _ }) => { self.p("["); @@ -1211,7 +1211,7 @@ impl<'a> Generator<'a> { } } - pub(crate) fn unparse_singleton(&mut self, singleton: &Singleton) { + pub(crate) fn unparse_singleton(&mut self, singleton: Singleton) { match singleton { Singleton::None => self.p("None"), Singleton::True => self.p("True"),