@@ -996,6 +996,93 @@ mod macos_only {
996
996
(identifier)
997
997
value: (string_literal))))))))
998
998
999
+ ================================================================================
1000
+ Attribute macros
1001
+ ================================================================================
1002
+
1003
+ foo(#[attr(=> arbitrary tokens <=)] x, y);
1004
+
1005
+ foo(#[bar(some tokens are special in other contexts: $/';()*()+.)] x);
1006
+
1007
+ --------------------------------------------------------------------------------
1008
+
1009
+ (source_file
1010
+ (expression_statement
1011
+ (call_expression
1012
+ function: (identifier)
1013
+ arguments: (arguments
1014
+ (attribute_item (attr_item
1015
+ (identifier)
1016
+ arguments: (delim_token_tree (identifier) (identifier))))
1017
+ (identifier)
1018
+ (identifier))))
1019
+ (expression_statement
1020
+ (call_expression
1021
+ function: (identifier)
1022
+ arguments: (arguments
1023
+ (attribute_item (attr_item
1024
+ (identifier)
1025
+ arguments: (delim_token_tree
1026
+ (identifier)
1027
+ (identifier)
1028
+ (identifier)
1029
+ (identifier)
1030
+ (identifier)
1031
+ (identifier)
1032
+ (identifier)
1033
+ (delim_token_tree)
1034
+ (delim_token_tree))))
1035
+ (identifier)))))
1036
+
1037
+ ================================================================================
1038
+ Derive macro helper attributes
1039
+ ================================================================================
1040
+
1041
+ use thiserror::Error;
1042
+
1043
+ #[derive(Error, Debug)]
1044
+ pub enum Error {
1045
+ #[error("first letter must be lowercase but was {:?}", first_char(.0))]
1046
+ WrongCase(String),
1047
+ #[error("invalid index {idx}, expected at least {} and at most {}", .limits.lo, .limits.hi)]
1048
+ OutOfBounds { idx: usize, limits: Limits },
1049
+ }
1050
+
1051
+ --------------------------------------------------------------------------------
1052
+
1053
+ (source_file
1054
+ (use_declaration
1055
+ (scoped_identifier (identifier) (identifier)))
1056
+ (attribute_item
1057
+ (meta_item (identifier)
1058
+ (meta_arguments
1059
+ (meta_item (identifier))
1060
+ (meta_item (identifier)))))
1061
+ (enum_item
1062
+ (visibility_modifier)
1063
+ (type_identifier)
1064
+ (enum_variant_list
1065
+ (attribute_item (attr_item
1066
+ (identifier)
1067
+ (delim_token_tree
1068
+ (string_literal)
1069
+ (identifier)
1070
+ (delim_token_tree (integer_literal)))))
1071
+ (enum_variant (identifier)
1072
+ (ordered_field_declaration_list (type_identifier)))
1073
+ (attribute_item (attr_item
1074
+ (identifier)
1075
+ (delim_token_tree
1076
+ (string_literal)
1077
+ (identifier)
1078
+ (identifier)
1079
+ (identifier)
1080
+ (identifier))))
1081
+ (enum_variant (identifier)
1082
+ (field_declaration_list
1083
+ (field_declaration (field_identifier) (primitive_type))
1084
+ (field_declaration (field_identifier) (type_identifier)))))))
1085
+
999
1086
================================================================================
1000
1087
Attributes and Expressions
1001
1088
================================================================================
0 commit comments