Skip to content

Commit

Permalink
chore: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Jun 26, 2024
1 parent bacbcdd commit a82b72f
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,6 @@ pub(super) fn recursive_non_entrypoint_function(
}
}

/// Test functions cannot have arguments in order to be executable.
pub(super) fn test_function_with_args(func: &NoirFunction) -> Option<ResolverError> {
if func.attributes().is_test_function() && !func.parameters().is_empty() {
Some(ResolverError::TestFunctionHasParameters { span: func.name_ident().span() })
} else {
None
}
}

/// Check that we are not passing a mutable reference from a constrained runtime to an unconstrained runtime.
pub(super) fn unconstrained_function_args(
function_args: &[(Type, ExprId, Span)],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ impl<'context> Elaborator<'context> {
self.run_lint(|elaborator| {
lints::low_level_function_outside_stdlib(func, elaborator.crate_id).map(Into::into)
});
self.run_lint(|_| lints::test_function_with_args(func).map(Into::into));
self.run_lint(|_| {
lints::recursive_non_entrypoint_function(func, is_entry_point).map(Into::into)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ pub enum ResolverError {
NoSuchNumericTypeVariable { path: crate::ast::Path },
#[error("Closures cannot capture mutable variables")]
CapturedMutableVariable { span: Span },
#[error("Test functions are not allowed to have any parameters")]
TestFunctionHasParameters { span: Span },
#[error("Only struct types can be used in constructor expressions")]
NonStructUsedInConstructor { typ: Type, span: Span },
#[error("Only struct types can have generics")]
Expand Down Expand Up @@ -245,11 +243,6 @@ impl<'a> From<&'a ResolverError> for Diagnostic {
"Mutable variable".into(),
*span,
),
ResolverError::TestFunctionHasParameters { span } => Diagnostic::simple_error(
"Test functions cannot have any parameters".into(),
"Try removing the parameters or moving the test into a wrapper function".into(),
*span,
),
ResolverError::NonStructUsedInConstructor { typ, span } => Diagnostic::simple_error(
"Only struct types can be used in constructor expressions".into(),
format!("{typ} has no fields to construct it with"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::hir_def::expr::{
use crate::hir_def::function::FunctionBody;
use crate::hir_def::traits::{Trait, TraitConstraint};
use crate::macros_api::SecondaryAttribute;
use crate::token::{Attributes, FunctionAttribute};
use crate::token::Attributes;
use regex::Regex;
use std::collections::{BTreeMap, BTreeSet, HashSet};
use std::rc::Rc;
Expand Down Expand Up @@ -1042,14 +1042,6 @@ impl<'a> Resolver<'a> {
});
}

if matches!(attributes.function, Some(FunctionAttribute::Test { .. }))
&& !parameters.is_empty()
{
self.push_err(ResolverError::TestFunctionHasParameters {
span: func.name_ident().span(),
});
}

let mut typ = Type::Function(parameter_types, return_type, Box::new(Type::Unit));

if !generics.is_empty() {
Expand Down
4 changes: 0 additions & 4 deletions noir/noir-repo/tooling/nargo_fmt/tests/expected/fn.nr
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,3 @@ fn main(
) {}

pub fn from_baz(x: [Field; crate::foo::MAGIC_NUMBER]) {}

fn whitespace_before_generics<T>(foo: T) {}

fn more_whitespace_before_generics<T>(foo: T) {}
5 changes: 0 additions & 5 deletions noir/noir-repo/tooling/nargo_fmt/tests/input/fn.nr
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,3 @@ fn main(
) {}

pub fn from_baz(x: [Field; crate::foo::MAGIC_NUMBER]) {}

fn whitespace_before_generics < T > (foo: T) {}

fn more_whitespace_before_generics <
T > (foo: T) {}

0 comments on commit a82b72f

Please sign in to comment.