diff --git a/compiler/noirc_frontend/src/hir/resolution/resolver.rs b/compiler/noirc_frontend/src/hir/resolution/resolver.rs index 0556698fb58..9cd28d80784 100644 --- a/compiler/noirc_frontend/src/hir/resolution/resolver.rs +++ b/compiler/noirc_frontend/src/hir/resolution/resolver.rs @@ -239,9 +239,8 @@ impl<'a> Resolver<'a> { }; let (hir_func, func_meta) = self.intern_function(NoirFunction { kind, def }, func_id); - let func_scope_tree = self.scopes.end_function(); - self.check_for_unused_variables_in_scope_tree(func_scope_tree); - + let _ = self.scopes.end_function(); + // Don't check the scope tree for unused variables, they can't be used in a declaration anyway. self.trait_bounds.clear(); (hir_func, func_meta) } diff --git a/compiler/noirc_frontend/src/tests.rs b/compiler/noirc_frontend/src/tests.rs index 2619189ee8d..7b2a94b4f10 100644 --- a/compiler/noirc_frontend/src/tests.rs +++ b/compiler/noirc_frontend/src/tests.rs @@ -48,15 +48,6 @@ mod test { }); } - /// Many of the tests in this file have odd unused variable warnings which do not occur - /// when running an identical program using `nargo execute`. They're filtered out of the - /// errors returned by `get_errors` for now. - pub(crate) fn remove_unused_variable_warnings(errors: &mut Vec<(CompilationError, FileId)>) { - errors.retain(|(error, _)| { - !matches!(error, CompilationError::ResolverError(ResolverError::UnusedVariable { .. })) - }); - } - pub(crate) fn get_program( src: &str, ) -> (ParsedModule, Context, Vec<(CompilationError, FileId)>) { @@ -97,9 +88,7 @@ mod test { } pub(crate) fn get_program_errors(src: &str) -> Vec<(CompilationError, FileId)> { - let (_program, _context, mut errors) = get_program(src); - remove_unused_variable_warnings(&mut errors); - errors + get_program(src).2 } #[test] @@ -797,7 +786,7 @@ mod test { } "#; - let (_, _, errors) = get_program(src); + let errors = get_program_errors(src); assert!(errors.len() == 1, "Expected 1 error, got: {:?}", errors); // It should be regarding the unused variable match &errors[0].0 { @@ -874,7 +863,7 @@ mod test { } "#; - let (_, _, errors) = get_program(src); + let errors = get_program_errors(src); assert!(errors.len() == 3, "Expected 3 errors, got: {:?}", errors); // Errors are: