From a82b72f7e15a2f4fb01ac99f843b24cfc86a68b7 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Wed, 26 Jun 2024 23:19:12 +0000 Subject: [PATCH] chore: fix --- .../compiler/noirc_frontend/src/elaborator/lints.rs | 9 --------- .../compiler/noirc_frontend/src/elaborator/mod.rs | 1 - .../noirc_frontend/src/hir/resolution/errors.rs | 7 ------- .../noirc_frontend/src/hir/resolution/resolver.rs | 10 +--------- noir/noir-repo/tooling/nargo_fmt/tests/expected/fn.nr | 4 ---- noir/noir-repo/tooling/nargo_fmt/tests/input/fn.nr | 5 ----- 6 files changed, 1 insertion(+), 35 deletions(-) diff --git a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/lints.rs b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/lints.rs index 4859ac5f97c..b86912940eb 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/lints.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/lints.rs @@ -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 { - 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)], diff --git a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs index 37ad74b78b0..cbc480358db 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs @@ -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) }); diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs index 06f6dda7142..319f38e9741 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs @@ -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")] @@ -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"), diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/resolver.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/resolver.rs index 01f58ba4c27..4613ca4ac55 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/resolver.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/resolver.rs @@ -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; @@ -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() { diff --git a/noir/noir-repo/tooling/nargo_fmt/tests/expected/fn.nr b/noir/noir-repo/tooling/nargo_fmt/tests/expected/fn.nr index 961e67faf1c..3d231cd3f7f 100644 --- a/noir/noir-repo/tooling/nargo_fmt/tests/expected/fn.nr +++ b/noir/noir-repo/tooling/nargo_fmt/tests/expected/fn.nr @@ -61,7 +61,3 @@ fn main( ) {} pub fn from_baz(x: [Field; crate::foo::MAGIC_NUMBER]) {} - -fn whitespace_before_generics(foo: T) {} - -fn more_whitespace_before_generics(foo: T) {} diff --git a/noir/noir-repo/tooling/nargo_fmt/tests/input/fn.nr b/noir/noir-repo/tooling/nargo_fmt/tests/input/fn.nr index 03806b0fef9..1c6d201fa39 100644 --- a/noir/noir-repo/tooling/nargo_fmt/tests/input/fn.nr +++ b/noir/noir-repo/tooling/nargo_fmt/tests/input/fn.nr @@ -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) {}