diff --git a/plugins/cairo-lang-macro/src/types/token.rs b/plugins/cairo-lang-macro/src/types/token.rs index 46f851c5c..374573188 100644 --- a/plugins/cairo-lang-macro/src/types/token.rs +++ b/plugins/cairo-lang-macro/src/types/token.rs @@ -10,7 +10,7 @@ use std::rc::Rc; /// This is both input and part of an output of a procedural macro. #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(try_from = "deserializer::TokenStream"))] -#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TokenStream { pub tokens: Vec, pub metadata: TokenStreamMetadata, @@ -85,12 +85,6 @@ pub enum TokenTree { Ident(Token), } -impl Default for TokenTree { - fn default() -> Self { - Self::Ident(Default::default()) - } -} - impl TokenTree { /// Get the size hint for the [`TokenTree`]. /// This can be used to estimate size of a buffer needed for allocating this [`TokenTree`]. @@ -103,7 +97,7 @@ impl TokenTree { /// A range of text offsets that form a span (like text selection). #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TextSpan { pub start: usize, pub end: usize, @@ -113,7 +107,7 @@ pub struct TextSpan { /// /// The most atomic item of Cairo code representation. #[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Token { pub content: InternedStr, pub span: TextSpan, @@ -157,15 +151,6 @@ impl InternedStr { } } -impl Default for InternedStr { - fn default() -> Self { - Self { - ptr: "" as *const str, - _bump: Rc::default(), - } - } -} - impl AsRef for InternedStr { fn as_ref(&self) -> &str { self.deref() @@ -202,7 +187,7 @@ impl Hash for InternedStr { } /// This wrapper de-allocates the underlying buffer on drop. -#[derive(Debug, Default)] +#[derive(Debug)] struct BumpWrap(pub Bump); impl Drop for BumpWrap { diff --git a/scarb/tests/proc_macro_server.rs b/scarb/tests/proc_macro_server.rs index 8950a5b12..455df2c8b 100644 --- a/scarb/tests/proc_macro_server.rs +++ b/scarb/tests/proc_macro_server.rs @@ -91,7 +91,7 @@ fn expand_attribute() { args: TokenStream::empty(), item: TokenStream::new(vec![TokenTree::Ident(Token::new( "fn some_test_fn(){}", - TextSpan::default(), + TextSpan::new(0, 0), ))]), }) .unwrap(); @@ -125,7 +125,7 @@ fn expand_derive() { let item = TokenStream::new(vec![TokenTree::Ident(Token::new( "fn some_test_fn(){}", - TextSpan::default(), + TextSpan::new(0, 0), ))]); let response = proc_macro_server @@ -182,7 +182,7 @@ fn expand_inline() { name: "replace_all_15_with_25".to_string(), args: TokenStream::new(vec![TokenTree::Ident(Token::new( "struct A { field: 15 , other_field: macro_call!(12)}", - TextSpan::default(), + TextSpan::new(0, 0), ))]), }) .unwrap(); diff --git a/utils/scarb-proc-macro-server-types/src/methods/mod.rs b/utils/scarb-proc-macro-server-types/src/methods/mod.rs index de8377f4a..102d355f7 100644 --- a/utils/scarb-proc-macro-server-types/src/methods/mod.rs +++ b/utils/scarb-proc-macro-server-types/src/methods/mod.rs @@ -15,10 +15,19 @@ pub trait Method { /// /// This struct encapsulates both the resulting token stream from macro expansion /// and any diagnostic messages (e.g., errors or warnings) that were generated during processing. -#[derive(Debug, Clone, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct ProcMacroResult { /// The resultant token stream produced after the macro expansion. pub token_stream: TokenStream, /// A list of diagnostics produced during the macro execution. pub diagnostics: Vec, } + +impl Default for ProcMacroResult { + fn default() -> Self { + Self { + token_stream: TokenStream::empty(), + diagnostics: Vec::new(), + } + } +}