From ad3654f3e73ecdebb7968110d1459170b6c7d70a Mon Sep 17 00:00:00 2001 From: Pratap Singh Date: Fri, 10 Nov 2023 11:49:27 -0500 Subject: [PATCH] fix wildcard type annotation --- src/lib.rs | 2 +- tests/rustfmt-tests.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index b9ef63c..ee0d2f6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -788,7 +788,7 @@ fn to_doc<'a>( .brackets() } Rule::slice_type => map_to_doc(ctx, arena, pair).brackets(), - Rule::infer_type => map_to_doc(ctx, arena, pair), + Rule::infer_type => arena.text("_").append(map_to_doc(ctx, arena, pair)), Rule::fn_ptr_type => map_to_doc(ctx, arena, pair), Rule::fn_trait_type => map_to_doc(ctx, arena, pair), Rule::for_type => map_to_doc(ctx, arena, pair), diff --git a/tests/rustfmt-tests.rs b/tests/rustfmt-tests.rs index 65715f3..0978a92 100644 --- a/tests/rustfmt-tests.rs +++ b/tests/rustfmt-tests.rs @@ -354,3 +354,20 @@ use LongLongLongLongLongLongLongLongLongLongType as LongerLongLongLongLongLongLo "#; compare(file); } + +#[test] +fn rust_wildcard_type_annotation() { + let file = r#" +fn foo() { + let x: _ = bar(); +} + +fn blah() { +let (temp_owl__x607, Tracked(itree)): ( _ +, Tracked, state_Initiator), Endpoint>> ) = { baz(); }; +} +"#; + compare(file); + +} +