Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove Recoverable #7307

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions compiler/noirc_frontend/src/ast/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::fmt::Display;
use thiserror::Error;

use crate::ast::{
Ident, ItemVisibility, Path, Pattern, Recoverable, Statement, StatementKind,
UnresolvedTraitConstraint, UnresolvedType, UnresolvedTypeData, Visibility,
Ident, ItemVisibility, Path, Pattern, Statement, StatementKind, UnresolvedTraitConstraint,
UnresolvedType, UnresolvedTypeData, Visibility,
};
use crate::node_interner::{
ExprId, InternedExpressionKind, InternedStatementKind, QuotedTypeId, TypeId,
Expand Down Expand Up @@ -226,24 +226,6 @@ impl ExpressionKind {
}
}

impl Recoverable for ExpressionKind {
fn error(_: Span) -> Self {
ExpressionKind::Error
}
}

impl Recoverable for Expression {
fn error(span: Span) -> Self {
Expression::new(ExpressionKind::Error, span)
}
}

impl Recoverable for Option<Expression> {
fn error(span: Span) -> Self {
Some(Expression::new(ExpressionKind::Error, span))
}
}

#[derive(Debug, Eq, Clone)]
pub struct Expression {
pub kind: ExpressionKind,
Expand Down
6 changes: 0 additions & 6 deletions compiler/noirc_frontend/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,6 @@
AsTraitPath(Box<AsTraitPath>),
}

impl Recoverable for UnresolvedType {
fn error(span: Span) -> Self {
UnresolvedType { typ: UnresolvedTypeData::Error, span }
}
}

impl std::fmt::Display for GenericTypeArg {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Expand Down Expand Up @@ -603,7 +597,7 @@
Self::Public => write!(f, "pub"),
Self::Private => write!(f, "priv"),
Self::CallData(id) => write!(f, "calldata{id}"),
Self::ReturnData => write!(f, "returndata"),

Check warning on line 600 in compiler/noirc_frontend/src/ast/mod.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (returndata)
}
}
}
34 changes: 0 additions & 34 deletions compiler/noirc_frontend/src/ast/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@ impl StatementKind {
}
}

impl Recoverable for StatementKind {
fn error(_: Span) -> Self {
StatementKind::Error
}
}

impl StatementKind {
pub fn new_let(
pattern: Pattern,
Expand Down Expand Up @@ -284,25 +278,6 @@ impl Ident {
}
}

impl Recoverable for Ident {
fn error(span: Span) -> Self {
Ident(Spanned::from(span, ERROR_IDENT.to_owned()))
}
}

impl<T> Recoverable for Vec<T> {
fn error(_: Span) -> Self {
vec![]
}
}

/// Trait for recoverable nodes during parsing.
/// This is similar to Default but is expected
/// to return an Error node of the appropriate type.
pub trait Recoverable {
fn error(span: Span) -> Self;
}

#[derive(Debug, PartialEq, Eq, Clone)]
pub struct ModuleDeclaration {
pub visibility: ItemVisibility,
Expand Down Expand Up @@ -420,9 +395,6 @@ pub struct TypePath {
pub turbofish: Option<GenericTypeArgs>,
}

// Note: Path deliberately doesn't implement Recoverable.
// No matter which default value we could give in Recoverable::error,
// it would most likely cause further errors during name resolution
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
pub struct Path {
pub segments: Vec<PathSegment>,
Expand Down Expand Up @@ -707,12 +679,6 @@ impl Pattern {
}
}

impl Recoverable for Pattern {
fn error(span: Span) -> Self {
Pattern::Identifier(Ident::error(span))
}
}

impl LValue {
pub fn as_expression(&self) -> Expression {
let kind = match self {
Expand Down
Loading