From da091b130347c4d6d8c75acb8e65c30a17dc1f5e Mon Sep 17 00:00:00 2001 From: veetaha Date: Mon, 6 Apr 2020 14:04:26 +0300 Subject: [PATCH 01/24] Migrate tests .txt -> .rast The sytax tree output files now use .rast extension (rust-analyzer syntax tree or rust abstract syntax tree (whatever)). This format has a editors/code/ra_syntax_tree.tmGrammar.json declaration that supplies nice syntax highlighting for .rast files. --- crates/ra_syntax/src/tests.rs | 14 ++++---- ...t => 0000_struct_field_missing_comma.rast} | 0 ...le.txt => 0001_item_recovery_in_file.rast} | 0 ...hebang.txt => 0002_duplicate_shebang.rast} | 0 ..._semicolon.txt => 0003_C++_semicolon.rast} | 0 ...ent.txt => 0004_use_path_bad_segment.rast} | 0 ...ecover.txt => 0005_attribute_recover.rast} | 0 ...ery.txt => 0006_named_field_recovery.rast} | 0 ...file.txt => 0007_stray_curly_in_file.rast} | 0 ...very.txt => 0008_item_block_recovery.rast} | 0 ...=> 0009_broken_struct_type_parameter.rast} | 0 ...lock.txt => 0010_unsafe_lambda_block.rast} | 0 ...ern_struct.txt => 0011_extern_struct.rast} | 0 ...ken_lambda.txt => 0012_broken_lambda.rast} | 0 ...nvalid_type.txt => 0013_invalid_type.rast} | 0 ...o_bounds.txt => 0014_where_no_bounds.rast} | 0 ...n_params.txt => 0015_curly_in_params.rast} | 0 ...issing_semi.txt => 0016_missing_semi.rast} | 0 ...nexpr.txt => 0017_incomplete_binexpr.rast} | 0 ...omplete_fn.txt => 0018_incomplete_fn.rast} | 0 ..._let_recover.txt => 0019_let_recover.rast} | 0 ...20_fn_recover.txt => 0020_fn_recover.rast} | 0 ...e_param.txt => 0021_incomplete_param.rast} | 0 ...0022_bad_exprs.txt => 0022_bad_exprs.rast} | 0 ...d_paren.txt => 0023_mismatched_paren.rast} | 0 ..._parens.txt => 0024_many_type_parens.rast} | 0 .../err/{0025_nope.txt => 0025_nope.rast} | 0 ...mp_recovery.txt => 0026_imp_recovery.rast} | 0 ...for.txt => 0027_incomplere_where_for.rast} | 0 ...pletion.txt => 0029_field_completion.rast} | 0 ..._attrs.txt => 0031_block_inner_attrs.rast} | 0 ...s.txt => 0032_match_arms_inner_attrs.rast} | 0 ...s.txt => 0033_match_arms_outer_attrs.rast} | 0 ..._pattern.txt => 0034_bad_box_pattern.rast} | 0 ..._use_recover.txt => 0035_use_recover.rast} | 0 ..._partial_use.txt => 0036_partial_use.rast} | 0 ...its.txt => 0037_visibility_in_traits.rast} | 0 ....txt => 0038_endless_inclusive_range.rast} | 0 ...recovery.txt => 0039_lambda_recovery.rast} | 0 ....txt => 0001_array_type_missing_semi.rast} | 0 ..._err.txt => 0002_misplaced_label_err.rast} | 0 ...t => 0003_pointer_type_no_mutability.rast} | 0 ...0004_impl_type.txt => 0004_impl_type.rast} | 0 ...t => 0005_fn_pointer_type_missing_fn.rast} | 0 ..._mod.txt => 0006_unsafe_block_in_mod.rast} | 0 ....txt => 0007_async_without_semicolon.rast} | 0 .../{0008_pub_expr.txt => 0008_pub_expr.rast} | 0 ...txt => 0009_attr_on_expr_not_allowed.rast} | 0 ...xpr.txt => 0010_bad_tuple_index_expr.rast} | 0 ...rder_fns.txt => 0010_wrong_order_fns.rast} | 0 ...rscore.txt => 0013_static_underscore.rast} | 0 ..._fn_type.txt => 0014_default_fn_type.rast} | 0 ...tem_list.txt => 0001_trait_item_list.rast} | 0 ..._tree_list.txt => 0002_use_tree_list.rast} | 0 ..._pred_for.txt => 0003_where_pred_for.rast} | 0 ...=> 0004_value_parameters_no_patterns.rast} | 0 ...ams.txt => 0005_function_type_params.rast} | 0 ...06_self_param.txt => 0006_self_param.rast} | 0 ...bounds.txt => 0007_type_param_bounds.rast} | 0 ...0008_path_part.txt => 0008_path_part.rast} | 0 ...0009_loop_expr.txt => 0009_loop_expr.rast} | 0 ...xtern_block.txt => 0010_extern_block.rast} | 0 ...11_field_expr.txt => 0011_field_expr.rast} | 0 ...e.txt => 0012_type_item_where_clause.rast} | 0 ...ype_mut.txt => 0013_pointer_type_mut.rast} | 0 ...14_never_type.txt => 0014_never_type.rast} | 0 ...tinue_expr.txt => 0015_continue_expr.rast} | 0 ...nsafe_trait.txt => 0016_unsafe_trait.rast} | 0 ...17_array_type.txt => 0017_array_type.rast} | 0 ...elf_types.txt => 0018_arb_self_types.rast} | 0 ...19_unary_expr.txt => 0019_unary_expr.rast} | 0 .../{0020_use_star.txt => 0020_use_star.rast} | 0 ...item_list.txt => 0021_impl_item_list.rast} | 0 ...ibility.txt => 0022_crate_visibility.rast} | 0 ...er_type.txt => 0023_placeholder_type.rast} | 0 ...0024_slice_pat.txt => 0024_slice_pat.rast} | 0 ...25_slice_type.txt => 0025_slice_type.rast} | 0 ..._fields.txt => 0026_tuple_pat_fields.rast} | 0 .../{0027_ref_pat.txt => 0027_ref_pat.rast} | 0 ...ait_type.txt => 0028_impl_trait_type.rast} | 0 ...0029_cast_expr.txt => 0029_cast_expr.rast} | 0 .../ok/{0030_cond.txt => 0030_cond.rast} | 0 ...31_while_expr.txt => 0031_while_expr.rast} | 0 ...ter_type.txt => 0032_fn_pointer_type.rast} | 0 ...ce_type;.txt => 0033_reference_type;.rast} | 0 ...34_break_expr.txt => 0034_break_expr.rast} | 0 ...tern_fn.txt => 0036_unsafe_extern_fn.rast} | 0 ...37_qual_paths.txt => 0037_qual_paths.rast} | 0 ...nge_expr.txt => 0038_full_range_expr.rast} | 0 .../{0039_type_arg.txt => 0039_type_arg.rast} | 0 ...rd_vis.txt => 0040_crate_keyword_vis.rast} | 0 ...41_trait_item.txt => 0041_trait_item.rast} | 0 ...0042_call_expr.txt => 0042_call_expr.rast} | 0 ...0043_use_alias.txt => 0043_use_alias.rast} | 0 ..._block_items.txt => 0044_block_items.rast} | 0 ....txt => 0045_param_list_opt_patterns.rast} | 0 ...ype.txt => 0046_singleton_tuple_type.rast} | 0 ...impl.txt => 0047_unsafe_default_impl.rast} | 0 ...ds.txt => 0048_path_type_with_bounds.rast} | 0 .../{0050_fn_decl.txt => 0050_fn_decl.rast} | 0 ...0051_unit_type.txt => 0051_unit_type.rast} | 0 ...0052_path_type.txt => 0052_path_type.rast} | 0 ...0053_path_expr.txt => 0053_path_expr.rast} | 0 ...attrs.txt => 0054_record_field_attrs.rast} | 0 ..._pattern.txt => 0055_literal_pattern.rast} | 0 ...here_clause.txt => 0056_where_clause.rast} | 0 .../{0057_const_fn.txt => 0057_const_fn.rast} | 0 ...0058_range_pat.txt => 0058_range_pat.rast} | 0 ...commas.txt => 0059_match_arms_commas.rast} | 0 ...xtern_crate.txt => 0060_extern_crate.rast} | 0 ...61_record_lit.txt => 0061_record_lit.rast} | 0 ...od_contents.txt => 0062_mod_contents.rast} | 0 ...mpl_def_neg.txt => 0063_impl_def_neg.rast} | 0 .../{0064_if_expr.txt => 0064_if_expr.rast} | 0 ...rait_type.txt => 0065_dyn_trait_type.rast} | 0 ...0066_match_arm.txt => 0066_match_arm.rast} | 0 ...67_crate_path.txt => 0067_crate_path.rast} | 0 ..._union_items.txt => 0068_union_items.rast} | 0 ...txt => 0069_use_tree_list_after_path.rast} | 0 ....txt => 0070_stmt_bin_expr_ambiguity.rast} | 0 ...71_match_expr.txt => 0071_match_expr.rast} | 0 ..._return_expr.txt => 0072_return_expr.rast} | 0 ...ms.txt => 0073_type_item_type_params.rast} | 0 ... => 0074_stmt_postfix_expr_ambiguity.rast} | 0 .../ok/{0075_block.txt => 0075_block.rast} | 0 ...se.txt => 0076_function_where_clause.rast} | 0 .../{0077_try_expr.txt => 0077_try_expr.rast} | 0 ...0078_type_item.txt => 0078_type_item.rast} | 0 .../{0079_impl_def.txt => 0079_impl_def.rast} | 0 ...tfix_range.txt => 0080_postfix_range.rast} | 0 .../{0081_for_type.txt => 0081_for_type.rast} | 0 .../{0082_ref_expr.txt => 0082_ref_expr.rast} | 0 ...truct_items.txt => 0083_struct_items.rast} | 0 ...84_paren_type.txt => 0084_paren_type.rast} | 0 ...r_literals.txt => 0085_expr_literals.rast} | 0 ...t_type.txt => 0086_function_ret_type.rast} | 0 ..._unsafe_impl.txt => 0087_unsafe_impl.rast} | 0 ...mbiguity.txt => 0088_break_ambiguity.rast} | 0 ...0089_extern_fn.txt => 0089_extern_fn.rast} | 0 ...fault.txt => 0090_type_param_default.rast} | 0 ...91_auto_trait.txt => 0091_auto_trait.rast} | 0 ...txt => 0092_fn_pointer_type_with_ret.rast} | 0 ...93_index_expr.txt => 0093_index_expr.rast} | 0 ..._trait.txt => 0094_unsafe_auto_trait.rast} | 0 ...lder_pat.txt => 0095_placeholder_pat.rast} | 0 ...lock.txt => 0096_no_semi_after_block.rast} | 0 ...efault_impl.txt => 0097_default_impl.rast} | 0 ...nsafe_fn.txt => 0098_const_unsafe_fn.rast} | 0 ...99_param_list.txt => 0099_param_list.rast} | 0 .../{0100_for_expr.txt => 0100_for_expr.rast} | 0 ...0101_unsafe_fn.txt => 0101_unsafe_fn.rast} | 0 ...st.txt => 0102_record_field_pat_list.rast} | 0 ...03_array_expr.txt => 0103_array_expr.rast} | 0 ..._args.txt => 0104_path_fn_trait_args.rast} | 0 ...05_block_expr.txt => 0105_block_expr.rast} | 0 ..._lambda_expr.txt => 0106_lambda_expr.rast} | 0 ...ll_expr.txt => 0107_method_call_expr.rast} | 0 ...08_tuple_expr.txt => 0108_tuple_expr.rast} | 0 .../ok/{0109_label.txt => 0109_label.rast} | 0 .../{0110_use_path.txt => 0110_use_path.rast} | 0 ...0111_tuple_pat.txt => 0111_tuple_pat.rast} | 0 .../{0112_bind_pat.txt => 0112_bind_pat.rast} | 0 ...ontentexpr.txt => 0113_nocontentexpr.rast} | 0 ...where.txt => 0114_tuple_struct_where.rast} | 0 ..._attrs.txt => 0115_tuple_field_attrs.rast} | 0 ...all_type.txt => 0117_macro_call_type.rast} | 0 ...es.txt => 0118_impl_inner_attributes.rast} | 0 ..._match_guard.txt => 0118_match_guard.rast} | 0 ...t => 0120_match_arms_inner_attribute.rast} | 0 ... => 0121_match_arms_outer_attributes.rast} | 0 ...0122_generic_lifetime_type_attribute.rast} | 0 ...vararg.txt => 0123_param_list_vararg.rast} | 0 .../{0124_async_fn.txt => 0124_async_fn.rast} | 0 ..._path.txt => 0125_crate_keyword_path.rast} | 0 ... 0125_record_literal_field_with_attr.rast} | 0 ...r_stmt.txt => 0126_attr_on_expr_stmt.rast} | 0 ...t => 0127_attr_on_last_expr_in_block.rast} | 0 ...ombined_fns.txt => 0128_combined_fns.rast} | 0 ...0129_marco_pat.txt => 0129_marco_pat.rast} | 0 .../{0130_let_stmt.txt => 0130_let_stmt.rast} | 0 ...lock_expr.txt => 0130_try_block_expr.rast} | 0 ...al_type.txt => 0131_existential_type.rast} | 0 .../{0132_box_expr.txt => 0132_box_expr.rast} | 0 ..._fn_type.txt => 0132_default_fn_type.rast} | 0 ...txt => 0134_nocontentexpr_after_item.rast} | 0 ...37_await_expr.txt => 0137_await_expr.rast} | 0 ...s.txt => 0138_associated_type_bounds.rast} | 0 ...k.txt => 0138_expression_after_block.rast} | 0 ...tr.txt => 0138_self_param_outer_attr.rast} | 0 ...uter_arg.txt => 0139_param_outer_arg.rast} | 0 ...ange_from.txt => 0142_for_range_from.rast} | 0 .../{0143_box_pat.txt => 0143_box_pat.rast} | 0 ..._dot_dot_pat.txt => 0144_dot_dot_pat.rast} | 0 ...eld_pat.txt => 0145_record_field_pat.rast} | 0 ...precedence.txt => 0146_as_precedence.rast} | 0 ..._const_param.txt => 0147_const_param.rast} | 0 ...0147_macro_def.txt => 0147_macro_def.rast} | 0 ..._macro_def.txt => 0148_pub_macro_def.rast} | 0 ..._array_attrs.txt => 0150_array_attrs.rast} | 0 ..._params.txt => 0150_impl_type_params.rast} | 0 ..._trait_alias.txt => 0151_trait_alias.rast} | 0 ..._with_attr.txt => 0152_arg_with_attr.rast} | 0 ... => 0154_fn_pointer_param_ident_path.rast} | 0 ...re_params.txt => 0155_closure_params.rast} | 0 ...n_def_param.txt => 0156_fn_def_param.rast} | 0 ...56_or_pattern.txt => 0156_or_pattern.rast} | 0 ...g.txt => 0157_fn_pointer_unnamed_arg.rast} | 0 ...ant.txt => 0157_variant_discriminant.rast} | 0 ...t => 0158_binop_resets_statementness.rast} | 0 ...t_block.txt => 0158_lambda_ret_block.rast} | 0 .../ok/{0000_empty.txt => 0000_empty.rast} | 0 ..._struct_item.txt => 0001_struct_item.rast} | 0 ..._field.txt => 0002_struct_item_field.rast} | 0 ...ile_shebang.txt => 0004_file_shebang.rast} | 0 .../{0005_fn_item.txt => 0005_fn_item.rast} | 0 ...ributes.txt => 0006_inner_attributes.rast} | 0 ...xtern_crate.txt => 0007_extern_crate.rast} | 0 .../{0008_mod_item.txt => 0008_mod_item.rast} | 0 .../{0009_use_item.txt => 0009_use_item.rast} | 0 ...gments.txt => 0010_use_path_segments.rast} | 0 ...ttribute.txt => 0011_outer_attribute.rast} | 0 ...12_visibility.txt => 0012_visibility.rast} | 0 ...uper.txt => 0013_use_path_self_super.rast} | 0 .../{0014_use_tree.txt => 0014_use_tree.rast} | 0 .../{0015_use_tree.txt => 0015_use_tree.rast} | 0 ...t_flavors.txt => 0016_struct_flavors.rast} | 0 ...omma.txt => 0017_attr_trailing_comma.rast} | 0 ...arams.txt => 0018_struct_type_params.rast} | 0 .../ok/{0019_enums.txt => 0019_enums.rast} | 0 ...bounds.txt => 0020_type_param_bounds.rast} | 0 ...0021_extern_fn.txt => 0021_extern_fn.rast} | 0 ...block.txt => 0022_empty_extern_block.rast} | 0 ...tatic_items.txt => 0023_static_items.rast} | 0 ...24_const_item.txt => 0024_const_item.rast} | 0 ...block.txt => 0025_extern_fn_in_block.rast} | 0 ..._block.txt => 0026_const_fn_in_block.rast} | 0 ...block.txt => 0027_unsafe_fn_in_block.rast} | 0 ...r.txt => 0028_operator_binding_power.rast} | 0 ..._range_forms.txt => 0029_range_forms.rast} | 0 ...suffixes.txt => 0030_string_suffixes.rast} | 0 .../ok/{0030_traits.txt => 0030_traits.rast} | 0 .../ok/{0031_extern.txt => 0031_extern.rast} | 0 ...0032_where_for.txt => 0032_where_for.rast} | 0 ..._label_break.txt => 0033_label_break.rast} | 0 ..._call.txt => 0034_crate_path_in_call.rast} | 0 ..._weird_exprs.txt => 0035_weird_exprs.rast} | 0 ...ualified.txt => 0036_fully_qualified.rast} | 0 .../parser/ok/{0037_mod.txt => 0037_mod.rast} | 0 ...red_type.txt => 0038_where_pred_type.rast} | 0 ..._raw_fn_item.txt => 0039_raw_fn_item.rast} | 0 ...ld.txt => 0040_raw_struct_item_field.rast} | 0 ...aw_keywords.txt => 0041_raw_keywords.rast} | 0 ...call_list.txt => 0042_ufcs_call_list.rast} | 0 ...nment.txt => 0043_complex_assignment.rast} | 0 ...0044_let_attrs.txt => 0044_let_attrs.rast} | 0 ..._attrs.txt => 0045_block_inner_attrs.rast} | 0 ....txt => 0046_extern_inner_attributes.rast} | 0 ...n.txt => 0047_minus_in_inner_pattern.rast} | 0 ...ment.txt => 0048_compound_assignment.rast} | 0 ..._async_block.txt => 0049_async_block.rast} | 0 ....txt => 0050_async_block_as_argument.rast} | 0 ...er_attrs.txt => 0051_parameter_attrs.rast} | 0 ...ge_block.txt => 0052_for_range_block.rast} | 0 ... 0053_outer_attribute_on_macro_rules.rast} | 0 ...rg.txt => 0054_qual_path_in_type_arg.rast} | 0 ..._dot_dot_dot.txt => 0055_dot_dot_dot.rast} | 0 ..._neq_in_type.txt => 0056_neq_in_type.rast} | 0 ...oop_in_call.txt => 0057_loop_in_call.rast} | 0 ...ce.txt => 0058_unary_expr_precedence.rast} | 0 ...n_parens.txt => 0059_loops_in_parens.rast} | 0 .../{0060_as_range.txt => 0060_as_range.rast} | 0 ...l_range.txt => 0061_match_full_range.rast} | 0 ...0062_macro_2.0.txt => 0062_macro_2.0.rast} | 0 ...tterns.txt => 0063_trait_fn_patterns.rast} | 0 ...ariadic_fun.txt => 0063_variadic_fun.rast} | 0 ...fn_params.txt => 0064_impl_fn_params.rast} | 0 ..._newline.txt => 0065_comment_newline.rast} | 0 crates/test_utils/src/lib.rs | 34 +++++++++---------- 278 files changed, 23 insertions(+), 25 deletions(-) rename crates/ra_syntax/test_data/parser/err/{0000_struct_field_missing_comma.txt => 0000_struct_field_missing_comma.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0001_item_recovery_in_file.txt => 0001_item_recovery_in_file.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0002_duplicate_shebang.txt => 0002_duplicate_shebang.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0003_C++_semicolon.txt => 0003_C++_semicolon.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0004_use_path_bad_segment.txt => 0004_use_path_bad_segment.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0005_attribute_recover.txt => 0005_attribute_recover.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0006_named_field_recovery.txt => 0006_named_field_recovery.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0007_stray_curly_in_file.txt => 0007_stray_curly_in_file.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0008_item_block_recovery.txt => 0008_item_block_recovery.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0009_broken_struct_type_parameter.txt => 0009_broken_struct_type_parameter.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0010_unsafe_lambda_block.txt => 0010_unsafe_lambda_block.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0011_extern_struct.txt => 0011_extern_struct.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0012_broken_lambda.txt => 0012_broken_lambda.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0013_invalid_type.txt => 0013_invalid_type.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0014_where_no_bounds.txt => 0014_where_no_bounds.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0015_curly_in_params.txt => 0015_curly_in_params.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0016_missing_semi.txt => 0016_missing_semi.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0017_incomplete_binexpr.txt => 0017_incomplete_binexpr.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0018_incomplete_fn.txt => 0018_incomplete_fn.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0019_let_recover.txt => 0019_let_recover.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0020_fn_recover.txt => 0020_fn_recover.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0021_incomplete_param.txt => 0021_incomplete_param.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0022_bad_exprs.txt => 0022_bad_exprs.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0023_mismatched_paren.txt => 0023_mismatched_paren.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0024_many_type_parens.txt => 0024_many_type_parens.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0025_nope.txt => 0025_nope.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0026_imp_recovery.txt => 0026_imp_recovery.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0027_incomplere_where_for.txt => 0027_incomplere_where_for.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0029_field_completion.txt => 0029_field_completion.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0031_block_inner_attrs.txt => 0031_block_inner_attrs.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0032_match_arms_inner_attrs.txt => 0032_match_arms_inner_attrs.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0033_match_arms_outer_attrs.txt => 0033_match_arms_outer_attrs.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0034_bad_box_pattern.txt => 0034_bad_box_pattern.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0035_use_recover.txt => 0035_use_recover.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0036_partial_use.txt => 0036_partial_use.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0037_visibility_in_traits.txt => 0037_visibility_in_traits.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0038_endless_inclusive_range.txt => 0038_endless_inclusive_range.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0039_lambda_recovery.txt => 0039_lambda_recovery.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/err/{0001_array_type_missing_semi.txt => 0001_array_type_missing_semi.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/err/{0002_misplaced_label_err.txt => 0002_misplaced_label_err.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/err/{0003_pointer_type_no_mutability.txt => 0003_pointer_type_no_mutability.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/err/{0004_impl_type.txt => 0004_impl_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/err/{0005_fn_pointer_type_missing_fn.txt => 0005_fn_pointer_type_missing_fn.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/err/{0006_unsafe_block_in_mod.txt => 0006_unsafe_block_in_mod.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/err/{0007_async_without_semicolon.txt => 0007_async_without_semicolon.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/err/{0008_pub_expr.txt => 0008_pub_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/err/{0009_attr_on_expr_not_allowed.txt => 0009_attr_on_expr_not_allowed.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/err/{0010_bad_tuple_index_expr.txt => 0010_bad_tuple_index_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/err/{0010_wrong_order_fns.txt => 0010_wrong_order_fns.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/err/{0013_static_underscore.txt => 0013_static_underscore.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/err/{0014_default_fn_type.txt => 0014_default_fn_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0001_trait_item_list.txt => 0001_trait_item_list.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0002_use_tree_list.txt => 0002_use_tree_list.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0003_where_pred_for.txt => 0003_where_pred_for.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0004_value_parameters_no_patterns.txt => 0004_value_parameters_no_patterns.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0005_function_type_params.txt => 0005_function_type_params.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0006_self_param.txt => 0006_self_param.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0007_type_param_bounds.txt => 0007_type_param_bounds.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0008_path_part.txt => 0008_path_part.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0009_loop_expr.txt => 0009_loop_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0010_extern_block.txt => 0010_extern_block.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0011_field_expr.txt => 0011_field_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0012_type_item_where_clause.txt => 0012_type_item_where_clause.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0013_pointer_type_mut.txt => 0013_pointer_type_mut.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0014_never_type.txt => 0014_never_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0015_continue_expr.txt => 0015_continue_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0016_unsafe_trait.txt => 0016_unsafe_trait.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0017_array_type.txt => 0017_array_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0018_arb_self_types.txt => 0018_arb_self_types.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0019_unary_expr.txt => 0019_unary_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0020_use_star.txt => 0020_use_star.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0021_impl_item_list.txt => 0021_impl_item_list.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0022_crate_visibility.txt => 0022_crate_visibility.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0023_placeholder_type.txt => 0023_placeholder_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0024_slice_pat.txt => 0024_slice_pat.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0025_slice_type.txt => 0025_slice_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0026_tuple_pat_fields.txt => 0026_tuple_pat_fields.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0027_ref_pat.txt => 0027_ref_pat.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0028_impl_trait_type.txt => 0028_impl_trait_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0029_cast_expr.txt => 0029_cast_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0030_cond.txt => 0030_cond.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0031_while_expr.txt => 0031_while_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0032_fn_pointer_type.txt => 0032_fn_pointer_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0033_reference_type;.txt => 0033_reference_type;.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0034_break_expr.txt => 0034_break_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0036_unsafe_extern_fn.txt => 0036_unsafe_extern_fn.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0037_qual_paths.txt => 0037_qual_paths.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0038_full_range_expr.txt => 0038_full_range_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0039_type_arg.txt => 0039_type_arg.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0040_crate_keyword_vis.txt => 0040_crate_keyword_vis.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0041_trait_item.txt => 0041_trait_item.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0042_call_expr.txt => 0042_call_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0043_use_alias.txt => 0043_use_alias.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0044_block_items.txt => 0044_block_items.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0045_param_list_opt_patterns.txt => 0045_param_list_opt_patterns.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0046_singleton_tuple_type.txt => 0046_singleton_tuple_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0047_unsafe_default_impl.txt => 0047_unsafe_default_impl.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0048_path_type_with_bounds.txt => 0048_path_type_with_bounds.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0050_fn_decl.txt => 0050_fn_decl.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0051_unit_type.txt => 0051_unit_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0052_path_type.txt => 0052_path_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0053_path_expr.txt => 0053_path_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0054_record_field_attrs.txt => 0054_record_field_attrs.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0055_literal_pattern.txt => 0055_literal_pattern.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0056_where_clause.txt => 0056_where_clause.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0057_const_fn.txt => 0057_const_fn.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0058_range_pat.txt => 0058_range_pat.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0059_match_arms_commas.txt => 0059_match_arms_commas.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0060_extern_crate.txt => 0060_extern_crate.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0061_record_lit.txt => 0061_record_lit.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0062_mod_contents.txt => 0062_mod_contents.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0063_impl_def_neg.txt => 0063_impl_def_neg.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0064_if_expr.txt => 0064_if_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0065_dyn_trait_type.txt => 0065_dyn_trait_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0066_match_arm.txt => 0066_match_arm.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0067_crate_path.txt => 0067_crate_path.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0068_union_items.txt => 0068_union_items.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0069_use_tree_list_after_path.txt => 0069_use_tree_list_after_path.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0070_stmt_bin_expr_ambiguity.txt => 0070_stmt_bin_expr_ambiguity.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0071_match_expr.txt => 0071_match_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0072_return_expr.txt => 0072_return_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0073_type_item_type_params.txt => 0073_type_item_type_params.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0074_stmt_postfix_expr_ambiguity.txt => 0074_stmt_postfix_expr_ambiguity.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0075_block.txt => 0075_block.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0076_function_where_clause.txt => 0076_function_where_clause.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0077_try_expr.txt => 0077_try_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0078_type_item.txt => 0078_type_item.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0079_impl_def.txt => 0079_impl_def.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0080_postfix_range.txt => 0080_postfix_range.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0081_for_type.txt => 0081_for_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0082_ref_expr.txt => 0082_ref_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0083_struct_items.txt => 0083_struct_items.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0084_paren_type.txt => 0084_paren_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0085_expr_literals.txt => 0085_expr_literals.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0086_function_ret_type.txt => 0086_function_ret_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0087_unsafe_impl.txt => 0087_unsafe_impl.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0088_break_ambiguity.txt => 0088_break_ambiguity.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0089_extern_fn.txt => 0089_extern_fn.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0090_type_param_default.txt => 0090_type_param_default.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0091_auto_trait.txt => 0091_auto_trait.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0092_fn_pointer_type_with_ret.txt => 0092_fn_pointer_type_with_ret.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0093_index_expr.txt => 0093_index_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0094_unsafe_auto_trait.txt => 0094_unsafe_auto_trait.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0095_placeholder_pat.txt => 0095_placeholder_pat.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0096_no_semi_after_block.txt => 0096_no_semi_after_block.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0097_default_impl.txt => 0097_default_impl.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0098_const_unsafe_fn.txt => 0098_const_unsafe_fn.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0099_param_list.txt => 0099_param_list.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0100_for_expr.txt => 0100_for_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0101_unsafe_fn.txt => 0101_unsafe_fn.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0102_record_field_pat_list.txt => 0102_record_field_pat_list.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0103_array_expr.txt => 0103_array_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0104_path_fn_trait_args.txt => 0104_path_fn_trait_args.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0105_block_expr.txt => 0105_block_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0106_lambda_expr.txt => 0106_lambda_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0107_method_call_expr.txt => 0107_method_call_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0108_tuple_expr.txt => 0108_tuple_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0109_label.txt => 0109_label.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0110_use_path.txt => 0110_use_path.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0111_tuple_pat.txt => 0111_tuple_pat.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0112_bind_pat.txt => 0112_bind_pat.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0113_nocontentexpr.txt => 0113_nocontentexpr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0114_tuple_struct_where.txt => 0114_tuple_struct_where.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0115_tuple_field_attrs.txt => 0115_tuple_field_attrs.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0117_macro_call_type.txt => 0117_macro_call_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0118_impl_inner_attributes.txt => 0118_impl_inner_attributes.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0118_match_guard.txt => 0118_match_guard.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0120_match_arms_inner_attribute.txt => 0120_match_arms_inner_attribute.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0121_match_arms_outer_attributes.txt => 0121_match_arms_outer_attributes.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0122_generic_lifetime_type_attribute.txt => 0122_generic_lifetime_type_attribute.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0123_param_list_vararg.txt => 0123_param_list_vararg.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0124_async_fn.txt => 0124_async_fn.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0125_crate_keyword_path.txt => 0125_crate_keyword_path.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0125_record_literal_field_with_attr.txt => 0125_record_literal_field_with_attr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0126_attr_on_expr_stmt.txt => 0126_attr_on_expr_stmt.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0127_attr_on_last_expr_in_block.txt => 0127_attr_on_last_expr_in_block.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0128_combined_fns.txt => 0128_combined_fns.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0129_marco_pat.txt => 0129_marco_pat.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0130_let_stmt.txt => 0130_let_stmt.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0130_try_block_expr.txt => 0130_try_block_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0131_existential_type.txt => 0131_existential_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0132_box_expr.txt => 0132_box_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0132_default_fn_type.txt => 0132_default_fn_type.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0134_nocontentexpr_after_item.txt => 0134_nocontentexpr_after_item.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0137_await_expr.txt => 0137_await_expr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0138_associated_type_bounds.txt => 0138_associated_type_bounds.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0138_expression_after_block.txt => 0138_expression_after_block.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0138_self_param_outer_attr.txt => 0138_self_param_outer_attr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0139_param_outer_arg.txt => 0139_param_outer_arg.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0142_for_range_from.txt => 0142_for_range_from.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0143_box_pat.txt => 0143_box_pat.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0144_dot_dot_pat.txt => 0144_dot_dot_pat.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0145_record_field_pat.txt => 0145_record_field_pat.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0146_as_precedence.txt => 0146_as_precedence.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0147_const_param.txt => 0147_const_param.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0147_macro_def.txt => 0147_macro_def.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0148_pub_macro_def.txt => 0148_pub_macro_def.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0150_array_attrs.txt => 0150_array_attrs.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0150_impl_type_params.txt => 0150_impl_type_params.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0151_trait_alias.txt => 0151_trait_alias.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0152_arg_with_attr.txt => 0152_arg_with_attr.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0154_fn_pointer_param_ident_path.txt => 0154_fn_pointer_param_ident_path.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0155_closure_params.txt => 0155_closure_params.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0156_fn_def_param.txt => 0156_fn_def_param.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0156_or_pattern.txt => 0156_or_pattern.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0157_fn_pointer_unnamed_arg.txt => 0157_fn_pointer_unnamed_arg.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0157_variant_discriminant.txt => 0157_variant_discriminant.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0158_binop_resets_statementness.txt => 0158_binop_resets_statementness.rast} (100%) rename crates/ra_syntax/test_data/parser/inline/ok/{0158_lambda_ret_block.txt => 0158_lambda_ret_block.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0000_empty.txt => 0000_empty.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0001_struct_item.txt => 0001_struct_item.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0002_struct_item_field.txt => 0002_struct_item_field.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0004_file_shebang.txt => 0004_file_shebang.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0005_fn_item.txt => 0005_fn_item.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0006_inner_attributes.txt => 0006_inner_attributes.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0007_extern_crate.txt => 0007_extern_crate.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0008_mod_item.txt => 0008_mod_item.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0009_use_item.txt => 0009_use_item.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0010_use_path_segments.txt => 0010_use_path_segments.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0011_outer_attribute.txt => 0011_outer_attribute.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0012_visibility.txt => 0012_visibility.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0013_use_path_self_super.txt => 0013_use_path_self_super.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0014_use_tree.txt => 0014_use_tree.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0015_use_tree.txt => 0015_use_tree.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0016_struct_flavors.txt => 0016_struct_flavors.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0017_attr_trailing_comma.txt => 0017_attr_trailing_comma.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0018_struct_type_params.txt => 0018_struct_type_params.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0019_enums.txt => 0019_enums.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0020_type_param_bounds.txt => 0020_type_param_bounds.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0021_extern_fn.txt => 0021_extern_fn.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0022_empty_extern_block.txt => 0022_empty_extern_block.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0023_static_items.txt => 0023_static_items.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0024_const_item.txt => 0024_const_item.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0025_extern_fn_in_block.txt => 0025_extern_fn_in_block.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0026_const_fn_in_block.txt => 0026_const_fn_in_block.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0027_unsafe_fn_in_block.txt => 0027_unsafe_fn_in_block.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0028_operator_binding_power.txt => 0028_operator_binding_power.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0029_range_forms.txt => 0029_range_forms.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0030_string_suffixes.txt => 0030_string_suffixes.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0030_traits.txt => 0030_traits.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0031_extern.txt => 0031_extern.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0032_where_for.txt => 0032_where_for.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0033_label_break.txt => 0033_label_break.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0034_crate_path_in_call.txt => 0034_crate_path_in_call.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0035_weird_exprs.txt => 0035_weird_exprs.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0036_fully_qualified.txt => 0036_fully_qualified.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0037_mod.txt => 0037_mod.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0038_where_pred_type.txt => 0038_where_pred_type.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0039_raw_fn_item.txt => 0039_raw_fn_item.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0040_raw_struct_item_field.txt => 0040_raw_struct_item_field.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0041_raw_keywords.txt => 0041_raw_keywords.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0042_ufcs_call_list.txt => 0042_ufcs_call_list.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0043_complex_assignment.txt => 0043_complex_assignment.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0044_let_attrs.txt => 0044_let_attrs.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0045_block_inner_attrs.txt => 0045_block_inner_attrs.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0046_extern_inner_attributes.txt => 0046_extern_inner_attributes.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0047_minus_in_inner_pattern.txt => 0047_minus_in_inner_pattern.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0048_compound_assignment.txt => 0048_compound_assignment.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0049_async_block.txt => 0049_async_block.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0050_async_block_as_argument.txt => 0050_async_block_as_argument.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0051_parameter_attrs.txt => 0051_parameter_attrs.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0052_for_range_block.txt => 0052_for_range_block.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0053_outer_attribute_on_macro_rules.txt => 0053_outer_attribute_on_macro_rules.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0054_qual_path_in_type_arg.txt => 0054_qual_path_in_type_arg.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0055_dot_dot_dot.txt => 0055_dot_dot_dot.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0056_neq_in_type.txt => 0056_neq_in_type.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0057_loop_in_call.txt => 0057_loop_in_call.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0058_unary_expr_precedence.txt => 0058_unary_expr_precedence.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0059_loops_in_parens.txt => 0059_loops_in_parens.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0060_as_range.txt => 0060_as_range.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0061_match_full_range.txt => 0061_match_full_range.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0062_macro_2.0.txt => 0062_macro_2.0.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0063_trait_fn_patterns.txt => 0063_trait_fn_patterns.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0063_variadic_fun.txt => 0063_variadic_fun.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0064_impl_fn_params.txt => 0064_impl_fn_params.rast} (100%) rename crates/ra_syntax/test_data/parser/ok/{0065_comment_newline.txt => 0065_comment_newline.rast} (100%) diff --git a/crates/ra_syntax/src/tests.rs b/crates/ra_syntax/src/tests.rs index 6a8cb6bb57b4..355843b946c9 100644 --- a/crates/ra_syntax/src/tests.rs +++ b/crates/ra_syntax/src/tests.rs @@ -3,7 +3,7 @@ use std::{ path::{Component, Path, PathBuf}, }; -use test_utils::{collect_tests, dir_tests, project_dir, read_text}; +use test_utils::{collect_rust_files, dir_tests, project_dir, read_text}; use crate::{fuzz, tokenize, SourceFile, SyntaxError, TextRange, TextUnit, Token}; @@ -13,12 +13,12 @@ fn lexer_tests() { // * Add tests for unicode escapes in byte-character and [raw]-byte-string literals // * Add tests for unescape errors - dir_tests(&test_data_dir(), &["lexer/ok"], |text, path| { + dir_tests(&test_data_dir(), &["lexer/ok"], "txt", |text, path| { let (tokens, errors) = tokenize(text); assert_errors_are_absent(&errors, path); dump_tokens_and_errors(&tokens, &errors, text) }); - dir_tests(&test_data_dir(), &["lexer/err"], |text, path| { + dir_tests(&test_data_dir(), &["lexer/err"], "txt", |text, path| { let (tokens, errors) = tokenize(text); assert_errors_are_present(&errors, path); dump_tokens_and_errors(&tokens, &errors, text) @@ -40,13 +40,13 @@ fn main() { #[test] fn parser_tests() { - dir_tests(&test_data_dir(), &["parser/inline/ok", "parser/ok"], |text, path| { + dir_tests(&test_data_dir(), &["parser/inline/ok", "parser/ok"], "rast", |text, path| { let parse = SourceFile::parse(text); let errors = parse.errors(); assert_errors_are_absent(&errors, path); parse.debug_dump() }); - dir_tests(&test_data_dir(), &["parser/err", "parser/inline/err"], |text, path| { + dir_tests(&test_data_dir(), &["parser/err", "parser/inline/err"], "rast", |text, path| { let parse = SourceFile::parse(text); let errors = parse.errors(); assert_errors_are_present(&errors, path); @@ -56,14 +56,14 @@ fn parser_tests() { #[test] fn parser_fuzz_tests() { - for (_, text) in collect_tests(&test_data_dir(), &["parser/fuzz-failures"]) { + for (_, text) in collect_rust_files(&test_data_dir(), &["parser/fuzz-failures"]) { fuzz::check_parser(&text) } } #[test] fn reparse_fuzz_tests() { - for (_, text) in collect_tests(&test_data_dir(), &["reparse/fuzz-failures"]) { + for (_, text) in collect_rust_files(&test_data_dir(), &["reparse/fuzz-failures"]) { let check = fuzz::CheckReparse::from_data(text.as_bytes()).unwrap(); println!("{:?}", check); check.run(); diff --git a/crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.txt b/crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.txt rename to crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.rast diff --git a/crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.txt b/crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.txt rename to crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.rast diff --git a/crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.txt b/crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.txt rename to crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast diff --git a/crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.txt b/crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.txt rename to crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.rast diff --git a/crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.txt b/crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.txt rename to crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast diff --git a/crates/ra_syntax/test_data/parser/err/0005_attribute_recover.txt b/crates/ra_syntax/test_data/parser/err/0005_attribute_recover.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0005_attribute_recover.txt rename to crates/ra_syntax/test_data/parser/err/0005_attribute_recover.rast diff --git a/crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.txt b/crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.txt rename to crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.rast diff --git a/crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.txt b/crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.txt rename to crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.rast diff --git a/crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.txt b/crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.txt rename to crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.rast diff --git a/crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.txt b/crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.txt rename to crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.rast diff --git a/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.txt b/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.txt rename to crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast diff --git a/crates/ra_syntax/test_data/parser/err/0011_extern_struct.txt b/crates/ra_syntax/test_data/parser/err/0011_extern_struct.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0011_extern_struct.txt rename to crates/ra_syntax/test_data/parser/err/0011_extern_struct.rast diff --git a/crates/ra_syntax/test_data/parser/err/0012_broken_lambda.txt b/crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0012_broken_lambda.txt rename to crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast diff --git a/crates/ra_syntax/test_data/parser/err/0013_invalid_type.txt b/crates/ra_syntax/test_data/parser/err/0013_invalid_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0013_invalid_type.txt rename to crates/ra_syntax/test_data/parser/err/0013_invalid_type.rast diff --git a/crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.txt b/crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.txt rename to crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/err/0015_curly_in_params.txt b/crates/ra_syntax/test_data/parser/err/0015_curly_in_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0015_curly_in_params.txt rename to crates/ra_syntax/test_data/parser/err/0015_curly_in_params.rast diff --git a/crates/ra_syntax/test_data/parser/err/0016_missing_semi.txt b/crates/ra_syntax/test_data/parser/err/0016_missing_semi.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0016_missing_semi.txt rename to crates/ra_syntax/test_data/parser/err/0016_missing_semi.rast diff --git a/crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.txt b/crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.txt rename to crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.rast diff --git a/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.txt b/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.txt rename to crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast diff --git a/crates/ra_syntax/test_data/parser/err/0019_let_recover.txt b/crates/ra_syntax/test_data/parser/err/0019_let_recover.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0019_let_recover.txt rename to crates/ra_syntax/test_data/parser/err/0019_let_recover.rast diff --git a/crates/ra_syntax/test_data/parser/err/0020_fn_recover.txt b/crates/ra_syntax/test_data/parser/err/0020_fn_recover.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0020_fn_recover.txt rename to crates/ra_syntax/test_data/parser/err/0020_fn_recover.rast diff --git a/crates/ra_syntax/test_data/parser/err/0021_incomplete_param.txt b/crates/ra_syntax/test_data/parser/err/0021_incomplete_param.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0021_incomplete_param.txt rename to crates/ra_syntax/test_data/parser/err/0021_incomplete_param.rast diff --git a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt b/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt rename to crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast diff --git a/crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.txt b/crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.txt rename to crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.rast diff --git a/crates/ra_syntax/test_data/parser/err/0024_many_type_parens.txt b/crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0024_many_type_parens.txt rename to crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast diff --git a/crates/ra_syntax/test_data/parser/err/0025_nope.txt b/crates/ra_syntax/test_data/parser/err/0025_nope.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0025_nope.txt rename to crates/ra_syntax/test_data/parser/err/0025_nope.rast diff --git a/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.txt b/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0026_imp_recovery.txt rename to crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast diff --git a/crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.txt b/crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.txt rename to crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast diff --git a/crates/ra_syntax/test_data/parser/err/0029_field_completion.txt b/crates/ra_syntax/test_data/parser/err/0029_field_completion.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0029_field_completion.txt rename to crates/ra_syntax/test_data/parser/err/0029_field_completion.rast diff --git a/crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.txt b/crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.txt rename to crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.txt b/crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.txt rename to crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.txt b/crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.txt rename to crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.txt b/crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.txt rename to crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.rast diff --git a/crates/ra_syntax/test_data/parser/err/0035_use_recover.txt b/crates/ra_syntax/test_data/parser/err/0035_use_recover.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0035_use_recover.txt rename to crates/ra_syntax/test_data/parser/err/0035_use_recover.rast diff --git a/crates/ra_syntax/test_data/parser/err/0036_partial_use.txt b/crates/ra_syntax/test_data/parser/err/0036_partial_use.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0036_partial_use.txt rename to crates/ra_syntax/test_data/parser/err/0036_partial_use.rast diff --git a/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.txt b/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.txt rename to crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast diff --git a/crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.txt b/crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.txt rename to crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.rast diff --git a/crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.txt b/crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.txt rename to crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.txt b/crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.txt rename to crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.txt b/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.txt rename to crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.txt b/crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.txt rename to crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.txt b/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.txt rename to crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.txt b/crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.txt rename to crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.txt b/crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.txt rename to crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.txt b/crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.txt rename to crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.txt b/crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.txt rename to crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.txt b/crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.txt rename to crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.txt b/crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.txt rename to crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.txt b/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.txt rename to crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.txt b/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.txt rename to crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.txt b/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.txt rename to crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.txt b/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.txt b/crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.txt b/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.txt b/crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.txt b/crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.txt b/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.txt b/crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.txt b/crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0010_extern_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0010_extern_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0010_extern_block.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0010_extern_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.txt b/crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.txt b/crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.txt b/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.txt b/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.txt b/crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.txt b/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.txt b/crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.txt b/crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0030_cond.txt b/crates/ra_syntax/test_data/parser/inline/ok/0030_cond.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0030_cond.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0030_cond.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.txt b/crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.txt b/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.txt b/crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.txt b/crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.txt b/crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.txt b/crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.txt b/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.txt b/crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.txt b/crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.txt b/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.txt b/crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.txt b/crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.txt b/crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.txt b/crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.txt b/crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.txt b/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.txt b/crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.txt b/crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.txt b/crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.txt b/crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.txt b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.txt b/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.txt b/crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.txt b/crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.txt b/crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.txt b/crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.txt b/crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.txt b/crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0075_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0075_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0075_block.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0075_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.txt b/crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.txt b/crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.txt b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.txt b/crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.txt b/crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.txt b/crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.txt b/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.txt b/crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.txt b/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.txt b/crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.txt b/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.txt b/crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.txt b/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.txt b/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.txt b/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.txt b/crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.txt b/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.txt b/crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.txt b/crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0109_label.txt b/crates/ra_syntax/test_data/parser/inline/ok/0109_label.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0109_label.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0109_label.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.txt b/crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.txt b/crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.txt b/crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.txt b/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.txt b/crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.txt b/crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.txt b/crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.txt b/crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.txt b/crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.txt b/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.txt b/crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.txt b/crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.txt b/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.txt b/crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.txt b/crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.txt b/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.txt b/crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.txt b/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.txt b/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.txt b/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.txt b/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.txt b/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.txt b/crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.txt b/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.txt b/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.txt b/crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.txt b/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.txt b/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.txt b/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.txt b/crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.txt b/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.txt b/crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0000_empty.txt b/crates/ra_syntax/test_data/parser/ok/0000_empty.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0000_empty.txt rename to crates/ra_syntax/test_data/parser/ok/0000_empty.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0001_struct_item.txt b/crates/ra_syntax/test_data/parser/ok/0001_struct_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0001_struct_item.txt rename to crates/ra_syntax/test_data/parser/ok/0001_struct_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.txt b/crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.txt rename to crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0004_file_shebang.txt b/crates/ra_syntax/test_data/parser/ok/0004_file_shebang.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0004_file_shebang.txt rename to crates/ra_syntax/test_data/parser/ok/0004_file_shebang.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0005_fn_item.txt b/crates/ra_syntax/test_data/parser/ok/0005_fn_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0005_fn_item.txt rename to crates/ra_syntax/test_data/parser/ok/0005_fn_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0006_inner_attributes.txt b/crates/ra_syntax/test_data/parser/ok/0006_inner_attributes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0006_inner_attributes.txt rename to crates/ra_syntax/test_data/parser/ok/0006_inner_attributes.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.txt b/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0007_extern_crate.txt rename to crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0008_mod_item.txt b/crates/ra_syntax/test_data/parser/ok/0008_mod_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0008_mod_item.txt rename to crates/ra_syntax/test_data/parser/ok/0008_mod_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0009_use_item.txt b/crates/ra_syntax/test_data/parser/ok/0009_use_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0009_use_item.txt rename to crates/ra_syntax/test_data/parser/ok/0009_use_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.txt b/crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.txt rename to crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.txt b/crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.txt rename to crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0012_visibility.txt b/crates/ra_syntax/test_data/parser/ok/0012_visibility.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0012_visibility.txt rename to crates/ra_syntax/test_data/parser/ok/0012_visibility.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.txt b/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.txt rename to crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0014_use_tree.txt b/crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0014_use_tree.txt rename to crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0015_use_tree.txt b/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0015_use_tree.txt rename to crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.txt b/crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.txt rename to crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.txt b/crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.txt rename to crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.txt b/crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.txt rename to crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0019_enums.txt b/crates/ra_syntax/test_data/parser/ok/0019_enums.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0019_enums.txt rename to crates/ra_syntax/test_data/parser/ok/0019_enums.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.txt b/crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.txt rename to crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.txt b/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0021_extern_fn.txt rename to crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0022_empty_extern_block.txt b/crates/ra_syntax/test_data/parser/ok/0022_empty_extern_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0022_empty_extern_block.txt rename to crates/ra_syntax/test_data/parser/ok/0022_empty_extern_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0023_static_items.txt b/crates/ra_syntax/test_data/parser/ok/0023_static_items.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0023_static_items.txt rename to crates/ra_syntax/test_data/parser/ok/0023_static_items.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0024_const_item.txt b/crates/ra_syntax/test_data/parser/ok/0024_const_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0024_const_item.txt rename to crates/ra_syntax/test_data/parser/ok/0024_const_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.txt b/crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.txt rename to crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.txt b/crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.txt rename to crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.txt b/crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.txt rename to crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.txt b/crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.txt rename to crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0029_range_forms.txt b/crates/ra_syntax/test_data/parser/ok/0029_range_forms.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0029_range_forms.txt rename to crates/ra_syntax/test_data/parser/ok/0029_range_forms.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.txt b/crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.txt rename to crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0030_traits.txt b/crates/ra_syntax/test_data/parser/ok/0030_traits.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0030_traits.txt rename to crates/ra_syntax/test_data/parser/ok/0030_traits.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0031_extern.txt b/crates/ra_syntax/test_data/parser/ok/0031_extern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0031_extern.txt rename to crates/ra_syntax/test_data/parser/ok/0031_extern.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0032_where_for.txt b/crates/ra_syntax/test_data/parser/ok/0032_where_for.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0032_where_for.txt rename to crates/ra_syntax/test_data/parser/ok/0032_where_for.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0033_label_break.txt b/crates/ra_syntax/test_data/parser/ok/0033_label_break.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0033_label_break.txt rename to crates/ra_syntax/test_data/parser/ok/0033_label_break.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.txt b/crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.txt rename to crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.txt b/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.txt rename to crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.txt b/crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.txt rename to crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0037_mod.txt b/crates/ra_syntax/test_data/parser/ok/0037_mod.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0037_mod.txt rename to crates/ra_syntax/test_data/parser/ok/0037_mod.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.txt b/crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.txt rename to crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.txt b/crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.txt rename to crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.txt b/crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.txt rename to crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.txt b/crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.txt rename to crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.txt b/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.txt rename to crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.txt b/crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.txt rename to crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0044_let_attrs.txt b/crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0044_let_attrs.txt rename to crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.txt b/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.txt rename to crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0046_extern_inner_attributes.txt b/crates/ra_syntax/test_data/parser/ok/0046_extern_inner_attributes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0046_extern_inner_attributes.txt rename to crates/ra_syntax/test_data/parser/ok/0046_extern_inner_attributes.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.txt b/crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.txt rename to crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.txt b/crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.txt rename to crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0049_async_block.txt b/crates/ra_syntax/test_data/parser/ok/0049_async_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0049_async_block.txt rename to crates/ra_syntax/test_data/parser/ok/0049_async_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.txt b/crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.txt rename to crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.txt b/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.txt rename to crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.txt b/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0052_for_range_block.txt rename to crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.txt b/crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.txt rename to crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.txt b/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.txt rename to crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.txt b/crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.txt rename to crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.txt b/crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.txt rename to crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.txt b/crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.txt rename to crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.txt b/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.txt rename to crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.txt b/crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.txt rename to crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0060_as_range.txt b/crates/ra_syntax/test_data/parser/ok/0060_as_range.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0060_as_range.txt rename to crates/ra_syntax/test_data/parser/ok/0060_as_range.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0061_match_full_range.txt b/crates/ra_syntax/test_data/parser/ok/0061_match_full_range.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0061_match_full_range.txt rename to crates/ra_syntax/test_data/parser/ok/0061_match_full_range.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.txt b/crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.txt rename to crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.txt b/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.txt rename to crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.txt b/crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.txt rename to crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.txt b/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.txt rename to crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0065_comment_newline.txt b/crates/ra_syntax/test_data/parser/ok/0065_comment_newline.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0065_comment_newline.txt rename to crates/ra_syntax/test_data/parser/ok/0065_comment_newline.rast diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index db03df1c45cb..4164bfd5eda1 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs @@ -302,42 +302,40 @@ pub fn find_mismatch<'a>(expected: &'a Value, actual: &'a Value) -> Option<(&'a } } -/// Calls callback `f` with input code and file paths of all `.rs` files from `test_data_dir` +/// Calls callback `f` with input code and file paths for each `.rs` file in `test_data_dir` /// subdirectories defined by `paths`. /// -/// If the content of the matching `.txt` file differs from the output of `f()` +/// If the content of the matching output file differs from the output of `f()` /// the test will fail. /// -/// If there is no matching `.txt` file it will be created and filled with the +/// If there is no matching output file it will be created and filled with the /// output of `f()`, but the test will fail. -pub fn dir_tests(test_data_dir: &Path, paths: &[&str], f: F) +pub fn dir_tests(test_data_dir: &Path, paths: &[&str], outfile_extension: &str, f: F) where F: Fn(&str, &Path) -> String, { - for (path, input_code) in collect_tests(test_data_dir, paths) { - let parse_tree = f(&input_code, &path); - let path = path.with_extension("txt"); + for (path, input_code) in collect_rust_files(test_data_dir, paths) { + let actual = f(&input_code, &path); + let path = path.with_extension(outfile_extension); if !path.exists() { println!("\nfile: {}", path.display()); println!("No .txt file with expected result, creating...\n"); - println!("{}\n{}", input_code, parse_tree); - fs::write(&path, &parse_tree).unwrap(); - panic!("No expected result") + println!("{}\n{}", input_code, actual); + fs::write(&path, &actual).unwrap(); + panic!("No expected result"); } let expected = read_text(&path); - let expected = expected.as_str(); - let parse_tree = parse_tree.as_str(); - assert_equal_text(expected, parse_tree, &path); + assert_equal_text(&expected, &actual, &path); } } -/// Collects all `.rs` files from `test_data_dir` subdirectories defined by `paths`. -pub fn collect_tests(test_data_dir: &Path, paths: &[&str]) -> Vec<(PathBuf, String)> { +/// Collects all `.rs` files from `dir` subdirectories defined by `paths`. +pub fn collect_rust_files(root_dir: &Path, paths: &[&str]) -> Vec<(PathBuf, String)> { paths .iter() .flat_map(|path| { - let path = test_data_dir.to_owned().join(path); - test_from_dir(&path).into_iter() + let path = root_dir.to_owned().join(path); + rust_files_in_dir(&path).into_iter() }) .map(|path| { let text = read_text(&path); @@ -347,7 +345,7 @@ pub fn collect_tests(test_data_dir: &Path, paths: &[&str]) -> Vec<(PathBuf, Stri } /// Collects paths to all `.rs` files from `dir` in a sorted `Vec`. -fn test_from_dir(dir: &Path) -> Vec { +fn rust_files_in_dir(dir: &Path) -> Vec { let mut acc = Vec::new(); for file in fs::read_dir(&dir).unwrap() { let file = file.unwrap(); From 52fd2c8e4858c548195edceb83c02437d2d28ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 6 Apr 2020 17:21:33 +0300 Subject: [PATCH 02/24] Fix unnecessary braces warnings --- crates/ra_hir/src/semantics/source_to_def.rs | 18 ++++---- crates/ra_hir_expand/src/builtin_derive.rs | 6 +-- crates/ra_ide/src/call_info.rs | 14 +++---- .../src/completion/complete_fn_param.rs | 4 +- .../ra_ide/src/completion/complete_keyword.rs | 6 +-- .../ra_ide/src/display/navigation_target.rs | 42 +++++++++---------- crates/ra_ide/src/display/structure.rs | 16 +++---- crates/ra_ide/src/goto_type_definition.rs | 6 +-- crates/ra_ide/src/runnables.rs | 4 +- crates/ra_ide_db/src/search.rs | 2 +- crates/ra_ide_db/src/symbol_index.rs | 16 +++---- crates/ra_syntax/src/validation.rs | 12 +++--- 12 files changed, 73 insertions(+), 73 deletions(-) diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs index 8843f2835413..66724919b0ff 100644 --- a/crates/ra_hir/src/semantics/source_to_def.rs +++ b/crates/ra_hir/src/semantics/source_to_def.rs @@ -208,12 +208,12 @@ impl SourceToDefCtx<'_, '_> { for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) { let res: GenericDefId = match_ast! { match (container.value) { - ast::FnDef(it) => { self.fn_to_def(container.with_value(it))?.into() }, - ast::StructDef(it) => { self.struct_to_def(container.with_value(it))?.into() }, - ast::EnumDef(it) => { self.enum_to_def(container.with_value(it))?.into() }, - ast::TraitDef(it) => { self.trait_to_def(container.with_value(it))?.into() }, - ast::TypeAliasDef(it) => { self.type_alias_to_def(container.with_value(it))?.into() }, - ast::ImplDef(it) => { self.impl_to_def(container.with_value(it))?.into() }, + ast::FnDef(it) => self.fn_to_def(container.with_value(it))?.into(), + ast::StructDef(it) => self.struct_to_def(container.with_value(it))?.into(), + ast::EnumDef(it) => self.enum_to_def(container.with_value(it))?.into(), + ast::TraitDef(it) => self.trait_to_def(container.with_value(it))?.into(), + ast::TypeAliasDef(it) => self.type_alias_to_def(container.with_value(it))?.into(), + ast::ImplDef(it) => self.impl_to_def(container.with_value(it))?.into(), _ => continue, } }; @@ -226,9 +226,9 @@ impl SourceToDefCtx<'_, '_> { for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) { let res: DefWithBodyId = match_ast! { match (container.value) { - ast::ConstDef(it) => { self.const_to_def(container.with_value(it))?.into() }, - ast::StaticDef(it) => { self.static_to_def(container.with_value(it))?.into() }, - ast::FnDef(it) => { self.fn_to_def(container.with_value(it))?.into() }, + ast::ConstDef(it) => self.const_to_def(container.with_value(it))?.into(), + ast::StaticDef(it) => self.static_to_def(container.with_value(it))?.into(), + ast::FnDef(it) => self.fn_to_def(container.with_value(it))?.into(), _ => continue, } }; diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index 79aea5806c92..bb45b0f1da06 100644 --- a/crates/ra_hir_expand/src/builtin_derive.rs +++ b/crates/ra_hir_expand/src/builtin_derive.rs @@ -73,9 +73,9 @@ fn parse_adt(tt: &tt::Subtree) -> Result { let node = item.syntax(); let (name, params) = match_ast! { match node { - ast::StructDef(it) => { (it.name(), it.type_param_list()) }, - ast::EnumDef(it) => { (it.name(), it.type_param_list()) }, - ast::UnionDef(it) => { (it.name(), it.type_param_list()) }, + ast::StructDef(it) => (it.name(), it.type_param_list()), + ast::EnumDef(it) => (it.name(), it.type_param_list()), + ast::UnionDef(it) => (it.name(), it.type_param_list()), _ => { debug!("unexpected node is {:?}", node); return Err(mbe::ExpandError::ConversionError) diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs index 39d09a07fe39..ca57eceff788 100644 --- a/crates/ra_ide/src/call_info.rs +++ b/crates/ra_ide/src/call_info.rs @@ -109,7 +109,7 @@ impl FnCallNode { syntax.ancestors().find_map(|node| { match_ast! { match node { - ast::CallExpr(it) => { Some(FnCallNode::CallExpr(it)) }, + ast::CallExpr(it) => Some(FnCallNode::CallExpr(it)), ast::MethodCallExpr(it) => { let arg_list = it.arg_list()?; if !syntax.text_range().is_subrange(&arg_list.syntax().text_range()) { @@ -117,8 +117,8 @@ impl FnCallNode { } Some(FnCallNode::MethodCallExpr(it)) }, - ast::MacroCall(it) => { Some(FnCallNode::MacroCallExpr(it)) }, - _ => { None }, + ast::MacroCall(it) => Some(FnCallNode::MacroCallExpr(it)), + _ => None, } } }) @@ -127,10 +127,10 @@ impl FnCallNode { pub(crate) fn with_node_exact(node: &SyntaxNode) -> Option { match_ast! { match node { - ast::CallExpr(it) => { Some(FnCallNode::CallExpr(it)) }, - ast::MethodCallExpr(it) => { Some(FnCallNode::MethodCallExpr(it)) }, - ast::MacroCall(it) => { Some(FnCallNode::MacroCallExpr(it)) }, - _ => { None }, + ast::CallExpr(it) => Some(FnCallNode::CallExpr(it)), + ast::MethodCallExpr(it) => Some(FnCallNode::MethodCallExpr(it)), + ast::MacroCall(it) => Some(FnCallNode::MacroCallExpr(it)), + _ => None, } } } diff --git a/crates/ra_ide/src/completion/complete_fn_param.rs b/crates/ra_ide/src/completion/complete_fn_param.rs index 9226ac0551af..62ae5ccb4673 100644 --- a/crates/ra_ide/src/completion/complete_fn_param.rs +++ b/crates/ra_ide/src/completion/complete_fn_param.rs @@ -18,8 +18,8 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) for node in ctx.token.parent().ancestors() { match_ast! { match node { - ast::SourceFile(it) => { process(it, &mut params) }, - ast::ItemList(it) => { process(it, &mut params) }, + ast::SourceFile(it) => process(it, &mut params), + ast::ItemList(it) => process(it, &mut params), _ => (), } } diff --git a/crates/ra_ide/src/completion/complete_keyword.rs b/crates/ra_ide/src/completion/complete_keyword.rs index 1e053ea4a6f0..38f9c34e72b4 100644 --- a/crates/ra_ide/src/completion/complete_keyword.rs +++ b/crates/ra_ide/src/completion/complete_keyword.rs @@ -86,9 +86,9 @@ fn is_in_loop_body(leaf: &SyntaxToken) -> bool { } let loop_body = match_ast! { match node { - ast::ForExpr(it) => { it.loop_body() }, - ast::WhileExpr(it) => { it.loop_body() }, - ast::LoopExpr(it) => { it.loop_body() }, + ast::ForExpr(it) => it.loop_body(), + ast::WhileExpr(it) => it.loop_body(), + ast::LoopExpr(it) => it.loop_body(), _ => None, } }; diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index d57451cc8cf8..e61846995a76 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -399,17 +399,17 @@ pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option match_ast! { match node { - ast::FnDef(it) => { it.doc_comment_text() }, - ast::StructDef(it) => { it.doc_comment_text() }, - ast::EnumDef(it) => { it.doc_comment_text() }, - ast::TraitDef(it) => { it.doc_comment_text() }, - ast::Module(it) => { it.doc_comment_text() }, - ast::TypeAliasDef(it) => { it.doc_comment_text() }, - ast::ConstDef(it) => { it.doc_comment_text() }, - ast::StaticDef(it) => { it.doc_comment_text() }, - ast::RecordFieldDef(it) => { it.doc_comment_text() }, - ast::EnumVariant(it) => { it.doc_comment_text() }, - ast::MacroCall(it) => { it.doc_comment_text() }, + ast::FnDef(it) => it.doc_comment_text(), + ast::StructDef(it) => it.doc_comment_text(), + ast::EnumDef(it) => it.doc_comment_text(), + ast::TraitDef(it) => it.doc_comment_text(), + ast::Module(it) => it.doc_comment_text(), + ast::TypeAliasDef(it) => it.doc_comment_text(), + ast::ConstDef(it) => it.doc_comment_text(), + ast::StaticDef(it) => it.doc_comment_text(), + ast::RecordFieldDef(it) => it.doc_comment_text(), + ast::EnumVariant(it) => it.doc_comment_text(), + ast::MacroCall(it) => it.doc_comment_text(), _ => None, } } @@ -424,16 +424,16 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> match_ast! { match node { - ast::FnDef(it) => { it.short_label() }, - ast::StructDef(it) => { it.short_label() }, - ast::EnumDef(it) => { it.short_label() }, - ast::TraitDef(it) => { it.short_label() }, - ast::Module(it) => { it.short_label() }, - ast::TypeAliasDef(it) => { it.short_label() }, - ast::ConstDef(it) => { it.short_label() }, - ast::StaticDef(it) => { it.short_label() }, - ast::RecordFieldDef(it) => { it.short_label() }, - ast::EnumVariant(it) => { it.short_label() }, + ast::FnDef(it) => it.short_label(), + ast::StructDef(it) => it.short_label(), + ast::EnumDef(it) => it.short_label(), + ast::TraitDef(it) => it.short_label(), + ast::Module(it) => it.short_label(), + ast::TypeAliasDef(it) => it.short_label(), + ast::ConstDef(it) => it.short_label(), + ast::StaticDef(it) => it.short_label(), + ast::RecordFieldDef(it) => it.short_label(), + ast::EnumVariant(it) => it.short_label(), _ => None, } } diff --git a/crates/ra_ide/src/display/structure.rs b/crates/ra_ide/src/display/structure.rs index 5774e9a8b410..7a774785c0f3 100644 --- a/crates/ra_ide/src/display/structure.rs +++ b/crates/ra_ide/src/display/structure.rs @@ -117,18 +117,18 @@ fn structure_node(node: &SyntaxNode) -> Option { decl_with_detail(it, Some(detail)) }, - ast::StructDef(it) => { decl(it) }, - ast::EnumDef(it) => { decl(it) }, - ast::EnumVariant(it) => { decl(it) }, - ast::TraitDef(it) => { decl(it) }, - ast::Module(it) => { decl(it) }, + ast::StructDef(it) => decl(it), + ast::EnumDef(it) => decl(it), + ast::EnumVariant(it) => decl(it), + ast::TraitDef(it) => decl(it), + ast::Module(it) => decl(it), ast::TypeAliasDef(it) => { let ty = it.type_ref(); decl_with_type_ref(it, ty) }, - ast::RecordFieldDef(it) => { decl_with_ascription(it) }, - ast::ConstDef(it) => { decl_with_ascription(it) }, - ast::StaticDef(it) => { decl_with_ascription(it) }, + ast::RecordFieldDef(it) => decl_with_ascription(it), + ast::ConstDef(it) => decl_with_ascription(it), + ast::StaticDef(it) => decl_with_ascription(it), ast::ImplDef(it) => { let target_type = it.target_type()?; let target_trait = it.target_trait(); diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs index 869a4708b7d6..bd2688df1b2d 100644 --- a/crates/ra_ide/src/goto_type_definition.rs +++ b/crates/ra_ide/src/goto_type_definition.rs @@ -18,9 +18,9 @@ pub(crate) fn goto_type_definition( let (ty, node) = sema.ancestors_with_macros(token.parent()).find_map(|node| { let ty = match_ast! { match node { - ast::Expr(expr) => { sema.type_of_expr(&expr)? }, - ast::Pat(pat) => { sema.type_of_pat(&pat)? }, - _ => { return None }, + ast::Expr(expr) => sema.type_of_expr(&expr)?, + ast::Pat(pat) => sema.type_of_pat(&pat)?, + _ => return None, } }; diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index 74877e90fec5..9433f3a24762 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs @@ -49,8 +49,8 @@ pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec { fn runnable(sema: &Semantics, item: SyntaxNode) -> Option { match_ast! { match item { - ast::FnDef(it) => { runnable_fn(sema, it) }, - ast::Module(it) => { runnable_mod(sema, it) }, + ast::FnDef(it) => runnable_fn(sema, it), + ast::Module(it) => runnable_mod(sema, it), _ => None, } } diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs index 05a0eed30a8b..1bf014149abb 100644 --- a/crates/ra_ide_db/src/search.rs +++ b/crates/ra_ide_db/src/search.rs @@ -286,7 +286,7 @@ fn reference_access(def: &Definition, name_ref: &ast::NameRef) -> Option {None} + _ => None } } }); diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs index 0f46f93c1725..d30458d8651a 100644 --- a/crates/ra_ide_db/src/symbol_index.rs +++ b/crates/ra_ide_db/src/symbol_index.rs @@ -354,14 +354,14 @@ fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> { } match_ast! { match node { - ast::FnDef(it) => { decl(it) }, - ast::StructDef(it) => { decl(it) }, - ast::EnumDef(it) => { decl(it) }, - ast::TraitDef(it) => { decl(it) }, - ast::Module(it) => { decl(it) }, - ast::TypeAliasDef(it) => { decl(it) }, - ast::ConstDef(it) => { decl(it) }, - ast::StaticDef(it) => { decl(it) }, + ast::FnDef(it) => decl(it), + ast::StructDef(it) => decl(it), + ast::EnumDef(it) => decl(it), + ast::TraitDef(it) => decl(it), + ast::Module(it) => decl(it), + ast::TypeAliasDef(it) => decl(it), + ast::ConstDef(it) => decl(it), + ast::StaticDef(it) => decl(it), ast::MacroCall(it) => { if it.is_macro_rules().is_some() { decl(it) diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index 7915cf8cb219..f85b3e61b475 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs @@ -88,12 +88,12 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec { for node in root.descendants() { match_ast! { match node { - ast::Literal(it) => { validate_literal(it, &mut errors) }, - ast::BlockExpr(it) => { block::validate_block_expr(it, &mut errors) }, - ast::FieldExpr(it) => { validate_numeric_name(it.name_ref(), &mut errors) }, - ast::RecordField(it) => { validate_numeric_name(it.name_ref(), &mut errors) }, - ast::Visibility(it) => { validate_visibility(it, &mut errors) }, - ast::RangeExpr(it) => { validate_range_expr(it, &mut errors) }, + ast::Literal(it) => validate_literal(it, &mut errors), + ast::BlockExpr(it) => block::validate_block_expr(it, &mut errors), + ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), &mut errors), + ast::RecordField(it) => validate_numeric_name(it.name_ref(), &mut errors), + ast::Visibility(it) => validate_visibility(it, &mut errors), + ast::RangeExpr(it) => validate_range_expr(it, &mut errors), _ => (), } } From bf569f8b29d05782597d40ec98ee33bc2574763e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 6 Apr 2020 16:58:16 +0200 Subject: [PATCH 03/24] Check for eprintln on CI --- crates/ra_assists/src/lib.rs | 5 +++++ crates/ra_hir/src/semantics.rs | 2 +- crates/ra_hir_def/src/lib.rs | 5 +++++ crates/ra_hir_ty/src/lib.rs | 5 +++++ crates/ra_ide/src/lib.rs | 5 +++++ crates/rust-analyzer/src/lib.rs | 13 ++----------- crates/stdx/src/lib.rs | 15 +++++++++++++++ 7 files changed, 38 insertions(+), 12 deletions(-) diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index fa3d3913f85a..c698d6e8c472 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs @@ -5,6 +5,11 @@ //! certain context. For example, if the cursor is over `,`, a "swap `,`" assist //! becomes available. +#[allow(unused)] +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; +} + mod assist_ctx; mod marks; #[cfg(test)] diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 16a5fe968097..2ad231d3688b 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -9,6 +9,7 @@ use hir_def::{ AsMacroCall, TraitId, }; use hir_expand::ExpansionInfo; +use itertools::Itertools; use ra_db::{FileId, FileRange}; use ra_prof::profile; use ra_syntax::{ @@ -135,7 +136,6 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { node: &SyntaxNode, offset: TextUnit, ) -> impl Iterator + '_ { - use itertools::Itertools; node.token_at_offset(offset) .map(|token| self.ancestors_with_macros(token.parent())) .kmerge_by(|node1, node2| node1.text_range().len() < node2.text_range().len()) diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index bd32ac20aac6..2d27bbdf8eb2 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -7,6 +7,11 @@ //! Note that `hir_def` is a work in progress, so not all of the above is //! actually true. +#[allow(unused)] +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; +} + pub mod db; pub mod attr; diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index a9022dee774d..9d61bba402cf 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -1,6 +1,11 @@ //! The type system. We currently use this to infer types for completion, hover //! information and various assists. +#[allow(unused)] +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; +} + macro_rules! impl_froms { ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => { $( diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 2853810865f9..5599f143f20b 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -10,6 +10,11 @@ // For proving that RootDatabase is RefUnwindSafe. #![recursion_limit = "128"] +#[allow(unused)] +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; +} + pub mod mock_analysis; mod source_change; diff --git a/crates/rust-analyzer/src/lib.rs b/crates/rust-analyzer/src/lib.rs index 02953be30391..036bf62a73c8 100644 --- a/crates/rust-analyzer/src/lib.rs +++ b/crates/rust-analyzer/src/lib.rs @@ -13,17 +13,8 @@ pub mod cli; #[allow(unused)] -macro_rules! println { - ($($tt:tt)*) => { - compile_error!("stdout is locked, use eprintln") - }; -} - -#[allow(unused)] -macro_rules! print { - ($($tt:tt)*) => { - compile_error!("stdout is locked, use eprint") - }; +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; } mod vfs_glob; diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index d2efa22363a4..401a568bd5bb 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs @@ -2,6 +2,21 @@ use std::{cell::Cell, fmt}; +#[inline(always)] +pub fn is_ci() -> bool { + option_env!("CI").is_some() +} + +#[macro_export] +macro_rules! eprintln { + ($($tt:tt)*) => {{ + if $crate::is_ci() { + panic!("Forgot to remove debug-print?") + } + std::eprintln!($($tt)*) + }} +} + /// Appends formatted string to a `String`. #[macro_export] macro_rules! format_to { From 1b2d255be168333c136677599d2ea8b5a3f5996b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 6 Apr 2020 17:01:46 +0200 Subject: [PATCH 04/24] More general CI env var --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 217f179751a4..02a3b622877e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ on: env: CARGO_INCREMENTAL: 0 CARGO_NET_RETRY: 10 - RUN_SLOW_TESTS: 1 + CI: 1 RUST_BACKTRACE: short RUSTFLAGS: -D warnings RUSTUP_MAX_RETRIES: 10 From 236ac630f6ffc403257d4c77e6187819432956cf Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Mon, 6 Apr 2020 17:24:08 +0200 Subject: [PATCH 05/24] Fix Chalk panic Fixes #3865. Basically I forgot to shift 'back' when we got `dyn Trait`s back from Chalk, so after going through Chalk a few times, the panic happened. --- crates/ra_hir_ty/src/lib.rs | 3 ++- crates/ra_hir_ty/src/tests/traits.rs | 25 +++++++++++++++++++++++++ crates/ra_hir_ty/src/traits/chalk.rs | 7 ++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 9d61bba402cf..717399b6de58 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -860,7 +860,8 @@ pub trait TypeWalk { ); self } - // /// Shifts up debruijn indices of `Ty::Bound` vars by `n`. + + /// Shifts up debruijn indices of `Ty::Bound` vars by `n`. fn shift_bound_vars(self, n: DebruijnIndex) -> Self where Self: Sized, diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index 081aa943a4e9..22ae6ca90922 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs @@ -2021,3 +2021,28 @@ fn main() { "### ); } + +#[test] +fn dyn_trait_through_chalk() { + let t = type_at( + r#" +//- /main.rs +struct Box {} +#[lang = "deref"] +trait Deref { + type Target; +} +impl Deref for Box { + type Target = T; +} +trait Trait { + fn foo(&self); +} + +fn test(x: Box) { + x.foo()<|>; +} +"#, + ); + assert_eq!(t, "()"); +} diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 53ce362ea20f..1bc0f0713581 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs @@ -427,7 +427,12 @@ impl ToChalk for GenericPredicate { db: &dyn HirDatabase, where_clause: chalk_ir::QuantifiedWhereClause, ) -> GenericPredicate { - match where_clause.value { + // we don't produce any where clauses with binders and can't currently deal with them + match where_clause + .value + .shifted_out(&Interner) + .expect("unexpected bound vars in where clause") + { chalk_ir::WhereClause::Implemented(tr) => { GenericPredicate::Implemented(from_chalk(db, tr)) } From 8f7fceeb9ceab6383deae8895c88b3ba53f8dabe Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Mon, 6 Apr 2020 21:41:31 -0700 Subject: [PATCH 06/24] fix cargo check config with custom command --- crates/rust-analyzer/src/config.rs | 40 +++++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index b6a015790223..4734df16ac3b 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -131,37 +131,47 @@ impl Config { set(value, "/cargo/allFeatures", &mut self.cargo.all_features); set(value, "/cargo/features", &mut self.cargo.features); set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); - if let Some(mut args) = get::>(value, "/rustfmt/overrideCommand") { - if !args.is_empty() { + match get::>(value, "/rustfmt/overrideCommand") { + Some(mut args) if !args.is_empty() => { let command = args.remove(0); self.rustfmt = RustfmtConfig::CustomCommand { command, args, } } - } else if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { - set(value, "/rustfmt/extraArgs", extra_args); - } + _ => { + if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { + set(value, "/rustfmt/extraArgs", extra_args); + } + } + }; if let Some(false) = get(value, "/checkOnSave/enable") { + // check is disabled self.check = None; } else { - if let Some(mut args) = get::>(value, "/checkOnSave/overrideCommand") { - if !args.is_empty() { + // check is enabled + match get::>(value, "/checkOnSave/overrideCommand") { + // first see if the user has completely overridden the command + Some(mut args) if !args.is_empty() => { let command = args.remove(0); self.check = Some(FlycheckConfig::CustomCommand { command, args, }); } - - } else if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check - { - set(value, "/checkOnSave/extraArgs", extra_args); - set(value, "/checkOnSave/command", command); - set(value, "/checkOnSave/allTargets", all_targets); - } - }; + // otherwise configure command customizations + _ => { + if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) + = &mut self.check + { + set(value, "/checkOnSave/extraArgs", extra_args); + set(value, "/checkOnSave/command", command); + set(value, "/checkOnSave/allTargets", all_targets); + } + } + }; + } set(value, "/inlayHints/typeHints", &mut self.inlay_hints.type_hints); set(value, "/inlayHints/parameterHints", &mut self.inlay_hints.parameter_hints); From 501c5b45acdc2ad3e6b4572425d40104923e7a75 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Apr 2020 08:51:52 +0200 Subject: [PATCH 07/24] Better config scheme & defaults --- editors/code/package.json | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/editors/code/package.json b/editors/code/package.json index 60ca0c69cdde..8ae8ea414060 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -251,11 +251,15 @@ "description": "Additional arguments to rustfmt" }, "rust-analyzer.rustfmt.overrideCommand": { - "type": "array", + "type": [ + "null", + "array" + ], "items": { - "type": "string" + "type": "string", + "minItems": 1 }, - "default": [], + "default": null, "markdownDescription": "Advanced option, fully override the command rust-analyzer uses for formatting." }, "rust-analyzer.checkOnSave.enable": { @@ -277,11 +281,15 @@ "markdownDescription": "Cargo command to use for `cargo check`" }, "rust-analyzer.checkOnSave.overrideCommand": { - "type": "array", + "type": [ + "null", + "array" + ], "items": { - "type": "string" + "type": "string", + "minItems": 1 }, - "default": [], + "default": null, "markdownDescription": "Advanced option, fully override the command rust-analyzer uses for checking. The command should include `--message=format=json` or similar option." }, "rust-analyzer.checkOnSave.allTargets": { From d3ccc80a2d00f719949a85be938cf445ec5d35bf Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Apr 2020 09:01:01 +0200 Subject: [PATCH 08/24] Run analysis-stats nightly --- .github/workflows/release.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fd184e8f102a..a31b4d3f6779 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -60,6 +60,10 @@ jobs: if: matrix.os != 'ubuntu-latest' run: cargo xtask dist + - name: Nightly analysis-stats check + if: matrix.os == 'ubuntu-latest' && if: github.ref != 'refs/heads/release' + run: ./dist/rust-analyzer analysis-stats . + - name: Upload artifacts uses: actions/upload-artifact@v1 with: From 942836ac33fbebff7179958ebb43317d1e3b2bd0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Apr 2020 09:24:02 +0200 Subject: [PATCH 09/24] Fix yaml --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a31b4d3f6779..f344582fc2f0 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -61,7 +61,7 @@ jobs: run: cargo xtask dist - name: Nightly analysis-stats check - if: matrix.os == 'ubuntu-latest' && if: github.ref != 'refs/heads/release' + if: matrix.os == 'ubuntu-latest' && github.ref != 'refs/heads/release' run: ./dist/rust-analyzer analysis-stats . - name: Upload artifacts From 9c482f4a215ecb98e038e3ea07d9ef9ec3c481f5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Apr 2020 09:40:01 +0200 Subject: [PATCH 10/24] Fix yaml --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f344582fc2f0..4db122ec758b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -62,7 +62,7 @@ jobs: - name: Nightly analysis-stats check if: matrix.os == 'ubuntu-latest' && github.ref != 'refs/heads/release' - run: ./dist/rust-analyzer analysis-stats . + run: ./dist/rust-analyzer-linux analysis-stats . - name: Upload artifacts uses: actions/upload-artifact@v1 From 372e684f6e8fa33e3c7d7de9d6669dfa6da4e818 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Apr 2020 11:37:59 +0200 Subject: [PATCH 11/24] When making a release, just promote the latest nightly --- xtask/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 4f01f84fb410..0b8243f62e61 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -172,8 +172,8 @@ pub fn run_pre_cache() -> Result<()> { pub fn run_release(dry_run: bool) -> Result<()> { if !dry_run { run!("git switch release")?; - run!("git fetch upstream")?; - run!("git reset --hard upstream/master")?; + run!("git fetch upstream --tags --force")?; + run!("git reset --hard tags/nightly")?; run!("git push")?; } From a5ffe53c9d185d790388760dfe09f265e352b6bf Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Apr 2020 13:19:57 +0200 Subject: [PATCH 12/24] Better naming for path completion --- crates/ra_ide/src/completion.rs | 8 ++++---- .../{complete_path.rs => complete_qualified_path.rs} | 0 .../{complete_scope.rs => complete_unqualified_path.rs} | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename crates/ra_ide/src/completion/{complete_path.rs => complete_qualified_path.rs} (100%) rename crates/ra_ide/src/completion/{complete_scope.rs => complete_unqualified_path.rs} (100%) diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs index 93157bbba63f..c9ba1d4ee421 100644 --- a/crates/ra_ide/src/completion.rs +++ b/crates/ra_ide/src/completion.rs @@ -10,8 +10,8 @@ mod complete_pattern; mod complete_fn_param; mod complete_keyword; mod complete_snippet; -mod complete_path; -mod complete_scope; +mod complete_qualified_path; +mod complete_unqualified_path; mod complete_postfix; mod complete_macro_in_item_position; mod complete_trait_impl; @@ -85,8 +85,8 @@ pub(crate) fn completions( complete_keyword::complete_use_tree_keyword(&mut acc, &ctx); complete_snippet::complete_expr_snippet(&mut acc, &ctx); complete_snippet::complete_item_snippet(&mut acc, &ctx); - complete_path::complete_path(&mut acc, &ctx); - complete_scope::complete_scope(&mut acc, &ctx); + complete_qualified_path::complete_path(&mut acc, &ctx); + complete_unqualified_path::complete_scope(&mut acc, &ctx); complete_dot::complete_dot(&mut acc, &ctx); complete_record::complete_record(&mut acc, &ctx); complete_pattern::complete_pattern(&mut acc, &ctx); diff --git a/crates/ra_ide/src/completion/complete_path.rs b/crates/ra_ide/src/completion/complete_qualified_path.rs similarity index 100% rename from crates/ra_ide/src/completion/complete_path.rs rename to crates/ra_ide/src/completion/complete_qualified_path.rs diff --git a/crates/ra_ide/src/completion/complete_scope.rs b/crates/ra_ide/src/completion/complete_unqualified_path.rs similarity index 100% rename from crates/ra_ide/src/completion/complete_scope.rs rename to crates/ra_ide/src/completion/complete_unqualified_path.rs From 021556043425d7b11800532bc06e5d49514c1347 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Apr 2020 13:20:41 +0200 Subject: [PATCH 13/24] Better naming for scope completion --- crates/ra_ide/src/completion.rs | 4 ++-- crates/ra_ide/src/completion/complete_qualified_path.rs | 2 +- crates/ra_ide/src/completion/complete_unqualified_path.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs index c9ba1d4ee421..4a1a2a04a7d1 100644 --- a/crates/ra_ide/src/completion.rs +++ b/crates/ra_ide/src/completion.rs @@ -85,8 +85,8 @@ pub(crate) fn completions( complete_keyword::complete_use_tree_keyword(&mut acc, &ctx); complete_snippet::complete_expr_snippet(&mut acc, &ctx); complete_snippet::complete_item_snippet(&mut acc, &ctx); - complete_qualified_path::complete_path(&mut acc, &ctx); - complete_unqualified_path::complete_scope(&mut acc, &ctx); + complete_qualified_path::complete_qualified_path(&mut acc, &ctx); + complete_unqualified_path::complete_unqualified_path(&mut acc, &ctx); complete_dot::complete_dot(&mut acc, &ctx); complete_record::complete_record(&mut acc, &ctx); complete_pattern::complete_pattern(&mut acc, &ctx); diff --git a/crates/ra_ide/src/completion/complete_qualified_path.rs b/crates/ra_ide/src/completion/complete_qualified_path.rs index 3ed2ae2b632b..d98523406a42 100644 --- a/crates/ra_ide/src/completion/complete_qualified_path.rs +++ b/crates/ra_ide/src/completion/complete_qualified_path.rs @@ -6,7 +6,7 @@ use test_utils::tested_by; use crate::completion::{CompletionContext, Completions}; -pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { +pub(super) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionContext) { let path = match &ctx.path_prefix { Some(path) => path.clone(), _ => return, diff --git a/crates/ra_ide/src/completion/complete_unqualified_path.rs b/crates/ra_ide/src/completion/complete_unqualified_path.rs index 665597e4cbd5..efde9bf73147 100644 --- a/crates/ra_ide/src/completion/complete_unqualified_path.rs +++ b/crates/ra_ide/src/completion/complete_unqualified_path.rs @@ -2,7 +2,7 @@ use crate::completion::{CompletionContext, Completions}; -pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { +pub(super) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionContext) { if !(ctx.is_trivial_path && !ctx.is_pat_binding_or_const) { return; } From 8c378af72117e92bc894fd4a79e978ef0d1c0cc7 Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Tue, 24 Mar 2020 04:40:58 -0700 Subject: [PATCH 14/24] missing match arms diagnostic --- Cargo.lock | 1 + crates/ra_hir/src/diagnostics.rs | 2 +- crates/ra_hir_ty/Cargo.toml | 1 + crates/ra_hir_ty/src/_match.rs | 944 ++++++++++++++++++++++++++++ crates/ra_hir_ty/src/diagnostics.rs | 20 +- crates/ra_hir_ty/src/expr.rs | 53 +- crates/ra_hir_ty/src/infer/pat.rs | 6 +- crates/ra_hir_ty/src/infer/path.rs | 12 +- crates/ra_hir_ty/src/lib.rs | 1 + crates/ra_hir_ty/src/test_db.rs | 6 +- crates/ra_hir_ty/src/tests.rs | 3 +- crates/ra_ide/src/diagnostics.rs | 10 +- 12 files changed, 1048 insertions(+), 11 deletions(-) create mode 100644 crates/ra_hir_ty/src/_match.rs diff --git a/Cargo.lock b/Cargo.lock index 91a57bf796be..eb9824218f3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -995,6 +995,7 @@ dependencies = [ "ra_prof", "ra_syntax", "rustc-hash", + "smallvec", "stdx", "test_utils", ] diff --git a/crates/ra_hir/src/diagnostics.rs b/crates/ra_hir/src/diagnostics.rs index a9040ea3d566..c82883d0c161 100644 --- a/crates/ra_hir/src/diagnostics.rs +++ b/crates/ra_hir/src/diagnostics.rs @@ -1,4 +1,4 @@ //! FIXME: write short doc here pub use hir_def::diagnostics::UnresolvedModule; pub use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink}; -pub use hir_ty::diagnostics::{MissingFields, MissingOkInTailExpr, NoSuchField}; +pub use hir_ty::diagnostics::{MissingFields, MissingMatchArms, MissingOkInTailExpr, NoSuchField}; diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 45be08430a2f..9a4a7aa6f7e6 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml @@ -9,6 +9,7 @@ doctest = false [dependencies] arrayvec = "0.5.1" +smallvec = "1.2.0" ena = "0.13.1" log = "0.4.8" rustc-hash = "1.1.0" diff --git a/crates/ra_hir_ty/src/_match.rs b/crates/ra_hir_ty/src/_match.rs new file mode 100644 index 000000000000..ac66dd415b2d --- /dev/null +++ b/crates/ra_hir_ty/src/_match.rs @@ -0,0 +1,944 @@ +//! This module implements match statement exhaustiveness checking and usefulness checking +//! for match arms. +//! +//! It is modeled on the rustc module `librustc_mir_build::hair::pattern::_match`, which +//! contains very detailed documentation about the match checking algorithm. +use std::sync::Arc; + +use smallvec::{smallvec, SmallVec}; + +use crate::{ + db::HirDatabase, + expr::{Body, Expr, Literal, Pat, PatId}, + InferenceResult, +}; +use hir_def::{adt::VariantData, EnumVariantId, VariantId}; + +#[derive(Debug, Clone, Copy)] +enum PatIdOrWild { + PatId(PatId), + Wild, +} + +impl PatIdOrWild { + fn as_pat(self, cx: &MatchCheckCtx) -> Pat { + match self { + PatIdOrWild::PatId(id) => cx.body.pats[id].clone(), + PatIdOrWild::Wild => Pat::Wild, + } + } + + fn as_id(self) -> Option { + match self { + PatIdOrWild::PatId(id) => Some(id), + PatIdOrWild::Wild => None, + } + } +} + +impl From for PatIdOrWild { + fn from(pat_id: PatId) -> Self { + Self::PatId(pat_id) + } +} + +type PatStackInner = SmallVec<[PatIdOrWild; 2]>; +#[derive(Debug)] +pub(crate) struct PatStack(PatStackInner); + +impl PatStack { + pub(crate) fn from_pattern(pat_id: PatId) -> PatStack { + Self(smallvec!(pat_id.into())) + } + + pub(crate) fn from_wild() -> PatStack { + Self(smallvec!(PatIdOrWild::Wild)) + } + + fn from_slice(slice: &[PatIdOrWild]) -> PatStack { + Self(SmallVec::from_slice(slice)) + } + + fn from_vec(v: PatStackInner) -> PatStack { + Self(v) + } + + fn is_empty(&self) -> bool { + self.0.is_empty() + } + + fn head(&self) -> PatIdOrWild { + self.0[0] + } + + fn get_head(&self) -> Option { + self.0.first().copied() + } + + fn to_tail(&self) -> PatStack { + Self::from_slice(&self.0[1..]) + } + + fn replace_head_with(&self, pat_ids: &[PatId]) -> PatStack { + let mut patterns: PatStackInner = smallvec![]; + for pat in pat_ids { + patterns.push((*pat).into()); + } + for pat in &self.0[1..] { + patterns.push(*pat); + } + PatStack::from_vec(patterns) + } + + // Computes `D(self)`. + fn specialize_wildcard(&self, cx: &MatchCheckCtx) -> Option { + if matches!(self.head().as_pat(cx), Pat::Wild) { + Some(self.to_tail()) + } else { + None + } + } + + // Computes `S(constructor, self)`. + fn specialize_constructor( + &self, + cx: &MatchCheckCtx, + constructor: &Constructor, + ) -> Option { + match (self.head().as_pat(cx), constructor) { + (Pat::Tuple(ref pat_ids), Constructor::Tuple { arity }) => { + if pat_ids.len() != *arity { + return None; + } + + Some(self.replace_head_with(pat_ids)) + } + (Pat::Lit(_), Constructor::Bool(_)) => { + // for now we only support bool literals + Some(self.to_tail()) + } + (Pat::Wild, constructor) => Some(self.expand_wildcard(cx, constructor)), + (Pat::Path(_), Constructor::Enum(constructor)) => { + let pat_id = self.head().as_id().expect("we know this isn't a wild"); + if !enum_variant_matches(cx, pat_id, *constructor) { + return None; + } + // enums with no associated data become `Pat::Path` + Some(self.to_tail()) + } + (Pat::TupleStruct { args: ref pat_ids, .. }, Constructor::Enum(constructor)) => { + let pat_id = self.head().as_id().expect("we know this isn't a wild"); + if !enum_variant_matches(cx, pat_id, *constructor) { + return None; + } + + Some(self.replace_head_with(pat_ids)) + } + (Pat::Or(_), _) => unreachable!("we desugar or patterns so this should never happen"), + (a, b) => unimplemented!("{:?}, {:?}", a, b), + } + } + + fn expand_wildcard(&self, cx: &MatchCheckCtx, constructor: &Constructor) -> PatStack { + assert_eq!( + Pat::Wild, + self.head().as_pat(cx), + "expand_wildcard must only be called on PatStack with wild at head", + ); + + let mut patterns: PatStackInner = smallvec![]; + let arity = match constructor { + Constructor::Bool(_) => 0, + Constructor::Tuple { arity } => *arity, + Constructor::Enum(e) => { + match cx.db.enum_data(e.parent).variants[e.local_id].variant_data.as_ref() { + VariantData::Tuple(struct_field_data) => struct_field_data.len(), + VariantData::Unit => 0, + x => unimplemented!("{:?}", x), + } + } + }; + + for _ in 0..arity { + patterns.push(PatIdOrWild::Wild); + } + + for pat in &self.0[1..] { + patterns.push(*pat); + } + + PatStack::from_vec(patterns) + } +} + +#[derive(Debug)] +pub(crate) struct Matrix(Vec); + +impl Matrix { + pub(crate) fn empty() -> Self { + Self(vec![]) + } + + pub(crate) fn push(&mut self, cx: &MatchCheckCtx, row: PatStack) { + // if the pattern is an or pattern it should be expanded + if let Some(Pat::Or(pat_ids)) = row.get_head().map(|pat_id| pat_id.as_pat(cx)) { + for pat_id in pat_ids { + self.0.push(PatStack::from_pattern(pat_id)); + } + } else { + self.0.push(row); + } + } + + fn is_empty(&self) -> bool { + self.0.is_empty() + } + + fn heads(&self) -> Vec { + self.0.iter().map(|p| p.head()).collect() + } + + // Computes `D(self)`. + fn specialize_wildcard(&self, cx: &MatchCheckCtx) -> Self { + Self::collect(cx, self.0.iter().filter_map(|r| r.specialize_wildcard(cx))) + } + + // Computes `S(constructor, self)`. + fn specialize_constructor(&self, cx: &MatchCheckCtx, constructor: &Constructor) -> Self { + Self::collect(cx, self.0.iter().filter_map(|r| r.specialize_constructor(cx, constructor))) + } + + fn collect>(cx: &MatchCheckCtx, iter: T) -> Self { + let mut matrix = Matrix::empty(); + + for pat in iter { + // using push ensures we expand or-patterns + matrix.push(cx, pat); + } + + matrix + } +} + +#[derive(Clone, Debug, PartialEq)] +pub enum Usefulness { + Useful, + NotUseful, +} + +pub struct MatchCheckCtx<'a> { + pub body: Arc, + pub match_expr: &'a Expr, + pub infer: Arc, + pub db: &'a dyn HirDatabase, +} + +// see src/librustc_mir_build/hair/pattern/_match.rs +// It seems the rustc version of this method is able to assume that all the match arm +// patterns are valid (they are valid given a particular match expression), but I +// don't think we can make that assumption here. How should that be handled? +// +// Perhaps check that validity before passing the patterns into this method? +pub(crate) fn is_useful(cx: &MatchCheckCtx, matrix: &Matrix, v: &PatStack) -> Usefulness { + dbg!(matrix); + dbg!(v); + if v.is_empty() { + if matrix.is_empty() { + return Usefulness::Useful; + } else { + return Usefulness::NotUseful; + } + } + + if let Pat::Or(pat_ids) = v.head().as_pat(cx) { + let any_useful = pat_ids.iter().any(|&pat_id| { + let v = PatStack::from_pattern(pat_id); + + is_useful(cx, matrix, &v) == Usefulness::Useful + }); + + return if any_useful { Usefulness::Useful } else { Usefulness::NotUseful }; + } + + if let Some(constructor) = pat_constructor(cx, v.head()) { + let matrix = matrix.specialize_constructor(&cx, &constructor); + let v = v.specialize_constructor(&cx, &constructor).expect("todo handle this case"); + + is_useful(&cx, &matrix, &v) + } else { + dbg!("expanding wildcard"); + // expanding wildcard + let used_constructors: Vec = + matrix.heads().iter().filter_map(|&p| pat_constructor(cx, p)).collect(); + + // We assume here that the first constructor is the "correct" type. Since we + // only care about the "type" of the constructor (i.e. if it is a bool we + // don't care about the value), this assumption should be valid as long as + // the match statement is well formed. But potentially a better way to handle + // this is to use the match expressions type. + match &used_constructors.first() { + Some(constructor) if all_constructors_covered(&cx, constructor, &used_constructors) => { + dbg!("all constructors are covered"); + // If all constructors are covered, then we need to consider whether + // any values are covered by this wildcard. + // + // For example, with matrix '[[Some(true)], [None]]', all + // constructors are covered (`Some`/`None`), so we need + // to perform specialization to see that our wildcard will cover + // the `Some(false)` case. + let constructor = + matrix.heads().iter().filter_map(|&pat| pat_constructor(cx, pat)).next(); + + if let Some(constructor) = constructor { + dbg!("found constructor {:?}, specializing..", &constructor); + if let Constructor::Enum(e) = constructor { + // For enums we handle each variant as a distinct constructor, so + // here we create a constructor for each variant and then check + // usefulness after specializing for that constructor. + let any_useful = cx + .db + .enum_data(e.parent) + .variants + .iter() + .map(|(local_id, _)| { + Constructor::Enum(EnumVariantId { parent: e.parent, local_id }) + }) + .any(|constructor| { + let matrix = matrix.specialize_constructor(&cx, &constructor); + let v = v.expand_wildcard(&cx, &constructor); + + is_useful(&cx, &matrix, &v) == Usefulness::Useful + }); + + if any_useful { + Usefulness::Useful + } else { + Usefulness::NotUseful + } + } else { + let matrix = matrix.specialize_constructor(&cx, &constructor); + let v = v.expand_wildcard(&cx, &constructor); + + is_useful(&cx, &matrix, &v) + } + } else { + Usefulness::NotUseful + } + } + _ => { + // Either not all constructors are covered, or the only other arms + // are wildcards. Either way, this pattern is useful if it is useful + // when compared to those arms with wildcards. + let matrix = matrix.specialize_wildcard(&cx); + let v = v.to_tail(); + + is_useful(&cx, &matrix, &v) + } + } + } +} + +#[derive(Debug)] +enum Constructor { + Bool(bool), + Tuple { arity: usize }, + Enum(EnumVariantId), +} + +fn pat_constructor(cx: &MatchCheckCtx, pat: PatIdOrWild) -> Option { + match pat.as_pat(cx) { + Pat::Wild => None, + Pat::Tuple(pats) => Some(Constructor::Tuple { arity: pats.len() }), + Pat::Lit(lit_expr) => { + // for now we only support bool literals + match cx.body.exprs[lit_expr] { + Expr::Literal(Literal::Bool(val)) => Some(Constructor::Bool(val)), + _ => unimplemented!(), + } + } + Pat::TupleStruct { .. } | Pat::Path(_) => { + let pat_id = pat.as_id().expect("we already know this pattern is not a wild"); + let variant_id = + cx.infer.variant_resolution_for_pat(pat_id).unwrap_or_else(|| unimplemented!()); + match variant_id { + VariantId::EnumVariantId(enum_variant_id) => { + Some(Constructor::Enum(enum_variant_id)) + } + _ => unimplemented!(), + } + } + x => unimplemented!("{:?} not yet implemented", x), + } +} + +fn all_constructors_covered( + cx: &MatchCheckCtx, + constructor: &Constructor, + used_constructors: &[Constructor], +) -> bool { + match constructor { + Constructor::Tuple { arity } => { + used_constructors.iter().any(|constructor| match constructor { + Constructor::Tuple { arity: used_arity } => arity == used_arity, + _ => false, + }) + } + Constructor::Bool(_) => { + if used_constructors.is_empty() { + return false; + } + + let covers_true = + used_constructors.iter().any(|c| matches!(c, Constructor::Bool(true))); + let covers_false = + used_constructors.iter().any(|c| matches!(c, Constructor::Bool(false))); + + covers_true && covers_false + } + Constructor::Enum(e) => cx.db.enum_data(e.parent).variants.iter().all(|(id, _)| { + for constructor in used_constructors { + if let Constructor::Enum(e) = constructor { + if id == e.local_id { + return true; + } + } + } + + false + }), + } +} + +fn enum_variant_matches(cx: &MatchCheckCtx, pat_id: PatId, enum_variant_id: EnumVariantId) -> bool { + if let Some(VariantId::EnumVariantId(pat_variant_id)) = + cx.infer.variant_resolution_for_pat(pat_id) + { + if pat_variant_id.local_id == enum_variant_id.local_id { + return true; + } + } + false +} + +#[cfg(test)] +mod tests { + pub(super) use insta::assert_snapshot; + pub(super) use ra_db::fixture::WithFixture; + + pub(super) use crate::test_db::TestDB; + + pub(super) fn check_diagnostic_message(content: &str) -> String { + TestDB::with_single_file(content).0.diagnostics().0 + } + + pub(super) fn check_diagnostic_with_no_fix(content: &str) { + let diagnostic_count = TestDB::with_single_file(content).0.diagnostics().1; + + assert_eq!(1, diagnostic_count, "no diagnotic reported"); + } + + pub(super) fn check_no_diagnostic(content: &str) { + let diagnostic_count = TestDB::with_single_file(content).0.diagnostics().1; + + assert_eq!(0, diagnostic_count, "expected no diagnostic, found one"); + } + + #[test] + fn empty_tuple_no_arms_diagnostic_message() { + let content = r" + fn test_fn() { + match () { + } + } + "; + + assert_snapshot!( + check_diagnostic_message(content), + @"\"{\\n }\": Missing match arm\n" + ); + } + + #[test] + fn empty_tuple_no_arms() { + let content = r" + fn test_fn() { + match () { + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn empty_tuple_no_diagnostic() { + let content = r" + fn test_fn() { + match () { + () => {} + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn tuple_of_empty_tuple_no_arms() { + let content = r" + fn test_fn() { + match (()) { + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn tuple_of_empty_tuple_no_diagnostic() { + let content = r" + fn test_fn() { + match (()) { + (()) => {} + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn tuple_of_two_empty_tuple_no_arms() { + let content = r" + fn test_fn() { + match ((), ()) { + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn tuple_of_two_empty_tuple_no_diagnostic() { + let content = r" + fn test_fn() { + match ((), ()) { + ((), ()) => {} + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn bool_no_arms() { + let content = r" + fn test_fn() { + match false { + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn bool_missing_arm() { + let content = r" + fn test_fn() { + match false { + true => {} + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn bool_no_diagnostic() { + let content = r" + fn test_fn() { + match false { + true => {} + false => {} + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn tuple_of_bools_no_arms() { + let content = r" + fn test_fn() { + match (false, true) { + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn tuple_of_bools_missing_arms() { + let content = r" + fn test_fn() { + match (false, true) { + (true, true) => {}, + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn tuple_of_bools_no_diagnostic() { + let content = r" + fn test_fn() { + match (false, true) { + (true, true) => {}, + (true, false) => {}, + (false, true) => {}, + (false, false) => {}, + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn tuple_of_tuple_and_bools_no_arms() { + let content = r" + fn test_fn() { + match (false, ((), false)) { + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn tuple_of_tuple_and_bools_missing_arms() { + let content = r" + fn test_fn() { + match (false, ((), false)) { + (true, ((), true)) => {}, + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn tuple_of_tuple_and_bools_no_diagnostic() { + let content = r" + fn test_fn() { + match (false, ((), false)) { + (true, ((), true)) => {}, + (true, ((), false)) => {}, + (false, ((), true)) => {}, + (false, ((), false)) => {}, + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn tuple_of_tuple_and_bools_wildcard_missing_arms() { + let content = r" + fn test_fn() { + match (false, ((), false)) { + (true, _) => {}, + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn tuple_of_tuple_and_bools_wildcard_no_diagnostic() { + let content = r" + fn test_fn() { + match (false, ((), false)) { + (true, ((), true)) => {}, + (true, ((), false)) => {}, + (false, _) => {}, + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn enum_no_arms() { + let content = r" + enum Either { + A, + B, + } + fn test_fn() { + match Either::A { + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn enum_missing_arms() { + let content = r" + enum Either { + A, + B, + } + fn test_fn() { + match Either::B { + Either::A => {}, + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn enum_no_diagnostic() { + let content = r" + enum Either { + A, + B, + } + fn test_fn() { + match Either::B { + Either::A => {}, + Either::B => {}, + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn enum_containing_bool_no_arms() { + let content = r" + enum Either { + A(bool), + B, + } + fn test_fn() { + match Either::B { + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn enum_containing_bool_missing_arms() { + let content = r" + enum Either { + A(bool), + B, + } + fn test_fn() { + match Either::B { + Either::A(true) => (), + Either::B => (), + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn enum_containing_bool_no_diagnostic() { + let content = r" + enum Either { + A(bool), + B, + } + fn test_fn() { + match Either::B { + Either::A(true) => (), + Either::A(false) => (), + Either::B => (), + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn enum_containing_bool_with_wild_no_diagnostic() { + let content = r" + enum Either { + A(bool), + B, + } + fn test_fn() { + match Either::B { + Either::B => (), + _ => (), + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn enum_containing_bool_with_wild_2_no_diagnostic() { + let content = r" + enum Either { + A(bool), + B, + } + fn test_fn() { + match Either::B { + Either::A(_) => (), + Either::B => (), + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn enum_different_sizes_missing_arms() { + let content = r" + enum Either { + A(bool), + B(bool, bool), + } + fn test_fn() { + match Either::A(false) { + Either::A(_) => (), + Either::B(false, _) => (), + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn enum_different_sizes_no_diagnostic() { + let content = r" + enum Either { + A(bool), + B(bool, bool), + } + fn test_fn() { + match Either::A(false) { + Either::A(_) => (), + Either::B(true, _) => (), + Either::B(false, _) => (), + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn or_no_diagnostic() { + let content = r" + enum Either { + A(bool), + B(bool, bool), + } + fn test_fn() { + match Either::A(false) { + Either::A(true) | Either::A(false) => (), + Either::B(true, _) => (), + Either::B(false, _) => (), + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn tuple_of_enum_no_diagnostic() { + let content = r" + enum Either { + A(bool), + B(bool, bool), + } + enum Either2 { + C, + D, + } + fn test_fn() { + match (Either::A(false), Either2::C) { + (Either::A(true), _) | (Either::A(false), _) => (), + (Either::B(true, _), Either2::C) => (), + (Either::B(false, _), Either2::C) => (), + (Either::B(_, _), Either2::D) => (), + } + } + "; + + check_no_diagnostic(content); + } +} + +#[cfg(test)] +mod false_negatives { + //! The implementation of match checking here is a work in progress. As we roll this out, we + //! prefer false negatives to false positives (ideally there would be no false positives). This + //! test module should document known false negatives. Eventually we will have a complete + //! implementation of match checking and this module will be empty. + //! + //! The reasons for documenting known false negatives: + //! + //! 1. It acts as a backlog of work that can be done to improve the behavior of the system. + //! 2. It ensures the code doesn't panic when handling these cases. + + use super::tests::*; + + #[test] + fn mismatched_types() { + let content = r" + enum Either { + A, + B, + } + enum Either2 { + C, + D, + } + fn test_fn() { + match Either::A { + Either2::C => (), + Either2::D => (), + } + } + "; + + // This is a false negative. + // We don't currently check that the match arms actually + // match the type of the match expression. + check_no_diagnostic(content); + } +} diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 0f8522021e0f..3457905e225e 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -6,7 +6,7 @@ use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile}; use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr}; use stdx::format_to; -pub use hir_def::diagnostics::UnresolvedModule; +pub use hir_def::{diagnostics::UnresolvedModule, expr::MatchArm}; pub use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink}; #[derive(Debug)] @@ -62,6 +62,24 @@ impl AstDiagnostic for MissingFields { } } +#[derive(Debug)] +pub struct MissingMatchArms { + pub file: HirFileId, + pub arms: AstPtr, +} + +impl Diagnostic for MissingMatchArms { + fn message(&self) -> String { + String::from("Missing match arm") + } + fn source(&self) -> InFile { + InFile { file_id: self.file, value: self.arms.into() } + } + fn as_any(&self) -> &(dyn Any + Send + 'static) { + self + } +} + #[derive(Debug)] pub struct MissingOkInTailExpr { pub file: HirFileId, diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index b7b476b4c19b..3caeeb394606 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs @@ -14,9 +14,10 @@ use rustc_hash::FxHashSet; use crate::{ db::HirDatabase, - diagnostics::{MissingFields, MissingOkInTailExpr}, + diagnostics::{MissingFields, MissingMatchArms, MissingOkInTailExpr}, utils::variant_data, ApplicationTy, InferenceResult, Ty, TypeCtor, + _match::{is_useful, MatchCheckCtx, Matrix, PatStack, Usefulness}, }; pub use hir_def::{ @@ -52,15 +53,63 @@ impl<'a, 'b> ExprValidator<'a, 'b> { for e in body.exprs.iter() { if let (id, Expr::RecordLit { path, fields, spread }) = e { self.validate_record_literal(id, path, fields, *spread, db); + } else if let (id, Expr::Match { expr, arms }) = e { + self.validate_match(id, *expr, arms, db, self.infer.clone()); } } let body_expr = &body[body.body_expr]; - if let Expr::Block { statements: _, tail: Some(t) } = body_expr { + if let Expr::Block { tail: Some(t), .. } = body_expr { self.validate_results_in_tail_expr(body.body_expr, *t, db); } } + fn validate_match( + &mut self, + id: ExprId, + expr: ExprId, + arms: &[MatchArm], + db: &dyn HirDatabase, + infer: Arc, + ) { + let (body, source_map): (Arc, Arc) = + db.body_with_source_map(self.func.into()); + + let match_expr: &hir_def::expr::Expr = &body[expr]; + + let cx = MatchCheckCtx { body: body.clone(), match_expr, infer, db }; + let pats = arms.iter().map(|arm| arm.pat); + + let mut seen = Matrix::empty(); + for pat in pats { + // If we had a NotUsefulMatchArm diagnostic, we could + // check the usefulness of each pattern as we added it + // to the matrix here. + let v = PatStack::from_pattern(pat); + seen.push(&cx, v); + } + + match is_useful(&cx, &seen, &PatStack::from_wild()) { + Usefulness::Useful => (), + // if a wildcard pattern is not useful, then all patterns are covered + Usefulness::NotUseful => return, + } + + if let Ok(source_ptr) = source_map.expr_syntax(id) { + if let Some(expr) = source_ptr.value.left() { + let root = source_ptr.file_syntax(db.upcast()); + if let ast::Expr::MatchExpr(match_expr) = expr.to_node(&root) { + if let Some(arms) = match_expr.match_arm_list() { + self.sink.push(MissingMatchArms { + file: source_ptr.file_id, + arms: AstPtr::new(&arms), + }) + } + } + } + } + } + fn validate_record_literal( &mut self, id: ExprId, diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/ra_hir_ty/src/infer/pat.rs index 86acd27f8dfc..69bbb4307f59 100644 --- a/crates/ra_hir_ty/src/infer/pat.rs +++ b/crates/ra_hir_ty/src/infer/pat.rs @@ -21,9 +21,13 @@ impl<'a> InferenceContext<'a> { subpats: &[PatId], expected: &Ty, default_bm: BindingMode, + id: PatId, ) -> Ty { let (ty, def) = self.resolve_variant(path); let var_data = def.map(|it| variant_data(self.db.upcast(), it)); + if let Some(variant) = def { + self.write_variant_resolution(id.into(), variant); + } self.unify(&ty, expected); let substs = ty.substs().unwrap_or_else(Substs::empty); @@ -152,7 +156,7 @@ impl<'a> InferenceContext<'a> { Ty::apply_one(TypeCtor::Ref(*mutability), subty) } Pat::TupleStruct { path: p, args: subpats } => { - self.infer_tuple_struct_pat(p.as_ref(), subpats, expected, default_bm) + self.infer_tuple_struct_pat(p.as_ref(), subpats, expected, default_bm, pat) } Pat::Record { path: p, args: fields } => { self.infer_record_pat(p.as_ref(), fields, expected, default_bm, pat) diff --git a/crates/ra_hir_ty/src/infer/path.rs b/crates/ra_hir_ty/src/infer/path.rs index 318652c6113b..2b6bc0f798f7 100644 --- a/crates/ra_hir_ty/src/infer/path.rs +++ b/crates/ra_hir_ty/src/infer/path.rs @@ -67,8 +67,16 @@ impl<'a> InferenceContext<'a> { ValueNs::FunctionId(it) => it.into(), ValueNs::ConstId(it) => it.into(), ValueNs::StaticId(it) => it.into(), - ValueNs::StructId(it) => it.into(), - ValueNs::EnumVariantId(it) => it.into(), + ValueNs::StructId(it) => { + self.write_variant_resolution(id, it.into()); + + it.into() + } + ValueNs::EnumVariantId(it) => { + self.write_variant_resolution(id, it.into()); + + it.into() + } }; let ty = self.db.value_ty(typable); diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 717399b6de58..18f74d3b12bd 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -43,6 +43,7 @@ mod tests; #[cfg(test)] mod test_db; mod marks; +mod _match; use std::ops::Deref; use std::sync::Arc; diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/ra_hir_ty/src/test_db.rs index 208096aab6d1..3a4d58bf9c4f 100644 --- a/crates/ra_hir_ty/src/test_db.rs +++ b/crates/ra_hir_ty/src/test_db.rs @@ -105,8 +105,9 @@ impl TestDB { } // FIXME: don't duplicate this - pub fn diagnostics(&self) -> String { + pub fn diagnostics(&self) -> (String, u32) { let mut buf = String::new(); + let mut count = 0; let crate_graph = self.crate_graph(); for krate in crate_graph.iter() { let crate_def_map = self.crate_def_map(krate); @@ -133,13 +134,14 @@ impl TestDB { let infer = self.infer(f.into()); let mut sink = DiagnosticSink::new(|d| { format_to!(buf, "{:?}: {}\n", d.syntax_node(self).text(), d.message()); + count += 1; }); infer.add_diagnostics(self, f, &mut sink); let mut validator = ExprValidator::new(f, infer, &mut sink); validator.validate_body(self); } } - buf + (buf, count) } } diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 027e5a8f88a0..e4a103d1be10 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs @@ -309,7 +309,8 @@ fn no_such_field_diagnostics() { } ", ) - .diagnostics(); + .diagnostics() + .0; assert_snapshot!(diagnostics, @r###" "baz: 62": no such field diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index c1d7ddaf2343..901ad104c10f 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -101,6 +101,14 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec fix, }) }) + .on::(|d| { + res.borrow_mut().push(Diagnostic { + range: d.highlight_range(), + message: d.message(), + severity: Severity::Error, + fix: None, + }) + }) .on::(|d| { let node = d.ast(db); let replacement = format!("Ok({})", node.syntax()); @@ -291,7 +299,7 @@ mod tests { fn check_no_diagnostic(content: &str) { let (analysis, file_id) = single_file(content); let diagnostics = analysis.diagnostics(file_id).unwrap(); - assert_eq!(diagnostics.len(), 0); + assert_eq!(diagnostics.len(), 0, "expected no diagnostic, found one"); } #[test] From b87b7a088f34ff794fc19e57ee2ae1cfe81a12df Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Sat, 4 Apr 2020 18:02:27 -0700 Subject: [PATCH 15/24] remove panics --- crates/ra_hir_ty/src/_match.rs | 271 +++++++++++++++++++++++++-------- crates/ra_hir_ty/src/expr.rs | 7 +- 2 files changed, 213 insertions(+), 65 deletions(-) diff --git a/crates/ra_hir_ty/src/_match.rs b/crates/ra_hir_ty/src/_match.rs index ac66dd415b2d..de291c1f6074 100644 --- a/crates/ra_hir_ty/src/_match.rs +++ b/crates/ra_hir_ty/src/_match.rs @@ -42,6 +42,10 @@ impl From for PatIdOrWild { } } +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct MatchCheckNotImplemented; +pub type MatchCheckResult = Result; + type PatStackInner = SmallVec<[PatIdOrWild; 2]>; #[derive(Debug)] pub(crate) struct PatStack(PatStackInner); @@ -104,42 +108,49 @@ impl PatStack { &self, cx: &MatchCheckCtx, constructor: &Constructor, - ) -> Option { - match (self.head().as_pat(cx), constructor) { + ) -> MatchCheckResult> { + let result = match (self.head().as_pat(cx), constructor) { (Pat::Tuple(ref pat_ids), Constructor::Tuple { arity }) => { if pat_ids.len() != *arity { - return None; + None + } else { + Some(self.replace_head_with(pat_ids)) } - - Some(self.replace_head_with(pat_ids)) } (Pat::Lit(_), Constructor::Bool(_)) => { // for now we only support bool literals Some(self.to_tail()) } - (Pat::Wild, constructor) => Some(self.expand_wildcard(cx, constructor)), + (Pat::Wild, constructor) => Some(self.expand_wildcard(cx, constructor)?), (Pat::Path(_), Constructor::Enum(constructor)) => { + // enums with no associated data become `Pat::Path` let pat_id = self.head().as_id().expect("we know this isn't a wild"); if !enum_variant_matches(cx, pat_id, *constructor) { - return None; + None + } else { + Some(self.to_tail()) } - // enums with no associated data become `Pat::Path` - Some(self.to_tail()) } (Pat::TupleStruct { args: ref pat_ids, .. }, Constructor::Enum(constructor)) => { let pat_id = self.head().as_id().expect("we know this isn't a wild"); if !enum_variant_matches(cx, pat_id, *constructor) { - return None; + None + } else { + Some(self.replace_head_with(pat_ids)) } - - Some(self.replace_head_with(pat_ids)) } (Pat::Or(_), _) => unreachable!("we desugar or patterns so this should never happen"), - (a, b) => unimplemented!("{:?}, {:?}", a, b), - } + (_, _) => return Err(MatchCheckNotImplemented), + }; + + Ok(result) } - fn expand_wildcard(&self, cx: &MatchCheckCtx, constructor: &Constructor) -> PatStack { + fn expand_wildcard( + &self, + cx: &MatchCheckCtx, + constructor: &Constructor, + ) -> MatchCheckResult { assert_eq!( Pat::Wild, self.head().as_pat(cx), @@ -154,7 +165,7 @@ impl PatStack { match cx.db.enum_data(e.parent).variants[e.local_id].variant_data.as_ref() { VariantData::Tuple(struct_field_data) => struct_field_data.len(), VariantData::Unit => 0, - x => unimplemented!("{:?}", x), + _ => return Err(MatchCheckNotImplemented), } } }; @@ -167,7 +178,7 @@ impl PatStack { patterns.push(*pat); } - PatStack::from_vec(patterns) + Ok(PatStack::from_vec(patterns)) } } @@ -204,8 +215,19 @@ impl Matrix { } // Computes `S(constructor, self)`. - fn specialize_constructor(&self, cx: &MatchCheckCtx, constructor: &Constructor) -> Self { - Self::collect(cx, self.0.iter().filter_map(|r| r.specialize_constructor(cx, constructor))) + fn specialize_constructor( + &self, + cx: &MatchCheckCtx, + constructor: &Constructor, + ) -> MatchCheckResult { + let mut new_matrix = Matrix::empty(); + for pat in &self.0 { + if let Some(pat) = pat.specialize_constructor(cx, constructor)? { + new_matrix.push(cx, pat); + } + } + + Ok(new_matrix) } fn collect>(cx: &MatchCheckCtx, iter: T) -> Self { @@ -239,37 +261,56 @@ pub struct MatchCheckCtx<'a> { // don't think we can make that assumption here. How should that be handled? // // Perhaps check that validity before passing the patterns into this method? -pub(crate) fn is_useful(cx: &MatchCheckCtx, matrix: &Matrix, v: &PatStack) -> Usefulness { - dbg!(matrix); - dbg!(v); +pub(crate) fn is_useful( + cx: &MatchCheckCtx, + matrix: &Matrix, + v: &PatStack, +) -> MatchCheckResult { if v.is_empty() { - if matrix.is_empty() { - return Usefulness::Useful; - } else { - return Usefulness::NotUseful; - } + let result = if matrix.is_empty() { Usefulness::Useful } else { Usefulness::NotUseful }; + + return Ok(result); } if let Pat::Or(pat_ids) = v.head().as_pat(cx) { + let mut found_unimplemented = false; let any_useful = pat_ids.iter().any(|&pat_id| { let v = PatStack::from_pattern(pat_id); - is_useful(cx, matrix, &v) == Usefulness::Useful + match is_useful(cx, matrix, &v) { + Ok(Usefulness::Useful) => true, + Ok(Usefulness::NotUseful) => false, + _ => { + found_unimplemented = true; + false + } + } }); - return if any_useful { Usefulness::Useful } else { Usefulness::NotUseful }; + return if any_useful { + Ok(Usefulness::Useful) + } else if found_unimplemented { + Err(MatchCheckNotImplemented) + } else { + Ok(Usefulness::NotUseful) + }; } - if let Some(constructor) = pat_constructor(cx, v.head()) { - let matrix = matrix.specialize_constructor(&cx, &constructor); - let v = v.specialize_constructor(&cx, &constructor).expect("todo handle this case"); + if let Some(constructor) = pat_constructor(cx, v.head())? { + let matrix = matrix.specialize_constructor(&cx, &constructor)?; + let v = v + .specialize_constructor(&cx, &constructor)? + .expect("we know this can't fail because we get the constructor from `v.head()` above"); is_useful(&cx, &matrix, &v) } else { - dbg!("expanding wildcard"); // expanding wildcard - let used_constructors: Vec = - matrix.heads().iter().filter_map(|&p| pat_constructor(cx, p)).collect(); + let mut used_constructors: Vec = vec![]; + for pat in matrix.heads() { + if let Some(constructor) = pat_constructor(cx, pat)? { + used_constructors.push(constructor); + } + } // We assume here that the first constructor is the "correct" type. Since we // only care about the "type" of the constructor (i.e. if it is a bool we @@ -278,7 +319,6 @@ pub(crate) fn is_useful(cx: &MatchCheckCtx, matrix: &Matrix, v: &PatStack) -> Us // this is to use the match expressions type. match &used_constructors.first() { Some(constructor) if all_constructors_covered(&cx, constructor, &used_constructors) => { - dbg!("all constructors are covered"); // If all constructors are covered, then we need to consider whether // any values are covered by this wildcard. // @@ -286,43 +326,48 @@ pub(crate) fn is_useful(cx: &MatchCheckCtx, matrix: &Matrix, v: &PatStack) -> Us // constructors are covered (`Some`/`None`), so we need // to perform specialization to see that our wildcard will cover // the `Some(false)` case. - let constructor = - matrix.heads().iter().filter_map(|&pat| pat_constructor(cx, pat)).next(); + let mut constructor = None; + for pat in matrix.heads() { + if let Some(c) = pat_constructor(cx, pat)? { + constructor = Some(c); + break; + } + } if let Some(constructor) = constructor { - dbg!("found constructor {:?}, specializing..", &constructor); if let Constructor::Enum(e) = constructor { // For enums we handle each variant as a distinct constructor, so // here we create a constructor for each variant and then check // usefulness after specializing for that constructor. - let any_useful = cx - .db - .enum_data(e.parent) - .variants - .iter() - .map(|(local_id, _)| { + let mut found_unimplemented = false; + for constructor in + cx.db.enum_data(e.parent).variants.iter().map(|(local_id, _)| { Constructor::Enum(EnumVariantId { parent: e.parent, local_id }) }) - .any(|constructor| { - let matrix = matrix.specialize_constructor(&cx, &constructor); - let v = v.expand_wildcard(&cx, &constructor); + { + let matrix = matrix.specialize_constructor(&cx, &constructor)?; + let v = v.expand_wildcard(&cx, &constructor)?; - is_useful(&cx, &matrix, &v) == Usefulness::Useful - }); + match is_useful(&cx, &matrix, &v) { + Ok(Usefulness::Useful) => return Ok(Usefulness::Useful), + Ok(Usefulness::NotUseful) => continue, + _ => found_unimplemented = true, + }; + } - if any_useful { - Usefulness::Useful + if found_unimplemented { + Err(MatchCheckNotImplemented) } else { - Usefulness::NotUseful + Ok(Usefulness::NotUseful) } } else { - let matrix = matrix.specialize_constructor(&cx, &constructor); - let v = v.expand_wildcard(&cx, &constructor); + let matrix = matrix.specialize_constructor(&cx, &constructor)?; + let v = v.expand_wildcard(&cx, &constructor)?; is_useful(&cx, &matrix, &v) } } else { - Usefulness::NotUseful + Ok(Usefulness::NotUseful) } } _ => { @@ -345,30 +390,32 @@ enum Constructor { Enum(EnumVariantId), } -fn pat_constructor(cx: &MatchCheckCtx, pat: PatIdOrWild) -> Option { - match pat.as_pat(cx) { +fn pat_constructor(cx: &MatchCheckCtx, pat: PatIdOrWild) -> MatchCheckResult> { + let res = match pat.as_pat(cx) { Pat::Wild => None, Pat::Tuple(pats) => Some(Constructor::Tuple { arity: pats.len() }), Pat::Lit(lit_expr) => { // for now we only support bool literals match cx.body.exprs[lit_expr] { Expr::Literal(Literal::Bool(val)) => Some(Constructor::Bool(val)), - _ => unimplemented!(), + _ => return Err(MatchCheckNotImplemented), } } Pat::TupleStruct { .. } | Pat::Path(_) => { let pat_id = pat.as_id().expect("we already know this pattern is not a wild"); let variant_id = - cx.infer.variant_resolution_for_pat(pat_id).unwrap_or_else(|| unimplemented!()); + cx.infer.variant_resolution_for_pat(pat_id).ok_or(MatchCheckNotImplemented)?; match variant_id { VariantId::EnumVariantId(enum_variant_id) => { Some(Constructor::Enum(enum_variant_id)) } - _ => unimplemented!(), + _ => return Err(MatchCheckNotImplemented), } } - x => unimplemented!("{:?} not yet implemented", x), - } + _ => return Err(MatchCheckNotImplemented), + }; + + Ok(res) } fn all_constructors_covered( @@ -613,6 +660,34 @@ mod tests { check_no_diagnostic(content); } + #[test] + fn tuple_of_bools_binding_missing_arms() { + let content = r" + fn test_fn() { + match (false, true) { + (true, _x) => {}, + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn tuple_of_bools_binding_no_diagnostic() { + let content = r" + fn test_fn() { + match (false, true) { + (true, _x) => {}, + (false, true) => {}, + (false, false) => {}, + } + } + "; + + check_no_diagnostic(content); + } + #[test] fn tuple_of_tuple_and_bools_no_arms() { let content = r" @@ -941,4 +1016,74 @@ mod false_negatives { // match the type of the match expression. check_no_diagnostic(content); } + + #[test] + fn mismatched_types_with_different_arity() { + let content = r" + fn test_fn() { + match (true, false) { + (true, false, true) => (), + (true) => (), + } + } + "; + + // This is a false negative. + // We don't currently check that the match arms actually + // match the type of the match expression. This test + // checks to ensure we don't panic when the code we are + // checking is malformed in such a way that the arity of the + // constructors doesn't match. + check_no_diagnostic(content); + } + + #[test] + fn integers() { + let content = r" + fn test_fn() { + match 5 { + 10 => (), + 11..20 => (), + } + } + "; + + // This is a false negative. + // We don't currently check integer exhaustiveness. + check_no_diagnostic(content); + } + + #[test] + fn enum_record() { + let content = r" + enum Either { + A { foo: u32 }, + B, + } + fn test_fn() { + match Either::B { + Either::A { foo: 5 } => (), + } + } + "; + + // This is a false negative. + // We don't currently handle enum record types. + check_no_diagnostic(content); + } + + #[test] + fn enum_not_in_scope() { + let content = r" + fn test_fn() { + match Foo::Bar { + Foo::Baz => (), + } + } + "; + + // This is a false negative. + // The enum is not in scope so we don't perform exhaustiveness checking. + check_no_diagnostic(content); + } } diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index 3caeeb394606..7498d04dcb4d 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs @@ -90,9 +90,12 @@ impl<'a, 'b> ExprValidator<'a, 'b> { } match is_useful(&cx, &seen, &PatStack::from_wild()) { - Usefulness::Useful => (), + Ok(Usefulness::Useful) => (), // if a wildcard pattern is not useful, then all patterns are covered - Usefulness::NotUseful => return, + Ok(Usefulness::NotUseful) => return, + // this path is for unimplemented checks, so we err on the side of not + // reporting any errors + _ => return, } if let Ok(source_ptr) = source_map.expr_syntax(id) { From 43dfd894934cf7c9161e473495a4e24965239475 Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Sun, 5 Apr 2020 10:16:34 -0700 Subject: [PATCH 16/24] handle non matching enum pattern types --- crates/ra_hir_ty/src/_match.rs | 68 +++++++++++++++++----------------- crates/ra_hir_ty/src/expr.rs | 30 +++++++++++---- 2 files changed, 57 insertions(+), 41 deletions(-) diff --git a/crates/ra_hir_ty/src/_match.rs b/crates/ra_hir_ty/src/_match.rs index de291c1f6074..91206adc3e6f 100644 --- a/crates/ra_hir_ty/src/_match.rs +++ b/crates/ra_hir_ty/src/_match.rs @@ -250,17 +250,13 @@ pub enum Usefulness { pub struct MatchCheckCtx<'a> { pub body: Arc, - pub match_expr: &'a Expr, pub infer: Arc, pub db: &'a dyn HirDatabase, } -// see src/librustc_mir_build/hair/pattern/_match.rs -// It seems the rustc version of this method is able to assume that all the match arm -// patterns are valid (they are valid given a particular match expression), but I -// don't think we can make that assumption here. How should that be handled? -// -// Perhaps check that validity before passing the patterns into this method? +/// Given a set of patterns `matrix`, and pattern to consider `v`, determines +/// whether `v` is useful. A pattern is useful if it covers cases which were +/// not previously covered. pub(crate) fn is_useful( cx: &MatchCheckCtx, matrix: &Matrix, @@ -517,6 +513,19 @@ mod tests { check_diagnostic_with_no_fix(content); } + #[test] + fn empty_tuple_wild() { + let content = r" + fn test_fn() { + match () { + _ => {} + } + } + "; + + check_no_diagnostic(content); + } + #[test] fn empty_tuple_no_diagnostic() { let content = r" @@ -976,21 +985,6 @@ mod tests { check_no_diagnostic(content); } -} - -#[cfg(test)] -mod false_negatives { - //! The implementation of match checking here is a work in progress. As we roll this out, we - //! prefer false negatives to false positives (ideally there would be no false positives). This - //! test module should document known false negatives. Eventually we will have a complete - //! implementation of match checking and this module will be empty. - //! - //! The reasons for documenting known false negatives: - //! - //! 1. It acts as a backlog of work that can be done to improve the behavior of the system. - //! 2. It ensures the code doesn't panic when handling these cases. - - use super::tests::*; #[test] fn mismatched_types() { @@ -1011,10 +1005,8 @@ mod false_negatives { } "; - // This is a false negative. - // We don't currently check that the match arms actually - // match the type of the match expression. - check_no_diagnostic(content); + // Match arms with the incorrect type are filtered out. + check_diagnostic_with_no_fix(content); } #[test] @@ -1028,14 +1020,24 @@ mod false_negatives { } "; - // This is a false negative. - // We don't currently check that the match arms actually - // match the type of the match expression. This test - // checks to ensure we don't panic when the code we are - // checking is malformed in such a way that the arity of the - // constructors doesn't match. - check_no_diagnostic(content); + // Match arms with the incorrect type are filtered out. + check_diagnostic_with_no_fix(content); } +} + +#[cfg(test)] +mod false_negatives { + //! The implementation of match checking here is a work in progress. As we roll this out, we + //! prefer false negatives to false positives (ideally there would be no false positives). This + //! test module should document known false negatives. Eventually we will have a complete + //! implementation of match checking and this module will be empty. + //! + //! The reasons for documenting known false negatives: + //! + //! 1. It acts as a backlog of work that can be done to improve the behavior of the system. + //! 2. It ensures the code doesn't panic when handling these cases. + + use super::tests::*; #[test] fn integers() { diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index 7498d04dcb4d..8c7d1a98e550 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs @@ -67,7 +67,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { fn validate_match( &mut self, id: ExprId, - expr: ExprId, + match_expr: ExprId, arms: &[MatchArm], db: &dyn HirDatabase, infer: Arc, @@ -75,18 +75,32 @@ impl<'a, 'b> ExprValidator<'a, 'b> { let (body, source_map): (Arc, Arc) = db.body_with_source_map(self.func.into()); - let match_expr: &hir_def::expr::Expr = &body[expr]; + let match_expr_ty = match infer.type_of_expr.get(match_expr) { + Some(ty) => ty, + // If we can't resolve the type of the match expression + // we cannot perform exhaustiveness checks. + None => return, + }; - let cx = MatchCheckCtx { body: body.clone(), match_expr, infer, db }; + let cx = MatchCheckCtx { body, infer: infer.clone(), db }; let pats = arms.iter().map(|arm| arm.pat); let mut seen = Matrix::empty(); for pat in pats { - // If we had a NotUsefulMatchArm diagnostic, we could - // check the usefulness of each pattern as we added it - // to the matrix here. - let v = PatStack::from_pattern(pat); - seen.push(&cx, v); + // We skip any patterns whose type we cannot resolve. + if let Some(pat_ty) = infer.type_of_pat.get(pat) { + // We only include patterns whose type matches the type + // of the match expression. If we had a InvalidMatchArmPattern + // diagnostic or similar we could raise that in an else + // block here. + if pat_ty == match_expr_ty { + // If we had a NotUsefulMatchArm diagnostic, we could + // check the usefulness of each pattern as we added it + // to the matrix here. + let v = PatStack::from_pattern(pat); + seen.push(&cx, v); + } + } } match is_useful(&cx, &seen, &PatStack::from_wild()) { From 5b4316377b9897f064b213a52a7efe8622d48487 Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Sun, 5 Apr 2020 11:28:53 -0700 Subject: [PATCH 17/24] improving documentation --- crates/ra_hir_ty/src/_match.rs | 80 +++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/crates/ra_hir_ty/src/_match.rs b/crates/ra_hir_ty/src/_match.rs index 91206adc3e6f..8b9bdb7cd5a5 100644 --- a/crates/ra_hir_ty/src/_match.rs +++ b/crates/ra_hir_ty/src/_match.rs @@ -2,7 +2,7 @@ //! for match arms. //! //! It is modeled on the rustc module `librustc_mir_build::hair::pattern::_match`, which -//! contains very detailed documentation about the match checking algorithm. +//! contains very detailed documentation about the algorithms used here. use std::sync::Arc; use smallvec::{smallvec, SmallVec}; @@ -15,6 +15,14 @@ use crate::{ use hir_def::{adt::VariantData, EnumVariantId, VariantId}; #[derive(Debug, Clone, Copy)] +/// Either a pattern from the source code being analyzed, represented as +/// as `PatId`, or a `Wild` pattern which is created as an intermediate +/// step in the match checking algorithm and thus is not backed by a +/// real `PatId`. +/// +/// Note that it is totally valid for the `PatId` variant to contain +/// a `PatId` which resolves to a `Wild` pattern, if that wild pattern +/// exists in the source code being analyzed. enum PatIdOrWild { PatId(PatId), Wild, @@ -44,11 +52,22 @@ impl From for PatIdOrWild { #[derive(Debug, Clone, Copy, PartialEq)] pub struct MatchCheckNotImplemented; + +/// The return type of `is_useful` is either an indication of usefulness +/// of the match arm, or an error in the case the match statement +/// is made up of types for which exhaustiveness checking is currently +/// not completely implemented. +/// +/// The `std::result::Result` type is used here rather than a custom enum +/// to allow the use of `?`. pub type MatchCheckResult = Result; -type PatStackInner = SmallVec<[PatIdOrWild; 2]>; #[derive(Debug)] +/// A row in a Matrix. +/// +/// This type is modeled from the struct of the same name in `rustc`. pub(crate) struct PatStack(PatStackInner); +type PatStackInner = SmallVec<[PatIdOrWild; 2]>; impl PatStack { pub(crate) fn from_pattern(pat_id: PatId) -> PatStack { @@ -94,7 +113,9 @@ impl PatStack { PatStack::from_vec(patterns) } - // Computes `D(self)`. + /// Computes `D(self)`. + /// + /// See the module docs and the associated documentation in rustc for details. fn specialize_wildcard(&self, cx: &MatchCheckCtx) -> Option { if matches!(self.head().as_pat(cx), Pat::Wild) { Some(self.to_tail()) @@ -103,7 +124,9 @@ impl PatStack { } } - // Computes `S(constructor, self)`. + /// Computes `S(constructor, self)`. + /// + /// See the module docs and the associated documentation in rustc for details. fn specialize_constructor( &self, cx: &MatchCheckCtx, @@ -146,6 +169,11 @@ impl PatStack { Ok(result) } + /// A special case of `specialize_constructor` where the head of the pattern stack + /// is a Wild pattern. + /// + /// Replaces the Wild pattern at the head of the pattern stack with N Wild patterns + /// (N >= 0), where N is the arity of the given constructor. fn expand_wildcard( &self, cx: &MatchCheckCtx, @@ -183,6 +211,9 @@ impl PatStack { } #[derive(Debug)] +/// A collection of PatStack. +/// +/// This type is modeled from the struct of the same name in `rustc`. pub(crate) struct Matrix(Vec); impl Matrix { @@ -191,8 +222,8 @@ impl Matrix { } pub(crate) fn push(&mut self, cx: &MatchCheckCtx, row: PatStack) { - // if the pattern is an or pattern it should be expanded if let Some(Pat::Or(pat_ids)) = row.get_head().map(|pat_id| pat_id.as_pat(cx)) { + // Or patterns are expanded here for pat_id in pat_ids { self.0.push(PatStack::from_pattern(pat_id)); } @@ -209,12 +240,16 @@ impl Matrix { self.0.iter().map(|p| p.head()).collect() } - // Computes `D(self)`. + /// Computes `D(self)` for each contained PatStack. + /// + /// See the module docs and the associated documentation in rustc for details. fn specialize_wildcard(&self, cx: &MatchCheckCtx) -> Self { Self::collect(cx, self.0.iter().filter_map(|r| r.specialize_wildcard(cx))) } - // Computes `S(constructor, self)`. + /// Computes `S(constructor, self)` for each contained PatStack. + /// + /// See the module docs and the associated documentation in rustc for details. fn specialize_constructor( &self, cx: &MatchCheckCtx, @@ -243,6 +278,11 @@ impl Matrix { } #[derive(Clone, Debug, PartialEq)] +/// An indication of the usefulness of a given match arm, where +/// usefulness is defined as matching some patterns which were +/// not matched by an prior match arms. +/// +/// We may eventually need an `Unknown` variant here. pub enum Usefulness { Useful, NotUseful, @@ -257,6 +297,11 @@ pub struct MatchCheckCtx<'a> { /// Given a set of patterns `matrix`, and pattern to consider `v`, determines /// whether `v` is useful. A pattern is useful if it covers cases which were /// not previously covered. +/// +/// When calling this function externally (that is, not the recursive calls) it +/// expected that you have already type checked the match arms. All patterns in +/// matrix should be the same type as v, as well as they should all be the same +/// type as the match expression. pub(crate) fn is_useful( cx: &MatchCheckCtx, matrix: &Matrix, @@ -311,8 +356,9 @@ pub(crate) fn is_useful( // We assume here that the first constructor is the "correct" type. Since we // only care about the "type" of the constructor (i.e. if it is a bool we // don't care about the value), this assumption should be valid as long as - // the match statement is well formed. But potentially a better way to handle - // this is to use the match expressions type. + // the match statement is well formed. We currently uphold this invariant by + // filtering match arms before calling `is_useful`, only passing in match arms + // whose type matches the type of the match expression. match &used_constructors.first() { Some(constructor) if all_constructors_covered(&cx, constructor, &used_constructors) => { // If all constructors are covered, then we need to consider whether @@ -380,23 +426,25 @@ pub(crate) fn is_useful( } #[derive(Debug)] +/// Similar to TypeCtor, but includes additional information about the specific +/// value being instantiated. For example, TypeCtor::Bool doesn't contain the +/// boolean value. enum Constructor { Bool(bool), Tuple { arity: usize }, Enum(EnumVariantId), } +/// Returns the constructor for the given pattern. Should only return None +/// in the case of a Wild pattern. fn pat_constructor(cx: &MatchCheckCtx, pat: PatIdOrWild) -> MatchCheckResult> { let res = match pat.as_pat(cx) { Pat::Wild => None, Pat::Tuple(pats) => Some(Constructor::Tuple { arity: pats.len() }), - Pat::Lit(lit_expr) => { - // for now we only support bool literals - match cx.body.exprs[lit_expr] { - Expr::Literal(Literal::Bool(val)) => Some(Constructor::Bool(val)), - _ => return Err(MatchCheckNotImplemented), - } - } + Pat::Lit(lit_expr) => match cx.body.exprs[lit_expr] { + Expr::Literal(Literal::Bool(val)) => Some(Constructor::Bool(val)), + _ => return Err(MatchCheckNotImplemented), + }, Pat::TupleStruct { .. } | Pat::Path(_) => { let pat_id = pat.as_id().expect("we already know this pattern is not a wild"); let variant_id = From 5fe608fb31430f43a404312e284a71d6f7cfa038 Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Sun, 5 Apr 2020 12:42:24 -0700 Subject: [PATCH 18/24] handle match auto-deref --- crates/ra_hir_ty/src/_match.rs | 35 ++++++++++++++++++++++++++++++++++ crates/ra_hir_ty/src/expr.rs | 11 ++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/crates/ra_hir_ty/src/_match.rs b/crates/ra_hir_ty/src/_match.rs index 8b9bdb7cd5a5..f502a920864d 100644 --- a/crates/ra_hir_ty/src/_match.rs +++ b/crates/ra_hir_ty/src/_match.rs @@ -865,6 +865,41 @@ mod tests { check_no_diagnostic(content); } + #[test] + fn enum_ref_missing_arms() { + let content = r" + enum Either { + A, + B, + } + fn test_fn() { + match &Either::B { + Either::A => {}, + } + } + "; + + check_diagnostic_with_no_fix(content); + } + + #[test] + fn enum_ref_no_diagnostic() { + let content = r" + enum Either { + A, + B, + } + fn test_fn() { + match &Either::B { + Either::A => {}, + Either::B => {}, + } + } + "; + + check_no_diagnostic(content); + } + #[test] fn enum_containing_bool_no_arms() { let content = r" diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index 8c7d1a98e550..6efed6f9e2f4 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs @@ -93,7 +93,16 @@ impl<'a, 'b> ExprValidator<'a, 'b> { // of the match expression. If we had a InvalidMatchArmPattern // diagnostic or similar we could raise that in an else // block here. - if pat_ty == match_expr_ty { + // + // When comparing the types, we also have to consider that rustc + // will automatically de-reference the match expression type if + // necessary. + if pat_ty == match_expr_ty + || match_expr_ty + .as_reference() + .map(|(match_expr_ty, _)| match_expr_ty == pat_ty) + .unwrap_or(false) + { // If we had a NotUsefulMatchArm diagnostic, we could // check the usefulness of each pattern as we added it // to the matrix here. From da6752d5f9a18ba58adb6a2e72d30a83532ec8a6 Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Mon, 6 Apr 2020 06:55:25 -0700 Subject: [PATCH 19/24] missing match arms diagnostic change source to match expression --- crates/ra_hir_ty/src/_match.rs | 2 +- crates/ra_hir_ty/src/diagnostics.rs | 3 ++- crates/ra_hir_ty/src/expr.rs | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/ra_hir_ty/src/_match.rs b/crates/ra_hir_ty/src/_match.rs index f502a920864d..02472e0c0e87 100644 --- a/crates/ra_hir_ty/src/_match.rs +++ b/crates/ra_hir_ty/src/_match.rs @@ -545,7 +545,7 @@ mod tests { assert_snapshot!( check_diagnostic_message(content), - @"\"{\\n }\": Missing match arm\n" + @"\"()\": Missing match arm\n" ); } diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 3457905e225e..8cbce11686c1 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -65,6 +65,7 @@ impl AstDiagnostic for MissingFields { #[derive(Debug)] pub struct MissingMatchArms { pub file: HirFileId, + pub match_expr: AstPtr, pub arms: AstPtr, } @@ -73,7 +74,7 @@ impl Diagnostic for MissingMatchArms { String::from("Missing match arm") } fn source(&self) -> InFile { - InFile { file_id: self.file, value: self.arms.into() } + InFile { file_id: self.file, value: self.match_expr.into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { self diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index 6efed6f9e2f4..19323fda12e2 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs @@ -125,9 +125,12 @@ impl<'a, 'b> ExprValidator<'a, 'b> { if let Some(expr) = source_ptr.value.left() { let root = source_ptr.file_syntax(db.upcast()); if let ast::Expr::MatchExpr(match_expr) = expr.to_node(&root) { - if let Some(arms) = match_expr.match_arm_list() { + if let (Some(match_expr), Some(arms)) = + (match_expr.expr(), match_expr.match_arm_list()) + { self.sink.push(MissingMatchArms { file: source_ptr.file_id, + match_expr: AstPtr::new(&match_expr), arms: AstPtr::new(&arms), }) } From a208de15b7846911856e6c069f7df03676c18a03 Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Mon, 6 Apr 2020 15:38:20 -0700 Subject: [PATCH 20/24] PR feedback implementation --- crates/ra_hir_ty/src/_match.rs | 425 +++++++++++++++++++++++++-------- 1 file changed, 331 insertions(+), 94 deletions(-) diff --git a/crates/ra_hir_ty/src/_match.rs b/crates/ra_hir_ty/src/_match.rs index 02472e0c0e87..f29a25505b98 100644 --- a/crates/ra_hir_ty/src/_match.rs +++ b/crates/ra_hir_ty/src/_match.rs @@ -2,7 +2,191 @@ //! for match arms. //! //! It is modeled on the rustc module `librustc_mir_build::hair::pattern::_match`, which -//! contains very detailed documentation about the algorithms used here. +//! contains very detailed documentation about the algorithms used here. I've duplicated +//! most of that documentation below. +//! +//! This file includes the logic for exhaustiveness and usefulness checking for +//! pattern-matching. Specifically, given a list of patterns for a type, we can +//! tell whether: +//! (a) the patterns cover every possible constructor for the type [exhaustiveness] +//! (b) each pattern is necessary [usefulness] +//! +//! The algorithm implemented here is a modified version of the one described in: +//! http://moscova.inria.fr/~maranget/papers/warn/index.html +//! However, to save future implementors from reading the original paper, we +//! summarise the algorithm here to hopefully save time and be a little clearer +//! (without being so rigorous). +//! +//! The core of the algorithm revolves about a "usefulness" check. In particular, we +//! are trying to compute a predicate `U(P, p)` where `P` is a list of patterns (we refer to this as +//! a matrix). `U(P, p)` represents whether, given an existing list of patterns +//! `P_1 ..= P_m`, adding a new pattern `p` will be "useful" (that is, cover previously- +//! uncovered values of the type). +//! +//! If we have this predicate, then we can easily compute both exhaustiveness of an +//! entire set of patterns and the individual usefulness of each one. +//! (a) the set of patterns is exhaustive iff `U(P, _)` is false (i.e., adding a wildcard +//! match doesn't increase the number of values we're matching) +//! (b) a pattern `P_i` is not useful if `U(P[0..=(i-1), P_i)` is false (i.e., adding a +//! pattern to those that have come before it doesn't increase the number of values +//! we're matching). +//! +//! During the course of the algorithm, the rows of the matrix won't just be individual patterns, +//! but rather partially-deconstructed patterns in the form of a list of patterns. The paper +//! calls those pattern-vectors, and we will call them pattern-stacks. The same holds for the +//! new pattern `p`. +//! +//! For example, say we have the following: +//! ``` +//! // x: (Option, Result<()>) +//! match x { +//! (Some(true), _) => {} +//! (None, Err(())) => {} +//! (None, Err(_)) => {} +//! } +//! ``` +//! Here, the matrix `P` starts as: +//! [ +//! [(Some(true), _)], +//! [(None, Err(()))], +//! [(None, Err(_))], +//! ] +//! We can tell it's not exhaustive, because `U(P, _)` is true (we're not covering +//! `[(Some(false), _)]`, for instance). In addition, row 3 is not useful, because +//! all the values it covers are already covered by row 2. +//! +//! A list of patterns can be thought of as a stack, because we are mainly interested in the top of +//! the stack at any given point, and we can pop or apply constructors to get new pattern-stacks. +//! To match the paper, the top of the stack is at the beginning / on the left. +//! +//! There are two important operations on pattern-stacks necessary to understand the algorithm: +//! 1. We can pop a given constructor off the top of a stack. This operation is called +//! `specialize`, and is denoted `S(c, p)` where `c` is a constructor (like `Some` or +//! `None`) and `p` a pattern-stack. +//! If the pattern on top of the stack can cover `c`, this removes the constructor and +//! pushes its arguments onto the stack. It also expands OR-patterns into distinct patterns. +//! Otherwise the pattern-stack is discarded. +//! This essentially filters those pattern-stacks whose top covers the constructor `c` and +//! discards the others. +//! +//! For example, the first pattern above initially gives a stack `[(Some(true), _)]`. If we +//! pop the tuple constructor, we are left with `[Some(true), _]`, and if we then pop the +//! `Some` constructor we get `[true, _]`. If we had popped `None` instead, we would get +//! nothing back. +//! +//! This returns zero or more new pattern-stacks, as follows. We look at the pattern `p_1` +//! on top of the stack, and we have four cases: +//! 1.1. `p_1 = c(r_1, .., r_a)`, i.e. the top of the stack has constructor `c`. We +//! push onto the stack the arguments of this constructor, and return the result: +//! r_1, .., r_a, p_2, .., p_n +//! 1.2. `p_1 = c'(r_1, .., r_a')` where `c ≠ c'`. We discard the current stack and +//! return nothing. +//! 1.3. `p_1 = _`. We push onto the stack as many wildcards as the constructor `c` has +//! arguments (its arity), and return the resulting stack: +//! _, .., _, p_2, .., p_n +//! 1.4. `p_1 = r_1 | r_2`. We expand the OR-pattern and then recurse on each resulting +//! stack: +//! S(c, (r_1, p_2, .., p_n)) +//! S(c, (r_2, p_2, .., p_n)) +//! +//! 2. We can pop a wildcard off the top of the stack. This is called `D(p)`, where `p` is +//! a pattern-stack. +//! This is used when we know there are missing constructor cases, but there might be +//! existing wildcard patterns, so to check the usefulness of the matrix, we have to check +//! all its *other* components. +//! +//! It is computed as follows. We look at the pattern `p_1` on top of the stack, +//! and we have three cases: +//! 1.1. `p_1 = c(r_1, .., r_a)`. We discard the current stack and return nothing. +//! 1.2. `p_1 = _`. We return the rest of the stack: +//! p_2, .., p_n +//! 1.3. `p_1 = r_1 | r_2`. We expand the OR-pattern and then recurse on each resulting +//! stack. +//! D((r_1, p_2, .., p_n)) +//! D((r_2, p_2, .., p_n)) +//! +//! Note that the OR-patterns are not always used directly in Rust, but are used to derive the +//! exhaustive integer matching rules, so they're written here for posterity. +//! +//! Both those operations extend straightforwardly to a list or pattern-stacks, i.e. a matrix, by +//! working row-by-row. Popping a constructor ends up keeping only the matrix rows that start with +//! the given constructor, and popping a wildcard keeps those rows that start with a wildcard. +//! +//! +//! The algorithm for computing `U` +//! ------------------------------- +//! The algorithm is inductive (on the number of columns: i.e., components of tuple patterns). +//! That means we're going to check the components from left-to-right, so the algorithm +//! operates principally on the first component of the matrix and new pattern-stack `p`. +//! This algorithm is realised in the `is_useful` function. +//! +//! Base case. (`n = 0`, i.e., an empty tuple pattern) +//! - If `P` already contains an empty pattern (i.e., if the number of patterns `m > 0`), +//! then `U(P, p)` is false. +//! - Otherwise, `P` must be empty, so `U(P, p)` is true. +//! +//! Inductive step. (`n > 0`, i.e., whether there's at least one column +//! [which may then be expanded into further columns later]) +//! We're going to match on the top of the new pattern-stack, `p_1`. +//! - If `p_1 == c(r_1, .., r_a)`, i.e. we have a constructor pattern. +//! Then, the usefulness of `p_1` can be reduced to whether it is useful when +//! we ignore all the patterns in the first column of `P` that involve other constructors. +//! This is where `S(c, P)` comes in: +//! `U(P, p) := U(S(c, P), S(c, p))` +//! This special case is handled in `is_useful_specialized`. +//! +//! For example, if `P` is: +//! [ +//! [Some(true), _], +//! [None, 0], +//! ] +//! and `p` is [Some(false), 0], then we don't care about row 2 since we know `p` only +//! matches values that row 2 doesn't. For row 1 however, we need to dig into the +//! arguments of `Some` to know whether some new value is covered. So we compute +//! `U([[true, _]], [false, 0])`. +//! +//! - If `p_1 == _`, then we look at the list of constructors that appear in the first +//! component of the rows of `P`: +//! + If there are some constructors that aren't present, then we might think that the +//! wildcard `_` is useful, since it covers those constructors that weren't covered +//! before. +//! That's almost correct, but only works if there were no wildcards in those first +//! components. So we need to check that `p` is useful with respect to the rows that +//! start with a wildcard, if there are any. This is where `D` comes in: +//! `U(P, p) := U(D(P), D(p))` +//! +//! For example, if `P` is: +//! [ +//! [_, true, _], +//! [None, false, 1], +//! ] +//! and `p` is [_, false, _], the `Some` constructor doesn't appear in `P`. So if we +//! only had row 2, we'd know that `p` is useful. However row 1 starts with a +//! wildcard, so we need to check whether `U([[true, _]], [false, 1])`. +//! +//! + Otherwise, all possible constructors (for the relevant type) are present. In this +//! case we must check whether the wildcard pattern covers any unmatched value. For +//! that, we can think of the `_` pattern as a big OR-pattern that covers all +//! possible constructors. For `Option`, that would mean `_ = None | Some(_)` for +//! example. The wildcard pattern is useful in this case if it is useful when +//! specialized to one of the possible constructors. So we compute: +//! `U(P, p) := ∃(k ϵ constructors) U(S(k, P), S(k, p))` +//! +//! For example, if `P` is: +//! [ +//! [Some(true), _], +//! [None, false], +//! ] +//! and `p` is [_, false], both `None` and `Some` constructors appear in the first +//! components of `P`. We will therefore try popping both constructors in turn: we +//! compute U([[true, _]], [_, false]) for the `Some` constructor, and U([[false]], +//! [false]) for the `None` constructor. The first case returns true, so we know that +//! `p` is useful for `P`. Indeed, it matches `[Some(false), _]` that wasn't matched +//! before. +//! +//! - If `p_1 == r_1 | r_2`, then the usefulness depends on each `r_i` separately: +//! `U(P, p) := U(P, (r_1, p_2, .., p_n)) +//! || U(P, (r_2, p_2, .., p_n))` use std::sync::Arc; use smallvec::{smallvec, SmallVec}; @@ -134,15 +318,25 @@ impl PatStack { ) -> MatchCheckResult> { let result = match (self.head().as_pat(cx), constructor) { (Pat::Tuple(ref pat_ids), Constructor::Tuple { arity }) => { - if pat_ids.len() != *arity { - None - } else { - Some(self.replace_head_with(pat_ids)) - } + debug_assert_eq!( + pat_ids.len(), + *arity, + "we type check before calling this code, so we should never hit this case", + ); + + Some(self.replace_head_with(pat_ids)) } - (Pat::Lit(_), Constructor::Bool(_)) => { - // for now we only support bool literals - Some(self.to_tail()) + (Pat::Lit(lit_expr), Constructor::Bool(constructor_val)) => { + match cx.body.exprs[lit_expr] { + Expr::Literal(Literal::Bool(pat_val)) if *constructor_val == pat_val => { + Some(self.to_tail()) + } + // it was a bool but the value doesn't match + Expr::Literal(Literal::Bool(_)) => None, + // perhaps this is actually unreachable given we have + // already checked that these match arms have the appropriate type? + _ => return Err(MatchCheckNotImplemented), + } } (Pat::Wild, constructor) => Some(self.expand_wildcard(cx, constructor)?), (Pat::Path(_), Constructor::Enum(constructor)) => { @@ -162,7 +356,7 @@ impl PatStack { Some(self.replace_head_with(pat_ids)) } } - (Pat::Or(_), _) => unreachable!("we desugar or patterns so this should never happen"), + (Pat::Or(_), _) => return Err(MatchCheckNotImplemented), (_, _) => return Err(MatchCheckNotImplemented), }; @@ -186,19 +380,8 @@ impl PatStack { ); let mut patterns: PatStackInner = smallvec![]; - let arity = match constructor { - Constructor::Bool(_) => 0, - Constructor::Tuple { arity } => *arity, - Constructor::Enum(e) => { - match cx.db.enum_data(e.parent).variants[e.local_id].variant_data.as_ref() { - VariantData::Tuple(struct_field_data) => struct_field_data.len(), - VariantData::Unit => 0, - _ => return Err(MatchCheckNotImplemented), - } - } - }; - for _ in 0..arity { + for _ in 0..constructor.arity(cx)? { patterns.push(PatIdOrWild::Wild); } @@ -368,46 +551,23 @@ pub(crate) fn is_useful( // constructors are covered (`Some`/`None`), so we need // to perform specialization to see that our wildcard will cover // the `Some(false)` case. - let mut constructor = None; - for pat in matrix.heads() { - if let Some(c) = pat_constructor(cx, pat)? { - constructor = Some(c); - break; - } + // + // Here we create a constructor for each variant and then check + // usefulness after specializing for that constructor. + let mut found_unimplemented = false; + for constructor in constructor.all_constructors(cx) { + let matrix = matrix.specialize_constructor(&cx, &constructor)?; + let v = v.expand_wildcard(&cx, &constructor)?; + + match is_useful(&cx, &matrix, &v) { + Ok(Usefulness::Useful) => return Ok(Usefulness::Useful), + Ok(Usefulness::NotUseful) => continue, + _ => found_unimplemented = true, + }; } - if let Some(constructor) = constructor { - if let Constructor::Enum(e) = constructor { - // For enums we handle each variant as a distinct constructor, so - // here we create a constructor for each variant and then check - // usefulness after specializing for that constructor. - let mut found_unimplemented = false; - for constructor in - cx.db.enum_data(e.parent).variants.iter().map(|(local_id, _)| { - Constructor::Enum(EnumVariantId { parent: e.parent, local_id }) - }) - { - let matrix = matrix.specialize_constructor(&cx, &constructor)?; - let v = v.expand_wildcard(&cx, &constructor)?; - - match is_useful(&cx, &matrix, &v) { - Ok(Usefulness::Useful) => return Ok(Usefulness::Useful), - Ok(Usefulness::NotUseful) => continue, - _ => found_unimplemented = true, - }; - } - - if found_unimplemented { - Err(MatchCheckNotImplemented) - } else { - Ok(Usefulness::NotUseful) - } - } else { - let matrix = matrix.specialize_constructor(&cx, &constructor)?; - let v = v.expand_wildcard(&cx, &constructor)?; - - is_useful(&cx, &matrix, &v) - } + if found_unimplemented { + Err(MatchCheckNotImplemented) } else { Ok(Usefulness::NotUseful) } @@ -425,7 +585,7 @@ pub(crate) fn is_useful( } } -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] /// Similar to TypeCtor, but includes additional information about the specific /// value being instantiated. For example, TypeCtor::Bool doesn't contain the /// boolean value. @@ -435,6 +595,40 @@ enum Constructor { Enum(EnumVariantId), } +impl Constructor { + fn arity(&self, cx: &MatchCheckCtx) -> MatchCheckResult { + let arity = match self { + Constructor::Bool(_) => 0, + Constructor::Tuple { arity } => *arity, + Constructor::Enum(e) => { + match cx.db.enum_data(e.parent).variants[e.local_id].variant_data.as_ref() { + VariantData::Tuple(struct_field_data) => struct_field_data.len(), + VariantData::Unit => 0, + _ => return Err(MatchCheckNotImplemented), + } + } + }; + + Ok(arity) + } + + fn all_constructors(&self, cx: &MatchCheckCtx) -> Vec { + match self { + Constructor::Bool(_) => vec![Constructor::Bool(true), Constructor::Bool(false)], + Constructor::Tuple { .. } => vec![*self], + Constructor::Enum(e) => cx + .db + .enum_data(e.parent) + .variants + .iter() + .map(|(local_id, _)| { + Constructor::Enum(EnumVariantId { parent: e.parent, local_id }) + }) + .collect(), + } + } +} + /// Returns the constructor for the given pattern. Should only return None /// in the case of a Wild pattern. fn pat_constructor(cx: &MatchCheckCtx, pat: PatIdOrWild) -> MatchCheckResult> { @@ -501,14 +695,7 @@ fn all_constructors_covered( } fn enum_variant_matches(cx: &MatchCheckCtx, pat_id: PatId, enum_variant_id: EnumVariantId) -> bool { - if let Some(VariantId::EnumVariantId(pat_variant_id)) = - cx.infer.variant_resolution_for_pat(pat_id) - { - if pat_variant_id.local_id == enum_variant_id.local_id { - return true; - } - } - false + Some(enum_variant_id.into()) == cx.infer.variant_resolution_for_pat(pat_id) } #[cfg(test)] @@ -522,10 +709,10 @@ mod tests { TestDB::with_single_file(content).0.diagnostics().0 } - pub(super) fn check_diagnostic_with_no_fix(content: &str) { + pub(super) fn check_diagnostic(content: &str) { let diagnostic_count = TestDB::with_single_file(content).0.diagnostics().1; - assert_eq!(1, diagnostic_count, "no diagnotic reported"); + assert_eq!(1, diagnostic_count, "no diagnostic reported"); } pub(super) fn check_no_diagnostic(content: &str) { @@ -558,7 +745,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -596,7 +783,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -621,7 +808,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -646,7 +833,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -659,7 +846,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -685,7 +872,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -698,7 +885,37 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); + } + + #[test] + fn tuple_of_bools_missing_arm() { + let content = r" + fn test_fn() { + match (false, true) { + (false, true) => {}, + (false, false) => {}, + (true, false) => {}, + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn tuple_of_bools_with_wilds() { + let content = r" + fn test_fn() { + match (false, true) { + (false, _) => {}, + (true, false) => {}, + (_, true) => {}, + } + } + "; + + check_no_diagnostic(content); } #[test] @@ -727,7 +944,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -754,7 +971,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -767,7 +984,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -796,7 +1013,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -827,7 +1044,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -844,7 +1061,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -879,7 +1096,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -913,7 +1130,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -931,7 +1148,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -1004,7 +1221,7 @@ mod tests { } "; - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -1089,7 +1306,7 @@ mod tests { "; // Match arms with the incorrect type are filtered out. - check_diagnostic_with_no_fix(content); + check_diagnostic(content); } #[test] @@ -1104,7 +1321,23 @@ mod tests { "; // Match arms with the incorrect type are filtered out. - check_diagnostic_with_no_fix(content); + check_diagnostic(content); + } + + #[test] + fn enum_not_in_scope() { + let content = r" + fn test_fn() { + match Foo::Bar { + Foo::Baz => (), + } + } + "; + + // The enum is not in scope so we don't perform exhaustiveness + // checking, but we want to be sure we don't panic here (and + // we don't create a diagnostic). + check_no_diagnostic(content); } } @@ -1158,17 +1391,21 @@ mod false_negatives { } #[test] - fn enum_not_in_scope() { + fn internal_or() { let content = r" fn test_fn() { - match Foo::Bar { - Foo::Baz => (), + enum Either { + A(bool), + B, + } + match Either::B { + Either::A(true | false) => (), } } "; // This is a false negative. - // The enum is not in scope so we don't perform exhaustiveness checking. + // We do not currently handle patterns with internal `or`s. check_no_diagnostic(content); } } From 9fc1f51b7ade2cda7d410450ab1347311eb074af Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Tue, 7 Apr 2020 05:17:59 -0700 Subject: [PATCH 21/24] add fixme to use type checker rather than manually comparing types --- crates/ra_hir_ty/src/expr.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index 19323fda12e2..1e7395b16480 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs @@ -88,6 +88,11 @@ impl<'a, 'b> ExprValidator<'a, 'b> { let mut seen = Matrix::empty(); for pat in pats { // We skip any patterns whose type we cannot resolve. + // + // This could lead to false positives in this diagnostic, so + // it might be better to skip the entire diagnostic if we either + // cannot resolve a match arm or determine that the match arm has + // the wrong type. if let Some(pat_ty) = infer.type_of_pat.get(pat) { // We only include patterns whose type matches the type // of the match expression. If we had a InvalidMatchArmPattern @@ -97,6 +102,8 @@ impl<'a, 'b> ExprValidator<'a, 'b> { // When comparing the types, we also have to consider that rustc // will automatically de-reference the match expression type if // necessary. + // + // FIXME we should use the type checker for this. if pat_ty == match_expr_ty || match_expr_ty .as_reference() From 73ccf7f495f328e10dca38e0f069de89ab52b9d3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Apr 2020 15:07:18 +0200 Subject: [PATCH 22/24] Reorder imports --- crates/ra_ide/src/completion/complete_record.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/ra_ide/src/completion/complete_record.rs b/crates/ra_ide/src/completion/complete_record.rs index 01dd8c6db708..780a98aea21b 100644 --- a/crates/ra_ide/src/completion/complete_record.rs +++ b/crates/ra_ide/src/completion/complete_record.rs @@ -1,7 +1,8 @@ //! Complete fields in record literals and patterns. -use crate::completion::{CompletionContext, Completions}; use ra_syntax::{ast, ast::NameOwner, SmolStr}; +use crate::completion::{CompletionContext, Completions}; + pub(super) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { let (ty, variant, already_present_fields) = match (ctx.record_lit_pat.as_ref(), ctx.record_lit_syntax.as_ref()) { @@ -59,9 +60,10 @@ fn pattern_ascribed_fields(record_pat: &ast::RecordPat) -> Vec { #[cfg(test)] mod tests { mod record_lit_tests { - use crate::completion::{test_utils::do_completion, CompletionItem, CompletionKind}; use insta::assert_debug_snapshot; + use crate::completion::{test_utils::do_completion, CompletionItem, CompletionKind}; + fn complete(code: &str) -> Vec { do_completion(code, CompletionKind::Reference) } @@ -204,9 +206,10 @@ mod tests { } mod record_pat_tests { - use crate::completion::{test_utils::do_completion, CompletionItem, CompletionKind}; use insta::assert_debug_snapshot; + use crate::completion::{test_utils::do_completion, CompletionItem, CompletionKind}; + fn complete(code: &str) -> Vec { do_completion(code, CompletionKind::Reference) } From 5540193fc87a33a6c141956a63f9f56fe6207ee8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Apr 2020 16:37:33 +0200 Subject: [PATCH 23/24] Don't insert !() if there's already some --- .../src/completion/completion_context.rs | 4 ++ crates/ra_ide/src/completion/presentation.rs | 43 +++++++++++++++++-- crates/ra_ide/src/marks.rs | 1 + 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index b8213d62f5d2..f833d2a9ade8 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -50,6 +50,8 @@ pub(crate) struct CompletionContext<'a> { pub(super) dot_receiver_is_ambiguous_float_literal: bool, /// If this is a call (method or function) in particular, i.e. the () are already there. pub(super) is_call: bool, + /// If this is a macro call, i.e. the () are already there. + pub(super) is_macro_call: bool, pub(super) is_path_type: bool, pub(super) has_type_args: bool, } @@ -102,6 +104,7 @@ impl<'a> CompletionContext<'a> { is_new_item: false, dot_receiver: None, is_call: false, + is_macro_call: false, is_path_type: false, has_type_args: false, dot_receiver_is_ambiguous_float_literal: false, @@ -269,6 +272,7 @@ impl<'a> CompletionContext<'a> { .and_then(ast::PathExpr::cast) .and_then(|it| it.syntax().parent().and_then(ast::CallExpr::cast)) .is_some(); + self.is_macro_call = path.syntax().parent().and_then(ast::MacroCall::cast).is_some(); self.is_path_type = path.syntax().parent().and_then(ast::PathType::cast).is_some(); self.has_type_args = segment.type_arg_list().is_some(); diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index cdfd7bc32437..55f75b15aa1f 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -174,7 +174,8 @@ impl Completions { .set_deprecated(is_deprecated(macro_, ctx.db)) .detail(detail); - builder = if ctx.use_item_syntax.is_some() { + builder = if ctx.use_item_syntax.is_some() || ctx.is_macro_call { + tested_by!(dont_insert_macro_call_parens_unncessary); builder.insert_text(name) } else { let macro_braces_to_insert = @@ -960,7 +961,8 @@ mod tests { } #[test] - fn dont_insert_macro_call_braces_in_use() { + fn dont_insert_macro_call_parens_unncessary() { + covers!(dont_insert_macro_call_parens_unncessary); assert_debug_snapshot!( do_reference_completion( r" @@ -986,6 +988,41 @@ mod tests { }, ] "### - ) + ); + + assert_debug_snapshot!( + do_reference_completion( + r" + //- /main.rs + macro_rules frobnicate { + () => () + } + fn main() { + frob<|>!(); + } + " + ), + @r###" + [ + CompletionItem { + label: "frobnicate!", + source_range: [56; 60), + delete: [56; 60), + insert: "frobnicate", + kind: Macro, + detail: "macro_rules! frobnicate", + }, + CompletionItem { + label: "main()", + source_range: [56; 60), + delete: [56; 60), + insert: "main()$0", + kind: Function, + lookup: "main", + detail: "fn main()", + }, + ] + "### + ); } } diff --git a/crates/ra_ide/src/marks.rs b/crates/ra_ide/src/marks.rs index 1236cb773c8b..5e1f135c56aa 100644 --- a/crates/ra_ide/src/marks.rs +++ b/crates/ra_ide/src/marks.rs @@ -7,4 +7,5 @@ test_utils::marks!( dont_complete_current_use test_resolve_parent_module_on_module_decl search_filters_by_range + dont_insert_macro_call_parens_unncessary ); From 3bde2b742388f3ec3bb08841f93a06a62be04e4d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Apr 2020 16:40:39 +0200 Subject: [PATCH 24/24] A more precise panic macro --- crates/ra_ide/src/completion/complete_record.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ra_ide/src/completion/complete_record.rs b/crates/ra_ide/src/completion/complete_record.rs index 780a98aea21b..79f5c8c8f9ea 100644 --- a/crates/ra_ide/src/completion/complete_record.rs +++ b/crates/ra_ide/src/completion/complete_record.rs @@ -7,7 +7,7 @@ pub(super) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) -> let (ty, variant, already_present_fields) = match (ctx.record_lit_pat.as_ref(), ctx.record_lit_syntax.as_ref()) { (None, None) => return None, - (Some(_), Some(_)) => panic!("A record cannot be both a literal and a pattern"), + (Some(_), Some(_)) => unreachable!("A record cannot be both a literal and a pattern"), (Some(record_pat), _) => ( ctx.sema.type_of_pat(&record_pat.clone().into())?, ctx.sema.resolve_record_pattern(record_pat)?,