Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename CustomAtrribute to CustomAttribute #6038

Merged
merged 1 commit into from
Sep 13, 2024
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
6 changes: 3 additions & 3 deletions compiler/noirc_frontend/src/ast/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
InternedUnresolvedTypeData, QuotedTypeId,
},
parser::{Item, ItemKind, ParsedSubModule},
token::{CustomAtrribute, SecondaryAttribute, Tokens},
token::{CustomAttribute, SecondaryAttribute, Tokens},
ParsedModule, QuotedType,
};

Expand Down Expand Up @@ -461,7 +461,7 @@
true
}

fn visit_custom_attribute(&mut self, _: &CustomAtrribute, _target: AttributeTarget) {}
fn visit_custom_attribute(&mut self, _: &CustomAttribute, _target: AttributeTarget) {}
}

impl ParsedModule {
Expand Down Expand Up @@ -1276,8 +1276,8 @@
UnresolvedTypeData::Unspecified => visitor.visit_unspecified_type(self.span),
UnresolvedTypeData::Quoted(typ) => visitor.visit_quoted_type(typ, self.span),
UnresolvedTypeData::FieldElement => visitor.visit_field_element_type(self.span),
UnresolvedTypeData::Integer(signdness, size) => {

Check warning on line 1279 in compiler/noirc_frontend/src/ast/visitor.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (signdness)
visitor.visit_integer_type(*signdness, *size, self.span);

Check warning on line 1280 in compiler/noirc_frontend/src/ast/visitor.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (signdness)
}
UnresolvedTypeData::Bool => visitor.visit_bool_type(self.span),
UnresolvedTypeData::Unit => visitor.visit_unit_type(self.span),
Expand Down Expand Up @@ -1377,7 +1377,7 @@
}
}

impl CustomAtrribute {
impl CustomAttribute {
pub fn accept(&self, target: AttributeTarget, visitor: &mut impl Visitor) {
visitor.visit_custom_attribute(self, target);
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/elaborator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::{
DefinitionKind, DependencyId, ExprId, FuncId, FunctionModifiers, GlobalId, ReferenceId,
TraitId, TypeAliasId,
},
token::CustomAtrribute,
token::CustomAttribute,
Shared, Type, TypeVariable,
};
use crate::{
Expand Down Expand Up @@ -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<CustomAtrribute> = attributes.cloned().collect();
let attributes: Vec<CustomAttribute> = attributes.cloned().collect();

let meta = FuncMeta {
name: name_ident,
Expand Down
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/hir_def/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -167,7 +167,7 @@ pub struct FuncMeta {
pub self_type: Option<Type>,

/// Custom attributes attached to this function.
pub custom_attributes: Vec<CustomAtrribute>,
pub custom_attributes: Vec<CustomAttribute>,
}

#[derive(Debug, Clone)]
Expand Down
6 changes: 3 additions & 3 deletions compiler/noirc_frontend/src/lexer/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
position: Position,
done: bool,
skip_comments: bool,
skip_whitespaces: bool,

Check warning on line 21 in compiler/noirc_frontend/src/lexer/lexer.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (whitespaces)
max_integer: BigInt,
}

Expand Down Expand Up @@ -46,8 +46,8 @@
position: 0,
done: false,
skip_comments: true,
skip_whitespaces: true,

Check warning on line 49 in compiler/noirc_frontend/src/lexer/lexer.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (whitespaces)
max_integer: BigInt::from_biguint(num_bigint::Sign::Plus, FieldElement::modulus())

Check warning on line 50 in compiler/noirc_frontend/src/lexer/lexer.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (biguint)
- BigInt::one(),
}
}
Expand All @@ -57,8 +57,8 @@
self
}

pub fn skip_whitespaces(mut self, flag: bool) -> Self {

Check warning on line 60 in compiler/noirc_frontend/src/lexer/lexer.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (whitespaces)
self.skip_whitespaces = flag;

Check warning on line 61 in compiler/noirc_frontend/src/lexer/lexer.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (whitespaces)
self
}

Expand Down Expand Up @@ -101,7 +101,7 @@
match self.next_char() {
Some(x) if Self::is_code_whitespace(x) => {
let spanned = self.eat_whitespace(x);
if self.skip_whitespaces {

Check warning on line 104 in compiler/noirc_frontend/src/lexer/lexer.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (whitespaces)
self.next_token()
} else {
Ok(spanned)
Expand Down Expand Up @@ -690,7 +690,7 @@
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() {
Expand Down Expand Up @@ -818,7 +818,7 @@
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)
Expand Down Expand Up @@ -916,7 +916,7 @@
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),
Expand Down Expand Up @@ -1243,7 +1243,7 @@
// (expected_token_discriminator, strings_to_lex)
// expected_token_discriminator matches a given token when
// std::mem::discriminant returns the same discriminant for both.
fn blns_base64_to_statements(base64_str: String) -> Vec<(Option<Token>, Vec<String>)> {

Check warning on line 1246 in compiler/noirc_frontend/src/lexer/lexer.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (blns)
use base64::engine::general_purpose;
use std::borrow::Cow;
use std::io::Cursor;
Expand Down Expand Up @@ -1301,7 +1301,7 @@
fn test_big_list_of_naughty_strings() {
use std::mem::discriminant;

let blns_contents = include_str!("./blns/blns.base64.json");

Check warning on line 1304 in compiler/noirc_frontend/src/lexer/lexer.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (blns)
let blns_base64: Vec<String> =
serde_json::from_str(blns_contents).expect("BLNS json invalid");
for blns_base64_str in blns_base64 {
Expand Down
10 changes: 5 additions & 5 deletions compiler/noirc_frontend/src/lexer/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -910,15 +910,15 @@ pub enum SecondaryAttribute {
ContractLibraryMethod,
Export,
Field(String),
Custom(CustomAtrribute),
Custom(CustomAttribute),
Abi(String),

/// A variable-argument comptime function.
Varargs,
}

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 {
Expand Down Expand Up @@ -959,15 +959,15 @@ 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,
// The span for the attribute contents (what's inside `#[...]`)
pub contents_span: Span,
}

impl CustomAtrribute {
impl CustomAttribute {
fn name(&self) -> Option<String> {
let mut lexer = Lexer::new(&self.contents);
let token = lexer.next()?.ok()?;
Expand Down
4 changes: 2 additions & 2 deletions tooling/lsp/src/requests/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Loading