From f4072b08a3726321d0999d736a0910c817116a30 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Wed, 3 Jun 2026 17:29:39 +0200 Subject: [PATCH] Removed new keyword --- crates/codegen/src/expr.rs | 26 ------------------------- crates/parser/src/ast/expr.rs | 1 - crates/parser/src/grammar.pest | 2 -- crates/parser/src/parser/common/expr.rs | 6 ------ 4 files changed, 35 deletions(-) diff --git a/crates/codegen/src/expr.rs b/crates/codegen/src/expr.rs index c6fa873..d46e059 100644 --- a/crates/codegen/src/expr.rs +++ b/crates/codegen/src/expr.rs @@ -87,7 +87,6 @@ impl GenRust for Expression { } => { prefixes.gen_rust(ctx, cg); initial.gen_rust(ctx, cg); - cg.add(&Some(prefixes).get_rust()); for postfix in postfixes { postfix.gen_rust(ctx, cg); } @@ -117,7 +116,6 @@ impl GenRust for Prefix { Self::Ref => cg.add("&"), Self::RefMut => cg.add("&mut "), Self::Not => cg.add("!"), - Self::New(_) => cg.add(""), Self::Neg => cg.add("-"), Self::Closure(ty, args) => { cg.add("|"); @@ -148,30 +146,6 @@ impl GenRust for Vec { } } -impl GetRust for Option<&Vec> { - fn get_rust(&self) -> String { - if let Some(prefixes) = self { - prefixes - .into_iter() - .last() - .map(|p| match p { - Prefix::New(generics) => format!( - "::new{}", - generics - .clone() - .map(|v| format!("::{}", v.get_rust())) - .unwrap_or_default(), - ), - _ => String::new(), - }) - .unwrap_or_default() - .to_string() - } else { - String::new() - } - } -} - impl GenRust for Postfix { fn gen_rust(&self, ctx: &mut Context, cg: &mut RustCodegen) { match self { diff --git a/crates/parser/src/ast/expr.rs b/crates/parser/src/ast/expr.rs index 23fb010..ebe58e6 100644 --- a/crates/parser/src/ast/expr.rs +++ b/crates/parser/src/ast/expr.rs @@ -58,7 +58,6 @@ pub enum Prefix { Ref, RefMut, Deref, - New(Option), Not, Neg, Closure(Option, Vec), diff --git a/crates/parser/src/grammar.pest b/crates/parser/src/grammar.pest index 12376dd..ccff3b6 100644 --- a/crates/parser/src/grammar.pest +++ b/crates/parser/src/grammar.pest @@ -562,7 +562,6 @@ postfix = { deref_px = { "*" } mut_ref_px = { "&" ~ mutable } ref_px = { "&" } -new_px = { "new" ~ generics? } not_px = { "!" } neg_px = { "-" } @@ -571,7 +570,6 @@ prefix = { | deref_px | mut_ref_px | ref_px - | new_px | not_px | neg_px } diff --git a/crates/parser/src/parser/common/expr.rs b/crates/parser/src/parser/common/expr.rs index 2bd9c67..59504f4 100644 --- a/crates/parser/src/parser/common/expr.rs +++ b/crates/parser/src/parser/common/expr.rs @@ -106,12 +106,6 @@ impl<'a> TryFrom> for Prefix { Rule::deref_px => Self::Deref, Rule::mut_ref_px => Self::RefMut, Rule::ref_px => Self::Ref, - Rule::new_px => Self::New( - pair.into_inner() - .next() - .map(|v| v.try_into().get()) - .transpose()?, - ), Rule::not_px => Self::Not, Rule::neg_px => Self::Neg, Rule::closure => {