@@ -768,8 +768,7 @@ fn extract_captures_inner(
768768/// ```
769769///
770770/// Template bodies (`=> (kind …)`) never carry an annotation — the
771- /// output kind is the template root. The shorthand `=> kind` (no
772- /// body) also carries no annotation. See `parse_rule_top` for dispatch.
771+ /// output kind is the template root.
773772#[ derive( Clone , Debug ) ]
774773struct ReturnAnnotation {
775774 kind : Ident ,
@@ -793,7 +792,6 @@ enum AnnotationMultiplicity {
793792/// `kind {` → annotation (single)
794793/// `kind? {` → annotation (optional)
795794/// `kind* {` → annotation (repeated)
796- /// `kind` → shorthand form (no `{` follows) — NOT an annotation
797795/// anything else → template or bare block — NOT an annotation
798796fn try_consume_return_annotation ( tokens : & mut Tokens ) -> Result < Option < ReturnAnnotation > > {
799797 // Must start with an identifier (the kind name).
@@ -881,15 +879,13 @@ pub fn parse_rule_top(input: TokenStream) -> Result<TokenStream> {
881879 let raw_bindings = capture_bindings ( raw_captures. into_iter ( ) ) ;
882880 let translated_bindings = capture_bindings ( translated_captures. into_iter ( ) ) ;
883881
884- // Parse transform: the token(s) after `=>` fall into one of three
882+ // Parse transform: the token(s) after `=>` fall into one of two
885883 // shapes, dispatched in order:
886884 //
887885 // 1. `kind [? | *] { rust_body }` — annotated Rust body (NEW).
888886 // Static-analysis-ready: the annotation declares the output
889887 // kind and multiplicity in the schema's own vocabulary.
890- // 2. `kind` alone — shorthand: emit `(kind field: {@cap})…` from
891- // the query's captures.
892- // 3. anything else — full template form (`(kind …)` or bare
888+ // 2. anything else — full template form (`(kind …)` or bare
893889 // `{ … }` splice via `parse_direct_list`).
894890 let annotation = try_consume_return_annotation ( & mut tokens) ?;
895891
@@ -926,65 +922,6 @@ pub fn parse_rule_top(input: TokenStream) -> Result<TokenStream> {
926922 yeast:: IntoFieldIds :: extend_into( __value, & mut __ids) ;
927923 __ids
928924 }
929- } else if peek_is_field ( & mut tokens) && {
930- // Shorthand form: bare identifier = output node kind.
931- // Auto-generate template from captures.
932- let mut lookahead = tokens. clone ( ) ;
933- lookahead. next ( ) ; // skip ident
934- lookahead. peek ( ) . is_none ( ) // nothing after = shorthand
935- } {
936- let output_kind = expect_ident ( & mut tokens, "expected output node kind" ) ?;
937- let output_kind_str = output_kind. to_string ( ) ;
938-
939- // Generate field assignments from captures
940- let field_stmts: Vec < TokenStream > = captures
941- . iter ( )
942- . map ( |cap| {
943- let name = Ident :: new ( & cap. name , Span :: call_site ( ) ) ;
944- let name_str = & cap. name ;
945- match cap. multiplicity {
946- CaptureMultiplicity :: Repeated => quote ! {
947- let __field_id = #ctx_ident. ast. field_id_for_name( #name_str)
948- . unwrap_or_else( || panic!( "field '{}' not found" , #name_str) ) ;
949- __fields. insert(
950- __field_id,
951- #name. into_iter( )
952- . map( :: std:: convert:: Into :: <yeast:: Id >:: into)
953- . collect( ) ,
954- ) ;
955- } ,
956- CaptureMultiplicity :: Optional => quote ! {
957- let __field_id = #ctx_ident. ast. field_id_for_name( #name_str)
958- . unwrap_or_else( || panic!( "field '{}' not found" , #name_str) ) ;
959- if let Some ( __id) = #name {
960- __fields. entry( __field_id) . or_insert_with( Vec :: new)
961- . push( :: std:: convert:: Into :: <yeast:: Id >:: into( __id) ) ;
962- }
963- } ,
964- CaptureMultiplicity :: Single => quote ! {
965- let __field_id = #ctx_ident. ast. field_id_for_name( #name_str)
966- . unwrap_or_else( || panic!( "field '{}' not found" , #name_str) ) ;
967- __fields. entry( __field_id) . or_insert_with( Vec :: new)
968- . push( :: std:: convert:: Into :: <yeast:: Id >:: into( #name) ) ;
969- } ,
970- }
971- } )
972- . collect ( ) ;
973-
974- quote ! {
975- let __kind = #ctx_ident. ast. id_for_node_kind( #output_kind_str)
976- . unwrap_or_else( || panic!( "node kind '{}' not found" , #output_kind_str) ) ;
977- let mut __fields = std:: collections:: BTreeMap :: new( ) ;
978- #( #field_stmts) *
979- let __id = #ctx_ident. ast. create_node_with_range(
980- __kind,
981- yeast:: NodeContent :: DynamicString ( String :: new( ) ) ,
982- __fields,
983- true ,
984- __source_range,
985- ) ;
986- vec![ __id]
987- }
988925 } else {
989926 // Reject bare `{ ... }` transforms — they used to be accepted
990927 // as either a Rust body producing a `Vec<Id>` or a template
@@ -1482,8 +1419,5 @@ mod rules_tests {
14821419 // Match expressions inside a block: `=>` is inside braces.
14831420 let toks = quote ! { { match x { 1 => 2 , _ => 3 } } } ;
14841421 assert ! ( !has_top_level_arrow( & toks) ) ;
1485- // Bare shorthand form: top-level `=>` followed by a bare ident.
1486- let toks = quote ! { ( a) => kind } ;
1487- assert ! ( has_top_level_arrow( & toks) ) ;
14881422 }
14891423}
0 commit comments