Skip to content

Commit c2a00c4

Browse files
committed
Add tests for attributes not in meta-item form
1 parent cf47ff8 commit c2a00c4

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

corpus/declarations.txt

+85
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,91 @@ mod macos_only {
812812
(identifier)
813813
value: (string_literal))))))))
814814

815+
============================================
816+
Attribute macros
817+
============================================
818+
819+
foo(#[attr(=> arbitrary tokens <=)] x, y);
820+
821+
foo(#[bar(some tokens are special in other contexts: $/';()*()+.)] x);
822+
823+
---
824+
825+
(source_file
826+
(call_expression
827+
function: (identifier)
828+
arguments: (arguments
829+
(attribute_item (attr_item
830+
(identifier)
831+
arguments: (delim_token_tree (identifier) (identifier))))
832+
(identifier)
833+
(identifier)))
834+
(call_expression
835+
function: (identifier)
836+
arguments: (arguments
837+
(attribute_item (attr_item
838+
(identifier)
839+
arguments: (delim_token_tree
840+
(identifier)
841+
(identifier)
842+
(identifier)
843+
(identifier)
844+
(identifier)
845+
(identifier)
846+
(identifier)
847+
(delim_token_tree)
848+
(delim_token_tree))))
849+
(identifier))))
850+
851+
============================================
852+
Derive macro helper attributes
853+
============================================
854+
855+
use thiserror::Error;
856+
857+
#[derive(Error, Debug)]
858+
pub enum Error {
859+
#[error("first letter must be lowercase but was {:?}", first_char(.0))]
860+
WrongCase(String),
861+
#[error("invalid index {idx}, expected at least {} and at most {}", .limits.lo, .limits.hi)]
862+
OutOfBounds { idx: usize, limits: Limits },
863+
}
864+
865+
---
866+
867+
(source_file
868+
(use_declaration
869+
(scoped_identifier (identifier) (identifier)))
870+
(attribute_item
871+
(meta_item (identifier)
872+
(meta_arguments
873+
(meta_item (identifier))
874+
(meta_item (identifier)))))
875+
(enum_item
876+
(visibility_modifier)
877+
(type_identifier)
878+
(enum_variant_list
879+
(attribute_item (attr_item
880+
(identifier)
881+
(delim_token_tree
882+
(string_literal)
883+
(identifier)
884+
(delim_token_tree (integer_literal)))))
885+
(enum_variant (identifier)
886+
(ordered_field_declaration_list (type_identifier)))
887+
(attribute_item (attr_item
888+
(identifier)
889+
(delim_token_tree
890+
(string_literal)
891+
(identifier)
892+
(identifier)
893+
(identifier)
894+
(identifier))))
895+
(enum_variant (identifier)
896+
(field_declaration_list
897+
(field_declaration (field_identifier) (primitive_type))
898+
(field_declaration (field_identifier) (type_identifier)))))))
899+
815900
============================================
816901
Attributes and Expressions
817902
============================================

0 commit comments

Comments
 (0)