Skip to content

Commit df0d729

Browse files
authored
chore: remove some unused types and functions in the AST (#7339)
1 parent a55a5fc commit df0d729

File tree

4 files changed

+1
-92
lines changed

4 files changed

+1
-92
lines changed

compiler/noirc_frontend/src/ast/expression.rs

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use acvm::{acir::AcirField, FieldElement};
1616
use iter_extended::vecmap;
1717
use noirc_errors::{Span, Spanned};
1818

19-
use super::{AsTraitPath, TypePath, UnaryRhsMemberAccess};
19+
use super::{AsTraitPath, TypePath};
2020

2121
#[derive(Debug, PartialEq, Eq, Clone)]
2222
pub enum ExpressionKind {
@@ -245,49 +245,6 @@ impl Expression {
245245
pub fn new(kind: ExpressionKind, span: Span) -> Expression {
246246
Expression { kind, span }
247247
}
248-
249-
pub fn member_access_or_method_call(
250-
lhs: Expression,
251-
rhs: UnaryRhsMemberAccess,
252-
span: Span,
253-
) -> Expression {
254-
let kind = match rhs.method_call {
255-
None => {
256-
let rhs = rhs.method_or_field;
257-
ExpressionKind::MemberAccess(Box::new(MemberAccessExpression { lhs, rhs }))
258-
}
259-
Some(method_call) => ExpressionKind::MethodCall(Box::new(MethodCallExpression {
260-
object: lhs,
261-
method_name: rhs.method_or_field,
262-
generics: method_call.turbofish,
263-
arguments: method_call.args,
264-
is_macro_call: method_call.macro_call,
265-
})),
266-
};
267-
Expression::new(kind, span)
268-
}
269-
270-
pub fn index(collection: Expression, index: Expression, span: Span) -> Expression {
271-
let kind = ExpressionKind::Index(Box::new(IndexExpression { collection, index }));
272-
Expression::new(kind, span)
273-
}
274-
275-
pub fn cast(lhs: Expression, r#type: UnresolvedType, span: Span) -> Expression {
276-
let kind = ExpressionKind::Cast(Box::new(CastExpression { lhs, r#type }));
277-
Expression::new(kind, span)
278-
}
279-
280-
pub fn call(
281-
lhs: Expression,
282-
is_macro_call: bool,
283-
arguments: Vec<Expression>,
284-
span: Span,
285-
) -> Expression {
286-
let func = Box::new(lhs);
287-
let kind =
288-
ExpressionKind::Call(Box::new(CallExpression { func, is_macro_call, arguments }));
289-
Expression::new(kind, span)
290-
}
291248
}
292249

293250
pub type BinaryOp = Spanned<BinaryOpKind>;

compiler/noirc_frontend/src/ast/mod.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,18 +225,6 @@ impl From<Vec<GenericTypeArg>> for GenericTypeArgs {
225225
}
226226
}
227227

228-
/// Type wrapper for a member access
229-
pub struct UnaryRhsMemberAccess {
230-
pub method_or_field: Ident,
231-
pub method_call: Option<UnaryRhsMethodCall>,
232-
}
233-
234-
pub struct UnaryRhsMethodCall {
235-
pub turbofish: Option<Vec<UnresolvedType>>,
236-
pub macro_call: bool,
237-
pub args: Vec<Expression>,
238-
}
239-
240228
/// The precursor to TypeExpression, this is the type that the parser allows
241229
/// to be used in the length position of an array type. Only constant integers, variables,
242230
/// and numeric binary operators are allowed here.

compiler/noirc_frontend/src/ast/statement.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -154,30 +154,6 @@ impl StatementKind {
154154
attributes,
155155
})
156156
}
157-
158-
/// Create a Statement::Assign value, desugaring any combined operators like += if needed.
159-
pub fn assign(
160-
lvalue: LValue,
161-
operator: Token,
162-
mut expression: Expression,
163-
span: Span,
164-
) -> StatementKind {
165-
// Desugar `a <op>= b` to `a = a <op> b`. This relies on the evaluation of `a` having no side effects,
166-
// which is currently enforced by the restricted syntax of LValues.
167-
if operator != Token::Assign {
168-
let lvalue_expr = lvalue.as_expression();
169-
let error_msg = "Token passed to Statement::assign is not a binary operator";
170-
171-
let infix = crate::ast::InfixExpression {
172-
lhs: lvalue_expr,
173-
operator: operator.try_into_binary_op(span).expect(error_msg),
174-
rhs: expression,
175-
};
176-
expression = Expression::new(ExpressionKind::Infix(Box::new(infix)), span);
177-
}
178-
179-
StatementKind::Assign(AssignStatement { lvalue, expression })
180-
}
181157
}
182158

183159
#[derive(Eq, Debug, Clone, Default)]

compiler/noirc_frontend/src/ast/type_alias.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ pub struct NoirTypeAlias {
1313
pub span: Span,
1414
}
1515

16-
impl NoirTypeAlias {
17-
pub fn new(
18-
name: Ident,
19-
generics: UnresolvedGenerics,
20-
typ: UnresolvedType,
21-
visibility: ItemVisibility,
22-
span: Span,
23-
) -> NoirTypeAlias {
24-
NoirTypeAlias { name, generics, typ, visibility, span }
25-
}
26-
}
27-
2816
impl Display for NoirTypeAlias {
2917
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3018
let generics = vecmap(&self.generics, |generic| generic.to_string());

0 commit comments

Comments
 (0)