Skip to content
Merged
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
26 changes: 1 addition & 25 deletions compiler/noirc_frontend/src/parser/parser/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,7 @@ impl Parser<'_> {
}

fn parse_non_tag_attribute(&mut self, start_location: Location) -> Attribute {
if matches!(&self.token.token(), Token::Keyword(..))
&& (self.next_is(Token::LeftParen) || self.next_is(Token::RightBracket))
{
// This is a Meta attribute with the syntax `keyword(arg1, arg2, .., argN)`
let path = Path::from_single(self.token.to_string(), self.current_token_location);
let name = MetaAttributeName::Path(path);
self.bump();
self.parse_meta_attribute(name, start_location)
} else if let Some(path) = self.parse_path_no_turbofish() {
if let Some(path) = self.parse_path_no_turbofish() {
if let Some(ident) = path.as_ident() {
if ident.as_str() == "test" {
// The test attribute is the only secondary attribute that has `a = b` in its syntax
Expand Down Expand Up @@ -764,22 +756,6 @@ mod tests {
assert!(meta.arguments.is_empty());
}

#[test]
fn parses_meta_attribute_single_identifier_as_keyword() {
let src = "#[dep]";
let mut parser = Parser::for_str_with_dummy_file(src);
let (attribute, _span) = parser.parse_attribute().unwrap();
expect_no_errors(&parser.errors);
let Attribute::Secondary(attribute) = attribute else {
panic!("Expected secondary attribute");
};
let SecondaryAttributeKind::Meta(meta) = attribute.kind else {
panic!("Expected meta attribute");
};
assert_eq!(meta.name.to_string(), "dep");
assert!(meta.arguments.is_empty());
}

#[test]
fn parses_meta_attribute_single_identifier_with_arguments() {
let src = "#[foo(1, 2, 3)]";
Expand Down
Loading