File tree Expand file tree Collapse file tree
src/tools/rust-analyzer/crates Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -738,6 +738,25 @@ fn main() {
738738 ) ;
739739 }
740740
741+ #[ test]
742+ fn handles_closures_with_unannotated_rest_patterns ( ) {
743+ check_assist (
744+ convert_closure_to_fn,
745+ r#"
746+ fn main() {
747+ let closure = |$0..| ();
748+ }
749+ "# ,
750+ r#"
751+ fn main() {
752+ fn closure(..: _) {
753+ ()
754+ }
755+ }
756+ "# ,
757+ ) ;
758+ }
759+
741760 #[ test]
742761 fn multiple_capture_usages ( ) {
743762 check_assist (
Original file line number Diff line number Diff line change @@ -831,6 +831,25 @@ fn main() {
831831 ) ;
832832 }
833833
834+ #[ test]
835+ fn regression_22759 ( ) {
836+ check_assist (
837+ unwrap_branch,
838+ r#"
839+ fn main() {
840+ match () {
841+ () $0=> let x = (),
842+ }
843+ }
844+ "# ,
845+ r#"
846+ fn main() {
847+ let x = ()
848+ }
849+ "# ,
850+ ) ;
851+ }
852+
834853 #[ test]
835854 fn simple_if_in_while_bad_cursor_position ( ) {
836855 check_assist_not_applicable (
Original file line number Diff line number Diff line change @@ -565,7 +565,17 @@ pub fn async_move_block_expr(
565565}
566566
567567pub fn tail_only_block_expr ( tail_expr : ast:: Expr ) -> ast:: BlockExpr {
568- ast_from_text ( & format ! ( "fn f() {{ {tail_expr} }}" ) )
568+ quote ! {
569+ BlockExpr {
570+ StmtList {
571+ [ '{' ]
572+ " "
573+ #tail_expr
574+ " "
575+ [ '}' ]
576+ }
577+ }
578+ }
569579}
570580
571581/// Ideally this function wouldn't exist since it involves manual indenting.
@@ -1043,7 +1053,14 @@ pub fn untyped_param(pat: ast::Pat) -> ast::Param {
10431053}
10441054
10451055pub fn param ( pat : ast:: Pat , ty : ast:: Type ) -> ast:: Param {
1046- ast_from_text ( & format ! ( "fn f({pat}: {ty}) {{ }}" ) )
1056+ quote ! {
1057+ Param {
1058+ #pat
1059+ [ : ]
1060+ " "
1061+ #ty
1062+ }
1063+ }
10471064}
10481065
10491066pub fn self_param ( ) -> ast:: SelfParam {
You can’t perform that action at this time.
0 commit comments