Skip to content
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
28 changes: 13 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ unused_qualifications = "warn"
unreachable_pub = "warn"
unsafe_code = "deny"
unused_must_use = "warn"
mismatched_lifetime_syntaxes = "allow"

[workspace.lints.clippy]
semicolon_if_nothing_returned = "warn"
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm_js/src/foreign_call/outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn decode_foreign_call_output(output: JsValue) -> Result<ForeignCallParam<FieldE
}
Ok(ForeignCallParam::Array(values))
} else {
return Err("Non-string-or-array element in foreign_call_handler return".into());
Err("Non-string-or-array element in foreign_call_handler return".into())
}
}

Expand Down
3 changes: 3 additions & 0 deletions compiler/noirc_frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ edition.workspace = true
rust-version.workspace = true
license.workspace = true

[lints]
workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
6 changes: 3 additions & 3 deletions compiler/noirc_frontend/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub enum UnresolvedTypeData {

/// An "as Trait" path leading to an associated type.
/// E.g. `<Foo as Trait>::Bar`
AsTraitPath(Box<crate::ast::AsTraitPath>),
AsTraitPath(Box<AsTraitPath>),

/// An already resolved type. These can only be parsed if they were present in the token stream
/// as a result of being spliced into a macro's token stream input.
Expand Down Expand Up @@ -295,10 +295,10 @@ impl std::fmt::Display for UnresolvedTypeData {
let args = vecmap(args, ToString::to_string).join(", ");

match &env.as_ref().typ {
UnresolvedTypeData::Unit => {
Unit => {
write!(f, "fn({args}) -> {ret}")
}
UnresolvedTypeData::Tuple(env_types) => {
Tuple(env_types) => {
let env_types = vecmap(env_types, |arg| arg.typ.to_string()).join(", ");
write!(f, "fn[{env_types}]({args}) -> {ret}")
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/ast/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ pub struct ModuleDeclaration {
pub has_semicolon: bool,
}

impl std::fmt::Display for ModuleDeclaration {
impl Display for ModuleDeclaration {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "mod {}", self.ident)
}
Expand Down
10 changes: 5 additions & 5 deletions compiler/noirc_frontend/src/debug/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl DebugInstrumenter {
let last_stmt = if has_ret_expr {
ast::Statement {
kind: ast::StatementKind::Expression(ast::Expression {
kind: ast::ExpressionKind::Variable(ast::Path::plain(
kind: ast::ExpressionKind::Variable(Path::plain(
vec![PathSegment::from(ident("__debug_expr", location))],
location,
)),
Expand Down Expand Up @@ -649,7 +649,7 @@ fn build_assign_var_stmt(var_id: SourceVarId, expr: ast::Expression) -> ast::Sta
let location = expr.location;
let kind = ast::ExpressionKind::Call(Box::new(ast::CallExpression {
func: Box::new(ast::Expression {
kind: ast::ExpressionKind::Variable(ast::Path::plain(
kind: ast::ExpressionKind::Variable(Path::plain(
vec![PathSegment::from(ident("__debug_var_assign", location))],
location,
)),
Expand All @@ -664,7 +664,7 @@ fn build_assign_var_stmt(var_id: SourceVarId, expr: ast::Expression) -> ast::Sta
fn build_drop_var_stmt(var_id: SourceVarId, location: Location) -> ast::Statement {
let kind = ast::ExpressionKind::Call(Box::new(ast::CallExpression {
func: Box::new(ast::Expression {
kind: ast::ExpressionKind::Variable(ast::Path::plain(
kind: ast::ExpressionKind::Variable(Path::plain(
vec![PathSegment::from(ident("__debug_var_drop", location))],
location,
)),
Expand All @@ -688,7 +688,7 @@ fn build_assign_member_stmt(
let location = expr.location;
let kind = ast::ExpressionKind::Call(Box::new(ast::CallExpression {
func: Box::new(ast::Expression {
kind: ast::ExpressionKind::Variable(ast::Path::plain(
kind: ast::ExpressionKind::Variable(Path::plain(
vec![PathSegment::from(ident(&format!["__debug_member_assign_{arity}"], location))],
location,
)),
Expand All @@ -708,7 +708,7 @@ fn build_assign_member_stmt(
fn build_debug_call_stmt(fname: &str, fn_id: DebugFnId, location: Location) -> ast::Statement {
let kind = ast::ExpressionKind::Call(Box::new(ast::CallExpression {
func: Box::new(ast::Expression {
kind: ast::ExpressionKind::Variable(ast::Path::plain(
kind: ast::ExpressionKind::Variable(Path::plain(
vec![PathSegment::from(ident(&format!["__debug_fn_{fname}"], location))],
location,
)),
Expand Down
7 changes: 3 additions & 4 deletions compiler/noirc_frontend/src/elaborator/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,13 @@ impl Elaborator<'_> {
let no_parameters = Parameters(Vec::new());
let global_body =
self.make_enum_variant_constructor(datatype, variant_index, &no_parameters, location);
let let_statement = crate::hir_def::stmt::HirStatement::Expression(global_body);
let let_statement = HirStatement::Expression(global_body);

let statement_id = self.interner.get_global(global_id).let_statement;
self.interner.replace_statement(statement_id, let_statement);

self.interner.get_global_mut(global_id).value = GlobalValue::Resolved(
crate::hir::comptime::Value::Enum(variant_index, Vec::new(), typ),
);
self.interner.get_global_mut(global_id).value =
GlobalValue::Resolved(Value::Enum(variant_index, Vec::new(), typ));

Self::get_module_mut(self.def_maps, type_id.module_id())
.declare_global(name.clone(), enum_.visibility, global_id)
Expand Down
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/elaborator/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ impl Elaborator<'_> {
// Given that we already produced an error, let's make this an `assert(true)` so
// we don't get further errors.
let message = None;
let kind = ExpressionKind::Literal(crate::ast::Literal::Bool(true));
let kind = ExpressionKind::Literal(Literal::Bool(true));
let expr = Expression { kind, location };
(message, expr)
} else {
Expand Down Expand Up @@ -1232,7 +1232,7 @@ impl Elaborator<'_> {
match_expr: MatchExpression,
location: Location,
) -> (HirExpression, Type) {
self.use_unstable_feature(super::UnstableFeature::Enums, location);
self.use_unstable_feature(UnstableFeature::Enums, location);

let expr_location = match_expr.expression.location;
let (expression, typ) = self.elaborate_expression(match_expr.expression);
Expand Down
17 changes: 8 additions & 9 deletions compiler/noirc_frontend/src/elaborator/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ impl Elaborator<'_> {
use Type::*;

match op {
crate::ast::UnaryOp::Minus | crate::ast::UnaryOp::Not => {
UnaryOp::Minus | UnaryOp::Not => {
match rhs_type {
// An error type will always return an error
Error => Ok((Error, false)),
Expand All @@ -1557,7 +1557,7 @@ impl Elaborator<'_> {

// The `!` prefix operator is not valid for Field, so if this is a numeric
// type we constrain it to just (non-Field) integer types.
if matches!(op, crate::ast::UnaryOp::Not) && rhs_type.is_numeric_value() {
if matches!(op, UnaryOp::Not) && rhs_type.is_numeric_value() {
let integer_type = Type::polymorphic_integer(self.interner);
self.unify(rhs_type, &integer_type, || {
TypeCheckError::InvalidUnaryOp {
Expand Down Expand Up @@ -1593,14 +1593,13 @@ impl Elaborator<'_> {
_ => Ok((rhs_type.clone(), true)),
}
}
crate::ast::UnaryOp::Reference { mutable } => {
let typ = Type::Reference(Box::new(rhs_type.follow_bindings()), *mutable);
UnaryOp::Reference { mutable } => {
let typ = Reference(Box::new(rhs_type.follow_bindings()), *mutable);
Ok((typ, false))
}
crate::ast::UnaryOp::Dereference { implicitly_added: _ } => {
UnaryOp::Dereference { implicitly_added: _ } => {
let element_type = self.interner.next_type_variable();
let make_expected =
|mutable| Type::Reference(Box::new(element_type.clone()), mutable);
let make_expected = |mutable| Reference(Box::new(element_type.clone()), mutable);

let immutable = make_expected(false);
let mutable = make_expected(true);
Expand Down Expand Up @@ -1686,7 +1685,7 @@ impl Elaborator<'_> {
let dereference_lhs = |this: &mut Self, lhs_type, element| {
let old_lhs = *access_lhs;
*access_lhs = this.interner.push_expr(HirExpression::Prefix(HirPrefixExpression::new(
crate::ast::UnaryOp::Dereference { implicitly_added: true },
UnaryOp::Dereference { implicitly_added: true },
old_lhs,
)));
this.interner.push_expr_type(old_lhs, lhs_type);
Expand Down Expand Up @@ -2228,7 +2227,7 @@ impl Elaborator<'_> {
}
}

fn function_info(&self, function_body_id: ExprId) -> (noirc_errors::Location, bool) {
fn function_info(&self, function_body_id: ExprId) -> (Location, bool) {
let (expr_location, empty_function) =
if let HirExpression::Block(block) = self.interner.expression(&function_body_id) {
let last_stmt = block.statements().last();
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir/comptime/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ pub enum InterpreterError {
}

#[allow(unused)]
pub(super) type IResult<T> = std::result::Result<T, InterpreterError>;
pub(super) type IResult<T> = Result<T, InterpreterError>;

impl From<InterpreterError> for CompilationError {
fn from(error: InterpreterError) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/hir/comptime/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,7 @@ fn evaluate_integer(typ: Type, value: SignedField, location: Location) -> IResul
Ok(Value::U128(value))
}
(Signedness::Signed, IntegerBitSize::One) => {
return Err(InterpreterError::TypeUnsupported { typ, location });
Err(InterpreterError::TypeUnsupported { typ, location })
}
(Signedness::Signed, IntegerBitSize::Eight) => {
let value = value
Expand All @@ -1596,7 +1596,7 @@ fn evaluate_integer(typ: Type, value: SignedField, location: Location) -> IResul
Ok(Value::I64(value))
}
(Signedness::Signed, IntegerBitSize::HundredTwentyEight) => {
return Err(InterpreterError::TypeUnsupported { typ, location });
Err(InterpreterError::TypeUnsupported { typ, location })
}
}
} else if let Type::TypeVariable(variable) = &typ {
Expand Down
22 changes: 11 additions & 11 deletions compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl Interpreter<'_, '_> {
fn failing_constraint<T>(
message: impl Into<String>,
location: Location,
call_stack: &im::Vector<Location>,
call_stack: &Vector<Location>,
) -> IResult<T> {
Err(InterpreterError::FailingConstraint {
message: Some(message.into()),
Expand Down Expand Up @@ -338,7 +338,7 @@ fn static_assert(
interner: &NodeInterner,
arguments: Vec<(Value, Location)>,
location: Location,
call_stack: &im::Vector<Location>,
call_stack: &Vector<Location>,
) -> IResult<Value> {
let (predicate, message) = check_two_arguments(arguments, location)?;
let predicate = get_bool(predicate)?;
Expand All @@ -359,7 +359,7 @@ fn str_as_bytes(
let string = check_one_argument(arguments, location)?;
let string = get_str(interner, string)?;

let bytes: im::Vector<Value> = string.bytes().map(Value::U8).collect();
let bytes: Vector<Value> = string.bytes().map(Value::U8).collect();
let byte_array_type = byte_array_type(bytes.len());
Ok(Value::Array(bytes, byte_array_type))
}
Expand Down Expand Up @@ -547,7 +547,7 @@ fn type_def_fields(
interner: &mut NodeInterner,
arguments: Vec<(Value, Location)>,
location: Location,
call_stack: &im::Vector<Location>,
call_stack: &Vector<Location>,
) -> IResult<Value> {
let (typ, generic_args) = check_two_arguments(arguments, location)?;
let struct_id = get_type_id(typ)?;
Expand All @@ -572,7 +572,7 @@ fn type_def_fields(
return Err(InterpreterError::FailingConstraint { message, location, call_stack });
}

let mut fields = im::Vector::new();
let mut fields = Vector::new();

if let Some(struct_fields) = struct_def.get_fields(&generic_args) {
for (field_name, field_type, visibility) in struct_fields {
Expand Down Expand Up @@ -606,7 +606,7 @@ fn type_def_fields_as_written(
let struct_def = interner.get_type(struct_id);
let struct_def = struct_def.borrow();

let mut fields = im::Vector::new();
let mut fields = Vector::new();

if let Some(struct_fields) = struct_def.get_fields_as_written() {
for field in struct_fields {
Expand Down Expand Up @@ -727,7 +727,7 @@ fn slice_remove(
interner: &mut NodeInterner,
arguments: Vec<(Value, Location)>,
location: Location,
call_stack: &im::Vector<Location>,
call_stack: &Vector<Location>,
) -> IResult<Value> {
let (slice, index) = check_two_arguments(arguments, location)?;

Expand Down Expand Up @@ -766,7 +766,7 @@ fn slice_pop_front(
interner: &mut NodeInterner,
arguments: Vec<(Value, Location)>,
location: Location,
call_stack: &im::Vector<Location>,
call_stack: &Vector<Location>,
) -> IResult<Value> {
let argument = check_one_argument(arguments, location)?;

Expand All @@ -783,7 +783,7 @@ fn slice_pop_back(
interner: &mut NodeInterner,
arguments: Vec<(Value, Location)>,
location: Location,
call_stack: &im::Vector<Location>,
call_stack: &Vector<Location>,
) -> IResult<Value> {
let argument = check_one_argument(arguments, location)?;

Expand Down Expand Up @@ -1471,7 +1471,7 @@ fn zeroed(return_type: Type, location: Location) -> Value {
Value::Zeroed(Type::Array(length_type, elem))
}
}
Type::Slice(_) => Value::Slice(im::Vector::new(), return_type),
Type::Slice(_) => Value::Slice(Vector::new(), return_type),
Type::Integer(sign, bits) => match (sign, bits) {
(Signedness::Unsigned, IntegerBitSize::One) => Value::U8(0),
(Signedness::Unsigned, IntegerBitSize::Eight) => Value::U8(0),
Expand Down Expand Up @@ -2098,7 +2098,7 @@ fn expr_as_member_access(
Shared::new(quote_ident(&member_access.rhs, location)),
]))
}
ExprValue::LValue(crate::ast::LValue::MemberAccess { object, field_name, location: _ }) => {
ExprValue::LValue(LValue::MemberAccess { object, field_name, location: _ }) => {
Some(Value::Tuple(vec![
Shared::new(Value::lvalue(*object)),
Shared::new(quote_ident(&field_name, location)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ fn gather_hir_pattern_tokens(
tokens.push(Token::Ident(name));
}
HirPattern::Mutable(pattern, _) => {
tokens.push(Token::Keyword(crate::token::Keyword::Mut));
tokens.push(Token::Keyword(Keyword::Mut));
gather_hir_pattern_tokens(interner, pattern, tokens);
}
HirPattern::Tuple(patterns, _) => {
Expand Down
Loading
Loading