From cb88a90a3998dbe32a6bc83d72679b871f5898f8 Mon Sep 17 00:00:00 2001 From: Ary Borenszweig Date: Fri, 13 Sep 2024 16:06:56 -0300 Subject: [PATCH] chore: rename CustomAtrribute to CustomAttribute --- compiler/noirc_frontend/src/ast/visitor.rs | 6 +++--- compiler/noirc_frontend/src/elaborator/mod.rs | 4 ++-- compiler/noirc_frontend/src/hir_def/function.rs | 4 ++-- compiler/noirc_frontend/src/lexer/lexer.rs | 6 +++--- compiler/noirc_frontend/src/lexer/token.rs | 10 +++++----- tooling/lsp/src/requests/completion.rs | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/compiler/noirc_frontend/src/ast/visitor.rs b/compiler/noirc_frontend/src/ast/visitor.rs index 8f207a55e9a..261440babb7 100644 --- a/compiler/noirc_frontend/src/ast/visitor.rs +++ b/compiler/noirc_frontend/src/ast/visitor.rs @@ -16,7 +16,7 @@ use crate::{ InternedUnresolvedTypeData, QuotedTypeId, }, parser::{Item, ItemKind, ParsedSubModule}, - token::{CustomAtrribute, SecondaryAttribute, Tokens}, + token::{CustomAttribute, SecondaryAttribute, Tokens}, ParsedModule, QuotedType, }; @@ -461,7 +461,7 @@ pub trait Visitor { true } - fn visit_custom_attribute(&mut self, _: &CustomAtrribute, _target: AttributeTarget) {} + fn visit_custom_attribute(&mut self, _: &CustomAttribute, _target: AttributeTarget) {} } impl ParsedModule { @@ -1377,7 +1377,7 @@ impl SecondaryAttribute { } } -impl CustomAtrribute { +impl CustomAttribute { pub fn accept(&self, target: AttributeTarget, visitor: &mut impl Visitor) { visitor.visit_custom_attribute(self, target); } diff --git a/compiler/noirc_frontend/src/elaborator/mod.rs b/compiler/noirc_frontend/src/elaborator/mod.rs index 6871152edb5..dbfbe9d4558 100644 --- a/compiler/noirc_frontend/src/elaborator/mod.rs +++ b/compiler/noirc_frontend/src/elaborator/mod.rs @@ -29,7 +29,7 @@ use crate::{ DefinitionKind, DependencyId, ExprId, FuncId, FunctionModifiers, GlobalId, ReferenceId, TraitId, TypeAliasId, }, - token::CustomAtrribute, + token::CustomAttribute, Shared, Type, TypeVariable, }; use crate::{ @@ -800,7 +800,7 @@ impl<'context> Elaborator<'context> { let attributes = func.secondary_attributes().iter(); let attributes = attributes.filter_map(|secondary_attribute| secondary_attribute.as_custom()); - let attributes: Vec = attributes.cloned().collect(); + let attributes: Vec = attributes.cloned().collect(); let meta = FuncMeta { name: name_ident, diff --git a/compiler/noirc_frontend/src/hir_def/function.rs b/compiler/noirc_frontend/src/hir_def/function.rs index 8e3baef1d00..39c87607446 100644 --- a/compiler/noirc_frontend/src/hir_def/function.rs +++ b/compiler/noirc_frontend/src/hir_def/function.rs @@ -10,7 +10,7 @@ use crate::graph::CrateId; use crate::hir::def_map::LocalModuleId; use crate::macros_api::{BlockExpression, StructId}; use crate::node_interner::{ExprId, NodeInterner, TraitId, TraitImplId}; -use crate::token::CustomAtrribute; +use crate::token::CustomAttribute; use crate::{ResolvedGeneric, Type}; /// A Hir function is a block expression with a list of statements. @@ -167,7 +167,7 @@ pub struct FuncMeta { pub self_type: Option, /// Custom attributes attached to this function. - pub custom_attributes: Vec, + pub custom_attributes: Vec, } #[derive(Debug, Clone)] diff --git a/compiler/noirc_frontend/src/lexer/lexer.rs b/compiler/noirc_frontend/src/lexer/lexer.rs index 7fbbb4fccef..a4ec19ba363 100644 --- a/compiler/noirc_frontend/src/lexer/lexer.rs +++ b/compiler/noirc_frontend/src/lexer/lexer.rs @@ -690,7 +690,7 @@ mod tests { use iter_extended::vecmap; use super::*; - use crate::token::{CustomAtrribute, FunctionAttribute, SecondaryAttribute, TestScope}; + use crate::token::{CustomAttribute, FunctionAttribute, SecondaryAttribute, TestScope}; #[test] fn test_single_double_char() { @@ -818,7 +818,7 @@ mod tests { let token = lexer.next_token().unwrap(); assert_eq!( token.token(), - &Token::Attribute(Attribute::Secondary(SecondaryAttribute::Custom(CustomAtrribute { + &Token::Attribute(Attribute::Secondary(SecondaryAttribute::Custom(CustomAttribute { contents: "custom(hello)".to_string(), span: Span::from(0..16), contents_span: Span::from(2..15) @@ -916,7 +916,7 @@ mod tests { let token = lexer.next_token().unwrap(); assert_eq!( token.token(), - &Token::InnerAttribute(SecondaryAttribute::Custom(CustomAtrribute { + &Token::InnerAttribute(SecondaryAttribute::Custom(CustomAttribute { contents: "something".to_string(), span: Span::from(0..13), contents_span: Span::from(3..12), diff --git a/compiler/noirc_frontend/src/lexer/token.rs b/compiler/noirc_frontend/src/lexer/token.rs index 83b82623ae7..62aa9ea0cdf 100644 --- a/compiler/noirc_frontend/src/lexer/token.rs +++ b/compiler/noirc_frontend/src/lexer/token.rs @@ -801,7 +801,7 @@ impl Attribute { ["varargs"] => Attribute::Secondary(SecondaryAttribute::Varargs), tokens => { tokens.iter().try_for_each(|token| validate(token))?; - Attribute::Secondary(SecondaryAttribute::Custom(CustomAtrribute { + Attribute::Secondary(SecondaryAttribute::Custom(CustomAttribute { contents: word.to_owned(), span, contents_span, @@ -910,7 +910,7 @@ pub enum SecondaryAttribute { ContractLibraryMethod, Export, Field(String), - Custom(CustomAtrribute), + Custom(CustomAttribute), Abi(String), /// A variable-argument comptime function. @@ -918,7 +918,7 @@ pub enum SecondaryAttribute { } impl SecondaryAttribute { - pub(crate) fn as_custom(&self) -> Option<&CustomAtrribute> { + pub(crate) fn as_custom(&self) -> Option<&CustomAttribute> { if let Self::Custom(attribute) = self { Some(attribute) } else { @@ -959,7 +959,7 @@ impl fmt::Display for SecondaryAttribute { } #[derive(PartialEq, Eq, Hash, Debug, Clone, PartialOrd, Ord)] -pub struct CustomAtrribute { +pub struct CustomAttribute { pub contents: String, // The span of the entire attribute, including leading `#[` and trailing `]` pub span: Span, @@ -967,7 +967,7 @@ pub struct CustomAtrribute { pub contents_span: Span, } -impl CustomAtrribute { +impl CustomAttribute { fn name(&self) -> Option { let mut lexer = Lexer::new(&self.contents); let token = lexer.next()?.ok()?; diff --git a/tooling/lsp/src/requests/completion.rs b/tooling/lsp/src/requests/completion.rs index 96eb8b2320a..d8be6c72aec 100644 --- a/tooling/lsp/src/requests/completion.rs +++ b/tooling/lsp/src/requests/completion.rs @@ -28,7 +28,7 @@ use noirc_frontend::{ macros_api::{ModuleDefId, NodeInterner}, node_interner::ReferenceId, parser::{Item, ItemKind, ParsedSubModule}, - token::CustomAtrribute, + token::CustomAttribute, ParsedModule, StructType, Type, }; use sort_text::underscore_sort_text; @@ -1434,7 +1434,7 @@ impl<'a> Visitor for NodeFinder<'a> { false } - fn visit_custom_attribute(&mut self, attribute: &CustomAtrribute, target: AttributeTarget) { + fn visit_custom_attribute(&mut self, attribute: &CustomAttribute, target: AttributeTarget) { if self.byte_index != attribute.contents_span.end() as usize { return; }