@@ -91,7 +91,6 @@ pub(crate) fn fixup_syntax(
9191 preorder. skip_subtree ( ) ;
9292 continue ;
9393 }
94-
9594 // In some other situations, we can fix things by just appending some tokens.
9695 match_ast ! {
9796 match node {
@@ -276,6 +275,62 @@ pub(crate) fn fixup_syntax(
276275 ] ) ;
277276 }
278277 } ,
278+ ast:: RecordExprField ( it) => {
279+ if let Some ( colon) = it. colon_token( ) {
280+ if it. name_ref( ) . is_some( ) {
281+ append. insert( colon. into( ) , vec![
282+ Leaf :: Ident ( Ident {
283+ text: "__ra_fixup" . into( ) ,
284+ span: fake_span( node_range)
285+ } )
286+ ] ) ;
287+ }
288+ }
289+ } ,
290+ ast:: Path ( it) => {
291+ if let Some ( colon) = it. coloncolon_token( ) {
292+ if it. segment( ) . is_none( ) {
293+ append. insert( colon. into( ) , vec![
294+ Leaf :: Ident ( Ident {
295+ text: "__ra_fixup" . into( ) ,
296+ span: fake_span( node_range)
297+ } )
298+ ] ) ;
299+ }
300+ }
301+ } ,
302+ ast:: ArgList ( it) => {
303+ if it. r_paren_token( ) . is_none( ) {
304+ append. insert( node. into( ) , vec![
305+ Leaf :: Punct ( Punct {
306+ span: fake_span( node_range) ,
307+ char : ')' ,
308+ spacing: Spacing :: Alone
309+ } )
310+ ] ) ;
311+ }
312+ } ,
313+ ast:: ArgList ( it) => {
314+ if it. r_paren_token( ) . is_none( ) {
315+ append. insert( node. into( ) , vec![
316+ Leaf :: Punct ( Punct {
317+ span: fake_span( node_range) ,
318+ char : ')' ,
319+ spacing: Spacing :: Alone
320+ } )
321+ ] ) ;
322+ }
323+ } ,
324+ ast:: ClosureExpr ( it) => {
325+ if it. body( ) . is_none( ) {
326+ append. insert( node. into( ) , vec![
327+ Leaf :: Ident ( Ident {
328+ text: "__ra_fixup" . into( ) ,
329+ span: fake_span( node_range)
330+ } )
331+ ] ) ;
332+ }
333+ } ,
279334 _ => ( ) ,
280335 }
281336 }
@@ -759,4 +814,70 @@ fn foo () {loop { }}
759814"# ] ] ,
760815 )
761816 }
817+
818+ #[ test]
819+ fn fixup_path ( ) {
820+ check (
821+ r#"
822+ fn foo() {
823+ path::
824+ }
825+ "# ,
826+ expect ! [ [ r#"
827+ fn foo () {path :: __ra_fixup}
828+ "# ] ] ,
829+ )
830+ }
831+
832+ #[ test]
833+ fn fixup_record_ctor_field ( ) {
834+ check (
835+ r#"
836+ fn foo() {
837+ R { f: }
838+ }
839+ "# ,
840+ expect ! [ [ r#"
841+ fn foo () {R {f : __ra_fixup}}
842+ "# ] ] ,
843+ )
844+ }
845+
846+ #[ test]
847+ fn fixup_arg_list ( ) {
848+ check (
849+ r#"
850+ fn foo() {
851+ foo(a
852+ }
853+ "# ,
854+ expect ! [ [ r#"
855+ fn foo () { foo ( a ) }
856+ "# ] ] ,
857+ ) ;
858+ check (
859+ r#"
860+ fn foo() {
861+ bar.foo(a
862+ }
863+ "# ,
864+ expect ! [ [ r#"
865+ fn foo () { bar . foo ( a ) }
866+ "# ] ] ,
867+ ) ;
868+ }
869+
870+ #[ test]
871+ fn fixup_closure ( ) {
872+ check (
873+ r#"
874+ fn foo() {
875+ ||
876+ }
877+ "# ,
878+ expect ! [ [ r#"
879+ fn foo () {|| __ra_fixup}
880+ "# ] ] ,
881+ ) ;
882+ }
762883}
0 commit comments