aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yaml5
-rw-r--r--Cargo.lock189
-rw-r--r--crates/flycheck/Cargo.toml2
-rw-r--r--crates/flycheck/src/lib.rs13
-rw-r--r--crates/ra_assists/src/assist_context.rs4
-rw-r--r--crates/ra_assists/src/ast_transform.rs34
-rw-r--r--crates/ra_assists/src/handlers/add_custom_impl.rs4
-rw-r--r--crates/ra_assists/src/handlers/add_explicit_type.rs20
-rw-r--r--crates/ra_assists/src/handlers/add_missing_impl_members.rs29
-rw-r--r--crates/ra_assists/src/handlers/auto_import.rs2
-rw-r--r--crates/ra_assists/src/handlers/change_return_type_to_result.rs9
-rw-r--r--crates/ra_assists/src/handlers/change_visibility.rs10
-rw-r--r--crates/ra_assists/src/handlers/early_return.rs14
-rw-r--r--crates/ra_assists/src/handlers/expand_glob_import.rs391
-rw-r--r--crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs2
-rw-r--r--crates/ra_assists/src/handlers/extract_variable.rs6
-rw-r--r--crates/ra_assists/src/handlers/fill_match_arms.rs29
-rw-r--r--crates/ra_assists/src/handlers/fix_visibility.rs2
-rw-r--r--crates/ra_assists/src/handlers/generate_derive.rs4
-rw-r--r--crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs8
-rw-r--r--crates/ra_assists/src/handlers/generate_function.rs8
-rw-r--r--crates/ra_assists/src/handlers/generate_impl.rs6
-rw-r--r--crates/ra_assists/src/handlers/generate_new.rs24
-rw-r--r--crates/ra_assists/src/handlers/inline_local_variable.rs2
-rw-r--r--crates/ra_assists/src/handlers/introduce_named_lifetime.rs24
-rw-r--r--crates/ra_assists/src/handlers/merge_imports.rs2
-rw-r--r--crates/ra_assists/src/handlers/merge_match_arms.rs2
-rw-r--r--crates/ra_assists/src/handlers/move_bounds.rs14
-rw-r--r--crates/ra_assists/src/handlers/raw_string.rs2
-rw-r--r--crates/ra_assists/src/handlers/remove_dbg.rs94
-rw-r--r--crates/ra_assists/src/handlers/reorder_fields.rs10
-rw-r--r--crates/ra_assists/src/handlers/replace_if_let_with_match.rs2
-rw-r--r--crates/ra_assists/src/handlers/replace_let_with_if_let.rs7
-rw-r--r--crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs46
-rw-r--r--crates/ra_assists/src/handlers/replace_unwrap_with_match.rs4
-rw-r--r--crates/ra_assists/src/lib.rs2
-rw-r--r--crates/ra_assists/src/tests/generated.rs27
-rw-r--r--crates/ra_assists/src/utils.rs24
-rw-r--r--crates/ra_assists/src/utils/insert_use.rs13
-rw-r--r--crates/ra_db/Cargo.toml2
-rw-r--r--crates/ra_hir/src/code_model.rs6
-rw-r--r--crates/ra_hir/src/db.rs9
-rw-r--r--crates/ra_hir/src/has_source.rs42
-rw-r--r--crates/ra_hir/src/semantics.rs49
-rw-r--r--crates/ra_hir/src/semantics/source_to_def.rs73
-rw-r--r--crates/ra_hir/src/source_analyzer.rs22
-rw-r--r--crates/ra_hir_def/src/adt.rs18
-rw-r--r--crates/ra_hir_def/src/attr.rs19
-rw-r--r--crates/ra_hir_def/src/body.rs4
-rw-r--r--crates/ra_hir_def/src/body/lower.rs163
-rw-r--r--crates/ra_hir_def/src/child_by_source.rs2
-rw-r--r--crates/ra_hir_def/src/generics.rs16
-rw-r--r--crates/ra_hir_def/src/item_tree.rs52
-rw-r--r--crates/ra_hir_def/src/item_tree/lower.rs175
-rw-r--r--crates/ra_hir_def/src/item_tree/tests.rs62
-rw-r--r--crates/ra_hir_def/src/keys.rs26
-rw-r--r--crates/ra_hir_def/src/lib.rs2
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs4
-rw-r--r--crates/ra_hir_def/src/path.rs4
-rw-r--r--crates/ra_hir_def/src/path/lower.rs52
-rw-r--r--crates/ra_hir_def/src/path/lower/lower_use.rs2
-rw-r--r--crates/ra_hir_def/src/type_ref.rs48
-rw-r--r--crates/ra_hir_expand/src/ast_id_map.rs2
-rw-r--r--crates/ra_hir_expand/src/builtin_derive.rs10
-rw-r--r--crates/ra_hir_expand/src/db.rs4
-rw-r--r--crates/ra_hir_expand/src/lib.rs6
-rw-r--r--crates/ra_hir_expand/src/proc_macro.rs2
-rw-r--r--crates/ra_hir_ty/Cargo.toml6
-rw-r--r--crates/ra_hir_ty/src/diagnostics.rs14
-rw-r--r--crates/ra_hir_ty/src/diagnostics/expr.rs6
-rw-r--r--crates/ra_hir_ty/src/diagnostics/unsafe_check.rs38
-rw-r--r--crates/ra_hir_ty/src/infer.rs11
-rw-r--r--crates/ra_hir_ty/src/lower.rs5
-rw-r--r--crates/ra_hir_ty/src/tests.rs2
-rw-r--r--crates/ra_hir_ty/src/tests/simple.rs38
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs19
-rw-r--r--crates/ra_hir_ty/src/traits/chalk/mapping.rs22
-rw-r--r--crates/ra_ide/Cargo.toml2
-rw-r--r--crates/ra_ide/src/call_hierarchy.rs54
-rw-r--r--crates/ra_ide/src/completion/complete_attribute.rs12
-rw-r--r--crates/ra_ide/src/completion/complete_fn_param.rs40
-rw-r--r--crates/ra_ide/src/completion/complete_keyword.rs38
-rw-r--r--crates/ra_ide/src/completion/complete_trait_impl.rs25
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs30
-rw-r--r--crates/ra_ide/src/completion/patterns.rs18
-rw-r--r--crates/ra_ide/src/completion/unstable_feature_descriptor.rs2
-rw-r--r--crates/ra_ide/src/diagnostics.rs32
-rw-r--r--crates/ra_ide/src/display.rs12
-rw-r--r--crates/ra_ide/src/display/navigation_target.rs46
-rw-r--r--crates/ra_ide/src/display/short_label.rs34
-rw-r--r--crates/ra_ide/src/extend_selection.rs12
-rw-r--r--crates/ra_ide/src/file_structure.rs80
-rw-r--r--crates/ra_ide/src/folding_ranges.rs31
-rw-r--r--crates/ra_ide/src/goto_implementation.rs14
-rw-r--r--crates/ra_ide/src/hover.rs68
-rw-r--r--crates/ra_ide/src/inlay_hints.rs22
-rw-r--r--crates/ra_ide/src/lib.rs3
-rw-r--r--crates/ra_ide/src/references.rs48
-rw-r--r--crates/ra_ide/src/references/rename.rs18
-rw-r--r--crates/ra_ide/src/runnables.rs200
-rw-r--r--crates/ra_ide/src/ssr.rs10
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs97
-rw-r--r--crates/ra_ide/src/syntax_highlighting/html.rs10
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tests.rs21
-rw-r--r--crates/ra_ide/src/syntax_tree.rs14
-rw-r--r--crates/ra_ide/test_data/highlight_unsafe.html18
-rw-r--r--crates/ra_ide/test_data/highlighting.html9
-rw-r--r--crates/ra_ide/test_data/rainbow_highlighting.html12
-rw-r--r--crates/ra_ide_db/src/change.rs24
-rw-r--r--crates/ra_ide_db/src/defs.rs57
-rw-r--r--crates/ra_ide_db/src/search.rs2
-rw-r--r--crates/ra_ide_db/src/symbol_index.rs16
-rw-r--r--crates/ra_mbe/src/syntax_bridge.rs2
-rw-r--r--crates/ra_mbe/src/tests.rs22
-rw-r--r--crates/ra_parser/src/grammar.rs20
-rw-r--r--crates/ra_parser/src/grammar/expressions.rs6
-rw-r--r--crates/ra_parser/src/grammar/expressions/atom.rs2
-rw-r--r--crates/ra_parser/src/grammar/items.rs18
-rw-r--r--crates/ra_parser/src/grammar/items/adt.rs18
-rw-r--r--crates/ra_parser/src/grammar/items/consts.rs4
-rw-r--r--crates/ra_parser/src/grammar/items/traits.rs4
-rw-r--r--crates/ra_parser/src/grammar/items/use_item.rs2
-rw-r--r--crates/ra_parser/src/grammar/patterns.rs12
-rw-r--r--crates/ra_parser/src/grammar/type_args.rs4
-rw-r--r--crates/ra_parser/src/grammar/type_params.rs2
-rw-r--r--crates/ra_parser/src/grammar/types.rs8
-rw-r--r--crates/ra_parser/src/syntax_kind/generated.rs72
-rw-r--r--crates/ra_proc_macro_srv/Cargo.toml2
-rw-r--r--crates/ra_prof/Cargo.toml3
-rw-r--r--crates/ra_prof/src/lib.rs2
-rw-r--r--crates/ra_prof/src/memory_usage.rs37
-rw-r--r--crates/ra_prof/src/stop_watch.rs86
-rw-r--r--crates/ra_project_model/Cargo.toml2
-rw-r--r--crates/ra_project_model/src/cargo_workspace.rs29
-rw-r--r--crates/ra_project_model/src/cfg_flag.rs4
-rw-r--r--crates/ra_project_model/src/sysroot.rs90
-rw-r--r--crates/ra_ssr/src/lib.rs6
-rw-r--r--crates/ra_ssr/src/matching.rs12
-rw-r--r--crates/ra_ssr/src/parsing.rs31
-rw-r--r--crates/ra_ssr/src/replacing.rs106
-rw-r--r--crates/ra_ssr/src/resolving.rs35
-rw-r--r--crates/ra_ssr/src/search.rs98
-rw-r--r--crates/ra_ssr/src/tests.rs195
-rw-r--r--crates/ra_syntax/Cargo.toml2
-rw-r--r--crates/ra_syntax/src/ast.rs20
-rw-r--r--crates/ra_syntax/src/ast/edit.rs51
-rw-r--r--crates/ra_syntax/src/ast/expr_ext.rs13
-rw-r--r--crates/ra_syntax/src/ast/generated.rs41
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs4754
-rw-r--r--crates/ra_syntax/src/ast/make.rs28
-rw-r--r--crates/ra_syntax/src/ast/node_ext.rs141
-rw-r--r--crates/ra_syntax/src/ast/traits.rs12
-rw-r--r--crates/ra_syntax/src/lib.rs10
-rw-r--r--crates/ra_syntax/src/parsing/text_tree_sink.rs4
-rw-r--r--crates/ra_syntax/src/ptr.rs2
-rw-r--r--crates/ra_syntax/src/tests.rs4
-rw-r--r--crates/ra_syntax/src/validation.rs10
-rw-r--r--crates/ra_syntax/src/validation/block.rs2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0005_attribute_recover.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0011_extern_struct.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast52
-rw-r--r--crates/ra_syntax/test_data/parser/err/0013_invalid_type.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0015_curly_in_params.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0016_missing_semi.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast18
-rw-r--r--crates/ra_syntax/test_data/parser/err/0019_let_recover.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0020_fn_recover.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0021_incomplete_param.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast30
-rw-r--r--crates/ra_syntax/test_data/parser/err/0025_nope.rast50
-rw-r--r--crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0029_field_completion.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0035_use_recover.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/err/0036_partial_use.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0043_default_const.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rast46
-rw-r--r--crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/fragments/type/ok/0000_result.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/fuzz-failures/0000.rs4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast20
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0030_cond.rast18
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.rast7
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast28
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast22
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0075_block.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast22
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.rast26
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.rast22
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast26
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast20
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0109_label.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.rast20
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast18
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rast94
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast18
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rast18
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0001_struct_item.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0005_fn_item.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast13
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0008_mod_item.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0009_use_item.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0012_visibility.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.rast26
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.rast68
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0019_enums.rast52
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.rast40
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0023_static_items.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0024_const_item.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0029_range_forms.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0030_traits.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0031_extern.rast150
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0032_where_for.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0033_label_break.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast110
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast20
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast22
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0049_async_block.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast60
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0060_as_range.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0061_match_full_range.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast40
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.rast26
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast34
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0065_comment_newline.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0066_default_const.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0067_where_for_pred.rast60
-rw-r--r--crates/rust-analyzer/Cargo.toml6
-rw-r--r--crates/rust-analyzer/src/bin/args.rs65
-rw-r--r--crates/rust-analyzer/src/bin/main.rs51
-rw-r--r--crates/rust-analyzer/src/caps.rs4
-rw-r--r--crates/rust-analyzer/src/cli.rs4
-rw-r--r--crates/rust-analyzer/src/cli/analysis_bench.rs135
-rw-r--r--crates/rust-analyzer/src/cli/analysis_stats.rs474
-rw-r--r--crates/rust-analyzer/src/config.rs5
-rw-r--r--crates/rust-analyzer/src/document.rs6
-rw-r--r--crates/rust-analyzer/src/global_state.rs8
-rw-r--r--crates/rust-analyzer/src/handlers.rs78
-rw-r--r--crates/rust-analyzer/src/lsp_ext.rs3
-rw-r--r--crates/rust-analyzer/src/lsp_utils.rs40
-rw-r--r--crates/rust-analyzer/src/main_loop.rs21
-rw-r--r--crates/rust-analyzer/src/semantic_tokens.rs139
-rw-r--r--crates/rust-analyzer/src/to_proto.rs39
-rw-r--r--crates/rust-analyzer/tests/heavy_tests/main.rs8
-rw-r--r--crates/rust-analyzer/tests/heavy_tests/support.rs3
-rw-r--r--crates/stdx/src/lib.rs15
-rw-r--r--crates/test_utils/src/fixture.rs8
-rw-r--r--docs/dev/README.md345
-rw-r--r--docs/dev/style.md212
-rw-r--r--docs/dev/syntax.md4
-rw-r--r--editors/code/package.json10
-rw-r--r--editors/code/src/commands.ts5
-rw-r--r--editors/code/src/debug.ts12
-rw-r--r--editors/code/src/lsp_ext.ts1
-rw-r--r--xtask/Cargo.toml10
-rw-r--r--xtask/src/ast_src.rs2102
-rw-r--r--xtask/src/codegen/gen_syntax.rs353
-rw-r--r--xtask/src/codegen/gen_unstable_future_descriptor.rs2
-rw-r--r--xtask/src/codegen/rust.ungram587
-rw-r--r--xtask/src/metrics.rs132
-rw-r--r--xtask/tests/tidy.rs1
478 files changed, 7833 insertions, 9017 deletions
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 20663196d..2acd44012 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -61,9 +61,6 @@ jobs:
61 override: true 61 override: true
62 components: rustfmt, rust-src 62 components: rustfmt, rust-src
63 63
64 - if: matrix.os == 'ubuntu-latest'
65 run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/
66
67 - name: Cache cargo directories 64 - name: Cache cargo directories
68 uses: actions/cache@v2 65 uses: actions/cache@v2
69 with: 66 with:
@@ -108,8 +105,6 @@ jobs:
108 override: true 105 override: true
109 target: 'powerpc-unknown-linux-gnu' 106 target: 'powerpc-unknown-linux-gnu'
110 107
111 - run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/
112
113 - name: Cache cargo directories 108 - name: Cache cargo directories
114 uses: actions/cache@v2 109 uses: actions/cache@v2
115 with: 110 with:
diff --git a/Cargo.lock b/Cargo.lock
index ff225399e..dc49fc4bd 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -102,13 +102,12 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
102 102
103[[package]] 103[[package]]
104name = "cargo_metadata" 104name = "cargo_metadata"
105version = "0.10.0" 105version = "0.11.1"
106source = "registry+https://github.com/rust-lang/crates.io-index" 106source = "registry+https://github.com/rust-lang/crates.io-index"
107checksum = "b8de60b887edf6d74370fc8eb177040da4847d971d6234c7b13a6da324ef0caf" 107checksum = "89fec17b16f1ac67908af82e47d0a90a7afd0e1827b181cd77504323d3263d35"
108dependencies = [ 108dependencies = [
109 "semver", 109 "semver",
110 "serde", 110 "serde",
111 "serde_derive",
112 "serde_json", 111 "serde_json",
113] 112]
114 113
@@ -126,9 +125,9 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
126 125
127[[package]] 126[[package]]
128name = "chalk-derive" 127name = "chalk-derive"
129version = "0.18.0" 128version = "0.21.0"
130source = "registry+https://github.com/rust-lang/crates.io-index" 129source = "registry+https://github.com/rust-lang/crates.io-index"
131checksum = "eea3a22f0c30b2504ac4ab58934dac0d00b92a4d7788df32795cabca24c3f929" 130checksum = "c1df0dbb57d74b4acd20f20fa66ab2acd09776b79eaeb9d8f947b2f3e01c40bf"
132dependencies = [ 131dependencies = [
133 "proc-macro2", 132 "proc-macro2",
134 "quote", 133 "quote",
@@ -138,9 +137,9 @@ dependencies = [
138 137
139[[package]] 138[[package]]
140name = "chalk-ir" 139name = "chalk-ir"
141version = "0.18.0" 140version = "0.21.0"
142source = "registry+https://github.com/rust-lang/crates.io-index" 141source = "registry+https://github.com/rust-lang/crates.io-index"
143checksum = "fb617b643e145e3b151502799e91a9625dd5daf1cf05dc2cb821bc75ae0c9cbd" 142checksum = "44361a25dbdb1dc428f56ad7a3c21ba9ca12f3225c26a47919ff6fcb10a583d4"
144dependencies = [ 143dependencies = [
145 "chalk-derive", 144 "chalk-derive",
146 "lazy_static", 145 "lazy_static",
@@ -148,9 +147,9 @@ dependencies = [
148 147
149[[package]] 148[[package]]
150name = "chalk-recursive" 149name = "chalk-recursive"
151version = "0.18.0" 150version = "0.21.0"
152source = "registry+https://github.com/rust-lang/crates.io-index" 151source = "registry+https://github.com/rust-lang/crates.io-index"
153checksum = "d280565c8eefbf9b2bc615df49c7dfd971faad37774bf65734e626fd23864bd6" 152checksum = "dd89556b98de156d5eaf21077d297cd2198628f10f2df140798ea3a5dd84bc86"
154dependencies = [ 153dependencies = [
155 "chalk-derive", 154 "chalk-derive",
156 "chalk-ir", 155 "chalk-ir",
@@ -161,9 +160,9 @@ dependencies = [
161 160
162[[package]] 161[[package]]
163name = "chalk-solve" 162name = "chalk-solve"
164version = "0.18.0" 163version = "0.21.0"
165source = "registry+https://github.com/rust-lang/crates.io-index" 164source = "registry+https://github.com/rust-lang/crates.io-index"
166checksum = "be906fbca3f3077dce0e76d9864771d0f450c946af0d86b569fb9504148a065a" 165checksum = "a886da37a0dc457057d86f78f026f7a09c6d8088aa13f4f4127fdb8dc80119a3"
167dependencies = [ 166dependencies = [
168 "chalk-derive", 167 "chalk-derive",
169 "chalk-ir", 168 "chalk-ir",
@@ -280,9 +279,9 @@ checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
280 279
281[[package]] 280[[package]]
282name = "drop_bomb" 281name = "drop_bomb"
283version = "0.1.4" 282version = "0.1.5"
284source = "registry+https://github.com/rust-lang/crates.io-index" 283source = "registry+https://github.com/rust-lang/crates.io-index"
285checksum = "69b26e475fd29098530e709294e94e661974c851aed42512793f120fed4e199f" 284checksum = "9bda8e21c04aca2ae33ffc2fd8c23134f3cac46db123ba97bd9d3f3b8a4a85e1"
286 285
287[[package]] 286[[package]]
288name = "either" 287name = "either"
@@ -319,9 +318,9 @@ dependencies = [
319 318
320[[package]] 319[[package]]
321name = "filetime" 320name = "filetime"
322version = "0.2.10" 321version = "0.2.12"
323source = "registry+https://github.com/rust-lang/crates.io-index" 322source = "registry+https://github.com/rust-lang/crates.io-index"
324checksum = "affc17579b132fc2461adf7c575cc6e8b134ebca52c51f5411388965227dc695" 323checksum = "3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e"
325dependencies = [ 324dependencies = [
326 "cfg-if", 325 "cfg-if",
327 "libc", 326 "libc",
@@ -401,17 +400,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
401checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" 400checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
402 401
403[[package]] 402[[package]]
404name = "getrandom"
405version = "0.1.14"
406source = "registry+https://github.com/rust-lang/crates.io-index"
407checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
408dependencies = [
409 "cfg-if",
410 "libc",
411 "wasi",
412]
413
414[[package]]
415name = "gimli" 403name = "gimli"
416version = "0.22.0" 404version = "0.22.0"
417source = "registry+https://github.com/rust-lang/crates.io-index" 405source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -565,9 +553,9 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
565 553
566[[package]] 554[[package]]
567name = "libc" 555name = "libc"
568version = "0.2.73" 556version = "0.2.74"
569source = "registry+https://github.com/rust-lang/crates.io-index" 557source = "registry+https://github.com/rust-lang/crates.io-index"
570checksum = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9" 558checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10"
571 559
572[[package]] 560[[package]]
573name = "libloading" 561name = "libloading"
@@ -619,9 +607,9 @@ dependencies = [
619 607
620[[package]] 608[[package]]
621name = "lsp-types" 609name = "lsp-types"
622version = "0.78.0" 610version = "0.79.0"
623source = "registry+https://github.com/rust-lang/crates.io-index" 611source = "registry+https://github.com/rust-lang/crates.io-index"
624checksum = "d2e6cf68e3492cfa2035f0382c1da1b6ab045db0320feca505b86b4f13d66c27" 612checksum = "7f1f86677fdbe8df5f88b99131b1424e50aad27bbe3e5900d221bc414bd72e9b"
625dependencies = [ 613dependencies = [
626 "base64", 614 "base64",
627 "bitflags", 615 "bitflags",
@@ -811,6 +799,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
811checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" 799checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d"
812 800
813[[package]] 801[[package]]
802name = "oorandom"
803version = "11.1.2"
804source = "registry+https://github.com/rust-lang/crates.io-index"
805checksum = "a170cebd8021a008ea92e4db85a72f80b35df514ec664b296fdcbb654eac0b2c"
806
807[[package]]
814name = "parking_lot" 808name = "parking_lot"
815version = "0.11.0" 809version = "0.11.0"
816source = "registry+https://github.com/rust-lang/crates.io-index" 810source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -847,6 +841,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
847checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" 841checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
848 842
849[[package]] 843[[package]]
844name = "perf-event"
845version = "0.4.4"
846source = "registry+https://github.com/rust-lang/crates.io-index"
847checksum = "76c42ba5d85a2f4472b99f475fb60cf336d9b4c85b1ea8bb300fef2e3c7c8f89"
848dependencies = [
849 "libc",
850 "perf-event-open-sys",
851]
852
853[[package]]
854name = "perf-event-open-sys"
855version = "0.3.1"
856source = "registry+https://github.com/rust-lang/crates.io-index"
857checksum = "95db63e37862bc1b842135d2234ef9418f222cc660c6752f45e7cf9ddfb97f96"
858dependencies = [
859 "libc",
860]
861
862[[package]]
850name = "petgraph" 863name = "petgraph"
851version = "0.5.1" 864version = "0.5.1"
852source = "registry+https://github.com/rust-lang/crates.io-index" 865source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -869,12 +882,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
869checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" 882checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
870 883
871[[package]] 884[[package]]
872name = "ppv-lite86"
873version = "0.2.8"
874source = "registry+https://github.com/rust-lang/crates.io-index"
875checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
876
877[[package]]
878name = "proc-macro2" 885name = "proc-macro2"
879version = "1.0.19" 886version = "1.0.19"
880source = "registry+https://github.com/rust-lang/crates.io-index" 887source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1046,6 +1053,7 @@ dependencies = [
1046 "indexmap", 1053 "indexmap",
1047 "itertools", 1054 "itertools",
1048 "log", 1055 "log",
1056 "oorandom",
1049 "ra_assists", 1057 "ra_assists",
1050 "ra_cfg", 1058 "ra_cfg",
1051 "ra_db", 1059 "ra_db",
@@ -1056,7 +1064,6 @@ dependencies = [
1056 "ra_ssr", 1064 "ra_ssr",
1057 "ra_syntax", 1065 "ra_syntax",
1058 "ra_text_edit", 1066 "ra_text_edit",
1059 "rand",
1060 "rustc-hash", 1067 "rustc-hash",
1061 "stdx", 1068 "stdx",
1062 "test_utils", 1069 "test_utils",
@@ -1138,6 +1145,7 @@ dependencies = [
1138 "cfg-if", 1145 "cfg-if",
1139 "libc", 1146 "libc",
1140 "once_cell", 1147 "once_cell",
1148 "perf-event",
1141 "ra_arena", 1149 "ra_arena",
1142] 1150]
1143 1151
@@ -1218,57 +1226,6 @@ dependencies = [
1218] 1226]
1219 1227
1220[[package]] 1228[[package]]
1221name = "rand"
1222version = "0.7.3"
1223source = "registry+https://github.com/rust-lang/crates.io-index"
1224checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
1225dependencies = [
1226 "getrandom",
1227 "libc",
1228 "rand_chacha",
1229 "rand_core",
1230 "rand_hc",
1231 "rand_pcg",
1232]
1233
1234[[package]]
1235name = "rand_chacha"
1236version = "0.2.2"
1237source = "registry+https://github.com/rust-lang/crates.io-index"
1238checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
1239dependencies = [
1240 "ppv-lite86",
1241 "rand_core",
1242]
1243
1244[[package]]
1245name = "rand_core"
1246version = "0.5.1"
1247source = "registry+https://github.com/rust-lang/crates.io-index"
1248checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
1249dependencies = [
1250 "getrandom",
1251]
1252
1253[[package]]
1254name = "rand_hc"
1255version = "0.2.0"
1256source = "registry+https://github.com/rust-lang/crates.io-index"
1257checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
1258dependencies = [
1259 "rand_core",
1260]
1261
1262[[package]]
1263name = "rand_pcg"
1264version = "0.2.1"
1265source = "registry+https://github.com/rust-lang/crates.io-index"
1266checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429"
1267dependencies = [
1268 "rand_core",
1269]
1270
1271[[package]]
1272name = "rayon" 1229name = "rayon"
1273version = "1.3.1" 1230version = "1.3.1"
1274source = "registry+https://github.com/rust-lang/crates.io-index" 1231source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1354,6 +1311,7 @@ dependencies = [
1354 "lsp-server", 1311 "lsp-server",
1355 "lsp-types", 1312 "lsp-types",
1356 "mimalloc", 1313 "mimalloc",
1314 "oorandom",
1357 "parking_lot", 1315 "parking_lot",
1358 "pico-args", 1316 "pico-args",
1359 "ra_cfg", 1317 "ra_cfg",
@@ -1372,7 +1330,6 @@ dependencies = [
1372 "ra_text_edit", 1330 "ra_text_edit",
1373 "ra_toolchain", 1331 "ra_toolchain",
1374 "ra_tt", 1332 "ra_tt",
1375 "rand",
1376 "rayon", 1333 "rayon",
1377 "rustc-hash", 1334 "rustc-hash",
1378 "serde", 1335 "serde",
@@ -1387,9 +1344,9 @@ dependencies = [
1387 1344
1388[[package]] 1345[[package]]
1389name = "rustc-ap-rustc_lexer" 1346name = "rustc-ap-rustc_lexer"
1390version = "669.0.0" 1347version = "671.0.0"
1391source = "registry+https://github.com/rust-lang/crates.io-index" 1348source = "registry+https://github.com/rust-lang/crates.io-index"
1392checksum = "456af5f09c006cf6c22c1a433ee0232c4bb74bdc6c647a010166a47c94ed2a63" 1349checksum = "22e1221f3bfa2943c942cf8da319ab2346887f8757778c29c7f1822cd27b521f"
1393dependencies = [ 1350dependencies = [
1394 "unicode-xid", 1351 "unicode-xid",
1395] 1352]
@@ -1414,16 +1371,16 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
1414 1371
1415[[package]] 1372[[package]]
1416name = "salsa" 1373name = "salsa"
1417version = "0.15.0" 1374version = "0.15.2"
1418source = "registry+https://github.com/rust-lang/crates.io-index" 1375source = "registry+https://github.com/rust-lang/crates.io-index"
1419checksum = "885b4b99dde959decc84e85dd943bd140b4aabd62db2f8206ef5270f77ec20b9" 1376checksum = "9ab29056d4fb4048a5f0d169c9b6e5526160c9ec37aded5a6879c2c9c445a8e4"
1420dependencies = [ 1377dependencies = [
1421 "crossbeam-utils", 1378 "crossbeam-utils",
1422 "indexmap", 1379 "indexmap",
1423 "lock_api", 1380 "lock_api",
1424 "log", 1381 "log",
1382 "oorandom",
1425 "parking_lot", 1383 "parking_lot",
1426 "rand",
1427 "rustc-hash", 1384 "rustc-hash",
1428 "salsa-macros", 1385 "salsa-macros",
1429 "smallvec", 1386 "smallvec",
@@ -1431,9 +1388,9 @@ dependencies = [
1431 1388
1432[[package]] 1389[[package]]
1433name = "salsa-macros" 1390name = "salsa-macros"
1434version = "0.15.0" 1391version = "0.15.2"
1435source = "registry+https://github.com/rust-lang/crates.io-index" 1392source = "registry+https://github.com/rust-lang/crates.io-index"
1436checksum = "2c280ac85b15ac214b86ac4b407626a48e6a1c4f90769a582fec74aa57942b9f" 1393checksum = "a1c3aec007c63c4ed4cd7a018529fb0b5575c4562575fc6a40d6cd2ae0b792ef"
1437dependencies = [ 1394dependencies = [
1438 "heck", 1395 "heck",
1439 "proc-macro2", 1396 "proc-macro2",
@@ -1484,9 +1441,9 @@ dependencies = [
1484 1441
1485[[package]] 1442[[package]]
1486name = "semver" 1443name = "semver"
1487version = "0.9.0" 1444version = "0.10.0"
1488source = "registry+https://github.com/rust-lang/crates.io-index" 1445source = "registry+https://github.com/rust-lang/crates.io-index"
1489checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 1446checksum = "394cec28fa623e00903caf7ba4fa6fb9a0e260280bb8cdbbba029611108a0190"
1490dependencies = [ 1447dependencies = [
1491 "semver-parser", 1448 "semver-parser",
1492 "serde", 1449 "serde",
@@ -1576,9 +1533,9 @@ version = "0.1.0"
1576 1533
1577[[package]] 1534[[package]]
1578name = "syn" 1535name = "syn"
1579version = "1.0.36" 1536version = "1.0.38"
1580source = "registry+https://github.com/rust-lang/crates.io-index" 1537source = "registry+https://github.com/rust-lang/crates.io-index"
1581checksum = "4cdb98bcb1f9d81d07b536179c269ea15999b5d14ea958196413869445bb5250" 1538checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4"
1582dependencies = [ 1539dependencies = [
1583 "proc-macro2", 1540 "proc-macro2",
1584 "quote", 1541 "quote",
@@ -1665,9 +1622,9 @@ checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed"
1665 1622
1666[[package]] 1623[[package]]
1667name = "tracing" 1624name = "tracing"
1668version = "0.1.17" 1625version = "0.1.18"
1669source = "registry+https://github.com/rust-lang/crates.io-index" 1626source = "registry+https://github.com/rust-lang/crates.io-index"
1670checksum = "dbdf4ccd1652592b01286a5dbe1e2a77d78afaa34beadd9872a5f7396f92aaa9" 1627checksum = "f0aae59226cf195d8e74d4b34beae1859257efb4e5fed3f147d2dc2c7d372178"
1671dependencies = [ 1628dependencies = [
1672 "cfg-if", 1629 "cfg-if",
1673 "tracing-attributes", 1630 "tracing-attributes",
@@ -1687,9 +1644,9 @@ dependencies = [
1687 1644
1688[[package]] 1645[[package]]
1689name = "tracing-core" 1646name = "tracing-core"
1690version = "0.1.11" 1647version = "0.1.13"
1691source = "registry+https://github.com/rust-lang/crates.io-index" 1648source = "registry+https://github.com/rust-lang/crates.io-index"
1692checksum = "94ae75f0d28ae10786f3b1895c55fe72e79928fd5ccdebb5438c75e93fec178f" 1649checksum = "d593f98af59ebc017c0648f0117525db358745a8894a8d684e185ba3f45954f9"
1693dependencies = [ 1650dependencies = [
1694 "lazy_static", 1651 "lazy_static",
1695] 1652]
@@ -1717,9 +1674,9 @@ dependencies = [
1717 1674
1718[[package]] 1675[[package]]
1719name = "tracing-subscriber" 1676name = "tracing-subscriber"
1720version = "0.2.9" 1677version = "0.2.10"
1721source = "registry+https://github.com/rust-lang/crates.io-index" 1678source = "registry+https://github.com/rust-lang/crates.io-index"
1722checksum = "e4f5dd7095c2481b7b3cbed71c8de53085fb3542bc3c2b4c73cba43e8f11c7ba" 1679checksum = "f7b33f8b2ef2ab0c3778c12646d9c42a24f7772bee4cdafc72199644a9f58fdc"
1723dependencies = [ 1680dependencies = [
1724 "ansi_term", 1681 "ansi_term",
1725 "chrono", 1682 "chrono",
@@ -1750,6 +1707,12 @@ dependencies = [
1750] 1707]
1751 1708
1752[[package]] 1709[[package]]
1710name = "ungrammar"
1711version = "1.1.1"
1712source = "registry+https://github.com/rust-lang/crates.io-index"
1713checksum = "c4e20e58a08ee1bcf8a4695cf74550cf054d6c489105f594beacb2c684210aad"
1714
1715[[package]]
1753name = "unicode-bidi" 1716name = "unicode-bidi"
1754version = "0.3.4" 1717version = "0.3.4"
1755source = "registry+https://github.com/rust-lang/crates.io-index" 1718source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1826,12 +1789,6 @@ dependencies = [
1826] 1789]
1827 1790
1828[[package]] 1791[[package]]
1829name = "wasi"
1830version = "0.9.0+wasi-snapshot-preview1"
1831source = "registry+https://github.com/rust-lang/crates.io-index"
1832checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
1833
1834[[package]]
1835name = "winapi" 1792name = "winapi"
1836version = "0.2.8" 1793version = "0.2.8"
1837source = "registry+https://github.com/rust-lang/crates.io-index" 1794source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1875,6 +1832,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1875checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1832checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
1876 1833
1877[[package]] 1834[[package]]
1835name = "write-json"
1836version = "0.1.2"
1837source = "registry+https://github.com/rust-lang/crates.io-index"
1838checksum = "06069a848f95fceae3e5e03c0ddc8cb78452b56654ee0c8e68f938cf790fb9e3"
1839
1840[[package]]
1878name = "ws2_32-sys" 1841name = "ws2_32-sys"
1879version = "0.2.1" 1842version = "0.2.1"
1880source = "registry+https://github.com/rust-lang/crates.io-index" 1843source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1893,5 +1856,7 @@ dependencies = [
1893 "pico-args", 1856 "pico-args",
1894 "proc-macro2", 1857 "proc-macro2",
1895 "quote", 1858 "quote",
1859 "ungrammar",
1896 "walkdir", 1860 "walkdir",
1861 "write-json",
1897] 1862]
diff --git a/crates/flycheck/Cargo.toml b/crates/flycheck/Cargo.toml
index bea485694..ff8a1e568 100644
--- a/crates/flycheck/Cargo.toml
+++ b/crates/flycheck/Cargo.toml
@@ -11,7 +11,7 @@ doctest = false
11[dependencies] 11[dependencies]
12crossbeam-channel = "0.4.0" 12crossbeam-channel = "0.4.0"
13log = "0.4.8" 13log = "0.4.8"
14cargo_metadata = "0.10.0" 14cargo_metadata = "0.11.1"
15serde_json = "1.0.48" 15serde_json = "1.0.48"
16jod-thread = "0.1.1" 16jod-thread = "0.1.1"
17ra_toolchain = { path = "../ra_toolchain" } 17ra_toolchain = { path = "../ra_toolchain" }
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs
index ad376ad18..7c38f5ef9 100644
--- a/crates/flycheck/src/lib.rs
+++ b/crates/flycheck/src/lib.rs
@@ -24,6 +24,7 @@ pub enum FlycheckConfig {
24 command: String, 24 command: String,
25 target_triple: Option<String>, 25 target_triple: Option<String>,
26 all_targets: bool, 26 all_targets: bool,
27 no_default_features: bool,
27 all_features: bool, 28 all_features: bool,
28 features: Vec<String>, 29 features: Vec<String>,
29 extra_args: Vec<String>, 30 extra_args: Vec<String>,
@@ -180,6 +181,7 @@ impl FlycheckActor {
180 FlycheckConfig::CargoCommand { 181 FlycheckConfig::CargoCommand {
181 command, 182 command,
182 target_triple, 183 target_triple,
184 no_default_features,
183 all_targets, 185 all_targets,
184 all_features, 186 all_features,
185 extra_args, 187 extra_args,
@@ -198,9 +200,14 @@ impl FlycheckActor {
198 } 200 }
199 if *all_features { 201 if *all_features {
200 cmd.arg("--all-features"); 202 cmd.arg("--all-features");
201 } else if !features.is_empty() { 203 } else {
202 cmd.arg("--features"); 204 if *no_default_features {
203 cmd.arg(features.join(" ")); 205 cmd.arg("--no-default-features");
206 }
207 if !features.is_empty() {
208 cmd.arg("--features");
209 cmd.arg(features.join(" "));
210 }
204 } 211 }
205 cmd.args(extra_args); 212 cmd.args(extra_args);
206 cmd 213 cmd
diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs
index 3407df856..afd3fd4b9 100644
--- a/crates/ra_assists/src/assist_context.rs
+++ b/crates/ra_assists/src/assist_context.rs
@@ -73,6 +73,10 @@ impl<'a> AssistContext<'a> {
73 self.sema.db 73 self.sema.db
74 } 74 }
75 75
76 pub(crate) fn source_file(&self) -> &SourceFile {
77 &self.source_file
78 }
79
76 // NB, this ignores active selection. 80 // NB, this ignores active selection.
77 pub(crate) fn offset(&self) -> TextSize { 81 pub(crate) fn offset(&self) -> TextSize {
78 self.frange.range.start() 82 self.frange.range.start()
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs
index 01adb834c..15ec75c95 100644
--- a/crates/ra_assists/src/ast_transform.rs
+++ b/crates/ra_assists/src/ast_transform.rs
@@ -32,7 +32,7 @@ impl<'a> AstTransform<'a> for NullTransformer {
32 32
33pub struct SubstituteTypeParams<'a> { 33pub struct SubstituteTypeParams<'a> {
34 source_scope: &'a SemanticsScope<'a>, 34 source_scope: &'a SemanticsScope<'a>,
35 substs: FxHashMap<hir::TypeParam, ast::TypeRef>, 35 substs: FxHashMap<hir::TypeParam, ast::Type>,
36 previous: Box<dyn AstTransform<'a> + 'a>, 36 previous: Box<dyn AstTransform<'a> + 'a>,
37} 37}
38 38
@@ -41,7 +41,7 @@ impl<'a> SubstituteTypeParams<'a> {
41 source_scope: &'a SemanticsScope<'a>, 41 source_scope: &'a SemanticsScope<'a>,
42 // FIXME: there's implicit invariant that `trait_` and `source_scope` match... 42 // FIXME: there's implicit invariant that `trait_` and `source_scope` match...
43 trait_: hir::Trait, 43 trait_: hir::Trait,
44 impl_def: ast::ImplDef, 44 impl_def: ast::Impl,
45 ) -> SubstituteTypeParams<'a> { 45 ) -> SubstituteTypeParams<'a> {
46 let substs = get_syntactic_substs(impl_def).unwrap_or_default(); 46 let substs = get_syntactic_substs(impl_def).unwrap_or_default();
47 let generic_def: hir::GenericDef = trait_.into(); 47 let generic_def: hir::GenericDef = trait_.into();
@@ -63,7 +63,7 @@ impl<'a> SubstituteTypeParams<'a> {
63 let default = k.default(source_scope.db)?; 63 let default = k.default(source_scope.db)?;
64 Some(( 64 Some((
65 k, 65 k,
66 ast::make::type_ref( 66 ast::make::ty(
67 &default 67 &default
68 .display_source_code(source_scope.db, source_scope.module()?.into()) 68 .display_source_code(source_scope.db, source_scope.module()?.into())
69 .ok()?, 69 .ok()?,
@@ -79,19 +79,25 @@ impl<'a> SubstituteTypeParams<'a> {
79 }; 79 };
80 80
81 // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the 81 // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the
82 // trait ref, and then go from the types in the substs back to the syntax) 82 // trait ref, and then go from the types in the substs back to the syntax).
83 fn get_syntactic_substs(impl_def: ast::ImplDef) -> Option<Vec<ast::TypeRef>> { 83 fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::Type>> {
84 let target_trait = impl_def.target_trait()?; 84 let target_trait = impl_def.trait_()?;
85 let path_type = match target_trait { 85 let path_type = match target_trait {
86 ast::TypeRef::PathType(path) => path, 86 ast::Type::PathType(path) => path,
87 _ => return None, 87 _ => return None,
88 }; 88 };
89 let type_arg_list = path_type.path()?.segment()?.type_arg_list()?; 89 let generic_arg_list = path_type.path()?.segment()?.generic_arg_list()?;
90
90 let mut result = Vec::new(); 91 let mut result = Vec::new();
91 for type_arg in type_arg_list.type_args() { 92 for generic_arg in generic_arg_list.generic_args() {
92 let type_arg: ast::TypeArg = type_arg; 93 match generic_arg {
93 result.push(type_arg.type_ref()?); 94 ast::GenericArg::TypeArg(type_arg) => result.push(type_arg.ty()?),
95 ast::GenericArg::AssocTypeArg(_)
96 | ast::GenericArg::LifetimeArg(_)
97 | ast::GenericArg::ConstArg(_) => (),
98 }
94 } 99 }
100
95 Some(result) 101 Some(result)
96 } 102 }
97 } 103 }
@@ -99,9 +105,9 @@ impl<'a> SubstituteTypeParams<'a> {
99 &self, 105 &self,
100 node: &ra_syntax::SyntaxNode, 106 node: &ra_syntax::SyntaxNode,
101 ) -> Option<ra_syntax::SyntaxNode> { 107 ) -> Option<ra_syntax::SyntaxNode> {
102 let type_ref = ast::TypeRef::cast(node.clone())?; 108 let type_ref = ast::Type::cast(node.clone())?;
103 let path = match &type_ref { 109 let path = match &type_ref {
104 ast::TypeRef::PathType(path_type) => path_type.path()?, 110 ast::Type::PathType(path_type) => path_type.path()?,
105 _ => return None, 111 _ => return None,
106 }; 112 };
107 // FIXME: use `hir::Path::from_src` instead. 113 // FIXME: use `hir::Path::from_src` instead.
@@ -157,7 +163,7 @@ impl<'a> QualifyPaths<'a> {
157 163
158 let type_args = p 164 let type_args = p
159 .segment() 165 .segment()
160 .and_then(|s| s.type_arg_list()) 166 .and_then(|s| s.generic_arg_list())
161 .map(|arg_list| apply(self, arg_list)); 167 .map(|arg_list| apply(self, arg_list));
162 if let Some(type_args) = type_args { 168 if let Some(type_args) = type_args {
163 let last_segment = path.segment().unwrap(); 169 let last_segment = path.segment().unwrap();
diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/ra_assists/src/handlers/add_custom_impl.rs
index acb07e36a..b67438b6b 100644
--- a/crates/ra_assists/src/handlers/add_custom_impl.rs
+++ b/crates/ra_assists/src/handlers/add_custom_impl.rs
@@ -29,8 +29,8 @@ use crate::{
29// } 29// }
30// ``` 30// ```
31pub(crate) fn add_custom_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 31pub(crate) fn add_custom_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
32 let input = ctx.find_node_at_offset::<ast::AttrInput>()?; 32 let attr = ctx.find_node_at_offset::<ast::Attr>()?;
33 let attr = input.syntax().parent().and_then(ast::Attr::cast)?; 33 let input = attr.token_tree()?;
34 34
35 let attr_name = attr 35 let attr_name = attr
36 .syntax() 36 .syntax()
diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs
index 39a5321d1..135a2ac9c 100644
--- a/crates/ra_assists/src/handlers/add_explicit_type.rs
+++ b/crates/ra_assists/src/handlers/add_explicit_type.rs
@@ -1,6 +1,6 @@
1use hir::HirDisplay; 1use hir::HirDisplay;
2use ra_syntax::{ 2use ra_syntax::{
3 ast::{self, AstNode, LetStmt, NameOwner, TypeAscriptionOwner}, 3 ast::{self, AstNode, LetStmt, NameOwner},
4 TextRange, 4 TextRange,
5}; 5};
6 6
@@ -22,20 +22,20 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
22// } 22// }
23// ``` 23// ```
24pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 24pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
25 let stmt = ctx.find_node_at_offset::<LetStmt>()?; 25 let let_stmt = ctx.find_node_at_offset::<LetStmt>()?;
26 let module = ctx.sema.scope(stmt.syntax()).module()?; 26 let module = ctx.sema.scope(let_stmt.syntax()).module()?;
27 let expr = stmt.initializer()?; 27 let expr = let_stmt.initializer()?;
28 // Must be a binding 28 // Must be a binding
29 let pat = match stmt.pat()? { 29 let pat = match let_stmt.pat()? {
30 ast::Pat::BindPat(bind_pat) => bind_pat, 30 ast::Pat::IdentPat(bind_pat) => bind_pat,
31 _ => return None, 31 _ => return None,
32 }; 32 };
33 let pat_range = pat.syntax().text_range(); 33 let pat_range = pat.syntax().text_range();
34 // The binding must have a name 34 // The binding must have a name
35 let name = pat.name()?; 35 let name = pat.name()?;
36 let name_range = name.syntax().text_range(); 36 let name_range = name.syntax().text_range();
37 let stmt_range = stmt.syntax().text_range(); 37 let stmt_range = let_stmt.syntax().text_range();
38 let eq_range = stmt.eq_token()?.text_range(); 38 let eq_range = let_stmt.eq_token()?.text_range();
39 // Assist should only be applicable if cursor is between 'let' and '=' 39 // Assist should only be applicable if cursor is between 'let' and '='
40 let let_range = TextRange::new(stmt_range.start(), eq_range.start()); 40 let let_range = TextRange::new(stmt_range.start(), eq_range.start());
41 let cursor_in_range = let_range.contains_range(ctx.frange.range); 41 let cursor_in_range = let_range.contains_range(ctx.frange.range);
@@ -44,9 +44,9 @@ pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Optio
44 } 44 }
45 // Assist not applicable if the type has already been specified 45 // Assist not applicable if the type has already been specified
46 // and it has no placeholders 46 // and it has no placeholders
47 let ascribed_ty = stmt.ascribed_type(); 47 let ascribed_ty = let_stmt.ty();
48 if let Some(ty) = &ascribed_ty { 48 if let Some(ty) = &ascribed_ty {
49 if ty.syntax().descendants().find_map(ast::PlaceholderType::cast).is_none() { 49 if ty.syntax().descendants().find_map(ast::InferType::cast).is_none() {
50 return None; 50 return None;
51 } 51 }
52 } 52 }
diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs
index f185e61e5..95a750aee 100644
--- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs
+++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs
@@ -111,16 +111,17 @@ fn add_missing_impl_members_inner(
111 label: &'static str, 111 label: &'static str,
112) -> Option<()> { 112) -> Option<()> {
113 let _p = ra_prof::profile("add_missing_impl_members_inner"); 113 let _p = ra_prof::profile("add_missing_impl_members_inner");
114 let impl_def = ctx.find_node_at_offset::<ast::ImplDef>()?; 114 let impl_def = ctx.find_node_at_offset::<ast::Impl>()?;
115 let impl_item_list = impl_def.item_list()?; 115 let impl_item_list = impl_def.assoc_item_list()?;
116 116
117 let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?; 117 let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?;
118 118
119 let def_name = |item: &ast::AssocItem| -> Option<SmolStr> { 119 let def_name = |item: &ast::AssocItem| -> Option<SmolStr> {
120 match item { 120 match item {
121 ast::AssocItem::FnDef(def) => def.name(), 121 ast::AssocItem::Fn(def) => def.name(),
122 ast::AssocItem::TypeAliasDef(def) => def.name(), 122 ast::AssocItem::TypeAlias(def) => def.name(),
123 ast::AssocItem::ConstDef(def) => def.name(), 123 ast::AssocItem::Const(def) => def.name(),
124 ast::AssocItem::MacroCall(_) => None,
124 } 125 }
125 .map(|it| it.text().clone()) 126 .map(|it| it.text().clone())
126 }; 127 };
@@ -128,13 +129,13 @@ fn add_missing_impl_members_inner(
128 let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def) 129 let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def)
129 .iter() 130 .iter()
130 .map(|i| match i { 131 .map(|i| match i {
131 hir::AssocItem::Function(i) => ast::AssocItem::FnDef(i.source(ctx.db()).value), 132 hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(ctx.db()).value),
132 hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAliasDef(i.source(ctx.db()).value), 133 hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAlias(i.source(ctx.db()).value),
133 hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db()).value), 134 hir::AssocItem::Const(i) => ast::AssocItem::Const(i.source(ctx.db()).value),
134 }) 135 })
135 .filter(|t| def_name(&t).is_some()) 136 .filter(|t| def_name(&t).is_some())
136 .filter(|t| match t { 137 .filter(|t| match t {
137 ast::AssocItem::FnDef(def) => match mode { 138 ast::AssocItem::Fn(def) => match mode {
138 AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(), 139 AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(),
139 AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(), 140 AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(),
140 }, 141 },
@@ -157,10 +158,8 @@ fn add_missing_impl_members_inner(
157 .into_iter() 158 .into_iter()
158 .map(|it| ast_transform::apply(&*ast_transform, it)) 159 .map(|it| ast_transform::apply(&*ast_transform, it))
159 .map(|it| match it { 160 .map(|it| match it {
160 ast::AssocItem::FnDef(def) => ast::AssocItem::FnDef(add_body(def)), 161 ast::AssocItem::Fn(def) => ast::AssocItem::Fn(add_body(def)),
161 ast::AssocItem::TypeAliasDef(def) => { 162 ast::AssocItem::TypeAlias(def) => ast::AssocItem::TypeAlias(def.remove_bounds()),
162 ast::AssocItem::TypeAliasDef(def.remove_bounds())
163 }
164 _ => it, 163 _ => it,
165 }) 164 })
166 .map(|it| edit::remove_attrs_and_docs(&it)); 165 .map(|it| edit::remove_attrs_and_docs(&it));
@@ -173,7 +172,7 @@ fn add_missing_impl_members_inner(
173 Some(cap) => { 172 Some(cap) => {
174 let mut cursor = Cursor::Before(first_new_item.syntax()); 173 let mut cursor = Cursor::Before(first_new_item.syntax());
175 let placeholder; 174 let placeholder;
176 if let ast::AssocItem::FnDef(func) = &first_new_item { 175 if let ast::AssocItem::Fn(func) = &first_new_item {
177 if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) { 176 if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) {
178 if m.syntax().text() == "todo!()" { 177 if m.syntax().text() == "todo!()" {
179 placeholder = m; 178 placeholder = m;
@@ -191,7 +190,7 @@ fn add_missing_impl_members_inner(
191 }) 190 })
192} 191}
193 192
194fn add_body(fn_def: ast::FnDef) -> ast::FnDef { 193fn add_body(fn_def: ast::Fn) -> ast::Fn {
195 if fn_def.body().is_some() { 194 if fn_def.body().is_some() {
196 return fn_def; 195 return fn_def;
197 } 196 }
diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs
index 947be3b9b..01e7b7a44 100644
--- a/crates/ra_assists/src/handlers/auto_import.rs
+++ b/crates/ra_assists/src/handlers/auto_import.rs
@@ -92,7 +92,7 @@ impl AutoImportAssets {
92 92
93 fn for_regular_path(path_under_caret: ast::Path, ctx: &AssistContext) -> Option<Self> { 93 fn for_regular_path(path_under_caret: ast::Path, ctx: &AssistContext) -> Option<Self> {
94 let syntax_under_caret = path_under_caret.syntax().to_owned(); 94 let syntax_under_caret = path_under_caret.syntax().to_owned();
95 if syntax_under_caret.ancestors().find_map(ast::UseItem::cast).is_some() { 95 if syntax_under_caret.ancestors().find_map(ast::Use::cast).is_some() {
96 return None; 96 return None;
97 } 97 }
98 98
diff --git a/crates/ra_assists/src/handlers/change_return_type_to_result.rs b/crates/ra_assists/src/handlers/change_return_type_to_result.rs
index def00f7d8..b83c94404 100644
--- a/crates/ra_assists/src/handlers/change_return_type_to_result.rs
+++ b/crates/ra_assists/src/handlers/change_return_type_to_result.rs
@@ -20,9 +20,9 @@ use test_utils::mark;
20pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 20pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
21 let ret_type = ctx.find_node_at_offset::<ast::RetType>()?; 21 let ret_type = ctx.find_node_at_offset::<ast::RetType>()?;
22 // FIXME: extend to lambdas as well 22 // FIXME: extend to lambdas as well
23 let fn_def = ret_type.syntax().parent().and_then(ast::FnDef::cast)?; 23 let fn_def = ret_type.syntax().parent().and_then(ast::Fn::cast)?;
24 24
25 let type_ref = &ret_type.type_ref()?; 25 let type_ref = &ret_type.ty()?;
26 let ret_type_str = type_ref.syntax().text().to_string(); 26 let ret_type_str = type_ref.syntax().text().to_string();
27 let first_part_ret_type = ret_type_str.splitn(2, '<').next(); 27 let first_part_ret_type = ret_type_str.splitn(2, '<').next();
28 if let Some(ret_type_first_part) = first_part_ret_type { 28 if let Some(ret_type_first_part) = first_part_ret_type {
@@ -74,6 +74,7 @@ impl TailReturnCollector {
74 let expr = match &stmt { 74 let expr = match &stmt {
75 ast::Stmt::ExprStmt(stmt) => stmt.expr(), 75 ast::Stmt::ExprStmt(stmt) => stmt.expr(),
76 ast::Stmt::LetStmt(stmt) => stmt.initializer(), 76 ast::Stmt::LetStmt(stmt) => stmt.initializer(),
77 ast::Stmt::Item(_) => continue,
77 }; 78 };
78 if let Some(expr) = &expr { 79 if let Some(expr) = &expr {
79 self.handle_exprs(expr, collect_break); 80 self.handle_exprs(expr, collect_break);
@@ -94,6 +95,7 @@ impl TailReturnCollector {
94 let expr_stmt = match &expr_stmt { 95 let expr_stmt = match &expr_stmt {
95 ast::Stmt::ExprStmt(stmt) => stmt.expr(), 96 ast::Stmt::ExprStmt(stmt) => stmt.expr(),
96 ast::Stmt::LetStmt(stmt) => stmt.initializer(), 97 ast::Stmt::LetStmt(stmt) => stmt.initializer(),
98 ast::Stmt::Item(_) => None,
97 }; 99 };
98 if let Some(expr) = &expr_stmt { 100 if let Some(expr) = &expr_stmt {
99 self.handle_exprs(expr, collect_break); 101 self.handle_exprs(expr, collect_break);
@@ -239,8 +241,7 @@ fn get_tail_expr_from_block(expr: &Expr) -> Option<Vec<NodeType>> {
239 Expr::ArrayExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), 241 Expr::ArrayExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
240 Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), 242 Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
241 Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), 243 Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
242 Expr::Label(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), 244 Expr::RecordExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
243 Expr::RecordLit(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
244 Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), 245 Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
245 Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), 246 Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
246 Expr::AwaitExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), 247 Expr::AwaitExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs
index 4343b423c..724daa93f 100644
--- a/crates/ra_assists/src/handlers/change_visibility.rs
+++ b/crates/ra_assists/src/handlers/change_visibility.rs
@@ -1,9 +1,7 @@
1use ra_syntax::{ 1use ra_syntax::{
2 ast::{self, NameOwner, VisibilityOwner}, 2 ast::{self, NameOwner, VisibilityOwner},
3 AstNode, 3 AstNode,
4 SyntaxKind::{ 4 SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, VISIBILITY},
5 CONST_DEF, ENUM_DEF, FN_DEF, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY,
6 },
7 T, 5 T,
8}; 6};
9use test_utils::mark; 7use test_utils::mark;
@@ -38,7 +36,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
38 36
39 let (offset, target) = if let Some(keyword) = item_keyword { 37 let (offset, target) = if let Some(keyword) = item_keyword {
40 let parent = keyword.parent(); 38 let parent = keyword.parent();
41 let def_kws = vec![CONST_DEF, STATIC_DEF, FN_DEF, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF]; 39 let def_kws = vec![CONST, STATIC, FN, MODULE, STRUCT, ENUM, TRAIT];
42 // Parent is not a definition, can't add visibility 40 // Parent is not a definition, can't add visibility
43 if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) { 41 if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) {
44 return None; 42 return None;
@@ -49,7 +47,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
49 } 47 }
50 (vis_offset(&parent), keyword.text_range()) 48 (vis_offset(&parent), keyword.text_range())
51 } else if let Some(field_name) = ctx.find_node_at_offset::<ast::Name>() { 49 } else if let Some(field_name) = ctx.find_node_at_offset::<ast::Name>() {
52 let field = field_name.syntax().ancestors().find_map(ast::RecordFieldDef::cast)?; 50 let field = field_name.syntax().ancestors().find_map(ast::RecordField::cast)?;
53 if field.name()? != field_name { 51 if field.name()? != field_name {
54 mark::hit!(change_visibility_field_false_positive); 52 mark::hit!(change_visibility_field_false_positive);
55 return None; 53 return None;
@@ -58,7 +56,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
58 return None; 56 return None;
59 } 57 }
60 (vis_offset(field.syntax()), field_name.syntax().text_range()) 58 (vis_offset(field.syntax()), field_name.syntax().text_range())
61 } else if let Some(field) = ctx.find_node_at_offset::<ast::TupleFieldDef>() { 59 } else if let Some(field) = ctx.find_node_at_offset::<ast::TupleField>() {
62 if field.visibility().is_some() { 60 if field.visibility().is_some() {
63 return None; 61 return None;
64 } 62 }
diff --git a/crates/ra_assists/src/handlers/early_return.rs b/crates/ra_assists/src/handlers/early_return.rs
index 330459f3c..6816a2709 100644
--- a/crates/ra_assists/src/handlers/early_return.rs
+++ b/crates/ra_assists/src/handlers/early_return.rs
@@ -8,7 +8,7 @@ use ra_syntax::{
8 make, 8 make,
9 }, 9 },
10 AstNode, 10 AstNode,
11 SyntaxKind::{FN_DEF, LOOP_EXPR, L_CURLY, R_CURLY, WHILE_EXPR, WHITESPACE}, 11 SyntaxKind::{FN, LOOP_EXPR, L_CURLY, R_CURLY, WHILE_EXPR, WHITESPACE},
12 SyntaxNode, 12 SyntaxNode,
13}; 13};
14 14
@@ -51,11 +51,11 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
51 // Check if there is an IfLet that we can handle. 51 // Check if there is an IfLet that we can handle.
52 let if_let_pat = match cond.pat() { 52 let if_let_pat = match cond.pat() {
53 None => None, // No IfLet, supported. 53 None => None, // No IfLet, supported.
54 Some(ast::Pat::TupleStructPat(pat)) if pat.args().count() == 1 => { 54 Some(ast::Pat::TupleStructPat(pat)) if pat.fields().count() == 1 => {
55 let path = pat.path()?; 55 let path = pat.path()?;
56 match path.qualifier() { 56 match path.qualifier() {
57 None => { 57 None => {
58 let bound_ident = pat.args().next().unwrap(); 58 let bound_ident = pat.fields().next().unwrap();
59 Some((path, bound_ident)) 59 Some((path, bound_ident))
60 } 60 }
61 Some(_) => return None, 61 Some(_) => return None,
@@ -88,7 +88,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
88 88
89 let early_expression: ast::Expr = match parent_container.kind() { 89 let early_expression: ast::Expr = match parent_container.kind() {
90 WHILE_EXPR | LOOP_EXPR => make::expr_continue(), 90 WHILE_EXPR | LOOP_EXPR => make::expr_continue(),
91 FN_DEF => make::expr_return(), 91 FN => make::expr_return(),
92 _ => return None, 92 _ => return None,
93 }; 93 };
94 94
@@ -123,7 +123,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
123 let happy_arm = { 123 let happy_arm = {
124 let pat = make::tuple_struct_pat( 124 let pat = make::tuple_struct_pat(
125 path, 125 path,
126 once(make::bind_pat(make::name("it")).into()), 126 once(make::ident_pat(make::name("it")).into()),
127 ); 127 );
128 let expr = { 128 let expr = {
129 let name_ref = make::name_ref("it"); 129 let name_ref = make::name_ref("it");
@@ -136,7 +136,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
136 136
137 let sad_arm = make::match_arm( 137 let sad_arm = make::match_arm(
138 // FIXME: would be cool to use `None` or `Err(_)` if appropriate 138 // FIXME: would be cool to use `None` or `Err(_)` if appropriate
139 once(make::placeholder_pat().into()), 139 once(make::wildcard_pat().into()),
140 early_expression, 140 early_expression,
141 ); 141 );
142 142
@@ -144,7 +144,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext)
144 }; 144 };
145 145
146 let let_stmt = make::let_stmt( 146 let let_stmt = make::let_stmt(
147 make::bind_pat(make::name(&bound_ident.syntax().to_string())).into(), 147 make::ident_pat(make::name(&bound_ident.syntax().to_string())).into(),
148 Some(match_expr), 148 Some(match_expr),
149 ); 149 );
150 let let_stmt = let_stmt.indent(if_indent_level); 150 let let_stmt = let_stmt.indent(if_indent_level);
diff --git a/crates/ra_assists/src/handlers/expand_glob_import.rs b/crates/ra_assists/src/handlers/expand_glob_import.rs
new file mode 100644
index 000000000..eb216a81a
--- /dev/null
+++ b/crates/ra_assists/src/handlers/expand_glob_import.rs
@@ -0,0 +1,391 @@
1use hir::{AssocItem, MacroDef, ModuleDef, Name, PathResolution, ScopeDef, SemanticsScope};
2use ra_ide_db::{
3 defs::{classify_name_ref, Definition, NameRefClass},
4 RootDatabase,
5};
6use ra_syntax::{algo, ast, match_ast, AstNode, SyntaxNode, SyntaxToken, T};
7
8use crate::{
9 assist_context::{AssistBuilder, AssistContext, Assists},
10 AssistId, AssistKind,
11};
12
13use either::Either;
14
15// Assist: expand_glob_import
16//
17// Expands glob imports.
18//
19// ```
20// mod foo {
21// pub struct Bar;
22// pub struct Baz;
23// }
24//
25// use foo::*<|>;
26//
27// fn qux(bar: Bar, baz: Baz) {}
28// ```
29// ->
30// ```
31// mod foo {
32// pub struct Bar;
33// pub struct Baz;
34// }
35//
36// use foo::{Baz, Bar};
37//
38// fn qux(bar: Bar, baz: Baz) {}
39// ```
40pub(crate) fn expand_glob_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
41 let star = ctx.find_token_at_offset(T![*])?;
42 let mod_path = find_mod_path(&star)?;
43
44 let source_file = ctx.source_file();
45 let scope = ctx.sema.scope_at_offset(source_file.syntax(), ctx.offset());
46
47 let defs_in_mod = find_defs_in_mod(ctx, scope, &mod_path)?;
48 let name_refs_in_source_file =
49 source_file.syntax().descendants().filter_map(ast::NameRef::cast).collect();
50 let used_names = find_used_names(ctx, defs_in_mod, name_refs_in_source_file);
51
52 let parent = star.parent().parent()?;
53 acc.add(
54 AssistId("expand_glob_import", AssistKind::RefactorRewrite),
55 "Expand glob import",
56 parent.text_range(),
57 |builder| {
58 replace_ast(builder, &parent, mod_path, used_names);
59 },
60 )
61}
62
63fn find_mod_path(star: &SyntaxToken) -> Option<ast::Path> {
64 star.ancestors().find_map(|n| ast::UseTree::cast(n).and_then(|u| u.path()))
65}
66
67#[derive(PartialEq)]
68enum Def {
69 ModuleDef(ModuleDef),
70 MacroDef(MacroDef),
71}
72
73impl Def {
74 fn name(&self, db: &RootDatabase) -> Option<Name> {
75 match self {
76 Def::ModuleDef(def) => def.name(db),
77 Def::MacroDef(def) => def.name(db),
78 }
79 }
80}
81
82fn find_defs_in_mod(
83 ctx: &AssistContext,
84 from: SemanticsScope<'_>,
85 path: &ast::Path,
86) -> Option<Vec<Def>> {
87 let hir_path = ctx.sema.lower_path(&path)?;
88 let module = if let Some(PathResolution::Def(ModuleDef::Module(module))) =
89 from.resolve_hir_path_qualifier(&hir_path)
90 {
91 module
92 } else {
93 return None;
94 };
95
96 let module_scope = module.scope(ctx.db(), from.module());
97
98 let mut defs = vec![];
99 for (_, def) in module_scope {
100 match def {
101 ScopeDef::ModuleDef(def) => defs.push(Def::ModuleDef(def)),
102 ScopeDef::MacroDef(def) => defs.push(Def::MacroDef(def)),
103 _ => continue,
104 }
105 }
106
107 Some(defs)
108}
109
110fn find_used_names(
111 ctx: &AssistContext,
112 defs_in_mod: Vec<Def>,
113 name_refs_in_source_file: Vec<ast::NameRef>,
114) -> Vec<Name> {
115 let defs_in_source_file = name_refs_in_source_file
116 .iter()
117 .filter_map(|r| classify_name_ref(&ctx.sema, r))
118 .filter_map(|rc| match rc {
119 NameRefClass::Definition(Definition::ModuleDef(def)) => Some(Def::ModuleDef(def)),
120 NameRefClass::Definition(Definition::Macro(def)) => Some(Def::MacroDef(def)),
121 _ => None,
122 })
123 .collect::<Vec<Def>>();
124
125 defs_in_mod
126 .iter()
127 .filter(|def| {
128 if let Def::ModuleDef(ModuleDef::Trait(tr)) = def {
129 for item in tr.items(ctx.db()) {
130 if let AssocItem::Function(f) = item {
131 if defs_in_source_file.contains(&Def::ModuleDef(ModuleDef::Function(f))) {
132 return true;
133 }
134 }
135 }
136 }
137
138 defs_in_source_file.contains(def)
139 })
140 .filter_map(|d| d.name(ctx.db()))
141 .collect()
142}
143
144fn replace_ast(
145 builder: &mut AssistBuilder,
146 node: &SyntaxNode,
147 path: ast::Path,
148 used_names: Vec<Name>,
149) {
150 let replacement: Either<ast::UseTree, ast::UseTreeList> = match used_names.as_slice() {
151 [name] => Either::Left(ast::make::use_tree(
152 ast::make::path_from_text(&format!("{}::{}", path, name)),
153 None,
154 None,
155 false,
156 )),
157 names => Either::Right(ast::make::use_tree_list(names.iter().map(|n| {
158 ast::make::use_tree(ast::make::path_from_text(&n.to_string()), None, None, false)
159 }))),
160 };
161
162 let mut replace_node = |replacement: Either<ast::UseTree, ast::UseTreeList>| {
163 algo::diff(node, &replacement.either(|u| u.syntax().clone(), |ut| ut.syntax().clone()))
164 .into_text_edit(builder.text_edit_builder());
165 };
166
167 match_ast! {
168 match node {
169 ast::UseTree(use_tree) => {
170 replace_node(replacement);
171 },
172 ast::UseTreeList(use_tree_list) => {
173 replace_node(replacement);
174 },
175 ast::Use(use_item) => {
176 builder.replace_ast(use_item, ast::make::use_(replacement.left_or_else(|ut| ast::make::use_tree(path, Some(ut), None, false))));
177 },
178 _ => {},
179 }
180 }
181}
182
183#[cfg(test)]
184mod tests {
185 use crate::tests::{check_assist, check_assist_not_applicable};
186
187 use super::*;
188
189 #[test]
190 fn expanding_glob_import() {
191 check_assist(
192 expand_glob_import,
193 r"
194mod foo {
195 pub struct Bar;
196 pub struct Baz;
197 pub struct Qux;
198
199 pub fn f() {}
200}
201
202use foo::*<|>;
203
204fn qux(bar: Bar, baz: Baz) {
205 f();
206}
207",
208 r"
209mod foo {
210 pub struct Bar;
211 pub struct Baz;
212 pub struct Qux;
213
214 pub fn f() {}
215}
216
217use foo::{Baz, Bar, f};
218
219fn qux(bar: Bar, baz: Baz) {
220 f();
221}
222",
223 )
224 }
225
226 #[test]
227 fn expanding_glob_import_with_existing_explicit_names() {
228 check_assist(
229 expand_glob_import,
230 r"
231mod foo {
232 pub struct Bar;
233 pub struct Baz;
234 pub struct Qux;
235
236 pub fn f() {}
237}
238
239use foo::{*<|>, f};
240
241fn qux(bar: Bar, baz: Baz) {
242 f();
243}
244",
245 r"
246mod foo {
247 pub struct Bar;
248 pub struct Baz;
249 pub struct Qux;
250
251 pub fn f() {}
252}
253
254use foo::{Baz, Bar, f};
255
256fn qux(bar: Bar, baz: Baz) {
257 f();
258}
259",
260 )
261 }
262
263 #[test]
264 fn expanding_nested_glob_import() {
265 check_assist(
266 expand_glob_import,
267 r"
268mod foo {
269 mod bar {
270 pub struct Bar;
271 pub struct Baz;
272 pub struct Qux;
273
274 pub fn f() {}
275 }
276
277 mod baz {
278 pub fn g() {}
279 }
280}
281
282use foo::{bar::{*<|>, f}, baz::*};
283
284fn qux(bar: Bar, baz: Baz) {
285 f();
286 g();
287}
288",
289 r"
290mod foo {
291 mod bar {
292 pub struct Bar;
293 pub struct Baz;
294 pub struct Qux;
295
296 pub fn f() {}
297 }
298
299 mod baz {
300 pub fn g() {}
301 }
302}
303
304use foo::{bar::{Baz, Bar, f}, baz::*};
305
306fn qux(bar: Bar, baz: Baz) {
307 f();
308 g();
309}
310",
311 )
312 }
313
314 #[test]
315 fn expanding_glob_import_with_macro_defs() {
316 check_assist(
317 expand_glob_import,
318 r"
319//- /lib.rs crate:foo
320#[macro_export]
321macro_rules! bar {
322 () => ()
323}
324
325pub fn baz() {}
326
327//- /main.rs crate:main deps:foo
328use foo::*<|>;
329
330fn main() {
331 bar!();
332 baz();
333}
334",
335 r"
336use foo::{bar, baz};
337
338fn main() {
339 bar!();
340 baz();
341}
342",
343 )
344 }
345
346 #[test]
347 fn expanding_glob_import_with_trait_method_uses() {
348 check_assist(
349 expand_glob_import,
350 r"
351//- /lib.rs crate:foo
352pub trait Tr {
353 fn method(&self) {}
354}
355impl Tr for () {}
356
357//- /main.rs crate:main deps:foo
358use foo::*<|>;
359
360fn main() {
361 ().method();
362}
363",
364 r"
365use foo::Tr;
366
367fn main() {
368 ().method();
369}
370",
371 )
372 }
373
374 #[test]
375 fn expanding_is_not_applicable_if_cursor_is_not_in_star_token() {
376 check_assist_not_applicable(
377 expand_glob_import,
378 r"
379 mod foo {
380 pub struct Bar;
381 pub struct Baz;
382 pub struct Qux;
383 }
384
385 use foo::Bar<|>;
386
387 fn qux(bar: Bar, baz: Baz) {}
388 ",
389 )
390 }
391}
diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs
index 2b8e273b3..ccec688ca 100644
--- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs
+++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs
@@ -31,7 +31,7 @@ pub(crate) fn extract_struct_from_enum_variant(
31 acc: &mut Assists, 31 acc: &mut Assists,
32 ctx: &AssistContext, 32 ctx: &AssistContext,
33) -> Option<()> { 33) -> Option<()> {
34 let variant = ctx.find_node_at_offset::<ast::EnumVariant>()?; 34 let variant = ctx.find_node_at_offset::<ast::Variant>()?;
35 let field_list = match variant.kind() { 35 let field_list = match variant.kind() {
36 ast::StructKind::Tuple(field_list) => field_list, 36 ast::StructKind::Tuple(field_list) => field_list,
37 _ => return None, 37 _ => return None,
diff --git a/crates/ra_assists/src/handlers/extract_variable.rs b/crates/ra_assists/src/handlers/extract_variable.rs
index 098adf078..cc62db0c4 100644
--- a/crates/ra_assists/src/handlers/extract_variable.rs
+++ b/crates/ra_assists/src/handlers/extract_variable.rs
@@ -1,7 +1,7 @@
1use ra_syntax::{ 1use ra_syntax::{
2 ast::{self, AstNode}, 2 ast::{self, AstNode},
3 SyntaxKind::{ 3 SyntaxKind::{
4 BLOCK_EXPR, BREAK_EXPR, COMMENT, LAMBDA_EXPR, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, 4 BLOCK_EXPR, BREAK_EXPR, CLOSURE_EXPR, COMMENT, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR,
5 }, 5 },
6 SyntaxNode, 6 SyntaxNode,
7}; 7};
@@ -45,7 +45,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option
45 target, 45 target,
46 move |edit| { 46 move |edit| {
47 let field_shorthand = 47 let field_shorthand =
48 match to_extract.syntax().parent().and_then(ast::RecordField::cast) { 48 match to_extract.syntax().parent().and_then(ast::RecordExprField::cast) {
49 Some(field) => field.name_ref(), 49 Some(field) => field.name_ref(),
50 None => None, 50 None => None,
51 }; 51 };
@@ -148,7 +148,7 @@ impl Anchor {
148 } 148 }
149 149
150 if let Some(parent) = node.parent() { 150 if let Some(parent) = node.parent() {
151 if parent.kind() == MATCH_ARM || parent.kind() == LAMBDA_EXPR { 151 if parent.kind() == MATCH_ARM || parent.kind() == CLOSURE_EXPR {
152 return Some(Anchor::WrapInBlock(node)); 152 return Some(Anchor::WrapInBlock(node));
153 } 153 }
154 } 154 }
diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/ra_assists/src/handlers/fill_match_arms.rs
index 708e1bc6c..6698d1a27 100644
--- a/crates/ra_assists/src/handlers/fill_match_arms.rs
+++ b/crates/ra_assists/src/handlers/fill_match_arms.rs
@@ -43,7 +43,7 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option<
43 43
44 let mut arms: Vec<MatchArm> = match_arm_list.arms().collect(); 44 let mut arms: Vec<MatchArm> = match_arm_list.arms().collect();
45 if arms.len() == 1 { 45 if arms.len() == 1 {
46 if let Some(Pat::PlaceholderPat(..)) = arms[0].pat() { 46 if let Some(Pat::WildcardPat(..)) = arms[0].pat() {
47 arms.clear(); 47 arms.clear();
48 } 48 }
49 } 49 }
@@ -116,17 +116,15 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option<
116 match (first_new_arm, ctx.config.snippet_cap) { 116 match (first_new_arm, ctx.config.snippet_cap) {
117 (Some(first_new_arm), Some(cap)) => { 117 (Some(first_new_arm), Some(cap)) => {
118 let extend_lifetime; 118 let extend_lifetime;
119 let cursor = match first_new_arm 119 let cursor =
120 .syntax() 120 match first_new_arm.syntax().descendants().find_map(ast::WildcardPat::cast)
121 .descendants() 121 {
122 .find_map(ast::PlaceholderPat::cast) 122 Some(it) => {
123 { 123 extend_lifetime = it.syntax().clone();
124 Some(it) => { 124 Cursor::Replace(&extend_lifetime)
125 extend_lifetime = it.syntax().clone(); 125 }
126 Cursor::Replace(&extend_lifetime) 126 None => Cursor::Before(first_new_arm.syntax()),
127 } 127 };
128 None => Cursor::Before(first_new_arm.syntax()),
129 };
130 let snippet = render_snippet(cap, new_arm_list.syntax(), cursor); 128 let snippet = render_snippet(cap, new_arm_list.syntax(), cursor);
131 builder.replace_snippet(cap, old_range, snippet); 129 builder.replace_snippet(cap, old_range, snippet);
132 } 130 }
@@ -152,7 +150,7 @@ fn does_pat_match_variant(pat: &Pat, var: &Pat) -> bool {
152 let first_node_text = |pat: &Pat| pat.syntax().first_child().map(|node| node.text()); 150 let first_node_text = |pat: &Pat| pat.syntax().first_child().map(|node| node.text());
153 151
154 let pat_head = match pat { 152 let pat_head = match pat {
155 Pat::BindPat(bind_pat) => { 153 Pat::IdentPat(bind_pat) => {
156 if let Some(p) = bind_pat.pat() { 154 if let Some(p) = bind_pat.pat() {
157 first_node_text(&p) 155 first_node_text(&p)
158 } else { 156 } else {
@@ -199,12 +197,11 @@ fn build_pat(db: &RootDatabase, module: hir::Module, var: hir::EnumVariant) -> O
199 // FIXME: use HIR for this; it doesn't currently expose struct vs. tuple vs. unit variants though 197 // FIXME: use HIR for this; it doesn't currently expose struct vs. tuple vs. unit variants though
200 let pat: ast::Pat = match var.source(db).value.kind() { 198 let pat: ast::Pat = match var.source(db).value.kind() {
201 ast::StructKind::Tuple(field_list) => { 199 ast::StructKind::Tuple(field_list) => {
202 let pats = 200 let pats = iter::repeat(make::wildcard_pat().into()).take(field_list.fields().count());
203 iter::repeat(make::placeholder_pat().into()).take(field_list.fields().count());
204 make::tuple_struct_pat(path, pats).into() 201 make::tuple_struct_pat(path, pats).into()
205 } 202 }
206 ast::StructKind::Record(field_list) => { 203 ast::StructKind::Record(field_list) => {
207 let pats = field_list.fields().map(|f| make::bind_pat(f.name().unwrap()).into()); 204 let pats = field_list.fields().map(|f| make::ident_pat(f.name().unwrap()).into());
208 make::record_pat(path, pats).into() 205 make::record_pat(path, pats).into()
209 } 206 }
210 ast::StructKind::Unit => make::path_pat(path), 207 ast::StructKind::Unit => make::path_pat(path),
diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/ra_assists/src/handlers/fix_visibility.rs
index 1d3ed3c6a..1aefa79cc 100644
--- a/crates/ra_assists/src/handlers/fix_visibility.rs
+++ b/crates/ra_assists/src/handlers/fix_visibility.rs
@@ -82,7 +82,7 @@ fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext) -> O
82} 82}
83 83
84fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 84fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
85 let record_field: ast::RecordField = ctx.find_node_at_offset()?; 85 let record_field: ast::RecordExprField = ctx.find_node_at_offset()?;
86 let (record_field_def, _) = ctx.sema.resolve_record_field(&record_field)?; 86 let (record_field_def, _) = ctx.sema.resolve_record_field(&record_field)?;
87 87
88 let current_module = ctx.sema.scope(record_field.syntax()).module()?; 88 let current_module = ctx.sema.scope(record_field.syntax()).module()?;
diff --git a/crates/ra_assists/src/handlers/generate_derive.rs b/crates/ra_assists/src/handlers/generate_derive.rs
index 6ccf39900..90ece9fab 100644
--- a/crates/ra_assists/src/handlers/generate_derive.rs
+++ b/crates/ra_assists/src/handlers/generate_derive.rs
@@ -26,7 +26,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
26// ``` 26// ```
27pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 27pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
28 let cap = ctx.config.snippet_cap?; 28 let cap = ctx.config.snippet_cap?;
29 let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?; 29 let nominal = ctx.find_node_at_offset::<ast::AdtDef>()?;
30 let node_start = derive_insertion_offset(&nominal)?; 30 let node_start = derive_insertion_offset(&nominal)?;
31 let target = nominal.syntax().text_range(); 31 let target = nominal.syntax().text_range();
32 acc.add( 32 acc.add(
@@ -58,7 +58,7 @@ pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext) -> Option<
58} 58}
59 59
60// Insert `derive` after doc comments. 60// Insert `derive` after doc comments.
61fn derive_insertion_offset(nominal: &ast::NominalDef) -> Option<TextSize> { 61fn derive_insertion_offset(nominal: &ast::AdtDef) -> Option<TextSize> {
62 let non_ws_child = nominal 62 let non_ws_child = nominal
63 .syntax() 63 .syntax()
64 .children_with_tokens() 64 .children_with_tokens()
diff --git a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs b/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs
index a347e3c2e..4c1aef8a2 100644
--- a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs
+++ b/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs
@@ -22,7 +22,7 @@ use crate::{utils::FamousDefs, AssistContext, AssistId, AssistKind, Assists};
22// } 22// }
23// ``` 23// ```
24pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 24pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
25 let variant = ctx.find_node_at_offset::<ast::EnumVariant>()?; 25 let variant = ctx.find_node_at_offset::<ast::Variant>()?;
26 let variant_name = variant.name()?; 26 let variant_name = variant.name()?;
27 let enum_name = variant.parent_enum().name()?; 27 let enum_name = variant.parent_enum().name()?;
28 let field_list = match variant.kind() { 28 let field_list = match variant.kind() {
@@ -32,9 +32,9 @@ pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext
32 if field_list.fields().count() != 1 { 32 if field_list.fields().count() != 1 {
33 return None; 33 return None;
34 } 34 }
35 let field_type = field_list.fields().next()?.type_ref()?; 35 let field_type = field_list.fields().next()?.ty()?;
36 let path = match field_type { 36 let path = match field_type {
37 ast::TypeRef::PathType(it) => it, 37 ast::Type::PathType(it) => it,
38 _ => return None, 38 _ => return None,
39 }; 39 };
40 40
@@ -69,7 +69,7 @@ impl From<{0}> for {1} {{
69 69
70fn existing_from_impl( 70fn existing_from_impl(
71 sema: &'_ hir::Semantics<'_, RootDatabase>, 71 sema: &'_ hir::Semantics<'_, RootDatabase>,
72 variant: &ast::EnumVariant, 72 variant: &ast::Variant,
73) -> Option<()> { 73) -> Option<()> {
74 let variant = sema.to_def(variant)?; 74 let variant = sema.to_def(variant)?;
75 let enum_ = variant.parent_enum(sema.db); 75 let enum_ = variant.parent_enum(sema.db);
diff --git a/crates/ra_assists/src/handlers/generate_function.rs b/crates/ra_assists/src/handlers/generate_function.rs
index b721b96bb..acc97e648 100644
--- a/crates/ra_assists/src/handlers/generate_function.rs
+++ b/crates/ra_assists/src/handlers/generate_function.rs
@@ -82,7 +82,7 @@ struct FunctionTemplate {
82 insert_offset: TextSize, 82 insert_offset: TextSize,
83 placeholder_expr: ast::MacroCall, 83 placeholder_expr: ast::MacroCall,
84 leading_ws: String, 84 leading_ws: String,
85 fn_def: ast::FnDef, 85 fn_def: ast::Fn,
86 trailing_ws: String, 86 trailing_ws: String,
87 file: FileId, 87 file: FileId,
88} 88}
@@ -104,7 +104,7 @@ impl FunctionTemplate {
104struct FunctionBuilder { 104struct FunctionBuilder {
105 target: GeneratedFunctionTarget, 105 target: GeneratedFunctionTarget,
106 fn_name: ast::Name, 106 fn_name: ast::Name,
107 type_params: Option<ast::TypeParamList>, 107 type_params: Option<ast::GenericParamList>,
108 params: ast::ParamList, 108 params: ast::ParamList,
109 file: FileId, 109 file: FileId,
110 needs_pub: bool, 110 needs_pub: bool,
@@ -142,7 +142,7 @@ impl FunctionBuilder {
142 let fn_body = make::block_expr(vec![], Some(placeholder_expr)); 142 let fn_body = make::block_expr(vec![], Some(placeholder_expr));
143 let visibility = if self.needs_pub { Some(make::visibility_pub_crate()) } else { None }; 143 let visibility = if self.needs_pub { Some(make::visibility_pub_crate()) } else { None };
144 let mut fn_def = 144 let mut fn_def =
145 make::fn_def(visibility, self.fn_name, self.type_params, self.params, fn_body); 145 make::fn_(visibility, self.fn_name, self.type_params, self.params, fn_body);
146 let leading_ws; 146 let leading_ws;
147 let trailing_ws; 147 let trailing_ws;
148 148
@@ -200,7 +200,7 @@ fn fn_args(
200 ctx: &AssistContext, 200 ctx: &AssistContext,
201 target_module: hir::Module, 201 target_module: hir::Module,
202 call: &ast::CallExpr, 202 call: &ast::CallExpr,
203) -> Option<(Option<ast::TypeParamList>, ast::ParamList)> { 203) -> Option<(Option<ast::GenericParamList>, ast::ParamList)> {
204 let mut arg_names = Vec::new(); 204 let mut arg_names = Vec::new();
205 let mut arg_types = Vec::new(); 205 let mut arg_types = Vec::new();
206 for arg in call.arg_list()?.args() { 206 for arg in call.arg_list()?.args() {
diff --git a/crates/ra_assists/src/handlers/generate_impl.rs b/crates/ra_assists/src/handlers/generate_impl.rs
index cbbac1d7f..d9b87c9c0 100644
--- a/crates/ra_assists/src/handlers/generate_impl.rs
+++ b/crates/ra_assists/src/handlers/generate_impl.rs
@@ -1,4 +1,4 @@
1use ra_syntax::ast::{self, AstNode, NameOwner, TypeParamsOwner}; 1use ra_syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner};
2use stdx::{format_to, SepBy}; 2use stdx::{format_to, SepBy};
3 3
4use crate::{AssistContext, AssistId, AssistKind, Assists}; 4use crate::{AssistContext, AssistId, AssistKind, Assists};
@@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
23// } 23// }
24// ``` 24// ```
25pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 25pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
26 let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?; 26 let nominal = ctx.find_node_at_offset::<ast::AdtDef>()?;
27 let name = nominal.name()?; 27 let name = nominal.name()?;
28 let target = nominal.syntax().text_range(); 28 let target = nominal.syntax().text_range();
29 acc.add( 29 acc.add(
@@ -31,7 +31,7 @@ pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()
31 format!("Generate impl for `{}`", name), 31 format!("Generate impl for `{}`", name),
32 target, 32 target,
33 |edit| { 33 |edit| {
34 let type_params = nominal.type_param_list(); 34 let type_params = nominal.generic_param_list();
35 let start_offset = nominal.syntax().text_range().end(); 35 let start_offset = nominal.syntax().text_range().end();
36 let mut buf = String::new(); 36 let mut buf = String::new();
37 buf.push_str("\n\nimpl"); 37 buf.push_str("\n\nimpl");
diff --git a/crates/ra_assists/src/handlers/generate_new.rs b/crates/ra_assists/src/handlers/generate_new.rs
index e27def1d8..b84aa24b6 100644
--- a/crates/ra_assists/src/handlers/generate_new.rs
+++ b/crates/ra_assists/src/handlers/generate_new.rs
@@ -1,8 +1,6 @@
1use hir::Adt; 1use hir::Adt;
2use ra_syntax::{ 2use ra_syntax::{
3 ast::{ 3 ast::{self, AstNode, GenericParamsOwner, NameOwner, StructKind, VisibilityOwner},
4 self, AstNode, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, VisibilityOwner,
5 },
6 T, 4 T,
7}; 5};
8use stdx::{format_to, SepBy}; 6use stdx::{format_to, SepBy};
@@ -30,7 +28,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
30// 28//
31// ``` 29// ```
32pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 30pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
33 let strukt = ctx.find_node_at_offset::<ast::StructDef>()?; 31 let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
34 32
35 // We want to only apply this to non-union structs with named fields 33 // We want to only apply this to non-union structs with named fields
36 let field_list = match strukt.kind() { 34 let field_list = match strukt.kind() {
@@ -53,9 +51,7 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
53 51
54 let params = field_list 52 let params = field_list
55 .fields() 53 .fields()
56 .filter_map(|f| { 54 .filter_map(|f| Some(format!("{}: {}", f.name()?.syntax(), f.ty()?.syntax())))
57 Some(format!("{}: {}", f.name()?.syntax(), f.ascribed_type()?.syntax()))
58 })
59 .sep_by(", "); 55 .sep_by(", ");
60 let fields = field_list.fields().filter_map(|f| f.name()).sep_by(", "); 56 let fields = field_list.fields().filter_map(|f| f.name()).sep_by(", ");
61 57
@@ -90,8 +86,8 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
90 86
91// Generates the surrounding `impl Type { <code> }` including type and lifetime 87// Generates the surrounding `impl Type { <code> }` including type and lifetime
92// parameters 88// parameters
93fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { 89fn generate_impl_text(strukt: &ast::Struct, code: &str) -> String {
94 let type_params = strukt.type_param_list(); 90 let type_params = strukt.generic_param_list();
95 let mut buf = String::with_capacity(code.len()); 91 let mut buf = String::with_capacity(code.len());
96 buf.push_str("\n\nimpl"); 92 buf.push_str("\n\nimpl");
97 if let Some(type_params) = &type_params { 93 if let Some(type_params) = &type_params {
@@ -121,7 +117,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String {
121// 117//
122// FIXME: change the new fn checking to a more semantic approach when that's more 118// FIXME: change the new fn checking to a more semantic approach when that's more
123// viable (e.g. we process proc macros, etc) 119// viable (e.g. we process proc macros, etc)
124fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Option<ast::ImplDef>> { 120fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option<Option<ast::Impl>> {
125 let db = ctx.db(); 121 let db = ctx.db();
126 let module = strukt.syntax().ancestors().find(|node| { 122 let module = strukt.syntax().ancestors().find(|node| {
127 ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) 123 ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind())
@@ -129,7 +125,7 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Opti
129 125
130 let struct_def = ctx.sema.to_def(strukt)?; 126 let struct_def = ctx.sema.to_def(strukt)?;
131 127
132 let block = module.descendants().filter_map(ast::ImplDef::cast).find_map(|impl_blk| { 128 let block = module.descendants().filter_map(ast::Impl::cast).find_map(|impl_blk| {
133 let blk = ctx.sema.to_def(&impl_blk)?; 129 let blk = ctx.sema.to_def(&impl_blk)?;
134 130
135 // FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}` 131 // FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}`
@@ -157,10 +153,10 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Opti
157 Some(block) 153 Some(block)
158} 154}
159 155
160fn has_new_fn(imp: &ast::ImplDef) -> bool { 156fn has_new_fn(imp: &ast::Impl) -> bool {
161 if let Some(il) = imp.item_list() { 157 if let Some(il) = imp.assoc_item_list() {
162 for item in il.assoc_items() { 158 for item in il.assoc_items() {
163 if let ast::AssocItem::FnDef(f) = item { 159 if let ast::AssocItem::Fn(f) = item {
164 if let Some(name) = f.name() { 160 if let Some(name) = f.name() {
165 if name.text().eq_ignore_ascii_case("new") { 161 if name.text().eq_ignore_ascii_case("new") {
166 return true; 162 return true;
diff --git a/crates/ra_assists/src/handlers/inline_local_variable.rs b/crates/ra_assists/src/handlers/inline_local_variable.rs
index 2fdfabaf5..3c58020f8 100644
--- a/crates/ra_assists/src/handlers/inline_local_variable.rs
+++ b/crates/ra_assists/src/handlers/inline_local_variable.rs
@@ -29,7 +29,7 @@ use crate::{
29pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 29pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
30 let let_stmt = ctx.find_node_at_offset::<ast::LetStmt>()?; 30 let let_stmt = ctx.find_node_at_offset::<ast::LetStmt>()?;
31 let bind_pat = match let_stmt.pat()? { 31 let bind_pat = match let_stmt.pat()? {
32 ast::Pat::BindPat(pat) => pat, 32 ast::Pat::IdentPat(pat) => pat,
33 _ => return None, 33 _ => return None,
34 }; 34 };
35 if bind_pat.mut_token().is_some() { 35 if bind_pat.mut_token().is_some() {
diff --git a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs
index 967593031..fbaf3c06b 100644
--- a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs
+++ b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs
@@ -1,5 +1,5 @@
1use ra_syntax::{ 1use ra_syntax::{
2 ast::{self, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, 2 ast::{self, GenericParamsOwner, NameOwner},
3 AstNode, SyntaxKind, TextRange, TextSize, 3 AstNode, SyntaxKind, TextRange, TextSize,
4}; 4};
5use rustc_hash::FxHashSet; 5use rustc_hash::FxHashSet;
@@ -38,9 +38,9 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) -
38 let lifetime_token = ctx 38 let lifetime_token = ctx
39 .find_token_at_offset(SyntaxKind::LIFETIME) 39 .find_token_at_offset(SyntaxKind::LIFETIME)
40 .filter(|lifetime| lifetime.text() == "'_")?; 40 .filter(|lifetime| lifetime.text() == "'_")?;
41 if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::FnDef::cast) { 41 if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::Fn::cast) {
42 generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range()) 42 generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range())
43 } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::ImplDef::cast) { 43 } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::Impl::cast) {
44 generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range()) 44 generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range())
45 } else { 45 } else {
46 None 46 None
@@ -50,11 +50,11 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) -
50/// Generate the assist for the fn def case 50/// Generate the assist for the fn def case
51fn generate_fn_def_assist( 51fn generate_fn_def_assist(
52 acc: &mut Assists, 52 acc: &mut Assists,
53 fn_def: &ast::FnDef, 53 fn_def: &ast::Fn,
54 lifetime_loc: TextRange, 54 lifetime_loc: TextRange,
55) -> Option<()> { 55) -> Option<()> {
56 let param_list: ast::ParamList = fn_def.param_list()?; 56 let param_list: ast::ParamList = fn_def.param_list()?;
57 let new_lifetime_param = generate_unique_lifetime_param_name(&fn_def.type_param_list())?; 57 let new_lifetime_param = generate_unique_lifetime_param_name(&fn_def.generic_param_list())?;
58 let end_of_fn_ident = fn_def.name()?.ident_token()?.text_range().end(); 58 let end_of_fn_ident = fn_def.name()?.ident_token()?.text_range().end();
59 let self_param = 59 let self_param =
60 // use the self if it's a reference and has no explicit lifetime 60 // use the self if it's a reference and has no explicit lifetime
@@ -67,8 +67,8 @@ fn generate_fn_def_assist(
67 // otherwise, if there's a single reference parameter without a named liftime, use that 67 // otherwise, if there's a single reference parameter without a named liftime, use that
68 let fn_params_without_lifetime: Vec<_> = param_list 68 let fn_params_without_lifetime: Vec<_> = param_list
69 .params() 69 .params()
70 .filter_map(|param| match param.ascribed_type() { 70 .filter_map(|param| match param.ty() {
71 Some(ast::TypeRef::ReferenceType(ascribed_type)) 71 Some(ast::Type::RefType(ascribed_type))
72 if ascribed_type.lifetime_token() == None => 72 if ascribed_type.lifetime_token() == None =>
73 { 73 {
74 Some(ascribed_type.amp_token()?.text_range().end()) 74 Some(ascribed_type.amp_token()?.text_range().end())
@@ -93,10 +93,10 @@ fn generate_fn_def_assist(
93/// Generate the assist for the impl def case 93/// Generate the assist for the impl def case
94fn generate_impl_def_assist( 94fn generate_impl_def_assist(
95 acc: &mut Assists, 95 acc: &mut Assists,
96 impl_def: &ast::ImplDef, 96 impl_def: &ast::Impl,
97 lifetime_loc: TextRange, 97 lifetime_loc: TextRange,
98) -> Option<()> { 98) -> Option<()> {
99 let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.type_param_list())?; 99 let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.generic_param_list())?;
100 let end_of_impl_kw = impl_def.impl_token()?.text_range().end(); 100 let end_of_impl_kw = impl_def.impl_token()?.text_range().end();
101 acc.add(AssistId(ASSIST_NAME, AssistKind::Refactor), ASSIST_LABEL, lifetime_loc, |builder| { 101 acc.add(AssistId(ASSIST_NAME, AssistKind::Refactor), ASSIST_LABEL, lifetime_loc, |builder| {
102 add_lifetime_param(impl_def, builder, end_of_impl_kw, new_lifetime_param); 102 add_lifetime_param(impl_def, builder, end_of_impl_kw, new_lifetime_param);
@@ -107,7 +107,7 @@ fn generate_impl_def_assist(
107/// Given a type parameter list, generate a unique lifetime parameter name 107/// Given a type parameter list, generate a unique lifetime parameter name
108/// which is not in the list 108/// which is not in the list
109fn generate_unique_lifetime_param_name( 109fn generate_unique_lifetime_param_name(
110 existing_type_param_list: &Option<ast::TypeParamList>, 110 existing_type_param_list: &Option<ast::GenericParamList>,
111) -> Option<char> { 111) -> Option<char> {
112 match existing_type_param_list { 112 match existing_type_param_list {
113 Some(type_params) => { 113 Some(type_params) => {
@@ -123,13 +123,13 @@ fn generate_unique_lifetime_param_name(
123 123
124/// Add the lifetime param to `builder`. If there are type parameters in `type_params_owner`, add it to the end. Otherwise 124/// Add the lifetime param to `builder`. If there are type parameters in `type_params_owner`, add it to the end. Otherwise
125/// add new type params brackets with the lifetime parameter at `new_type_params_loc`. 125/// add new type params brackets with the lifetime parameter at `new_type_params_loc`.
126fn add_lifetime_param<TypeParamsOwner: ast::TypeParamsOwner>( 126fn add_lifetime_param<TypeParamsOwner: ast::GenericParamsOwner>(
127 type_params_owner: &TypeParamsOwner, 127 type_params_owner: &TypeParamsOwner,
128 builder: &mut AssistBuilder, 128 builder: &mut AssistBuilder,
129 new_type_params_loc: TextSize, 129 new_type_params_loc: TextSize,
130 new_lifetime_param: char, 130 new_lifetime_param: char,
131) { 131) {
132 match type_params_owner.type_param_list() { 132 match type_params_owner.generic_param_list() {
133 // add the new lifetime parameter to an existing type param list 133 // add the new lifetime parameter to an existing type param list
134 Some(type_params) => { 134 Some(type_params) => {
135 builder.insert( 135 builder.insert(
diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs
index 1beccb61c..c775fe25c 100644
--- a/crates/ra_assists/src/handlers/merge_imports.rs
+++ b/crates/ra_assists/src/handlers/merge_imports.rs
@@ -28,7 +28,7 @@ pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext) -> Option<()
28 let mut rewriter = SyntaxRewriter::default(); 28 let mut rewriter = SyntaxRewriter::default();
29 let mut offset = ctx.offset(); 29 let mut offset = ctx.offset();
30 30
31 if let Some(use_item) = tree.syntax().parent().and_then(ast::UseItem::cast) { 31 if let Some(use_item) = tree.syntax().parent().and_then(ast::Use::cast) {
32 let (merged, to_delete) = next_prev() 32 let (merged, to_delete) = next_prev()
33 .filter_map(|dir| neighbor(&use_item, dir)) 33 .filter_map(|dir| neighbor(&use_item, dir))
34 .filter_map(|it| Some((it.clone(), it.use_tree()?))) 34 .filter_map(|it| Some((it.clone(), it.use_tree()?)))
diff --git a/crates/ra_assists/src/handlers/merge_match_arms.rs b/crates/ra_assists/src/handlers/merge_match_arms.rs
index 186a1f618..563292282 100644
--- a/crates/ra_assists/src/handlers/merge_match_arms.rs
+++ b/crates/ra_assists/src/handlers/merge_match_arms.rs
@@ -86,7 +86,7 @@ pub(crate) fn merge_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option
86} 86}
87 87
88fn contains_placeholder(a: &ast::MatchArm) -> bool { 88fn contains_placeholder(a: &ast::MatchArm) -> bool {
89 matches!(a.pat(), Some(ast::Pat::PlaceholderPat(..))) 89 matches!(a.pat(), Some(ast::Pat::WildcardPat(..)))
90} 90}
91 91
92#[cfg(test)] 92#[cfg(test)]
diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs
index ba3dafb99..6d394443e 100644
--- a/crates/ra_assists/src/handlers/move_bounds.rs
+++ b/crates/ra_assists/src/handlers/move_bounds.rs
@@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
23// } 23// }
24// ``` 24// ```
25pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 25pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
26 let type_param_list = ctx.find_node_at_offset::<ast::TypeParamList>()?; 26 let type_param_list = ctx.find_node_at_offset::<ast::GenericParamList>()?;
27 27
28 let mut type_params = type_param_list.type_params(); 28 let mut type_params = type_param_list.type_params();
29 if type_params.all(|p| p.type_bound_list().is_none()) { 29 if type_params.all(|p| p.type_bound_list().is_none()) {
@@ -37,13 +37,13 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext
37 37
38 let anchor = match_ast! { 38 let anchor = match_ast! {
39 match parent { 39 match parent {
40 ast::FnDef(it) => it.body()?.syntax().clone().into(), 40 ast::Fn(it) => it.body()?.syntax().clone().into(),
41 ast::TraitDef(it) => it.item_list()?.syntax().clone().into(), 41 ast::Trait(it) => it.assoc_item_list()?.syntax().clone().into(),
42 ast::ImplDef(it) => it.item_list()?.syntax().clone().into(), 42 ast::Impl(it) => it.assoc_item_list()?.syntax().clone().into(),
43 ast::EnumDef(it) => it.variant_list()?.syntax().clone().into(), 43 ast::Enum(it) => it.variant_list()?.syntax().clone().into(),
44 ast::StructDef(it) => { 44 ast::Struct(it) => {
45 it.syntax().children_with_tokens() 45 it.syntax().children_with_tokens()
46 .find(|it| it.kind() == RECORD_FIELD_DEF_LIST || it.kind() == T![;])? 46 .find(|it| it.kind() == RECORD_FIELD_LIST || it.kind() == T![;])?
47 }, 47 },
48 _ => return None 48 _ => return None
49 } 49 }
diff --git a/crates/ra_assists/src/handlers/raw_string.rs b/crates/ra_assists/src/handlers/raw_string.rs
index 4e8a0c2db..4c797178f 100644
--- a/crates/ra_assists/src/handlers/raw_string.rs
+++ b/crates/ra_assists/src/handlers/raw_string.rs
@@ -173,7 +173,7 @@ fn test_required_hashes() {
173} 173}
174 174
175#[cfg(test)] 175#[cfg(test)]
176mod test { 176mod tests {
177 use test_utils::mark; 177 use test_utils::mark;
178 178
179 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; 179 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target};
diff --git a/crates/ra_assists/src/handlers/remove_dbg.rs b/crates/ra_assists/src/handlers/remove_dbg.rs
index a616cca57..9430ce1b5 100644
--- a/crates/ra_assists/src/handlers/remove_dbg.rs
+++ b/crates/ra_assists/src/handlers/remove_dbg.rs
@@ -1,6 +1,6 @@
1use ra_syntax::{ 1use ra_syntax::{
2 ast::{self, AstNode}, 2 ast::{self, AstNode},
3 TextSize, T, 3 TextRange, TextSize, T,
4}; 4};
5 5
6use crate::{AssistContext, AssistId, AssistKind, Assists}; 6use crate::{AssistContext, AssistId, AssistKind, Assists};
@@ -27,19 +27,33 @@ pub(crate) fn remove_dbg(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
27 return None; 27 return None;
28 } 28 }
29 29
30 let macro_range = macro_call.syntax().text_range(); 30 let is_leaf = macro_call.syntax().next_sibling().is_none();
31 31
32 let macro_content = { 32 let macro_end = if macro_call.semicolon_token().is_some() {
33 let macro_args = macro_call.token_tree()?.syntax().clone(); 33 macro_call.syntax().text_range().end() - TextSize::of(';')
34 } else {
35 macro_call.syntax().text_range().end()
36 };
34 37
35 let text = macro_args.text(); 38 // macro_range determines what will be deleted and replaced with macro_content
36 let without_parens = TextSize::of('(')..text.len() - TextSize::of(')'); 39 let macro_range = TextRange::new(macro_call.syntax().text_range().start(), macro_end);
37 text.slice(without_parens).to_string() 40 let paste_instead_of_dbg = {
41 let text = macro_call.token_tree()?.syntax().text();
42
43 // leafiness determines if we should include the parenthesis or not
44 let slice_index: TextRange = if is_leaf {
45 // leaf means - we can extract the contents of the dbg! in text
46 TextRange::new(TextSize::of('('), text.len() - TextSize::of(')'))
47 } else {
48 // not leaf - means we should keep the parens
49 TextRange::up_to(text.len())
50 };
51 text.slice(slice_index).to_string()
38 }; 52 };
39 53
40 let target = macro_call.syntax().text_range(); 54 let target = macro_call.syntax().text_range();
41 acc.add(AssistId("remove_dbg", AssistKind::Refactor), "Remove dbg!()", target, |builder| { 55 acc.add(AssistId("remove_dbg", AssistKind::Refactor), "Remove dbg!()", target, |builder| {
42 builder.replace(macro_range, macro_content); 56 builder.replace(macro_range, paste_instead_of_dbg);
43 }) 57 })
44} 58}
45 59
@@ -99,6 +113,7 @@ fn foo(n: usize) {
99", 113",
100 ); 114 );
101 } 115 }
116
102 #[test] 117 #[test]
103 fn test_remove_dbg_with_brackets_and_braces() { 118 fn test_remove_dbg_with_brackets_and_braces() {
104 check_assist(remove_dbg, "dbg![<|>1 + 1]", "1 + 1"); 119 check_assist(remove_dbg, "dbg![<|>1 + 1]", "1 + 1");
@@ -113,7 +128,7 @@ fn foo(n: usize) {
113 } 128 }
114 129
115 #[test] 130 #[test]
116 fn remove_dbg_target() { 131 fn test_remove_dbg_target() {
117 check_assist_target( 132 check_assist_target(
118 remove_dbg, 133 remove_dbg,
119 " 134 "
@@ -126,4 +141,65 @@ fn foo(n: usize) {
126 "dbg!(n.checked_sub(4))", 141 "dbg!(n.checked_sub(4))",
127 ); 142 );
128 } 143 }
144
145 #[test]
146 fn test_remove_dbg_keep_semicolon() {
147 // https://github.com/rust-analyzer/rust-analyzer/issues/5129#issuecomment-651399779
148 // not quite though
149 // adding a comment at the end of the line makes
150 // the ast::MacroCall to include the semicolon at the end
151 check_assist(
152 remove_dbg,
153 r#"let res = <|>dbg!(1 * 20); // needless comment"#,
154 r#"let res = 1 * 20; // needless comment"#,
155 );
156 }
157
158 #[test]
159 fn test_remove_dbg_keep_expression() {
160 check_assist(
161 remove_dbg,
162 r#"let res = <|>dbg!(a + b).foo();"#,
163 r#"let res = (a + b).foo();"#,
164 );
165 }
166
167 #[test]
168 fn test_remove_dbg_from_inside_fn() {
169 check_assist_target(
170 remove_dbg,
171 r#"
172fn square(x: u32) -> u32 {
173 x * x
174}
175
176fn main() {
177 let x = square(dbg<|>!(5 + 10));
178 println!("{}", x);
179}"#,
180 "dbg!(5 + 10)",
181 );
182
183 check_assist(
184 remove_dbg,
185 r#"
186fn square(x: u32) -> u32 {
187 x * x
188}
189
190fn main() {
191 let x = square(dbg<|>!(5 + 10));
192 println!("{}", x);
193}"#,
194 r#"
195fn square(x: u32) -> u32 {
196 x * x
197}
198
199fn main() {
200 let x = square(5 + 10);
201 println!("{}", x);
202}"#,
203 );
204 }
129} 205}
diff --git a/crates/ra_assists/src/handlers/reorder_fields.rs b/crates/ra_assists/src/handlers/reorder_fields.rs
index 2ac1c56cf..c9b743a06 100644
--- a/crates/ra_assists/src/handlers/reorder_fields.rs
+++ b/crates/ra_assists/src/handlers/reorder_fields.rs
@@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
23// ``` 23// ```
24// 24//
25pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 25pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
26 reorder::<ast::RecordLit>(acc, ctx).or_else(|| reorder::<ast::RecordPat>(acc, ctx)) 26 reorder::<ast::RecordExpr>(acc, ctx).or_else(|| reorder::<ast::RecordPat>(acc, ctx))
27} 27}
28 28
29fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 29fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
@@ -56,8 +56,8 @@ fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
56 56
57fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> { 57fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> {
58 match node.kind() { 58 match node.kind() {
59 RECORD_LIT => vec![RECORD_FIELD], 59 RECORD_EXPR => vec![RECORD_EXPR_FIELD],
60 RECORD_PAT => vec![RECORD_FIELD_PAT, BIND_PAT], 60 RECORD_PAT => vec![RECORD_PAT_FIELD, IDENT_PAT],
61 _ => vec![], 61 _ => vec![],
62 } 62 }
63} 63}
@@ -65,8 +65,8 @@ fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> {
65fn get_field_name(node: &SyntaxNode) -> String { 65fn get_field_name(node: &SyntaxNode) -> String {
66 let res = match_ast! { 66 let res = match_ast! {
67 match node { 67 match node {
68 ast::RecordField(field) => field.field_name().map(|it| it.to_string()), 68 ast::RecordExprField(field) => field.field_name().map(|it| it.to_string()),
69 ast::RecordFieldPat(field) => field.field_name().map(|it| it.to_string()), 69 ast::RecordPatField(field) => field.field_name().map(|it| it.to_string()),
70 _ => None, 70 _ => None,
71 } 71 }
72 }; 72 };
diff --git a/crates/ra_assists/src/handlers/replace_if_let_with_match.rs b/crates/ra_assists/src/handlers/replace_if_let_with_match.rs
index b7e30a7f2..ecafb74a1 100644
--- a/crates/ra_assists/src/handlers/replace_if_let_with_match.rs
+++ b/crates/ra_assists/src/handlers/replace_if_let_with_match.rs
@@ -65,7 +65,7 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext)
65 .type_of_pat(&pat) 65 .type_of_pat(&pat)
66 .and_then(|ty| TryEnum::from_ty(&ctx.sema, &ty)) 66 .and_then(|ty| TryEnum::from_ty(&ctx.sema, &ty))
67 .map(|it| it.sad_pattern()) 67 .map(|it| it.sad_pattern())
68 .unwrap_or_else(|| make::placeholder_pat().into()); 68 .unwrap_or_else(|| make::wildcard_pat().into());
69 let else_expr = unwrap_trivial_block(else_block); 69 let else_expr = unwrap_trivial_block(else_block);
70 make::match_arm(vec![pattern], else_expr) 70 make::match_arm(vec![pattern], else_expr)
71 }; 71 };
diff --git a/crates/ra_assists/src/handlers/replace_let_with_if_let.rs b/crates/ra_assists/src/handlers/replace_let_with_if_let.rs
index a49292c97..e4d436dec 100644
--- a/crates/ra_assists/src/handlers/replace_let_with_if_let.rs
+++ b/crates/ra_assists/src/handlers/replace_let_with_if_let.rs
@@ -50,10 +50,10 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext) ->
50 target, 50 target,
51 |edit| { 51 |edit| {
52 let with_placeholder: ast::Pat = match happy_variant { 52 let with_placeholder: ast::Pat = match happy_variant {
53 None => make::placeholder_pat().into(), 53 None => make::wildcard_pat().into(),
54 Some(var_name) => make::tuple_struct_pat( 54 Some(var_name) => make::tuple_struct_pat(
55 make::path_unqualified(make::path_segment(make::name_ref(var_name))), 55 make::path_unqualified(make::path_segment(make::name_ref(var_name))),
56 once(make::placeholder_pat().into()), 56 once(make::wildcard_pat().into()),
57 ) 57 )
58 .into(), 58 .into(),
59 }; 59 };
@@ -62,8 +62,7 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext) ->
62 let if_ = make::expr_if(make::condition(init, Some(with_placeholder)), block); 62 let if_ = make::expr_if(make::condition(init, Some(with_placeholder)), block);
63 let stmt = make::expr_stmt(if_); 63 let stmt = make::expr_stmt(if_);
64 64
65 let placeholder = 65 let placeholder = stmt.syntax().descendants().find_map(ast::WildcardPat::cast).unwrap();
66 stmt.syntax().descendants().find_map(ast::PlaceholderPat::cast).unwrap();
67 let stmt = stmt.replace_descendant(placeholder.into(), original_pat); 66 let stmt = stmt.replace_descendant(placeholder.into(), original_pat);
68 67
69 edit.replace_ast(ast::Stmt::from(let_stmt), ast::Stmt::from(stmt)); 68 edit.replace_ast(ast::Stmt::from(let_stmt), ast::Stmt::from(stmt));
diff --git a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs
index 3d51faa54..da0a860c5 100644
--- a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs
+++ b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs
@@ -25,7 +25,7 @@ pub(crate) fn replace_qualified_name_with_use(
25) -> Option<()> { 25) -> Option<()> {
26 let path: ast::Path = ctx.find_node_at_offset()?; 26 let path: ast::Path = ctx.find_node_at_offset()?;
27 // We don't want to mess with use statements 27 // We don't want to mess with use statements
28 if path.syntax().ancestors().find_map(ast::UseItem::cast).is_some() { 28 if path.syntax().ancestors().find_map(ast::Use::cast).is_some() {
29 return None; 29 return None;
30 } 30 }
31 31
@@ -85,7 +85,7 @@ fn shorten_paths(rewriter: &mut SyntaxRewriter<'static>, node: SyntaxNode, path:
85 match child { 85 match child {
86 // Don't modify `use` items, as this can break the `use` item when injecting a new 86 // Don't modify `use` items, as this can break the `use` item when injecting a new
87 // import into the use tree. 87 // import into the use tree.
88 ast::UseItem(_it) => continue, 88 ast::Use(_it) => continue,
89 // Don't descend into submodules, they don't have the same `use` items in scope. 89 // Don't descend into submodules, they don't have the same `use` items in scope.
90 ast::Module(_it) => continue, 90 ast::Module(_it) => continue,
91 91
@@ -643,4 +643,46 @@ fn main() {
643 ", 643 ",
644 ); 644 );
645 } 645 }
646
647 #[test]
648 fn does_not_replace_pub_use() {
649 check_assist(
650 replace_qualified_name_with_use,
651 r"
652pub use std::fmt;
653
654impl std::io<|> for Foo {
655}
656 ",
657 r"
658use std::io;
659
660pub use std::fmt;
661
662impl io for Foo {
663}
664 ",
665 );
666 }
667
668 #[test]
669 fn does_not_replace_pub_crate_use() {
670 check_assist(
671 replace_qualified_name_with_use,
672 r"
673pub(crate) use std::fmt;
674
675impl std::io<|> for Foo {
676}
677 ",
678 r"
679use std::io;
680
681pub(crate) use std::fmt;
682
683impl io for Foo {
684}
685 ",
686 );
687 }
646} 688}
diff --git a/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs b/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs
index e5a4bb23c..d69f2c1b0 100644
--- a/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs
+++ b/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs
@@ -52,7 +52,7 @@ pub(crate) fn replace_unwrap_with_match(acc: &mut Assists, ctx: &AssistContext)
52 target, 52 target,
53 |builder| { 53 |builder| {
54 let ok_path = make::path_unqualified(make::path_segment(make::name_ref(happy_variant))); 54 let ok_path = make::path_unqualified(make::path_segment(make::name_ref(happy_variant)));
55 let it = make::bind_pat(make::name("a")).into(); 55 let it = make::ident_pat(make::name("a")).into();
56 let ok_tuple = make::tuple_struct_pat(ok_path, iter::once(it)).into(); 56 let ok_tuple = make::tuple_struct_pat(ok_path, iter::once(it)).into();
57 57
58 let bind_path = make::path_unqualified(make::path_segment(make::name_ref("a"))); 58 let bind_path = make::path_unqualified(make::path_segment(make::name_ref("a")));
@@ -60,7 +60,7 @@ pub(crate) fn replace_unwrap_with_match(acc: &mut Assists, ctx: &AssistContext)
60 60
61 let unreachable_call = make::expr_unreachable(); 61 let unreachable_call = make::expr_unreachable();
62 let err_arm = 62 let err_arm =
63 make::match_arm(iter::once(make::placeholder_pat().into()), unreachable_call); 63 make::match_arm(iter::once(make::wildcard_pat().into()), unreachable_call);
64 64
65 let match_arm_list = make::match_arm_list(vec![ok_arm, err_arm]); 65 let match_arm_list = make::match_arm_list(vec![ok_arm, err_arm]);
66 let match_expr = make::expr_match(caller.clone(), match_arm_list) 66 let match_expr = make::expr_match(caller.clone(), match_arm_list)
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs
index 465b90415..507646cc8 100644
--- a/crates/ra_assists/src/lib.rs
+++ b/crates/ra_assists/src/lib.rs
@@ -140,6 +140,7 @@ mod handlers {
140 mod change_return_type_to_result; 140 mod change_return_type_to_result;
141 mod change_visibility; 141 mod change_visibility;
142 mod early_return; 142 mod early_return;
143 mod expand_glob_import;
143 mod extract_struct_from_enum_variant; 144 mod extract_struct_from_enum_variant;
144 mod extract_variable; 145 mod extract_variable;
145 mod fill_match_arms; 146 mod fill_match_arms;
@@ -181,6 +182,7 @@ mod handlers {
181 change_return_type_to_result::change_return_type_to_result, 182 change_return_type_to_result::change_return_type_to_result,
182 change_visibility::change_visibility, 183 change_visibility::change_visibility,
183 early_return::convert_to_guarded_return, 184 early_return::convert_to_guarded_return,
185 expand_glob_import::expand_glob_import,
184 extract_struct_from_enum_variant::extract_struct_from_enum_variant, 186 extract_struct_from_enum_variant::extract_struct_from_enum_variant,
185 extract_variable::extract_variable, 187 extract_variable::extract_variable,
186 fill_match_arms::fill_match_arms, 188 fill_match_arms::fill_match_arms,
diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs
index eff7feded..97978e7a2 100644
--- a/crates/ra_assists/src/tests/generated.rs
+++ b/crates/ra_assists/src/tests/generated.rs
@@ -229,6 +229,33 @@ fn main() {
229} 229}
230 230
231#[test] 231#[test]
232fn doctest_expand_glob_import() {
233 check_doc_test(
234 "expand_glob_import",
235 r#####"
236mod foo {
237 pub struct Bar;
238 pub struct Baz;
239}
240
241use foo::*<|>;
242
243fn qux(bar: Bar, baz: Baz) {}
244"#####,
245 r#####"
246mod foo {
247 pub struct Bar;
248 pub struct Baz;
249}
250
251use foo::{Baz, Bar};
252
253fn qux(bar: Bar, baz: Baz) {}
254"#####,
255 )
256}
257
258#[test]
232fn doctest_extract_struct_from_enum_variant() { 259fn doctest_extract_struct_from_enum_variant() {
233 check_doc_test( 260 check_doc_test(
234 "extract_struct_from_enum_variant", 261 "extract_struct_from_enum_variant",
diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs
index 02de902d6..54d5678d1 100644
--- a/crates/ra_assists/src/utils.rs
+++ b/crates/ra_assists/src/utils.rs
@@ -56,33 +56,34 @@ pub(crate) fn render_snippet(_cap: SnippetCap, node: &SyntaxNode, cursor: Cursor
56 56
57pub fn get_missing_assoc_items( 57pub fn get_missing_assoc_items(
58 sema: &Semantics<RootDatabase>, 58 sema: &Semantics<RootDatabase>,
59 impl_def: &ast::ImplDef, 59 impl_def: &ast::Impl,
60) -> Vec<hir::AssocItem> { 60) -> Vec<hir::AssocItem> {
61 // Names must be unique between constants and functions. However, type aliases 61 // Names must be unique between constants and functions. However, type aliases
62 // may share the same name as a function or constant. 62 // may share the same name as a function or constant.
63 let mut impl_fns_consts = FxHashSet::default(); 63 let mut impl_fns_consts = FxHashSet::default();
64 let mut impl_type = FxHashSet::default(); 64 let mut impl_type = FxHashSet::default();
65 65
66 if let Some(item_list) = impl_def.item_list() { 66 if let Some(item_list) = impl_def.assoc_item_list() {
67 for item in item_list.assoc_items() { 67 for item in item_list.assoc_items() {
68 match item { 68 match item {
69 ast::AssocItem::FnDef(f) => { 69 ast::AssocItem::Fn(f) => {
70 if let Some(n) = f.name() { 70 if let Some(n) = f.name() {
71 impl_fns_consts.insert(n.syntax().to_string()); 71 impl_fns_consts.insert(n.syntax().to_string());
72 } 72 }
73 } 73 }
74 74
75 ast::AssocItem::TypeAliasDef(t) => { 75 ast::AssocItem::TypeAlias(t) => {
76 if let Some(n) = t.name() { 76 if let Some(n) = t.name() {
77 impl_type.insert(n.syntax().to_string()); 77 impl_type.insert(n.syntax().to_string());
78 } 78 }
79 } 79 }
80 80
81 ast::AssocItem::ConstDef(c) => { 81 ast::AssocItem::Const(c) => {
82 if let Some(n) = c.name() { 82 if let Some(n) = c.name() {
83 impl_fns_consts.insert(n.syntax().to_string()); 83 impl_fns_consts.insert(n.syntax().to_string());
84 } 84 }
85 } 85 }
86 ast::AssocItem::MacroCall(_) => (),
86 } 87 }
87 } 88 }
88 } 89 }
@@ -108,13 +109,10 @@ pub fn get_missing_assoc_items(
108 109
109pub(crate) fn resolve_target_trait( 110pub(crate) fn resolve_target_trait(
110 sema: &Semantics<RootDatabase>, 111 sema: &Semantics<RootDatabase>,
111 impl_def: &ast::ImplDef, 112 impl_def: &ast::Impl,
112) -> Option<hir::Trait> { 113) -> Option<hir::Trait> {
113 let ast_path = impl_def 114 let ast_path =
114 .target_trait() 115 impl_def.trait_().map(|it| it.syntax().clone()).and_then(ast::PathType::cast)?.path()?;
115 .map(|it| it.syntax().clone())
116 .and_then(ast::PathType::cast)?
117 .path()?;
118 116
119 match sema.resolve_path(&ast_path) { 117 match sema.resolve_path(&ast_path) {
120 Some(hir::PathResolution::Def(hir::ModuleDef::Trait(def))) => Some(def), 118 Some(hir::PathResolution::Def(hir::ModuleDef::Trait(def))) => Some(def),
@@ -183,10 +181,10 @@ impl TryEnum {
183 match self { 181 match self {
184 TryEnum::Result => make::tuple_struct_pat( 182 TryEnum::Result => make::tuple_struct_pat(
185 make::path_unqualified(make::path_segment(make::name_ref("Err"))), 183 make::path_unqualified(make::path_segment(make::name_ref("Err"))),
186 iter::once(make::placeholder_pat().into()), 184 iter::once(make::wildcard_pat().into()),
187 ) 185 )
188 .into(), 186 .into(),
189 TryEnum::Option => make::bind_pat(make::name("None")).into(), 187 TryEnum::Option => make::ident_pat(make::name("None")).into(),
190 } 188 }
191 } 189 }
192 190
diff --git a/crates/ra_assists/src/utils/insert_use.rs b/crates/ra_assists/src/utils/insert_use.rs
index 8c4f33e59..32780fceb 100644
--- a/crates/ra_assists/src/utils/insert_use.rs
+++ b/crates/ra_assists/src/utils/insert_use.rs
@@ -4,7 +4,7 @@
4 4
5use hir::{self, ModPath}; 5use hir::{self, ModPath};
6use ra_syntax::{ 6use ra_syntax::{
7 ast::{self, NameOwner}, 7 ast::{self, NameOwner, VisibilityOwner},
8 AstNode, Direction, SmolStr, 8 AstNode, Direction, SmolStr,
9 SyntaxKind::{PATH, PATH_SEGMENT}, 9 SyntaxKind::{PATH, PATH_SEGMENT},
10 SyntaxNode, T, 10 SyntaxNode, T,
@@ -215,7 +215,7 @@ fn walk_use_tree_for_best_action(
215 let prev_len = current_path_segments.len(); 215 let prev_len = current_path_segments.len();
216 216
217 let tree_list = current_use_tree.use_tree_list(); 217 let tree_list = current_use_tree.use_tree_list();
218 let alias = current_use_tree.alias(); 218 let alias = current_use_tree.rename();
219 219
220 let path = match current_use_tree.path() { 220 let path = match current_use_tree.path() {
221 Some(path) => path, 221 Some(path) => path,
@@ -225,7 +225,7 @@ fn walk_use_tree_for_best_action(
225 current_use_tree 225 current_use_tree
226 .syntax() 226 .syntax()
227 .ancestors() 227 .ancestors()
228 .find_map(ast::UseItem::cast) 228 .find_map(ast::Use::cast)
229 .map(|it| it.syntax().clone()), 229 .map(|it| it.syntax().clone()),
230 true, 230 true,
231 ); 231 );
@@ -254,7 +254,7 @@ fn walk_use_tree_for_best_action(
254 current_use_tree 254 current_use_tree
255 .syntax() 255 .syntax()
256 .ancestors() 256 .ancestors()
257 .find_map(ast::UseItem::cast) 257 .find_map(ast::Use::cast)
258 .map(|it| it.syntax().clone()), 258 .map(|it| it.syntax().clone()),
259 true, 259 true,
260 ), 260 ),
@@ -304,7 +304,7 @@ fn walk_use_tree_for_best_action(
304 current_use_tree 304 current_use_tree
305 .syntax() 305 .syntax()
306 .ancestors() 306 .ancestors()
307 .find_map(ast::UseItem::cast) 307 .find_map(ast::Use::cast)
308 .map(|it| it.syntax().clone()), 308 .map(|it| it.syntax().clone()),
309 true, 309 true,
310 ); 310 );
@@ -377,7 +377,8 @@ fn best_action_for_target(
377 let mut storage = Vec::with_capacity(16); // this should be the only allocation 377 let mut storage = Vec::with_capacity(16); // this should be the only allocation
378 let best_action = container 378 let best_action = container
379 .children() 379 .children()
380 .filter_map(ast::UseItem::cast) 380 .filter_map(ast::Use::cast)
381 .filter(|u| u.visibility().is_none())
381 .filter_map(|it| it.use_tree()) 382 .filter_map(|it| it.use_tree())
382 .map(|u| walk_use_tree_for_best_action(&mut storage, None, u, target)) 383 .map(|u| walk_use_tree_for_best_action(&mut storage, None, u, target))
383 .fold(None, |best, a| match best { 384 .fold(None, |best, a| match best {
diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml
index 5f334d04f..fe73dc015 100644
--- a/crates/ra_db/Cargo.toml
+++ b/crates/ra_db/Cargo.toml
@@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
9doctest = false 9doctest = false
10 10
11[dependencies] 11[dependencies]
12salsa = "0.15.0" 12salsa = "0.15.2"
13rustc-hash = "1.1.0" 13rustc-hash = "1.1.0"
14 14
15ra_syntax = { path = "../ra_syntax" } 15ra_syntax = { path = "../ra_syntax" }
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 859bdfb3b..27cdabea0 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -361,8 +361,8 @@ pub struct Field {
361 361
362#[derive(Debug, PartialEq, Eq)] 362#[derive(Debug, PartialEq, Eq)]
363pub enum FieldSource { 363pub enum FieldSource {
364 Named(ast::RecordFieldDef), 364 Named(ast::RecordField),
365 Pos(ast::TupleFieldDef), 365 Pos(ast::TupleField),
366} 366}
367 367
368impl Field { 368impl Field {
@@ -1002,7 +1002,7 @@ impl Local {
1002 Type::new(db, krate, def, ty) 1002 Type::new(db, krate, def, ty)
1003 } 1003 }
1004 1004
1005 pub fn source(self, db: &dyn HirDatabase) -> InFile<Either<ast::BindPat, ast::SelfParam>> { 1005 pub fn source(self, db: &dyn HirDatabase) -> InFile<Either<ast::IdentPat, ast::SelfParam>> {
1006 let (_body, source_map) = db.body_with_source_map(self.parent.into()); 1006 let (_body, source_map) = db.body_with_source_map(self.parent.into());
1007 let src = source_map.pat_syntax(self.pat_id).unwrap(); // Hmm... 1007 let src = source_map.pat_syntax(self.pat_id).unwrap(); // Hmm...
1008 let root = src.file_syntax(db.upcast()); 1008 let root = src.file_syntax(db.upcast());
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index a2b9f3e35..07333c453 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -13,14 +13,7 @@ pub use hir_expand::db::{
13 AstDatabase, AstDatabaseStorage, AstIdMapQuery, InternEagerExpansionQuery, InternMacroQuery, 13 AstDatabase, AstDatabaseStorage, AstIdMapQuery, InternEagerExpansionQuery, InternMacroQuery,
14 MacroArgTextQuery, MacroDefQuery, MacroExpandQuery, ParseMacroQuery, 14 MacroArgTextQuery, MacroDefQuery, MacroExpandQuery, ParseMacroQuery,
15}; 15};
16pub use hir_ty::db::{ 16pub use hir_ty::db::*;
17 AssociatedTyDataQuery, AssociatedTyValueQuery, CallableItemSignatureQuery, FieldTypesQuery,
18 GenericDefaultsQuery, GenericPredicatesForParamQuery, GenericPredicatesQuery, HirDatabase,
19 HirDatabaseStorage, ImplDatumQuery, ImplSelfTyQuery, ImplTraitQuery, InferQueryQuery,
20 InherentImplsInCrateQuery, InternTypeParamIdQuery, ReturnTypeImplTraitsQuery, StructDatumQuery,
21 TraitDatumQuery, TraitImplsInCrateQuery, TraitImplsInDepsQuery, TraitSolveQuery, TyQuery,
22 ValueTyQuery,
23};
24 17
25#[test] 18#[test]
26fn hir_database_is_object_safe() { 19fn hir_database_is_object_safe() {
diff --git a/crates/ra_hir/src/has_source.rs b/crates/ra_hir/src/has_source.rs
index 4fd675039..db9228d67 100644
--- a/crates/ra_hir/src/has_source.rs
+++ b/crates/ra_hir/src/has_source.rs
@@ -57,56 +57,56 @@ impl HasSource for Field {
57 } 57 }
58} 58}
59impl HasSource for Struct { 59impl HasSource for Struct {
60 type Ast = ast::StructDef; 60 type Ast = ast::Struct;
61 fn source(self, db: &dyn HirDatabase) -> InFile<ast::StructDef> { 61 fn source(self, db: &dyn HirDatabase) -> InFile<ast::Struct> {
62 self.id.lookup(db.upcast()).source(db.upcast()) 62 self.id.lookup(db.upcast()).source(db.upcast())
63 } 63 }
64} 64}
65impl HasSource for Union { 65impl HasSource for Union {
66 type Ast = ast::UnionDef; 66 type Ast = ast::Union;
67 fn source(self, db: &dyn HirDatabase) -> InFile<ast::UnionDef> { 67 fn source(self, db: &dyn HirDatabase) -> InFile<ast::Union> {
68 self.id.lookup(db.upcast()).source(db.upcast()) 68 self.id.lookup(db.upcast()).source(db.upcast())
69 } 69 }
70} 70}
71impl HasSource for Enum { 71impl HasSource for Enum {
72 type Ast = ast::EnumDef; 72 type Ast = ast::Enum;
73 fn source(self, db: &dyn HirDatabase) -> InFile<ast::EnumDef> { 73 fn source(self, db: &dyn HirDatabase) -> InFile<ast::Enum> {
74 self.id.lookup(db.upcast()).source(db.upcast()) 74 self.id.lookup(db.upcast()).source(db.upcast())
75 } 75 }
76} 76}
77impl HasSource for EnumVariant { 77impl HasSource for EnumVariant {
78 type Ast = ast::EnumVariant; 78 type Ast = ast::Variant;
79 fn source(self, db: &dyn HirDatabase) -> InFile<ast::EnumVariant> { 79 fn source(self, db: &dyn HirDatabase) -> InFile<ast::Variant> {
80 self.parent.id.child_source(db.upcast()).map(|map| map[self.id].clone()) 80 self.parent.id.child_source(db.upcast()).map(|map| map[self.id].clone())
81 } 81 }
82} 82}
83impl HasSource for Function { 83impl HasSource for Function {
84 type Ast = ast::FnDef; 84 type Ast = ast::Fn;
85 fn source(self, db: &dyn HirDatabase) -> InFile<ast::FnDef> { 85 fn source(self, db: &dyn HirDatabase) -> InFile<ast::Fn> {
86 self.id.lookup(db.upcast()).source(db.upcast()) 86 self.id.lookup(db.upcast()).source(db.upcast())
87 } 87 }
88} 88}
89impl HasSource for Const { 89impl HasSource for Const {
90 type Ast = ast::ConstDef; 90 type Ast = ast::Const;
91 fn source(self, db: &dyn HirDatabase) -> InFile<ast::ConstDef> { 91 fn source(self, db: &dyn HirDatabase) -> InFile<ast::Const> {
92 self.id.lookup(db.upcast()).source(db.upcast()) 92 self.id.lookup(db.upcast()).source(db.upcast())
93 } 93 }
94} 94}
95impl HasSource for Static { 95impl HasSource for Static {
96 type Ast = ast::StaticDef; 96 type Ast = ast::Static;
97 fn source(self, db: &dyn HirDatabase) -> InFile<ast::StaticDef> { 97 fn source(self, db: &dyn HirDatabase) -> InFile<ast::Static> {
98 self.id.lookup(db.upcast()).source(db.upcast()) 98 self.id.lookup(db.upcast()).source(db.upcast())
99 } 99 }
100} 100}
101impl HasSource for Trait { 101impl HasSource for Trait {
102 type Ast = ast::TraitDef; 102 type Ast = ast::Trait;
103 fn source(self, db: &dyn HirDatabase) -> InFile<ast::TraitDef> { 103 fn source(self, db: &dyn HirDatabase) -> InFile<ast::Trait> {
104 self.id.lookup(db.upcast()).source(db.upcast()) 104 self.id.lookup(db.upcast()).source(db.upcast())
105 } 105 }
106} 106}
107impl HasSource for TypeAlias { 107impl HasSource for TypeAlias {
108 type Ast = ast::TypeAliasDef; 108 type Ast = ast::TypeAlias;
109 fn source(self, db: &dyn HirDatabase) -> InFile<ast::TypeAliasDef> { 109 fn source(self, db: &dyn HirDatabase) -> InFile<ast::TypeAlias> {
110 self.id.lookup(db.upcast()).source(db.upcast()) 110 self.id.lookup(db.upcast()).source(db.upcast())
111 } 111 }
112} 112}
@@ -120,14 +120,14 @@ impl HasSource for MacroDef {
120 } 120 }
121} 121}
122impl HasSource for ImplDef { 122impl HasSource for ImplDef {
123 type Ast = ast::ImplDef; 123 type Ast = ast::Impl;
124 fn source(self, db: &dyn HirDatabase) -> InFile<ast::ImplDef> { 124 fn source(self, db: &dyn HirDatabase) -> InFile<ast::Impl> {
125 self.id.lookup(db.upcast()).source(db.upcast()) 125 self.id.lookup(db.upcast()).source(db.upcast())
126 } 126 }
127} 127}
128 128
129impl HasSource for TypeParam { 129impl HasSource for TypeParam {
130 type Ast = Either<ast::TraitDef, ast::TypeParam>; 130 type Ast = Either<ast::Trait, ast::TypeParam>;
131 fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> { 131 fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> {
132 let child_source = self.id.parent.child_source(db.upcast()); 132 let child_source = self.id.parent.child_source(db.upcast());
133 child_source.map(|it| it[self.id.local_id].clone()) 133 child_source.map(|it| it[self.id.local_id].clone())
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs
index 1436b1afe..307b336f2 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/ra_hir/src/semantics.rs
@@ -209,11 +209,14 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
209 self.imp.resolve_field(field) 209 self.imp.resolve_field(field)
210 } 210 }
211 211
212 pub fn resolve_record_field(&self, field: &ast::RecordField) -> Option<(Field, Option<Local>)> { 212 pub fn resolve_record_field(
213 &self,
214 field: &ast::RecordExprField,
215 ) -> Option<(Field, Option<Local>)> {
213 self.imp.resolve_record_field(field) 216 self.imp.resolve_record_field(field)
214 } 217 }
215 218
216 pub fn resolve_record_field_pat(&self, field: &ast::RecordFieldPat) -> Option<Field> { 219 pub fn resolve_record_field_pat(&self, field: &ast::RecordPatField) -> Option<Field> {
217 self.imp.resolve_record_field_pat(field) 220 self.imp.resolve_record_field_pat(field)
218 } 221 }
219 222
@@ -225,7 +228,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
225 self.imp.resolve_path(path) 228 self.imp.resolve_path(path)
226 } 229 }
227 230
228 pub fn resolve_variant(&self, record_lit: ast::RecordLit) -> Option<VariantDef> { 231 pub fn resolve_variant(&self, record_lit: ast::RecordExpr) -> Option<VariantDef> {
229 self.imp.resolve_variant(record_lit).map(VariantDef::from) 232 self.imp.resolve_variant(record_lit).map(VariantDef::from)
230 } 233 }
231 234
@@ -233,14 +236,14 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
233 self.imp.lower_path(path) 236 self.imp.lower_path(path)
234 } 237 }
235 238
236 pub fn resolve_bind_pat_to_const(&self, pat: &ast::BindPat) -> Option<ModuleDef> { 239 pub fn resolve_bind_pat_to_const(&self, pat: &ast::IdentPat) -> Option<ModuleDef> {
237 self.imp.resolve_bind_pat_to_const(pat) 240 self.imp.resolve_bind_pat_to_const(pat)
238 } 241 }
239 242
240 // FIXME: use this instead? 243 // FIXME: use this instead?
241 // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>; 244 // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>;
242 245
243 pub fn record_literal_missing_fields(&self, literal: &ast::RecordLit) -> Vec<(Field, Type)> { 246 pub fn record_literal_missing_fields(&self, literal: &ast::RecordExpr) -> Vec<(Field, Type)> {
244 self.imp.record_literal_missing_fields(literal) 247 self.imp.record_literal_missing_fields(literal)
245 } 248 }
246 249
@@ -422,11 +425,11 @@ impl<'db> SemanticsImpl<'db> {
422 self.analyze(field.syntax()).resolve_field(self.db, field) 425 self.analyze(field.syntax()).resolve_field(self.db, field)
423 } 426 }
424 427
425 fn resolve_record_field(&self, field: &ast::RecordField) -> Option<(Field, Option<Local>)> { 428 fn resolve_record_field(&self, field: &ast::RecordExprField) -> Option<(Field, Option<Local>)> {
426 self.analyze(field.syntax()).resolve_record_field(self.db, field) 429 self.analyze(field.syntax()).resolve_record_field(self.db, field)
427 } 430 }
428 431
429 fn resolve_record_field_pat(&self, field: &ast::RecordFieldPat) -> Option<Field> { 432 fn resolve_record_field_pat(&self, field: &ast::RecordPatField) -> Option<Field> {
430 self.analyze(field.syntax()).resolve_record_field_pat(self.db, field) 433 self.analyze(field.syntax()).resolve_record_field_pat(self.db, field)
431 } 434 }
432 435
@@ -440,7 +443,7 @@ impl<'db> SemanticsImpl<'db> {
440 self.analyze(path.syntax()).resolve_path(self.db, path) 443 self.analyze(path.syntax()).resolve_path(self.db, path)
441 } 444 }
442 445
443 fn resolve_variant(&self, record_lit: ast::RecordLit) -> Option<VariantId> { 446 fn resolve_variant(&self, record_lit: ast::RecordExpr) -> Option<VariantId> {
444 self.analyze(record_lit.syntax()).resolve_variant(self.db, record_lit) 447 self.analyze(record_lit.syntax()).resolve_variant(self.db, record_lit)
445 } 448 }
446 449
@@ -449,11 +452,11 @@ impl<'db> SemanticsImpl<'db> {
449 Path::from_src(path.clone(), &Hygiene::new(self.db.upcast(), src.file_id.into())) 452 Path::from_src(path.clone(), &Hygiene::new(self.db.upcast(), src.file_id.into()))
450 } 453 }
451 454
452 fn resolve_bind_pat_to_const(&self, pat: &ast::BindPat) -> Option<ModuleDef> { 455 fn resolve_bind_pat_to_const(&self, pat: &ast::IdentPat) -> Option<ModuleDef> {
453 self.analyze(pat.syntax()).resolve_bind_pat_to_const(self.db, pat) 456 self.analyze(pat.syntax()).resolve_bind_pat_to_const(self.db, pat)
454 } 457 }
455 458
456 fn record_literal_missing_fields(&self, literal: &ast::RecordLit) -> Vec<(Field, Type)> { 459 fn record_literal_missing_fields(&self, literal: &ast::RecordExpr) -> Vec<(Field, Type)> {
457 self.analyze(literal.syntax()) 460 self.analyze(literal.syntax())
458 .record_literal_missing_fields(self.db, literal) 461 .record_literal_missing_fields(self.db, literal)
459 .unwrap_or_default() 462 .unwrap_or_default()
@@ -577,21 +580,21 @@ macro_rules! to_def_impls {
577 580
578to_def_impls![ 581to_def_impls![
579 (crate::Module, ast::Module, module_to_def), 582 (crate::Module, ast::Module, module_to_def),
580 (crate::Struct, ast::StructDef, struct_to_def), 583 (crate::Struct, ast::Struct, struct_to_def),
581 (crate::Enum, ast::EnumDef, enum_to_def), 584 (crate::Enum, ast::Enum, enum_to_def),
582 (crate::Union, ast::UnionDef, union_to_def), 585 (crate::Union, ast::Union, union_to_def),
583 (crate::Trait, ast::TraitDef, trait_to_def), 586 (crate::Trait, ast::Trait, trait_to_def),
584 (crate::ImplDef, ast::ImplDef, impl_to_def), 587 (crate::ImplDef, ast::Impl, impl_to_def),
585 (crate::TypeAlias, ast::TypeAliasDef, type_alias_to_def), 588 (crate::TypeAlias, ast::TypeAlias, type_alias_to_def),
586 (crate::Const, ast::ConstDef, const_to_def), 589 (crate::Const, ast::Const, const_to_def),
587 (crate::Static, ast::StaticDef, static_to_def), 590 (crate::Static, ast::Static, static_to_def),
588 (crate::Function, ast::FnDef, fn_to_def), 591 (crate::Function, ast::Fn, fn_to_def),
589 (crate::Field, ast::RecordFieldDef, record_field_to_def), 592 (crate::Field, ast::RecordField, record_field_to_def),
590 (crate::Field, ast::TupleFieldDef, tuple_field_to_def), 593 (crate::Field, ast::TupleField, tuple_field_to_def),
591 (crate::EnumVariant, ast::EnumVariant, enum_variant_to_def), 594 (crate::EnumVariant, ast::Variant, enum_variant_to_def),
592 (crate::TypeParam, ast::TypeParam, type_param_to_def), 595 (crate::TypeParam, ast::TypeParam, type_param_to_def),
593 (crate::MacroDef, ast::MacroCall, macro_call_to_def), // this one is dubious, not all calls are macros 596 (crate::MacroDef, ast::MacroCall, macro_call_to_def), // this one is dubious, not all calls are macros
594 (crate::Local, ast::BindPat, bind_pat_to_def), 597 (crate::Local, ast::IdentPat, bind_pat_to_def),
595]; 598];
596 599
597fn find_root(node: &SyntaxNode) -> SyntaxNode { 600fn find_root(node: &SyntaxNode) -> SyntaxNode {
diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs
index 42e5a1bdb..863e8e5ff 100644
--- a/crates/ra_hir/src/semantics/source_to_def.rs
+++ b/crates/ra_hir/src/semantics/source_to_def.rs
@@ -65,57 +65,48 @@ impl SourceToDefCtx<'_, '_> {
65 Some(ModuleId { krate: parent_module.krate, local_id: child_id }) 65 Some(ModuleId { krate: parent_module.krate, local_id: child_id })
66 } 66 }
67 67
68 pub(super) fn trait_to_def(&mut self, src: InFile<ast::TraitDef>) -> Option<TraitId> { 68 pub(super) fn trait_to_def(&mut self, src: InFile<ast::Trait>) -> Option<TraitId> {
69 self.to_def(src, keys::TRAIT) 69 self.to_def(src, keys::TRAIT)
70 } 70 }
71 pub(super) fn impl_to_def(&mut self, src: InFile<ast::ImplDef>) -> Option<ImplId> { 71 pub(super) fn impl_to_def(&mut self, src: InFile<ast::Impl>) -> Option<ImplId> {
72 self.to_def(src, keys::IMPL) 72 self.to_def(src, keys::IMPL)
73 } 73 }
74 pub(super) fn fn_to_def(&mut self, src: InFile<ast::FnDef>) -> Option<FunctionId> { 74 pub(super) fn fn_to_def(&mut self, src: InFile<ast::Fn>) -> Option<FunctionId> {
75 self.to_def(src, keys::FUNCTION) 75 self.to_def(src, keys::FUNCTION)
76 } 76 }
77 pub(super) fn struct_to_def(&mut self, src: InFile<ast::StructDef>) -> Option<StructId> { 77 pub(super) fn struct_to_def(&mut self, src: InFile<ast::Struct>) -> Option<StructId> {
78 self.to_def(src, keys::STRUCT) 78 self.to_def(src, keys::STRUCT)
79 } 79 }
80 pub(super) fn enum_to_def(&mut self, src: InFile<ast::EnumDef>) -> Option<EnumId> { 80 pub(super) fn enum_to_def(&mut self, src: InFile<ast::Enum>) -> Option<EnumId> {
81 self.to_def(src, keys::ENUM) 81 self.to_def(src, keys::ENUM)
82 } 82 }
83 pub(super) fn union_to_def(&mut self, src: InFile<ast::UnionDef>) -> Option<UnionId> { 83 pub(super) fn union_to_def(&mut self, src: InFile<ast::Union>) -> Option<UnionId> {
84 self.to_def(src, keys::UNION) 84 self.to_def(src, keys::UNION)
85 } 85 }
86 pub(super) fn static_to_def(&mut self, src: InFile<ast::StaticDef>) -> Option<StaticId> { 86 pub(super) fn static_to_def(&mut self, src: InFile<ast::Static>) -> Option<StaticId> {
87 self.to_def(src, keys::STATIC) 87 self.to_def(src, keys::STATIC)
88 } 88 }
89 pub(super) fn const_to_def(&mut self, src: InFile<ast::ConstDef>) -> Option<ConstId> { 89 pub(super) fn const_to_def(&mut self, src: InFile<ast::Const>) -> Option<ConstId> {
90 self.to_def(src, keys::CONST) 90 self.to_def(src, keys::CONST)
91 } 91 }
92 pub(super) fn type_alias_to_def( 92 pub(super) fn type_alias_to_def(&mut self, src: InFile<ast::TypeAlias>) -> Option<TypeAliasId> {
93 &mut self,
94 src: InFile<ast::TypeAliasDef>,
95 ) -> Option<TypeAliasId> {
96 self.to_def(src, keys::TYPE_ALIAS) 93 self.to_def(src, keys::TYPE_ALIAS)
97 } 94 }
98 pub(super) fn record_field_to_def( 95 pub(super) fn record_field_to_def(&mut self, src: InFile<ast::RecordField>) -> Option<FieldId> {
99 &mut self,
100 src: InFile<ast::RecordFieldDef>,
101 ) -> Option<FieldId> {
102 self.to_def(src, keys::RECORD_FIELD) 96 self.to_def(src, keys::RECORD_FIELD)
103 } 97 }
104 pub(super) fn tuple_field_to_def( 98 pub(super) fn tuple_field_to_def(&mut self, src: InFile<ast::TupleField>) -> Option<FieldId> {
105 &mut self,
106 src: InFile<ast::TupleFieldDef>,
107 ) -> Option<FieldId> {
108 self.to_def(src, keys::TUPLE_FIELD) 99 self.to_def(src, keys::TUPLE_FIELD)
109 } 100 }
110 pub(super) fn enum_variant_to_def( 101 pub(super) fn enum_variant_to_def(
111 &mut self, 102 &mut self,
112 src: InFile<ast::EnumVariant>, 103 src: InFile<ast::Variant>,
113 ) -> Option<EnumVariantId> { 104 ) -> Option<EnumVariantId> {
114 self.to_def(src, keys::ENUM_VARIANT) 105 self.to_def(src, keys::VARIANT)
115 } 106 }
116 pub(super) fn bind_pat_to_def( 107 pub(super) fn bind_pat_to_def(
117 &mut self, 108 &mut self,
118 src: InFile<ast::BindPat>, 109 src: InFile<ast::IdentPat>,
119 ) -> Option<(DefWithBodyId, PatId)> { 110 ) -> Option<(DefWithBodyId, PatId)> {
120 let container = self.find_pat_container(src.as_ref().map(|it| it.syntax()))?; 111 let container = self.find_pat_container(src.as_ref().map(|it| it.syntax()))?;
121 let (_body, source_map) = self.db.body_with_source_map(container); 112 let (_body, source_map) = self.db.body_with_source_map(container);
@@ -163,39 +154,39 @@ impl SourceToDefCtx<'_, '_> {
163 let def = self.module_to_def(container.with_value(it))?; 154 let def = self.module_to_def(container.with_value(it))?;
164 def.into() 155 def.into()
165 }, 156 },
166 ast::TraitDef(it) => { 157 ast::Trait(it) => {
167 let def = self.trait_to_def(container.with_value(it))?; 158 let def = self.trait_to_def(container.with_value(it))?;
168 def.into() 159 def.into()
169 }, 160 },
170 ast::ImplDef(it) => { 161 ast::Impl(it) => {
171 let def = self.impl_to_def(container.with_value(it))?; 162 let def = self.impl_to_def(container.with_value(it))?;
172 def.into() 163 def.into()
173 }, 164 },
174 ast::FnDef(it) => { 165 ast::Fn(it) => {
175 let def = self.fn_to_def(container.with_value(it))?; 166 let def = self.fn_to_def(container.with_value(it))?;
176 DefWithBodyId::from(def).into() 167 DefWithBodyId::from(def).into()
177 }, 168 },
178 ast::StructDef(it) => { 169 ast::Struct(it) => {
179 let def = self.struct_to_def(container.with_value(it))?; 170 let def = self.struct_to_def(container.with_value(it))?;
180 VariantId::from(def).into() 171 VariantId::from(def).into()
181 }, 172 },
182 ast::EnumDef(it) => { 173 ast::Enum(it) => {
183 let def = self.enum_to_def(container.with_value(it))?; 174 let def = self.enum_to_def(container.with_value(it))?;
184 def.into() 175 def.into()
185 }, 176 },
186 ast::UnionDef(it) => { 177 ast::Union(it) => {
187 let def = self.union_to_def(container.with_value(it))?; 178 let def = self.union_to_def(container.with_value(it))?;
188 VariantId::from(def).into() 179 VariantId::from(def).into()
189 }, 180 },
190 ast::StaticDef(it) => { 181 ast::Static(it) => {
191 let def = self.static_to_def(container.with_value(it))?; 182 let def = self.static_to_def(container.with_value(it))?;
192 DefWithBodyId::from(def).into() 183 DefWithBodyId::from(def).into()
193 }, 184 },
194 ast::ConstDef(it) => { 185 ast::Const(it) => {
195 let def = self.const_to_def(container.with_value(it))?; 186 let def = self.const_to_def(container.with_value(it))?;
196 DefWithBodyId::from(def).into() 187 DefWithBodyId::from(def).into()
197 }, 188 },
198 ast::TypeAliasDef(it) => { 189 ast::TypeAlias(it) => {
199 let def = self.type_alias_to_def(container.with_value(it))?; 190 let def = self.type_alias_to_def(container.with_value(it))?;
200 def.into() 191 def.into()
201 }, 192 },
@@ -213,12 +204,12 @@ impl SourceToDefCtx<'_, '_> {
213 for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) { 204 for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) {
214 let res: GenericDefId = match_ast! { 205 let res: GenericDefId = match_ast! {
215 match (container.value) { 206 match (container.value) {
216 ast::FnDef(it) => self.fn_to_def(container.with_value(it))?.into(), 207 ast::Fn(it) => self.fn_to_def(container.with_value(it))?.into(),
217 ast::StructDef(it) => self.struct_to_def(container.with_value(it))?.into(), 208 ast::Struct(it) => self.struct_to_def(container.with_value(it))?.into(),
218 ast::EnumDef(it) => self.enum_to_def(container.with_value(it))?.into(), 209 ast::Enum(it) => self.enum_to_def(container.with_value(it))?.into(),
219 ast::TraitDef(it) => self.trait_to_def(container.with_value(it))?.into(), 210 ast::Trait(it) => self.trait_to_def(container.with_value(it))?.into(),
220 ast::TypeAliasDef(it) => self.type_alias_to_def(container.with_value(it))?.into(), 211 ast::TypeAlias(it) => self.type_alias_to_def(container.with_value(it))?.into(),
221 ast::ImplDef(it) => self.impl_to_def(container.with_value(it))?.into(), 212 ast::Impl(it) => self.impl_to_def(container.with_value(it))?.into(),
222 _ => continue, 213 _ => continue,
223 } 214 }
224 }; 215 };
@@ -231,9 +222,9 @@ impl SourceToDefCtx<'_, '_> {
231 for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) { 222 for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) {
232 let res: DefWithBodyId = match_ast! { 223 let res: DefWithBodyId = match_ast! {
233 match (container.value) { 224 match (container.value) {
234 ast::ConstDef(it) => self.const_to_def(container.with_value(it))?.into(), 225 ast::Const(it) => self.const_to_def(container.with_value(it))?.into(),
235 ast::StaticDef(it) => self.static_to_def(container.with_value(it))?.into(), 226 ast::Static(it) => self.static_to_def(container.with_value(it))?.into(),
236 ast::FnDef(it) => self.fn_to_def(container.with_value(it))?.into(), 227 ast::Fn(it) => self.fn_to_def(container.with_value(it))?.into(),
237 _ => continue, 228 _ => continue,
238 } 229 }
239 }; 230 };
diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs
index 86a47a9e5..d0cb62ef0 100644
--- a/crates/ra_hir/src/source_analyzer.rs
+++ b/crates/ra_hir/src/source_analyzer.rs
@@ -159,7 +159,7 @@ impl SourceAnalyzer {
159 pub(crate) fn resolve_record_field( 159 pub(crate) fn resolve_record_field(
160 &self, 160 &self,
161 db: &dyn HirDatabase, 161 db: &dyn HirDatabase,
162 field: &ast::RecordField, 162 field: &ast::RecordExprField,
163 ) -> Option<(Field, Option<Local>)> { 163 ) -> Option<(Field, Option<Local>)> {
164 let expr = field.expr()?; 164 let expr = field.expr()?;
165 let expr_id = self.expr_id(db, &expr)?; 165 let expr_id = self.expr_id(db, &expr)?;
@@ -182,7 +182,7 @@ impl SourceAnalyzer {
182 pub(crate) fn resolve_record_field_pat( 182 pub(crate) fn resolve_record_field_pat(
183 &self, 183 &self,
184 _db: &dyn HirDatabase, 184 _db: &dyn HirDatabase,
185 field: &ast::RecordFieldPat, 185 field: &ast::RecordPatField,
186 ) -> Option<Field> { 186 ) -> Option<Field> {
187 let pat_id = self.pat_id(&field.pat()?)?; 187 let pat_id = self.pat_id(&field.pat()?)?;
188 let struct_field = self.infer.as_ref()?.record_field_pat_resolution(pat_id)?; 188 let struct_field = self.infer.as_ref()?.record_field_pat_resolution(pat_id)?;
@@ -202,7 +202,7 @@ impl SourceAnalyzer {
202 pub(crate) fn resolve_bind_pat_to_const( 202 pub(crate) fn resolve_bind_pat_to_const(
203 &self, 203 &self,
204 db: &dyn HirDatabase, 204 db: &dyn HirDatabase,
205 pat: &ast::BindPat, 205 pat: &ast::IdentPat,
206 ) -> Option<ModuleDef> { 206 ) -> Option<ModuleDef> {
207 let pat_id = self.pat_id(&pat.clone().into())?; 207 let pat_id = self.pat_id(&pat.clone().into())?;
208 let body = self.body.as_ref()?; 208 let body = self.body.as_ref()?;
@@ -246,7 +246,7 @@ impl SourceAnalyzer {
246 } 246 }
247 } 247 }
248 248
249 if let Some(rec_lit) = path.syntax().parent().and_then(ast::RecordLit::cast) { 249 if let Some(rec_lit) = path.syntax().parent().and_then(ast::RecordExpr::cast) {
250 let expr_id = self.expr_id(db, &rec_lit.into())?; 250 let expr_id = self.expr_id(db, &rec_lit.into())?;
251 if let Some(VariantId::EnumVariantId(variant)) = 251 if let Some(VariantId::EnumVariantId(variant)) =
252 self.infer.as_ref()?.variant_resolution_for_expr(expr_id) 252 self.infer.as_ref()?.variant_resolution_for_expr(expr_id)
@@ -284,7 +284,7 @@ impl SourceAnalyzer {
284 pub(crate) fn record_literal_missing_fields( 284 pub(crate) fn record_literal_missing_fields(
285 &self, 285 &self,
286 db: &dyn HirDatabase, 286 db: &dyn HirDatabase,
287 literal: &ast::RecordLit, 287 literal: &ast::RecordExpr,
288 ) -> Option<Vec<(Field, Type)>> { 288 ) -> Option<Vec<(Field, Type)>> {
289 let krate = self.resolver.krate()?; 289 let krate = self.resolver.krate()?;
290 let body = self.body.as_ref()?; 290 let body = self.body.as_ref()?;
@@ -358,7 +358,7 @@ impl SourceAnalyzer {
358 pub(crate) fn resolve_variant( 358 pub(crate) fn resolve_variant(
359 &self, 359 &self,
360 db: &dyn HirDatabase, 360 db: &dyn HirDatabase,
361 record_lit: ast::RecordLit, 361 record_lit: ast::RecordExpr,
362 ) -> Option<VariantId> { 362 ) -> Option<VariantId> {
363 let infer = self.infer.as_ref()?; 363 let infer = self.infer.as_ref()?;
364 let expr_id = self.expr_id(db, &record_lit.into())?; 364 let expr_id = self.expr_id(db, &record_lit.into())?;
@@ -405,8 +405,7 @@ fn scope_for_offset(
405 ) 405 )
406 }) 406 })
407 .map(|(expr_range, scope)| { 407 .map(|(expr_range, scope)| {
408 adjust(db, scopes, source_map, expr_range, offset.file_id, offset.value) 408 adjust(db, scopes, source_map, expr_range, offset).unwrap_or(*scope)
409 .unwrap_or(*scope)
410 }) 409 })
411} 410}
412 411
@@ -417,8 +416,7 @@ fn adjust(
417 scopes: &ExprScopes, 416 scopes: &ExprScopes,
418 source_map: &BodySourceMap, 417 source_map: &BodySourceMap,
419 expr_range: TextRange, 418 expr_range: TextRange,
420 file_id: HirFileId, 419 offset: InFile<TextSize>,
421 offset: TextSize,
422) -> Option<ScopeId> { 420) -> Option<ScopeId> {
423 let child_scopes = scopes 421 let child_scopes = scopes
424 .scope_by_expr() 422 .scope_by_expr()
@@ -426,7 +424,7 @@ fn adjust(
426 .filter_map(|(id, scope)| { 424 .filter_map(|(id, scope)| {
427 let source = source_map.expr_syntax(*id).ok()?; 425 let source = source_map.expr_syntax(*id).ok()?;
428 // FIXME: correctly handle macro expansion 426 // FIXME: correctly handle macro expansion
429 if source.file_id != file_id { 427 if source.file_id != offset.file_id {
430 return None; 428 return None;
431 } 429 }
432 let root = source.file_syntax(db.upcast()); 430 let root = source.file_syntax(db.upcast());
@@ -434,7 +432,7 @@ fn adjust(
434 Some((node.syntax().text_range(), scope)) 432 Some((node.syntax().text_range(), scope))
435 }) 433 })
436 .filter(|&(range, _)| { 434 .filter(|&(range, _)| {
437 range.start() <= offset && expr_range.contains_range(range) && range != expr_range 435 range.start() <= offset.value && expr_range.contains_range(range) && range != expr_range
438 }); 436 });
439 437
440 child_scopes 438 child_scopes
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs
index 4994a2125..6cb56a1cd 100644
--- a/crates/ra_hir_def/src/adt.rs
+++ b/crates/ra_hir_def/src/adt.rs
@@ -8,7 +8,7 @@ use hir_expand::{
8 InFile, 8 InFile,
9}; 9};
10use ra_arena::{map::ArenaMap, Arena}; 10use ra_arena::{map::ArenaMap, Arena};
11use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner, VisibilityOwner}; 11use ra_syntax::ast::{self, NameOwner, VisibilityOwner};
12 12
13use crate::{ 13use crate::{
14 body::{CfgExpander, LowerCtx}, 14 body::{CfgExpander, LowerCtx},
@@ -112,7 +112,7 @@ impl EnumData {
112 112
113impl HasChildSource for EnumId { 113impl HasChildSource for EnumId {
114 type ChildId = LocalEnumVariantId; 114 type ChildId = LocalEnumVariantId;
115 type Value = ast::EnumVariant; 115 type Value = ast::Variant;
116 fn child_source(&self, db: &dyn DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> { 116 fn child_source(&self, db: &dyn DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> {
117 let src = self.lookup(db).source(db); 117 let src = self.lookup(db).source(db);
118 let mut trace = Trace::new_for_map(); 118 let mut trace = Trace::new_for_map();
@@ -123,8 +123,8 @@ impl HasChildSource for EnumId {
123 123
124fn lower_enum( 124fn lower_enum(
125 db: &dyn DefDatabase, 125 db: &dyn DefDatabase,
126 trace: &mut Trace<EnumVariantData, ast::EnumVariant>, 126 trace: &mut Trace<EnumVariantData, ast::Variant>,
127 ast: &InFile<ast::EnumDef>, 127 ast: &InFile<ast::Enum>,
128 module_id: ModuleId, 128 module_id: ModuleId,
129) { 129) {
130 let expander = CfgExpander::new(db, ast.file_id, module_id.krate); 130 let expander = CfgExpander::new(db, ast.file_id, module_id.krate);
@@ -179,7 +179,7 @@ impl VariantData {
179 179
180impl HasChildSource for VariantId { 180impl HasChildSource for VariantId {
181 type ChildId = LocalFieldId; 181 type ChildId = LocalFieldId;
182 type Value = Either<ast::TupleFieldDef, ast::RecordFieldDef>; 182 type Value = Either<ast::TupleField, ast::RecordField>;
183 183
184 fn child_source(&self, db: &dyn DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> { 184 fn child_source(&self, db: &dyn DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> {
185 let (src, module_id) = match self { 185 let (src, module_id) = match self {
@@ -194,7 +194,7 @@ impl HasChildSource for VariantId {
194 } 194 }
195 VariantId::UnionId(it) => ( 195 VariantId::UnionId(it) => (
196 it.lookup(db).source(db).map(|it| { 196 it.lookup(db).source(db).map(|it| {
197 it.record_field_def_list() 197 it.record_field_list()
198 .map(ast::StructKind::Record) 198 .map(ast::StructKind::Record)
199 .unwrap_or(ast::StructKind::Unit) 199 .unwrap_or(ast::StructKind::Unit)
200 }), 200 }),
@@ -218,7 +218,7 @@ pub enum StructKind {
218fn lower_struct( 218fn lower_struct(
219 db: &dyn DefDatabase, 219 db: &dyn DefDatabase,
220 expander: &mut CfgExpander, 220 expander: &mut CfgExpander,
221 trace: &mut Trace<FieldData, Either<ast::TupleFieldDef, ast::RecordFieldDef>>, 221 trace: &mut Trace<FieldData, Either<ast::TupleField, ast::RecordField>>,
222 ast: &InFile<ast::StructKind>, 222 ast: &InFile<ast::StructKind>,
223) -> StructKind { 223) -> StructKind {
224 let ctx = LowerCtx::new(db, ast.file_id); 224 let ctx = LowerCtx::new(db, ast.file_id);
@@ -234,7 +234,7 @@ fn lower_struct(
234 || Either::Left(fd.clone()), 234 || Either::Left(fd.clone()),
235 || FieldData { 235 || FieldData {
236 name: Name::new_tuple_field(i), 236 name: Name::new_tuple_field(i),
237 type_ref: TypeRef::from_ast_opt(&ctx, fd.type_ref()), 237 type_ref: TypeRef::from_ast_opt(&ctx, fd.ty()),
238 visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), 238 visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())),
239 }, 239 },
240 ); 240 );
@@ -251,7 +251,7 @@ fn lower_struct(
251 || Either::Right(fd.clone()), 251 || Either::Right(fd.clone()),
252 || FieldData { 252 || FieldData {
253 name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing), 253 name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing),
254 type_ref: TypeRef::from_ast_opt(&ctx, fd.ascribed_type()), 254 type_ref: TypeRef::from_ast_opt(&ctx, fd.ty()),
255 visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), 255 visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())),
256 }, 256 },
257 ); 257 );
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs
index 70ccd4305..050832ce0 100644
--- a/crates/ra_hir_def/src/attr.rs
+++ b/crates/ra_hir_def/src/attr.rs
@@ -151,18 +151,15 @@ pub enum AttrInput {
151impl Attr { 151impl Attr {
152 fn from_src(ast: ast::Attr, hygiene: &Hygiene) -> Option<Attr> { 152 fn from_src(ast: ast::Attr, hygiene: &Hygiene) -> Option<Attr> {
153 let path = ModPath::from_src(ast.path()?, hygiene)?; 153 let path = ModPath::from_src(ast.path()?, hygiene)?;
154 let input = match ast.input() { 154 let input = if let Some(lit) = ast.literal() {
155 None => None, 155 // FIXME: escape? raw string?
156 Some(ast::AttrInput::Literal(lit)) => { 156 let value = lit.syntax().first_token()?.text().trim_matches('"').into();
157 // FIXME: escape? raw string? 157 Some(AttrInput::Literal(value))
158 let value = lit.syntax().first_token()?.text().trim_matches('"').into(); 158 } else if let Some(tt) = ast.token_tree() {
159 Some(AttrInput::Literal(value)) 159 Some(AttrInput::TokenTree(ast_to_token_tree(&tt)?.0))
160 } 160 } else {
161 Some(ast::AttrInput::TokenTree(tt)) => { 161 None
162 Some(AttrInput::TokenTree(ast_to_token_tree(&tt)?.0))
163 }
164 }; 162 };
165
166 Some(Attr { path, input }) 163 Some(Attr { path, input })
167 } 164 }
168} 165}
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs
index 2fe04db2b..d5f18b920 100644
--- a/crates/ra_hir_def/src/body.rs
+++ b/crates/ra_hir_def/src/body.rs
@@ -216,7 +216,7 @@ pub struct BodySourceMap {
216 expr_map_back: ArenaMap<ExprId, Result<ExprSource, SyntheticSyntax>>, 216 expr_map_back: ArenaMap<ExprId, Result<ExprSource, SyntheticSyntax>>,
217 pat_map: FxHashMap<PatSource, PatId>, 217 pat_map: FxHashMap<PatSource, PatId>,
218 pat_map_back: ArenaMap<PatId, Result<PatSource, SyntheticSyntax>>, 218 pat_map_back: ArenaMap<PatId, Result<PatSource, SyntheticSyntax>>,
219 field_map: FxHashMap<(ExprId, usize), InFile<AstPtr<ast::RecordField>>>, 219 field_map: FxHashMap<(ExprId, usize), InFile<AstPtr<ast::RecordExprField>>>,
220 expansions: FxHashMap<InFile<AstPtr<ast::MacroCall>>, HirFileId>, 220 expansions: FxHashMap<InFile<AstPtr<ast::MacroCall>>, HirFileId>,
221} 221}
222 222
@@ -314,7 +314,7 @@ impl BodySourceMap {
314 self.pat_map.get(&src).cloned() 314 self.pat_map.get(&src).cloned()
315 } 315 }
316 316
317 pub fn field_syntax(&self, expr: ExprId, field: usize) -> InFile<AstPtr<ast::RecordField>> { 317 pub fn field_syntax(&self, expr: ExprId, field: usize) -> InFile<AstPtr<ast::RecordExprField>> {
318 self.field_map[&(expr, field)].clone() 318 self.field_map[&(expr, field)].clone()
319 } 319 }
320} 320}
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index c6bc85e2f..f5c37edb3 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -1,6 +1,8 @@
1//! Transforms `ast::Expr` into an equivalent `hir_def::expr::Expr` 1//! Transforms `ast::Expr` into an equivalent `hir_def::expr::Expr`
2//! representation. 2//! representation.
3 3
4use std::{any::type_name, sync::Arc};
5
4use either::Either; 6use either::Either;
5use hir_expand::{ 7use hir_expand::{
6 hygiene::Hygiene, 8 hygiene::Hygiene,
@@ -10,11 +12,12 @@ use hir_expand::{
10use ra_arena::Arena; 12use ra_arena::Arena;
11use ra_syntax::{ 13use ra_syntax::{
12 ast::{ 14 ast::{
13 self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, ModuleItemOwner, NameOwner, 15 self, ArgListOwner, ArrayExprKind, AstChildren, LiteralKind, LoopBodyOwner, NameOwner,
14 SlicePatComponents, TypeAscriptionOwner, 16 SlicePatComponents,
15 }, 17 },
16 AstNode, AstPtr, 18 AstNode, AstPtr,
17}; 19};
20use rustc_hash::FxHashMap;
18use test_utils::mark; 21use test_utils::mark;
19 22
20use crate::{ 23use crate::{
@@ -35,9 +38,6 @@ use crate::{
35}; 38};
36 39
37use super::{ExprSource, PatSource}; 40use super::{ExprSource, PatSource};
38use ast::AstChildren;
39use rustc_hash::FxHashMap;
40use std::{any::type_name, sync::Arc};
41 41
42pub(crate) struct LowerCtx { 42pub(crate) struct LowerCtx {
43 hygiene: Hygiene, 43 hygiene: Hygiene,
@@ -224,9 +224,22 @@ impl ExprCollector<'_> {
224 self.alloc_expr(Expr::Unsafe { body }, syntax_ptr) 224 self.alloc_expr(Expr::Unsafe { body }, syntax_ptr)
225 } 225 }
226 // FIXME: we need to record these effects somewhere... 226 // FIXME: we need to record these effects somewhere...
227 ast::Effect::Async(_) | ast::Effect::Label(_) => { 227 ast::Effect::Label(label) => match e.block_expr() {
228 self.collect_block_opt(e.block_expr()) 228 Some(block) => {
229 } 229 let res = self.collect_block(block);
230 match &mut self.body.exprs[res] {
231 Expr::Block { label: block_label, .. } => {
232 *block_label =
233 label.lifetime_token().map(|t| Name::new_lifetime(&t))
234 }
235 _ => unreachable!(),
236 }
237 res
238 }
239 None => self.missing_expr(),
240 },
241 // FIXME: we need to record these effects somewhere...
242 ast::Effect::Async(_) => self.collect_block_opt(e.block_expr()),
230 }, 243 },
231 ast::Expr::BlockExpr(e) => self.collect_block(e), 244 ast::Expr::BlockExpr(e) => self.collect_block(e),
232 ast::Expr::LoopExpr(e) => { 245 ast::Expr::LoopExpr(e) => {
@@ -324,7 +337,7 @@ impl ExprCollector<'_> {
324 }; 337 };
325 let method_name = e.name_ref().map(|nr| nr.as_name()).unwrap_or_else(Name::missing); 338 let method_name = e.name_ref().map(|nr| nr.as_name()).unwrap_or_else(Name::missing);
326 let generic_args = 339 let generic_args =
327 e.type_arg_list().and_then(|it| GenericArgs::from_ast(&self.ctx(), it)); 340 e.generic_arg_list().and_then(|it| GenericArgs::from_ast(&self.ctx(), it));
328 self.alloc_expr( 341 self.alloc_expr(
329 Expr::MethodCall { receiver, method_name, args, generic_args }, 342 Expr::MethodCall { receiver, method_name, args, generic_args },
330 syntax_ptr, 343 syntax_ptr,
@@ -379,10 +392,10 @@ impl ExprCollector<'_> {
379 let expr = e.expr().map(|e| self.collect_expr(e)); 392 let expr = e.expr().map(|e| self.collect_expr(e));
380 self.alloc_expr(Expr::Return { expr }, syntax_ptr) 393 self.alloc_expr(Expr::Return { expr }, syntax_ptr)
381 } 394 }
382 ast::Expr::RecordLit(e) => { 395 ast::Expr::RecordExpr(e) => {
383 let path = e.path().and_then(|path| self.expander.parse_path(path)); 396 let path = e.path().and_then(|path| self.expander.parse_path(path));
384 let mut field_ptrs = Vec::new(); 397 let mut field_ptrs = Vec::new();
385 let record_lit = if let Some(nfl) = e.record_field_list() { 398 let record_lit = if let Some(nfl) = e.record_expr_field_list() {
386 let fields = nfl 399 let fields = nfl
387 .fields() 400 .fields()
388 .inspect(|field| field_ptrs.push(AstPtr::new(field))) 401 .inspect(|field| field_ptrs.push(AstPtr::new(field)))
@@ -432,7 +445,7 @@ impl ExprCollector<'_> {
432 } 445 }
433 ast::Expr::CastExpr(e) => { 446 ast::Expr::CastExpr(e) => {
434 let expr = self.collect_expr_opt(e.expr()); 447 let expr = self.collect_expr_opt(e.expr());
435 let type_ref = TypeRef::from_ast_opt(&self.ctx(), e.type_ref()); 448 let type_ref = TypeRef::from_ast_opt(&self.ctx(), e.ty());
436 self.alloc_expr(Expr::Cast { expr, type_ref }, syntax_ptr) 449 self.alloc_expr(Expr::Cast { expr, type_ref }, syntax_ptr)
437 } 450 }
438 ast::Expr::RefExpr(e) => { 451 ast::Expr::RefExpr(e) => {
@@ -460,22 +473,19 @@ impl ExprCollector<'_> {
460 self.alloc_expr(Expr::Missing, syntax_ptr) 473 self.alloc_expr(Expr::Missing, syntax_ptr)
461 } 474 }
462 } 475 }
463 ast::Expr::LambdaExpr(e) => { 476 ast::Expr::ClosureExpr(e) => {
464 let mut args = Vec::new(); 477 let mut args = Vec::new();
465 let mut arg_types = Vec::new(); 478 let mut arg_types = Vec::new();
466 if let Some(pl) = e.param_list() { 479 if let Some(pl) = e.param_list() {
467 for param in pl.params() { 480 for param in pl.params() {
468 let pat = self.collect_pat_opt(param.pat()); 481 let pat = self.collect_pat_opt(param.pat());
469 let type_ref = 482 let type_ref = param.ty().map(|it| TypeRef::from_ast(&self.ctx(), it));
470 param.ascribed_type().map(|it| TypeRef::from_ast(&self.ctx(), it));
471 args.push(pat); 483 args.push(pat);
472 arg_types.push(type_ref); 484 arg_types.push(type_ref);
473 } 485 }
474 } 486 }
475 let ret_type = e 487 let ret_type =
476 .ret_type() 488 e.ret_type().and_then(|r| r.ty()).map(|it| TypeRef::from_ast(&self.ctx(), it));
477 .and_then(|r| r.type_ref())
478 .map(|it| TypeRef::from_ast(&self.ctx(), it));
479 let body = self.collect_expr_opt(e.body()); 489 let body = self.collect_expr_opt(e.body());
480 self.alloc_expr(Expr::Lambda { args, arg_types, ret_type, body }, syntax_ptr) 490 self.alloc_expr(Expr::Lambda { args, arg_types, ret_type, body }, syntax_ptr)
481 } 491 }
@@ -486,7 +496,7 @@ impl ExprCollector<'_> {
486 self.alloc_expr(Expr::BinaryOp { lhs, rhs, op }, syntax_ptr) 496 self.alloc_expr(Expr::BinaryOp { lhs, rhs, op }, syntax_ptr)
487 } 497 }
488 ast::Expr::TupleExpr(e) => { 498 ast::Expr::TupleExpr(e) => {
489 let exprs = e.exprs().map(|expr| self.collect_expr(expr)).collect(); 499 let exprs = e.fields().map(|expr| self.collect_expr(expr)).collect();
490 self.alloc_expr(Expr::Tuple { exprs }, syntax_ptr) 500 self.alloc_expr(Expr::Tuple { exprs }, syntax_ptr)
491 } 501 }
492 ast::Expr::BoxExpr(e) => { 502 ast::Expr::BoxExpr(e) => {
@@ -559,9 +569,6 @@ impl ExprCollector<'_> {
559 } 569 }
560 } 570 }
561 } 571 }
562
563 // FIXME implement HIR for these:
564 ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
565 } 572 }
566 } 573 }
567 574
@@ -604,76 +611,84 @@ impl ExprCollector<'_> {
604 self.collect_block_items(&block); 611 self.collect_block_items(&block);
605 let statements = block 612 let statements = block
606 .statements() 613 .statements()
607 .map(|s| match s { 614 .filter_map(|s| {
608 ast::Stmt::LetStmt(stmt) => { 615 let stmt = match s {
609 let pat = self.collect_pat_opt(stmt.pat()); 616 ast::Stmt::LetStmt(stmt) => {
610 let type_ref = 617 let pat = self.collect_pat_opt(stmt.pat());
611 stmt.ascribed_type().map(|it| TypeRef::from_ast(&self.ctx(), it)); 618 let type_ref = stmt.ty().map(|it| TypeRef::from_ast(&self.ctx(), it));
612 let initializer = stmt.initializer().map(|e| self.collect_expr(e)); 619 let initializer = stmt.initializer().map(|e| self.collect_expr(e));
613 Statement::Let { pat, type_ref, initializer } 620 Statement::Let { pat, type_ref, initializer }
614 } 621 }
615 ast::Stmt::ExprStmt(stmt) => Statement::Expr(self.collect_expr_opt(stmt.expr())), 622 ast::Stmt::ExprStmt(stmt) => {
623 Statement::Expr(self.collect_expr_opt(stmt.expr()))
624 }
625 ast::Stmt::Item(_) => return None,
626 };
627 Some(stmt)
616 }) 628 })
617 .collect(); 629 .collect();
618 let tail = block.expr().map(|e| self.collect_expr(e)); 630 let tail = block.expr().map(|e| self.collect_expr(e));
619 let label = block.label().and_then(|l| l.lifetime_token()).map(|t| Name::new_lifetime(&t)); 631 self.alloc_expr(Expr::Block { statements, tail, label: None }, syntax_node_ptr)
620 self.alloc_expr(Expr::Block { statements, tail, label }, syntax_node_ptr)
621 } 632 }
622 633
623 fn collect_block_items(&mut self, block: &ast::BlockExpr) { 634 fn collect_block_items(&mut self, block: &ast::BlockExpr) {
624 let container = ContainerId::DefWithBodyId(self.def); 635 let container = ContainerId::DefWithBodyId(self.def);
625 636
626 let items = block 637 let items = block
627 .items() 638 .statements()
639 .filter_map(|stmt| match stmt {
640 ast::Stmt::Item(it) => Some(it),
641 ast::Stmt::LetStmt(_) | ast::Stmt::ExprStmt(_) => None,
642 })
628 .filter_map(|item| { 643 .filter_map(|item| {
629 let (def, name): (ModuleDefId, Option<ast::Name>) = match item { 644 let (def, name): (ModuleDefId, Option<ast::Name>) = match item {
630 ast::ModuleItem::FnDef(def) => { 645 ast::Item::Fn(def) => {
631 let id = self.find_inner_item(&def)?; 646 let id = self.find_inner_item(&def)?;
632 ( 647 (
633 FunctionLoc { container: container.into(), id }.intern(self.db).into(), 648 FunctionLoc { container: container.into(), id }.intern(self.db).into(),
634 def.name(), 649 def.name(),
635 ) 650 )
636 } 651 }
637 ast::ModuleItem::TypeAliasDef(def) => { 652 ast::Item::TypeAlias(def) => {
638 let id = self.find_inner_item(&def)?; 653 let id = self.find_inner_item(&def)?;
639 ( 654 (
640 TypeAliasLoc { container: container.into(), id }.intern(self.db).into(), 655 TypeAliasLoc { container: container.into(), id }.intern(self.db).into(),
641 def.name(), 656 def.name(),
642 ) 657 )
643 } 658 }
644 ast::ModuleItem::ConstDef(def) => { 659 ast::Item::Const(def) => {
645 let id = self.find_inner_item(&def)?; 660 let id = self.find_inner_item(&def)?;
646 ( 661 (
647 ConstLoc { container: container.into(), id }.intern(self.db).into(), 662 ConstLoc { container: container.into(), id }.intern(self.db).into(),
648 def.name(), 663 def.name(),
649 ) 664 )
650 } 665 }
651 ast::ModuleItem::StaticDef(def) => { 666 ast::Item::Static(def) => {
652 let id = self.find_inner_item(&def)?; 667 let id = self.find_inner_item(&def)?;
653 (StaticLoc { container, id }.intern(self.db).into(), def.name()) 668 (StaticLoc { container, id }.intern(self.db).into(), def.name())
654 } 669 }
655 ast::ModuleItem::StructDef(def) => { 670 ast::Item::Struct(def) => {
656 let id = self.find_inner_item(&def)?; 671 let id = self.find_inner_item(&def)?;
657 (StructLoc { container, id }.intern(self.db).into(), def.name()) 672 (StructLoc { container, id }.intern(self.db).into(), def.name())
658 } 673 }
659 ast::ModuleItem::EnumDef(def) => { 674 ast::Item::Enum(def) => {
660 let id = self.find_inner_item(&def)?; 675 let id = self.find_inner_item(&def)?;
661 (EnumLoc { container, id }.intern(self.db).into(), def.name()) 676 (EnumLoc { container, id }.intern(self.db).into(), def.name())
662 } 677 }
663 ast::ModuleItem::UnionDef(def) => { 678 ast::Item::Union(def) => {
664 let id = self.find_inner_item(&def)?; 679 let id = self.find_inner_item(&def)?;
665 (UnionLoc { container, id }.intern(self.db).into(), def.name()) 680 (UnionLoc { container, id }.intern(self.db).into(), def.name())
666 } 681 }
667 ast::ModuleItem::TraitDef(def) => { 682 ast::Item::Trait(def) => {
668 let id = self.find_inner_item(&def)?; 683 let id = self.find_inner_item(&def)?;
669 (TraitLoc { container, id }.intern(self.db).into(), def.name()) 684 (TraitLoc { container, id }.intern(self.db).into(), def.name())
670 } 685 }
671 ast::ModuleItem::ExternBlock(_) => return None, // FIXME: collect from extern blocks 686 ast::Item::ExternBlock(_) => return None, // FIXME: collect from extern blocks
672 ast::ModuleItem::ImplDef(_) 687 ast::Item::Impl(_)
673 | ast::ModuleItem::UseItem(_) 688 | ast::Item::Use(_)
674 | ast::ModuleItem::ExternCrateItem(_) 689 | ast::Item::ExternCrate(_)
675 | ast::ModuleItem::Module(_) 690 | ast::Item::Module(_)
676 | ast::ModuleItem::MacroCall(_) => return None, 691 | ast::Item::MacroCall(_) => return None,
677 }; 692 };
678 693
679 Some((def, name)) 694 Some((def, name))
@@ -708,7 +723,7 @@ impl ExprCollector<'_> {
708 723
709 fn collect_pat(&mut self, pat: ast::Pat) -> PatId { 724 fn collect_pat(&mut self, pat: ast::Pat) -> PatId {
710 let pattern = match &pat { 725 let pattern = match &pat {
711 ast::Pat::BindPat(bp) => { 726 ast::Pat::IdentPat(bp) => {
712 let name = bp.name().map(|nr| nr.as_name()).unwrap_or_else(Name::missing); 727 let name = bp.name().map(|nr| nr.as_name()).unwrap_or_else(Name::missing);
713 let annotation = 728 let annotation =
714 BindingAnnotation::new(bp.mut_token().is_some(), bp.ref_token().is_some()); 729 BindingAnnotation::new(bp.mut_token().is_some(), bp.ref_token().is_some());
@@ -747,7 +762,7 @@ impl ExprCollector<'_> {
747 } 762 }
748 ast::Pat::TupleStructPat(p) => { 763 ast::Pat::TupleStructPat(p) => {
749 let path = p.path().and_then(|path| self.expander.parse_path(path)); 764 let path = p.path().and_then(|path| self.expander.parse_path(path));
750 let (args, ellipsis) = self.collect_tuple_pat(p.args()); 765 let (args, ellipsis) = self.collect_tuple_pat(p.fields());
751 Pat::TupleStruct { path, args, ellipsis } 766 Pat::TupleStruct { path, args, ellipsis }
752 } 767 }
753 ast::Pat::RefPat(p) => { 768 ast::Pat::RefPat(p) => {
@@ -765,40 +780,36 @@ impl ExprCollector<'_> {
765 } 780 }
766 ast::Pat::ParenPat(p) => return self.collect_pat_opt(p.pat()), 781 ast::Pat::ParenPat(p) => return self.collect_pat_opt(p.pat()),
767 ast::Pat::TuplePat(p) => { 782 ast::Pat::TuplePat(p) => {
768 let (args, ellipsis) = self.collect_tuple_pat(p.args()); 783 let (args, ellipsis) = self.collect_tuple_pat(p.fields());
769 Pat::Tuple { args, ellipsis } 784 Pat::Tuple { args, ellipsis }
770 } 785 }
771 ast::Pat::PlaceholderPat(_) => Pat::Wild, 786 ast::Pat::WildcardPat(_) => Pat::Wild,
772 ast::Pat::RecordPat(p) => { 787 ast::Pat::RecordPat(p) => {
773 let path = p.path().and_then(|path| self.expander.parse_path(path)); 788 let path = p.path().and_then(|path| self.expander.parse_path(path));
774 let record_field_pat_list = 789 let args: Vec<_> = p
775 p.record_field_pat_list().expect("every struct should have a field list"); 790 .record_pat_field_list()
776 let mut fields: Vec<_> = record_field_pat_list 791 .expect("every struct should have a field list")
777 .bind_pats() 792 .fields()
778 .filter_map(|bind_pat| { 793 .filter_map(|f| {
779 let ast_pat = 794 let ast_pat = f.pat()?;
780 ast::Pat::cast(bind_pat.syntax().clone()).expect("bind pat is a pat");
781 let pat = self.collect_pat(ast_pat); 795 let pat = self.collect_pat(ast_pat);
782 let name = bind_pat.name()?.as_name(); 796 let name = f.field_name()?.as_name();
783 Some(RecordFieldPat { name, pat }) 797 Some(RecordFieldPat { name, pat })
784 }) 798 })
785 .collect(); 799 .collect();
786 let iter = record_field_pat_list.record_field_pats().filter_map(|f| {
787 let ast_pat = f.pat()?;
788 let pat = self.collect_pat(ast_pat);
789 let name = f.field_name()?.as_name();
790 Some(RecordFieldPat { name, pat })
791 });
792 fields.extend(iter);
793 800
794 let ellipsis = record_field_pat_list.dotdot_token().is_some(); 801 let ellipsis = p
802 .record_pat_field_list()
803 .expect("every struct should have a field list")
804 .dotdot_token()
805 .is_some();
795 806
796 Pat::Record { path, args: fields, ellipsis } 807 Pat::Record { path, args, ellipsis }
797 } 808 }
798 ast::Pat::SlicePat(p) => { 809 ast::Pat::SlicePat(p) => {
799 let SlicePatComponents { prefix, slice, suffix } = p.components(); 810 let SlicePatComponents { prefix, slice, suffix } = p.components();
800 811
801 // FIXME properly handle `DotDotPat` 812 // FIXME properly handle `RestPat`
802 Pat::Slice { 813 Pat::Slice {
803 prefix: prefix.into_iter().map(|p| self.collect_pat(p)).collect(), 814 prefix: prefix.into_iter().map(|p| self.collect_pat(p)).collect(),
804 slice: slice.map(|p| self.collect_pat(p)), 815 slice: slice.map(|p| self.collect_pat(p)),
@@ -815,10 +826,10 @@ impl ExprCollector<'_> {
815 Pat::Missing 826 Pat::Missing
816 } 827 }
817 } 828 }
818 ast::Pat::DotDotPat(_) => { 829 ast::Pat::RestPat(_) => {
819 // `DotDotPat` requires special handling and should not be mapped 830 // `RestPat` requires special handling and should not be mapped
820 // to a Pat. Here we are using `Pat::Missing` as a fallback for 831 // to a Pat. Here we are using `Pat::Missing` as a fallback for
821 // when `DotDotPat` is mapped to `Pat`, which can easily happen 832 // when `RestPat` is mapped to `Pat`, which can easily happen
822 // when the source code being analyzed has a malformed pattern 833 // when the source code being analyzed has a malformed pattern
823 // which includes `..` in a place where it isn't valid. 834 // which includes `..` in a place where it isn't valid.
824 835
@@ -842,10 +853,10 @@ impl ExprCollector<'_> {
842 fn collect_tuple_pat(&mut self, args: AstChildren<ast::Pat>) -> (Vec<PatId>, Option<usize>) { 853 fn collect_tuple_pat(&mut self, args: AstChildren<ast::Pat>) -> (Vec<PatId>, Option<usize>) {
843 // Find the location of the `..`, if there is one. Note that we do not 854 // Find the location of the `..`, if there is one. Note that we do not
844 // consider the possiblity of there being multiple `..` here. 855 // consider the possiblity of there being multiple `..` here.
845 let ellipsis = args.clone().position(|p| matches!(p, ast::Pat::DotDotPat(_))); 856 let ellipsis = args.clone().position(|p| matches!(p, ast::Pat::RestPat(_)));
846 // We want to skip the `..` pattern here, since we account for it above. 857 // We want to skip the `..` pattern here, since we account for it above.
847 let args = args 858 let args = args
848 .filter(|p| !matches!(p, ast::Pat::DotDotPat(_))) 859 .filter(|p| !matches!(p, ast::Pat::RestPat(_)))
849 .map(|p| self.collect_pat(p)) 860 .map(|p| self.collect_pat(p))
850 .collect(); 861 .collect();
851 862
diff --git a/crates/ra_hir_def/src/child_by_source.rs b/crates/ra_hir_def/src/child_by_source.rs
index a885ec96d..dcb00a1d9 100644
--- a/crates/ra_hir_def/src/child_by_source.rs
+++ b/crates/ra_hir_def/src/child_by_source.rs
@@ -162,7 +162,7 @@ impl ChildBySource for EnumId {
162 let arena_map = arena_map.as_ref(); 162 let arena_map = arena_map.as_ref();
163 for (local_id, source) in arena_map.value.iter() { 163 for (local_id, source) in arena_map.value.iter() {
164 let id = EnumVariantId { parent: *self, local_id }; 164 let id = EnumVariantId { parent: *self, local_id };
165 res[keys::ENUM_VARIANT].insert(arena_map.with_value(source.clone()), id) 165 res[keys::VARIANT].insert(arena_map.with_value(source.clone()), id)
166 } 166 }
167 167
168 res 168 res
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs
index 6a0f493a7..699ba9c92 100644
--- a/crates/ra_hir_def/src/generics.rs
+++ b/crates/ra_hir_def/src/generics.rs
@@ -12,7 +12,7 @@ use hir_expand::{
12use ra_arena::{map::ArenaMap, Arena}; 12use ra_arena::{map::ArenaMap, Arena};
13use ra_db::FileId; 13use ra_db::FileId;
14use ra_prof::profile; 14use ra_prof::profile;
15use ra_syntax::ast::{self, NameOwner, TypeBoundsOwner, TypeParamsOwner}; 15use ra_syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner};
16 16
17use crate::{ 17use crate::{
18 body::LowerCtx, 18 body::LowerCtx,
@@ -66,7 +66,7 @@ pub enum WherePredicateTarget {
66 TypeParam(LocalTypeParamId), 66 TypeParam(LocalTypeParamId),
67} 67}
68 68
69type SourceMap = ArenaMap<LocalTypeParamId, Either<ast::TraitDef, ast::TypeParam>>; 69type SourceMap = ArenaMap<LocalTypeParamId, Either<ast::Trait, ast::TypeParam>>;
70 70
71impl GenericParams { 71impl GenericParams {
72 pub(crate) fn generic_params_query( 72 pub(crate) fn generic_params_query(
@@ -205,9 +205,9 @@ impl GenericParams {
205 &mut self, 205 &mut self,
206 lower_ctx: &LowerCtx, 206 lower_ctx: &LowerCtx,
207 sm: &mut SourceMap, 207 sm: &mut SourceMap,
208 node: &dyn TypeParamsOwner, 208 node: &dyn GenericParamsOwner,
209 ) { 209 ) {
210 if let Some(params) = node.type_param_list() { 210 if let Some(params) = node.generic_param_list() {
211 self.fill_params(lower_ctx, sm, params) 211 self.fill_params(lower_ctx, sm, params)
212 } 212 }
213 if let Some(where_clause) = node.where_clause() { 213 if let Some(where_clause) = node.where_clause() {
@@ -232,7 +232,7 @@ impl GenericParams {
232 &mut self, 232 &mut self,
233 lower_ctx: &LowerCtx, 233 lower_ctx: &LowerCtx,
234 sm: &mut SourceMap, 234 sm: &mut SourceMap,
235 params: ast::TypeParamList, 235 params: ast::GenericParamList,
236 ) { 236 ) {
237 for type_param in params.type_params() { 237 for type_param in params.type_params() {
238 let name = type_param.name().map_or_else(Name::missing, |it| it.as_name()); 238 let name = type_param.name().map_or_else(Name::missing, |it| it.as_name());
@@ -253,7 +253,7 @@ impl GenericParams {
253 253
254 fn fill_where_predicates(&mut self, lower_ctx: &LowerCtx, where_clause: ast::WhereClause) { 254 fn fill_where_predicates(&mut self, lower_ctx: &LowerCtx, where_clause: ast::WhereClause) {
255 for pred in where_clause.predicates() { 255 for pred in where_clause.predicates() {
256 let type_ref = match pred.type_ref() { 256 let type_ref = match pred.ty() {
257 Some(type_ref) => type_ref, 257 Some(type_ref) => type_ref,
258 None => continue, 258 None => continue,
259 }; 259 };
@@ -270,7 +270,7 @@ impl GenericParams {
270 bound: ast::TypeBound, 270 bound: ast::TypeBound,
271 type_ref: TypeRef, 271 type_ref: TypeRef,
272 ) { 272 ) {
273 if bound.question_token().is_some() { 273 if bound.question_mark_token().is_some() {
274 // FIXME: remove this bound 274 // FIXME: remove this bound
275 return; 275 return;
276 } 276 }
@@ -317,7 +317,7 @@ impl GenericParams {
317 317
318impl HasChildSource for GenericDefId { 318impl HasChildSource for GenericDefId {
319 type ChildId = LocalTypeParamId; 319 type ChildId = LocalTypeParamId;
320 type Value = Either<ast::TraitDef, ast::TypeParam>; 320 type Value = Either<ast::Trait, ast::TypeParam>;
321 fn child_source(&self, db: &dyn DefDatabase) -> InFile<SourceMap> { 321 fn child_source(&self, db: &dyn DefDatabase) -> InFile<SourceMap> {
322 let (_, sm) = GenericParams::new(db, *self); 322 let (_, sm) = GenericParams::new(db, *self);
323 sm 323 sm
diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs
index da79d8ffd..a67e75dac 100644
--- a/crates/ra_hir_def/src/item_tree.rs
+++ b/crates/ra_hir_def/src/item_tree.rs
@@ -13,7 +13,7 @@ use std::{
13 sync::Arc, 13 sync::Arc,
14}; 14};
15 15
16use ast::{AstNode, AttrsOwner, NameOwner, StructKind, TypeAscriptionOwner}; 16use ast::{AstNode, AttrsOwner, NameOwner, StructKind};
17use either::Either; 17use either::Either;
18use hir_expand::{ 18use hir_expand::{
19 ast_id_map::FileAstId, 19 ast_id_map::FileAstId,
@@ -70,7 +70,7 @@ impl GenericParamsId {
70pub struct ItemTree { 70pub struct ItemTree {
71 top_level: SmallVec<[ModItem; 1]>, 71 top_level: SmallVec<[ModItem; 1]>,
72 attrs: FxHashMap<AttrOwner, Attrs>, 72 attrs: FxHashMap<AttrOwner, Attrs>,
73 inner_items: FxHashMap<FileAstId<ast::ModuleItem>, SmallVec<[ModItem; 1]>>, 73 inner_items: FxHashMap<FileAstId<ast::Item>, SmallVec<[ModItem; 1]>>,
74 74
75 data: Option<Box<ItemTreeData>>, 75 data: Option<Box<ItemTreeData>>,
76} 76}
@@ -187,7 +187,7 @@ impl ItemTree {
187 /// 187 ///
188 /// Most AST items are lowered to a single `ModItem`, but some (eg. `use` items) may be lowered 188 /// Most AST items are lowered to a single `ModItem`, but some (eg. `use` items) may be lowered
189 /// to multiple items in the `ItemTree`. 189 /// to multiple items in the `ItemTree`.
190 pub fn inner_items(&self, ast: FileAstId<ast::ModuleItem>) -> &[ModItem] { 190 pub fn inner_items(&self, ast: FileAstId<ast::Item>) -> &[ModItem] {
191 &self.inner_items[&ast] 191 &self.inner_items[&ast]
192 } 192 }
193 193
@@ -310,7 +310,7 @@ from_attrs!(ModItem(ModItem), Variant(Idx<Variant>), Field(Idx<Field>));
310 310
311/// Trait implemented by all item nodes in the item tree. 311/// Trait implemented by all item nodes in the item tree.
312pub trait ItemTreeNode: Clone { 312pub trait ItemTreeNode: Clone {
313 type Source: AstNode + Into<ast::ModuleItem>; 313 type Source: AstNode + Into<ast::Item>;
314 314
315 fn ast_id(&self) -> FileAstId<Self::Source>; 315 fn ast_id(&self) -> FileAstId<Self::Source>;
316 316
@@ -411,17 +411,17 @@ macro_rules! mod_items {
411} 411}
412 412
413mod_items! { 413mod_items! {
414 Import in imports -> ast::UseItem, 414 Import in imports -> ast::Use,
415 ExternCrate in extern_crates -> ast::ExternCrateItem, 415 ExternCrate in extern_crates -> ast::ExternCrate,
416 Function in functions -> ast::FnDef, 416 Function in functions -> ast::Fn,
417 Struct in structs -> ast::StructDef, 417 Struct in structs -> ast::Struct,
418 Union in unions -> ast::UnionDef, 418 Union in unions -> ast::Union,
419 Enum in enums -> ast::EnumDef, 419 Enum in enums -> ast::Enum,
420 Const in consts -> ast::ConstDef, 420 Const in consts -> ast::Const,
421 Static in statics -> ast::StaticDef, 421 Static in statics -> ast::Static,
422 Trait in traits -> ast::TraitDef, 422 Trait in traits -> ast::Trait,
423 Impl in impls -> ast::ImplDef, 423 Impl in impls -> ast::Impl,
424 TypeAlias in type_aliases -> ast::TypeAliasDef, 424 TypeAlias in type_aliases -> ast::TypeAlias,
425 Mod in mods -> ast::Module, 425 Mod in mods -> ast::Module,
426 MacroCall in macro_calls -> ast::MacroCall, 426 MacroCall in macro_calls -> ast::MacroCall,
427} 427}
@@ -482,7 +482,7 @@ pub struct Import {
482 pub is_prelude: bool, 482 pub is_prelude: bool,
483 /// AST ID of the `use` or `extern crate` item this import was derived from. Note that many 483 /// AST ID of the `use` or `extern crate` item this import was derived from. Note that many
484 /// `Import`s can map to the same `use` item. 484 /// `Import`s can map to the same `use` item.
485 pub ast_id: FileAstId<ast::UseItem>, 485 pub ast_id: FileAstId<ast::Use>,
486} 486}
487 487
488#[derive(Debug, Clone, Eq, PartialEq)] 488#[derive(Debug, Clone, Eq, PartialEq)]
@@ -492,7 +492,7 @@ pub struct ExternCrate {
492 pub visibility: RawVisibilityId, 492 pub visibility: RawVisibilityId,
493 /// Whether this is a `#[macro_use] extern crate ...`. 493 /// Whether this is a `#[macro_use] extern crate ...`.
494 pub is_macro_use: bool, 494 pub is_macro_use: bool,
495 pub ast_id: FileAstId<ast::ExternCrateItem>, 495 pub ast_id: FileAstId<ast::ExternCrate>,
496} 496}
497 497
498#[derive(Debug, Clone, Eq, PartialEq)] 498#[derive(Debug, Clone, Eq, PartialEq)]
@@ -505,7 +505,7 @@ pub struct Function {
505 pub params: Box<[TypeRef]>, 505 pub params: Box<[TypeRef]>,
506 pub is_varargs: bool, 506 pub is_varargs: bool,
507 pub ret_type: TypeRef, 507 pub ret_type: TypeRef,
508 pub ast_id: FileAstId<ast::FnDef>, 508 pub ast_id: FileAstId<ast::Fn>,
509} 509}
510 510
511#[derive(Debug, Clone, Eq, PartialEq)] 511#[derive(Debug, Clone, Eq, PartialEq)]
@@ -514,7 +514,7 @@ pub struct Struct {
514 pub visibility: RawVisibilityId, 514 pub visibility: RawVisibilityId,
515 pub generic_params: GenericParamsId, 515 pub generic_params: GenericParamsId,
516 pub fields: Fields, 516 pub fields: Fields,
517 pub ast_id: FileAstId<ast::StructDef>, 517 pub ast_id: FileAstId<ast::Struct>,
518 pub kind: StructDefKind, 518 pub kind: StructDefKind,
519} 519}
520 520
@@ -534,7 +534,7 @@ pub struct Union {
534 pub visibility: RawVisibilityId, 534 pub visibility: RawVisibilityId,
535 pub generic_params: GenericParamsId, 535 pub generic_params: GenericParamsId,
536 pub fields: Fields, 536 pub fields: Fields,
537 pub ast_id: FileAstId<ast::UnionDef>, 537 pub ast_id: FileAstId<ast::Union>,
538} 538}
539 539
540#[derive(Debug, Clone, Eq, PartialEq)] 540#[derive(Debug, Clone, Eq, PartialEq)]
@@ -543,7 +543,7 @@ pub struct Enum {
543 pub visibility: RawVisibilityId, 543 pub visibility: RawVisibilityId,
544 pub generic_params: GenericParamsId, 544 pub generic_params: GenericParamsId,
545 pub variants: IdRange<Variant>, 545 pub variants: IdRange<Variant>,
546 pub ast_id: FileAstId<ast::EnumDef>, 546 pub ast_id: FileAstId<ast::Enum>,
547} 547}
548 548
549#[derive(Debug, Clone, Eq, PartialEq)] 549#[derive(Debug, Clone, Eq, PartialEq)]
@@ -552,7 +552,7 @@ pub struct Const {
552 pub name: Option<Name>, 552 pub name: Option<Name>,
553 pub visibility: RawVisibilityId, 553 pub visibility: RawVisibilityId,
554 pub type_ref: TypeRef, 554 pub type_ref: TypeRef,
555 pub ast_id: FileAstId<ast::ConstDef>, 555 pub ast_id: FileAstId<ast::Const>,
556} 556}
557 557
558#[derive(Debug, Clone, Eq, PartialEq)] 558#[derive(Debug, Clone, Eq, PartialEq)]
@@ -561,7 +561,7 @@ pub struct Static {
561 pub visibility: RawVisibilityId, 561 pub visibility: RawVisibilityId,
562 pub mutable: bool, 562 pub mutable: bool,
563 pub type_ref: TypeRef, 563 pub type_ref: TypeRef,
564 pub ast_id: FileAstId<ast::StaticDef>, 564 pub ast_id: FileAstId<ast::Static>,
565} 565}
566 566
567#[derive(Debug, Clone, Eq, PartialEq)] 567#[derive(Debug, Clone, Eq, PartialEq)]
@@ -571,7 +571,7 @@ pub struct Trait {
571 pub generic_params: GenericParamsId, 571 pub generic_params: GenericParamsId,
572 pub auto: bool, 572 pub auto: bool,
573 pub items: Box<[AssocItem]>, 573 pub items: Box<[AssocItem]>,
574 pub ast_id: FileAstId<ast::TraitDef>, 574 pub ast_id: FileAstId<ast::Trait>,
575} 575}
576 576
577#[derive(Debug, Clone, Eq, PartialEq)] 577#[derive(Debug, Clone, Eq, PartialEq)]
@@ -581,7 +581,7 @@ pub struct Impl {
581 pub target_type: TypeRef, 581 pub target_type: TypeRef,
582 pub is_negative: bool, 582 pub is_negative: bool,
583 pub items: Box<[AssocItem]>, 583 pub items: Box<[AssocItem]>,
584 pub ast_id: FileAstId<ast::ImplDef>, 584 pub ast_id: FileAstId<ast::Impl>,
585} 585}
586 586
587#[derive(Debug, Clone, PartialEq, Eq)] 587#[derive(Debug, Clone, PartialEq, Eq)]
@@ -592,7 +592,7 @@ pub struct TypeAlias {
592 pub bounds: Box<[TypeBound]>, 592 pub bounds: Box<[TypeBound]>,
593 pub generic_params: GenericParamsId, 593 pub generic_params: GenericParamsId,
594 pub type_ref: Option<TypeRef>, 594 pub type_ref: Option<TypeRef>,
595 pub ast_id: FileAstId<ast::TypeAliasDef>, 595 pub ast_id: FileAstId<ast::TypeAlias>,
596} 596}
597 597
598#[derive(Debug, Clone, Eq, PartialEq)] 598#[derive(Debug, Clone, Eq, PartialEq)]
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs
index f79b8fca3..450ef8798 100644
--- a/crates/ra_hir_def/src/item_tree/lower.rs
+++ b/crates/ra_hir_def/src/item_tree/lower.rs
@@ -1,10 +1,7 @@
1//! AST -> `ItemTree` lowering code. 1//! AST -> `ItemTree` lowering code.
2 2
3use super::*; 3use std::{collections::hash_map::Entry, mem, sync::Arc};
4use crate::{ 4
5 attr::Attrs,
6 generics::{GenericParams, TypeParamData, TypeParamProvenance},
7};
8use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, HirFileId}; 5use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, HirFileId};
9use ra_arena::map::ArenaMap; 6use ra_arena::map::ArenaMap;
10use ra_syntax::{ 7use ra_syntax::{
@@ -12,7 +9,13 @@ use ra_syntax::{
12 SyntaxNode, 9 SyntaxNode,
13}; 10};
14use smallvec::SmallVec; 11use smallvec::SmallVec;
15use std::{collections::hash_map::Entry, mem, sync::Arc}; 12
13use crate::{
14 attr::Attrs,
15 generics::{GenericParams, TypeParamData, TypeParamProvenance},
16};
17
18use super::*;
16 19
17fn id<N: ItemTreeNode>(index: Idx<N>) -> FileItemTreeId<N> { 20fn id<N: ItemTreeNode>(index: Idx<N>) -> FileItemTreeId<N> {
18 FileItemTreeId { index, _p: PhantomData } 21 FileItemTreeId { index, _p: PhantomData }
@@ -70,19 +73,19 @@ impl Ctx {
70 self.tree.data_mut() 73 self.tree.data_mut()
71 } 74 }
72 75
73 fn lower_mod_item(&mut self, item: &ast::ModuleItem, inner: bool) -> Option<ModItems> { 76 fn lower_mod_item(&mut self, item: &ast::Item, inner: bool) -> Option<ModItems> {
74 assert!(inner || self.inner_items.is_empty()); 77 assert!(inner || self.inner_items.is_empty());
75 78
76 // Collect inner items for 1-to-1-lowered items. 79 // Collect inner items for 1-to-1-lowered items.
77 match item { 80 match item {
78 ast::ModuleItem::StructDef(_) 81 ast::Item::Struct(_)
79 | ast::ModuleItem::UnionDef(_) 82 | ast::Item::Union(_)
80 | ast::ModuleItem::EnumDef(_) 83 | ast::Item::Enum(_)
81 | ast::ModuleItem::FnDef(_) 84 | ast::Item::Fn(_)
82 | ast::ModuleItem::TypeAliasDef(_) 85 | ast::Item::TypeAlias(_)
83 | ast::ModuleItem::ConstDef(_) 86 | ast::Item::Const(_)
84 | ast::ModuleItem::StaticDef(_) 87 | ast::Item::Static(_)
85 | ast::ModuleItem::MacroCall(_) => { 88 | ast::Item::MacroCall(_) => {
86 // Skip this if we're already collecting inner items. We'll descend into all nodes 89 // Skip this if we're already collecting inner items. We'll descend into all nodes
87 // already. 90 // already.
88 if !inner { 91 if !inner {
@@ -92,34 +95,30 @@ impl Ctx {
92 95
93 // These are handled in their respective `lower_X` method (since we can't just blindly 96 // These are handled in their respective `lower_X` method (since we can't just blindly
94 // walk them). 97 // walk them).
95 ast::ModuleItem::TraitDef(_) 98 ast::Item::Trait(_) | ast::Item::Impl(_) | ast::Item::ExternBlock(_) => {}
96 | ast::ModuleItem::ImplDef(_)
97 | ast::ModuleItem::ExternBlock(_) => {}
98 99
99 // These don't have inner items. 100 // These don't have inner items.
100 ast::ModuleItem::Module(_) 101 ast::Item::Module(_) | ast::Item::ExternCrate(_) | ast::Item::Use(_) => {}
101 | ast::ModuleItem::ExternCrateItem(_)
102 | ast::ModuleItem::UseItem(_) => {}
103 }; 102 };
104 103
105 let attrs = Attrs::new(item, &self.hygiene); 104 let attrs = Attrs::new(item, &self.hygiene);
106 let items = match item { 105 let items = match item {
107 ast::ModuleItem::StructDef(ast) => self.lower_struct(ast).map(Into::into), 106 ast::Item::Struct(ast) => self.lower_struct(ast).map(Into::into),
108 ast::ModuleItem::UnionDef(ast) => self.lower_union(ast).map(Into::into), 107 ast::Item::Union(ast) => self.lower_union(ast).map(Into::into),
109 ast::ModuleItem::EnumDef(ast) => self.lower_enum(ast).map(Into::into), 108 ast::Item::Enum(ast) => self.lower_enum(ast).map(Into::into),
110 ast::ModuleItem::FnDef(ast) => self.lower_function(ast).map(Into::into), 109 ast::Item::Fn(ast) => self.lower_function(ast).map(Into::into),
111 ast::ModuleItem::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into), 110 ast::Item::TypeAlias(ast) => self.lower_type_alias(ast).map(Into::into),
112 ast::ModuleItem::StaticDef(ast) => self.lower_static(ast).map(Into::into), 111 ast::Item::Static(ast) => self.lower_static(ast).map(Into::into),
113 ast::ModuleItem::ConstDef(ast) => Some(self.lower_const(ast).into()), 112 ast::Item::Const(ast) => Some(self.lower_const(ast).into()),
114 ast::ModuleItem::Module(ast) => self.lower_module(ast).map(Into::into), 113 ast::Item::Module(ast) => self.lower_module(ast).map(Into::into),
115 ast::ModuleItem::TraitDef(ast) => self.lower_trait(ast).map(Into::into), 114 ast::Item::Trait(ast) => self.lower_trait(ast).map(Into::into),
116 ast::ModuleItem::ImplDef(ast) => self.lower_impl(ast).map(Into::into), 115 ast::Item::Impl(ast) => self.lower_impl(ast).map(Into::into),
117 ast::ModuleItem::UseItem(ast) => Some(ModItems( 116 ast::Item::Use(ast) => Some(ModItems(
118 self.lower_use(ast).into_iter().map(Into::into).collect::<SmallVec<_>>(), 117 self.lower_use(ast).into_iter().map(Into::into).collect::<SmallVec<_>>(),
119 )), 118 )),
120 ast::ModuleItem::ExternCrateItem(ast) => self.lower_extern_crate(ast).map(Into::into), 119 ast::Item::ExternCrate(ast) => self.lower_extern_crate(ast).map(Into::into),
121 ast::ModuleItem::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into), 120 ast::Item::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into),
122 ast::ModuleItem::ExternBlock(ast) => { 121 ast::Item::ExternBlock(ast) => {
123 Some(ModItems(self.lower_extern_block(ast).into_iter().collect::<SmallVec<_>>())) 122 Some(ModItems(self.lower_extern_block(ast).into_iter().collect::<SmallVec<_>>()))
124 } 123 }
125 }; 124 };
@@ -147,27 +146,26 @@ impl Ctx {
147 fn collect_inner_items(&mut self, container: &SyntaxNode) { 146 fn collect_inner_items(&mut self, container: &SyntaxNode) {
148 let forced_vis = self.forced_visibility.take(); 147 let forced_vis = self.forced_visibility.take();
149 let mut inner_items = mem::take(&mut self.tree.inner_items); 148 let mut inner_items = mem::take(&mut self.tree.inner_items);
150 inner_items.extend( 149 inner_items.extend(container.descendants().skip(1).filter_map(ast::Item::cast).filter_map(
151 container.descendants().skip(1).filter_map(ast::ModuleItem::cast).filter_map(|item| { 150 |item| {
152 let ast_id = self.source_ast_id_map.ast_id(&item); 151 let ast_id = self.source_ast_id_map.ast_id(&item);
153 Some((ast_id, self.lower_mod_item(&item, true)?.0)) 152 Some((ast_id, self.lower_mod_item(&item, true)?.0))
154 }), 153 },
155 ); 154 ));
156 self.tree.inner_items = inner_items; 155 self.tree.inner_items = inner_items;
157 self.forced_visibility = forced_vis; 156 self.forced_visibility = forced_vis;
158 } 157 }
159 158
160 fn lower_assoc_item(&mut self, item: &ast::ModuleItem) -> Option<AssocItem> { 159 fn lower_assoc_item(&mut self, item: &ast::AssocItem) -> Option<AssocItem> {
161 match item { 160 match item {
162 ast::ModuleItem::FnDef(ast) => self.lower_function(ast).map(Into::into), 161 ast::AssocItem::Fn(ast) => self.lower_function(ast).map(Into::into),
163 ast::ModuleItem::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into), 162 ast::AssocItem::TypeAlias(ast) => self.lower_type_alias(ast).map(Into::into),
164 ast::ModuleItem::ConstDef(ast) => Some(self.lower_const(ast).into()), 163 ast::AssocItem::Const(ast) => Some(self.lower_const(ast).into()),
165 ast::ModuleItem::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into), 164 ast::AssocItem::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into),
166 _ => None,
167 } 165 }
168 } 166 }
169 167
170 fn lower_struct(&mut self, strukt: &ast::StructDef) -> Option<FileItemTreeId<Struct>> { 168 fn lower_struct(&mut self, strukt: &ast::Struct) -> Option<FileItemTreeId<Struct>> {
171 let visibility = self.lower_visibility(strukt); 169 let visibility = self.lower_visibility(strukt);
172 let name = strukt.name()?.as_name(); 170 let name = strukt.name()?.as_name();
173 let generic_params = self.lower_generic_params(GenericsOwner::Struct, strukt); 171 let generic_params = self.lower_generic_params(GenericsOwner::Struct, strukt);
@@ -196,7 +194,7 @@ impl Ctx {
196 } 194 }
197 } 195 }
198 196
199 fn lower_record_fields(&mut self, fields: &ast::RecordFieldDefList) -> IdRange<Field> { 197 fn lower_record_fields(&mut self, fields: &ast::RecordFieldList) -> IdRange<Field> {
200 let start = self.next_field_idx(); 198 let start = self.next_field_idx();
201 for field in fields.fields() { 199 for field in fields.fields() {
202 if let Some(data) = self.lower_record_field(&field) { 200 if let Some(data) = self.lower_record_field(&field) {
@@ -208,15 +206,15 @@ impl Ctx {
208 IdRange::new(start..end) 206 IdRange::new(start..end)
209 } 207 }
210 208
211 fn lower_record_field(&mut self, field: &ast::RecordFieldDef) -> Option<Field> { 209 fn lower_record_field(&mut self, field: &ast::RecordField) -> Option<Field> {
212 let name = field.name()?.as_name(); 210 let name = field.name()?.as_name();
213 let visibility = self.lower_visibility(field); 211 let visibility = self.lower_visibility(field);
214 let type_ref = self.lower_type_ref_opt(field.ascribed_type()); 212 let type_ref = self.lower_type_ref_opt(field.ty());
215 let res = Field { name, type_ref, visibility }; 213 let res = Field { name, type_ref, visibility };
216 Some(res) 214 Some(res)
217 } 215 }
218 216
219 fn lower_tuple_fields(&mut self, fields: &ast::TupleFieldDefList) -> IdRange<Field> { 217 fn lower_tuple_fields(&mut self, fields: &ast::TupleFieldList) -> IdRange<Field> {
220 let start = self.next_field_idx(); 218 let start = self.next_field_idx();
221 for (i, field) in fields.fields().enumerate() { 219 for (i, field) in fields.fields().enumerate() {
222 let data = self.lower_tuple_field(i, &field); 220 let data = self.lower_tuple_field(i, &field);
@@ -227,22 +225,20 @@ impl Ctx {
227 IdRange::new(start..end) 225 IdRange::new(start..end)
228 } 226 }
229 227
230 fn lower_tuple_field(&mut self, idx: usize, field: &ast::TupleFieldDef) -> Field { 228 fn lower_tuple_field(&mut self, idx: usize, field: &ast::TupleField) -> Field {
231 let name = Name::new_tuple_field(idx); 229 let name = Name::new_tuple_field(idx);
232 let visibility = self.lower_visibility(field); 230 let visibility = self.lower_visibility(field);
233 let type_ref = self.lower_type_ref_opt(field.type_ref()); 231 let type_ref = self.lower_type_ref_opt(field.ty());
234 let res = Field { name, type_ref, visibility }; 232 let res = Field { name, type_ref, visibility };
235 res 233 res
236 } 234 }
237 235
238 fn lower_union(&mut self, union: &ast::UnionDef) -> Option<FileItemTreeId<Union>> { 236 fn lower_union(&mut self, union: &ast::Union) -> Option<FileItemTreeId<Union>> {
239 let visibility = self.lower_visibility(union); 237 let visibility = self.lower_visibility(union);
240 let name = union.name()?.as_name(); 238 let name = union.name()?.as_name();
241 let generic_params = self.lower_generic_params(GenericsOwner::Union, union); 239 let generic_params = self.lower_generic_params(GenericsOwner::Union, union);
242 let fields = match union.record_field_def_list() { 240 let fields = match union.record_field_list() {
243 Some(record_field_def_list) => { 241 Some(record_field_list) => self.lower_fields(&StructKind::Record(record_field_list)),
244 self.lower_fields(&StructKind::Record(record_field_def_list))
245 }
246 None => Fields::Record(IdRange::new(self.next_field_idx()..self.next_field_idx())), 242 None => Fields::Record(IdRange::new(self.next_field_idx()..self.next_field_idx())),
247 }; 243 };
248 let ast_id = self.source_ast_id_map.ast_id(union); 244 let ast_id = self.source_ast_id_map.ast_id(union);
@@ -250,7 +246,7 @@ impl Ctx {
250 Some(id(self.data().unions.alloc(res))) 246 Some(id(self.data().unions.alloc(res)))
251 } 247 }
252 248
253 fn lower_enum(&mut self, enum_: &ast::EnumDef) -> Option<FileItemTreeId<Enum>> { 249 fn lower_enum(&mut self, enum_: &ast::Enum) -> Option<FileItemTreeId<Enum>> {
254 let visibility = self.lower_visibility(enum_); 250 let visibility = self.lower_visibility(enum_);
255 let name = enum_.name()?.as_name(); 251 let name = enum_.name()?.as_name();
256 let generic_params = self.lower_generic_params(GenericsOwner::Enum, enum_); 252 let generic_params = self.lower_generic_params(GenericsOwner::Enum, enum_);
@@ -263,7 +259,7 @@ impl Ctx {
263 Some(id(self.data().enums.alloc(res))) 259 Some(id(self.data().enums.alloc(res)))
264 } 260 }
265 261
266 fn lower_variants(&mut self, variants: &ast::EnumVariantList) -> IdRange<Variant> { 262 fn lower_variants(&mut self, variants: &ast::VariantList) -> IdRange<Variant> {
267 let start = self.next_variant_idx(); 263 let start = self.next_variant_idx();
268 for variant in variants.variants() { 264 for variant in variants.variants() {
269 if let Some(data) = self.lower_variant(&variant) { 265 if let Some(data) = self.lower_variant(&variant) {
@@ -275,14 +271,14 @@ impl Ctx {
275 IdRange::new(start..end) 271 IdRange::new(start..end)
276 } 272 }
277 273
278 fn lower_variant(&mut self, variant: &ast::EnumVariant) -> Option<Variant> { 274 fn lower_variant(&mut self, variant: &ast::Variant) -> Option<Variant> {
279 let name = variant.name()?.as_name(); 275 let name = variant.name()?.as_name();
280 let fields = self.lower_fields(&variant.kind()); 276 let fields = self.lower_fields(&variant.kind());
281 let res = Variant { name, fields }; 277 let res = Variant { name, fields };
282 Some(res) 278 Some(res)
283 } 279 }
284 280
285 fn lower_function(&mut self, func: &ast::FnDef) -> Option<FileItemTreeId<Function>> { 281 fn lower_function(&mut self, func: &ast::Fn) -> Option<FileItemTreeId<Function>> {
286 let visibility = self.lower_visibility(func); 282 let visibility = self.lower_visibility(func);
287 let name = func.name()?.as_name(); 283 let name = func.name()?.as_name();
288 284
@@ -290,7 +286,7 @@ impl Ctx {
290 let mut has_self_param = false; 286 let mut has_self_param = false;
291 if let Some(param_list) = func.param_list() { 287 if let Some(param_list) = func.param_list() {
292 if let Some(self_param) = param_list.self_param() { 288 if let Some(self_param) = param_list.self_param() {
293 let self_type = match self_param.ascribed_type() { 289 let self_type = match self_param.ty() {
294 Some(type_ref) => TypeRef::from_ast(&self.body_ctx, type_ref), 290 Some(type_ref) => TypeRef::from_ast(&self.body_ctx, type_ref),
295 None => { 291 None => {
296 let self_type = TypeRef::Path(name![Self].into()); 292 let self_type = TypeRef::Path(name![Self].into());
@@ -309,7 +305,7 @@ impl Ctx {
309 has_self_param = true; 305 has_self_param = true;
310 } 306 }
311 for param in param_list.params() { 307 for param in param_list.params() {
312 let type_ref = TypeRef::from_ast_opt(&self.body_ctx, param.ascribed_type()); 308 let type_ref = TypeRef::from_ast_opt(&self.body_ctx, param.ty());
313 params.push(type_ref); 309 params.push(type_ref);
314 } 310 }
315 } 311 }
@@ -321,7 +317,7 @@ impl Ctx {
321 } 317 }
322 } 318 }
323 319
324 let ret_type = match func.ret_type().and_then(|rt| rt.type_ref()) { 320 let ret_type = match func.ret_type().and_then(|rt| rt.ty()) {
325 Some(type_ref) => TypeRef::from_ast(&self.body_ctx, type_ref), 321 Some(type_ref) => TypeRef::from_ast(&self.body_ctx, type_ref),
326 _ => TypeRef::unit(), 322 _ => TypeRef::unit(),
327 }; 323 };
@@ -353,10 +349,10 @@ impl Ctx {
353 349
354 fn lower_type_alias( 350 fn lower_type_alias(
355 &mut self, 351 &mut self,
356 type_alias: &ast::TypeAliasDef, 352 type_alias: &ast::TypeAlias,
357 ) -> Option<FileItemTreeId<TypeAlias>> { 353 ) -> Option<FileItemTreeId<TypeAlias>> {
358 let name = type_alias.name()?.as_name(); 354 let name = type_alias.name()?.as_name();
359 let type_ref = type_alias.type_ref().map(|it| self.lower_type_ref(&it)); 355 let type_ref = type_alias.ty().map(|it| self.lower_type_ref(&it));
360 let visibility = self.lower_visibility(type_alias); 356 let visibility = self.lower_visibility(type_alias);
361 let bounds = self.lower_type_bounds(type_alias); 357 let bounds = self.lower_type_bounds(type_alias);
362 let generic_params = self.lower_generic_params(GenericsOwner::TypeAlias, type_alias); 358 let generic_params = self.lower_generic_params(GenericsOwner::TypeAlias, type_alias);
@@ -372,9 +368,9 @@ impl Ctx {
372 Some(id(self.data().type_aliases.alloc(res))) 368 Some(id(self.data().type_aliases.alloc(res)))
373 } 369 }
374 370
375 fn lower_static(&mut self, static_: &ast::StaticDef) -> Option<FileItemTreeId<Static>> { 371 fn lower_static(&mut self, static_: &ast::Static) -> Option<FileItemTreeId<Static>> {
376 let name = static_.name()?.as_name(); 372 let name = static_.name()?.as_name();
377 let type_ref = self.lower_type_ref_opt(static_.ascribed_type()); 373 let type_ref = self.lower_type_ref_opt(static_.ty());
378 let visibility = self.lower_visibility(static_); 374 let visibility = self.lower_visibility(static_);
379 let mutable = static_.mut_token().is_some(); 375 let mutable = static_.mut_token().is_some();
380 let ast_id = self.source_ast_id_map.ast_id(static_); 376 let ast_id = self.source_ast_id_map.ast_id(static_);
@@ -382,9 +378,9 @@ impl Ctx {
382 Some(id(self.data().statics.alloc(res))) 378 Some(id(self.data().statics.alloc(res)))
383 } 379 }
384 380
385 fn lower_const(&mut self, konst: &ast::ConstDef) -> FileItemTreeId<Const> { 381 fn lower_const(&mut self, konst: &ast::Const) -> FileItemTreeId<Const> {
386 let name = konst.name().map(|it| it.as_name()); 382 let name = konst.name().map(|it| it.as_name());
387 let type_ref = self.lower_type_ref_opt(konst.ascribed_type()); 383 let type_ref = self.lower_type_ref_opt(konst.ty());
388 let visibility = self.lower_visibility(konst); 384 let visibility = self.lower_visibility(konst);
389 let ast_id = self.source_ast_id_map.ast_id(konst); 385 let ast_id = self.source_ast_id_map.ast_id(konst);
390 let res = Const { name, visibility, type_ref, ast_id }; 386 let res = Const { name, visibility, type_ref, ast_id };
@@ -417,15 +413,15 @@ impl Ctx {
417 Some(id(self.data().mods.alloc(res))) 413 Some(id(self.data().mods.alloc(res)))
418 } 414 }
419 415
420 fn lower_trait(&mut self, trait_def: &ast::TraitDef) -> Option<FileItemTreeId<Trait>> { 416 fn lower_trait(&mut self, trait_def: &ast::Trait) -> Option<FileItemTreeId<Trait>> {
421 let name = trait_def.name()?.as_name(); 417 let name = trait_def.name()?.as_name();
422 let visibility = self.lower_visibility(trait_def); 418 let visibility = self.lower_visibility(trait_def);
423 let generic_params = 419 let generic_params =
424 self.lower_generic_params_and_inner_items(GenericsOwner::Trait(trait_def), trait_def); 420 self.lower_generic_params_and_inner_items(GenericsOwner::Trait(trait_def), trait_def);
425 let auto = trait_def.auto_token().is_some(); 421 let auto = trait_def.auto_token().is_some();
426 let items = trait_def.item_list().map(|list| { 422 let items = trait_def.assoc_item_list().map(|list| {
427 self.with_inherited_visibility(visibility, |this| { 423 self.with_inherited_visibility(visibility, |this| {
428 list.items() 424 list.assoc_items()
429 .filter_map(|item| { 425 .filter_map(|item| {
430 let attrs = Attrs::new(&item, &this.hygiene); 426 let attrs = Attrs::new(&item, &this.hygiene);
431 this.collect_inner_items(item.syntax()); 427 this.collect_inner_items(item.syntax());
@@ -449,18 +445,18 @@ impl Ctx {
449 Some(id(self.data().traits.alloc(res))) 445 Some(id(self.data().traits.alloc(res)))
450 } 446 }
451 447
452 fn lower_impl(&mut self, impl_def: &ast::ImplDef) -> Option<FileItemTreeId<Impl>> { 448 fn lower_impl(&mut self, impl_def: &ast::Impl) -> Option<FileItemTreeId<Impl>> {
453 let generic_params = 449 let generic_params =
454 self.lower_generic_params_and_inner_items(GenericsOwner::Impl, impl_def); 450 self.lower_generic_params_and_inner_items(GenericsOwner::Impl, impl_def);
455 let target_trait = impl_def.target_trait().map(|tr| self.lower_type_ref(&tr)); 451 let target_trait = impl_def.trait_().map(|tr| self.lower_type_ref(&tr));
456 let target_type = self.lower_type_ref(&impl_def.target_type()?); 452 let target_type = self.lower_type_ref(&impl_def.self_ty()?);
457 let is_negative = impl_def.excl_token().is_some(); 453 let is_negative = impl_def.excl_token().is_some();
458 454
459 // We cannot use `assoc_items()` here as that does not include macro calls. 455 // We cannot use `assoc_items()` here as that does not include macro calls.
460 let items = impl_def 456 let items = impl_def
461 .item_list() 457 .assoc_item_list()
462 .into_iter() 458 .into_iter()
463 .flat_map(|it| it.items()) 459 .flat_map(|it| it.assoc_items())
464 .filter_map(|item| { 460 .filter_map(|item| {
465 self.collect_inner_items(item.syntax()); 461 self.collect_inner_items(item.syntax());
466 let assoc = self.lower_assoc_item(&item)?; 462 let assoc = self.lower_assoc_item(&item)?;
@@ -474,7 +470,7 @@ impl Ctx {
474 Some(id(self.data().impls.alloc(res))) 470 Some(id(self.data().impls.alloc(res)))
475 } 471 }
476 472
477 fn lower_use(&mut self, use_item: &ast::UseItem) -> Vec<FileItemTreeId<Import>> { 473 fn lower_use(&mut self, use_item: &ast::Use) -> Vec<FileItemTreeId<Import>> {
478 // FIXME: cfg_attr 474 // FIXME: cfg_attr
479 let is_prelude = use_item.has_atom_attr("prelude_import"); 475 let is_prelude = use_item.has_atom_attr("prelude_import");
480 let visibility = self.lower_visibility(use_item); 476 let visibility = self.lower_visibility(use_item);
@@ -503,10 +499,10 @@ impl Ctx {
503 499
504 fn lower_extern_crate( 500 fn lower_extern_crate(
505 &mut self, 501 &mut self,
506 extern_crate: &ast::ExternCrateItem, 502 extern_crate: &ast::ExternCrate,
507 ) -> Option<FileItemTreeId<ExternCrate>> { 503 ) -> Option<FileItemTreeId<ExternCrate>> {
508 let path = ModPath::from_name_ref(&extern_crate.name_ref()?); 504 let path = ModPath::from_name_ref(&extern_crate.name_ref()?);
509 let alias = extern_crate.alias().map(|a| { 505 let alias = extern_crate.rename().map(|a| {
510 a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) 506 a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias)
511 }); 507 });
512 let visibility = self.lower_visibility(extern_crate); 508 let visibility = self.lower_visibility(extern_crate);
@@ -552,15 +548,16 @@ impl Ctx {
552 self.collect_inner_items(item.syntax()); 548 self.collect_inner_items(item.syntax());
553 let attrs = Attrs::new(&item, &self.hygiene); 549 let attrs = Attrs::new(&item, &self.hygiene);
554 let id: ModItem = match item { 550 let id: ModItem = match item {
555 ast::ExternItem::FnDef(ast) => { 551 ast::ExternItem::Fn(ast) => {
556 let func = self.lower_function(&ast)?; 552 let func = self.lower_function(&ast)?;
557 self.data().functions[func.index].is_unsafe = true; 553 self.data().functions[func.index].is_unsafe = true;
558 func.into() 554 func.into()
559 } 555 }
560 ast::ExternItem::StaticDef(ast) => { 556 ast::ExternItem::Static(ast) => {
561 let statik = self.lower_static(&ast)?; 557 let statik = self.lower_static(&ast)?;
562 statik.into() 558 statik.into()
563 } 559 }
560 ast::ExternItem::MacroCall(_) => return None,
564 }; 561 };
565 self.add_attrs(id.into(), attrs); 562 self.add_attrs(id.into(), attrs);
566 Some(id) 563 Some(id)
@@ -573,10 +570,10 @@ impl Ctx {
573 fn lower_generic_params_and_inner_items( 570 fn lower_generic_params_and_inner_items(
574 &mut self, 571 &mut self,
575 owner: GenericsOwner<'_>, 572 owner: GenericsOwner<'_>,
576 node: &impl ast::TypeParamsOwner, 573 node: &impl ast::GenericParamsOwner,
577 ) -> GenericParamsId { 574 ) -> GenericParamsId {
578 // Generics are part of item headers and may contain inner items we need to collect. 575 // Generics are part of item headers and may contain inner items we need to collect.
579 if let Some(params) = node.type_param_list() { 576 if let Some(params) = node.generic_param_list() {
580 self.collect_inner_items(params.syntax()); 577 self.collect_inner_items(params.syntax());
581 } 578 }
582 if let Some(clause) = node.where_clause() { 579 if let Some(clause) = node.where_clause() {
@@ -589,7 +586,7 @@ impl Ctx {
589 fn lower_generic_params( 586 fn lower_generic_params(
590 &mut self, 587 &mut self,
591 owner: GenericsOwner<'_>, 588 owner: GenericsOwner<'_>,
592 node: &impl ast::TypeParamsOwner, 589 node: &impl ast::GenericParamsOwner,
593 ) -> GenericParamsId { 590 ) -> GenericParamsId {
594 let mut sm = &mut ArenaMap::default(); 591 let mut sm = &mut ArenaMap::default();
595 let mut generics = GenericParams::default(); 592 let mut generics = GenericParams::default();
@@ -651,10 +648,10 @@ impl Ctx {
651 self.data().vis.alloc(vis) 648 self.data().vis.alloc(vis)
652 } 649 }
653 650
654 fn lower_type_ref(&self, type_ref: &ast::TypeRef) -> TypeRef { 651 fn lower_type_ref(&self, type_ref: &ast::Type) -> TypeRef {
655 TypeRef::from_ast(&self.body_ctx, type_ref.clone()) 652 TypeRef::from_ast(&self.body_ctx, type_ref.clone())
656 } 653 }
657 fn lower_type_ref_opt(&self, type_ref: Option<ast::TypeRef>) -> TypeRef { 654 fn lower_type_ref_opt(&self, type_ref: Option<ast::Type>) -> TypeRef {
658 type_ref.map(|ty| self.lower_type_ref(&ty)).unwrap_or(TypeRef::Error) 655 type_ref.map(|ty| self.lower_type_ref(&ty)).unwrap_or(TypeRef::Error)
659 } 656 }
660 657
@@ -702,7 +699,7 @@ enum GenericsOwner<'a> {
702 Enum, 699 Enum,
703 Union, 700 Union,
704 /// The `TraitDef` is needed to fill the source map for the implicit `Self` parameter. 701 /// The `TraitDef` is needed to fill the source map for the implicit `Self` parameter.
705 Trait(&'a ast::TraitDef), 702 Trait(&'a ast::Trait),
706 TypeAlias, 703 TypeAlias,
707 Impl, 704 Impl,
708} 705}
diff --git a/crates/ra_hir_def/src/item_tree/tests.rs b/crates/ra_hir_def/src/item_tree/tests.rs
index f26982985..a81497fa8 100644
--- a/crates/ra_hir_def/src/item_tree/tests.rs
+++ b/crates/ra_hir_def/src/item_tree/tests.rs
@@ -21,7 +21,7 @@ fn test_inner_items(ra_fixture: &str) {
21 let mut outer_items = FxHashSet::default(); 21 let mut outer_items = FxHashSet::default();
22 let mut worklist = tree.top_level_items().to_vec(); 22 let mut worklist = tree.top_level_items().to_vec();
23 while let Some(item) = worklist.pop() { 23 while let Some(item) = worklist.pop() {
24 let node: ast::ModuleItem = match item { 24 let node: ast::Item = match item {
25 ModItem::Import(it) => tree.source(&db, InFile::new(file_id, it)).into(), 25 ModItem::Import(it) => tree.source(&db, InFile::new(file_id, it)).into(),
26 ModItem::ExternCrate(it) => tree.source(&db, InFile::new(file_id, it)).into(), 26 ModItem::ExternCrate(it) => tree.source(&db, InFile::new(file_id, it)).into(),
27 ModItem::Function(it) => tree.source(&db, InFile::new(file_id, it)).into(), 27 ModItem::Function(it) => tree.source(&db, InFile::new(file_id, it)).into(),
@@ -53,7 +53,7 @@ fn test_inner_items(ra_fixture: &str) {
53 53
54 // Now descend the root node and check that all `ast::ModuleItem`s are either recorded above, or 54 // Now descend the root node and check that all `ast::ModuleItem`s are either recorded above, or
55 // registered as inner items. 55 // registered as inner items.
56 for item in root.descendants().skip(1).filter_map(ast::ModuleItem::cast) { 56 for item in root.descendants().skip(1).filter_map(ast::Item::cast) {
57 if outer_items.contains(&item) { 57 if outer_items.contains(&item) {
58 continue; 58 continue;
59 } 59 }
@@ -228,31 +228,31 @@ fn smoke() {
228 228
229 top-level items: 229 top-level items:
230 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] 230 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }]
231 Import { path: ModPath { kind: Plain, segments: [Name(Text("a"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: false, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UseItem>(0) } 231 Import { path: ModPath { kind: Plain, segments: [Name(Text("a"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: false, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Use>(0) }
232 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] 232 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }]
233 Import { path: ModPath { kind: Plain, segments: [Name(Text("b"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: true, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UseItem>(0) } 233 Import { path: ModPath { kind: Plain, segments: [Name(Text("b"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: true, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Use>(0) }
234 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("ext_crate"))] }, input: None }]) }] 234 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("ext_crate"))] }, input: None }]) }]
235 ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ExternCrateItem>(1) } 235 ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ExternCrate>(1) }
236 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_trait"))] }, input: None }]) }] 236 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_trait"))] }, input: None }]) }]
237 Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [TypeAlias(Idx::<TypeAlias>(0)), Const(Idx::<Const>(0)), Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TraitDef>(2) } 237 Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [TypeAlias(Idx::<TypeAlias>(0)), Const(Idx::<Const>(0)), Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Trait>(2) }
238 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_ty"))] }, input: None }]) }] 238 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_ty"))] }, input: None }]) }]
239 > TypeAlias { name: Name(Text("AssocTy")), visibility: RawVisibilityId("pub(self)"), bounds: [Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Tr"))] }, generic_args: [Some(GenericArgs { args: [Type(Tuple([]))], has_self_type: false, bindings: [] })] })], generic_params: GenericParamsId(4294967295), type_ref: None, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TypeAliasDef>(8) } 239 > TypeAlias { name: Name(Text("AssocTy")), visibility: RawVisibilityId("pub(self)"), bounds: [Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Tr"))] }, generic_args: [Some(GenericArgs { args: [Type(Tuple([]))], has_self_type: false, bindings: [] })] })], generic_params: GenericParamsId(4294967295), type_ref: None, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TypeAlias>(8) }
240 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }] 240 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }]
241 > Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ConstDef>(9) } 241 > Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Const>(9) }
242 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_method"))] }, input: None }]) }] 242 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_method"))] }, input: None }]) }]
243 > Function { name: Name(Text("method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Shared)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(10) } 243 > Function { name: Name(Text("method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Shared)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(10) }
244 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_dfl_method"))] }, input: None }]) }] 244 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_dfl_method"))] }, input: None }]) }]
245 > Function { name: Name(Text("dfl_method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Mut)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(11) } 245 > Function { name: Name(Text("dfl_method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Mut)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(11) }
246 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct0"))] }, input: None }]) }] 246 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct0"))] }, input: None }]) }]
247 Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(3), kind: Unit } 247 Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(3), kind: Unit }
248 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct1"))] }, input: None }]) }] 248 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct1"))] }, input: None }]) }]
249 Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(IdRange::<ra_hir_def::item_tree::Field>(0..1)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(4), kind: Tuple } 249 Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(IdRange::<ra_hir_def::item_tree::Field>(0..1)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(4), kind: Tuple }
250 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct2"))] }, input: None }]) }] 250 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct2"))] }, input: None }]) }]
251 Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(1..2)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(5), kind: Record } 251 Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(1..2)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(5), kind: Record }
252 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("en"))] }, input: None }]) }] 252 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("en"))] }, input: None }]) }]
253 Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::<ra_hir_def::item_tree::Variant>(0..1), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::EnumDef>(6) } 253 Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::<ra_hir_def::item_tree::Variant>(0..1), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Enum>(6) }
254 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("un"))] }, input: None }]) }] 254 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("un"))] }, input: None }]) }]
255 Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(3..4)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UnionDef>(7) } 255 Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(3..4)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Union>(7) }
256 "##]], 256 "##]],
257 ); 257 );
258} 258}
@@ -274,13 +274,13 @@ fn simple_inner_items() {
274 inner attrs: Attrs { entries: None } 274 inner attrs: Attrs { entries: None }
275 275
276 top-level items: 276 top-level items:
277 Impl { generic_params: GenericParamsId(0), target_trait: Some(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("D"))] }, generic_args: [None] })), target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Response"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), is_negative: false, items: [Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) } 277 Impl { generic_params: GenericParamsId(0), target_trait: Some(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("D"))] }, generic_args: [None] })), target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Response"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), is_negative: false, items: [Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Impl>(0) }
278 > Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } 278 > Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
279 279
280 inner items: 280 inner items:
281 281
282 for AST FileAstId::<ra_syntax::ast::generated::nodes::ModuleItem>(2): 282 for AST FileAstId::<ra_syntax::ast::generated::nodes::Item>(2):
283 Function { name: Name(Text("end")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } 283 Function { name: Name(Text("end")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) }
284 284
285 "#]], 285 "#]],
286 ); 286 );
@@ -303,9 +303,9 @@ fn extern_attrs() {
303 303
304 top-level items: 304 top-level items:
305 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }] 305 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }]
306 Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } 306 Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
307 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }] 307 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }]
308 Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } 308 Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) }
309 "##]], 309 "##]],
310 ); 310 );
311} 311}
@@ -327,11 +327,11 @@ fn trait_attrs() {
327 327
328 top-level items: 328 top-level items:
329 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("trait_attr"))] }, input: None }]) }] 329 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("trait_attr"))] }, input: None }]) }]
330 Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TraitDef>(0) } 330 Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Trait>(0) }
331 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] 331 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }]
332 > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } 332 > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
333 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] 333 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }]
334 > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } 334 > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) }
335 "##]], 335 "##]],
336 ); 336 );
337} 337}
@@ -353,11 +353,11 @@ fn impl_attrs() {
353 353
354 top-level items: 354 top-level items:
355 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("impl_attr"))] }, input: None }]) }] 355 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("impl_attr"))] }, input: None }]) }]
356 Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Ty"))] }, generic_args: [None] }), is_negative: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) } 356 Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Ty"))] }, generic_args: [None] }), is_negative: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Impl>(0) }
357 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] 357 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }]
358 > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } 358 > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
359 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] 359 > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }]
360 > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } 360 > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) }
361 "##]], 361 "##]],
362 ); 362 );
363} 363}
@@ -408,13 +408,13 @@ fn inner_item_attrs() {
408 inner attrs: Attrs { entries: None } 408 inner attrs: Attrs { entries: None }
409 409
410 top-level items: 410 top-level items:
411 Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(0) } 411 Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(0) }
412 412
413 inner items: 413 inner items:
414 414
415 for AST FileAstId::<ra_syntax::ast::generated::nodes::ModuleItem>(1): 415 for AST FileAstId::<ra_syntax::ast::generated::nodes::Item>(1):
416 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_inner"))] }, input: None }]) }] 416 #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_inner"))] }, input: None }]) }]
417 Function { name: Name(Text("inner")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } 417 Function { name: Name(Text("inner")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
418 418
419 "##]], 419 "##]],
420 ); 420 );
@@ -432,7 +432,7 @@ fn assoc_item_macros() {
432 inner attrs: Attrs { entries: None } 432 inner attrs: Attrs { entries: None }
433 433
434 top-level items: 434 top-level items:
435 Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("S"))] }, generic_args: [None] }), is_negative: false, items: [MacroCall(Idx::<MacroCall>(0))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) } 435 Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("S"))] }, generic_args: [None] }), is_negative: false, items: [MacroCall(Idx::<MacroCall>(0))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Impl>(0) }
436 > MacroCall { name: None, path: ModPath { kind: Plain, segments: [Name(Text("items"))] }, is_export: false, is_local_inner: false, is_builtin: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::MacroCall>(1) } 436 > MacroCall { name: None, path: ModPath { kind: Plain, segments: [Name(Text("items"))] }, is_export: false, is_local_inner: false, is_builtin: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::MacroCall>(1) }
437 "#]], 437 "#]],
438 ); 438 );
diff --git a/crates/ra_hir_def/src/keys.rs b/crates/ra_hir_def/src/keys.rs
index a7349a21d..441bdbead 100644
--- a/crates/ra_hir_def/src/keys.rs
+++ b/crates/ra_hir_def/src/keys.rs
@@ -14,19 +14,19 @@ use crate::{
14 14
15pub type Key<K, V> = crate::dyn_map::Key<InFile<K>, V, AstPtrPolicy<K, V>>; 15pub type Key<K, V> = crate::dyn_map::Key<InFile<K>, V, AstPtrPolicy<K, V>>;
16 16
17pub const FUNCTION: Key<ast::FnDef, FunctionId> = Key::new(); 17pub const FUNCTION: Key<ast::Fn, FunctionId> = Key::new();
18pub const CONST: Key<ast::ConstDef, ConstId> = Key::new(); 18pub const CONST: Key<ast::Const, ConstId> = Key::new();
19pub const STATIC: Key<ast::StaticDef, StaticId> = Key::new(); 19pub const STATIC: Key<ast::Static, StaticId> = Key::new();
20pub const TYPE_ALIAS: Key<ast::TypeAliasDef, TypeAliasId> = Key::new(); 20pub const TYPE_ALIAS: Key<ast::TypeAlias, TypeAliasId> = Key::new();
21pub const IMPL: Key<ast::ImplDef, ImplId> = Key::new(); 21pub const IMPL: Key<ast::Impl, ImplId> = Key::new();
22pub const TRAIT: Key<ast::TraitDef, TraitId> = Key::new(); 22pub const TRAIT: Key<ast::Trait, TraitId> = Key::new();
23pub const STRUCT: Key<ast::StructDef, StructId> = Key::new(); 23pub const STRUCT: Key<ast::Struct, StructId> = Key::new();
24pub const UNION: Key<ast::UnionDef, UnionId> = Key::new(); 24pub const UNION: Key<ast::Union, UnionId> = Key::new();
25pub const ENUM: Key<ast::EnumDef, EnumId> = Key::new(); 25pub const ENUM: Key<ast::Enum, EnumId> = Key::new();
26 26
27pub const ENUM_VARIANT: Key<ast::EnumVariant, EnumVariantId> = Key::new(); 27pub const VARIANT: Key<ast::Variant, EnumVariantId> = Key::new();
28pub const TUPLE_FIELD: Key<ast::TupleFieldDef, FieldId> = Key::new(); 28pub const TUPLE_FIELD: Key<ast::TupleField, FieldId> = Key::new();
29pub const RECORD_FIELD: Key<ast::RecordFieldDef, FieldId> = Key::new(); 29pub const RECORD_FIELD: Key<ast::RecordField, FieldId> = Key::new();
30pub const TYPE_PARAM: Key<ast::TypeParam, TypeParamId> = Key::new(); 30pub const TYPE_PARAM: Key<ast::TypeParam, TypeParamId> = Key::new();
31 31
32pub const MACRO: Key<ast::MacroCall, MacroDefId> = Key::new(); 32pub const MACRO: Key<ast::MacroCall, MacroDefId> = Key::new();
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index 87000fe98..237b1038a 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -521,7 +521,7 @@ impl AsMacroCall for AstIdWithPath<ast::MacroCall> {
521 } 521 }
522} 522}
523 523
524impl AsMacroCall for AstIdWithPath<ast::ModuleItem> { 524impl AsMacroCall for AstIdWithPath<ast::Item> {
525 fn as_call_id( 525 fn as_call_id(
526 &self, 526 &self,
527 db: &dyn db::DefDatabase, 527 db: &dyn db::DefDatabase,
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index a030cab47..28b7a20c5 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -170,7 +170,7 @@ struct MacroDirective {
170#[derive(Clone, Debug, Eq, PartialEq)] 170#[derive(Clone, Debug, Eq, PartialEq)]
171struct DeriveDirective { 171struct DeriveDirective {
172 module_id: LocalModuleId, 172 module_id: LocalModuleId,
173 ast_id: AstIdWithPath<ast::ModuleItem>, 173 ast_id: AstIdWithPath<ast::Item>,
174} 174}
175 175
176struct DefData<'a> { 176struct DefData<'a> {
@@ -1100,7 +1100,7 @@ impl ModCollector<'_, '_> {
1100 res 1100 res
1101 } 1101 }
1102 1102
1103 fn collect_derives(&mut self, attrs: &Attrs, ast_id: FileAstId<ast::ModuleItem>) { 1103 fn collect_derives(&mut self, attrs: &Attrs, ast_id: FileAstId<ast::Item>) {
1104 for derive_subtree in attrs.by_key("derive").tt_values() { 1104 for derive_subtree in attrs.by_key("derive").tt_values() {
1105 // for #[derive(Copy, Clone)], `derive_subtree` is the `(Copy, Clone)` subtree 1105 // for #[derive(Copy, Clone)], `derive_subtree` is the `(Copy, Clone)` subtree
1106 for tt in &derive_subtree.token_trees { 1106 for tt in &derive_subtree.token_trees {
diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs
index 190d6d98d..cc1726e9e 100644
--- a/crates/ra_hir_def/src/path.rs
+++ b/crates/ra_hir_def/src/path.rs
@@ -67,7 +67,7 @@ impl ModPath {
67 67
68 /// Calls `cb` with all paths, represented by this use item. 68 /// Calls `cb` with all paths, represented by this use item.
69 pub(crate) fn expand_use_item( 69 pub(crate) fn expand_use_item(
70 item_src: InFile<ast::UseItem>, 70 item_src: InFile<ast::Use>,
71 hygiene: &Hygiene, 71 hygiene: &Hygiene,
72 mut cb: impl FnMut(ModPath, &ast::UseTree, /* is_glob */ bool, Option<ImportAlias>), 72 mut cb: impl FnMut(ModPath, &ast::UseTree, /* is_glob */ bool, Option<ImportAlias>),
73 ) { 73 ) {
@@ -258,7 +258,7 @@ impl<'a> PathSegments<'a> {
258} 258}
259 259
260impl GenericArgs { 260impl GenericArgs {
261 pub(crate) fn from_ast(lower_ctx: &LowerCtx, node: ast::TypeArgList) -> Option<GenericArgs> { 261 pub(crate) fn from_ast(lower_ctx: &LowerCtx, node: ast::GenericArgList) -> Option<GenericArgs> {
262 lower::lower_generic_args(lower_ctx, node) 262 lower::lower_generic_args(lower_ctx, node)
263 } 263 }
264 264
diff --git a/crates/ra_hir_def/src/path/lower.rs b/crates/ra_hir_def/src/path/lower.rs
index 6a0c019fd..d09fc66e4 100644
--- a/crates/ra_hir_def/src/path/lower.rs
+++ b/crates/ra_hir_def/src/path/lower.rs
@@ -9,7 +9,7 @@ use hir_expand::{
9 hygiene::Hygiene, 9 hygiene::Hygiene,
10 name::{name, AsName}, 10 name::{name, AsName},
11}; 11};
12use ra_syntax::ast::{self, AstNode, TypeAscriptionOwner, TypeBoundsOwner}; 12use ra_syntax::ast::{self, AstNode, TypeBoundsOwner};
13 13
14use super::AssociatedTypeBinding; 14use super::AssociatedTypeBinding;
15use crate::{ 15use crate::{
@@ -41,7 +41,7 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
41 match hygiene.name_ref_to_name(name_ref) { 41 match hygiene.name_ref_to_name(name_ref) {
42 Either::Left(name) => { 42 Either::Left(name) => {
43 let args = segment 43 let args = segment
44 .type_arg_list() 44 .generic_arg_list()
45 .and_then(|it| lower_generic_args(&ctx, it)) 45 .and_then(|it| lower_generic_args(&ctx, it))
46 .or_else(|| { 46 .or_else(|| {
47 lower_generic_args_from_fn_path( 47 lower_generic_args_from_fn_path(
@@ -148,33 +148,37 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
148 148
149pub(super) fn lower_generic_args( 149pub(super) fn lower_generic_args(
150 lower_ctx: &LowerCtx, 150 lower_ctx: &LowerCtx,
151 node: ast::TypeArgList, 151 node: ast::GenericArgList,
152) -> Option<GenericArgs> { 152) -> Option<GenericArgs> {
153 let mut args = Vec::new(); 153 let mut args = Vec::new();
154 for type_arg in node.type_args() {
155 let type_ref = TypeRef::from_ast_opt(lower_ctx, type_arg.type_ref());
156 args.push(GenericArg::Type(type_ref));
157 }
158 // lifetimes ignored for now
159 let mut bindings = Vec::new(); 154 let mut bindings = Vec::new();
160 for assoc_type_arg in node.assoc_type_args() { 155 for generic_arg in node.generic_args() {
161 let assoc_type_arg: ast::AssocTypeArg = assoc_type_arg; 156 match generic_arg {
162 if let Some(name_ref) = assoc_type_arg.name_ref() { 157 ast::GenericArg::TypeArg(type_arg) => {
163 let name = name_ref.as_name(); 158 let type_ref = TypeRef::from_ast_opt(lower_ctx, type_arg.ty());
164 let type_ref = assoc_type_arg.type_ref().map(|it| TypeRef::from_ast(lower_ctx, it)); 159 args.push(GenericArg::Type(type_ref));
165 let bounds = if let Some(l) = assoc_type_arg.type_bound_list() { 160 }
166 l.bounds().map(|it| TypeBound::from_ast(lower_ctx, it)).collect() 161 ast::GenericArg::AssocTypeArg(assoc_type_arg) => {
167 } else { 162 if let Some(name_ref) = assoc_type_arg.name_ref() {
168 Vec::new() 163 let name = name_ref.as_name();
169 }; 164 let type_ref = assoc_type_arg.ty().map(|it| TypeRef::from_ast(lower_ctx, it));
170 bindings.push(AssociatedTypeBinding { name, type_ref, bounds }); 165 let bounds = if let Some(l) = assoc_type_arg.type_bound_list() {
166 l.bounds().map(|it| TypeBound::from_ast(lower_ctx, it)).collect()
167 } else {
168 Vec::new()
169 };
170 bindings.push(AssociatedTypeBinding { name, type_ref, bounds });
171 }
172 }
173 // Lifetimes and constants are ignored for now.
174 ast::GenericArg::LifetimeArg(_) | ast::GenericArg::ConstArg(_) => (),
171 } 175 }
172 } 176 }
177
173 if args.is_empty() && bindings.is_empty() { 178 if args.is_empty() && bindings.is_empty() {
174 None 179 return None;
175 } else {
176 Some(GenericArgs { args, has_self_type: false, bindings })
177 } 180 }
181 Some(GenericArgs { args, has_self_type: false, bindings })
178} 182}
179 183
180/// Collect `GenericArgs` from the parts of a fn-like path, i.e. `Fn(X, Y) 184/// Collect `GenericArgs` from the parts of a fn-like path, i.e. `Fn(X, Y)
@@ -189,14 +193,14 @@ fn lower_generic_args_from_fn_path(
189 if let Some(params) = params { 193 if let Some(params) = params {
190 let mut param_types = Vec::new(); 194 let mut param_types = Vec::new();
191 for param in params.params() { 195 for param in params.params() {
192 let type_ref = TypeRef::from_ast_opt(&ctx, param.ascribed_type()); 196 let type_ref = TypeRef::from_ast_opt(&ctx, param.ty());
193 param_types.push(type_ref); 197 param_types.push(type_ref);
194 } 198 }
195 let arg = GenericArg::Type(TypeRef::Tuple(param_types)); 199 let arg = GenericArg::Type(TypeRef::Tuple(param_types));
196 args.push(arg); 200 args.push(arg);
197 } 201 }
198 if let Some(ret_type) = ret_type { 202 if let Some(ret_type) = ret_type {
199 let type_ref = TypeRef::from_ast_opt(&ctx, ret_type.type_ref()); 203 let type_ref = TypeRef::from_ast_opt(&ctx, ret_type.ty());
200 bindings.push(AssociatedTypeBinding { 204 bindings.push(AssociatedTypeBinding {
201 name: name![Output], 205 name: name![Output],
202 type_ref: Some(type_ref), 206 type_ref: Some(type_ref),
diff --git a/crates/ra_hir_def/src/path/lower/lower_use.rs b/crates/ra_hir_def/src/path/lower/lower_use.rs
index 7cc655487..794be45e8 100644
--- a/crates/ra_hir_def/src/path/lower/lower_use.rs
+++ b/crates/ra_hir_def/src/path/lower/lower_use.rs
@@ -31,7 +31,7 @@ pub(crate) fn lower_use_tree(
31 lower_use_tree(prefix.clone(), child_tree, hygiene, cb); 31 lower_use_tree(prefix.clone(), child_tree, hygiene, cb);
32 } 32 }
33 } else { 33 } else {
34 let alias = tree.alias().map(|a| { 34 let alias = tree.rename().map(|a| {
35 a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) 35 a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias)
36 }); 36 });
37 let is_glob = tree.star_token().is_some(); 37 let is_glob = tree.star_token().is_some();
diff --git a/crates/ra_hir_def/src/type_ref.rs b/crates/ra_hir_def/src/type_ref.rs
index e90b2a0b9..6f7884ffe 100644
--- a/crates/ra_hir_def/src/type_ref.rs
+++ b/crates/ra_hir_def/src/type_ref.rs
@@ -1,7 +1,6 @@
1//! HIR for references to types. Paths in these are not yet resolved. They can 1//! HIR for references to types. Paths in these are not yet resolved. They can
2//! be directly created from an ast::TypeRef, without further queries. 2//! be directly created from an ast::TypeRef, without further queries.
3 3use ra_syntax::ast::{self};
4use ra_syntax::ast::{self, TypeAscriptionOwner, TypeBoundsOwner};
5 4
6use crate::{body::LowerCtx, path::Path}; 5use crate::{body::LowerCtx, path::Path};
7 6
@@ -80,14 +79,14 @@ pub enum TypeBound {
80 79
81impl TypeRef { 80impl TypeRef {
82 /// Converts an `ast::TypeRef` to a `hir::TypeRef`. 81 /// Converts an `ast::TypeRef` to a `hir::TypeRef`.
83 pub(crate) fn from_ast(ctx: &LowerCtx, node: ast::TypeRef) -> Self { 82 pub(crate) fn from_ast(ctx: &LowerCtx, node: ast::Type) -> Self {
84 match node { 83 match node {
85 ast::TypeRef::ParenType(inner) => TypeRef::from_ast_opt(&ctx, inner.type_ref()), 84 ast::Type::ParenType(inner) => TypeRef::from_ast_opt(&ctx, inner.ty()),
86 ast::TypeRef::TupleType(inner) => { 85 ast::Type::TupleType(inner) => {
87 TypeRef::Tuple(inner.fields().map(|it| TypeRef::from_ast(ctx, it)).collect()) 86 TypeRef::Tuple(inner.fields().map(|it| TypeRef::from_ast(ctx, it)).collect())
88 } 87 }
89 ast::TypeRef::NeverType(..) => TypeRef::Never, 88 ast::Type::NeverType(..) => TypeRef::Never,
90 ast::TypeRef::PathType(inner) => { 89 ast::Type::PathType(inner) => {
91 // FIXME: Use `Path::from_src` 90 // FIXME: Use `Path::from_src`
92 inner 91 inner
93 .path() 92 .path()
@@ -95,27 +94,27 @@ impl TypeRef {
95 .map(TypeRef::Path) 94 .map(TypeRef::Path)
96 .unwrap_or(TypeRef::Error) 95 .unwrap_or(TypeRef::Error)
97 } 96 }
98 ast::TypeRef::PointerType(inner) => { 97 ast::Type::PtrType(inner) => {
99 let inner_ty = TypeRef::from_ast_opt(&ctx, inner.type_ref()); 98 let inner_ty = TypeRef::from_ast_opt(&ctx, inner.ty());
100 let mutability = Mutability::from_mutable(inner.mut_token().is_some()); 99 let mutability = Mutability::from_mutable(inner.mut_token().is_some());
101 TypeRef::RawPtr(Box::new(inner_ty), mutability) 100 TypeRef::RawPtr(Box::new(inner_ty), mutability)
102 } 101 }
103 ast::TypeRef::ArrayType(inner) => { 102 ast::Type::ArrayType(inner) => {
104 TypeRef::Array(Box::new(TypeRef::from_ast_opt(&ctx, inner.type_ref()))) 103 TypeRef::Array(Box::new(TypeRef::from_ast_opt(&ctx, inner.ty())))
105 } 104 }
106 ast::TypeRef::SliceType(inner) => { 105 ast::Type::SliceType(inner) => {
107 TypeRef::Slice(Box::new(TypeRef::from_ast_opt(&ctx, inner.type_ref()))) 106 TypeRef::Slice(Box::new(TypeRef::from_ast_opt(&ctx, inner.ty())))
108 } 107 }
109 ast::TypeRef::ReferenceType(inner) => { 108 ast::Type::RefType(inner) => {
110 let inner_ty = TypeRef::from_ast_opt(&ctx, inner.type_ref()); 109 let inner_ty = TypeRef::from_ast_opt(&ctx, inner.ty());
111 let mutability = Mutability::from_mutable(inner.mut_token().is_some()); 110 let mutability = Mutability::from_mutable(inner.mut_token().is_some());
112 TypeRef::Reference(Box::new(inner_ty), mutability) 111 TypeRef::Reference(Box::new(inner_ty), mutability)
113 } 112 }
114 ast::TypeRef::PlaceholderType(_inner) => TypeRef::Placeholder, 113 ast::Type::InferType(_inner) => TypeRef::Placeholder,
115 ast::TypeRef::FnPointerType(inner) => { 114 ast::Type::FnPtrType(inner) => {
116 let ret_ty = inner 115 let ret_ty = inner
117 .ret_type() 116 .ret_type()
118 .and_then(|rt| rt.type_ref()) 117 .and_then(|rt| rt.ty())
119 .map(|it| TypeRef::from_ast(ctx, it)) 118 .map(|it| TypeRef::from_ast(ctx, it))
120 .unwrap_or_else(|| TypeRef::Tuple(Vec::new())); 119 .unwrap_or_else(|| TypeRef::Tuple(Vec::new()));
121 let mut is_varargs = false; 120 let mut is_varargs = false;
@@ -124,10 +123,7 @@ impl TypeRef {
124 is_varargs = param.dotdotdot_token().is_some(); 123 is_varargs = param.dotdotdot_token().is_some();
125 } 124 }
126 125
127 pl.params() 126 pl.params().map(|p| p.ty()).map(|it| TypeRef::from_ast_opt(&ctx, it)).collect()
128 .map(|p| p.ascribed_type())
129 .map(|it| TypeRef::from_ast_opt(&ctx, it))
130 .collect()
131 } else { 127 } else {
132 Vec::new() 128 Vec::new()
133 }; 129 };
@@ -135,17 +131,17 @@ impl TypeRef {
135 TypeRef::Fn(params, is_varargs) 131 TypeRef::Fn(params, is_varargs)
136 } 132 }
137 // for types are close enough for our purposes to the inner type for now... 133 // for types are close enough for our purposes to the inner type for now...
138 ast::TypeRef::ForType(inner) => TypeRef::from_ast_opt(&ctx, inner.type_ref()), 134 ast::Type::ForType(inner) => TypeRef::from_ast_opt(&ctx, inner.ty()),
139 ast::TypeRef::ImplTraitType(inner) => { 135 ast::Type::ImplTraitType(inner) => {
140 TypeRef::ImplTrait(type_bounds_from_ast(ctx, inner.type_bound_list())) 136 TypeRef::ImplTrait(type_bounds_from_ast(ctx, inner.type_bound_list()))
141 } 137 }
142 ast::TypeRef::DynTraitType(inner) => { 138 ast::Type::DynTraitType(inner) => {
143 TypeRef::DynTrait(type_bounds_from_ast(ctx, inner.type_bound_list())) 139 TypeRef::DynTrait(type_bounds_from_ast(ctx, inner.type_bound_list()))
144 } 140 }
145 } 141 }
146 } 142 }
147 143
148 pub(crate) fn from_ast_opt(ctx: &LowerCtx, node: Option<ast::TypeRef>) -> Self { 144 pub(crate) fn from_ast_opt(ctx: &LowerCtx, node: Option<ast::Type>) -> Self {
149 if let Some(node) = node { 145 if let Some(node) = node {
150 TypeRef::from_ast(ctx, node) 146 TypeRef::from_ast(ctx, node)
151 } else { 147 } else {
diff --git a/crates/ra_hir_expand/src/ast_id_map.rs b/crates/ra_hir_expand/src/ast_id_map.rs
index f4d31526a..8bfe1b4ba 100644
--- a/crates/ra_hir_expand/src/ast_id_map.rs
+++ b/crates/ra_hir_expand/src/ast_id_map.rs
@@ -73,7 +73,7 @@ impl AstIdMap {
73 // change parent's id. This means that, say, adding a new function to a 73 // change parent's id. This means that, say, adding a new function to a
74 // trait does not change ids of top-level items, which helps caching. 74 // trait does not change ids of top-level items, which helps caching.
75 bfs(node, |it| { 75 bfs(node, |it| {
76 if let Some(module_item) = ast::ModuleItem::cast(it) { 76 if let Some(module_item) = ast::Item::cast(it) {
77 res.alloc(module_item.syntax()); 77 res.alloc(module_item.syntax());
78 } 78 }
79 }); 79 });
diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs
index f2d664863..69fa907cb 100644
--- a/crates/ra_hir_expand/src/builtin_derive.rs
+++ b/crates/ra_hir_expand/src/builtin_derive.rs
@@ -4,7 +4,7 @@ use log::debug;
4 4
5use ra_parser::FragmentKind; 5use ra_parser::FragmentKind;
6use ra_syntax::{ 6use ra_syntax::{
7 ast::{self, AstNode, ModuleItemOwner, NameOwner, TypeParamsOwner}, 7 ast::{self, AstNode, GenericParamsOwner, ModuleItemOwner, NameOwner},
8 match_ast, 8 match_ast,
9}; 9};
10 10
@@ -72,9 +72,9 @@ fn parse_adt(tt: &tt::Subtree) -> Result<BasicAdtInfo, mbe::ExpandError> {
72 let node = item.syntax(); 72 let node = item.syntax();
73 let (name, params) = match_ast! { 73 let (name, params) = match_ast! {
74 match node { 74 match node {
75 ast::StructDef(it) => (it.name(), it.type_param_list()), 75 ast::Struct(it) => (it.name(), it.generic_param_list()),
76 ast::EnumDef(it) => (it.name(), it.type_param_list()), 76 ast::Enum(it) => (it.name(), it.generic_param_list()),
77 ast::UnionDef(it) => (it.name(), it.type_param_list()), 77 ast::Union(it) => (it.name(), it.generic_param_list()),
78 _ => { 78 _ => {
79 debug!("unexpected node is {:?}", node); 79 debug!("unexpected node is {:?}", node);
80 return Err(mbe::ExpandError::ConversionError) 80 return Err(mbe::ExpandError::ConversionError)
@@ -276,7 +276,7 @@ mod tests {
276 let file_id = file_pos.file_id; 276 let file_id = file_pos.file_id;
277 let parsed = db.parse(file_id); 277 let parsed = db.parse(file_id);
278 let items: Vec<_> = 278 let items: Vec<_> =
279 parsed.syntax_node().descendants().filter_map(ast::ModuleItem::cast).collect(); 279 parsed.syntax_node().descendants().filter_map(ast::Item::cast).collect();
280 280
281 let ast_id_map = db.ast_id_map(file_id.into()); 281 let ast_id_map = db.ast_id_map(file_id.into());
282 282
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs
index e0ad1567f..f3b7cd492 100644
--- a/crates/ra_hir_expand/src/db.rs
+++ b/crates/ra_hir_expand/src/db.rs
@@ -379,14 +379,14 @@ fn to_fragment_kind(db: &dyn AstDatabase, id: MacroCallId) -> FragmentKind {
379 379
380 FOR_EXPR => FragmentKind::Expr, 380 FOR_EXPR => FragmentKind::Expr,
381 PATH_EXPR => FragmentKind::Expr, 381 PATH_EXPR => FragmentKind::Expr,
382 LAMBDA_EXPR => FragmentKind::Expr, 382 CLOSURE_EXPR => FragmentKind::Expr,
383 CONDITION => FragmentKind::Expr, 383 CONDITION => FragmentKind::Expr,
384 BREAK_EXPR => FragmentKind::Expr, 384 BREAK_EXPR => FragmentKind::Expr,
385 RETURN_EXPR => FragmentKind::Expr, 385 RETURN_EXPR => FragmentKind::Expr,
386 MATCH_EXPR => FragmentKind::Expr, 386 MATCH_EXPR => FragmentKind::Expr,
387 MATCH_ARM => FragmentKind::Expr, 387 MATCH_ARM => FragmentKind::Expr,
388 MATCH_GUARD => FragmentKind::Expr, 388 MATCH_GUARD => FragmentKind::Expr,
389 RECORD_FIELD => FragmentKind::Expr, 389 RECORD_EXPR_FIELD => FragmentKind::Expr,
390 CALL_EXPR => FragmentKind::Expr, 390 CALL_EXPR => FragmentKind::Expr,
391 INDEX_EXPR => FragmentKind::Expr, 391 INDEX_EXPR => FragmentKind::Expr,
392 METHOD_CALL_EXPR => FragmentKind::Expr, 392 METHOD_CALL_EXPR => FragmentKind::Expr,
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs
index d9e31ac20..2e8d63691 100644
--- a/crates/ra_hir_expand/src/lib.rs
+++ b/crates/ra_hir_expand/src/lib.rs
@@ -159,7 +159,7 @@ impl HirFileId {
159 } 159 }
160 160
161 /// Indicate it is macro file generated for builtin derive 161 /// Indicate it is macro file generated for builtin derive
162 pub fn is_builtin_derive(&self, db: &dyn db::AstDatabase) -> Option<InFile<ast::ModuleItem>> { 162 pub fn is_builtin_derive(&self, db: &dyn db::AstDatabase) -> Option<InFile<ast::Item>> {
163 match self.0 { 163 match self.0 {
164 HirFileIdRepr::FileId(_) => None, 164 HirFileIdRepr::FileId(_) => None,
165 HirFileIdRepr::MacroFile(macro_file) => { 165 HirFileIdRepr::MacroFile(macro_file) => {
@@ -174,7 +174,7 @@ impl HirFileId {
174 MacroDefKind::BuiltInDerive(_) => loc.kind.node(db), 174 MacroDefKind::BuiltInDerive(_) => loc.kind.node(db),
175 _ => return None, 175 _ => return None,
176 }; 176 };
177 Some(item.with_value(ast::ModuleItem::cast(item.value.clone())?)) 177 Some(item.with_value(ast::Item::cast(item.value.clone())?))
178 } 178 }
179 } 179 }
180 } 180 }
@@ -258,7 +258,7 @@ pub struct MacroCallLoc {
258#[derive(Debug, Clone, PartialEq, Eq, Hash)] 258#[derive(Debug, Clone, PartialEq, Eq, Hash)]
259pub enum MacroCallKind { 259pub enum MacroCallKind {
260 FnLike(AstId<ast::MacroCall>), 260 FnLike(AstId<ast::MacroCall>),
261 Attr(AstId<ast::ModuleItem>, String), 261 Attr(AstId<ast::Item>, String),
262} 262}
263 263
264impl MacroCallKind { 264impl MacroCallKind {
diff --git a/crates/ra_hir_expand/src/proc_macro.rs b/crates/ra_hir_expand/src/proc_macro.rs
index 04c026004..2c0ec41d2 100644
--- a/crates/ra_hir_expand/src/proc_macro.rs
+++ b/crates/ra_hir_expand/src/proc_macro.rs
@@ -101,7 +101,7 @@ fn remove_derive_attrs(tt: &tt::Subtree) -> Option<tt::Subtree> {
101} 101}
102 102
103#[cfg(test)] 103#[cfg(test)]
104mod test { 104mod tests {
105 use super::*; 105 use super::*;
106 use test_utils::assert_eq_text; 106 use test_utils::assert_eq_text;
107 107
diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml
index 7242e2cb6..83397d579 100644
--- a/crates/ra_hir_ty/Cargo.toml
+++ b/crates/ra_hir_ty/Cargo.toml
@@ -28,9 +28,9 @@ test_utils = { path = "../test_utils" }
28 28
29scoped-tls = "1" 29scoped-tls = "1"
30 30
31chalk-solve = { version = "0.18.0" } 31chalk-solve = { version = "0.21.0" }
32chalk-ir = { version = "0.18.0" } 32chalk-ir = { version = "0.21.0" }
33chalk-recursive = { version = "0.18.0" } 33chalk-recursive = { version = "0.21.0" }
34 34
35[dev-dependencies] 35[dev-dependencies]
36expect = { path = "../expect" } 36expect = { path = "../expect" }
diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs
index 885abbaf2..977c0525b 100644
--- a/crates/ra_hir_ty/src/diagnostics.rs
+++ b/crates/ra_hir_ty/src/diagnostics.rs
@@ -29,7 +29,7 @@ pub fn validate_body(db: &dyn HirDatabase, owner: DefWithBodyId, sink: &mut Diag
29#[derive(Debug)] 29#[derive(Debug)]
30pub struct NoSuchField { 30pub struct NoSuchField {
31 pub file: HirFileId, 31 pub file: HirFileId,
32 pub field: AstPtr<ast::RecordField>, 32 pub field: AstPtr<ast::RecordExprField>,
33} 33}
34 34
35impl Diagnostic for NoSuchField { 35impl Diagnostic for NoSuchField {
@@ -47,19 +47,19 @@ impl Diagnostic for NoSuchField {
47} 47}
48 48
49impl AstDiagnostic for NoSuchField { 49impl AstDiagnostic for NoSuchField {
50 type AST = ast::RecordField; 50 type AST = ast::RecordExprField;
51 51
52 fn ast(&self, db: &dyn AstDatabase) -> Self::AST { 52 fn ast(&self, db: &dyn AstDatabase) -> Self::AST {
53 let root = db.parse_or_expand(self.source().file_id).unwrap(); 53 let root = db.parse_or_expand(self.source().file_id).unwrap();
54 let node = self.source().value.to_node(&root); 54 let node = self.source().value.to_node(&root);
55 ast::RecordField::cast(node).unwrap() 55 ast::RecordExprField::cast(node).unwrap()
56 } 56 }
57} 57}
58 58
59#[derive(Debug)] 59#[derive(Debug)]
60pub struct MissingFields { 60pub struct MissingFields {
61 pub file: HirFileId, 61 pub file: HirFileId,
62 pub field_list: AstPtr<ast::RecordFieldList>, 62 pub field_list: AstPtr<ast::RecordExprFieldList>,
63 pub missed_fields: Vec<Name>, 63 pub missed_fields: Vec<Name>,
64} 64}
65 65
@@ -80,19 +80,19 @@ impl Diagnostic for MissingFields {
80} 80}
81 81
82impl AstDiagnostic for MissingFields { 82impl AstDiagnostic for MissingFields {
83 type AST = ast::RecordFieldList; 83 type AST = ast::RecordExprFieldList;
84 84
85 fn ast(&self, db: &dyn AstDatabase) -> Self::AST { 85 fn ast(&self, db: &dyn AstDatabase) -> Self::AST {
86 let root = db.parse_or_expand(self.source().file_id).unwrap(); 86 let root = db.parse_or_expand(self.source().file_id).unwrap();
87 let node = self.source().value.to_node(&root); 87 let node = self.source().value.to_node(&root);
88 ast::RecordFieldList::cast(node).unwrap() 88 ast::RecordExprFieldList::cast(node).unwrap()
89 } 89 }
90} 90}
91 91
92#[derive(Debug)] 92#[derive(Debug)]
93pub struct MissingPatFields { 93pub struct MissingPatFields {
94 pub file: HirFileId, 94 pub file: HirFileId,
95 pub field_list: AstPtr<ast::RecordFieldPatList>, 95 pub field_list: AstPtr<ast::RecordPatFieldList>,
96 pub missed_fields: Vec<Name>, 96 pub missed_fields: Vec<Name>,
97} 97}
98 98
diff --git a/crates/ra_hir_ty/src/diagnostics/expr.rs b/crates/ra_hir_ty/src/diagnostics/expr.rs
index fd930eab1..95bbf2d95 100644
--- a/crates/ra_hir_ty/src/diagnostics/expr.rs
+++ b/crates/ra_hir_ty/src/diagnostics/expr.rs
@@ -100,8 +100,8 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
100 100
101 if let Ok(source_ptr) = source_map.expr_syntax(id) { 101 if let Ok(source_ptr) = source_map.expr_syntax(id) {
102 let root = source_ptr.file_syntax(db.upcast()); 102 let root = source_ptr.file_syntax(db.upcast());
103 if let ast::Expr::RecordLit(record_lit) = &source_ptr.value.to_node(&root) { 103 if let ast::Expr::RecordExpr(record_lit) = &source_ptr.value.to_node(&root) {
104 if let Some(field_list) = record_lit.record_field_list() { 104 if let Some(field_list) = record_lit.record_expr_field_list() {
105 let variant_data = variant_data(db.upcast(), variant_def); 105 let variant_data = variant_data(db.upcast(), variant_def);
106 let missed_fields = missed_fields 106 let missed_fields = missed_fields
107 .into_iter() 107 .into_iter()
@@ -131,7 +131,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
131 if let Some(expr) = source_ptr.value.as_ref().left() { 131 if let Some(expr) = source_ptr.value.as_ref().left() {
132 let root = source_ptr.file_syntax(db.upcast()); 132 let root = source_ptr.file_syntax(db.upcast());
133 if let ast::Pat::RecordPat(record_pat) = expr.to_node(&root) { 133 if let ast::Pat::RecordPat(record_pat) = expr.to_node(&root) {
134 if let Some(field_list) = record_pat.record_field_pat_list() { 134 if let Some(field_list) = record_pat.record_pat_field_list() {
135 let variant_data = variant_data(db.upcast(), variant_def); 135 let variant_data = variant_data(db.upcast(), variant_def);
136 let missed_fields = missed_fields 136 let missed_fields = missed_fields
137 .into_iter() 137 .into_iter()
diff --git a/crates/ra_hir_ty/src/diagnostics/unsafe_check.rs b/crates/ra_hir_ty/src/diagnostics/unsafe_check.rs
index 5cc76bdce..61ffbf5d1 100644
--- a/crates/ra_hir_ty/src/diagnostics/unsafe_check.rs
+++ b/crates/ra_hir_ty/src/diagnostics/unsafe_check.rs
@@ -6,6 +6,7 @@ use std::sync::Arc;
6use hir_def::{ 6use hir_def::{
7 body::Body, 7 body::Body,
8 expr::{Expr, ExprId, UnaryOp}, 8 expr::{Expr, ExprId, UnaryOp},
9 resolver::{resolver_for_expr, ResolveValueResult, ValueNs},
9 DefWithBodyId, 10 DefWithBodyId,
10}; 11};
11use hir_expand::diagnostics::DiagnosticSink; 12use hir_expand::diagnostics::DiagnosticSink;
@@ -70,7 +71,7 @@ pub fn unsafe_expressions(
70) -> Vec<UnsafeExpr> { 71) -> Vec<UnsafeExpr> {
71 let mut unsafe_exprs = vec![]; 72 let mut unsafe_exprs = vec![];
72 let body = db.body(def); 73 let body = db.body(def);
73 walk_unsafe(&mut unsafe_exprs, db, infer, &body, body.body_expr, false); 74 walk_unsafe(&mut unsafe_exprs, db, infer, def, &body, body.body_expr, false);
74 75
75 unsafe_exprs 76 unsafe_exprs
76} 77}
@@ -79,6 +80,7 @@ fn walk_unsafe(
79 unsafe_exprs: &mut Vec<UnsafeExpr>, 80 unsafe_exprs: &mut Vec<UnsafeExpr>,
80 db: &dyn HirDatabase, 81 db: &dyn HirDatabase,
81 infer: &InferenceResult, 82 infer: &InferenceResult,
83 def: DefWithBodyId,
82 body: &Body, 84 body: &Body,
83 current: ExprId, 85 current: ExprId,
84 inside_unsafe_block: bool, 86 inside_unsafe_block: bool,
@@ -97,6 +99,15 @@ fn walk_unsafe(
97 } 99 }
98 } 100 }
99 } 101 }
102 Expr::Path(path) => {
103 let resolver = resolver_for_expr(db.upcast(), def, current);
104 let value_or_partial = resolver.resolve_path_in_value_ns(db.upcast(), path.mod_path());
105 if let Some(ResolveValueResult::ValueNs(ValueNs::StaticId(id))) = value_or_partial {
106 if db.static_data(id).mutable {
107 unsafe_exprs.push(UnsafeExpr { expr: current, inside_unsafe_block });
108 }
109 }
110 }
100 Expr::MethodCall { .. } => { 111 Expr::MethodCall { .. } => {
101 if infer 112 if infer
102 .method_resolution(current) 113 .method_resolution(current)
@@ -112,13 +123,13 @@ fn walk_unsafe(
112 } 123 }
113 } 124 }
114 Expr::Unsafe { body: child } => { 125 Expr::Unsafe { body: child } => {
115 return walk_unsafe(unsafe_exprs, db, infer, body, *child, true); 126 return walk_unsafe(unsafe_exprs, db, infer, def, body, *child, true);
116 } 127 }
117 _ => {} 128 _ => {}
118 } 129 }
119 130
120 expr.walk_child_exprs(|child| { 131 expr.walk_child_exprs(|child| {
121 walk_unsafe(unsafe_exprs, db, infer, body, child, inside_unsafe_block); 132 walk_unsafe(unsafe_exprs, db, infer, def, body, child, inside_unsafe_block);
122 }); 133 });
123} 134}
124 135
@@ -170,4 +181,25 @@ fn main() {
170"#, 181"#,
171 ); 182 );
172 } 183 }
184
185 #[test]
186 fn missing_unsafe_diagnostic_with_static_mut() {
187 check_diagnostics(
188 r#"
189struct Ty {
190 a: u8,
191}
192
193static mut static_mut: Ty = Ty { a: 0 };
194
195fn main() {
196 let x = static_mut.a;
197 //^^^^^^^^^^ This operation is unsafe and requires an unsafe function or block
198 unsafe {
199 let x = static_mut.a;
200 }
201}
202"#,
203 );
204 }
173} 205}
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs
index 28f32a0a4..3d12039a6 100644
--- a/crates/ra_hir_ty/src/infer.rs
+++ b/crates/ra_hir_ty/src/infer.rs
@@ -440,6 +440,12 @@ impl<'a> InferenceContext<'a> {
440 let ty = self.insert_type_vars(ty.subst(&substs)); 440 let ty = self.insert_type_vars(ty.subst(&substs));
441 forbid_unresolved_segments((ty, Some(strukt.into())), unresolved) 441 forbid_unresolved_segments((ty, Some(strukt.into())), unresolved)
442 } 442 }
443 TypeNs::AdtId(AdtId::UnionId(u)) => {
444 let substs = Ty::substs_from_path(&ctx, path, u.into(), true);
445 let ty = self.db.ty(u.into());
446 let ty = self.insert_type_vars(ty.subst(&substs));
447 forbid_unresolved_segments((ty, Some(u.into())), unresolved)
448 }
443 TypeNs::EnumVariantId(var) => { 449 TypeNs::EnumVariantId(var) => {
444 let substs = Ty::substs_from_path(&ctx, path, var.into(), true); 450 let substs = Ty::substs_from_path(&ctx, path, var.into(), true);
445 let ty = self.db.ty(var.parent.into()); 451 let ty = self.db.ty(var.parent.into());
@@ -490,10 +496,7 @@ impl<'a> InferenceContext<'a> {
490 // FIXME potentially resolve assoc type 496 // FIXME potentially resolve assoc type
491 (Ty::Unknown, None) 497 (Ty::Unknown, None)
492 } 498 }
493 TypeNs::AdtId(AdtId::EnumId(_)) 499 TypeNs::AdtId(AdtId::EnumId(_)) | TypeNs::BuiltinType(_) | TypeNs::TraitId(_) => {
494 | TypeNs::AdtId(AdtId::UnionId(_))
495 | TypeNs::BuiltinType(_)
496 | TypeNs::TraitId(_) => {
497 // FIXME diagnostic 500 // FIXME diagnostic
498 (Ty::Unknown, None) 501 (Ty::Unknown, None)
499 } 502 }
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs
index 1eacc6f95..7638f167b 100644
--- a/crates/ra_hir_ty/src/lower.rs
+++ b/crates/ra_hir_ty/src/lower.rs
@@ -518,6 +518,7 @@ impl Ty {
518 let (segment, generic_def) = match resolved { 518 let (segment, generic_def) = match resolved {
519 ValueTyDefId::FunctionId(it) => (last, Some(it.into())), 519 ValueTyDefId::FunctionId(it) => (last, Some(it.into())),
520 ValueTyDefId::StructId(it) => (last, Some(it.into())), 520 ValueTyDefId::StructId(it) => (last, Some(it.into())),
521 ValueTyDefId::UnionId(it) => (last, Some(it.into())),
521 ValueTyDefId::ConstId(it) => (last, Some(it.into())), 522 ValueTyDefId::ConstId(it) => (last, Some(it.into())),
522 ValueTyDefId::StaticId(_) => (last, None), 523 ValueTyDefId::StaticId(_) => (last, None),
523 ValueTyDefId::EnumVariantId(var) => { 524 ValueTyDefId::EnumVariantId(var) => {
@@ -1148,11 +1149,12 @@ impl_from!(BuiltinType, AdtId(StructId, EnumId, UnionId), TypeAliasId for TyDefI
1148pub enum ValueTyDefId { 1149pub enum ValueTyDefId {
1149 FunctionId(FunctionId), 1150 FunctionId(FunctionId),
1150 StructId(StructId), 1151 StructId(StructId),
1152 UnionId(UnionId),
1151 EnumVariantId(EnumVariantId), 1153 EnumVariantId(EnumVariantId),
1152 ConstId(ConstId), 1154 ConstId(ConstId),
1153 StaticId(StaticId), 1155 StaticId(StaticId),
1154} 1156}
1155impl_from!(FunctionId, StructId, EnumVariantId, ConstId, StaticId for ValueTyDefId); 1157impl_from!(FunctionId, StructId, UnionId, EnumVariantId, ConstId, StaticId for ValueTyDefId);
1156 1158
1157/// Build the declared type of an item. This depends on the namespace; e.g. for 1159/// Build the declared type of an item. This depends on the namespace; e.g. for
1158/// `struct Foo(usize)`, we have two types: The type of the struct itself, and 1160/// `struct Foo(usize)`, we have two types: The type of the struct itself, and
@@ -1179,6 +1181,7 @@ pub(crate) fn value_ty_query(db: &dyn HirDatabase, def: ValueTyDefId) -> Binders
1179 match def { 1181 match def {
1180 ValueTyDefId::FunctionId(it) => type_for_fn(db, it), 1182 ValueTyDefId::FunctionId(it) => type_for_fn(db, it),
1181 ValueTyDefId::StructId(it) => type_for_struct_constructor(db, it), 1183 ValueTyDefId::StructId(it) => type_for_struct_constructor(db, it),
1184 ValueTyDefId::UnionId(it) => type_for_adt(db, it.into()),
1182 ValueTyDefId::EnumVariantId(it) => type_for_enum_variant_constructor(db, it), 1185 ValueTyDefId::EnumVariantId(it) => type_for_enum_variant_constructor(db, it),
1183 ValueTyDefId::ConstId(it) => type_for_const(db, it), 1186 ValueTyDefId::ConstId(it) => type_for_const(db, it),
1184 ValueTyDefId::StaticId(it) => type_for_static(db, it), 1187 ValueTyDefId::StaticId(it) => type_for_static(db, it),
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs
index 45bc14c37..016e689ff 100644
--- a/crates/ra_hir_ty/src/tests.rs
+++ b/crates/ra_hir_ty/src/tests.rs
@@ -81,7 +81,7 @@ fn check_types_impl(ra_fixture: &str, display_source: bool) {
81fn type_at_range(db: &TestDB, pos: FileRange) -> Ty { 81fn type_at_range(db: &TestDB, pos: FileRange) -> Ty {
82 let file = db.parse(pos.file_id).ok().unwrap(); 82 let file = db.parse(pos.file_id).ok().unwrap();
83 let expr = algo::find_node_at_range::<ast::Expr>(file.syntax(), pos.range).unwrap(); 83 let expr = algo::find_node_at_range::<ast::Expr>(file.syntax(), pos.range).unwrap();
84 let fn_def = expr.syntax().ancestors().find_map(ast::FnDef::cast).unwrap(); 84 let fn_def = expr.syntax().ancestors().find_map(ast::Fn::cast).unwrap();
85 let module = db.module_for_file(pos.file_id); 85 let module = db.module_for_file(pos.file_id);
86 let func = *module.child_by_source(db)[keys::FUNCTION] 86 let func = *module.child_by_source(db)[keys::FUNCTION]
87 .get(&InFile::new(pos.file_id.into(), fn_def)) 87 .get(&InFile::new(pos.file_id.into(), fn_def))
diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs
index 3fd7d5cd4..5a7cf9455 100644
--- a/crates/ra_hir_ty/src/tests/simple.rs
+++ b/crates/ra_hir_ty/src/tests/simple.rs
@@ -334,16 +334,44 @@ fn infer_union() {
334 bar: f32, 334 bar: f32,
335 } 335 }
336 336
337 fn test() {
338 let u = MyUnion { foo: 0 };
339 unsafe { baz(u); }
340 let u = MyUnion { bar: 0.0 };
341 unsafe { baz(u); }
342 }
343
337 unsafe fn baz(u: MyUnion) { 344 unsafe fn baz(u: MyUnion) {
338 let inner = u.foo; 345 let inner = u.foo;
346 let inner = u.bar;
339 } 347 }
340 "#, 348 "#,
341 expect![[r#" 349 expect![[r#"
342 61..62 'u': MyUnion 350 57..172 '{ ...); } }': ()
343 73..99 '{ ...foo; }': () 351 67..68 'u': MyUnion
344 83..88 'inner': u32 352 71..89 'MyUnio...o: 0 }': MyUnion
345 91..92 'u': MyUnion 353 86..87 '0': u32
346 91..96 'u.foo': u32 354 95..113 'unsafe...(u); }': ()
355 102..113 '{ baz(u); }': ()
356 104..107 'baz': fn baz(MyUnion)
357 104..110 'baz(u)': ()
358 108..109 'u': MyUnion
359 122..123 'u': MyUnion
360 126..146 'MyUnio... 0.0 }': MyUnion
361 141..144 '0.0': f32
362 152..170 'unsafe...(u); }': ()
363 159..170 '{ baz(u); }': ()
364 161..164 'baz': fn baz(MyUnion)
365 161..167 'baz(u)': ()
366 165..166 'u': MyUnion
367 188..189 'u': MyUnion
368 200..249 '{ ...bar; }': ()
369 210..215 'inner': u32
370 218..219 'u': MyUnion
371 218..223 'u.foo': u32
372 233..238 'inner': f32
373 241..242 'u': MyUnion
374 241..246 'u.bar': f32
347 "#]], 375 "#]],
348 ); 376 );
349} 377}
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 5298dbecf..1c7065364 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -183,6 +183,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
183 .collect(), 183 .collect(),
184 1, 184 1,
185 ), 185 ),
186 where_clauses: make_binders(vec![], 0),
186 }; 187 };
187 let num_vars = datas.num_binders; 188 let num_vars = datas.num_binders;
188 Arc::new(OpaqueTyDatum { opaque_ty_id: id, bound: make_binders(bound, num_vars) }) 189 Arc::new(OpaqueTyDatum { opaque_ty_id: id, bound: make_binders(bound, num_vars) })
@@ -193,15 +194,6 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
193 Ty::Unknown.to_chalk(self.db) 194 Ty::Unknown.to_chalk(self.db)
194 } 195 }
195 196
196 fn force_impl_for(
197 &self,
198 _well_known: rust_ir::WellKnownTrait,
199 _ty: &chalk_ir::TyData<Interner>,
200 ) -> Option<bool> {
201 // this method is mostly for rustc
202 None
203 }
204
205 fn is_object_safe(&self, _trait_id: chalk_ir::TraitId<Interner>) -> bool { 197 fn is_object_safe(&self, _trait_id: chalk_ir::TraitId<Interner>) -> bool {
206 // FIXME: implement actual object safety 198 // FIXME: implement actual object safety
207 true 199 true
@@ -547,8 +539,13 @@ pub(crate) fn fn_def_datum_query(
547 ), 539 ),
548 where_clauses, 540 where_clauses,
549 }; 541 };
550 let datum = 542 let datum = FnDefDatum {
551 FnDefDatum { id: fn_def_id, binders: make_binders(bound, sig.num_binders), abi: () }; 543 id: fn_def_id,
544 abi: (),
545 safety: chalk_ir::Safety::Safe,
546 variadic: sig.value.is_varargs,
547 binders: make_binders(bound, sig.num_binders),
548 };
552 Arc::new(datum) 549 Arc::new(datum)
553} 550}
554 551
diff --git a/crates/ra_hir_ty/src/traits/chalk/mapping.rs b/crates/ra_hir_ty/src/traits/chalk/mapping.rs
index 09d8347ca..b3e92993d 100644
--- a/crates/ra_hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/ra_hir_ty/src/traits/chalk/mapping.rs
@@ -30,11 +30,16 @@ impl ToChalk for Ty {
30 Ty::Apply(apply_ty) => match apply_ty.ctor { 30 Ty::Apply(apply_ty) => match apply_ty.ctor {
31 TypeCtor::Ref(m) => ref_to_chalk(db, m, apply_ty.parameters), 31 TypeCtor::Ref(m) => ref_to_chalk(db, m, apply_ty.parameters),
32 TypeCtor::Array => array_to_chalk(db, apply_ty.parameters), 32 TypeCtor::Array => array_to_chalk(db, apply_ty.parameters),
33 TypeCtor::FnPtr { num_args: _, is_varargs: _ } => { 33 TypeCtor::FnPtr { num_args: _, is_varargs } => {
34 // FIXME: handle is_varargs
35 let substitution = apply_ty.parameters.to_chalk(db).shifted_in(&Interner); 34 let substitution = apply_ty.parameters.to_chalk(db).shifted_in(&Interner);
36 chalk_ir::TyData::Function(chalk_ir::Fn { num_binders: 0, substitution }) 35 chalk_ir::TyData::Function(chalk_ir::FnPointer {
37 .intern(&Interner) 36 num_binders: 0,
37 abi: (),
38 safety: chalk_ir::Safety::Safe,
39 variadic: is_varargs,
40 substitution,
41 })
42 .intern(&Interner)
38 } 43 }
39 _ => { 44 _ => {
40 let name = apply_ty.ctor.to_chalk(db); 45 let name = apply_ty.ctor.to_chalk(db);
@@ -118,7 +123,12 @@ impl ToChalk for Ty {
118 let parameters = from_chalk(db, opaque_ty.substitution); 123 let parameters = from_chalk(db, opaque_ty.substitution);
119 Ty::Opaque(OpaqueTy { opaque_ty_id: impl_trait_id, parameters }) 124 Ty::Opaque(OpaqueTy { opaque_ty_id: impl_trait_id, parameters })
120 } 125 }
121 chalk_ir::TyData::Function(chalk_ir::Fn { num_binders, substitution }) => { 126 chalk_ir::TyData::Function(chalk_ir::FnPointer {
127 num_binders,
128 variadic,
129 substitution,
130 ..
131 }) => {
122 assert_eq!(num_binders, 0); 132 assert_eq!(num_binders, 0);
123 let parameters: Substs = from_chalk( 133 let parameters: Substs = from_chalk(
124 db, 134 db,
@@ -127,7 +137,7 @@ impl ToChalk for Ty {
127 Ty::Apply(ApplicationTy { 137 Ty::Apply(ApplicationTy {
128 ctor: TypeCtor::FnPtr { 138 ctor: TypeCtor::FnPtr {
129 num_args: (parameters.len() - 1) as u16, 139 num_args: (parameters.len() - 1) as u16,
130 is_varargs: false, 140 is_varargs: variadic,
131 }, 141 },
132 parameters, 142 parameters,
133 }) 143 })
diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml
index 6f8107491..f4181c4eb 100644
--- a/crates/ra_ide/Cargo.toml
+++ b/crates/ra_ide/Cargo.toml
@@ -17,7 +17,7 @@ indexmap = "1.3.2"
17itertools = "0.9.0" 17itertools = "0.9.0"
18log = "0.4.8" 18log = "0.4.8"
19rustc-hash = "1.1.0" 19rustc-hash = "1.1.0"
20rand = { version = "0.7.3", features = ["small_rng"] } 20oorandom = "11.1.2"
21 21
22stdx = { path = "../stdx" } 22stdx = { path = "../stdx" }
23 23
diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs
index c28af8ab3..1fcaf4a32 100644
--- a/crates/ra_ide/src/call_hierarchy.rs
+++ b/crates/ra_ide/src/call_hierarchy.rs
@@ -59,7 +59,7 @@ pub(crate) fn incoming_calls(db: &RootDatabase, position: FilePosition) -> Optio
59 if let Some(nav) = syntax.ancestors().find_map(|node| { 59 if let Some(nav) = syntax.ancestors().find_map(|node| {
60 match_ast! { 60 match_ast! {
61 match node { 61 match node {
62 ast::FnDef(it) => { 62 ast::Fn(it) => {
63 let def = sema.to_def(&it)?; 63 let def = sema.to_def(&it)?;
64 Some(def.to_nav(sema.db)) 64 Some(def.to_nav(sema.db))
65 }, 65 },
@@ -181,8 +181,8 @@ fn caller() {
181 call<|>ee(); 181 call<|>ee();
182} 182}
183"#, 183"#,
184 "callee FN_DEF FileId(1) 0..14 3..9", 184 "callee FN FileId(1) 0..14 3..9",
185 &["caller FN_DEF FileId(1) 15..44 18..24 : [33..39]"], 185 &["caller FN FileId(1) 15..44 18..24 : [33..39]"],
186 &[], 186 &[],
187 ); 187 );
188 } 188 }
@@ -197,8 +197,8 @@ fn caller() {
197 callee(); 197 callee();
198} 198}
199"#, 199"#,
200 "callee FN_DEF FileId(1) 0..14 3..9", 200 "callee FN FileId(1) 0..14 3..9",
201 &["caller FN_DEF FileId(1) 15..44 18..24 : [33..39]"], 201 &["caller FN FileId(1) 15..44 18..24 : [33..39]"],
202 &[], 202 &[],
203 ); 203 );
204 } 204 }
@@ -214,8 +214,8 @@ fn caller() {
214 callee(); 214 callee();
215} 215}
216"#, 216"#,
217 "callee FN_DEF FileId(1) 0..14 3..9", 217 "callee FN FileId(1) 0..14 3..9",
218 &["caller FN_DEF FileId(1) 15..58 18..24 : [33..39, 47..53]"], 218 &["caller FN FileId(1) 15..58 18..24 : [33..39, 47..53]"],
219 &[], 219 &[],
220 ); 220 );
221 } 221 }
@@ -234,10 +234,10 @@ fn caller2() {
234 callee(); 234 callee();
235} 235}
236"#, 236"#,
237 "callee FN_DEF FileId(1) 0..14 3..9", 237 "callee FN FileId(1) 0..14 3..9",
238 &[ 238 &[
239 "caller1 FN_DEF FileId(1) 15..45 18..25 : [34..40]", 239 "caller1 FN FileId(1) 15..45 18..25 : [34..40]",
240 "caller2 FN_DEF FileId(1) 47..77 50..57 : [66..72]", 240 "caller2 FN FileId(1) 47..77 50..57 : [66..72]",
241 ], 241 ],
242 &[], 242 &[],
243 ); 243 );
@@ -263,10 +263,10 @@ mod tests {
263 } 263 }
264} 264}
265"#, 265"#,
266 "callee FN_DEF FileId(1) 0..14 3..9", 266 "callee FN FileId(1) 0..14 3..9",
267 &[ 267 &[
268 "caller1 FN_DEF FileId(1) 15..45 18..25 : [34..40]", 268 "caller1 FN FileId(1) 15..45 18..25 : [34..40]",
269 "test_caller FN_DEF FileId(1) 95..149 110..121 : [134..140]", 269 "test_caller FN FileId(1) 95..149 110..121 : [134..140]",
270 ], 270 ],
271 &[], 271 &[],
272 ); 272 );
@@ -287,8 +287,8 @@ fn caller() {
287//- /foo/mod.rs 287//- /foo/mod.rs
288pub fn callee() {} 288pub fn callee() {}
289"#, 289"#,
290 "callee FN_DEF FileId(2) 0..18 7..13", 290 "callee FN FileId(2) 0..18 7..13",
291 &["caller FN_DEF FileId(1) 27..56 30..36 : [45..51]"], 291 &["caller FN FileId(1) 27..56 30..36 : [45..51]"],
292 &[], 292 &[],
293 ); 293 );
294 } 294 }
@@ -304,9 +304,9 @@ fn call<|>er() {
304 callee(); 304 callee();
305} 305}
306"#, 306"#,
307 "caller FN_DEF FileId(1) 15..58 18..24", 307 "caller FN FileId(1) 15..58 18..24",
308 &[], 308 &[],
309 &["callee FN_DEF FileId(1) 0..14 3..9 : [33..39, 47..53]"], 309 &["callee FN FileId(1) 0..14 3..9 : [33..39, 47..53]"],
310 ); 310 );
311 } 311 }
312 312
@@ -325,9 +325,9 @@ fn call<|>er() {
325//- /foo/mod.rs 325//- /foo/mod.rs
326pub fn callee() {} 326pub fn callee() {}
327"#, 327"#,
328 "caller FN_DEF FileId(1) 27..56 30..36", 328 "caller FN FileId(1) 27..56 30..36",
329 &[], 329 &[],
330 &["callee FN_DEF FileId(2) 0..18 7..13 : [45..51]"], 330 &["callee FN FileId(2) 0..18 7..13 : [45..51]"],
331 ); 331 );
332 } 332 }
333 333
@@ -348,9 +348,9 @@ fn caller3() {
348 348
349} 349}
350"#, 350"#,
351 "caller2 FN_DEF FileId(1) 33..64 36..43", 351 "caller2 FN FileId(1) 33..64 36..43",
352 &["caller1 FN_DEF FileId(1) 0..31 3..10 : [19..26]"], 352 &["caller1 FN FileId(1) 0..31 3..10 : [19..26]"],
353 &["caller3 FN_DEF FileId(1) 66..83 69..76 : [52..59]"], 353 &["caller3 FN FileId(1) 66..83 69..76 : [52..59]"],
354 ); 354 );
355 } 355 }
356 356
@@ -368,9 +368,9 @@ fn main() {
368 a<|>() 368 a<|>()
369} 369}
370"#, 370"#,
371 "a FN_DEF FileId(1) 0..18 3..4", 371 "a FN FileId(1) 0..18 3..4",
372 &["main FN_DEF FileId(1) 31..52 34..38 : [47..48]"], 372 &["main FN FileId(1) 31..52 34..38 : [47..48]"],
373 &["b FN_DEF FileId(1) 20..29 23..24 : [13..14]"], 373 &["b FN FileId(1) 20..29 23..24 : [13..14]"],
374 ); 374 );
375 375
376 check_hierarchy( 376 check_hierarchy(
@@ -385,8 +385,8 @@ fn main() {
385 a() 385 a()
386} 386}
387"#, 387"#,
388 "b FN_DEF FileId(1) 20..29 23..24", 388 "b FN FileId(1) 20..29 23..24",
389 &["a FN_DEF FileId(1) 0..18 3..4 : [13..14]"], 389 &["a FN FileId(1) 0..18 3..4 : [13..14]"],
390 &[], 390 &[],
391 ); 391 );
392 } 392 }
diff --git a/crates/ra_ide/src/completion/complete_attribute.rs b/crates/ra_ide/src/completion/complete_attribute.rs
index 7a4274645..089d806d8 100644
--- a/crates/ra_ide/src/completion/complete_attribute.rs
+++ b/crates/ra_ide/src/completion/complete_attribute.rs
@@ -16,25 +16,23 @@ use crate::completion::UNSTABLE_FEATURE_DESCRIPTOR;
16 16
17pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { 17pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
18 let attribute = ctx.attribute_under_caret.as_ref()?; 18 let attribute = ctx.attribute_under_caret.as_ref()?;
19 match (attribute.path(), attribute.input()) { 19 match (attribute.path(), attribute.token_tree()) {
20 (Some(path), Some(ast::AttrInput::TokenTree(token_tree))) 20 (Some(path), Some(token_tree)) if path.to_string() == "derive" => {
21 if path.to_string() == "derive" =>
22 {
23 complete_derive(acc, ctx, token_tree) 21 complete_derive(acc, ctx, token_tree)
24 } 22 }
25 (Some(path), Some(ast::AttrInput::TokenTree(token_tree))) 23 (Some(path), Some(token_tree))
26 if path.to_string() == "feature" => 24 if path.to_string() == "feature" =>
27 { 25 {
28 complete_lint(acc, ctx, token_tree, UNSTABLE_FEATURE_DESCRIPTOR); 26 complete_lint(acc, ctx, token_tree, UNSTABLE_FEATURE_DESCRIPTOR);
29 } 27 }
30 (Some(path), Some(ast::AttrInput::TokenTree(token_tree))) 28 (Some(path), Some(token_tree))
31 if ["allow", "warn", "deny", "forbid"] 29 if ["allow", "warn", "deny", "forbid"]
32 .iter() 30 .iter()
33 .any(|lint_level| lint_level == &path.to_string()) => 31 .any(|lint_level| lint_level == &path.to_string()) =>
34 { 32 {
35 complete_lint(acc, ctx, token_tree, DEFAULT_LINT_COMPLETIONS) 33 complete_lint(acc, ctx, token_tree, DEFAULT_LINT_COMPLETIONS)
36 } 34 }
37 (_, Some(ast::AttrInput::TokenTree(_token_tree))) => {} 35 (_, Some(_token_tree)) => {}
38 _ => complete_attribute_start(acc, ctx, attribute), 36 _ => complete_attribute_start(acc, ctx, attribute),
39 } 37 }
40 Some(()) 38 Some(())
diff --git a/crates/ra_ide/src/completion/complete_fn_param.rs b/crates/ra_ide/src/completion/complete_fn_param.rs
index db2abb4f1..406334257 100644
--- a/crates/ra_ide/src/completion/complete_fn_param.rs
+++ b/crates/ra_ide/src/completion/complete_fn_param.rs
@@ -18,26 +18,36 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
18 } 18 }
19 19
20 let mut params = FxHashMap::default(); 20 let mut params = FxHashMap::default();
21 let me = ctx.token.ancestors().find_map(ast::FnDef::cast); 21
22 let me = ctx.token.ancestors().find_map(ast::Fn::cast);
23 let mut process_fn = |func: ast::Fn| {
24 if Some(&func) == me.as_ref() {
25 return;
26 }
27 func.param_list().into_iter().flat_map(|it| it.params()).for_each(|param| {
28 let text = param.syntax().text().to_string();
29 params.entry(text).or_insert(param);
30 })
31 };
32
22 for node in ctx.token.parent().ancestors() { 33 for node in ctx.token.parent().ancestors() {
23 let items = match_ast! { 34 match_ast! {
24 match node { 35 match node {
25 ast::SourceFile(it) => it.items(), 36 ast::SourceFile(it) => it.items().filter_map(|item| match item {
26 ast::ItemList(it) => it.items(), 37 ast::Item::Fn(it) => Some(it),
38 _ => None,
39 }).for_each(&mut process_fn),
40 ast::ItemList(it) => it.items().filter_map(|item| match item {
41 ast::Item::Fn(it) => Some(it),
42 _ => None,
43 }).for_each(&mut process_fn),
44 ast::AssocItemList(it) => it.assoc_items().filter_map(|item| match item {
45 ast::AssocItem::Fn(it) => Some(it),
46 _ => None,
47 }).for_each(&mut process_fn),
27 _ => continue, 48 _ => continue,
28 } 49 }
29 }; 50 };
30 for item in items {
31 if let ast::ModuleItem::FnDef(func) = item {
32 if Some(&func) == me.as_ref() {
33 continue;
34 }
35 func.param_list().into_iter().flat_map(|it| it.params()).for_each(|param| {
36 let text = param.syntax().text().to_string();
37 params.entry(text).or_insert(param);
38 })
39 }
40 }
41 } 51 }
42 52
43 params 53 params
diff --git a/crates/ra_ide/src/completion/complete_keyword.rs b/crates/ra_ide/src/completion/complete_keyword.rs
index fcdaeef49..b62064797 100644
--- a/crates/ra_ide/src/completion/complete_keyword.rs
+++ b/crates/ra_ide/src/completion/complete_keyword.rs
@@ -66,27 +66,24 @@ pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
66 add_keyword(ctx, acc, "fn", "fn $0() {}") 66 add_keyword(ctx, acc, "fn", "fn $0() {}")
67 } 67 }
68 68
69 if (ctx.has_item_list_or_source_file_parent && !has_trait_or_impl_parent) 69 if (ctx.has_item_list_or_source_file_parent) || ctx.block_expr_parent {
70 || ctx.block_expr_parent
71 {
72 add_keyword(ctx, acc, "trait", "trait $0 {}"); 70 add_keyword(ctx, acc, "trait", "trait $0 {}");
73 add_keyword(ctx, acc, "impl", "impl $0 {}"); 71 add_keyword(ctx, acc, "impl", "impl $0 {}");
74 } 72 }
75 73
76 return; 74 return;
77 } 75 }
78 if ctx.has_item_list_or_source_file_parent || ctx.block_expr_parent { 76 if ctx.has_item_list_or_source_file_parent || has_trait_or_impl_parent || ctx.block_expr_parent
77 {
79 add_keyword(ctx, acc, "fn", "fn $0() {}"); 78 add_keyword(ctx, acc, "fn", "fn $0() {}");
80 } 79 }
81 if (ctx.has_item_list_or_source_file_parent && !has_trait_or_impl_parent) 80 if (ctx.has_item_list_or_source_file_parent) || ctx.block_expr_parent {
82 || ctx.block_expr_parent
83 {
84 add_keyword(ctx, acc, "use", "use "); 81 add_keyword(ctx, acc, "use", "use ");
85 add_keyword(ctx, acc, "impl", "impl $0 {}"); 82 add_keyword(ctx, acc, "impl", "impl $0 {}");
86 add_keyword(ctx, acc, "trait", "trait $0 {}"); 83 add_keyword(ctx, acc, "trait", "trait $0 {}");
87 } 84 }
88 85
89 if ctx.has_item_list_or_source_file_parent && !has_trait_or_impl_parent { 86 if ctx.has_item_list_or_source_file_parent {
90 add_keyword(ctx, acc, "enum", "enum $0 {}"); 87 add_keyword(ctx, acc, "enum", "enum $0 {}");
91 add_keyword(ctx, acc, "struct", "struct $0"); 88 add_keyword(ctx, acc, "struct", "struct $0");
92 add_keyword(ctx, acc, "union", "union $0 {}"); 89 add_keyword(ctx, acc, "union", "union $0 {}");
@@ -108,29 +105,28 @@ pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
108 add_keyword(ctx, acc, "else", "else {$0}"); 105 add_keyword(ctx, acc, "else", "else {$0}");
109 add_keyword(ctx, acc, "else if", "else if $0 {}"); 106 add_keyword(ctx, acc, "else if", "else if $0 {}");
110 } 107 }
111 if (ctx.has_item_list_or_source_file_parent && !has_trait_or_impl_parent) 108 if (ctx.has_item_list_or_source_file_parent) || ctx.block_expr_parent {
112 || ctx.block_expr_parent
113 {
114 add_keyword(ctx, acc, "mod", "mod $0 {}"); 109 add_keyword(ctx, acc, "mod", "mod $0 {}");
115 } 110 }
116 if ctx.bind_pat_parent || ctx.ref_pat_parent { 111 if ctx.bind_pat_parent || ctx.ref_pat_parent {
117 add_keyword(ctx, acc, "mut", "mut "); 112 add_keyword(ctx, acc, "mut", "mut ");
118 } 113 }
119 if ctx.has_item_list_or_source_file_parent || ctx.block_expr_parent { 114 if ctx.has_item_list_or_source_file_parent || has_trait_or_impl_parent || ctx.block_expr_parent
115 {
120 add_keyword(ctx, acc, "const", "const "); 116 add_keyword(ctx, acc, "const", "const ");
121 add_keyword(ctx, acc, "type", "type "); 117 add_keyword(ctx, acc, "type", "type ");
122 } 118 }
123 if (ctx.has_item_list_or_source_file_parent && !has_trait_or_impl_parent) 119 if (ctx.has_item_list_or_source_file_parent) || ctx.block_expr_parent {
124 || ctx.block_expr_parent
125 {
126 add_keyword(ctx, acc, "static", "static "); 120 add_keyword(ctx, acc, "static", "static ");
127 }; 121 };
128 if (ctx.has_item_list_or_source_file_parent && !has_trait_or_impl_parent) 122 if (ctx.has_item_list_or_source_file_parent) || ctx.block_expr_parent {
129 || ctx.block_expr_parent
130 {
131 add_keyword(ctx, acc, "extern", "extern "); 123 add_keyword(ctx, acc, "extern", "extern ");
132 } 124 }
133 if ctx.has_item_list_or_source_file_parent || ctx.block_expr_parent || ctx.is_match_arm { 125 if ctx.has_item_list_or_source_file_parent
126 || has_trait_or_impl_parent
127 || ctx.block_expr_parent
128 || ctx.is_match_arm
129 {
134 add_keyword(ctx, acc, "unsafe", "unsafe "); 130 add_keyword(ctx, acc, "unsafe", "unsafe ");
135 } 131 }
136 if ctx.in_loop_body { 132 if ctx.in_loop_body {
@@ -142,7 +138,7 @@ pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
142 add_keyword(ctx, acc, "break", "break"); 138 add_keyword(ctx, acc, "break", "break");
143 } 139 }
144 } 140 }
145 if ctx.has_item_list_or_source_file_parent && !ctx.has_trait_parent { 141 if ctx.has_item_list_or_source_file_parent || ctx.has_impl_parent {
146 add_keyword(ctx, acc, "pub", "pub ") 142 add_keyword(ctx, acc, "pub", "pub ")
147 } 143 }
148 144
@@ -173,7 +169,7 @@ fn add_keyword(ctx: &CompletionContext, acc: &mut Completions, kw: &str, snippet
173 169
174fn complete_return( 170fn complete_return(
175 ctx: &CompletionContext, 171 ctx: &CompletionContext,
176 fn_def: &ast::FnDef, 172 fn_def: &ast::Fn,
177 can_be_stmt: bool, 173 can_be_stmt: bool,
178) -> Option<CompletionItem> { 174) -> Option<CompletionItem> {
179 let snip = match (can_be_stmt, fn_def.ret_type().is_some()) { 175 let snip = match (can_be_stmt, fn_def.ret_type().is_some()) {
diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs
index cf716540f..d9a0ef167 100644
--- a/crates/ra_ide/src/completion/complete_trait_impl.rs
+++ b/crates/ra_ide/src/completion/complete_trait_impl.rs
@@ -2,8 +2,8 @@
2//! 2//!
3//! This module adds the completion items related to implementing associated 3//! This module adds the completion items related to implementing associated
4//! items within a `impl Trait for Struct` block. The current context node 4//! items within a `impl Trait for Struct` block. The current context node
5//! must be within either a `FN_DEF`, `TYPE_ALIAS_DEF`, or `CONST_DEF` node 5//! must be within either a `FN`, `TYPE_ALIAS`, or `CONST` node
6//! and an direct child of an `IMPL_DEF`. 6//! and an direct child of an `IMPL`.
7//! 7//!
8//! # Examples 8//! # Examples
9//! 9//!
@@ -34,7 +34,7 @@
34use hir::{self, Docs, HasSource}; 34use hir::{self, Docs, HasSource};
35use ra_assists::utils::get_missing_assoc_items; 35use ra_assists::utils::get_missing_assoc_items;
36use ra_syntax::{ 36use ra_syntax::{
37 ast::{self, edit, ImplDef}, 37 ast::{self, edit, Impl},
38 AstNode, SyntaxKind, SyntaxNode, TextRange, T, 38 AstNode, SyntaxKind, SyntaxNode, TextRange, T,
39}; 39};
40use ra_text_edit::TextEdit; 40use ra_text_edit::TextEdit;
@@ -63,7 +63,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
63 } 63 }
64 }), 64 }),
65 65
66 SyntaxKind::FN_DEF => { 66 SyntaxKind::FN => {
67 for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def) 67 for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def)
68 .into_iter() 68 .into_iter()
69 .filter_map(|item| match item { 69 .filter_map(|item| match item {
@@ -75,7 +75,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
75 } 75 }
76 } 76 }
77 77
78 SyntaxKind::TYPE_ALIAS_DEF => { 78 SyntaxKind::TYPE_ALIAS => {
79 for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def) 79 for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def)
80 .into_iter() 80 .into_iter()
81 .filter_map(|item| match item { 81 .filter_map(|item| match item {
@@ -87,7 +87,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
87 } 87 }
88 } 88 }
89 89
90 SyntaxKind::CONST_DEF => { 90 SyntaxKind::CONST => {
91 for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def) 91 for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def)
92 .into_iter() 92 .into_iter()
93 .filter_map(|item| match item { 93 .filter_map(|item| match item {
@@ -104,18 +104,17 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
104 } 104 }
105} 105}
106 106
107fn completion_match(ctx: &CompletionContext) -> Option<(SyntaxNode, ImplDef)> { 107fn completion_match(ctx: &CompletionContext) -> Option<(SyntaxNode, Impl)> {
108 let (trigger, impl_def_offset) = ctx.token.ancestors().find_map(|p| match p.kind() { 108 let (trigger, impl_def_offset) = ctx.token.ancestors().find_map(|p| match p.kind() {
109 SyntaxKind::FN_DEF 109 SyntaxKind::FN | SyntaxKind::TYPE_ALIAS | SyntaxKind::CONST | SyntaxKind::BLOCK_EXPR => {
110 | SyntaxKind::TYPE_ALIAS_DEF 110 Some((p, 2))
111 | SyntaxKind::CONST_DEF 111 }
112 | SyntaxKind::BLOCK_EXPR => Some((p, 2)),
113 SyntaxKind::NAME_REF => Some((p, 5)), 112 SyntaxKind::NAME_REF => Some((p, 5)),
114 _ => None, 113 _ => None,
115 })?; 114 })?;
116 let impl_def = (0..impl_def_offset - 1) 115 let impl_def = (0..impl_def_offset - 1)
117 .try_fold(trigger.parent()?, |t, _| t.parent()) 116 .try_fold(trigger.parent()?, |t, _| t.parent())
118 .and_then(ast::ImplDef::cast)?; 117 .and_then(ast::Impl::cast)?;
119 Some((trigger, impl_def)) 118 Some((trigger, impl_def))
120} 119}
121 120
@@ -201,7 +200,7 @@ fn add_const_impl(
201 } 200 }
202} 201}
203 202
204fn make_const_compl_syntax(const_: &ast::ConstDef) -> String { 203fn make_const_compl_syntax(const_: &ast::Const) -> String {
205 let const_ = edit::remove_attrs_and_docs(const_); 204 let const_ = edit::remove_attrs_and_docs(const_);
206 205
207 let const_start = const_.syntax().text_range().start(); 206 let const_start = const_.syntax().text_range().start();
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index c84d43d77..6b03b30bb 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -35,12 +35,12 @@ pub(crate) struct CompletionContext<'a> {
35 pub(super) krate: Option<hir::Crate>, 35 pub(super) krate: Option<hir::Crate>,
36 pub(super) expected_type: Option<Type>, 36 pub(super) expected_type: Option<Type>,
37 pub(super) name_ref_syntax: Option<ast::NameRef>, 37 pub(super) name_ref_syntax: Option<ast::NameRef>,
38 pub(super) function_syntax: Option<ast::FnDef>, 38 pub(super) function_syntax: Option<ast::Fn>,
39 pub(super) use_item_syntax: Option<ast::UseItem>, 39 pub(super) use_item_syntax: Option<ast::Use>,
40 pub(super) record_lit_syntax: Option<ast::RecordLit>, 40 pub(super) record_lit_syntax: Option<ast::RecordExpr>,
41 pub(super) record_pat_syntax: Option<ast::RecordPat>, 41 pub(super) record_pat_syntax: Option<ast::RecordPat>,
42 pub(super) record_field_syntax: Option<ast::RecordField>, 42 pub(super) record_field_syntax: Option<ast::RecordExprField>,
43 pub(super) impl_def: Option<ast::ImplDef>, 43 pub(super) impl_def: Option<ast::Impl>,
44 /// FIXME: `ActiveParameter` is string-based, which is very very wrong 44 /// FIXME: `ActiveParameter` is string-based, which is very very wrong
45 pub(super) active_parameter: Option<ActiveParameter>, 45 pub(super) active_parameter: Option<ActiveParameter>,
46 pub(super) is_param: bool, 46 pub(super) is_param: bool,
@@ -265,7 +265,7 @@ impl<'a> CompletionContext<'a> {
265 return; 265 return;
266 } 266 }
267 // FIXME: remove this (V) duplication and make the check more precise 267 // FIXME: remove this (V) duplication and make the check more precise
268 if name_ref.syntax().ancestors().find_map(ast::RecordFieldPatList::cast).is_some() { 268 if name_ref.syntax().ancestors().find_map(ast::RecordPatFieldList::cast).is_some() {
269 self.record_pat_syntax = 269 self.record_pat_syntax =
270 self.sema.find_node_at_offset_with_macros(&original_file, offset); 270 self.sema.find_node_at_offset_with_macros(&original_file, offset);
271 } 271 }
@@ -275,7 +275,7 @@ impl<'a> CompletionContext<'a> {
275 // Otherwise, see if this is a declaration. We can use heuristics to 275 // Otherwise, see if this is a declaration. We can use heuristics to
276 // suggest declaration names, see `CompletionKind::Magic`. 276 // suggest declaration names, see `CompletionKind::Magic`.
277 if let Some(name) = find_node_at_offset::<ast::Name>(&file_with_fake_ident, offset) { 277 if let Some(name) = find_node_at_offset::<ast::Name>(&file_with_fake_ident, offset) {
278 if let Some(bind_pat) = name.syntax().ancestors().find_map(ast::BindPat::cast) { 278 if let Some(bind_pat) = name.syntax().ancestors().find_map(ast::IdentPat::cast) {
279 self.is_pat_binding_or_const = true; 279 self.is_pat_binding_or_const = true;
280 if bind_pat.at_token().is_some() 280 if bind_pat.at_token().is_some()
281 || bind_pat.ref_token().is_some() 281 || bind_pat.ref_token().is_some()
@@ -283,7 +283,7 @@ impl<'a> CompletionContext<'a> {
283 { 283 {
284 self.is_pat_binding_or_const = false; 284 self.is_pat_binding_or_const = false;
285 } 285 }
286 if bind_pat.syntax().parent().and_then(ast::RecordFieldPatList::cast).is_some() { 286 if bind_pat.syntax().parent().and_then(ast::RecordPatFieldList::cast).is_some() {
287 self.is_pat_binding_or_const = false; 287 self.is_pat_binding_or_const = false;
288 } 288 }
289 if let Some(let_stmt) = bind_pat.syntax().ancestors().find_map(ast::LetStmt::cast) { 289 if let Some(let_stmt) = bind_pat.syntax().ancestors().find_map(ast::LetStmt::cast) {
@@ -300,7 +300,7 @@ impl<'a> CompletionContext<'a> {
300 return; 300 return;
301 } 301 }
302 // FIXME: remove this (^) duplication and make the check more precise 302 // FIXME: remove this (^) duplication and make the check more precise
303 if name.syntax().ancestors().find_map(ast::RecordFieldPatList::cast).is_some() { 303 if name.syntax().ancestors().find_map(ast::RecordPatFieldList::cast).is_some() {
304 self.record_pat_syntax = 304 self.record_pat_syntax =
305 self.sema.find_node_at_offset_with_macros(&original_file, offset); 305 self.sema.find_node_at_offset_with_macros(&original_file, offset);
306 } 306 }
@@ -316,7 +316,7 @@ impl<'a> CompletionContext<'a> {
316 self.name_ref_syntax = 316 self.name_ref_syntax =
317 find_node_at_offset(&original_file, name_ref.syntax().text_range().start()); 317 find_node_at_offset(&original_file, name_ref.syntax().text_range().start());
318 let name_range = name_ref.syntax().text_range(); 318 let name_range = name_ref.syntax().text_range();
319 if ast::RecordField::for_field_name(&name_ref).is_some() { 319 if ast::RecordExprField::for_field_name(&name_ref).is_some() {
320 self.record_lit_syntax = 320 self.record_lit_syntax =
321 self.sema.find_node_at_offset_with_macros(&original_file, offset); 321 self.sema.find_node_at_offset_with_macros(&original_file, offset);
322 } 322 }
@@ -325,7 +325,7 @@ impl<'a> CompletionContext<'a> {
325 .sema 325 .sema
326 .ancestors_with_macros(self.token.parent()) 326 .ancestors_with_macros(self.token.parent())
327 .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) 327 .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE)
328 .find_map(ast::ImplDef::cast); 328 .find_map(ast::Impl::cast);
329 329
330 let top_node = name_ref 330 let top_node = name_ref
331 .syntax() 331 .syntax()
@@ -343,13 +343,13 @@ impl<'a> CompletionContext<'a> {
343 } 343 }
344 344
345 self.use_item_syntax = 345 self.use_item_syntax =
346 self.sema.ancestors_with_macros(self.token.parent()).find_map(ast::UseItem::cast); 346 self.sema.ancestors_with_macros(self.token.parent()).find_map(ast::Use::cast);
347 347
348 self.function_syntax = self 348 self.function_syntax = self
349 .sema 349 .sema
350 .ancestors_with_macros(self.token.parent()) 350 .ancestors_with_macros(self.token.parent())
351 .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) 351 .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE)
352 .find_map(ast::FnDef::cast); 352 .find_map(ast::Fn::cast);
353 353
354 self.record_field_syntax = self 354 self.record_field_syntax = self
355 .sema 355 .sema
@@ -357,7 +357,7 @@ impl<'a> CompletionContext<'a> {
357 .take_while(|it| { 357 .take_while(|it| {
358 it.kind() != SOURCE_FILE && it.kind() != MODULE && it.kind() != CALL_EXPR 358 it.kind() != SOURCE_FILE && it.kind() != MODULE && it.kind() != CALL_EXPR
359 }) 359 })
360 .find_map(ast::RecordField::cast); 360 .find_map(ast::RecordExprField::cast);
361 361
362 let parent = match name_ref.syntax().parent() { 362 let parent = match name_ref.syntax().parent() {
363 Some(it) => it, 363 Some(it) => it,
@@ -377,7 +377,7 @@ impl<'a> CompletionContext<'a> {
377 path.syntax().parent().and_then(ast::TupleStructPat::cast).is_some(); 377 path.syntax().parent().and_then(ast::TupleStructPat::cast).is_some();
378 378
379 self.is_path_type = path.syntax().parent().and_then(ast::PathType::cast).is_some(); 379 self.is_path_type = path.syntax().parent().and_then(ast::PathType::cast).is_some();
380 self.has_type_args = segment.type_arg_list().is_some(); 380 self.has_type_args = segment.generic_arg_list().is_some();
381 381
382 #[allow(deprecated)] 382 #[allow(deprecated)]
383 if let Some(path) = hir::Path::from_ast(path.clone()) { 383 if let Some(path) = hir::Path::from_ast(path.clone()) {
diff --git a/crates/ra_ide/src/completion/patterns.rs b/crates/ra_ide/src/completion/patterns.rs
index b2fe13280..7c4feff6d 100644
--- a/crates/ra_ide/src/completion/patterns.rs
+++ b/crates/ra_ide/src/completion/patterns.rs
@@ -13,9 +13,9 @@ use crate::completion::test_utils::check_pattern_is_applicable;
13 13
14pub(crate) fn has_trait_parent(element: SyntaxElement) -> bool { 14pub(crate) fn has_trait_parent(element: SyntaxElement) -> bool {
15 not_same_range_ancestor(element) 15 not_same_range_ancestor(element)
16 .filter(|it| it.kind() == ITEM_LIST) 16 .filter(|it| it.kind() == ASSOC_ITEM_LIST)
17 .and_then(|it| it.parent()) 17 .and_then(|it| it.parent())
18 .filter(|it| it.kind() == TRAIT_DEF) 18 .filter(|it| it.kind() == TRAIT)
19 .is_some() 19 .is_some()
20} 20}
21#[test] 21#[test]
@@ -25,9 +25,9 @@ fn test_has_trait_parent() {
25 25
26pub(crate) fn has_impl_parent(element: SyntaxElement) -> bool { 26pub(crate) fn has_impl_parent(element: SyntaxElement) -> bool {
27 not_same_range_ancestor(element) 27 not_same_range_ancestor(element)
28 .filter(|it| it.kind() == ITEM_LIST) 28 .filter(|it| it.kind() == ASSOC_ITEM_LIST)
29 .and_then(|it| it.parent()) 29 .and_then(|it| it.parent())
30 .filter(|it| it.kind() == IMPL_DEF) 30 .filter(|it| it.kind() == IMPL)
31 .is_some() 31 .is_some()
32} 32}
33#[test] 33#[test]
@@ -44,7 +44,7 @@ fn test_has_block_expr_parent() {
44} 44}
45 45
46pub(crate) fn has_bind_pat_parent(element: SyntaxElement) -> bool { 46pub(crate) fn has_bind_pat_parent(element: SyntaxElement) -> bool {
47 element.ancestors().find(|it| it.kind() == BIND_PAT).is_some() 47 element.ancestors().find(|it| it.kind() == IDENT_PAT).is_some()
48} 48}
49#[test] 49#[test]
50fn test_has_bind_pat_parent() { 50fn test_has_bind_pat_parent() {
@@ -73,7 +73,7 @@ pub(crate) fn has_item_list_or_source_file_parent(element: SyntaxElement) -> boo
73#[test] 73#[test]
74fn test_has_item_list_or_source_file_parent() { 74fn test_has_item_list_or_source_file_parent() {
75 check_pattern_is_applicable(r"i<|>", has_item_list_or_source_file_parent); 75 check_pattern_is_applicable(r"i<|>", has_item_list_or_source_file_parent);
76 check_pattern_is_applicable(r"impl { f<|> }", has_item_list_or_source_file_parent); 76 check_pattern_is_applicable(r"mod foo { f<|> }", has_item_list_or_source_file_parent);
77} 77}
78 78
79pub(crate) fn is_match_arm(element: SyntaxElement) -> bool { 79pub(crate) fn is_match_arm(element: SyntaxElement) -> bool {
@@ -113,7 +113,7 @@ fn test_if_is_prev() {
113} 113}
114 114
115pub(crate) fn has_trait_as_prev_sibling(element: SyntaxElement) -> bool { 115pub(crate) fn has_trait_as_prev_sibling(element: SyntaxElement) -> bool {
116 previous_sibling_or_ancestor_sibling(element).filter(|it| it.kind() == TRAIT_DEF).is_some() 116 previous_sibling_or_ancestor_sibling(element).filter(|it| it.kind() == TRAIT).is_some()
117} 117}
118#[test] 118#[test]
119fn test_has_trait_as_prev_sibling() { 119fn test_has_trait_as_prev_sibling() {
@@ -121,7 +121,7 @@ fn test_has_trait_as_prev_sibling() {
121} 121}
122 122
123pub(crate) fn has_impl_as_prev_sibling(element: SyntaxElement) -> bool { 123pub(crate) fn has_impl_as_prev_sibling(element: SyntaxElement) -> bool {
124 previous_sibling_or_ancestor_sibling(element).filter(|it| it.kind() == IMPL_DEF).is_some() 124 previous_sibling_or_ancestor_sibling(element).filter(|it| it.kind() == IMPL).is_some()
125} 125}
126#[test] 126#[test]
127fn test_has_impl_as_prev_sibling() { 127fn test_has_impl_as_prev_sibling() {
@@ -134,7 +134,7 @@ pub(crate) fn is_in_loop_body(element: SyntaxElement) -> bool {
134 NodeOrToken::Token(token) => token.parent(), 134 NodeOrToken::Token(token) => token.parent(),
135 }; 135 };
136 for node in leaf.ancestors() { 136 for node in leaf.ancestors() {
137 if node.kind() == FN_DEF || node.kind() == LAMBDA_EXPR { 137 if node.kind() == FN || node.kind() == CLOSURE_EXPR {
138 break; 138 break;
139 } 139 }
140 let loop_body = match_ast! { 140 let loop_body = match_ast! {
diff --git a/crates/ra_ide/src/completion/unstable_feature_descriptor.rs b/crates/ra_ide/src/completion/unstable_feature_descriptor.rs
index ae7fc1cfb..a40071a26 100644
--- a/crates/ra_ide/src/completion/unstable_feature_descriptor.rs
+++ b/crates/ra_ide/src/completion/unstable_feature_descriptor.rs
@@ -1,4 +1,4 @@
1//! Generated file, do not edit by hand, see `xtask/src/codegen` 1//! Generated file, do not edit by hand, see `xtask/src/codegen`
2 2
3use crate::completion::LintCompletion; 3use crate::completion::LintCompletion;
4const UNSTABLE_FEATURE_DESCRIPTOR : & [ LintCompletion ] = & [ LintCompletion { label : "crate_visibility_modifier" , description : "# `crate_visibility_modifier`\n\nThe tracking issue for this feature is: [#53120]\n\n[#53120]: https://github.com/rust-lang/rust/issues/53120\n\n-----\n\nThe `crate_visibility_modifier` feature allows the `crate` keyword to be used\nas a visibility modifier synonymous to `pub(crate)`, indicating that a type\n(function, _&c._) is to be visible to the entire enclosing crate, but not to\nother crates.\n\n```rust\n#![feature(crate_visibility_modifier)]\n\ncrate struct Foo {\n bar: usize,\n}\n```\n" } , LintCompletion { label : "abi_thiscall" , description : "# `abi_thiscall`\n\nThe tracking issue for this feature is: [#42202]\n\n[#42202]: https://github.com/rust-lang/rust/issues/42202\n\n------------------------\n\nThe MSVC ABI on x86 Windows uses the `thiscall` calling convention for C++\ninstance methods by default; it is identical to the usual (C) calling\nconvention on x86 Windows except that the first parameter of the method,\nthe `this` pointer, is passed in the ECX register.\n" } , LintCompletion { label : "infer_static_outlives_requirements" , description : "# `infer_static_outlives_requirements`\n\nThe tracking issue for this feature is: [#54185]\n\n[#54185]: https://github.com/rust-lang/rust/issues/54185\n\n------------------------\nThe `infer_static_outlives_requirements` feature indicates that certain\n`'static` outlives requirements can be inferred by the compiler rather than\nstating them explicitly.\n\nNote: It is an accompanying feature to `infer_outlives_requirements`,\nwhich must be enabled to infer outlives requirements.\n\nFor example, currently generic struct definitions that contain\nreferences, require where-clauses of the form T: 'static. By using\nthis feature the outlives predicates will be inferred, although\nthey may still be written explicitly.\n\n```rust,ignore (pseudo-Rust)\nstruct Foo<U> where U: 'static { // <-- currently required\n bar: Bar<U>\n}\nstruct Bar<T: 'static> {\n x: T,\n}\n```\n\n\n## Examples:\n\n```rust,ignore (pseudo-Rust)\n#![feature(infer_outlives_requirements)]\n#![feature(infer_static_outlives_requirements)]\n\n#[rustc_outlives]\n// Implicitly infer U: 'static\nstruct Foo<U> {\n bar: Bar<U>\n}\nstruct Bar<T: 'static> {\n x: T,\n}\n```\n\n" } , LintCompletion { label : "repr128" , description : "# `repr128`\n\nThe tracking issue for this feature is: [#56071]\n\n[#56071]: https://github.com/rust-lang/rust/issues/56071\n\n------------------------\n\nThe `repr128` feature adds support for `#[repr(u128)]` on `enum`s.\n\n```rust\n#![feature(repr128)]\n\n#[repr(u128)]\nenum Foo {\n Bar(u64),\n}\n```\n" } , LintCompletion { label : "doc_masked" , description : "# `doc_masked`\n\nThe tracking issue for this feature is: [#44027]\n\n-----\n\nThe `doc_masked` feature allows a crate to exclude types from a given crate from appearing in lists\nof trait implementations. The specifics of the feature are as follows:\n\n1. When rustdoc encounters an `extern crate` statement annotated with a `#[doc(masked)]` attribute,\n it marks the crate as being masked.\n\n2. When listing traits a given type implements, rustdoc ensures that traits from masked crates are\n not emitted into the documentation.\n\n3. When listing types that implement a given trait, rustdoc ensures that types from masked crates\n are not emitted into the documentation.\n\nThis feature was introduced in PR [#44026] to ensure that compiler-internal and\nimplementation-specific types and traits were not included in the standard library's documentation.\nSuch types would introduce broken links into the documentation.\n\n[#44026]: https://github.com/rust-lang/rust/pull/44026\n[#44027]: https://github.com/rust-lang/rust/pull/44027\n" } , LintCompletion { label : "link_args" , description : "# `link_args`\n\nThe tracking issue for this feature is: [#29596]\n\n[#29596]: https://github.com/rust-lang/rust/issues/29596\n\n------------------------\n\nYou can tell `rustc` how to customize linking, and that is via the `link_args`\nattribute. This attribute is applied to `extern` blocks and specifies raw flags\nwhich need to get passed to the linker when producing an artifact. An example\nusage would be:\n\n```rust,no_run\n#![feature(link_args)]\n\n#[link_args = \"-foo -bar -baz\"]\nextern {}\n# fn main() {}\n```\n\nNote that this feature is currently hidden behind the `feature(link_args)` gate\nbecause this is not a sanctioned way of performing linking. Right now `rustc`\nshells out to the system linker (`gcc` on most systems, `link.exe` on MSVC), so\nit makes sense to provide extra command line arguments, but this will not\nalways be the case. In the future `rustc` may use LLVM directly to link native\nlibraries, in which case `link_args` will have no meaning. You can achieve the\nsame effect as the `link_args` attribute with the `-C link-args` argument to\n`rustc`.\n\nIt is highly recommended to *not* use this attribute, and rather use the more\nformal `#[link(...)]` attribute on `extern` blocks instead.\n" } , LintCompletion { label : "cfg_version" , description : "# `cfg_version`\n\nThe tracking issue for this feature is: [#64796]\n\n[#64796]: https://github.com/rust-lang/rust/issues/64796\n\n------------------------\n\nThe `cfg_version` feature makes it possible to execute different code\ndepending on the compiler version.\n\n## Examples\n\n```rust\n#![feature(cfg_version)]\n\n#[cfg(version(\"1.42\"))]\nfn a() {\n // ...\n}\n\n#[cfg(not(version(\"1.42\")))]\nfn a() {\n // ...\n}\n\nfn b() {\n if cfg!(version(\"1.42\")) {\n // ...\n } else {\n // ...\n }\n}\n```\n" } , LintCompletion { label : "ffi_const" , description : "# `ffi_const`\n\nThe `#[ffi_const]` attribute applies clang's `const` attribute to foreign\nfunctions declarations.\n\nThat is, `#[ffi_const]` functions shall have no effects except for its return\nvalue, which can only depend on the values of the function parameters, and is\nnot affected by changes to the observable state of the program.\n\nApplying the `#[ffi_const]` attribute to a function that violates these\nrequirements is undefined behaviour.\n\nThis attribute enables Rust to perform common optimizations, like sub-expression\nelimination, and it can avoid emitting some calls in repeated invocations of the\nfunction with the same argument values regardless of other operations being\nperformed in between these functions calls (as opposed to `#[ffi_pure]`\nfunctions).\n\n## Pitfalls\n\nA `#[ffi_const]` function can only read global memory that would not affect\nits return value for the whole execution of the program (e.g. immutable global\nmemory). `#[ffi_const]` functions are referentially-transparent and therefore\nmore strict than `#[ffi_pure]` functions.\n\nA common pitfall involves applying the `#[ffi_const]` attribute to a\nfunction that reads memory through pointer arguments which do not necessarily\npoint to immutable global memory.\n\nA `#[ffi_const]` function that returns unit has no effect on the abstract\nmachine's state, and a `#[ffi_const]` function cannot be `#[ffi_pure]`.\n\nA `#[ffi_const]` function must not diverge, neither via a side effect (e.g. a\ncall to `abort`) nor by infinite loops.\n\nWhen translating C headers to Rust FFI, it is worth verifying for which targets\nthe `const` attribute is enabled in those headers, and using the appropriate\n`cfg` macros in the Rust side to match those definitions. While the semantics of\n`const` are implemented identically by many C and C++ compilers, e.g., clang,\n[GCC], [ARM C/C++ compiler], [IBM ILE C/C++], etc. they are not necessarily\nimplemented in this way on all of them. It is therefore also worth verifying\nthat the semantics of the C toolchain used to compile the binary being linked\nagainst are compatible with those of the `#[ffi_const]`.\n\n[ARM C/C++ compiler]: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/Cacgigch.html\n[GCC]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute\n[IBM ILE C/C++]: https://www.ibm.com/support/knowledgecenter/fr/ssw_ibm_i_71/rzarg/fn_attrib_const.htm\n" } , LintCompletion { label : "doc_cfg" , description : "# `doc_cfg`\n\nThe tracking issue for this feature is: [#43781]\n\n------\n\nThe `doc_cfg` feature allows an API be documented as only available in some specific platforms.\nThis attribute has two effects:\n\n1. In the annotated item's documentation, there will be a message saying \"This is supported on\n (platform) only\".\n\n2. The item's doc-tests will only run on the specific platform.\n\nIn addition to allowing the use of the `#[doc(cfg)]` attribute, this feature enables the use of a\nspecial conditional compilation flag, `#[cfg(doc)]`, set whenever building documentation on your\ncrate.\n\nThis feature was introduced as part of PR [#43348] to allow the platform-specific parts of the\nstandard library be documented.\n\n```rust\n#![feature(doc_cfg)]\n\n#[cfg(any(windows, doc))]\n#[doc(cfg(windows))]\n/// The application's icon in the notification area (a.k.a. system tray).\n///\n/// # Examples\n///\n/// ```no_run\n/// extern crate my_awesome_ui_library;\n/// use my_awesome_ui_library::current_app;\n/// use my_awesome_ui_library::windows::notification;\n///\n/// let icon = current_app().get::<notification::Icon>();\n/// icon.show();\n/// icon.show_message(\"Hello\");\n/// ```\npub struct Icon {\n // ...\n}\n```\n\n[#43781]: https://github.com/rust-lang/rust/issues/43781\n[#43348]: https://github.com/rust-lang/rust/issues/43348\n" } , LintCompletion { label : "unsized_tuple_coercion" , description : "# `unsized_tuple_coercion`\n\nThe tracking issue for this feature is: [#42877]\n\n[#42877]: https://github.com/rust-lang/rust/issues/42877\n\n------------------------\n\nThis is a part of [RFC0401]. According to the RFC, there should be an implementation like this:\n\n```rust,ignore\nimpl<..., T, U: ?Sized> Unsized<(..., U)> for (..., T) where T: Unsized<U> {}\n```\n\nThis implementation is currently gated behind `#[feature(unsized_tuple_coercion)]` to avoid insta-stability. Therefore you can use it like this:\n\n```rust\n#![feature(unsized_tuple_coercion)]\n\nfn main() {\n let x : ([i32; 3], [i32; 3]) = ([1, 2, 3], [4, 5, 6]);\n let y : &([i32; 3], [i32]) = &x;\n assert_eq!(y.1[0], 4);\n}\n```\n\n[RFC0401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md\n" } , LintCompletion { label : "abi_msp430_interrupt" , description : "# `abi_msp430_interrupt`\n\nThe tracking issue for this feature is: [#38487]\n\n[#38487]: https://github.com/rust-lang/rust/issues/38487\n\n------------------------\n\nIn the MSP430 architecture, interrupt handlers have a special calling\nconvention. You can use the `\"msp430-interrupt\"` ABI to make the compiler apply\nthe right calling convention to the interrupt handlers you define.\n\n<!-- NOTE(ignore) this example is specific to the msp430 target -->\n\n``` rust,ignore\n#![feature(abi_msp430_interrupt)]\n#![no_std]\n\n// Place the interrupt handler at the appropriate memory address\n// (Alternatively, you can use `#[used]` and remove `pub` and `#[no_mangle]`)\n#[link_section = \"__interrupt_vector_10\"]\n#[no_mangle]\npub static TIM0_VECTOR: extern \"msp430-interrupt\" fn() = tim0;\n\n// The interrupt handler\nextern \"msp430-interrupt\" fn tim0() {\n // ..\n}\n```\n\n``` text\n$ msp430-elf-objdump -CD ./target/msp430/release/app\nDisassembly of section __interrupt_vector_10:\n\n0000fff2 <TIM0_VECTOR>:\n fff2: 00 c0 interrupt service routine at 0xc000\n\nDisassembly of section .text:\n\n0000c000 <int::tim0>:\n c000: 00 13 reti\n```\n" } , LintCompletion { label : "generators" , description : "# `generators`\n\nThe tracking issue for this feature is: [#43122]\n\n[#43122]: https://github.com/rust-lang/rust/issues/43122\n\n------------------------\n\nThe `generators` feature gate in Rust allows you to define generator or\ncoroutine literals. A generator is a \"resumable function\" that syntactically\nresembles a closure but compiles to much different semantics in the compiler\nitself. The primary feature of a generator is that it can be suspended during\nexecution to be resumed at a later date. Generators use the `yield` keyword to\n\"return\", and then the caller can `resume` a generator to resume execution just\nafter the `yield` keyword.\n\nGenerators are an extra-unstable feature in the compiler right now. Added in\n[RFC 2033] they're mostly intended right now as a information/constraint\ngathering phase. The intent is that experimentation can happen on the nightly\ncompiler before actual stabilization. A further RFC will be required to\nstabilize generators/coroutines and will likely contain at least a few small\ntweaks to the overall design.\n\n[RFC 2033]: https://github.com/rust-lang/rfcs/pull/2033\n\nA syntactical example of a generator is:\n\n```rust\n#![feature(generators, generator_trait)]\n\nuse std::ops::{Generator, GeneratorState};\nuse std::pin::Pin;\n\nfn main() {\n let mut generator = || {\n yield 1;\n return \"foo\"\n };\n\n match Pin::new(&mut generator).resume(()) {\n GeneratorState::Yielded(1) => {}\n _ => panic!(\"unexpected value from resume\"),\n }\n match Pin::new(&mut generator).resume(()) {\n GeneratorState::Complete(\"foo\") => {}\n _ => panic!(\"unexpected value from resume\"),\n }\n}\n```\n\nGenerators are closure-like literals which can contain a `yield` statement. The\n`yield` statement takes an optional expression of a value to yield out of the\ngenerator. All generator literals implement the `Generator` trait in the\n`std::ops` module. The `Generator` trait has one main method, `resume`, which\nresumes execution of the generator at the previous suspension point.\n\nAn example of the control flow of generators is that the following example\nprints all numbers in order:\n\n```rust\n#![feature(generators, generator_trait)]\n\nuse std::ops::Generator;\nuse std::pin::Pin;\n\nfn main() {\n let mut generator = || {\n println!(\"2\");\n yield;\n println!(\"4\");\n };\n\n println!(\"1\");\n Pin::new(&mut generator).resume(());\n println!(\"3\");\n Pin::new(&mut generator).resume(());\n println!(\"5\");\n}\n```\n\nAt this time the main intended use case of generators is an implementation\nprimitive for async/await syntax, but generators will likely be extended to\nergonomic implementations of iterators and other primitives in the future.\nFeedback on the design and usage is always appreciated!\n\n### The `Generator` trait\n\nThe `Generator` trait in `std::ops` currently looks like:\n\n```rust\n# #![feature(arbitrary_self_types, generator_trait)]\n# use std::ops::GeneratorState;\n# use std::pin::Pin;\n\npub trait Generator<R = ()> {\n type Yield;\n type Return;\n fn resume(self: Pin<&mut Self>, resume: R) -> GeneratorState<Self::Yield, Self::Return>;\n}\n```\n\nThe `Generator::Yield` type is the type of values that can be yielded with the\n`yield` statement. The `Generator::Return` type is the returned type of the\ngenerator. This is typically the last expression in a generator's definition or\nany value passed to `return` in a generator. The `resume` function is the entry\npoint for executing the `Generator` itself.\n\nThe return value of `resume`, `GeneratorState`, looks like:\n\n```rust\npub enum GeneratorState<Y, R> {\n Yielded(Y),\n Complete(R),\n}\n```\n\nThe `Yielded` variant indicates that the generator can later be resumed. This\ncorresponds to a `yield` point in a generator. The `Complete` variant indicates\nthat the generator is complete and cannot be resumed again. Calling `resume`\nafter a generator has returned `Complete` will likely result in a panic of the\nprogram.\n\n### Closure-like semantics\n\nThe closure-like syntax for generators alludes to the fact that they also have\nclosure-like semantics. Namely:\n\n* When created, a generator executes no code. A closure literal does not\n actually execute any of the closure's code on construction, and similarly a\n generator literal does not execute any code inside the generator when\n constructed.\n\n* Generators can capture outer variables by reference or by move, and this can\n be tweaked with the `move` keyword at the beginning of the closure. Like\n closures all generators will have an implicit environment which is inferred by\n the compiler. Outer variables can be moved into a generator for use as the\n generator progresses.\n\n* Generator literals produce a value with a unique type which implements the\n `std::ops::Generator` trait. This allows actual execution of the generator\n through the `Generator::resume` method as well as also naming it in return\n types and such.\n\n* Traits like `Send` and `Sync` are automatically implemented for a `Generator`\n depending on the captured variables of the environment. Unlike closures,\n generators also depend on variables live across suspension points. This means\n that although the ambient environment may be `Send` or `Sync`, the generator\n itself may not be due to internal variables live across `yield` points being\n not-`Send` or not-`Sync`. Note that generators do\n not implement traits like `Copy` or `Clone` automatically.\n\n* Whenever a generator is dropped it will drop all captured environment\n variables.\n\n### Generators as state machines\n\nIn the compiler, generators are currently compiled as state machines. Each\n`yield` expression will correspond to a different state that stores all live\nvariables over that suspension point. Resumption of a generator will dispatch on\nthe current state and then execute internally until a `yield` is reached, at\nwhich point all state is saved off in the generator and a value is returned.\n\nLet's take a look at an example to see what's going on here:\n\n```rust\n#![feature(generators, generator_trait)]\n\nuse std::ops::Generator;\nuse std::pin::Pin;\n\nfn main() {\n let ret = \"foo\";\n let mut generator = move || {\n yield 1;\n return ret\n };\n\n Pin::new(&mut generator).resume(());\n Pin::new(&mut generator).resume(());\n}\n```\n\nThis generator literal will compile down to something similar to:\n\n```rust\n#![feature(arbitrary_self_types, generators, generator_trait)]\n\nuse std::ops::{Generator, GeneratorState};\nuse std::pin::Pin;\n\nfn main() {\n let ret = \"foo\";\n let mut generator = {\n enum __Generator {\n Start(&'static str),\n Yield1(&'static str),\n Done,\n }\n\n impl Generator for __Generator {\n type Yield = i32;\n type Return = &'static str;\n\n fn resume(mut self: Pin<&mut Self>, resume: ()) -> GeneratorState<i32, &'static str> {\n use std::mem;\n match mem::replace(&mut *self, __Generator::Done) {\n __Generator::Start(s) => {\n *self = __Generator::Yield1(s);\n GeneratorState::Yielded(1)\n }\n\n __Generator::Yield1(s) => {\n *self = __Generator::Done;\n GeneratorState::Complete(s)\n }\n\n __Generator::Done => {\n panic!(\"generator resumed after completion\")\n }\n }\n }\n }\n\n __Generator::Start(ret)\n };\n\n Pin::new(&mut generator).resume(());\n Pin::new(&mut generator).resume(());\n}\n```\n\nNotably here we can see that the compiler is generating a fresh type,\n`__Generator` in this case. This type has a number of states (represented here\nas an `enum`) corresponding to each of the conceptual states of the generator.\nAt the beginning we're closing over our outer variable `foo` and then that\nvariable is also live over the `yield` point, so it's stored in both states.\n\nWhen the generator starts it'll immediately yield 1, but it saves off its state\njust before it does so indicating that it has reached the yield point. Upon\nresuming again we'll execute the `return ret` which returns the `Complete`\nstate.\n\nHere we can also note that the `Done` state, if resumed, panics immediately as\nit's invalid to resume a completed generator. It's also worth noting that this\nis just a rough desugaring, not a normative specification for what the compiler\ndoes.\n" } , LintCompletion { label : "marker_trait_attr" , description : "# `marker_trait_attr`\n\nThe tracking issue for this feature is: [#29864]\n\n[#29864]: https://github.com/rust-lang/rust/issues/29864\n\n------------------------\n\nNormally, Rust keeps you from adding trait implementations that could\noverlap with each other, as it would be ambiguous which to use. This\nfeature, however, carves out an exception to that rule: a trait can\nopt-in to having overlapping implementations, at the cost that those\nimplementations are not allowed to override anything (and thus the\ntrait itself cannot have any associated items, as they're pointless\nwhen they'd need to do the same thing for every type anyway).\n\n```rust\n#![feature(marker_trait_attr)]\n\n#[marker] trait CheapToClone: Clone {}\n\nimpl<T: Copy> CheapToClone for T {}\n\n// These could potentially overlap with the blanket implementation above,\n// so are only allowed because CheapToClone is a marker trait.\nimpl<T: CheapToClone, U: CheapToClone> CheapToClone for (T, U) {}\nimpl<T: CheapToClone> CheapToClone for std::ops::Range<T> {}\n\nfn cheap_clone<T: CheapToClone>(t: T) -> T {\n t.clone()\n}\n```\n\nThis is expected to replace the unstable `overlapping_marker_traits`\nfeature, which applied to all empty traits (without needing an opt-in).\n" } , LintCompletion { label : "const_in_array_repeat_expressions" , description : "# `const_in_array_repeat_expressions`\n\nThe tracking issue for this feature is: [#49147]\n\n[#49147]: https://github.com/rust-lang/rust/issues/49147\n\n------------------------\n\nRelaxes the rules for repeat expressions, `[x; N]` such that `x` may also be `const` (strictly\nspeaking rvalue promotable), in addition to `typeof(x): Copy`. The result of `[x; N]` where `x` is\n`const` is itself also `const`.\n" } , LintCompletion { label : "external_doc" , description : "# `external_doc`\n\nThe tracking issue for this feature is: [#44732]\n\nThe `external_doc` feature allows the use of the `include` parameter to the `#[doc]` attribute, to\ninclude external files in documentation. Use the attribute in place of, or in addition to, regular\ndoc comments and `#[doc]` attributes, and `rustdoc` will load the given file when it renders\ndocumentation for your crate.\n\nWith the following files in the same directory:\n\n`external-doc.md`:\n\n```markdown\n# My Awesome Type\n\nThis is the documentation for this spectacular type.\n```\n\n`lib.rs`:\n\n```no_run (needs-external-files)\n#![feature(external_doc)]\n\n#[doc(include = \"external-doc.md\")]\npub struct MyAwesomeType;\n```\n\n`rustdoc` will load the file `external-doc.md` and use it as the documentation for the `MyAwesomeType`\nstruct.\n\nWhen locating files, `rustdoc` will base paths in the `src/` directory, as if they were alongside the\n`lib.rs` for your crate. So if you want a `docs/` folder to live alongside the `src/` directory,\nstart your paths with `../docs/` for `rustdoc` to properly find the file.\n\nThis feature was proposed in [RFC #1990] and initially implemented in PR [#44781].\n\n[#44732]: https://github.com/rust-lang/rust/issues/44732\n[RFC #1990]: https://github.com/rust-lang/rfcs/pull/1990\n[#44781]: https://github.com/rust-lang/rust/pull/44781\n" } , LintCompletion { label : "unsized_locals" , description : "# `unsized_locals`\n\nThe tracking issue for this feature is: [#48055]\n\n[#48055]: https://github.com/rust-lang/rust/issues/48055\n\n------------------------\n\nThis implements [RFC1909]. When turned on, you can have unsized arguments and locals:\n\n[RFC1909]: https://github.com/rust-lang/rfcs/blob/master/text/1909-unsized-rvalues.md\n\n```rust\n#![feature(unsized_locals)]\n\nuse std::any::Any;\n\nfn main() {\n let x: Box<dyn Any> = Box::new(42);\n let x: dyn Any = *x;\n // ^ unsized local variable\n // ^^ unsized temporary\n foo(x);\n}\n\nfn foo(_: dyn Any) {}\n// ^^^^^^ unsized argument\n```\n\nThe RFC still forbids the following unsized expressions:\n\n```rust,ignore\n#![feature(unsized_locals)]\n\nuse std::any::Any;\n\nstruct MyStruct<T: ?Sized> {\n content: T,\n}\n\nstruct MyTupleStruct<T: ?Sized>(T);\n\nfn answer() -> Box<dyn Any> {\n Box::new(42)\n}\n\nfn main() {\n // You CANNOT have unsized statics.\n static X: dyn Any = *answer(); // ERROR\n const Y: dyn Any = *answer(); // ERROR\n\n // You CANNOT have struct initialized unsized.\n MyStruct { content: *answer() }; // ERROR\n MyTupleStruct(*answer()); // ERROR\n (42, *answer()); // ERROR\n\n // You CANNOT have unsized return types.\n fn my_function() -> dyn Any { *answer() } // ERROR\n\n // You CAN have unsized local variables...\n let mut x: dyn Any = *answer(); // OK\n // ...but you CANNOT reassign to them.\n x = *answer(); // ERROR\n\n // You CANNOT even initialize them separately.\n let y: dyn Any; // OK\n y = *answer(); // ERROR\n\n // Not mentioned in the RFC, but by-move captured variables are also Sized.\n let x: dyn Any = *answer();\n (move || { // ERROR\n let y = x;\n })();\n\n // You CAN create a closure with unsized arguments,\n // but you CANNOT call it.\n // This is an implementation detail and may be changed in the future.\n let f = |x: dyn Any| {};\n f(*answer()); // ERROR\n}\n```\n\n## By-value trait objects\n\nWith this feature, you can have by-value `self` arguments without `Self: Sized` bounds.\n\n```rust\n#![feature(unsized_locals)]\n\ntrait Foo {\n fn foo(self) {}\n}\n\nimpl<T: ?Sized> Foo for T {}\n\nfn main() {\n let slice: Box<[i32]> = Box::new([1, 2, 3]);\n <[i32] as Foo>::foo(*slice);\n}\n```\n\nAnd `Foo` will also be object-safe.\n\n```rust\n#![feature(unsized_locals)]\n\ntrait Foo {\n fn foo(self) {}\n}\n\nimpl<T: ?Sized> Foo for T {}\n\nfn main () {\n let slice: Box<dyn Foo> = Box::new([1, 2, 3]);\n // doesn't compile yet\n <dyn Foo as Foo>::foo(*slice);\n}\n```\n\nOne of the objectives of this feature is to allow `Box<dyn FnOnce>`.\n\n## Variable length arrays\n\nThe RFC also describes an extension to the array literal syntax: `[e; dyn n]`. In the syntax, `n` isn't necessarily a constant expression. The array is dynamically allocated on the stack and has the type of `[T]`, instead of `[T; n]`.\n\n```rust,ignore\n#![feature(unsized_locals)]\n\nfn mergesort<T: Ord>(a: &mut [T]) {\n let mut tmp = [T; dyn a.len()];\n // ...\n}\n\nfn main() {\n let mut a = [3, 1, 5, 6];\n mergesort(&mut a);\n assert_eq!(a, [1, 3, 5, 6]);\n}\n```\n\nVLAs are not implemented yet. The syntax isn't final, either. We may need an alternative syntax for Rust 2015 because, in Rust 2015, expressions like `[e; dyn(1)]` would be ambiguous. One possible alternative proposed in the RFC is `[e; n]`: if `n` captures one or more local variables, then it is considered as `[e; dyn n]`.\n\n## Advisory on stack usage\n\nIt's advised not to casually use the `#![feature(unsized_locals)]` feature. Typical use-cases are:\n\n- When you need a by-value trait objects.\n- When you really need a fast allocation of small temporary arrays.\n\nAnother pitfall is repetitive allocation and temporaries. Currently the compiler simply extends the stack frame every time it encounters an unsized assignment. So for example, the code\n\n```rust\n#![feature(unsized_locals)]\n\nfn main() {\n let x: Box<[i32]> = Box::new([1, 2, 3, 4, 5]);\n let _x = {{{{{{{{{{*x}}}}}}}}}};\n}\n```\n\nand the code\n\n```rust\n#![feature(unsized_locals)]\n\nfn main() {\n for _ in 0..10 {\n let x: Box<[i32]> = Box::new([1, 2, 3, 4, 5]);\n let _x = *x;\n }\n}\n```\n\nwill unnecessarily extend the stack frame.\n" } , LintCompletion { label : "or_patterns" , description : "# `or_patterns`\n\nThe tracking issue for this feature is: [#54883]\n\n[#54883]: https://github.com/rust-lang/rust/issues/54883\n\n------------------------\n\nThe `or_pattern` language feature allows `|` to be arbitrarily nested within\na pattern, for example, `Some(A(0) | B(1 | 2))` becomes a valid pattern.\n\n## Examples\n\n```rust,ignore\n#![feature(or_patterns)]\n\npub enum Foo {\n Bar,\n Baz,\n Quux,\n}\n\npub fn example(maybe_foo: Option<Foo>) {\n match maybe_foo {\n Some(Foo::Bar | Foo::Baz) => {\n println!(\"The value contained `Bar` or `Baz`\");\n }\n Some(_) => {\n println!(\"The value did not contain `Bar` or `Baz`\");\n }\n None => {\n println!(\"The value was `None`\");\n }\n }\n}\n```\n" } , LintCompletion { label : "member_constraints" , description : "# `member_constraints`\n\nThe tracking issue for this feature is: [#61997]\n\n[#61997]: https://github.com/rust-lang/rust/issues/61997\n\n------------------------\n\nThe `member_constraints` feature gate lets you use `impl Trait` syntax with\nmultiple unrelated lifetime parameters.\n\nA simple example is:\n\n```rust\n#![feature(member_constraints)]\n\ntrait Trait<'a, 'b> { }\nimpl<T> Trait<'_, '_> for T {}\n\nfn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Trait<'a, 'b> {\n (x, y)\n}\n\nfn main() { }\n```\n\nWithout the `member_constraints` feature gate, the above example is an\nerror because both `'a` and `'b` appear in the impl Trait bounds, but\nneither outlives the other.\n" } , LintCompletion { label : "optin_builtin_traits" , description : "# `optin_builtin_traits`\n\nThe tracking issue for this feature is [#13231] \n\n[#13231]: https://github.com/rust-lang/rust/issues/13231\n\n----\n\nThe `optin_builtin_traits` feature gate allows you to define auto traits.\n\nAuto traits, like [`Send`] or [`Sync`] in the standard library, are marker traits\nthat are automatically implemented for every type, unless the type, or a type it contains, \nhas explicitly opted out via a negative impl. (Negative impls are separately controlled\nby the `negative_impls` feature.)\n\n[`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html\n[`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html\n\n```rust,ignore\nimpl !Trait for Type\n```\n\nExample:\n\n```rust\n#![feature(negative_impls)]\n#![feature(optin_builtin_traits)]\n\nauto trait Valid {}\n\nstruct True;\nstruct False;\n\nimpl !Valid for False {}\n\nstruct MaybeValid<T>(T);\n\nfn must_be_valid<T: Valid>(_t: T) { }\n\nfn main() {\n // works\n must_be_valid( MaybeValid(True) );\n \n // compiler error - trait bound not satisfied\n // must_be_valid( MaybeValid(False) );\n}\n```\n\n## Automatic trait implementations\n\nWhen a type is declared as an `auto trait`, we will automatically\ncreate impls for every struct/enum/union, unless an explicit impl is\nprovided. These automatic impls contain a where clause for each field\nof the form `T: AutoTrait`, where `T` is the type of the field and\n`AutoTrait` is the auto trait in question. As an example, consider the\nstruct `List` and the auto trait `Send`:\n\n```rust\nstruct List<T> {\n data: T,\n next: Option<Box<List<T>>>,\n}\n```\n\nPresuming that there is no explicit impl of `Send` for `List`, the\ncompiler will supply an automatic impl of the form:\n\n```rust\nstruct List<T> {\n data: T,\n next: Option<Box<List<T>>>,\n}\n\nunsafe impl<T> Send for List<T>\nwhere\n T: Send, // from the field `data`\n Option<Box<List<T>>>: Send, // from the field `next`\n{ }\n```\n\nExplicit impls may be either positive or negative. They take the form:\n\n```rust,ignore\nimpl<...> AutoTrait for StructName<..> { }\nimpl<...> !AutoTrait for StructName<..> { }\n```\n\n## Coinduction: Auto traits permit cyclic matching\n\nUnlike ordinary trait matching, auto traits are **coinductive**. This\nmeans, in short, that cycles which occur in trait matching are\nconsidered ok. As an example, consider the recursive struct `List`\nintroduced in the previous section. In attempting to determine whether\n`List: Send`, we would wind up in a cycle: to apply the impl, we must\nshow that `Option<Box<List>>: Send`, which will in turn require\n`Box<List>: Send` and then finally `List: Send` again. Under ordinary\ntrait matching, this cycle would be an error, but for an auto trait it\nis considered a successful match.\n\n## Items\n\nAuto traits cannot have any trait items, such as methods or associated types. This ensures that we can generate default implementations.\n\n## Supertraits\n\nAuto traits cannot have supertraits. This is for soundness reasons, as the interaction of coinduction with implied bounds is difficult to reconcile.\n\n" } , LintCompletion { label : "rustc_attrs" , description : "# `rustc_attrs`\n\nThis feature has no tracking issue, and is therefore internal to\nthe compiler, not being intended for general use.\n\nNote: `rustc_attrs` enables many rustc-internal attributes and this page\nonly discuss a few of them.\n\n------------------------\n\nThe `rustc_attrs` feature allows debugging rustc type layouts by using\n`#[rustc_layout(...)]` to debug layout at compile time (it even works\nwith `cargo check`) as an alternative to `rustc -Z print-type-sizes`\nthat is way more verbose.\n\nOptions provided by `#[rustc_layout(...)]` are `debug`, `size`, `abi`.\nNote that it only work best with sized type without generics.\n\n## Examples\n\n```rust,ignore\n#![feature(rustc_attrs)]\n\n#[rustc_layout(abi, size)]\npub enum X {\n Y(u8, u8, u8),\n Z(isize),\n}\n```\n\nWhen that is compiled, the compiler will error with something like\n\n```text\nerror: abi: Aggregate { sized: true }\n --> src/lib.rs:4:1\n |\n4 | / pub enum T {\n5 | | Y(u8, u8, u8),\n6 | | Z(isize),\n7 | | }\n | |_^\n\nerror: size: Size { raw: 16 }\n --> src/lib.rs:4:1\n |\n4 | / pub enum T {\n5 | | Y(u8, u8, u8),\n6 | | Z(isize),\n7 | | }\n | |_^\n\nerror: aborting due to 2 previous errors\n```\n" } , LintCompletion { label : "non_ascii_idents" , description : "# `non_ascii_idents`\n\nThe tracking issue for this feature is: [#55467]\n\n[#55467]: https://github.com/rust-lang/rust/issues/55467\n\n------------------------\n\nThe `non_ascii_idents` feature adds support for non-ASCII identifiers.\n\n## Examples\n\n```rust\n#![feature(non_ascii_idents)]\n\nconst ε: f64 = 0.00001f64;\nconst Π: f64 = 3.14f64;\n```\n\n## Changes to the language reference\n\n> **<sup>Lexer:<sup>** \n> IDENTIFIER : \n> &nbsp;&nbsp; &nbsp;&nbsp; XID_start XID_continue<sup>\\*</sup> \n> &nbsp;&nbsp; | `_` XID_continue<sup>+</sup> \n\nAn identifier is any nonempty Unicode string of the following form:\n\nEither\n\n * The first character has property [`XID_start`]\n * The remaining characters have property [`XID_continue`]\n\nOr\n\n * The first character is `_`\n * The identifier is more than one character, `_` alone is not an identifier\n * The remaining characters have property [`XID_continue`]\n\nthat does _not_ occur in the set of [strict keywords].\n\n> **Note**: [`XID_start`] and [`XID_continue`] as character properties cover the\n> character ranges used to form the more familiar C and Java language-family\n> identifiers.\n\n[`XID_start`]: http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5B%3AXID_Start%3A%5D&abb=on&g=&i=\n[`XID_continue`]: http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5B%3AXID_Continue%3A%5D&abb=on&g=&i=\n[strict keywords]: ../../reference/keywords.md#strict-keywords\n" } , LintCompletion { label : "box_syntax" , description : "# `box_syntax`\n\nThe tracking issue for this feature is: [#49733]\n\n[#49733]: https://github.com/rust-lang/rust/issues/49733\n\nSee also [`box_patterns`](box-patterns.md)\n\n------------------------\n\nCurrently the only stable way to create a `Box` is via the `Box::new` method.\nAlso it is not possible in stable Rust to destructure a `Box` in a match\npattern. The unstable `box` keyword can be used to create a `Box`. An example\nusage would be:\n\n```rust\n#![feature(box_syntax)]\n\nfn main() {\n let b = box 5;\n}\n```\n" } , LintCompletion { label : "no_sanitize" , description : "# `no_sanitize`\n\nThe tracking issue for this feature is: [#39699]\n\n[#39699]: https://github.com/rust-lang/rust/issues/39699\n\n------------------------\n\nThe `no_sanitize` attribute can be used to selectively disable sanitizer\ninstrumentation in an annotated function. This might be useful to: avoid\ninstrumentation overhead in a performance critical function, or avoid\ninstrumenting code that contains constructs unsupported by given sanitizer.\n\nThe precise effect of this annotation depends on particular sanitizer in use.\nFor example, with `no_sanitize(thread)`, the thread sanitizer will no longer\ninstrument non-atomic store / load operations, but it will instrument atomic\noperations to avoid reporting false positives and provide meaning full stack\ntraces.\n\n## Examples\n\n``` rust\n#![feature(no_sanitize)]\n\n#[no_sanitize(address)]\nfn foo() {\n // ...\n}\n```\n" } , LintCompletion { label : "trait_alias" , description : "# `trait_alias`\n\nThe tracking issue for this feature is: [#41517]\n\n[#41517]: https://github.com/rust-lang/rust/issues/41517\n\n------------------------\n\nThe `trait_alias` feature adds support for trait aliases. These allow aliases\nto be created for one or more traits (currently just a single regular trait plus\nany number of auto-traits), and used wherever traits would normally be used as\neither bounds or trait objects.\n\n```rust\n#![feature(trait_alias)]\n\ntrait Foo = std::fmt::Debug + Send;\ntrait Bar = Foo + Sync;\n\n// Use trait alias as bound on type parameter.\nfn foo<T: Foo>(v: &T) {\n println!(\"{:?}\", v);\n}\n\npub fn main() {\n foo(&1);\n\n // Use trait alias for trait objects.\n let a: &Bar = &123;\n println!(\"{:?}\", a);\n let b = Box::new(456) as Box<dyn Foo>;\n println!(\"{:?}\", b);\n}\n```\n" } , LintCompletion { label : "unboxed_closures" , description : "# `unboxed_closures`\n\nThe tracking issue for this feature is [#29625]\n\nSee Also: [`fn_traits`](../library-features/fn-traits.md)\n\n[#29625]: https://github.com/rust-lang/rust/issues/29625\n\n----\n\nThe `unboxed_closures` feature allows you to write functions using the `\"rust-call\"` ABI,\nrequired for implementing the [`Fn*`] family of traits. `\"rust-call\"` functions must have \nexactly one (non self) argument, a tuple representing the argument list.\n\n[`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html\n\n```rust\n#![feature(unboxed_closures)]\n\nextern \"rust-call\" fn add_args(args: (u32, u32)) -> u32 {\n args.0 + args.1\n}\n\nfn main() {}\n```\n" } , LintCompletion { label : "lang_items" , description : "# `lang_items`\n\nThe tracking issue for this feature is: None.\n\n------------------------\n\nThe `rustc` compiler has certain pluggable operations, that is,\nfunctionality that isn't hard-coded into the language, but is\nimplemented in libraries, with a special marker to tell the compiler\nit exists. The marker is the attribute `#[lang = \"...\"]` and there are\nvarious different values of `...`, i.e. various different 'lang\nitems'.\n\nFor example, `Box` pointers require two lang items, one for allocation\nand one for deallocation. A freestanding program that uses the `Box`\nsugar for dynamic allocations via `malloc` and `free`:\n\n```rust,ignore\n#![feature(lang_items, box_syntax, start, libc, core_intrinsics)]\n#![no_std]\nuse core::intrinsics;\nuse core::panic::PanicInfo;\n\nextern crate libc;\n\n#[lang = \"owned_box\"]\npub struct Box<T>(*mut T);\n\n#[lang = \"exchange_malloc\"]\nunsafe fn allocate(size: usize, _align: usize) -> *mut u8 {\n let p = libc::malloc(size as libc::size_t) as *mut u8;\n\n // Check if `malloc` failed:\n if p as usize == 0 {\n intrinsics::abort();\n }\n\n p\n}\n\n#[lang = \"box_free\"]\nunsafe fn box_free<T: ?Sized>(ptr: *mut T) {\n libc::free(ptr as *mut libc::c_void)\n}\n\n#[start]\nfn main(_argc: isize, _argv: *const *const u8) -> isize {\n let _x = box 1;\n\n 0\n}\n\n#[lang = \"eh_personality\"] extern fn rust_eh_personality() {}\n#[lang = \"panic_impl\"] extern fn rust_begin_panic(info: &PanicInfo) -> ! { unsafe { intrinsics::abort() } }\n#[no_mangle] pub extern fn rust_eh_register_frames () {}\n#[no_mangle] pub extern fn rust_eh_unregister_frames () {}\n```\n\nNote the use of `abort`: the `exchange_malloc` lang item is assumed to\nreturn a valid pointer, and so needs to do the check internally.\n\nOther features provided by lang items include:\n\n- overloadable operators via traits: the traits corresponding to the\n `==`, `<`, dereferencing (`*`) and `+` (etc.) operators are all\n marked with lang items; those specific four are `eq`, `ord`,\n `deref`, and `add` respectively.\n- stack unwinding and general failure; the `eh_personality`,\n `panic` and `panic_bounds_checks` lang items.\n- the traits in `std::marker` used to indicate types of\n various kinds; lang items `send`, `sync` and `copy`.\n- the marker types and variance indicators found in\n `std::marker`; lang items `covariant_type`,\n `contravariant_lifetime`, etc.\n\nLang items are loaded lazily by the compiler; e.g. if one never uses\n`Box` then there is no need to define functions for `exchange_malloc`\nand `box_free`. `rustc` will emit an error when an item is needed\nbut not found in the current crate or any that it depends on.\n\nMost lang items are defined by `libcore`, but if you're trying to build\nan executable without the standard library, you'll run into the need\nfor lang items. The rest of this page focuses on this use-case, even though\nlang items are a bit broader than that.\n\n### Using libc\n\nIn order to build a `#[no_std]` executable we will need libc as a dependency.\nWe can specify this using our `Cargo.toml` file:\n\n```toml\n[dependencies]\nlibc = { version = \"0.2.14\", default-features = false }\n```\n\nNote that the default features have been disabled. This is a critical step -\n**the default features of libc include the standard library and so must be\ndisabled.**\n\n### Writing an executable without stdlib\n\nControlling the entry point is possible in two ways: the `#[start]` attribute,\nor overriding the default shim for the C `main` function with your own.\n\nThe function marked `#[start]` is passed the command line parameters\nin the same format as C:\n\n```rust,ignore\n#![feature(lang_items, core_intrinsics)]\n#![feature(start)]\n#![no_std]\nuse core::intrinsics;\nuse core::panic::PanicInfo;\n\n// Pull in the system libc library for what crt0.o likely requires.\nextern crate libc;\n\n// Entry point for this program.\n#[start]\nfn start(_argc: isize, _argv: *const *const u8) -> isize {\n 0\n}\n\n// These functions are used by the compiler, but not\n// for a bare-bones hello world. These are normally\n// provided by libstd.\n#[lang = \"eh_personality\"]\n#[no_mangle]\npub extern fn rust_eh_personality() {\n}\n\n#[lang = \"panic_impl\"]\n#[no_mangle]\npub extern fn rust_begin_panic(info: &PanicInfo) -> ! {\n unsafe { intrinsics::abort() }\n}\n```\n\nTo override the compiler-inserted `main` shim, one has to disable it\nwith `#![no_main]` and then create the appropriate symbol with the\ncorrect ABI and the correct name, which requires overriding the\ncompiler's name mangling too:\n\n```rust,ignore\n#![feature(lang_items, core_intrinsics)]\n#![feature(start)]\n#![no_std]\n#![no_main]\nuse core::intrinsics;\nuse core::panic::PanicInfo;\n\n// Pull in the system libc library for what crt0.o likely requires.\nextern crate libc;\n\n// Entry point for this program.\n#[no_mangle] // ensure that this symbol is called `main` in the output\npub extern fn main(_argc: i32, _argv: *const *const u8) -> i32 {\n 0\n}\n\n// These functions are used by the compiler, but not\n// for a bare-bones hello world. These are normally\n// provided by libstd.\n#[lang = \"eh_personality\"]\n#[no_mangle]\npub extern fn rust_eh_personality() {\n}\n\n#[lang = \"panic_impl\"]\n#[no_mangle]\npub extern fn rust_begin_panic(info: &PanicInfo) -> ! {\n unsafe { intrinsics::abort() }\n}\n```\n\nIn many cases, you may need to manually link to the `compiler_builtins` crate\nwhen building a `no_std` binary. You may observe this via linker error messages\nsuch as \"```undefined reference to `__rust_probestack'```\".\n\n## More about the language items\n\nThe compiler currently makes a few assumptions about symbols which are\navailable in the executable to call. Normally these functions are provided by\nthe standard library, but without it you must define your own. These symbols\nare called \"language items\", and they each have an internal name, and then a\nsignature that an implementation must conform to.\n\nThe first of these functions, `rust_eh_personality`, is used by the failure\nmechanisms of the compiler. This is often mapped to GCC's personality function\n(see the [libstd implementation][unwind] for more information), but crates\nwhich do not trigger a panic can be assured that this function is never\ncalled. The language item's name is `eh_personality`.\n\n[unwind]: https://github.com/rust-lang/rust/blob/master/src/libpanic_unwind/gcc.rs\n\nThe second function, `rust_begin_panic`, is also used by the failure mechanisms of the\ncompiler. When a panic happens, this controls the message that's displayed on\nthe screen. While the language item's name is `panic_impl`, the symbol name is\n`rust_begin_panic`.\n\nFinally, a `eh_catch_typeinfo` static is needed for certain targets which\nimplement Rust panics on top of C++ exceptions.\n\n## List of all language items\n\nThis is a list of all language items in Rust along with where they are located in\nthe source code.\n\n- Primitives\n - `i8`: `libcore/num/mod.rs`\n - `i16`: `libcore/num/mod.rs`\n - `i32`: `libcore/num/mod.rs`\n - `i64`: `libcore/num/mod.rs`\n - `i128`: `libcore/num/mod.rs`\n - `isize`: `libcore/num/mod.rs`\n - `u8`: `libcore/num/mod.rs`\n - `u16`: `libcore/num/mod.rs`\n - `u32`: `libcore/num/mod.rs`\n - `u64`: `libcore/num/mod.rs`\n - `u128`: `libcore/num/mod.rs`\n - `usize`: `libcore/num/mod.rs`\n - `f32`: `libstd/f32.rs`\n - `f64`: `libstd/f64.rs`\n - `char`: `libcore/char.rs`\n - `slice`: `liballoc/slice.rs`\n - `str`: `liballoc/str.rs`\n - `const_ptr`: `libcore/ptr.rs`\n - `mut_ptr`: `libcore/ptr.rs`\n - `unsafe_cell`: `libcore/cell.rs`\n- Runtime\n - `start`: `libstd/rt.rs`\n - `eh_personality`: `libpanic_unwind/emcc.rs` (EMCC)\n - `eh_personality`: `libpanic_unwind/gcc.rs` (GNU)\n - `eh_personality`: `libpanic_unwind/seh.rs` (SEH)\n - `eh_catch_typeinfo`: `libpanic_unwind/emcc.rs` (EMCC)\n - `panic`: `libcore/panicking.rs`\n - `panic_bounds_check`: `libcore/panicking.rs`\n - `panic_impl`: `libcore/panicking.rs`\n - `panic_impl`: `libstd/panicking.rs`\n- Allocations\n - `owned_box`: `liballoc/boxed.rs`\n - `exchange_malloc`: `liballoc/heap.rs`\n - `box_free`: `liballoc/heap.rs`\n- Operands\n - `not`: `libcore/ops/bit.rs`\n - `bitand`: `libcore/ops/bit.rs`\n - `bitor`: `libcore/ops/bit.rs`\n - `bitxor`: `libcore/ops/bit.rs`\n - `shl`: `libcore/ops/bit.rs`\n - `shr`: `libcore/ops/bit.rs`\n - `bitand_assign`: `libcore/ops/bit.rs`\n - `bitor_assign`: `libcore/ops/bit.rs`\n - `bitxor_assign`: `libcore/ops/bit.rs`\n - `shl_assign`: `libcore/ops/bit.rs`\n - `shr_assign`: `libcore/ops/bit.rs`\n - `deref`: `libcore/ops/deref.rs`\n - `deref_mut`: `libcore/ops/deref.rs`\n - `index`: `libcore/ops/index.rs`\n - `index_mut`: `libcore/ops/index.rs`\n - `add`: `libcore/ops/arith.rs`\n - `sub`: `libcore/ops/arith.rs`\n - `mul`: `libcore/ops/arith.rs`\n - `div`: `libcore/ops/arith.rs`\n - `rem`: `libcore/ops/arith.rs`\n - `neg`: `libcore/ops/arith.rs`\n - `add_assign`: `libcore/ops/arith.rs`\n - `sub_assign`: `libcore/ops/arith.rs`\n - `mul_assign`: `libcore/ops/arith.rs`\n - `div_assign`: `libcore/ops/arith.rs`\n - `rem_assign`: `libcore/ops/arith.rs`\n - `eq`: `libcore/cmp.rs`\n - `ord`: `libcore/cmp.rs`\n- Functions\n - `fn`: `libcore/ops/function.rs`\n - `fn_mut`: `libcore/ops/function.rs`\n - `fn_once`: `libcore/ops/function.rs`\n - `generator_state`: `libcore/ops/generator.rs`\n - `generator`: `libcore/ops/generator.rs`\n- Other\n - `coerce_unsized`: `libcore/ops/unsize.rs`\n - `drop`: `libcore/ops/drop.rs`\n - `drop_in_place`: `libcore/ptr.rs`\n - `clone`: `libcore/clone.rs`\n - `copy`: `libcore/marker.rs`\n - `send`: `libcore/marker.rs`\n - `sized`: `libcore/marker.rs`\n - `unsize`: `libcore/marker.rs`\n - `sync`: `libcore/marker.rs`\n - `phantom_data`: `libcore/marker.rs`\n - `discriminant_kind`: `libcore/marker.rs`\n - `freeze`: `libcore/marker.rs`\n - `debug_trait`: `libcore/fmt/mod.rs`\n - `non_zero`: `libcore/nonzero.rs`\n - `arc`: `liballoc/sync.rs`\n - `rc`: `liballoc/rc.rs`\n" } , LintCompletion { label : "negative_impls" , description : "# `negative_impls`\n\nThe tracking issue for this feature is [#68318].\n\n[#68318]: https://github.com/rust-lang/rust/issues/68318\n\n----\n\nWith the feature gate `negative_impls`, you can write negative impls as well as positive ones:\n\n```rust\n#![feature(negative_impls)]\ntrait DerefMut { }\nimpl<T: ?Sized> !DerefMut for &T { }\n```\n\nNegative impls indicate a semver guarantee that the given trait will not be implemented for the given types. Negative impls play an additional purpose for auto traits, described below.\n\nNegative impls have the following characteristics:\n\n* They do not have any items.\n* They must obey the orphan rules as if they were a positive impl.\n* They cannot \"overlap\" with any positive impls.\n\n## Semver interaction\n\nIt is a breaking change to remove a negative impl. Negative impls are a commitment not to implement the given trait for the named types.\n\n## Orphan and overlap rules\n\nNegative impls must obey the same orphan rules as a positive impl. This implies you cannot add a negative impl for types defined in upstream crates and so forth.\n\nSimilarly, negative impls cannot overlap with positive impls, again using the same \"overlap\" check that we ordinarily use to determine if two impls overlap. (Note that positive impls typically cannot overlap with one another either, except as permitted by specialization.)\n\n## Interaction with auto traits\n\nDeclaring a negative impl `impl !SomeAutoTrait for SomeType` for an\nauto-trait serves two purposes:\n\n* as with any trait, it declares that `SomeType` will never implement `SomeAutoTrait`;\n* it disables the automatic `SomeType: SomeAutoTrait` impl that would otherwise have been generated.\n\nNote that, at present, there is no way to indicate that a given type\ndoes not implement an auto trait *but that it may do so in the\nfuture*. For ordinary types, this is done by simply not declaring any\nimpl at all, but that is not an option for auto traits. A workaround\nis that one could embed a marker type as one of the fields, where the\nmarker type is `!AutoTrait`.\n\n## Immediate uses\n\nNegative impls are used to declare that `&T: !DerefMut` and `&mut T: !Clone`, as required to fix the soundness of `Pin` described in [#66544](https://github.com/rust-lang/rust/issues/66544).\n\nThis serves two purposes:\n\n* For proving the correctness of unsafe code, we can use that impl as evidence that no `DerefMut` or `Clone` impl exists.\n* It prevents downstream crates from creating such impls.\n" } , LintCompletion { label : "abi_ptx" , description : "# `abi_ptx`\n\nThe tracking issue for this feature is: [#38788]\n\n[#38788]: https://github.com/rust-lang/rust/issues/38788\n\n------------------------\n\nWhen emitting PTX code, all vanilla Rust functions (`fn`) get translated to\n\"device\" functions. These functions are *not* callable from the host via the\nCUDA API so a crate with only device functions is not too useful!\n\nOTOH, \"global\" functions *can* be called by the host; you can think of them\nas the real public API of your crate. To produce a global function use the\n`\"ptx-kernel\"` ABI.\n\n<!-- NOTE(ignore) this example is specific to the nvptx targets -->\n\n``` rust,ignore\n#![feature(abi_ptx)]\n#![no_std]\n\npub unsafe extern \"ptx-kernel\" fn global_function() {\n device_function();\n}\n\npub fn device_function() {\n // ..\n}\n```\n\n``` text\n$ xargo rustc --target nvptx64-nvidia-cuda --release -- --emit=asm\n\n$ cat $(find -name '*.s')\n//\n// Generated by LLVM NVPTX Back-End\n//\n\n.version 3.2\n.target sm_20\n.address_size 64\n\n // .globl _ZN6kernel15global_function17h46111ebe6516b382E\n\n.visible .entry _ZN6kernel15global_function17h46111ebe6516b382E()\n{\n\n\n ret;\n}\n\n // .globl _ZN6kernel15device_function17hd6a0e4993bbf3f78E\n.visible .func _ZN6kernel15device_function17hd6a0e4993bbf3f78E()\n{\n\n\n ret;\n}\n```\n" } , LintCompletion { label : "try_blocks" , description : "# `try_blocks`\n\nThe tracking issue for this feature is: [#31436]\n\n[#31436]: https://github.com/rust-lang/rust/issues/31436\n\n------------------------\n\nThe `try_blocks` feature adds support for `try` blocks. A `try`\nblock creates a new scope one can use the `?` operator in.\n\n```rust,edition2018\n#![feature(try_blocks)]\n\nuse std::num::ParseIntError;\n\nlet result: Result<i32, ParseIntError> = try {\n \"1\".parse::<i32>()?\n + \"2\".parse::<i32>()?\n + \"3\".parse::<i32>()?\n};\nassert_eq!(result, Ok(6));\n\nlet result: Result<i32, ParseIntError> = try {\n \"1\".parse::<i32>()?\n + \"foo\".parse::<i32>()?\n + \"3\".parse::<i32>()?\n};\nassert!(result.is_err());\n```\n" } , LintCompletion { label : "profiler_runtime" , description : "# `profiler_runtime`\n\nThe tracking issue for this feature is: [#42524](https://github.com/rust-lang/rust/issues/42524).\n\n------------------------\n" } , LintCompletion { label : "compiler_builtins" , description : "# `compiler_builtins`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "doc_spotlight" , description : "# `doc_spotlight`\n\nThe tracking issue for this feature is: [#45040]\n\nThe `doc_spotlight` feature allows the use of the `spotlight` parameter to the `#[doc]` attribute,\nto \"spotlight\" a specific trait on the return values of functions. Adding a `#[doc(spotlight)]`\nattribute to a trait definition will make rustdoc print extra information for functions which return\na type that implements that trait. This attribute is applied to the `Iterator`, `io::Read`, and\n`io::Write` traits in the standard library.\n\nYou can do this on your own traits, like this:\n\n```\n#![feature(doc_spotlight)]\n\n#[doc(spotlight)]\npub trait MyTrait {}\n\npub struct MyStruct;\nimpl MyTrait for MyStruct {}\n\n/// The docs for this function will have an extra line about `MyStruct` implementing `MyTrait`,\n/// without having to write that yourself!\npub fn my_fn() -> MyStruct { MyStruct }\n```\n\nThis feature was originally implemented in PR [#45039].\n\n[#45040]: https://github.com/rust-lang/rust/issues/45040\n[#45039]: https://github.com/rust-lang/rust/pull/45039\n" } , LintCompletion { label : "box_patterns" , description : "# `box_patterns`\n\nThe tracking issue for this feature is: [#29641]\n\n[#29641]: https://github.com/rust-lang/rust/issues/29641\n\nSee also [`box_syntax`](box-syntax.md)\n\n------------------------\n\nBox patterns let you match on `Box<T>`s:\n\n\n```rust\n#![feature(box_patterns)]\n\nfn main() {\n let b = Some(Box::new(5));\n match b {\n Some(box n) if n < 0 => {\n println!(\"Box contains negative number {}\", n);\n },\n Some(box n) if n >= 0 => {\n println!(\"Box contains non-negative number {}\", n);\n },\n None => {\n println!(\"No box\");\n },\n _ => unreachable!()\n }\n}\n```\n" } , LintCompletion { label : "const_eval_limit" , description : "# `const_eval_limit`\n\nThe tracking issue for this feature is: [#67217]\n\n[#67217]: https://github.com/rust-lang/rust/issues/67217\n\nThe `const_eval_limit` allows someone to limit the evaluation steps the CTFE undertakes to evaluate a `const fn`.\n" } , LintCompletion { label : "arbitrary_enum_discriminant" , description : "# `arbitrary_enum_discriminant`\n\nThe tracking issue for this feature is: [#60553]\n\n[#60553]: https://github.com/rust-lang/rust/issues/60553\n\n------------------------\n\nThe `arbitrary_enum_discriminant` feature permits tuple-like and\nstruct-like enum variants with `#[repr(<int-type>)]` to have explicit discriminants.\n\n## Examples\n\n```rust\n#![feature(arbitrary_enum_discriminant)]\n\n#[allow(dead_code)]\n#[repr(u8)]\nenum Enum {\n Unit = 3,\n Tuple(u16) = 2,\n Struct {\n a: u8,\n b: u16,\n } = 1,\n}\n\nimpl Enum {\n fn tag(&self) -> u8 {\n unsafe { *(self as *const Self as *const u8) }\n }\n}\n\nassert_eq!(3, Enum::Unit.tag());\nassert_eq!(2, Enum::Tuple(5).tag());\nassert_eq!(1, Enum::Struct{a: 7, b: 11}.tag());\n```\n" } , LintCompletion { label : "custom_test_frameworks" , description : "# `custom_test_frameworks`\n\nThe tracking issue for this feature is: [#50297]\n\n[#50297]: https://github.com/rust-lang/rust/issues/50297\n\n------------------------\n\nThe `custom_test_frameworks` feature allows the use of `#[test_case]` and `#![test_runner]`.\nAny function, const, or static can be annotated with `#[test_case]` causing it to be aggregated (like `#[test]`)\nand be passed to the test runner determined by the `#![test_runner]` crate attribute.\n\n```rust\n#![feature(custom_test_frameworks)]\n#![test_runner(my_runner)]\n\nfn my_runner(tests: &[&i32]) {\n for t in tests {\n if **t == 0 {\n println!(\"PASSED\");\n } else {\n println!(\"FAILED\");\n }\n }\n}\n\n#[test_case]\nconst WILL_PASS: i32 = 0;\n\n#[test_case]\nconst WILL_FAIL: i32 = 4;\n```\n\n" } , LintCompletion { label : "plugin_registrar" , description : "# `plugin_registrar`\n\nThe tracking issue for this feature is: [#29597]\n\n[#29597]: https://github.com/rust-lang/rust/issues/29597\n\nThis feature is part of \"compiler plugins.\" It will often be used with the\n[`plugin`] and `rustc_private` features as well. For more details, see\ntheir docs.\n\n[`plugin`]: plugin.md\n\n------------------------\n" } , LintCompletion { label : "impl_trait_in_bindings" , description : "# `impl_trait_in_bindings`\n\nThe tracking issue for this feature is: [#63065]\n\n[#63065]: https://github.com/rust-lang/rust/issues/63065\n\n------------------------\n\nThe `impl_trait_in_bindings` feature gate lets you use `impl Trait` syntax in\n`let`, `static`, and `const` bindings.\n\nA simple example is:\n\n```rust\n#![feature(impl_trait_in_bindings)]\n\nuse std::fmt::Debug;\n\nfn main() {\n let a: impl Debug + Clone = 42;\n let b = a.clone();\n println!(\"{:?}\", b); // prints `42`\n}\n```\n\nNote however that because the types of `a` and `b` are opaque in the above\nexample, calling inherent methods or methods outside of the specified traits\n(e.g., `a.abs()` or `b.abs()`) is not allowed, and yields an error.\n" } , LintCompletion { label : "ffi_pure" , description : "# `ffi_pure`\n\nThe `#[ffi_pure]` attribute applies clang's `pure` attribute to foreign\nfunctions declarations.\n\nThat is, `#[ffi_pure]` functions shall have no effects except for its return\nvalue, which shall not change across two consecutive function calls with\nthe same parameters.\n\nApplying the `#[ffi_pure]` attribute to a function that violates these\nrequirements is undefined behavior.\n\nThis attribute enables Rust to perform common optimizations, like sub-expression\nelimination and loop optimizations. Some common examples of pure functions are\n`strlen` or `memcmp`.\n\nThese optimizations are only applicable when the compiler can prove that no\nprogram state observable by the `#[ffi_pure]` function has changed between calls\nof the function, which could alter the result. See also the `#[ffi_const]`\nattribute, which provides stronger guarantees regarding the allowable behavior\nof a function, enabling further optimization.\n\n## Pitfalls\n\nA `#[ffi_pure]` function can read global memory through the function\nparameters (e.g. pointers), globals, etc. `#[ffi_pure]` functions are not\nreferentially-transparent, and are therefore more relaxed than `#[ffi_const]`\nfunctions.\n\nHowever, accesing global memory through volatile or atomic reads can violate the\nrequirement that two consecutive function calls shall return the same value.\n\nA `pure` function that returns unit has no effect on the abstract machine's\nstate.\n\nA `#[ffi_pure]` function must not diverge, neither via a side effect (e.g. a\ncall to `abort`) nor by infinite loops.\n\nWhen translating C headers to Rust FFI, it is worth verifying for which targets\nthe `pure` attribute is enabled in those headers, and using the appropriate\n`cfg` macros in the Rust side to match those definitions. While the semantics of\n`pure` are implemented identically by many C and C++ compilers, e.g., clang,\n[GCC], [ARM C/C++ compiler], [IBM ILE C/C++], etc. they are not necessarily\nimplemented in this way on all of them. It is therefore also worth verifying\nthat the semantics of the C toolchain used to compile the binary being linked\nagainst are compatible with those of the `#[ffi_pure]`.\n\n\n[ARM C/C++ compiler]: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/Cacigdac.html\n[GCC]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute\n[IBM ILE C/C++]: https://www.ibm.com/support/knowledgecenter/fr/ssw_ibm_i_71/rzarg/fn_attrib_pure.htm\n" } , LintCompletion { label : "const_fn" , description : "# `const_fn`\n\nThe tracking issue for this feature is: [#57563]\n\n[#57563]: https://github.com/rust-lang/rust/issues/57563\n\n------------------------\n\nThe `const_fn` feature allows marking free functions and inherent methods as\n`const`, enabling them to be called in constants contexts, with constant\narguments.\n\n## Examples\n\n```rust\n#![feature(const_fn)]\n\nconst fn double(x: i32) -> i32 {\n x * 2\n}\n\nconst FIVE: i32 = 5;\nconst TEN: i32 = double(FIVE);\n\nfn main() {\n assert_eq!(5, FIVE);\n assert_eq!(10, TEN);\n}\n```\n" } , LintCompletion { label : "intrinsics" , description : "# `intrinsics`\n\nThe tracking issue for this feature is: None.\n\nIntrinsics are never intended to be stable directly, but intrinsics are often\nexported in some sort of stable manner. Prefer using the stable interfaces to\nthe intrinsic directly when you can.\n\n------------------------\n\n\nThese are imported as if they were FFI functions, with the special\n`rust-intrinsic` ABI. For example, if one was in a freestanding\ncontext, but wished to be able to `transmute` between types, and\nperform efficient pointer arithmetic, one would import those functions\nvia a declaration like\n\n```rust\n#![feature(intrinsics)]\n# fn main() {}\n\nextern \"rust-intrinsic\" {\n fn transmute<T, U>(x: T) -> U;\n\n fn offset<T>(dst: *const T, offset: isize) -> *const T;\n}\n```\n\nAs with any other FFI functions, these are always `unsafe` to call.\n\n" } , LintCompletion { label : "c_variadic" , description : "# `c_variadic`\n\nThe tracking issue for this feature is: [#44930]\n\n[#44930]: https://github.com/rust-lang/rust/issues/44930\n\n------------------------\n\nThe `c_variadic` language feature enables C-variadic functions to be\ndefined in Rust. The may be called both from within Rust and via FFI.\n\n## Examples\n\n```rust\n#![feature(c_variadic)]\n\npub unsafe extern \"C\" fn add(n: usize, mut args: ...) -> usize {\n let mut sum = 0;\n for _ in 0..n {\n sum += args.arg::<usize>();\n }\n sum\n}\n```\n" } , LintCompletion { label : "cfg_sanitize" , description : "# `cfg_sanitize`\n\nThe tracking issue for this feature is: [#39699]\n\n[#39699]: https://github.com/rust-lang/rust/issues/39699\n\n------------------------\n\nThe `cfg_sanitize` feature makes it possible to execute different code\ndepending on whether a particular sanitizer is enabled or not.\n\n## Examples\n\n```rust\n#![feature(cfg_sanitize)]\n\n#[cfg(sanitize = \"thread\")]\nfn a() {\n // ...\n}\n\n#[cfg(not(sanitize = \"thread\"))]\nfn a() {\n // ...\n}\n\nfn b() {\n if cfg!(sanitize = \"leak\") {\n // ...\n } else {\n // ...\n }\n}\n```\n" } , LintCompletion { label : "allocator_internals" , description : "# `allocator_internals`\n\nThis feature does not have a tracking issue, it is an unstable implementation\ndetail of the `global_allocator` feature not intended for use outside the\ncompiler.\n\n------------------------\n" } , LintCompletion { label : "doc_alias" , description : "# `doc_alias`\n\nThe tracking issue for this feature is: [#50146]\n\n[#50146]: https://github.com/rust-lang/rust/issues/50146\n\n------------------------\n\nYou can add alias(es) to an item when using the `rustdoc` search through the\n`doc(alias)` attribute. Example:\n\n```rust,no_run\n#![feature(doc_alias)]\n\n#[doc(alias = \"x\")]\n#[doc(alias = \"big\")]\npub struct BigX;\n```\n\nThen, when looking for it through the `rustdoc` search, if you enter \"x\" or\n\"big\", search will show the `BigX` struct first.\n\nNote that this feature is currently hidden behind the `feature(doc_alias)` gate.\n" } , LintCompletion { label : "link_cfg" , description : "# `link_cfg`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "transparent_unions" , description : "# `transparent_unions`\n\nThe tracking issue for this feature is [#60405]\n\n[#60405]: https://github.com/rust-lang/rust/issues/60405\n\n----\n\nThe `transparent_unions` feature allows you mark `union`s as\n`#[repr(transparent)]`. A `union` may be `#[repr(transparent)]` in exactly the\nsame conditions in which a `struct` may be `#[repr(transparent)]` (generally,\nthis means the `union` must have exactly one non-zero-sized field). Some\nconcrete illustrations follow.\n\n```rust\n#![feature(transparent_unions)]\n\n// This union has the same representation as `f32`.\n#[repr(transparent)]\nunion SingleFieldUnion {\n field: f32,\n}\n\n// This union has the same representation as `usize`.\n#[repr(transparent)]\nunion MultiFieldUnion {\n field: usize,\n nothing: (),\n}\n```\n\nFor consistency with transparent `struct`s, `union`s must have exactly one\nnon-zero-sized field. If all fields are zero-sized, the `union` must not be\n`#[repr(transparent)]`:\n\n```rust\n#![feature(transparent_unions)]\n\n// This (non-transparent) union is already valid in stable Rust:\npub union GoodUnion {\n pub nothing: (),\n}\n\n// Error: transparent union needs exactly one non-zero-sized field, but has 0\n// #[repr(transparent)]\n// pub union BadUnion {\n// pub nothing: (),\n// }\n```\n\nThe one exception is if the `union` is generic over `T` and has a field of type\n`T`, it may be `#[repr(transparent)]` even if `T` is a zero-sized type:\n\n```rust\n#![feature(transparent_unions)]\n\n// This union has the same representation as `T`.\n#[repr(transparent)]\npub union GenericUnion<T: Copy> { // Unions with non-`Copy` fields are unstable.\n pub field: T,\n pub nothing: (),\n}\n\n// This is okay even though `()` is a zero-sized type.\npub const THIS_IS_OKAY: GenericUnion<()> = GenericUnion { field: () };\n```\n\nLike transarent `struct`s, a transparent `union` of type `U` has the same\nlayout, size, and ABI as its single non-ZST field. If it is generic over a type\n`T`, and all its fields are ZSTs except for exactly one field of type `T`, then\nit has the same layout and ABI as `T` (even if `T` is a ZST when monomorphized).\n\nLike transparent `struct`s, transparent `union`s are FFI-safe if and only if\ntheir underlying representation type is also FFI-safe.\n\nA `union` may not be eligible for the same nonnull-style optimizations that a\n`struct` or `enum` (with the same fields) are eligible for. Adding\n`#[repr(transparent)]` to `union` does not change this. To give a more concrete\nexample, it is unspecified whether `size_of::<T>()` is equal to\n`size_of::<Option<T>>()`, where `T` is a `union` (regardless of whether or not\nit is transparent). The Rust compiler is free to perform this optimization if\npossible, but is not required to, and different compiler versions may differ in\ntheir application of these optimizations.\n" } , LintCompletion { label : "plugin" , description : "# `plugin`\n\nThe tracking issue for this feature is: [#29597]\n\n[#29597]: https://github.com/rust-lang/rust/issues/29597\n\n\nThis feature is part of \"compiler plugins.\" It will often be used with the\n[`plugin_registrar`] and `rustc_private` features.\n\n[`plugin_registrar`]: plugin-registrar.md\n\n------------------------\n\n`rustc` can load compiler plugins, which are user-provided libraries that\nextend the compiler's behavior with new lint checks, etc.\n\nA plugin is a dynamic library crate with a designated *registrar* function that\nregisters extensions with `rustc`. Other crates can load these extensions using\nthe crate attribute `#![plugin(...)]`. See the\n`rustc_driver::plugin` documentation for more about the\nmechanics of defining and loading a plugin.\n\nIn the vast majority of cases, a plugin should *only* be used through\n`#![plugin]` and not through an `extern crate` item. Linking a plugin would\npull in all of librustc_ast and librustc as dependencies of your crate. This is\ngenerally unwanted unless you are building another plugin.\n\nThe usual practice is to put compiler plugins in their own crate, separate from\nany `macro_rules!` macros or ordinary Rust code meant to be used by consumers\nof a library.\n\n# Lint plugins\n\nPlugins can extend [Rust's lint\ninfrastructure](../../reference/attributes/diagnostics.md#lint-check-attributes) with\nadditional checks for code style, safety, etc. Now let's write a plugin\n[`lint-plugin-test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs)\nthat warns about any item named `lintme`.\n\n```rust,ignore\n#![feature(plugin_registrar)]\n#![feature(box_syntax, rustc_private)]\n\nextern crate rustc_ast;\n\n// Load rustc as a plugin to get macros\nextern crate rustc_driver;\n#[macro_use]\nextern crate rustc_lint;\n#[macro_use]\nextern crate rustc_session;\n\nuse rustc_driver::plugin::Registry;\nuse rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};\nuse rustc_ast::ast;\ndeclare_lint!(TEST_LINT, Warn, \"Warn about items named 'lintme'\");\n\ndeclare_lint_pass!(Pass => [TEST_LINT]);\n\nimpl EarlyLintPass for Pass {\n fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {\n if it.ident.name.as_str() == \"lintme\" {\n cx.lint(TEST_LINT, |lint| {\n lint.build(\"item is named 'lintme'\").set_span(it.span).emit()\n });\n }\n }\n}\n\n#[plugin_registrar]\npub fn plugin_registrar(reg: &mut Registry) {\n reg.lint_store.register_lints(&[&TEST_LINT]);\n reg.lint_store.register_early_pass(|| box Pass);\n}\n```\n\nThen code like\n\n```rust,ignore\n#![feature(plugin)]\n#![plugin(lint_plugin_test)]\n\nfn lintme() { }\n```\n\nwill produce a compiler warning:\n\n```txt\nfoo.rs:4:1: 4:16 warning: item is named 'lintme', #[warn(test_lint)] on by default\nfoo.rs:4 fn lintme() { }\n ^~~~~~~~~~~~~~~\n```\n\nThe components of a lint plugin are:\n\n* one or more `declare_lint!` invocations, which define static `Lint` structs;\n\n* a struct holding any state needed by the lint pass (here, none);\n\n* a `LintPass`\n implementation defining how to check each syntax element. A single\n `LintPass` may call `span_lint` for several different `Lint`s, but should\n register them all through the `get_lints` method.\n\nLint passes are syntax traversals, but they run at a late stage of compilation\nwhere type information is available. `rustc`'s [built-in\nlints](https://github.com/rust-lang/rust/blob/master/src/librustc_session/lint/builtin.rs)\nmostly use the same infrastructure as lint plugins, and provide examples of how\nto access type information.\n\nLints defined by plugins are controlled by the usual [attributes and compiler\nflags](../../reference/attributes/diagnostics.md#lint-check-attributes), e.g.\n`#[allow(test_lint)]` or `-A test-lint`. These identifiers are derived from the\nfirst argument to `declare_lint!`, with appropriate case and punctuation\nconversion.\n\nYou can run `rustc -W help foo.rs` to see a list of lints known to `rustc`,\nincluding those provided by plugins loaded by `foo.rs`.\n" } , LintCompletion { label : "concat_idents" , description : "# `concat_idents`\n\nThe tracking issue for this feature is: [#29599]\n\n[#29599]: https://github.com/rust-lang/rust/issues/29599\n\n------------------------\n\nThe `concat_idents` feature adds a macro for concatenating multiple identifiers\ninto one identifier.\n\n## Examples\n\n```rust\n#![feature(concat_idents)]\n\nfn main() {\n fn foobar() -> u32 { 23 }\n let f = concat_idents!(foo, bar);\n assert_eq!(f(), 23);\n}\n```" } , LintCompletion { label : "update_panic_count" , description : "# `update_panic_count`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "fn_traits" , description : "# `fn_traits`\n\nThe tracking issue for this feature is [#29625]\n\nSee Also: [`unboxed_closures`](../language-features/unboxed-closures.md)\n\n[#29625]: https://github.com/rust-lang/rust/issues/29625\n\n----\n\nThe `fn_traits` feature allows for implementation of the [`Fn*`] traits\nfor creating custom closure-like types.\n\n[`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html\n\n```rust\n#![feature(unboxed_closures)]\n#![feature(fn_traits)]\n\nstruct Adder {\n a: u32\n}\n\nimpl FnOnce<(u32, )> for Adder {\n type Output = u32;\n extern \"rust-call\" fn call_once(self, b: (u32, )) -> Self::Output {\n self.a + b.0\n }\n}\n\nfn main() {\n let adder = Adder { a: 3 };\n assert_eq!(adder(2), 5);\n}\n```\n" } , LintCompletion { label : "try_trait" , description : "# `try_trait`\n\nThe tracking issue for this feature is: [#42327]\n\n[#42327]: https://github.com/rust-lang/rust/issues/42327\n\n------------------------\n\nThis introduces a new trait `Try` for extending the `?` operator to types\nother than `Result` (a part of [RFC 1859]). The trait provides the canonical\nway to _view_ a type in terms of a success/failure dichotomy. This will\nallow `?` to supplant the `try_opt!` macro on `Option` and the `try_ready!`\nmacro on `Poll`, among other things.\n\n[RFC 1859]: https://github.com/rust-lang/rfcs/pull/1859\n\nHere's an example implementation of the trait:\n\n```rust,ignore\n/// A distinct type to represent the `None` value of an `Option`.\n///\n/// This enables using the `?` operator on `Option`; it's rarely useful alone.\n#[derive(Debug)]\n#[unstable(feature = \"try_trait\", issue = \"42327\")]\npub struct None { _priv: () }\n\n#[unstable(feature = \"try_trait\", issue = \"42327\")]\nimpl<T> ops::Try for Option<T> {\n type Ok = T;\n type Error = None;\n\n fn into_result(self) -> Result<T, None> {\n self.ok_or(None { _priv: () })\n }\n\n fn from_ok(v: T) -> Self {\n Some(v)\n }\n\n fn from_error(_: None) -> Self {\n None\n }\n}\n```\n\nNote the `Error` associated type here is a new marker. The `?` operator\nallows interconversion between different `Try` implementers only when\nthe error type can be converted `Into` the error type of the enclosing\nfunction (or catch block). Having a distinct error type (as opposed to\njust `()`, or similar) restricts this to where it's semantically meaningful.\n" } , LintCompletion { label : "rt" , description : "# `rt`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "default_free_fn" , description : "# `default_free_fn`\n\nThe tracking issue for this feature is: [#73014]\n\n[#73014]: https://github.com/rust-lang/rust/issues/73014\n\n------------------------\n\nAdds a free `default()` function to the `std::default` module. This function\njust forwards to [`Default::default()`], but may remove repetition of the word\n\"default\" from the call site.\n\nHere is an example:\n\n```rust\n#![feature(default_free_fn)]\nuse std::default::default;\n\n#[derive(Default)]\nstruct AppConfig {\n foo: FooConfig,\n bar: BarConfig,\n}\n\n#[derive(Default)]\nstruct FooConfig {\n foo: i32,\n}\n\n#[derive(Default)]\nstruct BarConfig {\n bar: f32,\n baz: u8,\n}\n\nfn main() {\n let options = AppConfig {\n foo: default(),\n bar: BarConfig {\n bar: 10.1,\n ..default()\n },\n };\n}\n```\n" } , LintCompletion { label : "libstd_sys_internals" , description : "# `libstd_sys_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "fd" , description : "# `fd`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "dec2flt" , description : "# `dec2flt`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "fmt_internals" , description : "# `fmt_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "int_error_internals" , description : "# `int_error_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "libstd_thread_internals" , description : "# `libstd_thread_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "windows_net" , description : "# `windows_net`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "core_intrinsics" , description : "# `core_intrinsics`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "global_asm" , description : "# `global_asm`\n\nThe tracking issue for this feature is: [#35119]\n\n[#35119]: https://github.com/rust-lang/rust/issues/35119\n\n------------------------\n\nThe `global_asm!` macro allows the programmer to write arbitrary\nassembly outside the scope of a function body, passing it through\n`rustc` and `llvm` to the assembler. The macro is a no-frills\ninterface to LLVM's concept of [module-level inline assembly]. That is,\nall caveats applicable to LLVM's module-level inline assembly apply\nto `global_asm!`.\n\n[module-level inline assembly]: http://llvm.org/docs/LangRef.html#module-level-inline-assembly\n\n`global_asm!` fills a role not currently satisfied by either `asm!`\nor `#[naked]` functions. The programmer has _all_ features of the\nassembler at their disposal. The linker will expect to resolve any\nsymbols defined in the inline assembly, modulo any symbols marked as\nexternal. It also means syntax for directives and assembly follow the\nconventions of the assembler in your toolchain.\n\nA simple usage looks like this:\n\n```rust,ignore\n# #![feature(global_asm)]\n# you also need relevant target_arch cfgs\nglobal_asm!(include_str!(\"something_neato.s\"));\n```\n\nAnd a more complicated usage looks like this:\n\n```rust,ignore\n# #![feature(global_asm)]\n# #![cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\n\npub mod sally {\n global_asm!(r#\"\n .global foo\n foo:\n jmp baz\n \"#);\n\n #[no_mangle]\n pub unsafe extern \"C\" fn baz() {}\n}\n\n// the symbols `foo` and `bar` are global, no matter where\n// `global_asm!` was used.\nextern \"C\" {\n fn foo();\n fn bar();\n}\n\npub mod harry {\n global_asm!(r#\"\n .global bar\n bar:\n jmp quux\n \"#);\n\n #[no_mangle]\n pub unsafe extern \"C\" fn quux() {}\n}\n```\n\nYou may use `global_asm!` multiple times, anywhere in your crate, in\nwhatever way suits you. The effect is as if you concatenated all\nusages and placed the larger, single usage in the crate root.\n\n------------------------\n\nIf you don't need quite as much power and flexibility as\n`global_asm!` provides, and you don't mind restricting your inline\nassembly to `fn` bodies only, you might try the\n[asm](asm.md) feature instead.\n" } , LintCompletion { label : "sort_internals" , description : "# `sort_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "test" , description : "# `test`\n\nThe tracking issue for this feature is: None.\n\n------------------------\n\nThe internals of the `test` crate are unstable, behind the `test` flag. The\nmost widely used part of the `test` crate are benchmark tests, which can test\nthe performance of your code. Let's make our `src/lib.rs` look like this\n(comments elided):\n\n```rust,ignore\n#![feature(test)]\n\nextern crate test;\n\npub fn add_two(a: i32) -> i32 {\n a + 2\n}\n\n#[cfg(test)]\nmod tests {\n use super::*;\n use test::Bencher;\n\n #[test]\n fn it_works() {\n assert_eq!(4, add_two(2));\n }\n\n #[bench]\n fn bench_add_two(b: &mut Bencher) {\n b.iter(|| add_two(2));\n }\n}\n```\n\nNote the `test` feature gate, which enables this unstable feature.\n\nWe've imported the `test` crate, which contains our benchmarking support.\nWe have a new function as well, with the `bench` attribute. Unlike regular\ntests, which take no arguments, benchmark tests take a `&mut Bencher`. This\n`Bencher` provides an `iter` method, which takes a closure. This closure\ncontains the code we'd like to benchmark.\n\nWe can run benchmark tests with `cargo bench`:\n\n```bash\n$ cargo bench\n Compiling adder v0.0.1 (file:///home/steve/tmp/adder)\n Running target/release/adder-91b3e234d4ed382a\n\nrunning 2 tests\ntest tests::it_works ... ignored\ntest tests::bench_add_two ... bench: 1 ns/iter (+/- 0)\n\ntest result: ok. 0 passed; 0 failed; 1 ignored; 1 measured\n```\n\nOur non-benchmark test was ignored. You may have noticed that `cargo bench`\ntakes a bit longer than `cargo test`. This is because Rust runs our benchmark\na number of times, and then takes the average. Because we're doing so little\nwork in this example, we have a `1 ns/iter (+/- 0)`, but this would show\nthe variance if there was one.\n\nAdvice on writing benchmarks:\n\n\n* Move setup code outside the `iter` loop; only put the part you want to measure inside\n* Make the code do \"the same thing\" on each iteration; do not accumulate or change state\n* Make the outer function idempotent too; the benchmark runner is likely to run\n it many times\n* Make the inner `iter` loop short and fast so benchmark runs are fast and the\n calibrator can adjust the run-length at fine resolution\n* Make the code in the `iter` loop do something simple, to assist in pinpointing\n performance improvements (or regressions)\n\n## Gotcha: optimizations\n\nThere's another tricky part to writing benchmarks: benchmarks compiled with\noptimizations activated can be dramatically changed by the optimizer so that\nthe benchmark is no longer benchmarking what one expects. For example, the\ncompiler might recognize that some calculation has no external effects and\nremove it entirely.\n\n```rust,ignore\n#![feature(test)]\n\nextern crate test;\nuse test::Bencher;\n\n#[bench]\nfn bench_xor_1000_ints(b: &mut Bencher) {\n b.iter(|| {\n (0..1000).fold(0, |old, new| old ^ new);\n });\n}\n```\n\ngives the following results\n\n```text\nrunning 1 test\ntest bench_xor_1000_ints ... bench: 0 ns/iter (+/- 0)\n\ntest result: ok. 0 passed; 0 failed; 0 ignored; 1 measured\n```\n\nThe benchmarking runner offers two ways to avoid this. Either, the closure that\nthe `iter` method receives can return an arbitrary value which forces the\noptimizer to consider the result used and ensures it cannot remove the\ncomputation entirely. This could be done for the example above by adjusting the\n`b.iter` call to\n\n```rust\n# struct X;\n# impl X { fn iter<T, F>(&self, _: F) where F: FnMut() -> T {} } let b = X;\nb.iter(|| {\n // Note lack of `;` (could also use an explicit `return`).\n (0..1000).fold(0, |old, new| old ^ new)\n});\n```\n\nOr, the other option is to call the generic `test::black_box` function, which\nis an opaque \"black box\" to the optimizer and so forces it to consider any\nargument as used.\n\n```rust\n#![feature(test)]\n\nextern crate test;\n\n# fn main() {\n# struct X;\n# impl X { fn iter<T, F>(&self, _: F) where F: FnMut() -> T {} } let b = X;\nb.iter(|| {\n let n = test::black_box(1000);\n\n (0..n).fold(0, |a, b| a ^ b)\n})\n# }\n```\n\nNeither of these read or modify the value, and are very cheap for small values.\nLarger values can be passed indirectly to reduce overhead (e.g.\n`black_box(&huge_struct)`).\n\nPerforming either of the above changes gives the following benchmarking results\n\n```text\nrunning 1 test\ntest bench_xor_1000_ints ... bench: 131 ns/iter (+/- 3)\n\ntest result: ok. 0 passed; 0 failed; 0 ignored; 1 measured\n```\n\nHowever, the optimizer can still modify a testcase in an undesirable manner\neven when using either of the above.\n" } , LintCompletion { label : "windows_stdio" , description : "# `windows_stdio`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "allocator_api" , description : "# `allocator_api`\n\nThe tracking issue for this feature is [#32838]\n\n[#32838]: https://github.com/rust-lang/rust/issues/32838\n\n------------------------\n\nSometimes you want the memory for one collection to use a different\nallocator than the memory for another collection. In this case,\nreplacing the global allocator is not a workable option. Instead,\nyou need to pass in an instance of an `AllocRef` to each collection\nfor which you want a custom allocator.\n\nTBD\n" } , LintCompletion { label : "asm" , description : "# `asm`\n\nThe tracking issue for this feature is: [#72016]\n\n[#72016]: https://github.com/rust-lang/rust/issues/72016\n\n------------------------\n\nFor extremely low-level manipulations and performance reasons, one\nmight wish to control the CPU directly. Rust supports using inline\nassembly to do this via the `asm!` macro.\n\n# Guide-level explanation\n[guide-level-explanation]: #guide-level-explanation\n\nRust provides support for inline assembly via the `asm!` macro.\nIt can be used to embed handwritten assembly in the assembly output generated by the compiler.\nGenerally this should not be necessary, but might be where the required performance or timing\ncannot be otherwise achieved. Accessing low level hardware primitives, e.g. in kernel code, may also demand this functionality.\n\n> **Note**: the examples here are given in x86/x86-64 assembly, but ARM, AArch64 and RISC-V are also supported.\n\n## Basic usage\n\nLet us start with the simplest possible example:\n\n```rust,allow_fail\n# #![feature(asm)]\nunsafe {\n asm!(\"nop\");\n}\n```\n\nThis will insert a NOP (no operation) instruction into the assembly generated by the compiler.\nNote that all `asm!` invocations have to be inside an `unsafe` block, as they could insert\narbitrary instructions and break various invariants. The instructions to be inserted are listed\nin the first argument of the `asm!` macro as a string literal.\n\n## Inputs and outputs\n\nNow inserting an instruction that does nothing is rather boring. Let us do something that\nactually acts on data:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet x: u64;\nunsafe {\n asm!(\"mov {}, 5\", out(reg) x);\n}\nassert_eq!(x, 5);\n```\n\nThis will write the value `5` into the `u64` variable `x`.\nYou can see that the string literal we use to specify instructions is actually a template string.\nIt is governed by the same rules as Rust [format strings][format-syntax].\nThe arguments that are inserted into the template however look a bit different then you may\nbe familiar with. First we need to specify if the variable is an input or an output of the\ninline assembly. In this case it is an output. We declared this by writing `out`.\nWe also need to specify in what kind of register the assembly expects the variable.\nIn this case we put it in an arbitrary general purpose register by specifying `reg`.\nThe compiler will choose an appropriate register to insert into\nthe template and will read the variable from there after the inline assembly finishes executing.\n\nLet us see another example that also uses an input:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet i: u64 = 3;\nlet o: u64;\nunsafe {\n asm!(\n \"mov {0}, {1}\",\n \"add {0}, {number}\",\n out(reg) o,\n in(reg) i,\n number = const 5,\n );\n}\nassert_eq!(o, 8);\n```\n\nThis will add `5` to the input in variable `i` and write the result to variable `o`.\nThe particular way this assembly does this is first copying the value from `i` to the output,\nand then adding `5` to it.\n\nThe example shows a few things:\n\nFirst, we can see that `asm!` allows multiple template string arguments; each\none is treated as a separate line of assembly code, as if they were all joined\ntogether with newlines between them. This makes it easy to format assembly\ncode.\n\nSecond, we can see that inputs are declared by writing `in` instead of `out`.\n\nThird, one of our operands has a type we haven't seen yet, `const`.\nThis tells the compiler to expand this argument to value directly inside the assembly template.\nThis is only possible for constants and literals.\n\nFourth, we can see that we can specify an argument number, or name as in any format string.\nFor inline assembly templates this is particularly useful as arguments are often used more than once.\nFor more complex inline assembly using this facility is generally recommended, as it improves\nreadability, and allows reordering instructions without changing the argument order.\n\nWe can further refine the above example to avoid the `mov` instruction:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet mut x: u64 = 3;\nunsafe {\n asm!(\"add {0}, {number}\", inout(reg) x, number = const 5);\n}\nassert_eq!(x, 8);\n```\n\nWe can see that `inout` is used to specify an argument that is both input and output.\nThis is different from specifying an input and output separately in that it is guaranteed to assign both to the same register.\n\nIt is also possible to specify different variables for the input and output parts of an `inout` operand:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet x: u64 = 3;\nlet y: u64;\nunsafe {\n asm!(\"add {0}, {number}\", inout(reg) x => y, number = const 5);\n}\nassert_eq!(y, 8);\n```\n\n## Late output operands\n\nThe Rust compiler is conservative with its allocation of operands. It is assumed that an `out`\ncan be written at any time, and can therefore not share its location with any other argument.\nHowever, to guarantee optimal performance it is important to use as few registers as possible,\nso they won't have to be saved and reloaded around the inline assembly block.\nTo achieve this Rust provides a `lateout` specifier. This can be used on any output that is\nwritten only after all inputs have been consumed.\nThere is also a `inlateout` variant of this specifier.\n\nHere is an example where `inlateout` *cannot* be used:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet mut a: u64 = 4;\nlet b: u64 = 4;\nlet c: u64 = 4;\nunsafe {\n asm!(\n \"add {0}, {1}\",\n \"add {0}, {2}\",\n inout(reg) a,\n in(reg) b,\n in(reg) c,\n );\n}\nassert_eq!(a, 12);\n```\n\nHere the compiler is free to allocate the same register for inputs `b` and `c` since it knows they have the same value. However it must allocate a separate register for `a` since it uses `inout` and not `inlateout`. If `inlateout` was used, then `a` and `c` could be allocated to the same register, in which case the first instruction to overwrite the value of `c` and cause the assembly code to produce the wrong result.\n\nHowever the following example can use `inlateout` since the output is only modified after all input registers have been read:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet mut a: u64 = 4;\nlet b: u64 = 4;\nunsafe {\n asm!(\"add {0}, {1}\", inlateout(reg) a, in(reg) b);\n}\nassert_eq!(a, 8);\n```\n\nAs you can see, this assembly fragment will still work correctly if `a` and `b` are assigned to the same register.\n\n## Explicit register operands\n\nSome instructions require that the operands be in a specific register.\nTherefore, Rust inline assembly provides some more specific constraint specifiers.\nWhile `reg` is generally available on any architecture, these are highly architecture specific. E.g. for x86 the general purpose registers `eax`, `ebx`, `ecx`, `edx`, `ebp`, `esi`, and `edi`\namong others can be addressed by their name.\n\n```rust,allow_fail,no_run\n# #![feature(asm)]\nlet cmd = 0xd1;\nunsafe {\n asm!(\"out 0x64, eax\", in(\"eax\") cmd);\n}\n```\n\nIn this example we call the `out` instruction to output the content of the `cmd` variable\nto port `0x64`. Since the `out` instruction only accepts `eax` (and its sub registers) as operand\nwe had to use the `eax` constraint specifier.\n\nNote that unlike other operand types, explicit register operands cannot be used in the template string: you can't use `{}` and should write the register name directly instead. Also, they must appear at the end of the operand list after all other operand types.\n\nConsider this example which uses the x86 `mul` instruction:\n\n```rust,allow_fail\n# #![feature(asm)]\nfn mul(a: u64, b: u64) -> u128 {\n let lo: u64;\n let hi: u64;\n\n unsafe {\n asm!(\n // The x86 mul instruction takes rax as an implicit input and writes\n // the 128-bit result of the multiplication to rax:rdx.\n \"mul {}\",\n in(reg) a,\n inlateout(\"rax\") b => lo,\n lateout(\"rdx\") hi\n );\n }\n\n ((hi as u128) << 64) + lo as u128\n}\n```\n\nThis uses the `mul` instruction to multiply two 64-bit inputs with a 128-bit result.\nThe only explicit operand is a register, that we fill from the variable `a`.\nThe second operand is implicit, and must be the `rax` register, which we fill from the variable `b`.\nThe lower 64 bits of the result are stored in `rax` from which we fill the variable `lo`.\nThe higher 64 bits are stored in `rdx` from which we fill the variable `hi`.\n\n## Clobbered registers\n\nIn many cases inline assembly will modify state that is not needed as an output.\nUsually this is either because we have to use a scratch register in the assembly,\nor instructions modify state that we don't need to further examine.\nThis state is generally referred to as being \"clobbered\".\nWe need to tell the compiler about this since it may need to save and restore this state\naround the inline assembly block.\n\n```rust,allow_fail\n# #![feature(asm)]\nlet ebx: u32;\nlet ecx: u32;\n\nunsafe {\n asm!(\n \"cpuid\",\n // EAX 4 selects the \"Deterministic Cache Parameters\" CPUID leaf\n inout(\"eax\") 4 => _,\n // ECX 0 selects the L0 cache information.\n inout(\"ecx\") 0 => ecx,\n lateout(\"ebx\") ebx,\n lateout(\"edx\") _,\n );\n}\n\nprintln!(\n \"L1 Cache: {}\",\n ((ebx >> 22) + 1) * (((ebx >> 12) & 0x3ff) + 1) * ((ebx & 0xfff) + 1) * (ecx + 1)\n);\n```\n\nIn the example above we use the `cpuid` instruction to get the L1 cache size.\nThis instruction writes to `eax`, `ebx`, `ecx`, and `edx`, but for the cache size we only care about the contents of `ebx` and `ecx`.\n\nHowever we still need to tell the compiler that `eax` and `edx` have been modified so that it can save any values that were in these registers before the asm. This is done by declaring these as outputs but with `_` instead of a variable name, which indicates that the output value is to be discarded.\n\nThis can also be used with a general register class (e.g. `reg`) to obtain a scratch register for use inside the asm code:\n\n```rust,allow_fail\n# #![feature(asm)]\n// Multiply x by 6 using shifts and adds\nlet mut x: u64 = 4;\nunsafe {\n asm!(\n \"mov {tmp}, {x}\",\n \"shl {tmp}, 1\",\n \"shl {x}, 2\",\n \"add {x}, {tmp}\",\n x = inout(reg) x,\n tmp = out(reg) _,\n );\n}\nassert_eq!(x, 4 * 6);\n```\n\n## Symbol operands\n\nA special operand type, `sym`, allows you to use the symbol name of a `fn` or `static` in inline assembly code.\nThis allows you to call a function or access a global variable without needing to keep its address in a register.\n\n```rust,allow_fail\n# #![feature(asm)]\nextern \"C\" fn foo(arg: i32) {\n println!(\"arg = {}\", arg);\n}\n\nfn call_foo(arg: i32) {\n unsafe {\n asm!(\n \"call {}\",\n sym foo,\n // 1st argument in rdi, which is caller-saved\n inout(\"rdi\") arg => _,\n // All caller-saved registers must be marked as clobberred\n out(\"rax\") _, out(\"rcx\") _, out(\"rdx\") _, out(\"rsi\") _,\n out(\"r8\") _, out(\"r9\") _, out(\"r10\") _, out(\"r11\") _,\n out(\"xmm0\") _, out(\"xmm1\") _, out(\"xmm2\") _, out(\"xmm3\") _,\n out(\"xmm4\") _, out(\"xmm5\") _, out(\"xmm6\") _, out(\"xmm7\") _,\n out(\"xmm8\") _, out(\"xmm9\") _, out(\"xmm10\") _, out(\"xmm11\") _,\n out(\"xmm12\") _, out(\"xmm13\") _, out(\"xmm14\") _, out(\"xmm15\") _,\n )\n }\n}\n```\n\nNote that the `fn` or `static` item does not need to be public or `#[no_mangle]`:\nthe compiler will automatically insert the appropriate mangled symbol name into the assembly code.\n\n## Register template modifiers\n\nIn some cases, fine control is needed over the way a register name is formatted when inserted into the template string. This is needed when an architecture's assembly language has several names for the same register, each typically being a \"view\" over a subset of the register (e.g. the low 32 bits of a 64-bit register).\n\nBy default the compiler will always choose the name that refers to the full register size (e.g. `rax` on x86-64, `eax` on x86, etc).\n\nThis default can be overriden by using modifiers on the template string operands, just like you would with format strings:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet mut x: u16 = 0xab;\n\nunsafe {\n asm!(\"mov {0:h}, {0:l}\", inout(reg_abcd) x);\n}\n\nassert_eq!(x, 0xabab);\n```\n\nIn this example, we use the `reg_abcd` register class to restrict the register allocator to the 4 legacy x86 register (`ax`, `bx`, `cx`, `dx`) of which the first two bytes can be addressed independently.\n\nLet us assume that the register allocator has chosen to allocate `x` in the `ax` register.\nThe `h` modifier will emit the register name for the high byte of that register and the `l` modifier will emit the register name for the low byte. The asm code will therefore be expanded as `mov ah, al` which copies the low byte of the value into the high byte.\n\nIf you use a smaller data type (e.g. `u16`) with an operand and forget the use template modifiers, the compiler will emit a warning and suggest the correct modifier to use.\n\n## Options\n\nBy default, an inline assembly block is treated the same way as an external FFI function call with a custom calling convention: it may read/write memory, have observable side effects, etc. However in many cases, it is desirable to give the compiler more information about what the assembly code is actually doing so that it can optimize better.\n\nLet's take our previous example of an `add` instruction:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet mut a: u64 = 4;\nlet b: u64 = 4;\nunsafe {\n asm!(\n \"add {0}, {1}\",\n inlateout(reg) a, in(reg) b,\n options(pure, nomem, nostack),\n );\n}\nassert_eq!(a, 8);\n```\n\nOptions can be provided as an optional final argument to the `asm!` macro. We specified three options here:\n- `pure` means that the asm code has no observable side effects and that its output depends only on its inputs. This allows the compiler optimizer to call the inline asm fewer times or even eliminate it entirely.\n- `nomem` means that the asm code does not read or write to memory. By default the compiler will assume that inline assembly can read or write any memory address that is accessible to it (e.g. through a pointer passed as an operand, or a global).\n- `nostack` means that the asm code does not push any data onto the stack. This allows the compiler to use optimizations such as the stack red zone on x86-64 to avoid stack pointer adjustments.\n\nThese allow the compiler to better optimize code using `asm!`, for example by eliminating pure `asm!` blocks whose outputs are not needed.\n\nSee the reference for the full list of available options and their effects.\n\n# Reference-level explanation\n[reference-level-explanation]: #reference-level-explanation\n\nInline assembler is implemented as an unsafe macro `asm!()`.\nThe first argument to this macro is a template string literal used to build the final assembly.\nThe following arguments specify input and output operands.\nWhen required, options are specified as the final argument.\n\nThe following ABNF specifies the general syntax:\n\n```ignore\ndir_spec := \"in\" / \"out\" / \"lateout\" / \"inout\" / \"inlateout\"\nreg_spec := <register class> / \"<explicit register>\"\noperand_expr := expr / \"_\" / expr \"=>\" expr / expr \"=>\" \"_\"\nreg_operand := dir_spec \"(\" reg_spec \")\" operand_expr\noperand := reg_operand / \"const\" const_expr / \"sym\" path\noption := \"pure\" / \"nomem\" / \"readonly\" / \"preserves_flags\" / \"noreturn\" / \"att_syntax\"\noptions := \"options(\" option *[\",\" option] [\",\"] \")\"\nasm := \"asm!(\" format_string *(\",\" format_string) *(\",\" [ident \"=\"] operand) [\",\" options] [\",\"] \")\"\n```\n\nThe macro will initially be supported only on ARM, AArch64, Hexagon, x86, x86-64 and RISC-V targets. Support for more targets may be added in the future. The compiler will emit an error if `asm!` is used on an unsupported target.\n\n[format-syntax]: https://doc.rust-lang.org/std/fmt/#syntax\n\n## Template string arguments\n\nThe assembler template uses the same syntax as [format strings][format-syntax] (i.e. placeholders are specified by curly braces). The corresponding arguments are accessed in order, by index, or by name. However, implicit named arguments (introduced by [RFC #2795][rfc-2795]) are not supported.\n\nAn `asm!` invocation may have one or more template string arguments; an `asm!` with multiple template string arguments is treated as if all the strings were concatenated with a `\\n` between them. The expected usage is for each template string argument to correspond to a line of assembly code. All template string arguments must appear before any other arguments.\n\nAs with format strings, named arguments must appear after positional arguments. Explicit register operands must appear at the end of the operand list, after named arguments if any.\n\nExplicit register operands cannot be used by placeholders in the template string. All other named and positional operands must appear at least once in the template string, otherwise a compiler error is generated.\n\nThe exact assembly code syntax is target-specific and opaque to the compiler except for the way operands are substituted into the template string to form the code passed to the assembler.\n\nThe 5 targets specified in this RFC (x86, ARM, AArch64, RISC-V, Hexagon) all use the assembly code syntax of the GNU assembler (GAS). On x86, the `.intel_syntax noprefix` mode of GAS is used by default. On ARM, the `.syntax unified` mode is used. These targets impose an additional restriction on the assembly code: any assembler state (e.g. the current section which can be changed with `.section`) must be restored to its original value at the end of the asm string. Assembly code that does not conform to the GAS syntax will result in assembler-specific behavior.\n\n[rfc-2795]: https://github.com/rust-lang/rfcs/pull/2795\n\n## Operand type\n\nSeveral types of operands are supported:\n\n* `in(<reg>) <expr>`\n - `<reg>` can refer to a register class or an explicit register. The allocated register name is substituted into the asm template string.\n - The allocated register will contain the value of `<expr>` at the start of the asm code.\n - The allocated register must contain the same value at the end of the asm code (except if a `lateout` is allocated to the same register).\n* `out(<reg>) <expr>`\n - `<reg>` can refer to a register class or an explicit register. The allocated register name is substituted into the asm template string.\n - The allocated register will contain an undefined value at the start of the asm code.\n - `<expr>` must be a (possibly uninitialized) place expression, to which the contents of the allocated register is written to at the end of the asm code.\n - An underscore (`_`) may be specified instead of an expression, which will cause the contents of the register to be discarded at the end of the asm code (effectively acting as a clobber).\n* `lateout(<reg>) <expr>`\n - Identical to `out` except that the register allocator can reuse a register allocated to an `in`.\n - You should only write to the register after all inputs are read, otherwise you may clobber an input.\n* `inout(<reg>) <expr>`\n - `<reg>` can refer to a register class or an explicit register. The allocated register name is substituted into the asm template string.\n - The allocated register will contain the value of `<expr>` at the start of the asm code.\n - `<expr>` must be a mutable initialized place expression, to which the contents of the allocated register is written to at the end of the asm code.\n* `inout(<reg>) <in expr> => <out expr>`\n - Same as `inout` except that the initial value of the register is taken from the value of `<in expr>`.\n - `<out expr>` must be a (possibly uninitialized) place expression, to which the contents of the allocated register is written to at the end of the asm code.\n - An underscore (`_`) may be specified instead of an expression for `<out expr>`, which will cause the contents of the register to be discarded at the end of the asm code (effectively acting as a clobber).\n - `<in expr>` and `<out expr>` may have different types.\n* `inlateout(<reg>) <expr>` / `inlateout(<reg>) <in expr> => <out expr>`\n - Identical to `inout` except that the register allocator can reuse a register allocated to an `in` (this can happen if the compiler knows the `in` has the same initial value as the `inlateout`).\n - You should only write to the register after all inputs are read, otherwise you may clobber an input.\n* `const <expr>`\n - `<expr>` must be an integer or floating-point constant expression.\n - The value of the expression is formatted as a string and substituted directly into the asm template string.\n* `sym <path>`\n - `<path>` must refer to a `fn` or `static`.\n - A mangled symbol name referring to the item is substituted into the asm template string.\n - The substituted string does not include any modifiers (e.g. GOT, PLT, relocations, etc).\n - `<path>` is allowed to point to a `#[thread_local]` static, in which case the asm code can combine the symbol with relocations (e.g. `@plt`, `@TPOFF`) to read from thread-local data.\n\nOperand expressions are evaluated from left to right, just like function call arguments. After the `asm!` has executed, outputs are written to in left to right order. This is significant if two outputs point to the same place: that place will contain the value of the rightmost output.\n\n## Register operands\n\nInput and output operands can be specified either as an explicit register or as a register class from which the register allocator can select a register. Explicit registers are specified as string literals (e.g. `\"eax\"`) while register classes are specified as identifiers (e.g. `reg`). Using string literals for register names enables support for architectures that use special characters in register names, such as MIPS (`$0`, `$1`, etc).\n\nNote that explicit registers treat register aliases (e.g. `r14` vs `lr` on ARM) and smaller views of a register (e.g. `eax` vs `rax`) as equivalent to the base register. It is a compile-time error to use the same explicit register for two input operands or two output operands. Additionally, it is also a compile-time error to use overlapping registers (e.g. ARM VFP) in input operands or in output operands.\n\nOnly the following types are allowed as operands for inline assembly:\n- Integers (signed and unsigned)\n- Floating-point numbers\n- Pointers (thin only)\n- Function pointers\n- SIMD vectors (structs defined with `#[repr(simd)]` and which implement `Copy`). This includes architecture-specific vector types defined in `std::arch` such as `__m128` (x86) or `int8x16_t` (ARM).\n\nHere is the list of currently supported register classes:\n\n| Architecture | Register class | Registers | LLVM constraint code |\n| ------------ | -------------- | --------- | -------------------- |\n| x86 | `reg` | `ax`, `bx`, `cx`, `dx`, `si`, `di`, `r[8-15]` (x86-64 only) | `r` |\n| x86 | `reg_abcd` | `ax`, `bx`, `cx`, `dx` | `Q` |\n| x86-32 | `reg_byte` | `al`, `bl`, `cl`, `dl`, `ah`, `bh`, `ch`, `dh` | `q` |\n| x86-64 | `reg_byte` | `al`, `bl`, `cl`, `dl`, `sil`, `dil`, `r[8-15]b`, `ah`\\*, `bh`\\*, `ch`\\*, `dh`\\* | `q` |\n| x86 | `xmm_reg` | `xmm[0-7]` (x86) `xmm[0-15]` (x86-64) | `x` |\n| x86 | `ymm_reg` | `ymm[0-7]` (x86) `ymm[0-15]` (x86-64) | `x` |\n| x86 | `zmm_reg` | `zmm[0-7]` (x86) `zmm[0-31]` (x86-64) | `v` |\n| x86 | `kreg` | `k[1-7]` | `Yk` |\n| AArch64 | `reg` | `x[0-28]`, `x30` | `r` |\n| AArch64 | `vreg` | `v[0-31]` | `w` |\n| AArch64 | `vreg_low16` | `v[0-15]` | `x` |\n| ARM | `reg` | `r[0-5]` `r7`\\*, `r[8-10]`, `r11`\\*, `r12`, `r14` | `r` |\n| ARM (Thumb) | `reg_thumb` | `r[0-r7]` | `l` |\n| ARM (ARM) | `reg_thumb` | `r[0-r10]`, `r12`, `r14` | `l` |\n| ARM | `sreg` | `s[0-31]` | `t` |\n| ARM | `sreg_low16` | `s[0-15]` | `x` |\n| ARM | `dreg` | `d[0-31]` | `w` |\n| ARM | `dreg_low16` | `d[0-15]` | `t` |\n| ARM | `dreg_low8` | `d[0-8]` | `x` |\n| ARM | `qreg` | `q[0-15]` | `w` |\n| ARM | `qreg_low8` | `q[0-7]` | `t` |\n| ARM | `qreg_low4` | `q[0-3]` | `x` |\n| NVPTX | `reg16` | None\\* | `h` |\n| NVPTX | `reg32` | None\\* | `r` |\n| NVPTX | `reg64` | None\\* | `l` |\n| RISC-V | `reg` | `x1`, `x[5-7]`, `x[9-15]`, `x[16-31]` (non-RV32E) | `r` |\n| RISC-V | `freg` | `f[0-31]` | `f` |\n| Hexagon | `reg` | `r[0-28]` | `r` |\n\n> **Note**: On x86 we treat `reg_byte` differently from `reg` because the compiler can allocate `al` and `ah` separately whereas `reg` reserves the whole register.\n>\n> Note #2: On x86-64 the high byte registers (e.g. `ah`) are only available when used as an explicit register. Specifying the `reg_byte` register class for an operand will always allocate a low byte register.\n>\n> Note #3: NVPTX doesn't have a fixed register set, so named registers are not supported.\n>\n> Note #4: On ARM the frame pointer is either `r7` or `r11` depending on the platform.\n\nAdditional register classes may be added in the future based on demand (e.g. MMX, x87, etc).\n\nEach register class has constraints on which value types they can be used with. This is necessary because the way a value is loaded into a register depends on its type. For example, on big-endian systems, loading a `i32x4` and a `i8x16` into a SIMD register may result in different register contents even if the byte-wise memory representation of both values is identical. The availability of supported types for a particular register class may depend on what target features are currently enabled.\n\n| Architecture | Register class | Target feature | Allowed types |\n| ------------ | -------------- | -------------- | ------------- |\n| x86-32 | `reg` | None | `i16`, `i32`, `f32` |\n| x86-64 | `reg` | None | `i16`, `i32`, `f32`, `i64`, `f64` |\n| x86 | `reg_byte` | None | `i8` |\n| x86 | `xmm_reg` | `sse` | `i32`, `f32`, `i64`, `f64`, <br> `i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2` |\n| x86 | `ymm_reg` | `avx` | `i32`, `f32`, `i64`, `f64`, <br> `i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2` <br> `i8x32`, `i16x16`, `i32x8`, `i64x4`, `f32x8`, `f64x4` |\n| x86 | `zmm_reg` | `avx512f` | `i32`, `f32`, `i64`, `f64`, <br> `i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2` <br> `i8x32`, `i16x16`, `i32x8`, `i64x4`, `f32x8`, `f64x4` <br> `i8x64`, `i16x32`, `i32x16`, `i64x8`, `f32x16`, `f64x8` |\n| x86 | `kreg` | `axv512f` | `i8`, `i16` |\n| x86 | `kreg` | `axv512bw` | `i32`, `i64` |\n| AArch64 | `reg` | None | `i8`, `i16`, `i32`, `f32`, `i64`, `f64` |\n| AArch64 | `vreg` | `fp` | `i8`, `i16`, `i32`, `f32`, `i64`, `f64`, <br> `i8x8`, `i16x4`, `i32x2`, `i64x1`, `f32x2`, `f64x1`, <br> `i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2` |\n| ARM | `reg` | None | `i8`, `i16`, `i32`, `f32` |\n| ARM | `sreg` | `vfp2` | `i32`, `f32` |\n| ARM | `dreg` | `vfp2` | `i64`, `f64`, `i8x8`, `i16x4`, `i32x2`, `i64x1`, `f32x2` |\n| ARM | `qreg` | `neon` | `i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4` |\n| NVPTX | `reg16` | None | `i8`, `i16` |\n| NVPTX | `reg32` | None | `i8`, `i16`, `i32`, `f32` |\n| NVPTX | `reg64` | None | `i8`, `i16`, `i32`, `f32`, `i64`, `f64` |\n| RISC-V32 | `reg` | None | `i8`, `i16`, `i32`, `f32` |\n| RISC-V64 | `reg` | None | `i8`, `i16`, `i32`, `f32`, `i64`, `f64` |\n| RISC-V | `freg` | `f` | `f32` |\n| RISC-V | `freg` | `d` | `f64` |\n| Hexagon | `reg` | None | `i8`, `i16`, `i32`, `f32` |\n\n> **Note**: For the purposes of the above table pointers, function pointers and `isize`/`usize` are treated as the equivalent integer type (`i16`/`i32`/`i64` depending on the target).\n\nIf a value is of a smaller size than the register it is allocated in then the upper bits of that register will have an undefined value for inputs and will be ignored for outputs. The only exception is the `freg` register class on RISC-V where `f32` values are NaN-boxed in a `f64` as required by the RISC-V architecture.\n\nWhen separate input and output expressions are specified for an `inout` operand, both expressions must have the same type. The only exception is if both operands are pointers or integers, in which case they are only required to have the same size. This restriction exists because the register allocators in LLVM and GCC sometimes cannot handle tied operands with different types.\n\n## Register names\n\nSome registers have multiple names. These are all treated by the compiler as identical to the base register name. Here is the list of all supported register aliases:\n\n| Architecture | Base register | Aliases |\n| ------------ | ------------- | ------- |\n| x86 | `ax` | `eax`, `rax` |\n| x86 | `bx` | `ebx`, `rbx` |\n| x86 | `cx` | `ecx`, `rcx` |\n| x86 | `dx` | `edx`, `rdx` |\n| x86 | `si` | `esi`, `rsi` |\n| x86 | `di` | `edi`, `rdi` |\n| x86 | `bp` | `bpl`, `ebp`, `rbp` |\n| x86 | `sp` | `spl`, `esp`, `rsp` |\n| x86 | `ip` | `eip`, `rip` |\n| x86 | `st(0)` | `st` |\n| x86 | `r[8-15]` | `r[8-15]b`, `r[8-15]w`, `r[8-15]d` |\n| x86 | `xmm[0-31]` | `ymm[0-31]`, `zmm[0-31]` |\n| AArch64 | `x[0-30]` | `w[0-30]` |\n| AArch64 | `x29` | `fp` |\n| AArch64 | `x30` | `lr` |\n| AArch64 | `sp` | `wsp` |\n| AArch64 | `xzr` | `wzr` |\n| AArch64 | `v[0-31]` | `b[0-31]`, `h[0-31]`, `s[0-31]`, `d[0-31]`, `q[0-31]` |\n| ARM | `r[0-3]` | `a[1-4]` |\n| ARM | `r[4-9]` | `v[1-6]` |\n| ARM | `r9` | `rfp` |\n| ARM | `r10` | `sl` |\n| ARM | `r11` | `fp` |\n| ARM | `r12` | `ip` |\n| ARM | `r13` | `sp` |\n| ARM | `r14` | `lr` |\n| ARM | `r15` | `pc` |\n| RISC-V | `x0` | `zero` |\n| RISC-V | `x1` | `ra` |\n| RISC-V | `x2` | `sp` |\n| RISC-V | `x3` | `gp` |\n| RISC-V | `x4` | `tp` |\n| RISC-V | `x[5-7]` | `t[0-2]` |\n| RISC-V | `x8` | `fp`, `s0` |\n| RISC-V | `x9` | `s1` |\n| RISC-V | `x[10-17]` | `a[0-7]` |\n| RISC-V | `x[18-27]` | `s[2-11]` |\n| RISC-V | `x[28-31]` | `t[3-6]` |\n| RISC-V | `f[0-7]` | `ft[0-7]` |\n| RISC-V | `f[8-9]` | `fs[0-1]` |\n| RISC-V | `f[10-17]` | `fa[0-7]` |\n| RISC-V | `f[18-27]` | `fs[2-11]` |\n| RISC-V | `f[28-31]` | `ft[8-11]` |\n| Hexagon | `r29` | `sp` |\n| Hexagon | `r30` | `fr` |\n| Hexagon | `r31` | `lr` |\n\nSome registers cannot be used for input or output operands:\n\n| Architecture | Unsupported register | Reason |\n| ------------ | -------------------- | ------ |\n| All | `sp` | The stack pointer must be restored to its original value at the end of an asm code block. |\n| All | `bp` (x86), `x29` (AArch64), `x8` (RISC-V), `fr` (Hexagon) | The frame pointer cannot be used as an input or output. |\n| ARM | `r7` or `r11` | On ARM the frame pointer can be either `r7` or `r11` depending on the target. The frame pointer cannot be used as an input or output. |\n| ARM | `r6` | `r6` is used internally by LLVM as a base pointer and therefore cannot be used as an input or output. |\n| x86 | `k0` | This is a constant zero register which can't be modified. |\n| x86 | `ip` | This is the program counter, not a real register. |\n| x86 | `mm[0-7]` | MMX registers are not currently supported (but may be in the future). |\n| x86 | `st([0-7])` | x87 registers are not currently supported (but may be in the future). |\n| AArch64 | `xzr` | This is a constant zero register which can't be modified. |\n| ARM | `pc` | This is the program counter, not a real register. |\n| RISC-V | `x0` | This is a constant zero register which can't be modified. |\n| RISC-V | `gp`, `tp` | These registers are reserved and cannot be used as inputs or outputs. |\n| Hexagon | `lr` | This is the link register which cannot be used as an input or output. |\n\n## Template modifiers\n\nThe placeholders can be augmented by modifiers which are specified after the `:` in the curly braces. These modifiers do not affect register allocation, but change the way operands are formatted when inserted into the template string. Only one modifier is allowed per template placeholder.\n\nThe supported modifiers are a subset of LLVM's (and GCC's) [asm template argument modifiers][llvm-argmod], but do not use the same letter codes.\n\n| Architecture | Register class | Modifier | Example output | LLVM modifier |\n| ------------ | -------------- | -------- | -------------- | ------------- |\n| x86-32 | `reg` | None | `eax` | `k` |\n| x86-64 | `reg` | None | `rax` | `q` |\n| x86-32 | `reg_abcd` | `l` | `al` | `b` |\n| x86-64 | `reg` | `l` | `al` | `b` |\n| x86 | `reg_abcd` | `h` | `ah` | `h` |\n| x86 | `reg` | `x` | `ax` | `w` |\n| x86 | `reg` | `e` | `eax` | `k` |\n| x86-64 | `reg` | `r` | `rax` | `q` |\n| x86 | `reg_byte` | None | `al` / `ah` | None |\n| x86 | `xmm_reg` | None | `xmm0` | `x` |\n| x86 | `ymm_reg` | None | `ymm0` | `t` |\n| x86 | `zmm_reg` | None | `zmm0` | `g` |\n| x86 | `*mm_reg` | `x` | `xmm0` | `x` |\n| x86 | `*mm_reg` | `y` | `ymm0` | `t` |\n| x86 | `*mm_reg` | `z` | `zmm0` | `g` |\n| x86 | `kreg` | None | `k1` | None |\n| AArch64 | `reg` | None | `x0` | `x` |\n| AArch64 | `reg` | `w` | `w0` | `w` |\n| AArch64 | `reg` | `x` | `x0` | `x` |\n| AArch64 | `vreg` | None | `v0` | None |\n| AArch64 | `vreg` | `v` | `v0` | None |\n| AArch64 | `vreg` | `b` | `b0` | `b` |\n| AArch64 | `vreg` | `h` | `h0` | `h` |\n| AArch64 | `vreg` | `s` | `s0` | `s` |\n| AArch64 | `vreg` | `d` | `d0` | `d` |\n| AArch64 | `vreg` | `q` | `q0` | `q` |\n| ARM | `reg` | None | `r0` | None |\n| ARM | `sreg` | None | `s0` | None |\n| ARM | `dreg` | None | `d0` | `P` |\n| ARM | `qreg` | None | `q0` | `q` |\n| ARM | `qreg` | `e` / `f` | `d0` / `d1` | `e` / `f` |\n| NVPTX | `reg16` | None | `rs0` | None |\n| NVPTX | `reg32` | None | `r0` | None |\n| NVPTX | `reg64` | None | `rd0` | None |\n| RISC-V | `reg` | None | `x1` | None |\n| RISC-V | `freg` | None | `f0` | None |\n| Hexagon | `reg` | None | `r0` | None |\n\n> Notes:\n> - on ARM `e` / `f`: this prints the low or high doubleword register name of a NEON quad (128-bit) register.\n> - on x86: our behavior for `reg` with no modifiers differs from what GCC does. GCC will infer the modifier based on the operand value type, while we default to the full register size.\n> - on x86 `xmm_reg`: the `x`, `t` and `g` LLVM modifiers are not yet implemented in LLVM (they are supported by GCC only), but this should be a simple change.\n\nAs stated in the previous section, passing an input value smaller than the register width will result in the upper bits of the register containing undefined values. This is not a problem if the inline asm only accesses the lower bits of the register, which can be done by using a template modifier to use a subregister name in the asm code (e.g. `ax` instead of `rax`). Since this an easy pitfall, the compiler will suggest a template modifier to use where appropriate given the input type. If all references to an operand already have modifiers then the warning is suppressed for that operand.\n\n[llvm-argmod]: http://llvm.org/docs/LangRef.html#asm-template-argument-modifiers\n\n## Options\n\nFlags are used to further influence the behavior of the inline assembly block.\nCurrently the following options are defined:\n- `pure`: The `asm` block has no side effects, and its outputs depend only on its direct inputs (i.e. the values themselves, not what they point to) or values read from memory (unless the `nomem` options is also set). This allows the compiler to execute the `asm` block fewer times than specified in the program (e.g. by hoisting it out of a loop) or even eliminate it entirely if the outputs are not used.\n- `nomem`: The `asm` blocks does not read or write to any memory. This allows the compiler to cache the values of modified global variables in registers across the `asm` block since it knows that they are not read or written to by the `asm`.\n- `readonly`: The `asm` block does not write to any memory. This allows the compiler to cache the values of unmodified global variables in registers across the `asm` block since it knows that they are not written to by the `asm`.\n- `preserves_flags`: The `asm` block does not modify the flags register (defined in the rules below). This allows the compiler to avoid recomputing the condition flags after the `asm` block.\n- `noreturn`: The `asm` block never returns, and its return type is defined as `!` (never). Behavior is undefined if execution falls through past the end of the asm code. A `noreturn` asm block behaves just like a function which doesn't return; notably, local variables in scope are not dropped before it is invoked.\n- `nostack`: The `asm` block does not push data to the stack, or write to the stack red-zone (if supported by the target). If this option is *not* used then the stack pointer is guaranteed to be suitably aligned (according to the target ABI) for a function call.\n- `att_syntax`: This option is only valid on x86, and causes the assembler to use the `.att_syntax prefix` mode of the GNU assembler. Register operands are substituted in with a leading `%`.\n\nThe compiler performs some additional checks on options:\n- The `nomem` and `readonly` options are mutually exclusive: it is a compile-time error to specify both.\n- The `pure` option must be combined with either the `nomem` or `readonly` options, otherwise a compile-time error is emitted.\n- It is a compile-time error to specify `pure` on an asm block with no outputs or only discarded outputs (`_`).\n- It is a compile-time error to specify `noreturn` on an asm block with outputs.\n\n## Rules for inline assembly\n\n- Any registers not specified as inputs will contain an undefined value on entry to the asm block.\n - An \"undefined value\" in the context of inline assembly means that the register can (non-deterministically) have any one of the possible values allowed by the architecture. Notably it is not the same as an LLVM `undef` which can have a different value every time you read it (since such a concept does not exist in assembly code).\n- Any registers not specified as outputs must have the same value upon exiting the asm block as they had on entry, otherwise behavior is undefined.\n - This only applies to registers which can be specified as an input or output. Other registers follow target-specific rules.\n - Note that a `lateout` may be allocated to the same register as an `in`, in which case this rule does not apply. Code should not rely on this however since it depends on the results of register allocation.\n- Behavior is undefined if execution unwinds out of an asm block.\n - This also applies if the assembly code calls a function which then unwinds.\n- The set of memory locations that assembly code is allowed the read and write are the same as those allowed for an FFI function.\n - Refer to the unsafe code guidelines for the exact rules.\n - If the `readonly` option is set, then only memory reads are allowed.\n - If the `nomem` option is set then no reads or writes to memory are allowed.\n - These rules do not apply to memory which is private to the asm code, such as stack space allocated within the asm block.\n- The compiler cannot assume that the instructions in the asm are the ones that will actually end up executed.\n - This effectively means that the compiler must treat the `asm!` as a black box and only take the interface specification into account, not the instructions themselves.\n - Runtime code patching is allowed, via target-specific mechanisms (outside the scope of this RFC).\n- Unless the `nostack` option is set, asm code is allowed to use stack space below the stack pointer.\n - On entry to the asm block the stack pointer is guaranteed to be suitably aligned (according to the target ABI) for a function call.\n - You are responsible for making sure you don't overflow the stack (e.g. use stack probing to ensure you hit a guard page).\n - You should adjust the stack pointer when allocating stack memory as required by the target ABI.\n - The stack pointer must be restored to its original value before leaving the asm block.\n- If the `noreturn` option is set then behavior is undefined if execution falls through to the end of the asm block.\n- If the `pure` option is set then behavior is undefined if the `asm` has side-effects other than its direct outputs. Behavior is also undefined if two executions of the `asm` code with the same inputs result in different outputs.\n - When used with the `nomem` option, \"inputs\" are just the direct inputs of the `asm!`.\n - When used with the `readonly` option, \"inputs\" comprise the direct inputs of the `asm!` and any memory that the `asm!` block is allowed to read.\n- These flags registers must be restored upon exiting the asm block if the `preserves_flags` option is set:\n - x86\n - Status flags in `EFLAGS` (CF, PF, AF, ZF, SF, OF).\n - Floating-point status word (all).\n - Floating-point exception flags in `MXCSR` (PE, UE, OE, ZE, DE, IE).\n - ARM\n - Condition flags in `CPSR` (N, Z, C, V)\n - Saturation flag in `CPSR` (Q)\n - Greater than or equal flags in `CPSR` (GE).\n - Condition flags in `FPSCR` (N, Z, C, V)\n - Saturation flag in `FPSCR` (QC)\n - Floating-point exception flags in `FPSCR` (IDC, IXC, UFC, OFC, DZC, IOC).\n - AArch64\n - Condition flags (`NZCV` register).\n - Floating-point status (`FPSR` register).\n - RISC-V\n - Floating-point exception flags in `fcsr` (`fflags`).\n- On x86, the direction flag (DF in `EFLAGS`) is clear on entry to an asm block and must be clear on exit.\n - Behavior is undefined if the direction flag is set on exiting an asm block.\n- The requirement of restoring the stack pointer and non-output registers to their original value only applies when exiting an `asm!` block.\n - This means that `asm!` blocks that never return (even if not marked `noreturn`) don't need to preserve these registers.\n - When returning to a different `asm!` block than you entered (e.g. for context switching), these registers must contain the value they had upon entering the `asm!` block that you are *exiting*.\n - You cannot exit an `asm!` block that has not been entered. Neither can you exit an `asm!` block that has already been exited.\n - You are responsible for switching any target-specific state (e.g. thread-local storage, stack bounds).\n - The set of memory locations that you may access is the intersection of those allowed by the `asm!` blocks you entered and exited.\n- You cannot assume that an `asm!` block will appear exactly once in the output binary. The compiler is allowed to instantiate multiple copies of the `asm!` block, for example when the function containing it is inlined in multiple places.\n - As a consequence, you should only use [local labels] inside inline assembly code. Defining symbols in assembly code may lead to assembler and/or linker errors due to duplicate symbol definitions.\n\n> **Note**: As a general rule, the flags covered by `preserves_flags` are those which are *not* preserved when performing a function call.\n\n[local labels]: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Local-Labels\n" } , LintCompletion { label : "is_sorted" , description : "# `is_sorted`\n\nThe tracking issue for this feature is: [#53485]\n\n[#53485]: https://github.com/rust-lang/rust/issues/53485\n\n------------------------\n\nAdd the methods `is_sorted`, `is_sorted_by` and `is_sorted_by_key` to `[T]`;\nadd the methods `is_sorted`, `is_sorted_by` and `is_sorted_by_key` to\n`Iterator`.\n" } , LintCompletion { label : "derive_clone_copy" , description : "# `derive_clone_copy`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "print_internals" , description : "# `print_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "set_stdio" , description : "# `set_stdio`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "windows_handle" , description : "# `windows_handle`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "thread_local_internals" , description : "# `thread_local_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "profiler_runtime_lib" , description : "# `profiler_runtime_lib`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "windows_c" , description : "# `windows_c`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "fd_read" , description : "# `fd_read`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "c_void_variant" , description : "# `c_void_variant`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "flt2dec" , description : "# `flt2dec`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "core_private_bignum" , description : "# `core_private_bignum`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "format_args_capture" , description : "# `format_args_capture`\n\nThe tracking issue for this feature is: [#67984]\n\n[#67984]: https://github.com/rust-lang/rust/issues/67984\n\n------------------------\n\nEnables `format_args!` (and macros which use `format_args!` in their implementation, such\nas `format!`, `print!` and `panic!`) to capture variables from the surrounding scope.\nThis avoids the need to pass named parameters when the binding in question\nalready exists in scope.\n\n```rust\n#![feature(format_args_capture)]\n\nlet (person, species, name) = (\"Charlie Brown\", \"dog\", \"Snoopy\");\n\n// captures named argument `person`\nprint!(\"Hello {person}\");\n\n// captures named arguments `species` and `name`\nformat!(\"The {species}'s name is {name}.\");\n```\n\nThis also works for formatting parameters such as width and precision:\n\n```rust\n#![feature(format_args_capture)]\n\nlet precision = 2;\nlet s = format!(\"{:.precision$}\", 1.324223);\n\nassert_eq!(&s, \"1.32\");\n```\n\nA non-exhaustive list of macros which benefit from this functionality include:\n- `format!`\n- `print!` and `println!`\n- `eprint!` and `eprintln!`\n- `write!` and `writeln!`\n- `panic!`\n- `unreachable!`\n- `unimplemented!`\n- `todo!`\n- `assert!` and similar\n- macros in many thirdparty crates, such as `log`\n" } , LintCompletion { label : "libstd_io_internals" , description : "# `libstd_io_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "derive_eq" , description : "# `derive_eq`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "c_variadic" , description : "# `c_variadic`\n\nThe tracking issue for this feature is: [#44930]\n\n[#44930]: https://github.com/rust-lang/rust/issues/44930\n\n------------------------\n\nThe `c_variadic` library feature exposes the `VaList` structure,\nRust's analogue of C's `va_list` type.\n\n## Examples\n\n```rust\n#![feature(c_variadic)]\n\nuse std::ffi::VaList;\n\npub unsafe extern \"C\" fn vadd(n: usize, mut args: VaList) -> usize {\n let mut sum = 0;\n for _ in 0..n {\n sum += args.arg::<usize>();\n }\n sum\n}\n```\n" } , LintCompletion { label : "trace_macros" , description : "# `trace_macros`\n\nThe tracking issue for this feature is [#29598].\n\n[#29598]: https://github.com/rust-lang/rust/issues/29598\n\n------------------------\n\nWith `trace_macros` you can trace the expansion of macros in your code.\n\n## Examples\n\n```rust\n#![feature(trace_macros)]\n\nfn main() {\n trace_macros!(true);\n println!(\"Hello, Rust!\");\n trace_macros!(false);\n}\n```\n\nThe `cargo build` output:\n\n```txt\nnote: trace_macro\n --> src/main.rs:5:5\n |\n5 | println!(\"Hello, Rust!\");\n | ^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = note: expanding `println! { \"Hello, Rust!\" }`\n = note: to `print ! ( concat ! ( \"Hello, Rust!\" , \"\\n\" ) )`\n = note: expanding `print! { concat ! ( \"Hello, Rust!\" , \"\\n\" ) }`\n = note: to `$crate :: io :: _print ( format_args ! ( concat ! ( \"Hello, Rust!\" , \"\\n\" ) )\n )`\n\n Finished dev [unoptimized + debuginfo] target(s) in 0.60 secs\n```\n" } , LintCompletion { label : "core_private_diy_float" , description : "# `core_private_diy_float`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "core_panic" , description : "# `core_panic`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "str_internals" , description : "# `str_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "char_error_internals" , description : "# `char_error_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "llvm_asm" , description : "# `llvm_asm`\n\nThe tracking issue for this feature is: [#70173]\n\n[#70173]: https://github.com/rust-lang/rust/issues/70173\n\n------------------------\n\nFor extremely low-level manipulations and performance reasons, one\nmight wish to control the CPU directly. Rust supports using inline\nassembly to do this via the `llvm_asm!` macro.\n\n```rust,ignore\nllvm_asm!(assembly template\n : output operands\n : input operands\n : clobbers\n : options\n );\n```\n\nAny use of `llvm_asm` is feature gated (requires `#![feature(llvm_asm)]` on the\ncrate to allow) and of course requires an `unsafe` block.\n\n> **Note**: the examples here are given in x86/x86-64 assembly, but\n> all platforms are supported.\n\n## Assembly template\n\nThe `assembly template` is the only required parameter and must be a\nliteral string (i.e. `\"\"`)\n\n```rust\n#![feature(llvm_asm)]\n\n#[cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\nfn foo() {\n unsafe {\n llvm_asm!(\"NOP\");\n }\n}\n\n// Other platforms:\n#[cfg(not(any(target_arch = \"x86\", target_arch = \"x86_64\")))]\nfn foo() { /* ... */ }\n\nfn main() {\n // ...\n foo();\n // ...\n}\n```\n\n(The `feature(llvm_asm)` and `#[cfg]`s are omitted from now on.)\n\nOutput operands, input operands, clobbers and options are all optional\nbut you must add the right number of `:` if you skip them:\n\n```rust\n# #![feature(llvm_asm)]\n# #[cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\n# fn main() { unsafe {\nllvm_asm!(\"xor %eax, %eax\"\n :\n :\n : \"eax\"\n );\n# } }\n# #[cfg(not(any(target_arch = \"x86\", target_arch = \"x86_64\")))]\n# fn main() {}\n```\n\nWhitespace also doesn't matter:\n\n```rust\n# #![feature(llvm_asm)]\n# #[cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\n# fn main() { unsafe {\nllvm_asm!(\"xor %eax, %eax\" ::: \"eax\");\n# } }\n# #[cfg(not(any(target_arch = \"x86\", target_arch = \"x86_64\")))]\n# fn main() {}\n```\n\n## Operands\n\nInput and output operands follow the same format: `:\n\"constraints1\"(expr1), \"constraints2\"(expr2), ...\"`. Output operand\nexpressions must be mutable place, or not yet assigned:\n\n```rust\n# #![feature(llvm_asm)]\n# #[cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\nfn add(a: i32, b: i32) -> i32 {\n let c: i32;\n unsafe {\n llvm_asm!(\"add $2, $0\"\n : \"=r\"(c)\n : \"0\"(a), \"r\"(b)\n );\n }\n c\n}\n# #[cfg(not(any(target_arch = \"x86\", target_arch = \"x86_64\")))]\n# fn add(a: i32, b: i32) -> i32 { a + b }\n\nfn main() {\n assert_eq!(add(3, 14159), 14162)\n}\n```\n\nIf you would like to use real operands in this position, however,\nyou are required to put curly braces `{}` around the register that\nyou want, and you are required to put the specific size of the\noperand. This is useful for very low level programming, where\nwhich register you use is important:\n\n```rust\n# #![feature(llvm_asm)]\n# #[cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\n# unsafe fn read_byte_in(port: u16) -> u8 {\nlet result: u8;\nllvm_asm!(\"in %dx, %al\" : \"={al}\"(result) : \"{dx}\"(port));\nresult\n# }\n```\n\n## Clobbers\n\nSome instructions modify registers which might otherwise have held\ndifferent values so we use the clobbers list to indicate to the\ncompiler not to assume any values loaded into those registers will\nstay valid.\n\n```rust\n# #![feature(llvm_asm)]\n# #[cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\n# fn main() { unsafe {\n// Put the value 0x200 in eax:\nllvm_asm!(\"mov $$0x200, %eax\" : /* no outputs */ : /* no inputs */ : \"eax\");\n# } }\n# #[cfg(not(any(target_arch = \"x86\", target_arch = \"x86_64\")))]\n# fn main() {}\n```\n\nInput and output registers need not be listed since that information\nis already communicated by the given constraints. Otherwise, any other\nregisters used either implicitly or explicitly should be listed.\n\nIf the assembly changes the condition code register `cc` should be\nspecified as one of the clobbers. Similarly, if the assembly modifies\nmemory, `memory` should also be specified.\n\n## Options\n\nThe last section, `options` is specific to Rust. The format is comma\nseparated literal strings (i.e. `:\"foo\", \"bar\", \"baz\"`). It's used to\nspecify some extra info about the inline assembly:\n\nCurrent valid options are:\n\n1. *volatile* - specifying this is analogous to\n `__asm__ __volatile__ (...)` in gcc/clang.\n2. *alignstack* - certain instructions expect the stack to be\n aligned a certain way (i.e. SSE) and specifying this indicates to\n the compiler to insert its usual stack alignment code\n3. *intel* - use intel syntax instead of the default AT&T.\n\n```rust\n# #![feature(llvm_asm)]\n# #[cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\n# fn main() {\nlet result: i32;\nunsafe {\n llvm_asm!(\"mov eax, 2\" : \"={eax}\"(result) : : : \"intel\")\n}\nprintln!(\"eax is currently {}\", result);\n# }\n# #[cfg(not(any(target_arch = \"x86\", target_arch = \"x86_64\")))]\n# fn main() {}\n```\n\n## More Information\n\nThe current implementation of the `llvm_asm!` macro is a direct binding to [LLVM's\ninline assembler expressions][llvm-docs], so be sure to check out [their\ndocumentation as well][llvm-docs] for more information about clobbers,\nconstraints, etc.\n\n[llvm-docs]: http://llvm.org/docs/LangRef.html#inline-assembler-expressions\n\nIf you need more power and don't mind losing some of the niceties of\n`llvm_asm!`, check out [global_asm](global-asm.md).\n" } ] ; 4pub const UNSTABLE_FEATURE_DESCRIPTOR : & [ LintCompletion ] = & [ LintCompletion { label : "crate_visibility_modifier" , description : "# `crate_visibility_modifier`\n\nThe tracking issue for this feature is: [#53120]\n\n[#53120]: https://github.com/rust-lang/rust/issues/53120\n\n-----\n\nThe `crate_visibility_modifier` feature allows the `crate` keyword to be used\nas a visibility modifier synonymous to `pub(crate)`, indicating that a type\n(function, _&c._) is to be visible to the entire enclosing crate, but not to\nother crates.\n\n```rust\n#![feature(crate_visibility_modifier)]\n\ncrate struct Foo {\n bar: usize,\n}\n```\n" } , LintCompletion { label : "abi_thiscall" , description : "# `abi_thiscall`\n\nThe tracking issue for this feature is: [#42202]\n\n[#42202]: https://github.com/rust-lang/rust/issues/42202\n\n------------------------\n\nThe MSVC ABI on x86 Windows uses the `thiscall` calling convention for C++\ninstance methods by default; it is identical to the usual (C) calling\nconvention on x86 Windows except that the first parameter of the method,\nthe `this` pointer, is passed in the ECX register.\n" } , LintCompletion { label : "infer_static_outlives_requirements" , description : "# `infer_static_outlives_requirements`\n\nThe tracking issue for this feature is: [#54185]\n\n[#54185]: https://github.com/rust-lang/rust/issues/54185\n\n------------------------\nThe `infer_static_outlives_requirements` feature indicates that certain\n`'static` outlives requirements can be inferred by the compiler rather than\nstating them explicitly.\n\nNote: It is an accompanying feature to `infer_outlives_requirements`,\nwhich must be enabled to infer outlives requirements.\n\nFor example, currently generic struct definitions that contain\nreferences, require where-clauses of the form T: 'static. By using\nthis feature the outlives predicates will be inferred, although\nthey may still be written explicitly.\n\n```rust,ignore (pseudo-Rust)\nstruct Foo<U> where U: 'static { // <-- currently required\n bar: Bar<U>\n}\nstruct Bar<T: 'static> {\n x: T,\n}\n```\n\n\n## Examples:\n\n```rust,ignore (pseudo-Rust)\n#![feature(infer_outlives_requirements)]\n#![feature(infer_static_outlives_requirements)]\n\n#[rustc_outlives]\n// Implicitly infer U: 'static\nstruct Foo<U> {\n bar: Bar<U>\n}\nstruct Bar<T: 'static> {\n x: T,\n}\n```\n\n" } , LintCompletion { label : "repr128" , description : "# `repr128`\n\nThe tracking issue for this feature is: [#56071]\n\n[#56071]: https://github.com/rust-lang/rust/issues/56071\n\n------------------------\n\nThe `repr128` feature adds support for `#[repr(u128)]` on `enum`s.\n\n```rust\n#![feature(repr128)]\n\n#[repr(u128)]\nenum Foo {\n Bar(u64),\n}\n```\n" } , LintCompletion { label : "doc_masked" , description : "# `doc_masked`\n\nThe tracking issue for this feature is: [#44027]\n\n-----\n\nThe `doc_masked` feature allows a crate to exclude types from a given crate from appearing in lists\nof trait implementations. The specifics of the feature are as follows:\n\n1. When rustdoc encounters an `extern crate` statement annotated with a `#[doc(masked)]` attribute,\n it marks the crate as being masked.\n\n2. When listing traits a given type implements, rustdoc ensures that traits from masked crates are\n not emitted into the documentation.\n\n3. When listing types that implement a given trait, rustdoc ensures that types from masked crates\n are not emitted into the documentation.\n\nThis feature was introduced in PR [#44026] to ensure that compiler-internal and\nimplementation-specific types and traits were not included in the standard library's documentation.\nSuch types would introduce broken links into the documentation.\n\n[#44026]: https://github.com/rust-lang/rust/pull/44026\n[#44027]: https://github.com/rust-lang/rust/pull/44027\n" } , LintCompletion { label : "link_args" , description : "# `link_args`\n\nThe tracking issue for this feature is: [#29596]\n\n[#29596]: https://github.com/rust-lang/rust/issues/29596\n\n------------------------\n\nYou can tell `rustc` how to customize linking, and that is via the `link_args`\nattribute. This attribute is applied to `extern` blocks and specifies raw flags\nwhich need to get passed to the linker when producing an artifact. An example\nusage would be:\n\n```rust,no_run\n#![feature(link_args)]\n\n#[link_args = \"-foo -bar -baz\"]\nextern {}\n# fn main() {}\n```\n\nNote that this feature is currently hidden behind the `feature(link_args)` gate\nbecause this is not a sanctioned way of performing linking. Right now `rustc`\nshells out to the system linker (`gcc` on most systems, `link.exe` on MSVC), so\nit makes sense to provide extra command line arguments, but this will not\nalways be the case. In the future `rustc` may use LLVM directly to link native\nlibraries, in which case `link_args` will have no meaning. You can achieve the\nsame effect as the `link_args` attribute with the `-C link-args` argument to\n`rustc`.\n\nIt is highly recommended to *not* use this attribute, and rather use the more\nformal `#[link(...)]` attribute on `extern` blocks instead.\n" } , LintCompletion { label : "cfg_version" , description : "# `cfg_version`\n\nThe tracking issue for this feature is: [#64796]\n\n[#64796]: https://github.com/rust-lang/rust/issues/64796\n\n------------------------\n\nThe `cfg_version` feature makes it possible to execute different code\ndepending on the compiler version.\n\n## Examples\n\n```rust\n#![feature(cfg_version)]\n\n#[cfg(version(\"1.42\"))]\nfn a() {\n // ...\n}\n\n#[cfg(not(version(\"1.42\")))]\nfn a() {\n // ...\n}\n\nfn b() {\n if cfg!(version(\"1.42\")) {\n // ...\n } else {\n // ...\n }\n}\n```\n" } , LintCompletion { label : "ffi_const" , description : "# `ffi_const`\n\nThe `#[ffi_const]` attribute applies clang's `const` attribute to foreign\nfunctions declarations.\n\nThat is, `#[ffi_const]` functions shall have no effects except for its return\nvalue, which can only depend on the values of the function parameters, and is\nnot affected by changes to the observable state of the program.\n\nApplying the `#[ffi_const]` attribute to a function that violates these\nrequirements is undefined behaviour.\n\nThis attribute enables Rust to perform common optimizations, like sub-expression\nelimination, and it can avoid emitting some calls in repeated invocations of the\nfunction with the same argument values regardless of other operations being\nperformed in between these functions calls (as opposed to `#[ffi_pure]`\nfunctions).\n\n## Pitfalls\n\nA `#[ffi_const]` function can only read global memory that would not affect\nits return value for the whole execution of the program (e.g. immutable global\nmemory). `#[ffi_const]` functions are referentially-transparent and therefore\nmore strict than `#[ffi_pure]` functions.\n\nA common pitfall involves applying the `#[ffi_const]` attribute to a\nfunction that reads memory through pointer arguments which do not necessarily\npoint to immutable global memory.\n\nA `#[ffi_const]` function that returns unit has no effect on the abstract\nmachine's state, and a `#[ffi_const]` function cannot be `#[ffi_pure]`.\n\nA `#[ffi_const]` function must not diverge, neither via a side effect (e.g. a\ncall to `abort`) nor by infinite loops.\n\nWhen translating C headers to Rust FFI, it is worth verifying for which targets\nthe `const` attribute is enabled in those headers, and using the appropriate\n`cfg` macros in the Rust side to match those definitions. While the semantics of\n`const` are implemented identically by many C and C++ compilers, e.g., clang,\n[GCC], [ARM C/C++ compiler], [IBM ILE C/C++], etc. they are not necessarily\nimplemented in this way on all of them. It is therefore also worth verifying\nthat the semantics of the C toolchain used to compile the binary being linked\nagainst are compatible with those of the `#[ffi_const]`.\n\n[ARM C/C++ compiler]: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/Cacgigch.html\n[GCC]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute\n[IBM ILE C/C++]: https://www.ibm.com/support/knowledgecenter/fr/ssw_ibm_i_71/rzarg/fn_attrib_const.htm\n" } , LintCompletion { label : "doc_cfg" , description : "# `doc_cfg`\n\nThe tracking issue for this feature is: [#43781]\n\n------\n\nThe `doc_cfg` feature allows an API be documented as only available in some specific platforms.\nThis attribute has two effects:\n\n1. In the annotated item's documentation, there will be a message saying \"This is supported on\n (platform) only\".\n\n2. The item's doc-tests will only run on the specific platform.\n\nIn addition to allowing the use of the `#[doc(cfg)]` attribute, this feature enables the use of a\nspecial conditional compilation flag, `#[cfg(doc)]`, set whenever building documentation on your\ncrate.\n\nThis feature was introduced as part of PR [#43348] to allow the platform-specific parts of the\nstandard library be documented.\n\n```rust\n#![feature(doc_cfg)]\n\n#[cfg(any(windows, doc))]\n#[doc(cfg(windows))]\n/// The application's icon in the notification area (a.k.a. system tray).\n///\n/// # Examples\n///\n/// ```no_run\n/// extern crate my_awesome_ui_library;\n/// use my_awesome_ui_library::current_app;\n/// use my_awesome_ui_library::windows::notification;\n///\n/// let icon = current_app().get::<notification::Icon>();\n/// icon.show();\n/// icon.show_message(\"Hello\");\n/// ```\npub struct Icon {\n // ...\n}\n```\n\n[#43781]: https://github.com/rust-lang/rust/issues/43781\n[#43348]: https://github.com/rust-lang/rust/issues/43348\n" } , LintCompletion { label : "unsized_tuple_coercion" , description : "# `unsized_tuple_coercion`\n\nThe tracking issue for this feature is: [#42877]\n\n[#42877]: https://github.com/rust-lang/rust/issues/42877\n\n------------------------\n\nThis is a part of [RFC0401]. According to the RFC, there should be an implementation like this:\n\n```rust,ignore\nimpl<..., T, U: ?Sized> Unsized<(..., U)> for (..., T) where T: Unsized<U> {}\n```\n\nThis implementation is currently gated behind `#[feature(unsized_tuple_coercion)]` to avoid insta-stability. Therefore you can use it like this:\n\n```rust\n#![feature(unsized_tuple_coercion)]\n\nfn main() {\n let x : ([i32; 3], [i32; 3]) = ([1, 2, 3], [4, 5, 6]);\n let y : &([i32; 3], [i32]) = &x;\n assert_eq!(y.1[0], 4);\n}\n```\n\n[RFC0401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md\n" } , LintCompletion { label : "abi_msp430_interrupt" , description : "# `abi_msp430_interrupt`\n\nThe tracking issue for this feature is: [#38487]\n\n[#38487]: https://github.com/rust-lang/rust/issues/38487\n\n------------------------\n\nIn the MSP430 architecture, interrupt handlers have a special calling\nconvention. You can use the `\"msp430-interrupt\"` ABI to make the compiler apply\nthe right calling convention to the interrupt handlers you define.\n\n<!-- NOTE(ignore) this example is specific to the msp430 target -->\n\n``` rust,ignore\n#![feature(abi_msp430_interrupt)]\n#![no_std]\n\n// Place the interrupt handler at the appropriate memory address\n// (Alternatively, you can use `#[used]` and remove `pub` and `#[no_mangle]`)\n#[link_section = \"__interrupt_vector_10\"]\n#[no_mangle]\npub static TIM0_VECTOR: extern \"msp430-interrupt\" fn() = tim0;\n\n// The interrupt handler\nextern \"msp430-interrupt\" fn tim0() {\n // ..\n}\n```\n\n``` text\n$ msp430-elf-objdump -CD ./target/msp430/release/app\nDisassembly of section __interrupt_vector_10:\n\n0000fff2 <TIM0_VECTOR>:\n fff2: 00 c0 interrupt service routine at 0xc000\n\nDisassembly of section .text:\n\n0000c000 <int::tim0>:\n c000: 00 13 reti\n```\n" } , LintCompletion { label : "generators" , description : "# `generators`\n\nThe tracking issue for this feature is: [#43122]\n\n[#43122]: https://github.com/rust-lang/rust/issues/43122\n\n------------------------\n\nThe `generators` feature gate in Rust allows you to define generator or\ncoroutine literals. A generator is a \"resumable function\" that syntactically\nresembles a closure but compiles to much different semantics in the compiler\nitself. The primary feature of a generator is that it can be suspended during\nexecution to be resumed at a later date. Generators use the `yield` keyword to\n\"return\", and then the caller can `resume` a generator to resume execution just\nafter the `yield` keyword.\n\nGenerators are an extra-unstable feature in the compiler right now. Added in\n[RFC 2033] they're mostly intended right now as a information/constraint\ngathering phase. The intent is that experimentation can happen on the nightly\ncompiler before actual stabilization. A further RFC will be required to\nstabilize generators/coroutines and will likely contain at least a few small\ntweaks to the overall design.\n\n[RFC 2033]: https://github.com/rust-lang/rfcs/pull/2033\n\nA syntactical example of a generator is:\n\n```rust\n#![feature(generators, generator_trait)]\n\nuse std::ops::{Generator, GeneratorState};\nuse std::pin::Pin;\n\nfn main() {\n let mut generator = || {\n yield 1;\n return \"foo\"\n };\n\n match Pin::new(&mut generator).resume(()) {\n GeneratorState::Yielded(1) => {}\n _ => panic!(\"unexpected value from resume\"),\n }\n match Pin::new(&mut generator).resume(()) {\n GeneratorState::Complete(\"foo\") => {}\n _ => panic!(\"unexpected value from resume\"),\n }\n}\n```\n\nGenerators are closure-like literals which can contain a `yield` statement. The\n`yield` statement takes an optional expression of a value to yield out of the\ngenerator. All generator literals implement the `Generator` trait in the\n`std::ops` module. The `Generator` trait has one main method, `resume`, which\nresumes execution of the generator at the previous suspension point.\n\nAn example of the control flow of generators is that the following example\nprints all numbers in order:\n\n```rust\n#![feature(generators, generator_trait)]\n\nuse std::ops::Generator;\nuse std::pin::Pin;\n\nfn main() {\n let mut generator = || {\n println!(\"2\");\n yield;\n println!(\"4\");\n };\n\n println!(\"1\");\n Pin::new(&mut generator).resume(());\n println!(\"3\");\n Pin::new(&mut generator).resume(());\n println!(\"5\");\n}\n```\n\nAt this time the main intended use case of generators is an implementation\nprimitive for async/await syntax, but generators will likely be extended to\nergonomic implementations of iterators and other primitives in the future.\nFeedback on the design and usage is always appreciated!\n\n### The `Generator` trait\n\nThe `Generator` trait in `std::ops` currently looks like:\n\n```rust\n# #![feature(arbitrary_self_types, generator_trait)]\n# use std::ops::GeneratorState;\n# use std::pin::Pin;\n\npub trait Generator<R = ()> {\n type Yield;\n type Return;\n fn resume(self: Pin<&mut Self>, resume: R) -> GeneratorState<Self::Yield, Self::Return>;\n}\n```\n\nThe `Generator::Yield` type is the type of values that can be yielded with the\n`yield` statement. The `Generator::Return` type is the returned type of the\ngenerator. This is typically the last expression in a generator's definition or\nany value passed to `return` in a generator. The `resume` function is the entry\npoint for executing the `Generator` itself.\n\nThe return value of `resume`, `GeneratorState`, looks like:\n\n```rust\npub enum GeneratorState<Y, R> {\n Yielded(Y),\n Complete(R),\n}\n```\n\nThe `Yielded` variant indicates that the generator can later be resumed. This\ncorresponds to a `yield` point in a generator. The `Complete` variant indicates\nthat the generator is complete and cannot be resumed again. Calling `resume`\nafter a generator has returned `Complete` will likely result in a panic of the\nprogram.\n\n### Closure-like semantics\n\nThe closure-like syntax for generators alludes to the fact that they also have\nclosure-like semantics. Namely:\n\n* When created, a generator executes no code. A closure literal does not\n actually execute any of the closure's code on construction, and similarly a\n generator literal does not execute any code inside the generator when\n constructed.\n\n* Generators can capture outer variables by reference or by move, and this can\n be tweaked with the `move` keyword at the beginning of the closure. Like\n closures all generators will have an implicit environment which is inferred by\n the compiler. Outer variables can be moved into a generator for use as the\n generator progresses.\n\n* Generator literals produce a value with a unique type which implements the\n `std::ops::Generator` trait. This allows actual execution of the generator\n through the `Generator::resume` method as well as also naming it in return\n types and such.\n\n* Traits like `Send` and `Sync` are automatically implemented for a `Generator`\n depending on the captured variables of the environment. Unlike closures,\n generators also depend on variables live across suspension points. This means\n that although the ambient environment may be `Send` or `Sync`, the generator\n itself may not be due to internal variables live across `yield` points being\n not-`Send` or not-`Sync`. Note that generators do\n not implement traits like `Copy` or `Clone` automatically.\n\n* Whenever a generator is dropped it will drop all captured environment\n variables.\n\n### Generators as state machines\n\nIn the compiler, generators are currently compiled as state machines. Each\n`yield` expression will correspond to a different state that stores all live\nvariables over that suspension point. Resumption of a generator will dispatch on\nthe current state and then execute internally until a `yield` is reached, at\nwhich point all state is saved off in the generator and a value is returned.\n\nLet's take a look at an example to see what's going on here:\n\n```rust\n#![feature(generators, generator_trait)]\n\nuse std::ops::Generator;\nuse std::pin::Pin;\n\nfn main() {\n let ret = \"foo\";\n let mut generator = move || {\n yield 1;\n return ret\n };\n\n Pin::new(&mut generator).resume(());\n Pin::new(&mut generator).resume(());\n}\n```\n\nThis generator literal will compile down to something similar to:\n\n```rust\n#![feature(arbitrary_self_types, generators, generator_trait)]\n\nuse std::ops::{Generator, GeneratorState};\nuse std::pin::Pin;\n\nfn main() {\n let ret = \"foo\";\n let mut generator = {\n enum __Generator {\n Start(&'static str),\n Yield1(&'static str),\n Done,\n }\n\n impl Generator for __Generator {\n type Yield = i32;\n type Return = &'static str;\n\n fn resume(mut self: Pin<&mut Self>, resume: ()) -> GeneratorState<i32, &'static str> {\n use std::mem;\n match mem::replace(&mut *self, __Generator::Done) {\n __Generator::Start(s) => {\n *self = __Generator::Yield1(s);\n GeneratorState::Yielded(1)\n }\n\n __Generator::Yield1(s) => {\n *self = __Generator::Done;\n GeneratorState::Complete(s)\n }\n\n __Generator::Done => {\n panic!(\"generator resumed after completion\")\n }\n }\n }\n }\n\n __Generator::Start(ret)\n };\n\n Pin::new(&mut generator).resume(());\n Pin::new(&mut generator).resume(());\n}\n```\n\nNotably here we can see that the compiler is generating a fresh type,\n`__Generator` in this case. This type has a number of states (represented here\nas an `enum`) corresponding to each of the conceptual states of the generator.\nAt the beginning we're closing over our outer variable `foo` and then that\nvariable is also live over the `yield` point, so it's stored in both states.\n\nWhen the generator starts it'll immediately yield 1, but it saves off its state\njust before it does so indicating that it has reached the yield point. Upon\nresuming again we'll execute the `return ret` which returns the `Complete`\nstate.\n\nHere we can also note that the `Done` state, if resumed, panics immediately as\nit's invalid to resume a completed generator. It's also worth noting that this\nis just a rough desugaring, not a normative specification for what the compiler\ndoes.\n" } , LintCompletion { label : "marker_trait_attr" , description : "# `marker_trait_attr`\n\nThe tracking issue for this feature is: [#29864]\n\n[#29864]: https://github.com/rust-lang/rust/issues/29864\n\n------------------------\n\nNormally, Rust keeps you from adding trait implementations that could\noverlap with each other, as it would be ambiguous which to use. This\nfeature, however, carves out an exception to that rule: a trait can\nopt-in to having overlapping implementations, at the cost that those\nimplementations are not allowed to override anything (and thus the\ntrait itself cannot have any associated items, as they're pointless\nwhen they'd need to do the same thing for every type anyway).\n\n```rust\n#![feature(marker_trait_attr)]\n\n#[marker] trait CheapToClone: Clone {}\n\nimpl<T: Copy> CheapToClone for T {}\n\n// These could potentially overlap with the blanket implementation above,\n// so are only allowed because CheapToClone is a marker trait.\nimpl<T: CheapToClone, U: CheapToClone> CheapToClone for (T, U) {}\nimpl<T: CheapToClone> CheapToClone for std::ops::Range<T> {}\n\nfn cheap_clone<T: CheapToClone>(t: T) -> T {\n t.clone()\n}\n```\n\nThis is expected to replace the unstable `overlapping_marker_traits`\nfeature, which applied to all empty traits (without needing an opt-in).\n" } , LintCompletion { label : "const_in_array_repeat_expressions" , description : "# `const_in_array_repeat_expressions`\n\nThe tracking issue for this feature is: [#49147]\n\n[#49147]: https://github.com/rust-lang/rust/issues/49147\n\n------------------------\n\nRelaxes the rules for repeat expressions, `[x; N]` such that `x` may also be `const` (strictly\nspeaking rvalue promotable), in addition to `typeof(x): Copy`. The result of `[x; N]` where `x` is\n`const` is itself also `const`.\n" } , LintCompletion { label : "external_doc" , description : "# `external_doc`\n\nThe tracking issue for this feature is: [#44732]\n\nThe `external_doc` feature allows the use of the `include` parameter to the `#[doc]` attribute, to\ninclude external files in documentation. Use the attribute in place of, or in addition to, regular\ndoc comments and `#[doc]` attributes, and `rustdoc` will load the given file when it renders\ndocumentation for your crate.\n\nWith the following files in the same directory:\n\n`external-doc.md`:\n\n```markdown\n# My Awesome Type\n\nThis is the documentation for this spectacular type.\n```\n\n`lib.rs`:\n\n```no_run (needs-external-files)\n#![feature(external_doc)]\n\n#[doc(include = \"external-doc.md\")]\npub struct MyAwesomeType;\n```\n\n`rustdoc` will load the file `external-doc.md` and use it as the documentation for the `MyAwesomeType`\nstruct.\n\nWhen locating files, `rustdoc` will base paths in the `src/` directory, as if they were alongside the\n`lib.rs` for your crate. So if you want a `docs/` folder to live alongside the `src/` directory,\nstart your paths with `../docs/` for `rustdoc` to properly find the file.\n\nThis feature was proposed in [RFC #1990] and initially implemented in PR [#44781].\n\n[#44732]: https://github.com/rust-lang/rust/issues/44732\n[RFC #1990]: https://github.com/rust-lang/rfcs/pull/1990\n[#44781]: https://github.com/rust-lang/rust/pull/44781\n" } , LintCompletion { label : "unsized_locals" , description : "# `unsized_locals`\n\nThe tracking issue for this feature is: [#48055]\n\n[#48055]: https://github.com/rust-lang/rust/issues/48055\n\n------------------------\n\nThis implements [RFC1909]. When turned on, you can have unsized arguments and locals:\n\n[RFC1909]: https://github.com/rust-lang/rfcs/blob/master/text/1909-unsized-rvalues.md\n\n```rust\n#![feature(unsized_locals)]\n\nuse std::any::Any;\n\nfn main() {\n let x: Box<dyn Any> = Box::new(42);\n let x: dyn Any = *x;\n // ^ unsized local variable\n // ^^ unsized temporary\n foo(x);\n}\n\nfn foo(_: dyn Any) {}\n// ^^^^^^ unsized argument\n```\n\nThe RFC still forbids the following unsized expressions:\n\n```rust,ignore\n#![feature(unsized_locals)]\n\nuse std::any::Any;\n\nstruct MyStruct<T: ?Sized> {\n content: T,\n}\n\nstruct MyTupleStruct<T: ?Sized>(T);\n\nfn answer() -> Box<dyn Any> {\n Box::new(42)\n}\n\nfn main() {\n // You CANNOT have unsized statics.\n static X: dyn Any = *answer(); // ERROR\n const Y: dyn Any = *answer(); // ERROR\n\n // You CANNOT have struct initialized unsized.\n MyStruct { content: *answer() }; // ERROR\n MyTupleStruct(*answer()); // ERROR\n (42, *answer()); // ERROR\n\n // You CANNOT have unsized return types.\n fn my_function() -> dyn Any { *answer() } // ERROR\n\n // You CAN have unsized local variables...\n let mut x: dyn Any = *answer(); // OK\n // ...but you CANNOT reassign to them.\n x = *answer(); // ERROR\n\n // You CANNOT even initialize them separately.\n let y: dyn Any; // OK\n y = *answer(); // ERROR\n\n // Not mentioned in the RFC, but by-move captured variables are also Sized.\n let x: dyn Any = *answer();\n (move || { // ERROR\n let y = x;\n })();\n\n // You CAN create a closure with unsized arguments,\n // but you CANNOT call it.\n // This is an implementation detail and may be changed in the future.\n let f = |x: dyn Any| {};\n f(*answer()); // ERROR\n}\n```\n\n## By-value trait objects\n\nWith this feature, you can have by-value `self` arguments without `Self: Sized` bounds.\n\n```rust\n#![feature(unsized_locals)]\n\ntrait Foo {\n fn foo(self) {}\n}\n\nimpl<T: ?Sized> Foo for T {}\n\nfn main() {\n let slice: Box<[i32]> = Box::new([1, 2, 3]);\n <[i32] as Foo>::foo(*slice);\n}\n```\n\nAnd `Foo` will also be object-safe.\n\n```rust\n#![feature(unsized_locals)]\n\ntrait Foo {\n fn foo(self) {}\n}\n\nimpl<T: ?Sized> Foo for T {}\n\nfn main () {\n let slice: Box<dyn Foo> = Box::new([1, 2, 3]);\n // doesn't compile yet\n <dyn Foo as Foo>::foo(*slice);\n}\n```\n\nOne of the objectives of this feature is to allow `Box<dyn FnOnce>`.\n\n## Variable length arrays\n\nThe RFC also describes an extension to the array literal syntax: `[e; dyn n]`. In the syntax, `n` isn't necessarily a constant expression. The array is dynamically allocated on the stack and has the type of `[T]`, instead of `[T; n]`.\n\n```rust,ignore\n#![feature(unsized_locals)]\n\nfn mergesort<T: Ord>(a: &mut [T]) {\n let mut tmp = [T; dyn a.len()];\n // ...\n}\n\nfn main() {\n let mut a = [3, 1, 5, 6];\n mergesort(&mut a);\n assert_eq!(a, [1, 3, 5, 6]);\n}\n```\n\nVLAs are not implemented yet. The syntax isn't final, either. We may need an alternative syntax for Rust 2015 because, in Rust 2015, expressions like `[e; dyn(1)]` would be ambiguous. One possible alternative proposed in the RFC is `[e; n]`: if `n` captures one or more local variables, then it is considered as `[e; dyn n]`.\n\n## Advisory on stack usage\n\nIt's advised not to casually use the `#![feature(unsized_locals)]` feature. Typical use-cases are:\n\n- When you need a by-value trait objects.\n- When you really need a fast allocation of small temporary arrays.\n\nAnother pitfall is repetitive allocation and temporaries. Currently the compiler simply extends the stack frame every time it encounters an unsized assignment. So for example, the code\n\n```rust\n#![feature(unsized_locals)]\n\nfn main() {\n let x: Box<[i32]> = Box::new([1, 2, 3, 4, 5]);\n let _x = {{{{{{{{{{*x}}}}}}}}}};\n}\n```\n\nand the code\n\n```rust\n#![feature(unsized_locals)]\n\nfn main() {\n for _ in 0..10 {\n let x: Box<[i32]> = Box::new([1, 2, 3, 4, 5]);\n let _x = *x;\n }\n}\n```\n\nwill unnecessarily extend the stack frame.\n" } , LintCompletion { label : "or_patterns" , description : "# `or_patterns`\n\nThe tracking issue for this feature is: [#54883]\n\n[#54883]: https://github.com/rust-lang/rust/issues/54883\n\n------------------------\n\nThe `or_pattern` language feature allows `|` to be arbitrarily nested within\na pattern, for example, `Some(A(0) | B(1 | 2))` becomes a valid pattern.\n\n## Examples\n\n```rust,ignore\n#![feature(or_patterns)]\n\npub enum Foo {\n Bar,\n Baz,\n Quux,\n}\n\npub fn example(maybe_foo: Option<Foo>) {\n match maybe_foo {\n Some(Foo::Bar | Foo::Baz) => {\n println!(\"The value contained `Bar` or `Baz`\");\n }\n Some(_) => {\n println!(\"The value did not contain `Bar` or `Baz`\");\n }\n None => {\n println!(\"The value was `None`\");\n }\n }\n}\n```\n" } , LintCompletion { label : "member_constraints" , description : "# `member_constraints`\n\nThe tracking issue for this feature is: [#61997]\n\n[#61997]: https://github.com/rust-lang/rust/issues/61997\n\n------------------------\n\nThe `member_constraints` feature gate lets you use `impl Trait` syntax with\nmultiple unrelated lifetime parameters.\n\nA simple example is:\n\n```rust\n#![feature(member_constraints)]\n\ntrait Trait<'a, 'b> { }\nimpl<T> Trait<'_, '_> for T {}\n\nfn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Trait<'a, 'b> {\n (x, y)\n}\n\nfn main() { }\n```\n\nWithout the `member_constraints` feature gate, the above example is an\nerror because both `'a` and `'b` appear in the impl Trait bounds, but\nneither outlives the other.\n" } , LintCompletion { label : "optin_builtin_traits" , description : "# `optin_builtin_traits`\n\nThe tracking issue for this feature is [#13231] \n\n[#13231]: https://github.com/rust-lang/rust/issues/13231\n\n----\n\nThe `optin_builtin_traits` feature gate allows you to define auto traits.\n\nAuto traits, like [`Send`] or [`Sync`] in the standard library, are marker traits\nthat are automatically implemented for every type, unless the type, or a type it contains, \nhas explicitly opted out via a negative impl. (Negative impls are separately controlled\nby the `negative_impls` feature.)\n\n[`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html\n[`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html\n\n```rust,ignore\nimpl !Trait for Type\n```\n\nExample:\n\n```rust\n#![feature(negative_impls)]\n#![feature(optin_builtin_traits)]\n\nauto trait Valid {}\n\nstruct True;\nstruct False;\n\nimpl !Valid for False {}\n\nstruct MaybeValid<T>(T);\n\nfn must_be_valid<T: Valid>(_t: T) { }\n\nfn main() {\n // works\n must_be_valid( MaybeValid(True) );\n \n // compiler error - trait bound not satisfied\n // must_be_valid( MaybeValid(False) );\n}\n```\n\n## Automatic trait implementations\n\nWhen a type is declared as an `auto trait`, we will automatically\ncreate impls for every struct/enum/union, unless an explicit impl is\nprovided. These automatic impls contain a where clause for each field\nof the form `T: AutoTrait`, where `T` is the type of the field and\n`AutoTrait` is the auto trait in question. As an example, consider the\nstruct `List` and the auto trait `Send`:\n\n```rust\nstruct List<T> {\n data: T,\n next: Option<Box<List<T>>>,\n}\n```\n\nPresuming that there is no explicit impl of `Send` for `List`, the\ncompiler will supply an automatic impl of the form:\n\n```rust\nstruct List<T> {\n data: T,\n next: Option<Box<List<T>>>,\n}\n\nunsafe impl<T> Send for List<T>\nwhere\n T: Send, // from the field `data`\n Option<Box<List<T>>>: Send, // from the field `next`\n{ }\n```\n\nExplicit impls may be either positive or negative. They take the form:\n\n```rust,ignore\nimpl<...> AutoTrait for StructName<..> { }\nimpl<...> !AutoTrait for StructName<..> { }\n```\n\n## Coinduction: Auto traits permit cyclic matching\n\nUnlike ordinary trait matching, auto traits are **coinductive**. This\nmeans, in short, that cycles which occur in trait matching are\nconsidered ok. As an example, consider the recursive struct `List`\nintroduced in the previous section. In attempting to determine whether\n`List: Send`, we would wind up in a cycle: to apply the impl, we must\nshow that `Option<Box<List>>: Send`, which will in turn require\n`Box<List>: Send` and then finally `List: Send` again. Under ordinary\ntrait matching, this cycle would be an error, but for an auto trait it\nis considered a successful match.\n\n## Items\n\nAuto traits cannot have any trait items, such as methods or associated types. This ensures that we can generate default implementations.\n\n## Supertraits\n\nAuto traits cannot have supertraits. This is for soundness reasons, as the interaction of coinduction with implied bounds is difficult to reconcile.\n\n" } , LintCompletion { label : "rustc_attrs" , description : "# `rustc_attrs`\n\nThis feature has no tracking issue, and is therefore internal to\nthe compiler, not being intended for general use.\n\nNote: `rustc_attrs` enables many rustc-internal attributes and this page\nonly discuss a few of them.\n\n------------------------\n\nThe `rustc_attrs` feature allows debugging rustc type layouts by using\n`#[rustc_layout(...)]` to debug layout at compile time (it even works\nwith `cargo check`) as an alternative to `rustc -Z print-type-sizes`\nthat is way more verbose.\n\nOptions provided by `#[rustc_layout(...)]` are `debug`, `size`, `abi`.\nNote that it only work best with sized type without generics.\n\n## Examples\n\n```rust,ignore\n#![feature(rustc_attrs)]\n\n#[rustc_layout(abi, size)]\npub enum X {\n Y(u8, u8, u8),\n Z(isize),\n}\n```\n\nWhen that is compiled, the compiler will error with something like\n\n```text\nerror: abi: Aggregate { sized: true }\n --> src/lib.rs:4:1\n |\n4 | / pub enum T {\n5 | | Y(u8, u8, u8),\n6 | | Z(isize),\n7 | | }\n | |_^\n\nerror: size: Size { raw: 16 }\n --> src/lib.rs:4:1\n |\n4 | / pub enum T {\n5 | | Y(u8, u8, u8),\n6 | | Z(isize),\n7 | | }\n | |_^\n\nerror: aborting due to 2 previous errors\n```\n" } , LintCompletion { label : "non_ascii_idents" , description : "# `non_ascii_idents`\n\nThe tracking issue for this feature is: [#55467]\n\n[#55467]: https://github.com/rust-lang/rust/issues/55467\n\n------------------------\n\nThe `non_ascii_idents` feature adds support for non-ASCII identifiers.\n\n## Examples\n\n```rust\n#![feature(non_ascii_idents)]\n\nconst ε: f64 = 0.00001f64;\nconst Π: f64 = 3.14f64;\n```\n\n## Changes to the language reference\n\n> **<sup>Lexer:<sup>** \n> IDENTIFIER : \n> &nbsp;&nbsp; &nbsp;&nbsp; XID_start XID_continue<sup>\\*</sup> \n> &nbsp;&nbsp; | `_` XID_continue<sup>+</sup> \n\nAn identifier is any nonempty Unicode string of the following form:\n\nEither\n\n * The first character has property [`XID_start`]\n * The remaining characters have property [`XID_continue`]\n\nOr\n\n * The first character is `_`\n * The identifier is more than one character, `_` alone is not an identifier\n * The remaining characters have property [`XID_continue`]\n\nthat does _not_ occur in the set of [strict keywords].\n\n> **Note**: [`XID_start`] and [`XID_continue`] as character properties cover the\n> character ranges used to form the more familiar C and Java language-family\n> identifiers.\n\n[`XID_start`]: http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5B%3AXID_Start%3A%5D&abb=on&g=&i=\n[`XID_continue`]: http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5B%3AXID_Continue%3A%5D&abb=on&g=&i=\n[strict keywords]: ../../reference/keywords.md#strict-keywords\n" } , LintCompletion { label : "box_syntax" , description : "# `box_syntax`\n\nThe tracking issue for this feature is: [#49733]\n\n[#49733]: https://github.com/rust-lang/rust/issues/49733\n\nSee also [`box_patterns`](box-patterns.md)\n\n------------------------\n\nCurrently the only stable way to create a `Box` is via the `Box::new` method.\nAlso it is not possible in stable Rust to destructure a `Box` in a match\npattern. The unstable `box` keyword can be used to create a `Box`. An example\nusage would be:\n\n```rust\n#![feature(box_syntax)]\n\nfn main() {\n let b = box 5;\n}\n```\n" } , LintCompletion { label : "no_sanitize" , description : "# `no_sanitize`\n\nThe tracking issue for this feature is: [#39699]\n\n[#39699]: https://github.com/rust-lang/rust/issues/39699\n\n------------------------\n\nThe `no_sanitize` attribute can be used to selectively disable sanitizer\ninstrumentation in an annotated function. This might be useful to: avoid\ninstrumentation overhead in a performance critical function, or avoid\ninstrumenting code that contains constructs unsupported by given sanitizer.\n\nThe precise effect of this annotation depends on particular sanitizer in use.\nFor example, with `no_sanitize(thread)`, the thread sanitizer will no longer\ninstrument non-atomic store / load operations, but it will instrument atomic\noperations to avoid reporting false positives and provide meaning full stack\ntraces.\n\n## Examples\n\n``` rust\n#![feature(no_sanitize)]\n\n#[no_sanitize(address)]\nfn foo() {\n // ...\n}\n```\n" } , LintCompletion { label : "trait_alias" , description : "# `trait_alias`\n\nThe tracking issue for this feature is: [#41517]\n\n[#41517]: https://github.com/rust-lang/rust/issues/41517\n\n------------------------\n\nThe `trait_alias` feature adds support for trait aliases. These allow aliases\nto be created for one or more traits (currently just a single regular trait plus\nany number of auto-traits), and used wherever traits would normally be used as\neither bounds or trait objects.\n\n```rust\n#![feature(trait_alias)]\n\ntrait Foo = std::fmt::Debug + Send;\ntrait Bar = Foo + Sync;\n\n// Use trait alias as bound on type parameter.\nfn foo<T: Foo>(v: &T) {\n println!(\"{:?}\", v);\n}\n\npub fn main() {\n foo(&1);\n\n // Use trait alias for trait objects.\n let a: &Bar = &123;\n println!(\"{:?}\", a);\n let b = Box::new(456) as Box<dyn Foo>;\n println!(\"{:?}\", b);\n}\n```\n" } , LintCompletion { label : "unboxed_closures" , description : "# `unboxed_closures`\n\nThe tracking issue for this feature is [#29625]\n\nSee Also: [`fn_traits`](../library-features/fn-traits.md)\n\n[#29625]: https://github.com/rust-lang/rust/issues/29625\n\n----\n\nThe `unboxed_closures` feature allows you to write functions using the `\"rust-call\"` ABI,\nrequired for implementing the [`Fn*`] family of traits. `\"rust-call\"` functions must have \nexactly one (non self) argument, a tuple representing the argument list.\n\n[`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html\n\n```rust\n#![feature(unboxed_closures)]\n\nextern \"rust-call\" fn add_args(args: (u32, u32)) -> u32 {\n args.0 + args.1\n}\n\nfn main() {}\n```\n" } , LintCompletion { label : "lang_items" , description : "# `lang_items`\n\nThe tracking issue for this feature is: None.\n\n------------------------\n\nThe `rustc` compiler has certain pluggable operations, that is,\nfunctionality that isn't hard-coded into the language, but is\nimplemented in libraries, with a special marker to tell the compiler\nit exists. The marker is the attribute `#[lang = \"...\"]` and there are\nvarious different values of `...`, i.e. various different 'lang\nitems'.\n\nFor example, `Box` pointers require two lang items, one for allocation\nand one for deallocation. A freestanding program that uses the `Box`\nsugar for dynamic allocations via `malloc` and `free`:\n\n```rust,ignore\n#![feature(lang_items, box_syntax, start, libc, core_intrinsics)]\n#![no_std]\nuse core::intrinsics;\nuse core::panic::PanicInfo;\n\nextern crate libc;\n\n#[lang = \"owned_box\"]\npub struct Box<T>(*mut T);\n\n#[lang = \"exchange_malloc\"]\nunsafe fn allocate(size: usize, _align: usize) -> *mut u8 {\n let p = libc::malloc(size as libc::size_t) as *mut u8;\n\n // Check if `malloc` failed:\n if p as usize == 0 {\n intrinsics::abort();\n }\n\n p\n}\n\n#[lang = \"box_free\"]\nunsafe fn box_free<T: ?Sized>(ptr: *mut T) {\n libc::free(ptr as *mut libc::c_void)\n}\n\n#[start]\nfn main(_argc: isize, _argv: *const *const u8) -> isize {\n let _x = box 1;\n\n 0\n}\n\n#[lang = \"eh_personality\"] extern fn rust_eh_personality() {}\n#[lang = \"panic_impl\"] extern fn rust_begin_panic(info: &PanicInfo) -> ! { unsafe { intrinsics::abort() } }\n#[no_mangle] pub extern fn rust_eh_register_frames () {}\n#[no_mangle] pub extern fn rust_eh_unregister_frames () {}\n```\n\nNote the use of `abort`: the `exchange_malloc` lang item is assumed to\nreturn a valid pointer, and so needs to do the check internally.\n\nOther features provided by lang items include:\n\n- overloadable operators via traits: the traits corresponding to the\n `==`, `<`, dereferencing (`*`) and `+` (etc.) operators are all\n marked with lang items; those specific four are `eq`, `ord`,\n `deref`, and `add` respectively.\n- stack unwinding and general failure; the `eh_personality`,\n `panic` and `panic_bounds_checks` lang items.\n- the traits in `std::marker` used to indicate types of\n various kinds; lang items `send`, `sync` and `copy`.\n- the marker types and variance indicators found in\n `std::marker`; lang items `covariant_type`,\n `contravariant_lifetime`, etc.\n\nLang items are loaded lazily by the compiler; e.g. if one never uses\n`Box` then there is no need to define functions for `exchange_malloc`\nand `box_free`. `rustc` will emit an error when an item is needed\nbut not found in the current crate or any that it depends on.\n\nMost lang items are defined by `libcore`, but if you're trying to build\nan executable without the standard library, you'll run into the need\nfor lang items. The rest of this page focuses on this use-case, even though\nlang items are a bit broader than that.\n\n### Using libc\n\nIn order to build a `#[no_std]` executable we will need libc as a dependency.\nWe can specify this using our `Cargo.toml` file:\n\n```toml\n[dependencies]\nlibc = { version = \"0.2.14\", default-features = false }\n```\n\nNote that the default features have been disabled. This is a critical step -\n**the default features of libc include the standard library and so must be\ndisabled.**\n\n### Writing an executable without stdlib\n\nControlling the entry point is possible in two ways: the `#[start]` attribute,\nor overriding the default shim for the C `main` function with your own.\n\nThe function marked `#[start]` is passed the command line parameters\nin the same format as C:\n\n```rust,ignore\n#![feature(lang_items, core_intrinsics)]\n#![feature(start)]\n#![no_std]\nuse core::intrinsics;\nuse core::panic::PanicInfo;\n\n// Pull in the system libc library for what crt0.o likely requires.\nextern crate libc;\n\n// Entry point for this program.\n#[start]\nfn start(_argc: isize, _argv: *const *const u8) -> isize {\n 0\n}\n\n// These functions are used by the compiler, but not\n// for a bare-bones hello world. These are normally\n// provided by libstd.\n#[lang = \"eh_personality\"]\n#[no_mangle]\npub extern fn rust_eh_personality() {\n}\n\n#[lang = \"panic_impl\"]\n#[no_mangle]\npub extern fn rust_begin_panic(info: &PanicInfo) -> ! {\n unsafe { intrinsics::abort() }\n}\n```\n\nTo override the compiler-inserted `main` shim, one has to disable it\nwith `#![no_main]` and then create the appropriate symbol with the\ncorrect ABI and the correct name, which requires overriding the\ncompiler's name mangling too:\n\n```rust,ignore\n#![feature(lang_items, core_intrinsics)]\n#![feature(start)]\n#![no_std]\n#![no_main]\nuse core::intrinsics;\nuse core::panic::PanicInfo;\n\n// Pull in the system libc library for what crt0.o likely requires.\nextern crate libc;\n\n// Entry point for this program.\n#[no_mangle] // ensure that this symbol is called `main` in the output\npub extern fn main(_argc: i32, _argv: *const *const u8) -> i32 {\n 0\n}\n\n// These functions are used by the compiler, but not\n// for a bare-bones hello world. These are normally\n// provided by libstd.\n#[lang = \"eh_personality\"]\n#[no_mangle]\npub extern fn rust_eh_personality() {\n}\n\n#[lang = \"panic_impl\"]\n#[no_mangle]\npub extern fn rust_begin_panic(info: &PanicInfo) -> ! {\n unsafe { intrinsics::abort() }\n}\n```\n\nIn many cases, you may need to manually link to the `compiler_builtins` crate\nwhen building a `no_std` binary. You may observe this via linker error messages\nsuch as \"```undefined reference to `__rust_probestack'```\".\n\n## More about the language items\n\nThe compiler currently makes a few assumptions about symbols which are\navailable in the executable to call. Normally these functions are provided by\nthe standard library, but without it you must define your own. These symbols\nare called \"language items\", and they each have an internal name, and then a\nsignature that an implementation must conform to.\n\nThe first of these functions, `rust_eh_personality`, is used by the failure\nmechanisms of the compiler. This is often mapped to GCC's personality function\n(see the [libstd implementation][unwind] for more information), but crates\nwhich do not trigger a panic can be assured that this function is never\ncalled. The language item's name is `eh_personality`.\n\n[unwind]: https://github.com/rust-lang/rust/blob/master/src/libpanic_unwind/gcc.rs\n\nThe second function, `rust_begin_panic`, is also used by the failure mechanisms of the\ncompiler. When a panic happens, this controls the message that's displayed on\nthe screen. While the language item's name is `panic_impl`, the symbol name is\n`rust_begin_panic`.\n\nFinally, a `eh_catch_typeinfo` static is needed for certain targets which\nimplement Rust panics on top of C++ exceptions.\n\n## List of all language items\n\nThis is a list of all language items in Rust along with where they are located in\nthe source code.\n\n- Primitives\n - `i8`: `libcore/num/mod.rs`\n - `i16`: `libcore/num/mod.rs`\n - `i32`: `libcore/num/mod.rs`\n - `i64`: `libcore/num/mod.rs`\n - `i128`: `libcore/num/mod.rs`\n - `isize`: `libcore/num/mod.rs`\n - `u8`: `libcore/num/mod.rs`\n - `u16`: `libcore/num/mod.rs`\n - `u32`: `libcore/num/mod.rs`\n - `u64`: `libcore/num/mod.rs`\n - `u128`: `libcore/num/mod.rs`\n - `usize`: `libcore/num/mod.rs`\n - `f32`: `libstd/f32.rs`\n - `f64`: `libstd/f64.rs`\n - `char`: `libcore/char.rs`\n - `slice`: `liballoc/slice.rs`\n - `str`: `liballoc/str.rs`\n - `const_ptr`: `libcore/ptr.rs`\n - `mut_ptr`: `libcore/ptr.rs`\n - `unsafe_cell`: `libcore/cell.rs`\n- Runtime\n - `start`: `libstd/rt.rs`\n - `eh_personality`: `libpanic_unwind/emcc.rs` (EMCC)\n - `eh_personality`: `libpanic_unwind/gcc.rs` (GNU)\n - `eh_personality`: `libpanic_unwind/seh.rs` (SEH)\n - `eh_catch_typeinfo`: `libpanic_unwind/emcc.rs` (EMCC)\n - `panic`: `libcore/panicking.rs`\n - `panic_bounds_check`: `libcore/panicking.rs`\n - `panic_impl`: `libcore/panicking.rs`\n - `panic_impl`: `libstd/panicking.rs`\n- Allocations\n - `owned_box`: `liballoc/boxed.rs`\n - `exchange_malloc`: `liballoc/heap.rs`\n - `box_free`: `liballoc/heap.rs`\n- Operands\n - `not`: `libcore/ops/bit.rs`\n - `bitand`: `libcore/ops/bit.rs`\n - `bitor`: `libcore/ops/bit.rs`\n - `bitxor`: `libcore/ops/bit.rs`\n - `shl`: `libcore/ops/bit.rs`\n - `shr`: `libcore/ops/bit.rs`\n - `bitand_assign`: `libcore/ops/bit.rs`\n - `bitor_assign`: `libcore/ops/bit.rs`\n - `bitxor_assign`: `libcore/ops/bit.rs`\n - `shl_assign`: `libcore/ops/bit.rs`\n - `shr_assign`: `libcore/ops/bit.rs`\n - `deref`: `libcore/ops/deref.rs`\n - `deref_mut`: `libcore/ops/deref.rs`\n - `index`: `libcore/ops/index.rs`\n - `index_mut`: `libcore/ops/index.rs`\n - `add`: `libcore/ops/arith.rs`\n - `sub`: `libcore/ops/arith.rs`\n - `mul`: `libcore/ops/arith.rs`\n - `div`: `libcore/ops/arith.rs`\n - `rem`: `libcore/ops/arith.rs`\n - `neg`: `libcore/ops/arith.rs`\n - `add_assign`: `libcore/ops/arith.rs`\n - `sub_assign`: `libcore/ops/arith.rs`\n - `mul_assign`: `libcore/ops/arith.rs`\n - `div_assign`: `libcore/ops/arith.rs`\n - `rem_assign`: `libcore/ops/arith.rs`\n - `eq`: `libcore/cmp.rs`\n - `ord`: `libcore/cmp.rs`\n- Functions\n - `fn`: `libcore/ops/function.rs`\n - `fn_mut`: `libcore/ops/function.rs`\n - `fn_once`: `libcore/ops/function.rs`\n - `generator_state`: `libcore/ops/generator.rs`\n - `generator`: `libcore/ops/generator.rs`\n- Other\n - `coerce_unsized`: `libcore/ops/unsize.rs`\n - `drop`: `libcore/ops/drop.rs`\n - `drop_in_place`: `libcore/ptr.rs`\n - `clone`: `libcore/clone.rs`\n - `copy`: `libcore/marker.rs`\n - `send`: `libcore/marker.rs`\n - `sized`: `libcore/marker.rs`\n - `unsize`: `libcore/marker.rs`\n - `sync`: `libcore/marker.rs`\n - `phantom_data`: `libcore/marker.rs`\n - `discriminant_kind`: `libcore/marker.rs`\n - `freeze`: `libcore/marker.rs`\n - `debug_trait`: `libcore/fmt/mod.rs`\n - `non_zero`: `libcore/nonzero.rs`\n - `arc`: `liballoc/sync.rs`\n - `rc`: `liballoc/rc.rs`\n" } , LintCompletion { label : "negative_impls" , description : "# `negative_impls`\n\nThe tracking issue for this feature is [#68318].\n\n[#68318]: https://github.com/rust-lang/rust/issues/68318\n\n----\n\nWith the feature gate `negative_impls`, you can write negative impls as well as positive ones:\n\n```rust\n#![feature(negative_impls)]\ntrait DerefMut { }\nimpl<T: ?Sized> !DerefMut for &T { }\n```\n\nNegative impls indicate a semver guarantee that the given trait will not be implemented for the given types. Negative impls play an additional purpose for auto traits, described below.\n\nNegative impls have the following characteristics:\n\n* They do not have any items.\n* They must obey the orphan rules as if they were a positive impl.\n* They cannot \"overlap\" with any positive impls.\n\n## Semver interaction\n\nIt is a breaking change to remove a negative impl. Negative impls are a commitment not to implement the given trait for the named types.\n\n## Orphan and overlap rules\n\nNegative impls must obey the same orphan rules as a positive impl. This implies you cannot add a negative impl for types defined in upstream crates and so forth.\n\nSimilarly, negative impls cannot overlap with positive impls, again using the same \"overlap\" check that we ordinarily use to determine if two impls overlap. (Note that positive impls typically cannot overlap with one another either, except as permitted by specialization.)\n\n## Interaction with auto traits\n\nDeclaring a negative impl `impl !SomeAutoTrait for SomeType` for an\nauto-trait serves two purposes:\n\n* as with any trait, it declares that `SomeType` will never implement `SomeAutoTrait`;\n* it disables the automatic `SomeType: SomeAutoTrait` impl that would otherwise have been generated.\n\nNote that, at present, there is no way to indicate that a given type\ndoes not implement an auto trait *but that it may do so in the\nfuture*. For ordinary types, this is done by simply not declaring any\nimpl at all, but that is not an option for auto traits. A workaround\nis that one could embed a marker type as one of the fields, where the\nmarker type is `!AutoTrait`.\n\n## Immediate uses\n\nNegative impls are used to declare that `&T: !DerefMut` and `&mut T: !Clone`, as required to fix the soundness of `Pin` described in [#66544](https://github.com/rust-lang/rust/issues/66544).\n\nThis serves two purposes:\n\n* For proving the correctness of unsafe code, we can use that impl as evidence that no `DerefMut` or `Clone` impl exists.\n* It prevents downstream crates from creating such impls.\n" } , LintCompletion { label : "abi_ptx" , description : "# `abi_ptx`\n\nThe tracking issue for this feature is: [#38788]\n\n[#38788]: https://github.com/rust-lang/rust/issues/38788\n\n------------------------\n\nWhen emitting PTX code, all vanilla Rust functions (`fn`) get translated to\n\"device\" functions. These functions are *not* callable from the host via the\nCUDA API so a crate with only device functions is not too useful!\n\nOTOH, \"global\" functions *can* be called by the host; you can think of them\nas the real public API of your crate. To produce a global function use the\n`\"ptx-kernel\"` ABI.\n\n<!-- NOTE(ignore) this example is specific to the nvptx targets -->\n\n``` rust,ignore\n#![feature(abi_ptx)]\n#![no_std]\n\npub unsafe extern \"ptx-kernel\" fn global_function() {\n device_function();\n}\n\npub fn device_function() {\n // ..\n}\n```\n\n``` text\n$ xargo rustc --target nvptx64-nvidia-cuda --release -- --emit=asm\n\n$ cat $(find -name '*.s')\n//\n// Generated by LLVM NVPTX Back-End\n//\n\n.version 3.2\n.target sm_20\n.address_size 64\n\n // .globl _ZN6kernel15global_function17h46111ebe6516b382E\n\n.visible .entry _ZN6kernel15global_function17h46111ebe6516b382E()\n{\n\n\n ret;\n}\n\n // .globl _ZN6kernel15device_function17hd6a0e4993bbf3f78E\n.visible .func _ZN6kernel15device_function17hd6a0e4993bbf3f78E()\n{\n\n\n ret;\n}\n```\n" } , LintCompletion { label : "try_blocks" , description : "# `try_blocks`\n\nThe tracking issue for this feature is: [#31436]\n\n[#31436]: https://github.com/rust-lang/rust/issues/31436\n\n------------------------\n\nThe `try_blocks` feature adds support for `try` blocks. A `try`\nblock creates a new scope one can use the `?` operator in.\n\n```rust,edition2018\n#![feature(try_blocks)]\n\nuse std::num::ParseIntError;\n\nlet result: Result<i32, ParseIntError> = try {\n \"1\".parse::<i32>()?\n + \"2\".parse::<i32>()?\n + \"3\".parse::<i32>()?\n};\nassert_eq!(result, Ok(6));\n\nlet result: Result<i32, ParseIntError> = try {\n \"1\".parse::<i32>()?\n + \"foo\".parse::<i32>()?\n + \"3\".parse::<i32>()?\n};\nassert!(result.is_err());\n```\n" } , LintCompletion { label : "profiler_runtime" , description : "# `profiler_runtime`\n\nThe tracking issue for this feature is: [#42524](https://github.com/rust-lang/rust/issues/42524).\n\n------------------------\n" } , LintCompletion { label : "compiler_builtins" , description : "# `compiler_builtins`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "doc_spotlight" , description : "# `doc_spotlight`\n\nThe tracking issue for this feature is: [#45040]\n\nThe `doc_spotlight` feature allows the use of the `spotlight` parameter to the `#[doc]` attribute,\nto \"spotlight\" a specific trait on the return values of functions. Adding a `#[doc(spotlight)]`\nattribute to a trait definition will make rustdoc print extra information for functions which return\na type that implements that trait. This attribute is applied to the `Iterator`, `io::Read`, and\n`io::Write` traits in the standard library.\n\nYou can do this on your own traits, like this:\n\n```\n#![feature(doc_spotlight)]\n\n#[doc(spotlight)]\npub trait MyTrait {}\n\npub struct MyStruct;\nimpl MyTrait for MyStruct {}\n\n/// The docs for this function will have an extra line about `MyStruct` implementing `MyTrait`,\n/// without having to write that yourself!\npub fn my_fn() -> MyStruct { MyStruct }\n```\n\nThis feature was originally implemented in PR [#45039].\n\n[#45040]: https://github.com/rust-lang/rust/issues/45040\n[#45039]: https://github.com/rust-lang/rust/pull/45039\n" } , LintCompletion { label : "box_patterns" , description : "# `box_patterns`\n\nThe tracking issue for this feature is: [#29641]\n\n[#29641]: https://github.com/rust-lang/rust/issues/29641\n\nSee also [`box_syntax`](box-syntax.md)\n\n------------------------\n\nBox patterns let you match on `Box<T>`s:\n\n\n```rust\n#![feature(box_patterns)]\n\nfn main() {\n let b = Some(Box::new(5));\n match b {\n Some(box n) if n < 0 => {\n println!(\"Box contains negative number {}\", n);\n },\n Some(box n) if n >= 0 => {\n println!(\"Box contains non-negative number {}\", n);\n },\n None => {\n println!(\"No box\");\n },\n _ => unreachable!()\n }\n}\n```\n" } , LintCompletion { label : "const_eval_limit" , description : "# `const_eval_limit`\n\nThe tracking issue for this feature is: [#67217]\n\n[#67217]: https://github.com/rust-lang/rust/issues/67217\n\nThe `const_eval_limit` allows someone to limit the evaluation steps the CTFE undertakes to evaluate a `const fn`.\n" } , LintCompletion { label : "arbitrary_enum_discriminant" , description : "# `arbitrary_enum_discriminant`\n\nThe tracking issue for this feature is: [#60553]\n\n[#60553]: https://github.com/rust-lang/rust/issues/60553\n\n------------------------\n\nThe `arbitrary_enum_discriminant` feature permits tuple-like and\nstruct-like enum variants with `#[repr(<int-type>)]` to have explicit discriminants.\n\n## Examples\n\n```rust\n#![feature(arbitrary_enum_discriminant)]\n\n#[allow(dead_code)]\n#[repr(u8)]\nenum Enum {\n Unit = 3,\n Tuple(u16) = 2,\n Struct {\n a: u8,\n b: u16,\n } = 1,\n}\n\nimpl Enum {\n fn tag(&self) -> u8 {\n unsafe { *(self as *const Self as *const u8) }\n }\n}\n\nassert_eq!(3, Enum::Unit.tag());\nassert_eq!(2, Enum::Tuple(5).tag());\nassert_eq!(1, Enum::Struct{a: 7, b: 11}.tag());\n```\n" } , LintCompletion { label : "custom_test_frameworks" , description : "# `custom_test_frameworks`\n\nThe tracking issue for this feature is: [#50297]\n\n[#50297]: https://github.com/rust-lang/rust/issues/50297\n\n------------------------\n\nThe `custom_test_frameworks` feature allows the use of `#[test_case]` and `#![test_runner]`.\nAny function, const, or static can be annotated with `#[test_case]` causing it to be aggregated (like `#[test]`)\nand be passed to the test runner determined by the `#![test_runner]` crate attribute.\n\n```rust\n#![feature(custom_test_frameworks)]\n#![test_runner(my_runner)]\n\nfn my_runner(tests: &[&i32]) {\n for t in tests {\n if **t == 0 {\n println!(\"PASSED\");\n } else {\n println!(\"FAILED\");\n }\n }\n}\n\n#[test_case]\nconst WILL_PASS: i32 = 0;\n\n#[test_case]\nconst WILL_FAIL: i32 = 4;\n```\n\n" } , LintCompletion { label : "plugin_registrar" , description : "# `plugin_registrar`\n\nThe tracking issue for this feature is: [#29597]\n\n[#29597]: https://github.com/rust-lang/rust/issues/29597\n\nThis feature is part of \"compiler plugins.\" It will often be used with the\n[`plugin`] and `rustc_private` features as well. For more details, see\ntheir docs.\n\n[`plugin`]: plugin.md\n\n------------------------\n" } , LintCompletion { label : "impl_trait_in_bindings" , description : "# `impl_trait_in_bindings`\n\nThe tracking issue for this feature is: [#63065]\n\n[#63065]: https://github.com/rust-lang/rust/issues/63065\n\n------------------------\n\nThe `impl_trait_in_bindings` feature gate lets you use `impl Trait` syntax in\n`let`, `static`, and `const` bindings.\n\nA simple example is:\n\n```rust\n#![feature(impl_trait_in_bindings)]\n\nuse std::fmt::Debug;\n\nfn main() {\n let a: impl Debug + Clone = 42;\n let b = a.clone();\n println!(\"{:?}\", b); // prints `42`\n}\n```\n\nNote however that because the types of `a` and `b` are opaque in the above\nexample, calling inherent methods or methods outside of the specified traits\n(e.g., `a.abs()` or `b.abs()`) is not allowed, and yields an error.\n" } , LintCompletion { label : "ffi_pure" , description : "# `ffi_pure`\n\nThe `#[ffi_pure]` attribute applies clang's `pure` attribute to foreign\nfunctions declarations.\n\nThat is, `#[ffi_pure]` functions shall have no effects except for its return\nvalue, which shall not change across two consecutive function calls with\nthe same parameters.\n\nApplying the `#[ffi_pure]` attribute to a function that violates these\nrequirements is undefined behavior.\n\nThis attribute enables Rust to perform common optimizations, like sub-expression\nelimination and loop optimizations. Some common examples of pure functions are\n`strlen` or `memcmp`.\n\nThese optimizations are only applicable when the compiler can prove that no\nprogram state observable by the `#[ffi_pure]` function has changed between calls\nof the function, which could alter the result. See also the `#[ffi_const]`\nattribute, which provides stronger guarantees regarding the allowable behavior\nof a function, enabling further optimization.\n\n## Pitfalls\n\nA `#[ffi_pure]` function can read global memory through the function\nparameters (e.g. pointers), globals, etc. `#[ffi_pure]` functions are not\nreferentially-transparent, and are therefore more relaxed than `#[ffi_const]`\nfunctions.\n\nHowever, accesing global memory through volatile or atomic reads can violate the\nrequirement that two consecutive function calls shall return the same value.\n\nA `pure` function that returns unit has no effect on the abstract machine's\nstate.\n\nA `#[ffi_pure]` function must not diverge, neither via a side effect (e.g. a\ncall to `abort`) nor by infinite loops.\n\nWhen translating C headers to Rust FFI, it is worth verifying for which targets\nthe `pure` attribute is enabled in those headers, and using the appropriate\n`cfg` macros in the Rust side to match those definitions. While the semantics of\n`pure` are implemented identically by many C and C++ compilers, e.g., clang,\n[GCC], [ARM C/C++ compiler], [IBM ILE C/C++], etc. they are not necessarily\nimplemented in this way on all of them. It is therefore also worth verifying\nthat the semantics of the C toolchain used to compile the binary being linked\nagainst are compatible with those of the `#[ffi_pure]`.\n\n\n[ARM C/C++ compiler]: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/Cacigdac.html\n[GCC]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute\n[IBM ILE C/C++]: https://www.ibm.com/support/knowledgecenter/fr/ssw_ibm_i_71/rzarg/fn_attrib_pure.htm\n" } , LintCompletion { label : "const_fn" , description : "# `const_fn`\n\nThe tracking issue for this feature is: [#57563]\n\n[#57563]: https://github.com/rust-lang/rust/issues/57563\n\n------------------------\n\nThe `const_fn` feature allows marking free functions and inherent methods as\n`const`, enabling them to be called in constants contexts, with constant\narguments.\n\n## Examples\n\n```rust\n#![feature(const_fn)]\n\nconst fn double(x: i32) -> i32 {\n x * 2\n}\n\nconst FIVE: i32 = 5;\nconst TEN: i32 = double(FIVE);\n\nfn main() {\n assert_eq!(5, FIVE);\n assert_eq!(10, TEN);\n}\n```\n" } , LintCompletion { label : "intrinsics" , description : "# `intrinsics`\n\nThe tracking issue for this feature is: None.\n\nIntrinsics are never intended to be stable directly, but intrinsics are often\nexported in some sort of stable manner. Prefer using the stable interfaces to\nthe intrinsic directly when you can.\n\n------------------------\n\n\nThese are imported as if they were FFI functions, with the special\n`rust-intrinsic` ABI. For example, if one was in a freestanding\ncontext, but wished to be able to `transmute` between types, and\nperform efficient pointer arithmetic, one would import those functions\nvia a declaration like\n\n```rust\n#![feature(intrinsics)]\n# fn main() {}\n\nextern \"rust-intrinsic\" {\n fn transmute<T, U>(x: T) -> U;\n\n fn offset<T>(dst: *const T, offset: isize) -> *const T;\n}\n```\n\nAs with any other FFI functions, these are always `unsafe` to call.\n\n" } , LintCompletion { label : "c_variadic" , description : "# `c_variadic`\n\nThe tracking issue for this feature is: [#44930]\n\n[#44930]: https://github.com/rust-lang/rust/issues/44930\n\n------------------------\n\nThe `c_variadic` language feature enables C-variadic functions to be\ndefined in Rust. The may be called both from within Rust and via FFI.\n\n## Examples\n\n```rust\n#![feature(c_variadic)]\n\npub unsafe extern \"C\" fn add(n: usize, mut args: ...) -> usize {\n let mut sum = 0;\n for _ in 0..n {\n sum += args.arg::<usize>();\n }\n sum\n}\n```\n" } , LintCompletion { label : "cfg_sanitize" , description : "# `cfg_sanitize`\n\nThe tracking issue for this feature is: [#39699]\n\n[#39699]: https://github.com/rust-lang/rust/issues/39699\n\n------------------------\n\nThe `cfg_sanitize` feature makes it possible to execute different code\ndepending on whether a particular sanitizer is enabled or not.\n\n## Examples\n\n```rust\n#![feature(cfg_sanitize)]\n\n#[cfg(sanitize = \"thread\")]\nfn a() {\n // ...\n}\n\n#[cfg(not(sanitize = \"thread\"))]\nfn a() {\n // ...\n}\n\nfn b() {\n if cfg!(sanitize = \"leak\") {\n // ...\n } else {\n // ...\n }\n}\n```\n" } , LintCompletion { label : "allocator_internals" , description : "# `allocator_internals`\n\nThis feature does not have a tracking issue, it is an unstable implementation\ndetail of the `global_allocator` feature not intended for use outside the\ncompiler.\n\n------------------------\n" } , LintCompletion { label : "doc_alias" , description : "# `doc_alias`\n\nThe tracking issue for this feature is: [#50146]\n\n[#50146]: https://github.com/rust-lang/rust/issues/50146\n\n------------------------\n\nYou can add alias(es) to an item when using the `rustdoc` search through the\n`doc(alias)` attribute. Example:\n\n```rust,no_run\n#![feature(doc_alias)]\n\n#[doc(alias = \"x\")]\n#[doc(alias = \"big\")]\npub struct BigX;\n```\n\nThen, when looking for it through the `rustdoc` search, if you enter \"x\" or\n\"big\", search will show the `BigX` struct first.\n\nNote that this feature is currently hidden behind the `feature(doc_alias)` gate.\n" } , LintCompletion { label : "link_cfg" , description : "# `link_cfg`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "transparent_unions" , description : "# `transparent_unions`\n\nThe tracking issue for this feature is [#60405]\n\n[#60405]: https://github.com/rust-lang/rust/issues/60405\n\n----\n\nThe `transparent_unions` feature allows you mark `union`s as\n`#[repr(transparent)]`. A `union` may be `#[repr(transparent)]` in exactly the\nsame conditions in which a `struct` may be `#[repr(transparent)]` (generally,\nthis means the `union` must have exactly one non-zero-sized field). Some\nconcrete illustrations follow.\n\n```rust\n#![feature(transparent_unions)]\n\n// This union has the same representation as `f32`.\n#[repr(transparent)]\nunion SingleFieldUnion {\n field: f32,\n}\n\n// This union has the same representation as `usize`.\n#[repr(transparent)]\nunion MultiFieldUnion {\n field: usize,\n nothing: (),\n}\n```\n\nFor consistency with transparent `struct`s, `union`s must have exactly one\nnon-zero-sized field. If all fields are zero-sized, the `union` must not be\n`#[repr(transparent)]`:\n\n```rust\n#![feature(transparent_unions)]\n\n// This (non-transparent) union is already valid in stable Rust:\npub union GoodUnion {\n pub nothing: (),\n}\n\n// Error: transparent union needs exactly one non-zero-sized field, but has 0\n// #[repr(transparent)]\n// pub union BadUnion {\n// pub nothing: (),\n// }\n```\n\nThe one exception is if the `union` is generic over `T` and has a field of type\n`T`, it may be `#[repr(transparent)]` even if `T` is a zero-sized type:\n\n```rust\n#![feature(transparent_unions)]\n\n// This union has the same representation as `T`.\n#[repr(transparent)]\npub union GenericUnion<T: Copy> { // Unions with non-`Copy` fields are unstable.\n pub field: T,\n pub nothing: (),\n}\n\n// This is okay even though `()` is a zero-sized type.\npub const THIS_IS_OKAY: GenericUnion<()> = GenericUnion { field: () };\n```\n\nLike transarent `struct`s, a transparent `union` of type `U` has the same\nlayout, size, and ABI as its single non-ZST field. If it is generic over a type\n`T`, and all its fields are ZSTs except for exactly one field of type `T`, then\nit has the same layout and ABI as `T` (even if `T` is a ZST when monomorphized).\n\nLike transparent `struct`s, transparent `union`s are FFI-safe if and only if\ntheir underlying representation type is also FFI-safe.\n\nA `union` may not be eligible for the same nonnull-style optimizations that a\n`struct` or `enum` (with the same fields) are eligible for. Adding\n`#[repr(transparent)]` to `union` does not change this. To give a more concrete\nexample, it is unspecified whether `size_of::<T>()` is equal to\n`size_of::<Option<T>>()`, where `T` is a `union` (regardless of whether or not\nit is transparent). The Rust compiler is free to perform this optimization if\npossible, but is not required to, and different compiler versions may differ in\ntheir application of these optimizations.\n" } , LintCompletion { label : "plugin" , description : "# `plugin`\n\nThe tracking issue for this feature is: [#29597]\n\n[#29597]: https://github.com/rust-lang/rust/issues/29597\n\n\nThis feature is part of \"compiler plugins.\" It will often be used with the\n[`plugin_registrar`] and `rustc_private` features.\n\n[`plugin_registrar`]: plugin-registrar.md\n\n------------------------\n\n`rustc` can load compiler plugins, which are user-provided libraries that\nextend the compiler's behavior with new lint checks, etc.\n\nA plugin is a dynamic library crate with a designated *registrar* function that\nregisters extensions with `rustc`. Other crates can load these extensions using\nthe crate attribute `#![plugin(...)]`. See the\n`rustc_driver::plugin` documentation for more about the\nmechanics of defining and loading a plugin.\n\nIn the vast majority of cases, a plugin should *only* be used through\n`#![plugin]` and not through an `extern crate` item. Linking a plugin would\npull in all of librustc_ast and librustc as dependencies of your crate. This is\ngenerally unwanted unless you are building another plugin.\n\nThe usual practice is to put compiler plugins in their own crate, separate from\nany `macro_rules!` macros or ordinary Rust code meant to be used by consumers\nof a library.\n\n# Lint plugins\n\nPlugins can extend [Rust's lint\ninfrastructure](../../reference/attributes/diagnostics.md#lint-check-attributes) with\nadditional checks for code style, safety, etc. Now let's write a plugin\n[`lint-plugin-test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs)\nthat warns about any item named `lintme`.\n\n```rust,ignore\n#![feature(plugin_registrar)]\n#![feature(box_syntax, rustc_private)]\n\nextern crate rustc_ast;\n\n// Load rustc as a plugin to get macros\nextern crate rustc_driver;\n#[macro_use]\nextern crate rustc_lint;\n#[macro_use]\nextern crate rustc_session;\n\nuse rustc_driver::plugin::Registry;\nuse rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};\nuse rustc_ast::ast;\ndeclare_lint!(TEST_LINT, Warn, \"Warn about items named 'lintme'\");\n\ndeclare_lint_pass!(Pass => [TEST_LINT]);\n\nimpl EarlyLintPass for Pass {\n fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {\n if it.ident.name.as_str() == \"lintme\" {\n cx.lint(TEST_LINT, |lint| {\n lint.build(\"item is named 'lintme'\").set_span(it.span).emit()\n });\n }\n }\n}\n\n#[plugin_registrar]\npub fn plugin_registrar(reg: &mut Registry) {\n reg.lint_store.register_lints(&[&TEST_LINT]);\n reg.lint_store.register_early_pass(|| box Pass);\n}\n```\n\nThen code like\n\n```rust,ignore\n#![feature(plugin)]\n#![plugin(lint_plugin_test)]\n\nfn lintme() { }\n```\n\nwill produce a compiler warning:\n\n```txt\nfoo.rs:4:1: 4:16 warning: item is named 'lintme', #[warn(test_lint)] on by default\nfoo.rs:4 fn lintme() { }\n ^~~~~~~~~~~~~~~\n```\n\nThe components of a lint plugin are:\n\n* one or more `declare_lint!` invocations, which define static `Lint` structs;\n\n* a struct holding any state needed by the lint pass (here, none);\n\n* a `LintPass`\n implementation defining how to check each syntax element. A single\n `LintPass` may call `span_lint` for several different `Lint`s, but should\n register them all through the `get_lints` method.\n\nLint passes are syntax traversals, but they run at a late stage of compilation\nwhere type information is available. `rustc`'s [built-in\nlints](https://github.com/rust-lang/rust/blob/master/src/librustc_session/lint/builtin.rs)\nmostly use the same infrastructure as lint plugins, and provide examples of how\nto access type information.\n\nLints defined by plugins are controlled by the usual [attributes and compiler\nflags](../../reference/attributes/diagnostics.md#lint-check-attributes), e.g.\n`#[allow(test_lint)]` or `-A test-lint`. These identifiers are derived from the\nfirst argument to `declare_lint!`, with appropriate case and punctuation\nconversion.\n\nYou can run `rustc -W help foo.rs` to see a list of lints known to `rustc`,\nincluding those provided by plugins loaded by `foo.rs`.\n" } , LintCompletion { label : "concat_idents" , description : "# `concat_idents`\n\nThe tracking issue for this feature is: [#29599]\n\n[#29599]: https://github.com/rust-lang/rust/issues/29599\n\n------------------------\n\nThe `concat_idents` feature adds a macro for concatenating multiple identifiers\ninto one identifier.\n\n## Examples\n\n```rust\n#![feature(concat_idents)]\n\nfn main() {\n fn foobar() -> u32 { 23 }\n let f = concat_idents!(foo, bar);\n assert_eq!(f(), 23);\n}\n```" } , LintCompletion { label : "update_panic_count" , description : "# `update_panic_count`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "fn_traits" , description : "# `fn_traits`\n\nThe tracking issue for this feature is [#29625]\n\nSee Also: [`unboxed_closures`](../language-features/unboxed-closures.md)\n\n[#29625]: https://github.com/rust-lang/rust/issues/29625\n\n----\n\nThe `fn_traits` feature allows for implementation of the [`Fn*`] traits\nfor creating custom closure-like types.\n\n[`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html\n\n```rust\n#![feature(unboxed_closures)]\n#![feature(fn_traits)]\n\nstruct Adder {\n a: u32\n}\n\nimpl FnOnce<(u32, )> for Adder {\n type Output = u32;\n extern \"rust-call\" fn call_once(self, b: (u32, )) -> Self::Output {\n self.a + b.0\n }\n}\n\nfn main() {\n let adder = Adder { a: 3 };\n assert_eq!(adder(2), 5);\n}\n```\n" } , LintCompletion { label : "try_trait" , description : "# `try_trait`\n\nThe tracking issue for this feature is: [#42327]\n\n[#42327]: https://github.com/rust-lang/rust/issues/42327\n\n------------------------\n\nThis introduces a new trait `Try` for extending the `?` operator to types\nother than `Result` (a part of [RFC 1859]). The trait provides the canonical\nway to _view_ a type in terms of a success/failure dichotomy. This will\nallow `?` to supplant the `try_opt!` macro on `Option` and the `try_ready!`\nmacro on `Poll`, among other things.\n\n[RFC 1859]: https://github.com/rust-lang/rfcs/pull/1859\n\nHere's an example implementation of the trait:\n\n```rust,ignore\n/// A distinct type to represent the `None` value of an `Option`.\n///\n/// This enables using the `?` operator on `Option`; it's rarely useful alone.\n#[derive(Debug)]\n#[unstable(feature = \"try_trait\", issue = \"42327\")]\npub struct None { _priv: () }\n\n#[unstable(feature = \"try_trait\", issue = \"42327\")]\nimpl<T> ops::Try for Option<T> {\n type Ok = T;\n type Error = None;\n\n fn into_result(self) -> Result<T, None> {\n self.ok_or(None { _priv: () })\n }\n\n fn from_ok(v: T) -> Self {\n Some(v)\n }\n\n fn from_error(_: None) -> Self {\n None\n }\n}\n```\n\nNote the `Error` associated type here is a new marker. The `?` operator\nallows interconversion between different `Try` implementers only when\nthe error type can be converted `Into` the error type of the enclosing\nfunction (or catch block). Having a distinct error type (as opposed to\njust `()`, or similar) restricts this to where it's semantically meaningful.\n" } , LintCompletion { label : "rt" , description : "# `rt`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "default_free_fn" , description : "# `default_free_fn`\n\nThe tracking issue for this feature is: [#73014]\n\n[#73014]: https://github.com/rust-lang/rust/issues/73014\n\n------------------------\n\nAdds a free `default()` function to the `std::default` module. This function\njust forwards to [`Default::default()`], but may remove repetition of the word\n\"default\" from the call site.\n\nHere is an example:\n\n```rust\n#![feature(default_free_fn)]\nuse std::default::default;\n\n#[derive(Default)]\nstruct AppConfig {\n foo: FooConfig,\n bar: BarConfig,\n}\n\n#[derive(Default)]\nstruct FooConfig {\n foo: i32,\n}\n\n#[derive(Default)]\nstruct BarConfig {\n bar: f32,\n baz: u8,\n}\n\nfn main() {\n let options = AppConfig {\n foo: default(),\n bar: BarConfig {\n bar: 10.1,\n ..default()\n },\n };\n}\n```\n" } , LintCompletion { label : "libstd_sys_internals" , description : "# `libstd_sys_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "fd" , description : "# `fd`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "dec2flt" , description : "# `dec2flt`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "fmt_internals" , description : "# `fmt_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "int_error_internals" , description : "# `int_error_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "libstd_thread_internals" , description : "# `libstd_thread_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "windows_net" , description : "# `windows_net`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "core_intrinsics" , description : "# `core_intrinsics`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "global_asm" , description : "# `global_asm`\n\nThe tracking issue for this feature is: [#35119]\n\n[#35119]: https://github.com/rust-lang/rust/issues/35119\n\n------------------------\n\nThe `global_asm!` macro allows the programmer to write arbitrary\nassembly outside the scope of a function body, passing it through\n`rustc` and `llvm` to the assembler. The macro is a no-frills\ninterface to LLVM's concept of [module-level inline assembly]. That is,\nall caveats applicable to LLVM's module-level inline assembly apply\nto `global_asm!`.\n\n[module-level inline assembly]: http://llvm.org/docs/LangRef.html#module-level-inline-assembly\n\n`global_asm!` fills a role not currently satisfied by either `asm!`\nor `#[naked]` functions. The programmer has _all_ features of the\nassembler at their disposal. The linker will expect to resolve any\nsymbols defined in the inline assembly, modulo any symbols marked as\nexternal. It also means syntax for directives and assembly follow the\nconventions of the assembler in your toolchain.\n\nA simple usage looks like this:\n\n```rust,ignore\n# #![feature(global_asm)]\n# you also need relevant target_arch cfgs\nglobal_asm!(include_str!(\"something_neato.s\"));\n```\n\nAnd a more complicated usage looks like this:\n\n```rust,ignore\n# #![feature(global_asm)]\n# #![cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\n\npub mod sally {\n global_asm!(r#\"\n .global foo\n foo:\n jmp baz\n \"#);\n\n #[no_mangle]\n pub unsafe extern \"C\" fn baz() {}\n}\n\n// the symbols `foo` and `bar` are global, no matter where\n// `global_asm!` was used.\nextern \"C\" {\n fn foo();\n fn bar();\n}\n\npub mod harry {\n global_asm!(r#\"\n .global bar\n bar:\n jmp quux\n \"#);\n\n #[no_mangle]\n pub unsafe extern \"C\" fn quux() {}\n}\n```\n\nYou may use `global_asm!` multiple times, anywhere in your crate, in\nwhatever way suits you. The effect is as if you concatenated all\nusages and placed the larger, single usage in the crate root.\n\n------------------------\n\nIf you don't need quite as much power and flexibility as\n`global_asm!` provides, and you don't mind restricting your inline\nassembly to `fn` bodies only, you might try the\n[asm](asm.md) feature instead.\n" } , LintCompletion { label : "sort_internals" , description : "# `sort_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "test" , description : "# `test`\n\nThe tracking issue for this feature is: None.\n\n------------------------\n\nThe internals of the `test` crate are unstable, behind the `test` flag. The\nmost widely used part of the `test` crate are benchmark tests, which can test\nthe performance of your code. Let's make our `src/lib.rs` look like this\n(comments elided):\n\n```rust,ignore\n#![feature(test)]\n\nextern crate test;\n\npub fn add_two(a: i32) -> i32 {\n a + 2\n}\n\n#[cfg(test)]\nmod tests {\n use super::*;\n use test::Bencher;\n\n #[test]\n fn it_works() {\n assert_eq!(4, add_two(2));\n }\n\n #[bench]\n fn bench_add_two(b: &mut Bencher) {\n b.iter(|| add_two(2));\n }\n}\n```\n\nNote the `test` feature gate, which enables this unstable feature.\n\nWe've imported the `test` crate, which contains our benchmarking support.\nWe have a new function as well, with the `bench` attribute. Unlike regular\ntests, which take no arguments, benchmark tests take a `&mut Bencher`. This\n`Bencher` provides an `iter` method, which takes a closure. This closure\ncontains the code we'd like to benchmark.\n\nWe can run benchmark tests with `cargo bench`:\n\n```bash\n$ cargo bench\n Compiling adder v0.0.1 (file:///home/steve/tmp/adder)\n Running target/release/adder-91b3e234d4ed382a\n\nrunning 2 tests\ntest tests::it_works ... ignored\ntest tests::bench_add_two ... bench: 1 ns/iter (+/- 0)\n\ntest result: ok. 0 passed; 0 failed; 1 ignored; 1 measured\n```\n\nOur non-benchmark test was ignored. You may have noticed that `cargo bench`\ntakes a bit longer than `cargo test`. This is because Rust runs our benchmark\na number of times, and then takes the average. Because we're doing so little\nwork in this example, we have a `1 ns/iter (+/- 0)`, but this would show\nthe variance if there was one.\n\nAdvice on writing benchmarks:\n\n\n* Move setup code outside the `iter` loop; only put the part you want to measure inside\n* Make the code do \"the same thing\" on each iteration; do not accumulate or change state\n* Make the outer function idempotent too; the benchmark runner is likely to run\n it many times\n* Make the inner `iter` loop short and fast so benchmark runs are fast and the\n calibrator can adjust the run-length at fine resolution\n* Make the code in the `iter` loop do something simple, to assist in pinpointing\n performance improvements (or regressions)\n\n## Gotcha: optimizations\n\nThere's another tricky part to writing benchmarks: benchmarks compiled with\noptimizations activated can be dramatically changed by the optimizer so that\nthe benchmark is no longer benchmarking what one expects. For example, the\ncompiler might recognize that some calculation has no external effects and\nremove it entirely.\n\n```rust,ignore\n#![feature(test)]\n\nextern crate test;\nuse test::Bencher;\n\n#[bench]\nfn bench_xor_1000_ints(b: &mut Bencher) {\n b.iter(|| {\n (0..1000).fold(0, |old, new| old ^ new);\n });\n}\n```\n\ngives the following results\n\n```text\nrunning 1 test\ntest bench_xor_1000_ints ... bench: 0 ns/iter (+/- 0)\n\ntest result: ok. 0 passed; 0 failed; 0 ignored; 1 measured\n```\n\nThe benchmarking runner offers two ways to avoid this. Either, the closure that\nthe `iter` method receives can return an arbitrary value which forces the\noptimizer to consider the result used and ensures it cannot remove the\ncomputation entirely. This could be done for the example above by adjusting the\n`b.iter` call to\n\n```rust\n# struct X;\n# impl X { fn iter<T, F>(&self, _: F) where F: FnMut() -> T {} } let b = X;\nb.iter(|| {\n // Note lack of `;` (could also use an explicit `return`).\n (0..1000).fold(0, |old, new| old ^ new)\n});\n```\n\nOr, the other option is to call the generic `test::black_box` function, which\nis an opaque \"black box\" to the optimizer and so forces it to consider any\nargument as used.\n\n```rust\n#![feature(test)]\n\nextern crate test;\n\n# fn main() {\n# struct X;\n# impl X { fn iter<T, F>(&self, _: F) where F: FnMut() -> T {} } let b = X;\nb.iter(|| {\n let n = test::black_box(1000);\n\n (0..n).fold(0, |a, b| a ^ b)\n})\n# }\n```\n\nNeither of these read or modify the value, and are very cheap for small values.\nLarger values can be passed indirectly to reduce overhead (e.g.\n`black_box(&huge_struct)`).\n\nPerforming either of the above changes gives the following benchmarking results\n\n```text\nrunning 1 test\ntest bench_xor_1000_ints ... bench: 131 ns/iter (+/- 3)\n\ntest result: ok. 0 passed; 0 failed; 0 ignored; 1 measured\n```\n\nHowever, the optimizer can still modify a testcase in an undesirable manner\neven when using either of the above.\n" } , LintCompletion { label : "windows_stdio" , description : "# `windows_stdio`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "allocator_api" , description : "# `allocator_api`\n\nThe tracking issue for this feature is [#32838]\n\n[#32838]: https://github.com/rust-lang/rust/issues/32838\n\n------------------------\n\nSometimes you want the memory for one collection to use a different\nallocator than the memory for another collection. In this case,\nreplacing the global allocator is not a workable option. Instead,\nyou need to pass in an instance of an `AllocRef` to each collection\nfor which you want a custom allocator.\n\nTBD\n" } , LintCompletion { label : "asm" , description : "# `asm`\n\nThe tracking issue for this feature is: [#72016]\n\n[#72016]: https://github.com/rust-lang/rust/issues/72016\n\n------------------------\n\nFor extremely low-level manipulations and performance reasons, one\nmight wish to control the CPU directly. Rust supports using inline\nassembly to do this via the `asm!` macro.\n\n# Guide-level explanation\n[guide-level-explanation]: #guide-level-explanation\n\nRust provides support for inline assembly via the `asm!` macro.\nIt can be used to embed handwritten assembly in the assembly output generated by the compiler.\nGenerally this should not be necessary, but might be where the required performance or timing\ncannot be otherwise achieved. Accessing low level hardware primitives, e.g. in kernel code, may also demand this functionality.\n\n> **Note**: the examples here are given in x86/x86-64 assembly, but ARM, AArch64 and RISC-V are also supported.\n\n## Basic usage\n\nLet us start with the simplest possible example:\n\n```rust,allow_fail\n# #![feature(asm)]\nunsafe {\n asm!(\"nop\");\n}\n```\n\nThis will insert a NOP (no operation) instruction into the assembly generated by the compiler.\nNote that all `asm!` invocations have to be inside an `unsafe` block, as they could insert\narbitrary instructions and break various invariants. The instructions to be inserted are listed\nin the first argument of the `asm!` macro as a string literal.\n\n## Inputs and outputs\n\nNow inserting an instruction that does nothing is rather boring. Let us do something that\nactually acts on data:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet x: u64;\nunsafe {\n asm!(\"mov {}, 5\", out(reg) x);\n}\nassert_eq!(x, 5);\n```\n\nThis will write the value `5` into the `u64` variable `x`.\nYou can see that the string literal we use to specify instructions is actually a template string.\nIt is governed by the same rules as Rust [format strings][format-syntax].\nThe arguments that are inserted into the template however look a bit different then you may\nbe familiar with. First we need to specify if the variable is an input or an output of the\ninline assembly. In this case it is an output. We declared this by writing `out`.\nWe also need to specify in what kind of register the assembly expects the variable.\nIn this case we put it in an arbitrary general purpose register by specifying `reg`.\nThe compiler will choose an appropriate register to insert into\nthe template and will read the variable from there after the inline assembly finishes executing.\n\nLet us see another example that also uses an input:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet i: u64 = 3;\nlet o: u64;\nunsafe {\n asm!(\n \"mov {0}, {1}\",\n \"add {0}, {number}\",\n out(reg) o,\n in(reg) i,\n number = const 5,\n );\n}\nassert_eq!(o, 8);\n```\n\nThis will add `5` to the input in variable `i` and write the result to variable `o`.\nThe particular way this assembly does this is first copying the value from `i` to the output,\nand then adding `5` to it.\n\nThe example shows a few things:\n\nFirst, we can see that `asm!` allows multiple template string arguments; each\none is treated as a separate line of assembly code, as if they were all joined\ntogether with newlines between them. This makes it easy to format assembly\ncode.\n\nSecond, we can see that inputs are declared by writing `in` instead of `out`.\n\nThird, one of our operands has a type we haven't seen yet, `const`.\nThis tells the compiler to expand this argument to value directly inside the assembly template.\nThis is only possible for constants and literals.\n\nFourth, we can see that we can specify an argument number, or name as in any format string.\nFor inline assembly templates this is particularly useful as arguments are often used more than once.\nFor more complex inline assembly using this facility is generally recommended, as it improves\nreadability, and allows reordering instructions without changing the argument order.\n\nWe can further refine the above example to avoid the `mov` instruction:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet mut x: u64 = 3;\nunsafe {\n asm!(\"add {0}, {number}\", inout(reg) x, number = const 5);\n}\nassert_eq!(x, 8);\n```\n\nWe can see that `inout` is used to specify an argument that is both input and output.\nThis is different from specifying an input and output separately in that it is guaranteed to assign both to the same register.\n\nIt is also possible to specify different variables for the input and output parts of an `inout` operand:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet x: u64 = 3;\nlet y: u64;\nunsafe {\n asm!(\"add {0}, {number}\", inout(reg) x => y, number = const 5);\n}\nassert_eq!(y, 8);\n```\n\n## Late output operands\n\nThe Rust compiler is conservative with its allocation of operands. It is assumed that an `out`\ncan be written at any time, and can therefore not share its location with any other argument.\nHowever, to guarantee optimal performance it is important to use as few registers as possible,\nso they won't have to be saved and reloaded around the inline assembly block.\nTo achieve this Rust provides a `lateout` specifier. This can be used on any output that is\nwritten only after all inputs have been consumed.\nThere is also a `inlateout` variant of this specifier.\n\nHere is an example where `inlateout` *cannot* be used:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet mut a: u64 = 4;\nlet b: u64 = 4;\nlet c: u64 = 4;\nunsafe {\n asm!(\n \"add {0}, {1}\",\n \"add {0}, {2}\",\n inout(reg) a,\n in(reg) b,\n in(reg) c,\n );\n}\nassert_eq!(a, 12);\n```\n\nHere the compiler is free to allocate the same register for inputs `b` and `c` since it knows they have the same value. However it must allocate a separate register for `a` since it uses `inout` and not `inlateout`. If `inlateout` was used, then `a` and `c` could be allocated to the same register, in which case the first instruction to overwrite the value of `c` and cause the assembly code to produce the wrong result.\n\nHowever the following example can use `inlateout` since the output is only modified after all input registers have been read:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet mut a: u64 = 4;\nlet b: u64 = 4;\nunsafe {\n asm!(\"add {0}, {1}\", inlateout(reg) a, in(reg) b);\n}\nassert_eq!(a, 8);\n```\n\nAs you can see, this assembly fragment will still work correctly if `a` and `b` are assigned to the same register.\n\n## Explicit register operands\n\nSome instructions require that the operands be in a specific register.\nTherefore, Rust inline assembly provides some more specific constraint specifiers.\nWhile `reg` is generally available on any architecture, these are highly architecture specific. E.g. for x86 the general purpose registers `eax`, `ebx`, `ecx`, `edx`, `ebp`, `esi`, and `edi`\namong others can be addressed by their name.\n\n```rust,allow_fail,no_run\n# #![feature(asm)]\nlet cmd = 0xd1;\nunsafe {\n asm!(\"out 0x64, eax\", in(\"eax\") cmd);\n}\n```\n\nIn this example we call the `out` instruction to output the content of the `cmd` variable\nto port `0x64`. Since the `out` instruction only accepts `eax` (and its sub registers) as operand\nwe had to use the `eax` constraint specifier.\n\nNote that unlike other operand types, explicit register operands cannot be used in the template string: you can't use `{}` and should write the register name directly instead. Also, they must appear at the end of the operand list after all other operand types.\n\nConsider this example which uses the x86 `mul` instruction:\n\n```rust,allow_fail\n# #![feature(asm)]\nfn mul(a: u64, b: u64) -> u128 {\n let lo: u64;\n let hi: u64;\n\n unsafe {\n asm!(\n // The x86 mul instruction takes rax as an implicit input and writes\n // the 128-bit result of the multiplication to rax:rdx.\n \"mul {}\",\n in(reg) a,\n inlateout(\"rax\") b => lo,\n lateout(\"rdx\") hi\n );\n }\n\n ((hi as u128) << 64) + lo as u128\n}\n```\n\nThis uses the `mul` instruction to multiply two 64-bit inputs with a 128-bit result.\nThe only explicit operand is a register, that we fill from the variable `a`.\nThe second operand is implicit, and must be the `rax` register, which we fill from the variable `b`.\nThe lower 64 bits of the result are stored in `rax` from which we fill the variable `lo`.\nThe higher 64 bits are stored in `rdx` from which we fill the variable `hi`.\n\n## Clobbered registers\n\nIn many cases inline assembly will modify state that is not needed as an output.\nUsually this is either because we have to use a scratch register in the assembly,\nor instructions modify state that we don't need to further examine.\nThis state is generally referred to as being \"clobbered\".\nWe need to tell the compiler about this since it may need to save and restore this state\naround the inline assembly block.\n\n```rust,allow_fail\n# #![feature(asm)]\nlet ebx: u32;\nlet ecx: u32;\n\nunsafe {\n asm!(\n \"cpuid\",\n // EAX 4 selects the \"Deterministic Cache Parameters\" CPUID leaf\n inout(\"eax\") 4 => _,\n // ECX 0 selects the L0 cache information.\n inout(\"ecx\") 0 => ecx,\n lateout(\"ebx\") ebx,\n lateout(\"edx\") _,\n );\n}\n\nprintln!(\n \"L1 Cache: {}\",\n ((ebx >> 22) + 1) * (((ebx >> 12) & 0x3ff) + 1) * ((ebx & 0xfff) + 1) * (ecx + 1)\n);\n```\n\nIn the example above we use the `cpuid` instruction to get the L1 cache size.\nThis instruction writes to `eax`, `ebx`, `ecx`, and `edx`, but for the cache size we only care about the contents of `ebx` and `ecx`.\n\nHowever we still need to tell the compiler that `eax` and `edx` have been modified so that it can save any values that were in these registers before the asm. This is done by declaring these as outputs but with `_` instead of a variable name, which indicates that the output value is to be discarded.\n\nThis can also be used with a general register class (e.g. `reg`) to obtain a scratch register for use inside the asm code:\n\n```rust,allow_fail\n# #![feature(asm)]\n// Multiply x by 6 using shifts and adds\nlet mut x: u64 = 4;\nunsafe {\n asm!(\n \"mov {tmp}, {x}\",\n \"shl {tmp}, 1\",\n \"shl {x}, 2\",\n \"add {x}, {tmp}\",\n x = inout(reg) x,\n tmp = out(reg) _,\n );\n}\nassert_eq!(x, 4 * 6);\n```\n\n## Symbol operands\n\nA special operand type, `sym`, allows you to use the symbol name of a `fn` or `static` in inline assembly code.\nThis allows you to call a function or access a global variable without needing to keep its address in a register.\n\n```rust,allow_fail\n# #![feature(asm)]\nextern \"C\" fn foo(arg: i32) {\n println!(\"arg = {}\", arg);\n}\n\nfn call_foo(arg: i32) {\n unsafe {\n asm!(\n \"call {}\",\n sym foo,\n // 1st argument in rdi, which is caller-saved\n inout(\"rdi\") arg => _,\n // All caller-saved registers must be marked as clobberred\n out(\"rax\") _, out(\"rcx\") _, out(\"rdx\") _, out(\"rsi\") _,\n out(\"r8\") _, out(\"r9\") _, out(\"r10\") _, out(\"r11\") _,\n out(\"xmm0\") _, out(\"xmm1\") _, out(\"xmm2\") _, out(\"xmm3\") _,\n out(\"xmm4\") _, out(\"xmm5\") _, out(\"xmm6\") _, out(\"xmm7\") _,\n out(\"xmm8\") _, out(\"xmm9\") _, out(\"xmm10\") _, out(\"xmm11\") _,\n out(\"xmm12\") _, out(\"xmm13\") _, out(\"xmm14\") _, out(\"xmm15\") _,\n )\n }\n}\n```\n\nNote that the `fn` or `static` item does not need to be public or `#[no_mangle]`:\nthe compiler will automatically insert the appropriate mangled symbol name into the assembly code.\n\n## Register template modifiers\n\nIn some cases, fine control is needed over the way a register name is formatted when inserted into the template string. This is needed when an architecture's assembly language has several names for the same register, each typically being a \"view\" over a subset of the register (e.g. the low 32 bits of a 64-bit register).\n\nBy default the compiler will always choose the name that refers to the full register size (e.g. `rax` on x86-64, `eax` on x86, etc).\n\nThis default can be overriden by using modifiers on the template string operands, just like you would with format strings:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet mut x: u16 = 0xab;\n\nunsafe {\n asm!(\"mov {0:h}, {0:l}\", inout(reg_abcd) x);\n}\n\nassert_eq!(x, 0xabab);\n```\n\nIn this example, we use the `reg_abcd` register class to restrict the register allocator to the 4 legacy x86 register (`ax`, `bx`, `cx`, `dx`) of which the first two bytes can be addressed independently.\n\nLet us assume that the register allocator has chosen to allocate `x` in the `ax` register.\nThe `h` modifier will emit the register name for the high byte of that register and the `l` modifier will emit the register name for the low byte. The asm code will therefore be expanded as `mov ah, al` which copies the low byte of the value into the high byte.\n\nIf you use a smaller data type (e.g. `u16`) with an operand and forget the use template modifiers, the compiler will emit a warning and suggest the correct modifier to use.\n\n## Options\n\nBy default, an inline assembly block is treated the same way as an external FFI function call with a custom calling convention: it may read/write memory, have observable side effects, etc. However in many cases, it is desirable to give the compiler more information about what the assembly code is actually doing so that it can optimize better.\n\nLet's take our previous example of an `add` instruction:\n\n```rust,allow_fail\n# #![feature(asm)]\nlet mut a: u64 = 4;\nlet b: u64 = 4;\nunsafe {\n asm!(\n \"add {0}, {1}\",\n inlateout(reg) a, in(reg) b,\n options(pure, nomem, nostack),\n );\n}\nassert_eq!(a, 8);\n```\n\nOptions can be provided as an optional final argument to the `asm!` macro. We specified three options here:\n- `pure` means that the asm code has no observable side effects and that its output depends only on its inputs. This allows the compiler optimizer to call the inline asm fewer times or even eliminate it entirely.\n- `nomem` means that the asm code does not read or write to memory. By default the compiler will assume that inline assembly can read or write any memory address that is accessible to it (e.g. through a pointer passed as an operand, or a global).\n- `nostack` means that the asm code does not push any data onto the stack. This allows the compiler to use optimizations such as the stack red zone on x86-64 to avoid stack pointer adjustments.\n\nThese allow the compiler to better optimize code using `asm!`, for example by eliminating pure `asm!` blocks whose outputs are not needed.\n\nSee the reference for the full list of available options and their effects.\n\n# Reference-level explanation\n[reference-level-explanation]: #reference-level-explanation\n\nInline assembler is implemented as an unsafe macro `asm!()`.\nThe first argument to this macro is a template string literal used to build the final assembly.\nThe following arguments specify input and output operands.\nWhen required, options are specified as the final argument.\n\nThe following ABNF specifies the general syntax:\n\n```ignore\ndir_spec := \"in\" / \"out\" / \"lateout\" / \"inout\" / \"inlateout\"\nreg_spec := <register class> / \"<explicit register>\"\noperand_expr := expr / \"_\" / expr \"=>\" expr / expr \"=>\" \"_\"\nreg_operand := dir_spec \"(\" reg_spec \")\" operand_expr\noperand := reg_operand / \"const\" const_expr / \"sym\" path\noption := \"pure\" / \"nomem\" / \"readonly\" / \"preserves_flags\" / \"noreturn\" / \"att_syntax\"\noptions := \"options(\" option *[\",\" option] [\",\"] \")\"\nasm := \"asm!(\" format_string *(\",\" format_string) *(\",\" [ident \"=\"] operand) [\",\" options] [\",\"] \")\"\n```\n\nThe macro will initially be supported only on ARM, AArch64, Hexagon, x86, x86-64 and RISC-V targets. Support for more targets may be added in the future. The compiler will emit an error if `asm!` is used on an unsupported target.\n\n[format-syntax]: https://doc.rust-lang.org/std/fmt/#syntax\n\n## Template string arguments\n\nThe assembler template uses the same syntax as [format strings][format-syntax] (i.e. placeholders are specified by curly braces). The corresponding arguments are accessed in order, by index, or by name. However, implicit named arguments (introduced by [RFC #2795][rfc-2795]) are not supported.\n\nAn `asm!` invocation may have one or more template string arguments; an `asm!` with multiple template string arguments is treated as if all the strings were concatenated with a `\\n` between them. The expected usage is for each template string argument to correspond to a line of assembly code. All template string arguments must appear before any other arguments.\n\nAs with format strings, named arguments must appear after positional arguments. Explicit register operands must appear at the end of the operand list, after named arguments if any.\n\nExplicit register operands cannot be used by placeholders in the template string. All other named and positional operands must appear at least once in the template string, otherwise a compiler error is generated.\n\nThe exact assembly code syntax is target-specific and opaque to the compiler except for the way operands are substituted into the template string to form the code passed to the assembler.\n\nThe 5 targets specified in this RFC (x86, ARM, AArch64, RISC-V, Hexagon) all use the assembly code syntax of the GNU assembler (GAS). On x86, the `.intel_syntax noprefix` mode of GAS is used by default. On ARM, the `.syntax unified` mode is used. These targets impose an additional restriction on the assembly code: any assembler state (e.g. the current section which can be changed with `.section`) must be restored to its original value at the end of the asm string. Assembly code that does not conform to the GAS syntax will result in assembler-specific behavior.\n\n[rfc-2795]: https://github.com/rust-lang/rfcs/pull/2795\n\n## Operand type\n\nSeveral types of operands are supported:\n\n* `in(<reg>) <expr>`\n - `<reg>` can refer to a register class or an explicit register. The allocated register name is substituted into the asm template string.\n - The allocated register will contain the value of `<expr>` at the start of the asm code.\n - The allocated register must contain the same value at the end of the asm code (except if a `lateout` is allocated to the same register).\n* `out(<reg>) <expr>`\n - `<reg>` can refer to a register class or an explicit register. The allocated register name is substituted into the asm template string.\n - The allocated register will contain an undefined value at the start of the asm code.\n - `<expr>` must be a (possibly uninitialized) place expression, to which the contents of the allocated register is written to at the end of the asm code.\n - An underscore (`_`) may be specified instead of an expression, which will cause the contents of the register to be discarded at the end of the asm code (effectively acting as a clobber).\n* `lateout(<reg>) <expr>`\n - Identical to `out` except that the register allocator can reuse a register allocated to an `in`.\n - You should only write to the register after all inputs are read, otherwise you may clobber an input.\n* `inout(<reg>) <expr>`\n - `<reg>` can refer to a register class or an explicit register. The allocated register name is substituted into the asm template string.\n - The allocated register will contain the value of `<expr>` at the start of the asm code.\n - `<expr>` must be a mutable initialized place expression, to which the contents of the allocated register is written to at the end of the asm code.\n* `inout(<reg>) <in expr> => <out expr>`\n - Same as `inout` except that the initial value of the register is taken from the value of `<in expr>`.\n - `<out expr>` must be a (possibly uninitialized) place expression, to which the contents of the allocated register is written to at the end of the asm code.\n - An underscore (`_`) may be specified instead of an expression for `<out expr>`, which will cause the contents of the register to be discarded at the end of the asm code (effectively acting as a clobber).\n - `<in expr>` and `<out expr>` may have different types.\n* `inlateout(<reg>) <expr>` / `inlateout(<reg>) <in expr> => <out expr>`\n - Identical to `inout` except that the register allocator can reuse a register allocated to an `in` (this can happen if the compiler knows the `in` has the same initial value as the `inlateout`).\n - You should only write to the register after all inputs are read, otherwise you may clobber an input.\n* `const <expr>`\n - `<expr>` must be an integer or floating-point constant expression.\n - The value of the expression is formatted as a string and substituted directly into the asm template string.\n* `sym <path>`\n - `<path>` must refer to a `fn` or `static`.\n - A mangled symbol name referring to the item is substituted into the asm template string.\n - The substituted string does not include any modifiers (e.g. GOT, PLT, relocations, etc).\n - `<path>` is allowed to point to a `#[thread_local]` static, in which case the asm code can combine the symbol with relocations (e.g. `@plt`, `@TPOFF`) to read from thread-local data.\n\nOperand expressions are evaluated from left to right, just like function call arguments. After the `asm!` has executed, outputs are written to in left to right order. This is significant if two outputs point to the same place: that place will contain the value of the rightmost output.\n\n## Register operands\n\nInput and output operands can be specified either as an explicit register or as a register class from which the register allocator can select a register. Explicit registers are specified as string literals (e.g. `\"eax\"`) while register classes are specified as identifiers (e.g. `reg`). Using string literals for register names enables support for architectures that use special characters in register names, such as MIPS (`$0`, `$1`, etc).\n\nNote that explicit registers treat register aliases (e.g. `r14` vs `lr` on ARM) and smaller views of a register (e.g. `eax` vs `rax`) as equivalent to the base register. It is a compile-time error to use the same explicit register for two input operands or two output operands. Additionally, it is also a compile-time error to use overlapping registers (e.g. ARM VFP) in input operands or in output operands.\n\nOnly the following types are allowed as operands for inline assembly:\n- Integers (signed and unsigned)\n- Floating-point numbers\n- Pointers (thin only)\n- Function pointers\n- SIMD vectors (structs defined with `#[repr(simd)]` and which implement `Copy`). This includes architecture-specific vector types defined in `std::arch` such as `__m128` (x86) or `int8x16_t` (ARM).\n\nHere is the list of currently supported register classes:\n\n| Architecture | Register class | Registers | LLVM constraint code |\n| ------------ | -------------- | --------- | -------------------- |\n| x86 | `reg` | `ax`, `bx`, `cx`, `dx`, `si`, `di`, `r[8-15]` (x86-64 only) | `r` |\n| x86 | `reg_abcd` | `ax`, `bx`, `cx`, `dx` | `Q` |\n| x86-32 | `reg_byte` | `al`, `bl`, `cl`, `dl`, `ah`, `bh`, `ch`, `dh` | `q` |\n| x86-64 | `reg_byte` | `al`, `bl`, `cl`, `dl`, `sil`, `dil`, `r[8-15]b`, `ah`\\*, `bh`\\*, `ch`\\*, `dh`\\* | `q` |\n| x86 | `xmm_reg` | `xmm[0-7]` (x86) `xmm[0-15]` (x86-64) | `x` |\n| x86 | `ymm_reg` | `ymm[0-7]` (x86) `ymm[0-15]` (x86-64) | `x` |\n| x86 | `zmm_reg` | `zmm[0-7]` (x86) `zmm[0-31]` (x86-64) | `v` |\n| x86 | `kreg` | `k[1-7]` | `Yk` |\n| AArch64 | `reg` | `x[0-28]`, `x30` | `r` |\n| AArch64 | `vreg` | `v[0-31]` | `w` |\n| AArch64 | `vreg_low16` | `v[0-15]` | `x` |\n| ARM | `reg` | `r[0-5]` `r7`\\*, `r[8-10]`, `r11`\\*, `r12`, `r14` | `r` |\n| ARM (Thumb) | `reg_thumb` | `r[0-r7]` | `l` |\n| ARM (ARM) | `reg_thumb` | `r[0-r10]`, `r12`, `r14` | `l` |\n| ARM | `sreg` | `s[0-31]` | `t` |\n| ARM | `sreg_low16` | `s[0-15]` | `x` |\n| ARM | `dreg` | `d[0-31]` | `w` |\n| ARM | `dreg_low16` | `d[0-15]` | `t` |\n| ARM | `dreg_low8` | `d[0-8]` | `x` |\n| ARM | `qreg` | `q[0-15]` | `w` |\n| ARM | `qreg_low8` | `q[0-7]` | `t` |\n| ARM | `qreg_low4` | `q[0-3]` | `x` |\n| NVPTX | `reg16` | None\\* | `h` |\n| NVPTX | `reg32` | None\\* | `r` |\n| NVPTX | `reg64` | None\\* | `l` |\n| RISC-V | `reg` | `x1`, `x[5-7]`, `x[9-15]`, `x[16-31]` (non-RV32E) | `r` |\n| RISC-V | `freg` | `f[0-31]` | `f` |\n| Hexagon | `reg` | `r[0-28]` | `r` |\n\n> **Note**: On x86 we treat `reg_byte` differently from `reg` because the compiler can allocate `al` and `ah` separately whereas `reg` reserves the whole register.\n>\n> Note #2: On x86-64 the high byte registers (e.g. `ah`) are only available when used as an explicit register. Specifying the `reg_byte` register class for an operand will always allocate a low byte register.\n>\n> Note #3: NVPTX doesn't have a fixed register set, so named registers are not supported.\n>\n> Note #4: On ARM the frame pointer is either `r7` or `r11` depending on the platform.\n\nAdditional register classes may be added in the future based on demand (e.g. MMX, x87, etc).\n\nEach register class has constraints on which value types they can be used with. This is necessary because the way a value is loaded into a register depends on its type. For example, on big-endian systems, loading a `i32x4` and a `i8x16` into a SIMD register may result in different register contents even if the byte-wise memory representation of both values is identical. The availability of supported types for a particular register class may depend on what target features are currently enabled.\n\n| Architecture | Register class | Target feature | Allowed types |\n| ------------ | -------------- | -------------- | ------------- |\n| x86-32 | `reg` | None | `i16`, `i32`, `f32` |\n| x86-64 | `reg` | None | `i16`, `i32`, `f32`, `i64`, `f64` |\n| x86 | `reg_byte` | None | `i8` |\n| x86 | `xmm_reg` | `sse` | `i32`, `f32`, `i64`, `f64`, <br> `i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2` |\n| x86 | `ymm_reg` | `avx` | `i32`, `f32`, `i64`, `f64`, <br> `i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2` <br> `i8x32`, `i16x16`, `i32x8`, `i64x4`, `f32x8`, `f64x4` |\n| x86 | `zmm_reg` | `avx512f` | `i32`, `f32`, `i64`, `f64`, <br> `i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2` <br> `i8x32`, `i16x16`, `i32x8`, `i64x4`, `f32x8`, `f64x4` <br> `i8x64`, `i16x32`, `i32x16`, `i64x8`, `f32x16`, `f64x8` |\n| x86 | `kreg` | `axv512f` | `i8`, `i16` |\n| x86 | `kreg` | `axv512bw` | `i32`, `i64` |\n| AArch64 | `reg` | None | `i8`, `i16`, `i32`, `f32`, `i64`, `f64` |\n| AArch64 | `vreg` | `fp` | `i8`, `i16`, `i32`, `f32`, `i64`, `f64`, <br> `i8x8`, `i16x4`, `i32x2`, `i64x1`, `f32x2`, `f64x1`, <br> `i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2` |\n| ARM | `reg` | None | `i8`, `i16`, `i32`, `f32` |\n| ARM | `sreg` | `vfp2` | `i32`, `f32` |\n| ARM | `dreg` | `vfp2` | `i64`, `f64`, `i8x8`, `i16x4`, `i32x2`, `i64x1`, `f32x2` |\n| ARM | `qreg` | `neon` | `i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4` |\n| NVPTX | `reg16` | None | `i8`, `i16` |\n| NVPTX | `reg32` | None | `i8`, `i16`, `i32`, `f32` |\n| NVPTX | `reg64` | None | `i8`, `i16`, `i32`, `f32`, `i64`, `f64` |\n| RISC-V32 | `reg` | None | `i8`, `i16`, `i32`, `f32` |\n| RISC-V64 | `reg` | None | `i8`, `i16`, `i32`, `f32`, `i64`, `f64` |\n| RISC-V | `freg` | `f` | `f32` |\n| RISC-V | `freg` | `d` | `f64` |\n| Hexagon | `reg` | None | `i8`, `i16`, `i32`, `f32` |\n\n> **Note**: For the purposes of the above table pointers, function pointers and `isize`/`usize` are treated as the equivalent integer type (`i16`/`i32`/`i64` depending on the target).\n\nIf a value is of a smaller size than the register it is allocated in then the upper bits of that register will have an undefined value for inputs and will be ignored for outputs. The only exception is the `freg` register class on RISC-V where `f32` values are NaN-boxed in a `f64` as required by the RISC-V architecture.\n\nWhen separate input and output expressions are specified for an `inout` operand, both expressions must have the same type. The only exception is if both operands are pointers or integers, in which case they are only required to have the same size. This restriction exists because the register allocators in LLVM and GCC sometimes cannot handle tied operands with different types.\n\n## Register names\n\nSome registers have multiple names. These are all treated by the compiler as identical to the base register name. Here is the list of all supported register aliases:\n\n| Architecture | Base register | Aliases |\n| ------------ | ------------- | ------- |\n| x86 | `ax` | `eax`, `rax` |\n| x86 | `bx` | `ebx`, `rbx` |\n| x86 | `cx` | `ecx`, `rcx` |\n| x86 | `dx` | `edx`, `rdx` |\n| x86 | `si` | `esi`, `rsi` |\n| x86 | `di` | `edi`, `rdi` |\n| x86 | `bp` | `bpl`, `ebp`, `rbp` |\n| x86 | `sp` | `spl`, `esp`, `rsp` |\n| x86 | `ip` | `eip`, `rip` |\n| x86 | `st(0)` | `st` |\n| x86 | `r[8-15]` | `r[8-15]b`, `r[8-15]w`, `r[8-15]d` |\n| x86 | `xmm[0-31]` | `ymm[0-31]`, `zmm[0-31]` |\n| AArch64 | `x[0-30]` | `w[0-30]` |\n| AArch64 | `x29` | `fp` |\n| AArch64 | `x30` | `lr` |\n| AArch64 | `sp` | `wsp` |\n| AArch64 | `xzr` | `wzr` |\n| AArch64 | `v[0-31]` | `b[0-31]`, `h[0-31]`, `s[0-31]`, `d[0-31]`, `q[0-31]` |\n| ARM | `r[0-3]` | `a[1-4]` |\n| ARM | `r[4-9]` | `v[1-6]` |\n| ARM | `r9` | `rfp` |\n| ARM | `r10` | `sl` |\n| ARM | `r11` | `fp` |\n| ARM | `r12` | `ip` |\n| ARM | `r13` | `sp` |\n| ARM | `r14` | `lr` |\n| ARM | `r15` | `pc` |\n| RISC-V | `x0` | `zero` |\n| RISC-V | `x1` | `ra` |\n| RISC-V | `x2` | `sp` |\n| RISC-V | `x3` | `gp` |\n| RISC-V | `x4` | `tp` |\n| RISC-V | `x[5-7]` | `t[0-2]` |\n| RISC-V | `x8` | `fp`, `s0` |\n| RISC-V | `x9` | `s1` |\n| RISC-V | `x[10-17]` | `a[0-7]` |\n| RISC-V | `x[18-27]` | `s[2-11]` |\n| RISC-V | `x[28-31]` | `t[3-6]` |\n| RISC-V | `f[0-7]` | `ft[0-7]` |\n| RISC-V | `f[8-9]` | `fs[0-1]` |\n| RISC-V | `f[10-17]` | `fa[0-7]` |\n| RISC-V | `f[18-27]` | `fs[2-11]` |\n| RISC-V | `f[28-31]` | `ft[8-11]` |\n| Hexagon | `r29` | `sp` |\n| Hexagon | `r30` | `fr` |\n| Hexagon | `r31` | `lr` |\n\nSome registers cannot be used for input or output operands:\n\n| Architecture | Unsupported register | Reason |\n| ------------ | -------------------- | ------ |\n| All | `sp` | The stack pointer must be restored to its original value at the end of an asm code block. |\n| All | `bp` (x86), `x29` (AArch64), `x8` (RISC-V), `fr` (Hexagon) | The frame pointer cannot be used as an input or output. |\n| ARM | `r7` or `r11` | On ARM the frame pointer can be either `r7` or `r11` depending on the target. The frame pointer cannot be used as an input or output. |\n| ARM | `r6` | `r6` is used internally by LLVM as a base pointer and therefore cannot be used as an input or output. |\n| x86 | `k0` | This is a constant zero register which can't be modified. |\n| x86 | `ip` | This is the program counter, not a real register. |\n| x86 | `mm[0-7]` | MMX registers are not currently supported (but may be in the future). |\n| x86 | `st([0-7])` | x87 registers are not currently supported (but may be in the future). |\n| AArch64 | `xzr` | This is a constant zero register which can't be modified. |\n| ARM | `pc` | This is the program counter, not a real register. |\n| RISC-V | `x0` | This is a constant zero register which can't be modified. |\n| RISC-V | `gp`, `tp` | These registers are reserved and cannot be used as inputs or outputs. |\n| Hexagon | `lr` | This is the link register which cannot be used as an input or output. |\n\n## Template modifiers\n\nThe placeholders can be augmented by modifiers which are specified after the `:` in the curly braces. These modifiers do not affect register allocation, but change the way operands are formatted when inserted into the template string. Only one modifier is allowed per template placeholder.\n\nThe supported modifiers are a subset of LLVM's (and GCC's) [asm template argument modifiers][llvm-argmod], but do not use the same letter codes.\n\n| Architecture | Register class | Modifier | Example output | LLVM modifier |\n| ------------ | -------------- | -------- | -------------- | ------------- |\n| x86-32 | `reg` | None | `eax` | `k` |\n| x86-64 | `reg` | None | `rax` | `q` |\n| x86-32 | `reg_abcd` | `l` | `al` | `b` |\n| x86-64 | `reg` | `l` | `al` | `b` |\n| x86 | `reg_abcd` | `h` | `ah` | `h` |\n| x86 | `reg` | `x` | `ax` | `w` |\n| x86 | `reg` | `e` | `eax` | `k` |\n| x86-64 | `reg` | `r` | `rax` | `q` |\n| x86 | `reg_byte` | None | `al` / `ah` | None |\n| x86 | `xmm_reg` | None | `xmm0` | `x` |\n| x86 | `ymm_reg` | None | `ymm0` | `t` |\n| x86 | `zmm_reg` | None | `zmm0` | `g` |\n| x86 | `*mm_reg` | `x` | `xmm0` | `x` |\n| x86 | `*mm_reg` | `y` | `ymm0` | `t` |\n| x86 | `*mm_reg` | `z` | `zmm0` | `g` |\n| x86 | `kreg` | None | `k1` | None |\n| AArch64 | `reg` | None | `x0` | `x` |\n| AArch64 | `reg` | `w` | `w0` | `w` |\n| AArch64 | `reg` | `x` | `x0` | `x` |\n| AArch64 | `vreg` | None | `v0` | None |\n| AArch64 | `vreg` | `v` | `v0` | None |\n| AArch64 | `vreg` | `b` | `b0` | `b` |\n| AArch64 | `vreg` | `h` | `h0` | `h` |\n| AArch64 | `vreg` | `s` | `s0` | `s` |\n| AArch64 | `vreg` | `d` | `d0` | `d` |\n| AArch64 | `vreg` | `q` | `q0` | `q` |\n| ARM | `reg` | None | `r0` | None |\n| ARM | `sreg` | None | `s0` | None |\n| ARM | `dreg` | None | `d0` | `P` |\n| ARM | `qreg` | None | `q0` | `q` |\n| ARM | `qreg` | `e` / `f` | `d0` / `d1` | `e` / `f` |\n| NVPTX | `reg16` | None | `rs0` | None |\n| NVPTX | `reg32` | None | `r0` | None |\n| NVPTX | `reg64` | None | `rd0` | None |\n| RISC-V | `reg` | None | `x1` | None |\n| RISC-V | `freg` | None | `f0` | None |\n| Hexagon | `reg` | None | `r0` | None |\n\n> Notes:\n> - on ARM `e` / `f`: this prints the low or high doubleword register name of a NEON quad (128-bit) register.\n> - on x86: our behavior for `reg` with no modifiers differs from what GCC does. GCC will infer the modifier based on the operand value type, while we default to the full register size.\n> - on x86 `xmm_reg`: the `x`, `t` and `g` LLVM modifiers are not yet implemented in LLVM (they are supported by GCC only), but this should be a simple change.\n\nAs stated in the previous section, passing an input value smaller than the register width will result in the upper bits of the register containing undefined values. This is not a problem if the inline asm only accesses the lower bits of the register, which can be done by using a template modifier to use a subregister name in the asm code (e.g. `ax` instead of `rax`). Since this an easy pitfall, the compiler will suggest a template modifier to use where appropriate given the input type. If all references to an operand already have modifiers then the warning is suppressed for that operand.\n\n[llvm-argmod]: http://llvm.org/docs/LangRef.html#asm-template-argument-modifiers\n\n## Options\n\nFlags are used to further influence the behavior of the inline assembly block.\nCurrently the following options are defined:\n- `pure`: The `asm` block has no side effects, and its outputs depend only on its direct inputs (i.e. the values themselves, not what they point to) or values read from memory (unless the `nomem` options is also set). This allows the compiler to execute the `asm` block fewer times than specified in the program (e.g. by hoisting it out of a loop) or even eliminate it entirely if the outputs are not used.\n- `nomem`: The `asm` blocks does not read or write to any memory. This allows the compiler to cache the values of modified global variables in registers across the `asm` block since it knows that they are not read or written to by the `asm`.\n- `readonly`: The `asm` block does not write to any memory. This allows the compiler to cache the values of unmodified global variables in registers across the `asm` block since it knows that they are not written to by the `asm`.\n- `preserves_flags`: The `asm` block does not modify the flags register (defined in the rules below). This allows the compiler to avoid recomputing the condition flags after the `asm` block.\n- `noreturn`: The `asm` block never returns, and its return type is defined as `!` (never). Behavior is undefined if execution falls through past the end of the asm code. A `noreturn` asm block behaves just like a function which doesn't return; notably, local variables in scope are not dropped before it is invoked.\n- `nostack`: The `asm` block does not push data to the stack, or write to the stack red-zone (if supported by the target). If this option is *not* used then the stack pointer is guaranteed to be suitably aligned (according to the target ABI) for a function call.\n- `att_syntax`: This option is only valid on x86, and causes the assembler to use the `.att_syntax prefix` mode of the GNU assembler. Register operands are substituted in with a leading `%`.\n\nThe compiler performs some additional checks on options:\n- The `nomem` and `readonly` options are mutually exclusive: it is a compile-time error to specify both.\n- The `pure` option must be combined with either the `nomem` or `readonly` options, otherwise a compile-time error is emitted.\n- It is a compile-time error to specify `pure` on an asm block with no outputs or only discarded outputs (`_`).\n- It is a compile-time error to specify `noreturn` on an asm block with outputs.\n\n## Rules for inline assembly\n\n- Any registers not specified as inputs will contain an undefined value on entry to the asm block.\n - An \"undefined value\" in the context of inline assembly means that the register can (non-deterministically) have any one of the possible values allowed by the architecture. Notably it is not the same as an LLVM `undef` which can have a different value every time you read it (since such a concept does not exist in assembly code).\n- Any registers not specified as outputs must have the same value upon exiting the asm block as they had on entry, otherwise behavior is undefined.\n - This only applies to registers which can be specified as an input or output. Other registers follow target-specific rules.\n - Note that a `lateout` may be allocated to the same register as an `in`, in which case this rule does not apply. Code should not rely on this however since it depends on the results of register allocation.\n- Behavior is undefined if execution unwinds out of an asm block.\n - This also applies if the assembly code calls a function which then unwinds.\n- The set of memory locations that assembly code is allowed the read and write are the same as those allowed for an FFI function.\n - Refer to the unsafe code guidelines for the exact rules.\n - If the `readonly` option is set, then only memory reads are allowed.\n - If the `nomem` option is set then no reads or writes to memory are allowed.\n - These rules do not apply to memory which is private to the asm code, such as stack space allocated within the asm block.\n- The compiler cannot assume that the instructions in the asm are the ones that will actually end up executed.\n - This effectively means that the compiler must treat the `asm!` as a black box and only take the interface specification into account, not the instructions themselves.\n - Runtime code patching is allowed, via target-specific mechanisms (outside the scope of this RFC).\n- Unless the `nostack` option is set, asm code is allowed to use stack space below the stack pointer.\n - On entry to the asm block the stack pointer is guaranteed to be suitably aligned (according to the target ABI) for a function call.\n - You are responsible for making sure you don't overflow the stack (e.g. use stack probing to ensure you hit a guard page).\n - You should adjust the stack pointer when allocating stack memory as required by the target ABI.\n - The stack pointer must be restored to its original value before leaving the asm block.\n- If the `noreturn` option is set then behavior is undefined if execution falls through to the end of the asm block.\n- If the `pure` option is set then behavior is undefined if the `asm` has side-effects other than its direct outputs. Behavior is also undefined if two executions of the `asm` code with the same inputs result in different outputs.\n - When used with the `nomem` option, \"inputs\" are just the direct inputs of the `asm!`.\n - When used with the `readonly` option, \"inputs\" comprise the direct inputs of the `asm!` and any memory that the `asm!` block is allowed to read.\n- These flags registers must be restored upon exiting the asm block if the `preserves_flags` option is set:\n - x86\n - Status flags in `EFLAGS` (CF, PF, AF, ZF, SF, OF).\n - Floating-point status word (all).\n - Floating-point exception flags in `MXCSR` (PE, UE, OE, ZE, DE, IE).\n - ARM\n - Condition flags in `CPSR` (N, Z, C, V)\n - Saturation flag in `CPSR` (Q)\n - Greater than or equal flags in `CPSR` (GE).\n - Condition flags in `FPSCR` (N, Z, C, V)\n - Saturation flag in `FPSCR` (QC)\n - Floating-point exception flags in `FPSCR` (IDC, IXC, UFC, OFC, DZC, IOC).\n - AArch64\n - Condition flags (`NZCV` register).\n - Floating-point status (`FPSR` register).\n - RISC-V\n - Floating-point exception flags in `fcsr` (`fflags`).\n- On x86, the direction flag (DF in `EFLAGS`) is clear on entry to an asm block and must be clear on exit.\n - Behavior is undefined if the direction flag is set on exiting an asm block.\n- The requirement of restoring the stack pointer and non-output registers to their original value only applies when exiting an `asm!` block.\n - This means that `asm!` blocks that never return (even if not marked `noreturn`) don't need to preserve these registers.\n - When returning to a different `asm!` block than you entered (e.g. for context switching), these registers must contain the value they had upon entering the `asm!` block that you are *exiting*.\n - You cannot exit an `asm!` block that has not been entered. Neither can you exit an `asm!` block that has already been exited.\n - You are responsible for switching any target-specific state (e.g. thread-local storage, stack bounds).\n - The set of memory locations that you may access is the intersection of those allowed by the `asm!` blocks you entered and exited.\n- You cannot assume that an `asm!` block will appear exactly once in the output binary. The compiler is allowed to instantiate multiple copies of the `asm!` block, for example when the function containing it is inlined in multiple places.\n - As a consequence, you should only use [local labels] inside inline assembly code. Defining symbols in assembly code may lead to assembler and/or linker errors due to duplicate symbol definitions.\n\n> **Note**: As a general rule, the flags covered by `preserves_flags` are those which are *not* preserved when performing a function call.\n\n[local labels]: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Local-Labels\n" } , LintCompletion { label : "is_sorted" , description : "# `is_sorted`\n\nThe tracking issue for this feature is: [#53485]\n\n[#53485]: https://github.com/rust-lang/rust/issues/53485\n\n------------------------\n\nAdd the methods `is_sorted`, `is_sorted_by` and `is_sorted_by_key` to `[T]`;\nadd the methods `is_sorted`, `is_sorted_by` and `is_sorted_by_key` to\n`Iterator`.\n" } , LintCompletion { label : "derive_clone_copy" , description : "# `derive_clone_copy`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "print_internals" , description : "# `print_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "set_stdio" , description : "# `set_stdio`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "windows_handle" , description : "# `windows_handle`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "thread_local_internals" , description : "# `thread_local_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "profiler_runtime_lib" , description : "# `profiler_runtime_lib`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "windows_c" , description : "# `windows_c`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "fd_read" , description : "# `fd_read`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "c_void_variant" , description : "# `c_void_variant`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "flt2dec" , description : "# `flt2dec`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "core_private_bignum" , description : "# `core_private_bignum`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "format_args_capture" , description : "# `format_args_capture`\n\nThe tracking issue for this feature is: [#67984]\n\n[#67984]: https://github.com/rust-lang/rust/issues/67984\n\n------------------------\n\nEnables `format_args!` (and macros which use `format_args!` in their implementation, such\nas `format!`, `print!` and `panic!`) to capture variables from the surrounding scope.\nThis avoids the need to pass named parameters when the binding in question\nalready exists in scope.\n\n```rust\n#![feature(format_args_capture)]\n\nlet (person, species, name) = (\"Charlie Brown\", \"dog\", \"Snoopy\");\n\n// captures named argument `person`\nprint!(\"Hello {person}\");\n\n// captures named arguments `species` and `name`\nformat!(\"The {species}'s name is {name}.\");\n```\n\nThis also works for formatting parameters such as width and precision:\n\n```rust\n#![feature(format_args_capture)]\n\nlet precision = 2;\nlet s = format!(\"{:.precision$}\", 1.324223);\n\nassert_eq!(&s, \"1.32\");\n```\n\nA non-exhaustive list of macros which benefit from this functionality include:\n- `format!`\n- `print!` and `println!`\n- `eprint!` and `eprintln!`\n- `write!` and `writeln!`\n- `panic!`\n- `unreachable!`\n- `unimplemented!`\n- `todo!`\n- `assert!` and similar\n- macros in many thirdparty crates, such as `log`\n" } , LintCompletion { label : "libstd_io_internals" , description : "# `libstd_io_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "derive_eq" , description : "# `derive_eq`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "c_variadic" , description : "# `c_variadic`\n\nThe tracking issue for this feature is: [#44930]\n\n[#44930]: https://github.com/rust-lang/rust/issues/44930\n\n------------------------\n\nThe `c_variadic` library feature exposes the `VaList` structure,\nRust's analogue of C's `va_list` type.\n\n## Examples\n\n```rust\n#![feature(c_variadic)]\n\nuse std::ffi::VaList;\n\npub unsafe extern \"C\" fn vadd(n: usize, mut args: VaList) -> usize {\n let mut sum = 0;\n for _ in 0..n {\n sum += args.arg::<usize>();\n }\n sum\n}\n```\n" } , LintCompletion { label : "trace_macros" , description : "# `trace_macros`\n\nThe tracking issue for this feature is [#29598].\n\n[#29598]: https://github.com/rust-lang/rust/issues/29598\n\n------------------------\n\nWith `trace_macros` you can trace the expansion of macros in your code.\n\n## Examples\n\n```rust\n#![feature(trace_macros)]\n\nfn main() {\n trace_macros!(true);\n println!(\"Hello, Rust!\");\n trace_macros!(false);\n}\n```\n\nThe `cargo build` output:\n\n```txt\nnote: trace_macro\n --> src/main.rs:5:5\n |\n5 | println!(\"Hello, Rust!\");\n | ^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = note: expanding `println! { \"Hello, Rust!\" }`\n = note: to `print ! ( concat ! ( \"Hello, Rust!\" , \"\\n\" ) )`\n = note: expanding `print! { concat ! ( \"Hello, Rust!\" , \"\\n\" ) }`\n = note: to `$crate :: io :: _print ( format_args ! ( concat ! ( \"Hello, Rust!\" , \"\\n\" ) )\n )`\n\n Finished dev [unoptimized + debuginfo] target(s) in 0.60 secs\n```\n" } , LintCompletion { label : "core_private_diy_float" , description : "# `core_private_diy_float`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "core_panic" , description : "# `core_panic`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "str_internals" , description : "# `str_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "char_error_internals" , description : "# `char_error_internals`\n\nThis feature is internal to the Rust compiler and is not intended for general use.\n\n------------------------\n" } , LintCompletion { label : "llvm_asm" , description : "# `llvm_asm`\n\nThe tracking issue for this feature is: [#70173]\n\n[#70173]: https://github.com/rust-lang/rust/issues/70173\n\n------------------------\n\nFor extremely low-level manipulations and performance reasons, one\nmight wish to control the CPU directly. Rust supports using inline\nassembly to do this via the `llvm_asm!` macro.\n\n```rust,ignore\nllvm_asm!(assembly template\n : output operands\n : input operands\n : clobbers\n : options\n );\n```\n\nAny use of `llvm_asm` is feature gated (requires `#![feature(llvm_asm)]` on the\ncrate to allow) and of course requires an `unsafe` block.\n\n> **Note**: the examples here are given in x86/x86-64 assembly, but\n> all platforms are supported.\n\n## Assembly template\n\nThe `assembly template` is the only required parameter and must be a\nliteral string (i.e. `\"\"`)\n\n```rust\n#![feature(llvm_asm)]\n\n#[cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\nfn foo() {\n unsafe {\n llvm_asm!(\"NOP\");\n }\n}\n\n// Other platforms:\n#[cfg(not(any(target_arch = \"x86\", target_arch = \"x86_64\")))]\nfn foo() { /* ... */ }\n\nfn main() {\n // ...\n foo();\n // ...\n}\n```\n\n(The `feature(llvm_asm)` and `#[cfg]`s are omitted from now on.)\n\nOutput operands, input operands, clobbers and options are all optional\nbut you must add the right number of `:` if you skip them:\n\n```rust\n# #![feature(llvm_asm)]\n# #[cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\n# fn main() { unsafe {\nllvm_asm!(\"xor %eax, %eax\"\n :\n :\n : \"eax\"\n );\n# } }\n# #[cfg(not(any(target_arch = \"x86\", target_arch = \"x86_64\")))]\n# fn main() {}\n```\n\nWhitespace also doesn't matter:\n\n```rust\n# #![feature(llvm_asm)]\n# #[cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\n# fn main() { unsafe {\nllvm_asm!(\"xor %eax, %eax\" ::: \"eax\");\n# } }\n# #[cfg(not(any(target_arch = \"x86\", target_arch = \"x86_64\")))]\n# fn main() {}\n```\n\n## Operands\n\nInput and output operands follow the same format: `:\n\"constraints1\"(expr1), \"constraints2\"(expr2), ...\"`. Output operand\nexpressions must be mutable place, or not yet assigned:\n\n```rust\n# #![feature(llvm_asm)]\n# #[cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\nfn add(a: i32, b: i32) -> i32 {\n let c: i32;\n unsafe {\n llvm_asm!(\"add $2, $0\"\n : \"=r\"(c)\n : \"0\"(a), \"r\"(b)\n );\n }\n c\n}\n# #[cfg(not(any(target_arch = \"x86\", target_arch = \"x86_64\")))]\n# fn add(a: i32, b: i32) -> i32 { a + b }\n\nfn main() {\n assert_eq!(add(3, 14159), 14162)\n}\n```\n\nIf you would like to use real operands in this position, however,\nyou are required to put curly braces `{}` around the register that\nyou want, and you are required to put the specific size of the\noperand. This is useful for very low level programming, where\nwhich register you use is important:\n\n```rust\n# #![feature(llvm_asm)]\n# #[cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\n# unsafe fn read_byte_in(port: u16) -> u8 {\nlet result: u8;\nllvm_asm!(\"in %dx, %al\" : \"={al}\"(result) : \"{dx}\"(port));\nresult\n# }\n```\n\n## Clobbers\n\nSome instructions modify registers which might otherwise have held\ndifferent values so we use the clobbers list to indicate to the\ncompiler not to assume any values loaded into those registers will\nstay valid.\n\n```rust\n# #![feature(llvm_asm)]\n# #[cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\n# fn main() { unsafe {\n// Put the value 0x200 in eax:\nllvm_asm!(\"mov $$0x200, %eax\" : /* no outputs */ : /* no inputs */ : \"eax\");\n# } }\n# #[cfg(not(any(target_arch = \"x86\", target_arch = \"x86_64\")))]\n# fn main() {}\n```\n\nInput and output registers need not be listed since that information\nis already communicated by the given constraints. Otherwise, any other\nregisters used either implicitly or explicitly should be listed.\n\nIf the assembly changes the condition code register `cc` should be\nspecified as one of the clobbers. Similarly, if the assembly modifies\nmemory, `memory` should also be specified.\n\n## Options\n\nThe last section, `options` is specific to Rust. The format is comma\nseparated literal strings (i.e. `:\"foo\", \"bar\", \"baz\"`). It's used to\nspecify some extra info about the inline assembly:\n\nCurrent valid options are:\n\n1. *volatile* - specifying this is analogous to\n `__asm__ __volatile__ (...)` in gcc/clang.\n2. *alignstack* - certain instructions expect the stack to be\n aligned a certain way (i.e. SSE) and specifying this indicates to\n the compiler to insert its usual stack alignment code\n3. *intel* - use intel syntax instead of the default AT&T.\n\n```rust\n# #![feature(llvm_asm)]\n# #[cfg(any(target_arch = \"x86\", target_arch = \"x86_64\"))]\n# fn main() {\nlet result: i32;\nunsafe {\n llvm_asm!(\"mov eax, 2\" : \"={eax}\"(result) : : : \"intel\")\n}\nprintln!(\"eax is currently {}\", result);\n# }\n# #[cfg(not(any(target_arch = \"x86\", target_arch = \"x86_64\")))]\n# fn main() {}\n```\n\n## More Information\n\nThe current implementation of the `llvm_asm!` macro is a direct binding to [LLVM's\ninline assembler expressions][llvm-docs], so be sure to check out [their\ndocumentation as well][llvm-docs] for more information about clobbers,\nconstraints, etc.\n\n[llvm-docs]: http://llvm.org/docs/LangRef.html#inline-assembler-expressions\n\nIf you need more power and don't mind losing some of the niceties of\n`llvm_asm!`, check out [global_asm](global-asm.md).\n" } ] ;
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs
index 897177d05..73c0b8275 100644
--- a/crates/ra_ide/src/diagnostics.rs
+++ b/crates/ra_ide/src/diagnostics.rs
@@ -78,8 +78,10 @@ pub(crate) fn diagnostics(
78 } else { 78 } else {
79 let mut field_list = d.ast(db); 79 let mut field_list = d.ast(db);
80 for f in d.missed_fields.iter() { 80 for f in d.missed_fields.iter() {
81 let field = 81 let field = make::record_expr_field(
82 make::record_field(make::name_ref(&f.to_string()), Some(make::expr_unit())); 82 make::name_ref(&f.to_string()),
83 Some(make::expr_unit()),
84 );
83 field_list = field_list.append_field(&field); 85 field_list = field_list.append_field(&field);
84 } 86 }
85 87
@@ -146,7 +148,7 @@ fn missing_struct_field_fix(
146) -> Option<Fix> { 148) -> Option<Fix> {
147 let record_expr = sema.ast(d); 149 let record_expr = sema.ast(d);
148 150
149 let record_lit = ast::RecordLit::cast(record_expr.syntax().parent()?.parent()?)?; 151 let record_lit = ast::RecordExpr::cast(record_expr.syntax().parent()?.parent()?)?;
150 let def_id = sema.resolve_variant(record_lit)?; 152 let def_id = sema.resolve_variant(record_lit)?;
151 let module; 153 let module;
152 let def_file_id; 154 let def_file_id;
@@ -155,21 +157,21 @@ fn missing_struct_field_fix(
155 module = s.module(sema.db); 157 module = s.module(sema.db);
156 let source = s.source(sema.db); 158 let source = s.source(sema.db);
157 def_file_id = source.file_id; 159 def_file_id = source.file_id;
158 let fields = source.value.field_def_list()?; 160 let fields = source.value.field_list()?;
159 record_field_def_list(fields)? 161 record_field_list(fields)?
160 } 162 }
161 VariantDef::Union(u) => { 163 VariantDef::Union(u) => {
162 module = u.module(sema.db); 164 module = u.module(sema.db);
163 let source = u.source(sema.db); 165 let source = u.source(sema.db);
164 def_file_id = source.file_id; 166 def_file_id = source.file_id;
165 source.value.record_field_def_list()? 167 source.value.record_field_list()?
166 } 168 }
167 VariantDef::EnumVariant(e) => { 169 VariantDef::EnumVariant(e) => {
168 module = e.module(sema.db); 170 module = e.module(sema.db);
169 let source = e.source(sema.db); 171 let source = e.source(sema.db);
170 def_file_id = source.file_id; 172 def_file_id = source.file_id;
171 let fields = source.value.field_def_list()?; 173 let fields = source.value.field_list()?;
172 record_field_def_list(fields)? 174 record_field_list(fields)?
173 } 175 }
174 }; 176 };
175 let def_file_id = def_file_id.original_file(sema.db); 177 let def_file_id = def_file_id.original_file(sema.db);
@@ -178,9 +180,9 @@ fn missing_struct_field_fix(
178 if new_field_type.is_unknown() { 180 if new_field_type.is_unknown() {
179 return None; 181 return None;
180 } 182 }
181 let new_field = make::record_field_def( 183 let new_field = make::record_field(
182 record_expr.field_name()?, 184 record_expr.field_name()?,
183 make::type_ref(&new_field_type.display_source_code(sema.db, module.into()).ok()?), 185 make::ty(&new_field_type.display_source_code(sema.db, module.into()).ok()?),
184 ); 186 );
185 187
186 let last_field = record_fields.fields().last()?; 188 let last_field = record_fields.fields().last()?;
@@ -205,10 +207,10 @@ fn missing_struct_field_fix(
205 let fix = Fix::new("Create field", source_change.into()); 207 let fix = Fix::new("Create field", source_change.into());
206 return Some(fix); 208 return Some(fix);
207 209
208 fn record_field_def_list(field_def_list: ast::FieldDefList) -> Option<ast::RecordFieldDefList> { 210 fn record_field_list(field_def_list: ast::FieldList) -> Option<ast::RecordFieldList> {
209 match field_def_list { 211 match field_def_list {
210 ast::FieldDefList::RecordFieldDefList(it) => Some(it), 212 ast::FieldList::RecordFieldList(it) => Some(it),
211 ast::FieldDefList::TupleFieldDefList(_) => None, 213 ast::FieldList::TupleFieldList(_) => None,
212 } 214 }
213 } 215 }
214} 216}
@@ -263,8 +265,8 @@ fn check_struct_shorthand_initialization(
263 file_id: FileId, 265 file_id: FileId,
264 node: &SyntaxNode, 266 node: &SyntaxNode,
265) -> Option<()> { 267) -> Option<()> {
266 let record_lit = ast::RecordLit::cast(node.clone())?; 268 let record_lit = ast::RecordExpr::cast(node.clone())?;
267 let record_field_list = record_lit.record_field_list()?; 269 let record_field_list = record_lit.record_expr_field_list()?;
268 for record_field in record_field_list.fields() { 270 for record_field in record_field_list.fields() {
269 if let (Some(name_ref), Some(expr)) = (record_field.name_ref(), record_field.expr()) { 271 if let (Some(name_ref), Some(expr)) = (record_field.name_ref(), record_field.expr()) {
270 let field_name = name_ref.syntax().text().to_string(); 272 let field_name = name_ref.syntax().text().to_string();
diff --git a/crates/ra_ide/src/display.rs b/crates/ra_ide/src/display.rs
index 6d4151dd8..fd42aa435 100644
--- a/crates/ra_ide/src/display.rs
+++ b/crates/ra_ide/src/display.rs
@@ -5,7 +5,7 @@ mod navigation_target;
5mod short_label; 5mod short_label;
6 6
7use ra_syntax::{ 7use ra_syntax::{
8 ast::{self, AstNode, AttrsOwner, NameOwner, TypeParamsOwner}, 8 ast::{self, AstNode, AttrsOwner, GenericParamsOwner, NameOwner},
9 SyntaxKind::{ATTR, COMMENT}, 9 SyntaxKind::{ATTR, COMMENT},
10}; 10};
11 11
@@ -16,7 +16,7 @@ pub use navigation_target::NavigationTarget;
16pub(crate) use navigation_target::{ToNav, TryToNav}; 16pub(crate) use navigation_target::{ToNav, TryToNav};
17pub(crate) use short_label::ShortLabel; 17pub(crate) use short_label::ShortLabel;
18 18
19pub(crate) fn function_declaration(node: &ast::FnDef) -> String { 19pub(crate) fn function_declaration(node: &ast::Fn) -> String {
20 let mut buf = String::new(); 20 let mut buf = String::new();
21 if let Some(vis) = node.visibility() { 21 if let Some(vis) = node.visibility() {
22 format_to!(buf, "{} ", vis); 22 format_to!(buf, "{} ", vis);
@@ -37,14 +37,14 @@ pub(crate) fn function_declaration(node: &ast::FnDef) -> String {
37 if let Some(name) = node.name() { 37 if let Some(name) = node.name() {
38 format_to!(buf, "fn {}", name) 38 format_to!(buf, "fn {}", name)
39 } 39 }
40 if let Some(type_params) = node.type_param_list() { 40 if let Some(type_params) = node.generic_param_list() {
41 format_to!(buf, "{}", type_params); 41 format_to!(buf, "{}", type_params);
42 } 42 }
43 if let Some(param_list) = node.param_list() { 43 if let Some(param_list) = node.param_list() {
44 format_to!(buf, "{}", param_list); 44 format_to!(buf, "{}", param_list);
45 } 45 }
46 if let Some(ret_type) = node.ret_type() { 46 if let Some(ret_type) = node.ret_type() {
47 if ret_type.type_ref().is_some() { 47 if ret_type.ty().is_some() {
48 format_to!(buf, " {}", ret_type); 48 format_to!(buf, " {}", ret_type);
49 } 49 }
50 } 50 }
@@ -54,7 +54,7 @@ pub(crate) fn function_declaration(node: &ast::FnDef) -> String {
54 buf 54 buf
55} 55}
56 56
57pub(crate) fn const_label(node: &ast::ConstDef) -> String { 57pub(crate) fn const_label(node: &ast::Const) -> String {
58 let label: String = node 58 let label: String = node
59 .syntax() 59 .syntax()
60 .children_with_tokens() 60 .children_with_tokens()
@@ -65,7 +65,7 @@ pub(crate) fn const_label(node: &ast::ConstDef) -> String {
65 label.trim().to_owned() 65 label.trim().to_owned()
66} 66}
67 67
68pub(crate) fn type_label(node: &ast::TypeAliasDef) -> String { 68pub(crate) fn type_label(node: &ast::TypeAlias) -> String {
69 let label: String = node 69 let label: String = node
70 .syntax() 70 .syntax()
71 .children_with_tokens() 71 .children_with_tokens()
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs
index fd245705c..fdbf75abd 100644
--- a/crates/ra_ide/src/display/navigation_target.rs
+++ b/crates/ra_ide/src/display/navigation_target.rs
@@ -7,7 +7,7 @@ use ra_ide_db::{defs::Definition, RootDatabase};
7use ra_syntax::{ 7use ra_syntax::{
8 ast::{self, DocCommentsOwner, NameOwner}, 8 ast::{self, DocCommentsOwner, NameOwner},
9 match_ast, AstNode, SmolStr, 9 match_ast, AstNode, SmolStr,
10 SyntaxKind::{self, BIND_PAT, TYPE_PARAM}, 10 SyntaxKind::{self, IDENT_PAT, TYPE_PARAM},
11 TextRange, 11 TextRange,
12}; 12};
13 13
@@ -253,7 +253,7 @@ impl ToNav for hir::ImplDef {
253 let focus_range = if derive_attr.is_some() { 253 let focus_range = if derive_attr.is_some() {
254 None 254 None
255 } else { 255 } else {
256 src.value.target_type().map(|ty| original_range(db, src.with_value(ty.syntax())).range) 256 src.value.self_ty().map(|ty| original_range(db, src.with_value(ty.syntax())).range)
257 }; 257 };
258 258
259 NavigationTarget::from_syntax( 259 NavigationTarget::from_syntax(
@@ -339,7 +339,7 @@ impl ToNav for hir::Local {
339 NavigationTarget { 339 NavigationTarget {
340 file_id: full_range.file_id, 340 file_id: full_range.file_id,
341 name, 341 name,
342 kind: BIND_PAT, 342 kind: IDENT_PAT,
343 full_range: full_range.range, 343 full_range: full_range.range,
344 focus_range: None, 344 focus_range: None,
345 container_name: None, 345 container_name: None,
@@ -379,16 +379,16 @@ pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option
379 379
380 match_ast! { 380 match_ast! {
381 match node { 381 match node {
382 ast::FnDef(it) => it.doc_comment_text(), 382 ast::Fn(it) => it.doc_comment_text(),
383 ast::StructDef(it) => it.doc_comment_text(), 383 ast::Struct(it) => it.doc_comment_text(),
384 ast::EnumDef(it) => it.doc_comment_text(), 384 ast::Enum(it) => it.doc_comment_text(),
385 ast::TraitDef(it) => it.doc_comment_text(), 385 ast::Trait(it) => it.doc_comment_text(),
386 ast::Module(it) => it.doc_comment_text(), 386 ast::Module(it) => it.doc_comment_text(),
387 ast::TypeAliasDef(it) => it.doc_comment_text(), 387 ast::TypeAlias(it) => it.doc_comment_text(),
388 ast::ConstDef(it) => it.doc_comment_text(), 388 ast::Const(it) => it.doc_comment_text(),
389 ast::StaticDef(it) => it.doc_comment_text(), 389 ast::Static(it) => it.doc_comment_text(),
390 ast::RecordFieldDef(it) => it.doc_comment_text(), 390 ast::RecordField(it) => it.doc_comment_text(),
391 ast::EnumVariant(it) => it.doc_comment_text(), 391 ast::Variant(it) => it.doc_comment_text(),
392 ast::MacroCall(it) => it.doc_comment_text(), 392 ast::MacroCall(it) => it.doc_comment_text(),
393 _ => None, 393 _ => None,
394 } 394 }
@@ -404,16 +404,16 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) ->
404 404
405 match_ast! { 405 match_ast! {
406 match node { 406 match node {
407 ast::FnDef(it) => it.short_label(), 407 ast::Fn(it) => it.short_label(),
408 ast::StructDef(it) => it.short_label(), 408 ast::Struct(it) => it.short_label(),
409 ast::EnumDef(it) => it.short_label(), 409 ast::Enum(it) => it.short_label(),
410 ast::TraitDef(it) => it.short_label(), 410 ast::Trait(it) => it.short_label(),
411 ast::Module(it) => it.short_label(), 411 ast::Module(it) => it.short_label(),
412 ast::TypeAliasDef(it) => it.short_label(), 412 ast::TypeAlias(it) => it.short_label(),
413 ast::ConstDef(it) => it.short_label(), 413 ast::Const(it) => it.short_label(),
414 ast::StaticDef(it) => it.short_label(), 414 ast::Static(it) => it.short_label(),
415 ast::RecordFieldDef(it) => it.short_label(), 415 ast::RecordField(it) => it.short_label(),
416 ast::EnumVariant(it) => it.short_label(), 416 ast::Variant(it) => it.short_label(),
417 _ => None, 417 _ => None,
418 } 418 }
419 } 419 }
@@ -446,7 +446,7 @@ fn foo() { enum FooInner { } }
446 5..13, 446 5..13,
447 ), 447 ),
448 name: "FooInner", 448 name: "FooInner",
449 kind: ENUM_DEF, 449 kind: ENUM,
450 container_name: None, 450 container_name: None,
451 description: Some( 451 description: Some(
452 "enum FooInner", 452 "enum FooInner",
@@ -462,7 +462,7 @@ fn foo() { enum FooInner { } }
462 34..42, 462 34..42,
463 ), 463 ),
464 name: "FooInner", 464 name: "FooInner",
465 kind: ENUM_DEF, 465 kind: ENUM,
466 container_name: Some( 466 container_name: Some(
467 "foo", 467 "foo",
468 ), 468 ),
diff --git a/crates/ra_ide/src/display/short_label.rs b/crates/ra_ide/src/display/short_label.rs
index 5588130a1..0fdf8e9a5 100644
--- a/crates/ra_ide/src/display/short_label.rs
+++ b/crates/ra_ide/src/display/short_label.rs
@@ -1,37 +1,37 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use ra_syntax::ast::{self, AstNode, NameOwner, TypeAscriptionOwner, VisibilityOwner}; 3use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner};
4use stdx::format_to; 4use stdx::format_to;
5 5
6pub(crate) trait ShortLabel { 6pub(crate) trait ShortLabel {
7 fn short_label(&self) -> Option<String>; 7 fn short_label(&self) -> Option<String>;
8} 8}
9 9
10impl ShortLabel for ast::FnDef { 10impl ShortLabel for ast::Fn {
11 fn short_label(&self) -> Option<String> { 11 fn short_label(&self) -> Option<String> {
12 Some(crate::display::function_declaration(self)) 12 Some(crate::display::function_declaration(self))
13 } 13 }
14} 14}
15 15
16impl ShortLabel for ast::StructDef { 16impl ShortLabel for ast::Struct {
17 fn short_label(&self) -> Option<String> { 17 fn short_label(&self) -> Option<String> {
18 short_label_from_node(self, "struct ") 18 short_label_from_node(self, "struct ")
19 } 19 }
20} 20}
21 21
22impl ShortLabel for ast::UnionDef { 22impl ShortLabel for ast::Union {
23 fn short_label(&self) -> Option<String> { 23 fn short_label(&self) -> Option<String> {
24 short_label_from_node(self, "union ") 24 short_label_from_node(self, "union ")
25 } 25 }
26} 26}
27 27
28impl ShortLabel for ast::EnumDef { 28impl ShortLabel for ast::Enum {
29 fn short_label(&self) -> Option<String> { 29 fn short_label(&self) -> Option<String> {
30 short_label_from_node(self, "enum ") 30 short_label_from_node(self, "enum ")
31 } 31 }
32} 32}
33 33
34impl ShortLabel for ast::TraitDef { 34impl ShortLabel for ast::Trait {
35 fn short_label(&self) -> Option<String> { 35 fn short_label(&self) -> Option<String> {
36 if self.unsafe_token().is_some() { 36 if self.unsafe_token().is_some() {
37 short_label_from_node(self, "unsafe trait ") 37 short_label_from_node(self, "unsafe trait ")
@@ -47,43 +47,43 @@ impl ShortLabel for ast::Module {
47 } 47 }
48} 48}
49 49
50impl ShortLabel for ast::TypeAliasDef { 50impl ShortLabel for ast::TypeAlias {
51 fn short_label(&self) -> Option<String> { 51 fn short_label(&self) -> Option<String> {
52 short_label_from_node(self, "type ") 52 short_label_from_node(self, "type ")
53 } 53 }
54} 54}
55 55
56impl ShortLabel for ast::ConstDef { 56impl ShortLabel for ast::Const {
57 fn short_label(&self) -> Option<String> { 57 fn short_label(&self) -> Option<String> {
58 short_label_from_ascribed_node(self, "const ") 58 short_label_from_ty(self, self.ty(), "const ")
59 } 59 }
60} 60}
61 61
62impl ShortLabel for ast::StaticDef { 62impl ShortLabel for ast::Static {
63 fn short_label(&self) -> Option<String> { 63 fn short_label(&self) -> Option<String> {
64 short_label_from_ascribed_node(self, "static ") 64 short_label_from_ty(self, self.ty(), "static ")
65 } 65 }
66} 66}
67 67
68impl ShortLabel for ast::RecordFieldDef { 68impl ShortLabel for ast::RecordField {
69 fn short_label(&self) -> Option<String> { 69 fn short_label(&self) -> Option<String> {
70 short_label_from_ascribed_node(self, "") 70 short_label_from_ty(self, self.ty(), "")
71 } 71 }
72} 72}
73 73
74impl ShortLabel for ast::EnumVariant { 74impl ShortLabel for ast::Variant {
75 fn short_label(&self) -> Option<String> { 75 fn short_label(&self) -> Option<String> {
76 Some(self.name()?.text().to_string()) 76 Some(self.name()?.text().to_string())
77 } 77 }
78} 78}
79 79
80fn short_label_from_ascribed_node<T>(node: &T, prefix: &str) -> Option<String> 80fn short_label_from_ty<T>(node: &T, ty: Option<ast::Type>, prefix: &str) -> Option<String>
81where 81where
82 T: NameOwner + VisibilityOwner + TypeAscriptionOwner, 82 T: NameOwner + VisibilityOwner,
83{ 83{
84 let mut buf = short_label_from_node(node, prefix)?; 84 let mut buf = short_label_from_node(node, prefix)?;
85 85
86 if let Some(type_ref) = node.ascribed_type() { 86 if let Some(type_ref) = ty {
87 format_to!(buf, ": {}", type_ref.syntax()); 87 format_to!(buf, ": {}", type_ref.syntax());
88 } 88 }
89 89
diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs
index 8a6b3ea99..7230a0ff9 100644
--- a/crates/ra_ide/src/extend_selection.rs
+++ b/crates/ra_ide/src/extend_selection.rs
@@ -37,15 +37,15 @@ fn try_extend_selection(
37 37
38 let string_kinds = [COMMENT, STRING, RAW_STRING, BYTE_STRING, RAW_BYTE_STRING]; 38 let string_kinds = [COMMENT, STRING, RAW_STRING, BYTE_STRING, RAW_BYTE_STRING];
39 let list_kinds = [ 39 let list_kinds = [
40 RECORD_FIELD_PAT_LIST, 40 RECORD_PAT_FIELD_LIST,
41 MATCH_ARM_LIST, 41 MATCH_ARM_LIST,
42 RECORD_FIELD_DEF_LIST,
43 TUPLE_FIELD_DEF_LIST,
44 RECORD_FIELD_LIST, 42 RECORD_FIELD_LIST,
45 ENUM_VARIANT_LIST, 43 TUPLE_FIELD_LIST,
44 RECORD_EXPR_FIELD_LIST,
45 VARIANT_LIST,
46 USE_TREE_LIST, 46 USE_TREE_LIST,
47 TYPE_PARAM_LIST, 47 GENERIC_PARAM_LIST,
48 TYPE_ARG_LIST, 48 GENERIC_ARG_LIST,
49 TYPE_BOUND_LIST, 49 TYPE_BOUND_LIST,
50 PARAM_LIST, 50 PARAM_LIST,
51 ARG_LIST, 51 ARG_LIST,
diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs
index 1f6a3febf..87cab4503 100644
--- a/crates/ra_ide/src/file_structure.rs
+++ b/crates/ra_ide/src/file_structure.rs
@@ -1,5 +1,5 @@
1use ra_syntax::{ 1use ra_syntax::{
2 ast::{self, AttrsOwner, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, 2 ast::{self, AttrsOwner, GenericParamsOwner, NameOwner},
3 match_ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, WalkEvent, 3 match_ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, WalkEvent,
4}; 4};
5 5
@@ -52,19 +52,12 @@ pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
52 52
53fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { 53fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
54 fn decl<N: NameOwner + AttrsOwner>(node: N) -> Option<StructureNode> { 54 fn decl<N: NameOwner + AttrsOwner>(node: N) -> Option<StructureNode> {
55 decl_with_detail(node, None) 55 decl_with_detail(&node, None)
56 }
57
58 fn decl_with_ascription<N: NameOwner + AttrsOwner + TypeAscriptionOwner>(
59 node: N,
60 ) -> Option<StructureNode> {
61 let ty = node.ascribed_type();
62 decl_with_type_ref(node, ty)
63 } 56 }
64 57
65 fn decl_with_type_ref<N: NameOwner + AttrsOwner>( 58 fn decl_with_type_ref<N: NameOwner + AttrsOwner>(
66 node: N, 59 node: &N,
67 type_ref: Option<ast::TypeRef>, 60 type_ref: Option<ast::Type>,
68 ) -> Option<StructureNode> { 61 ) -> Option<StructureNode> {
69 let detail = type_ref.map(|type_ref| { 62 let detail = type_ref.map(|type_ref| {
70 let mut detail = String::new(); 63 let mut detail = String::new();
@@ -75,7 +68,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
75 } 68 }
76 69
77 fn decl_with_detail<N: NameOwner + AttrsOwner>( 70 fn decl_with_detail<N: NameOwner + AttrsOwner>(
78 node: N, 71 node: &N,
79 detail: Option<String>, 72 detail: Option<String>,
80 ) -> Option<StructureNode> { 73 ) -> Option<StructureNode> {
81 let name = node.name()?; 74 let name = node.name()?;
@@ -111,9 +104,9 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
111 104
112 match_ast! { 105 match_ast! {
113 match node { 106 match node {
114 ast::FnDef(it) => { 107 ast::Fn(it) => {
115 let mut detail = String::from("fn"); 108 let mut detail = String::from("fn");
116 if let Some(type_param_list) = it.type_param_list() { 109 if let Some(type_param_list) = it.generic_param_list() {
117 collapse_ws(type_param_list.syntax(), &mut detail); 110 collapse_ws(type_param_list.syntax(), &mut detail);
118 } 111 }
119 if let Some(param_list) = it.param_list() { 112 if let Some(param_list) = it.param_list() {
@@ -124,24 +117,21 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
124 collapse_ws(ret_type.syntax(), &mut detail); 117 collapse_ws(ret_type.syntax(), &mut detail);
125 } 118 }
126 119
127 decl_with_detail(it, Some(detail)) 120 decl_with_detail(&it, Some(detail))
128 }, 121 },
129 ast::StructDef(it) => decl(it), 122 ast::Struct(it) => decl(it),
130 ast::UnionDef(it) => decl(it), 123 ast::Union(it) => decl(it),
131 ast::EnumDef(it) => decl(it), 124 ast::Enum(it) => decl(it),
132 ast::EnumVariant(it) => decl(it), 125 ast::Variant(it) => decl(it),
133 ast::TraitDef(it) => decl(it), 126 ast::Trait(it) => decl(it),
134 ast::Module(it) => decl(it), 127 ast::Module(it) => decl(it),
135 ast::TypeAliasDef(it) => { 128 ast::TypeAlias(it) => decl_with_type_ref(&it, it.ty()),
136 let ty = it.type_ref(); 129 ast::RecordField(it) => decl_with_type_ref(&it, it.ty()),
137 decl_with_type_ref(it, ty) 130 ast::Const(it) => decl_with_type_ref(&it, it.ty()),
138 }, 131 ast::Static(it) => decl_with_type_ref(&it, it.ty()),
139 ast::RecordFieldDef(it) => decl_with_ascription(it), 132 ast::Impl(it) => {
140 ast::ConstDef(it) => decl_with_ascription(it), 133 let target_type = it.self_ty()?;
141 ast::StaticDef(it) => decl_with_ascription(it), 134 let target_trait = it.trait_();
142 ast::ImplDef(it) => {
143 let target_type = it.target_type()?;
144 let target_trait = it.target_trait();
145 let label = match target_trait { 135 let label = match target_trait {
146 None => format!("impl {}", target_type.syntax().text()), 136 None => format!("impl {}", target_type.syntax().text()),
147 Some(t) => { 137 Some(t) => {
@@ -238,7 +228,7 @@ fn very_obsolete() {}
238 label: "Foo", 228 label: "Foo",
239 navigation_range: 8..11, 229 navigation_range: 8..11,
240 node_range: 1..26, 230 node_range: 1..26,
241 kind: STRUCT_DEF, 231 kind: STRUCT,
242 detail: None, 232 detail: None,
243 deprecated: false, 233 deprecated: false,
244 }, 234 },
@@ -249,7 +239,7 @@ fn very_obsolete() {}
249 label: "x", 239 label: "x",
250 navigation_range: 18..19, 240 navigation_range: 18..19,
251 node_range: 18..24, 241 node_range: 18..24,
252 kind: RECORD_FIELD_DEF, 242 kind: RECORD_FIELD,
253 detail: Some( 243 detail: Some(
254 "i32", 244 "i32",
255 ), 245 ),
@@ -271,7 +261,7 @@ fn very_obsolete() {}
271 label: "bar1", 261 label: "bar1",
272 navigation_range: 43..47, 262 navigation_range: 43..47,
273 node_range: 40..52, 263 node_range: 40..52,
274 kind: FN_DEF, 264 kind: FN,
275 detail: Some( 265 detail: Some(
276 "fn()", 266 "fn()",
277 ), 267 ),
@@ -284,7 +274,7 @@ fn very_obsolete() {}
284 label: "bar2", 274 label: "bar2",
285 navigation_range: 60..64, 275 navigation_range: 60..64,
286 node_range: 57..81, 276 node_range: 57..81,
287 kind: FN_DEF, 277 kind: FN,
288 detail: Some( 278 detail: Some(
289 "fn<T>(t: T) -> T", 279 "fn<T>(t: T) -> T",
290 ), 280 ),
@@ -297,7 +287,7 @@ fn very_obsolete() {}
297 label: "bar3", 287 label: "bar3",
298 navigation_range: 89..93, 288 navigation_range: 89..93,
299 node_range: 86..156, 289 node_range: 86..156,
300 kind: FN_DEF, 290 kind: FN,
301 detail: Some( 291 detail: Some(
302 "fn<A, B>(a: A, b: B) -> Vec< u32 >", 292 "fn<A, B>(a: A, b: B) -> Vec< u32 >",
303 ), 293 ),
@@ -308,7 +298,7 @@ fn very_obsolete() {}
308 label: "E", 298 label: "E",
309 navigation_range: 165..166, 299 navigation_range: 165..166,
310 node_range: 160..180, 300 node_range: 160..180,
311 kind: ENUM_DEF, 301 kind: ENUM,
312 detail: None, 302 detail: None,
313 deprecated: false, 303 deprecated: false,
314 }, 304 },
@@ -319,7 +309,7 @@ fn very_obsolete() {}
319 label: "X", 309 label: "X",
320 navigation_range: 169..170, 310 navigation_range: 169..170,
321 node_range: 169..170, 311 node_range: 169..170,
322 kind: ENUM_VARIANT, 312 kind: VARIANT,
323 detail: None, 313 detail: None,
324 deprecated: false, 314 deprecated: false,
325 }, 315 },
@@ -330,7 +320,7 @@ fn very_obsolete() {}
330 label: "Y", 320 label: "Y",
331 navigation_range: 172..173, 321 navigation_range: 172..173,
332 node_range: 172..178, 322 node_range: 172..178,
333 kind: ENUM_VARIANT, 323 kind: VARIANT,
334 detail: None, 324 detail: None,
335 deprecated: false, 325 deprecated: false,
336 }, 326 },
@@ -339,7 +329,7 @@ fn very_obsolete() {}
339 label: "T", 329 label: "T",
340 navigation_range: 186..187, 330 navigation_range: 186..187,
341 node_range: 181..193, 331 node_range: 181..193,
342 kind: TYPE_ALIAS_DEF, 332 kind: TYPE_ALIAS,
343 detail: Some( 333 detail: Some(
344 "()", 334 "()",
345 ), 335 ),
@@ -350,7 +340,7 @@ fn very_obsolete() {}
350 label: "S", 340 label: "S",
351 navigation_range: 201..202, 341 navigation_range: 201..202,
352 node_range: 194..213, 342 node_range: 194..213,
353 kind: STATIC_DEF, 343 kind: STATIC,
354 detail: Some( 344 detail: Some(
355 "i32", 345 "i32",
356 ), 346 ),
@@ -361,7 +351,7 @@ fn very_obsolete() {}
361 label: "C", 351 label: "C",
362 navigation_range: 220..221, 352 navigation_range: 220..221,
363 node_range: 214..232, 353 node_range: 214..232,
364 kind: CONST_DEF, 354 kind: CONST,
365 detail: Some( 355 detail: Some(
366 "i32", 356 "i32",
367 ), 357 ),
@@ -372,7 +362,7 @@ fn very_obsolete() {}
372 label: "impl E", 362 label: "impl E",
373 navigation_range: 239..240, 363 navigation_range: 239..240,
374 node_range: 234..243, 364 node_range: 234..243,
375 kind: IMPL_DEF, 365 kind: IMPL,
376 detail: None, 366 detail: None,
377 deprecated: false, 367 deprecated: false,
378 }, 368 },
@@ -381,7 +371,7 @@ fn very_obsolete() {}
381 label: "impl fmt::Debug for E", 371 label: "impl fmt::Debug for E",
382 navigation_range: 265..266, 372 navigation_range: 265..266,
383 node_range: 245..269, 373 node_range: 245..269,
384 kind: IMPL_DEF, 374 kind: IMPL,
385 detail: None, 375 detail: None,
386 deprecated: false, 376 deprecated: false,
387 }, 377 },
@@ -417,7 +407,7 @@ fn very_obsolete() {}
417 label: "obsolete", 407 label: "obsolete",
418 navigation_range: 428..436, 408 navigation_range: 428..436,
419 node_range: 411..441, 409 node_range: 411..441,
420 kind: FN_DEF, 410 kind: FN,
421 detail: Some( 411 detail: Some(
422 "fn()", 412 "fn()",
423 ), 413 ),
@@ -428,7 +418,7 @@ fn very_obsolete() {}
428 label: "very_obsolete", 418 label: "very_obsolete",
429 navigation_range: 481..494, 419 navigation_range: 481..494,
430 node_range: 443..499, 420 node_range: 443..499,
431 kind: FN_DEF, 421 kind: FN,
432 detail: Some( 422 detail: Some(
433 "fn()", 423 "fn()",
434 ), 424 ),
diff --git a/crates/ra_ide/src/folding_ranges.rs b/crates/ra_ide/src/folding_ranges.rs
index 315808890..0fbc9babd 100644
--- a/crates/ra_ide/src/folding_ranges.rs
+++ b/crates/ra_ide/src/folding_ranges.rs
@@ -58,7 +58,7 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
58 } 58 }
59 NodeOrToken::Node(node) => { 59 NodeOrToken::Node(node) => {
60 // Fold groups of imports 60 // Fold groups of imports
61 if node.kind() == USE_ITEM && !visited_imports.contains(&node) { 61 if node.kind() == USE && !visited_imports.contains(&node) {
62 if let Some(range) = contiguous_range_for_group(&node, &mut visited_imports) { 62 if let Some(range) = contiguous_range_for_group(&node, &mut visited_imports) {
63 res.push(Fold { range, kind: FoldKind::Imports }) 63 res.push(Fold { range, kind: FoldKind::Imports })
64 } 64 }
@@ -83,17 +83,18 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
83fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> { 83fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
84 match kind { 84 match kind {
85 COMMENT => Some(FoldKind::Comment), 85 COMMENT => Some(FoldKind::Comment),
86 USE_ITEM => Some(FoldKind::Imports), 86 USE => Some(FoldKind::Imports),
87 ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList), 87 ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList),
88 RECORD_FIELD_DEF_LIST 88 ASSOC_ITEM_LIST
89 | RECORD_FIELD_PAT_LIST
90 | RECORD_FIELD_LIST 89 | RECORD_FIELD_LIST
90 | RECORD_PAT_FIELD_LIST
91 | RECORD_EXPR_FIELD_LIST
91 | ITEM_LIST 92 | ITEM_LIST
92 | EXTERN_ITEM_LIST 93 | EXTERN_ITEM_LIST
93 | USE_TREE_LIST 94 | USE_TREE_LIST
94 | BLOCK_EXPR 95 | BLOCK_EXPR
95 | MATCH_ARM_LIST 96 | MATCH_ARM_LIST
96 | ENUM_VARIANT_LIST 97 | VARIANT_LIST
97 | TOKEN_TREE => Some(FoldKind::Block), 98 | TOKEN_TREE => Some(FoldKind::Block),
98 _ => None, 99 _ => None,
99 } 100 }
@@ -337,6 +338,26 @@ fn main() <fold block>{
337 } 338 }
338 339
339 #[test] 340 #[test]
341 fn test_folds_structs() {
342 check(
343 r#"
344struct Foo <fold block>{
345}</fold>
346"#,
347 );
348 }
349
350 #[test]
351 fn test_folds_traits() {
352 check(
353 r#"
354trait Foo <fold block>{
355}</fold>
356"#,
357 );
358 }
359
360 #[test]
340 fn test_folds_macros() { 361 fn test_folds_macros() {
341 check( 362 check(
342 r#" 363 r#"
diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs
index 3ee048f28..9912b7142 100644
--- a/crates/ra_ide/src/goto_implementation.rs
+++ b/crates/ra_ide/src/goto_implementation.rs
@@ -23,12 +23,12 @@ pub(crate) fn goto_implementation(
23 23
24 let krate = sema.to_module_def(position.file_id)?.krate(); 24 let krate = sema.to_module_def(position.file_id)?.krate();
25 25
26 if let Some(nominal_def) = find_node_at_offset::<ast::NominalDef>(&syntax, position.offset) { 26 if let Some(nominal_def) = find_node_at_offset::<ast::AdtDef>(&syntax, position.offset) {
27 return Some(RangeInfo::new( 27 return Some(RangeInfo::new(
28 nominal_def.syntax().text_range(), 28 nominal_def.syntax().text_range(),
29 impls_for_def(&sema, &nominal_def, krate)?, 29 impls_for_def(&sema, &nominal_def, krate)?,
30 )); 30 ));
31 } else if let Some(trait_def) = find_node_at_offset::<ast::TraitDef>(&syntax, position.offset) { 31 } else if let Some(trait_def) = find_node_at_offset::<ast::Trait>(&syntax, position.offset) {
32 return Some(RangeInfo::new( 32 return Some(RangeInfo::new(
33 trait_def.syntax().text_range(), 33 trait_def.syntax().text_range(),
34 impls_for_trait(&sema, &trait_def, krate)?, 34 impls_for_trait(&sema, &trait_def, krate)?,
@@ -40,13 +40,13 @@ pub(crate) fn goto_implementation(
40 40
41fn impls_for_def( 41fn impls_for_def(
42 sema: &Semantics<RootDatabase>, 42 sema: &Semantics<RootDatabase>,
43 node: &ast::NominalDef, 43 node: &ast::AdtDef,
44 krate: Crate, 44 krate: Crate,
45) -> Option<Vec<NavigationTarget>> { 45) -> Option<Vec<NavigationTarget>> {
46 let ty = match node { 46 let ty = match node {
47 ast::NominalDef::StructDef(def) => sema.to_def(def)?.ty(sema.db), 47 ast::AdtDef::Struct(def) => sema.to_def(def)?.ty(sema.db),
48 ast::NominalDef::EnumDef(def) => sema.to_def(def)?.ty(sema.db), 48 ast::AdtDef::Enum(def) => sema.to_def(def)?.ty(sema.db),
49 ast::NominalDef::UnionDef(def) => sema.to_def(def)?.ty(sema.db), 49 ast::AdtDef::Union(def) => sema.to_def(def)?.ty(sema.db),
50 }; 50 };
51 51
52 let impls = ImplDef::all_in_crate(sema.db, krate); 52 let impls = ImplDef::all_in_crate(sema.db, krate);
@@ -62,7 +62,7 @@ fn impls_for_def(
62 62
63fn impls_for_trait( 63fn impls_for_trait(
64 sema: &Semantics<RootDatabase>, 64 sema: &Semantics<RootDatabase>,
65 node: &ast::TraitDef, 65 node: &ast::Trait,
66 krate: Crate, 66 krate: Crate,
67) -> Option<Vec<NavigationTarget>> { 67) -> Option<Vec<NavigationTarget>> {
68 let tr = sema.to_def(node)?; 68 let tr = sema.to_def(node)?;
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index d067c339d..aa48cb412 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -1361,7 +1361,7 @@ fn foo_<|>test() {}
1361 11..19, 1361 11..19,
1362 ), 1362 ),
1363 name: "foo_test", 1363 name: "foo_test",
1364 kind: FN_DEF, 1364 kind: FN,
1365 container_name: None, 1365 container_name: None,
1366 description: None, 1366 description: None,
1367 docs: None, 1367 docs: None,
@@ -1443,7 +1443,7 @@ fn main() { let s<|>t = S{ f1:0 }; }
1443 7..8, 1443 7..8,
1444 ), 1444 ),
1445 name: "S", 1445 name: "S",
1446 kind: STRUCT_DEF, 1446 kind: STRUCT,
1447 container_name: None, 1447 container_name: None,
1448 description: Some( 1448 description: Some(
1449 "struct S", 1449 "struct S",
@@ -1482,7 +1482,7 @@ fn main() { let s<|>t = S{ f1:Arg(0) }; }
1482 24..25, 1482 24..25,
1483 ), 1483 ),
1484 name: "S", 1484 name: "S",
1485 kind: STRUCT_DEF, 1485 kind: STRUCT,
1486 container_name: None, 1486 container_name: None,
1487 description: Some( 1487 description: Some(
1488 "struct S", 1488 "struct S",
@@ -1501,7 +1501,7 @@ fn main() { let s<|>t = S{ f1:Arg(0) }; }
1501 7..10, 1501 7..10,
1502 ), 1502 ),
1503 name: "Arg", 1503 name: "Arg",
1504 kind: STRUCT_DEF, 1504 kind: STRUCT,
1505 container_name: None, 1505 container_name: None,
1506 description: Some( 1506 description: Some(
1507 "struct Arg", 1507 "struct Arg",
@@ -1540,7 +1540,7 @@ fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; }
1540 24..25, 1540 24..25,
1541 ), 1541 ),
1542 name: "S", 1542 name: "S",
1543 kind: STRUCT_DEF, 1543 kind: STRUCT,
1544 container_name: None, 1544 container_name: None,
1545 description: Some( 1545 description: Some(
1546 "struct S", 1546 "struct S",
@@ -1559,7 +1559,7 @@ fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; }
1559 7..10, 1559 7..10,
1560 ), 1560 ),
1561 name: "Arg", 1561 name: "Arg",
1562 kind: STRUCT_DEF, 1562 kind: STRUCT,
1563 container_name: None, 1563 container_name: None,
1564 description: Some( 1564 description: Some(
1565 "struct Arg", 1565 "struct Arg",
@@ -1601,7 +1601,7 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); }
1601 7..8, 1601 7..8,
1602 ), 1602 ),
1603 name: "A", 1603 name: "A",
1604 kind: STRUCT_DEF, 1604 kind: STRUCT,
1605 container_name: None, 1605 container_name: None,
1606 description: Some( 1606 description: Some(
1607 "struct A", 1607 "struct A",
@@ -1620,7 +1620,7 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); }
1620 22..23, 1620 22..23,
1621 ), 1621 ),
1622 name: "B", 1622 name: "B",
1623 kind: STRUCT_DEF, 1623 kind: STRUCT,
1624 container_name: None, 1624 container_name: None,
1625 description: Some( 1625 description: Some(
1626 "struct B", 1626 "struct B",
@@ -1639,7 +1639,7 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); }
1639 53..54, 1639 53..54,
1640 ), 1640 ),
1641 name: "C", 1641 name: "C",
1642 kind: STRUCT_DEF, 1642 kind: STRUCT,
1643 container_name: None, 1643 container_name: None,
1644 description: Some( 1644 description: Some(
1645 "pub struct C", 1645 "pub struct C",
@@ -1678,7 +1678,7 @@ fn main() { let s<|>t = foo(); }
1678 6..9, 1678 6..9,
1679 ), 1679 ),
1680 name: "Foo", 1680 name: "Foo",
1681 kind: TRAIT_DEF, 1681 kind: TRAIT,
1682 container_name: None, 1682 container_name: None,
1683 description: Some( 1683 description: Some(
1684 "trait Foo", 1684 "trait Foo",
@@ -1718,7 +1718,7 @@ fn main() { let s<|>t = foo(); }
1718 6..9, 1718 6..9,
1719 ), 1719 ),
1720 name: "Foo", 1720 name: "Foo",
1721 kind: TRAIT_DEF, 1721 kind: TRAIT,
1722 container_name: None, 1722 container_name: None,
1723 description: Some( 1723 description: Some(
1724 "trait Foo", 1724 "trait Foo",
@@ -1737,7 +1737,7 @@ fn main() { let s<|>t = foo(); }
1737 23..24, 1737 23..24,
1738 ), 1738 ),
1739 name: "S", 1739 name: "S",
1740 kind: STRUCT_DEF, 1740 kind: STRUCT,
1741 container_name: None, 1741 container_name: None,
1742 description: Some( 1742 description: Some(
1743 "struct S", 1743 "struct S",
@@ -1777,7 +1777,7 @@ fn main() { let s<|>t = foo(); }
1777 6..9, 1777 6..9,
1778 ), 1778 ),
1779 name: "Foo", 1779 name: "Foo",
1780 kind: TRAIT_DEF, 1780 kind: TRAIT,
1781 container_name: None, 1781 container_name: None,
1782 description: Some( 1782 description: Some(
1783 "trait Foo", 1783 "trait Foo",
@@ -1796,7 +1796,7 @@ fn main() { let s<|>t = foo(); }
1796 19..22, 1796 19..22,
1797 ), 1797 ),
1798 name: "Bar", 1798 name: "Bar",
1799 kind: TRAIT_DEF, 1799 kind: TRAIT,
1800 container_name: None, 1800 container_name: None,
1801 description: Some( 1801 description: Some(
1802 "trait Bar", 1802 "trait Bar",
@@ -1839,7 +1839,7 @@ fn main() { let s<|>t = foo(); }
1839 6..9, 1839 6..9,
1840 ), 1840 ),
1841 name: "Foo", 1841 name: "Foo",
1842 kind: TRAIT_DEF, 1842 kind: TRAIT,
1843 container_name: None, 1843 container_name: None,
1844 description: Some( 1844 description: Some(
1845 "trait Foo", 1845 "trait Foo",
@@ -1858,7 +1858,7 @@ fn main() { let s<|>t = foo(); }
1858 22..25, 1858 22..25,
1859 ), 1859 ),
1860 name: "Bar", 1860 name: "Bar",
1861 kind: TRAIT_DEF, 1861 kind: TRAIT,
1862 container_name: None, 1862 container_name: None,
1863 description: Some( 1863 description: Some(
1864 "trait Bar", 1864 "trait Bar",
@@ -1877,7 +1877,7 @@ fn main() { let s<|>t = foo(); }
1877 39..41, 1877 39..41,
1878 ), 1878 ),
1879 name: "S1", 1879 name: "S1",
1880 kind: STRUCT_DEF, 1880 kind: STRUCT,
1881 container_name: None, 1881 container_name: None,
1882 description: Some( 1882 description: Some(
1883 "struct S1", 1883 "struct S1",
@@ -1896,7 +1896,7 @@ fn main() { let s<|>t = foo(); }
1896 52..54, 1896 52..54,
1897 ), 1897 ),
1898 name: "S2", 1898 name: "S2",
1899 kind: STRUCT_DEF, 1899 kind: STRUCT,
1900 container_name: None, 1900 container_name: None,
1901 description: Some( 1901 description: Some(
1902 "struct S2", 1902 "struct S2",
@@ -1933,7 +1933,7 @@ fn foo(ar<|>g: &impl Foo) {}
1933 6..9, 1933 6..9,
1934 ), 1934 ),
1935 name: "Foo", 1935 name: "Foo",
1936 kind: TRAIT_DEF, 1936 kind: TRAIT,
1937 container_name: None, 1937 container_name: None,
1938 description: Some( 1938 description: Some(
1939 "trait Foo", 1939 "trait Foo",
@@ -1973,7 +1973,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
1973 6..9, 1973 6..9,
1974 ), 1974 ),
1975 name: "Foo", 1975 name: "Foo",
1976 kind: TRAIT_DEF, 1976 kind: TRAIT,
1977 container_name: None, 1977 container_name: None,
1978 description: Some( 1978 description: Some(
1979 "trait Foo", 1979 "trait Foo",
@@ -1992,7 +1992,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
1992 19..22, 1992 19..22,
1993 ), 1993 ),
1994 name: "Bar", 1994 name: "Bar",
1995 kind: TRAIT_DEF, 1995 kind: TRAIT,
1996 container_name: None, 1996 container_name: None,
1997 description: Some( 1997 description: Some(
1998 "trait Bar", 1998 "trait Bar",
@@ -2011,7 +2011,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
2011 36..37, 2011 36..37,
2012 ), 2012 ),
2013 name: "S", 2013 name: "S",
2014 kind: STRUCT_DEF, 2014 kind: STRUCT,
2015 container_name: None, 2015 container_name: None,
2016 description: Some( 2016 description: Some(
2017 "struct S", 2017 "struct S",
@@ -2049,7 +2049,7 @@ fn foo(ar<|>g: &impl Foo<S>) {}
2049 6..9, 2049 6..9,
2050 ), 2050 ),
2051 name: "Foo", 2051 name: "Foo",
2052 kind: TRAIT_DEF, 2052 kind: TRAIT,
2053 container_name: None, 2053 container_name: None,
2054 description: Some( 2054 description: Some(
2055 "trait Foo", 2055 "trait Foo",
@@ -2068,7 +2068,7 @@ fn foo(ar<|>g: &impl Foo<S>) {}
2068 23..24, 2068 23..24,
2069 ), 2069 ),
2070 name: "S", 2070 name: "S",
2071 kind: STRUCT_DEF, 2071 kind: STRUCT,
2072 container_name: None, 2072 container_name: None,
2073 description: Some( 2073 description: Some(
2074 "struct S", 2074 "struct S",
@@ -2111,7 +2111,7 @@ fn main() { let s<|>t = foo(); }
2111 49..50, 2111 49..50,
2112 ), 2112 ),
2113 name: "B", 2113 name: "B",
2114 kind: STRUCT_DEF, 2114 kind: STRUCT,
2115 container_name: None, 2115 container_name: None,
2116 description: Some( 2116 description: Some(
2117 "struct B", 2117 "struct B",
@@ -2130,7 +2130,7 @@ fn main() { let s<|>t = foo(); }
2130 6..9, 2130 6..9,
2131 ), 2131 ),
2132 name: "Foo", 2132 name: "Foo",
2133 kind: TRAIT_DEF, 2133 kind: TRAIT,
2134 container_name: None, 2134 container_name: None,
2135 description: Some( 2135 description: Some(
2136 "trait Foo", 2136 "trait Foo",
@@ -2167,7 +2167,7 @@ fn foo(ar<|>g: &dyn Foo) {}
2167 6..9, 2167 6..9,
2168 ), 2168 ),
2169 name: "Foo", 2169 name: "Foo",
2170 kind: TRAIT_DEF, 2170 kind: TRAIT,
2171 container_name: None, 2171 container_name: None,
2172 description: Some( 2172 description: Some(
2173 "trait Foo", 2173 "trait Foo",
@@ -2205,7 +2205,7 @@ fn foo(ar<|>g: &dyn Foo<S>) {}
2205 6..9, 2205 6..9,
2206 ), 2206 ),
2207 name: "Foo", 2207 name: "Foo",
2208 kind: TRAIT_DEF, 2208 kind: TRAIT,
2209 container_name: None, 2209 container_name: None,
2210 description: Some( 2210 description: Some(
2211 "trait Foo", 2211 "trait Foo",
@@ -2224,7 +2224,7 @@ fn foo(ar<|>g: &dyn Foo<S>) {}
2224 23..24, 2224 23..24,
2225 ), 2225 ),
2226 name: "S", 2226 name: "S",
2227 kind: STRUCT_DEF, 2227 kind: STRUCT,
2228 container_name: None, 2228 container_name: None,
2229 description: Some( 2229 description: Some(
2230 "struct S", 2230 "struct S",
@@ -2265,7 +2265,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
2265 6..15, 2265 6..15,
2266 ), 2266 ),
2267 name: "ImplTrait", 2267 name: "ImplTrait",
2268 kind: TRAIT_DEF, 2268 kind: TRAIT,
2269 container_name: None, 2269 container_name: None,
2270 description: Some( 2270 description: Some(
2271 "trait ImplTrait", 2271 "trait ImplTrait",
@@ -2284,7 +2284,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
2284 50..51, 2284 50..51,
2285 ), 2285 ),
2286 name: "B", 2286 name: "B",
2287 kind: STRUCT_DEF, 2287 kind: STRUCT,
2288 container_name: None, 2288 container_name: None,
2289 description: Some( 2289 description: Some(
2290 "struct B", 2290 "struct B",
@@ -2303,7 +2303,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
2303 28..36, 2303 28..36,
2304 ), 2304 ),
2305 name: "DynTrait", 2305 name: "DynTrait",
2306 kind: TRAIT_DEF, 2306 kind: TRAIT,
2307 container_name: None, 2307 container_name: None,
2308 description: Some( 2308 description: Some(
2309 "trait DynTrait", 2309 "trait DynTrait",
@@ -2322,7 +2322,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
2322 65..66, 2322 65..66,
2323 ), 2323 ),
2324 name: "S", 2324 name: "S",
2325 kind: STRUCT_DEF, 2325 kind: STRUCT,
2326 container_name: None, 2326 container_name: None,
2327 description: Some( 2327 description: Some(
2328 "struct S", 2328 "struct S",
@@ -2370,7 +2370,7 @@ fn main() { let s<|>t = test().get(); }
2370 6..9, 2370 6..9,
2371 ), 2371 ),
2372 name: "Foo", 2372 name: "Foo",
2373 kind: TRAIT_DEF, 2373 kind: TRAIT,
2374 container_name: None, 2374 container_name: None,
2375 description: Some( 2375 description: Some(
2376 "trait Foo", 2376 "trait Foo",
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index f2e4f7ee5..1bacead63 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -2,7 +2,7 @@ use hir::{Adt, Callable, HirDisplay, Semantics, Type};
2use ra_ide_db::RootDatabase; 2use ra_ide_db::RootDatabase;
3use ra_prof::profile; 3use ra_prof::profile;
4use ra_syntax::{ 4use ra_syntax::{
5 ast::{self, ArgListOwner, AstNode, TypeAscriptionOwner}, 5 ast::{self, ArgListOwner, AstNode},
6 match_ast, Direction, NodeOrToken, SmolStr, SyntaxKind, TextRange, T, 6 match_ast, Direction, NodeOrToken, SmolStr, SyntaxKind, TextRange, T,
7}; 7};
8use stdx::to_lower_snake_case; 8use stdx::to_lower_snake_case;
@@ -78,7 +78,7 @@ pub(crate) fn inlay_hints(
78 match node { 78 match node {
79 ast::CallExpr(it) => { get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it)); }, 79 ast::CallExpr(it) => { get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it)); },
80 ast::MethodCallExpr(it) => { get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it)); }, 80 ast::MethodCallExpr(it) => { get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it)); },
81 ast::BindPat(it) => { get_bind_pat_hints(&mut res, &sema, config, it); }, 81 ast::IdentPat(it) => { get_bind_pat_hints(&mut res, &sema, config, it); },
82 _ => (), 82 _ => (),
83 } 83 }
84 } 84 }
@@ -96,7 +96,7 @@ fn get_chaining_hints(
96 return None; 96 return None;
97 } 97 }
98 98
99 if matches!(expr, ast::Expr::RecordLit(_)) { 99 if matches!(expr, ast::Expr::RecordExpr(_)) {
100 return None; 100 return None;
101 } 101 }
102 102
@@ -161,7 +161,7 @@ fn get_param_name_hints(
161 Either::Left(self_param) => Some((self_param.to_string(), arg)), 161 Either::Left(self_param) => Some((self_param.to_string(), arg)),
162 Either::Right(pat) => { 162 Either::Right(pat) => {
163 let param_name = match pat { 163 let param_name = match pat {
164 ast::Pat::BindPat(it) => it.name()?.to_string(), 164 ast::Pat::IdentPat(it) => it.name()?.to_string(),
165 it => it.to_string(), 165 it => it.to_string(),
166 }; 166 };
167 Some((param_name, arg)) 167 Some((param_name, arg))
@@ -182,7 +182,7 @@ fn get_bind_pat_hints(
182 acc: &mut Vec<InlayHint>, 182 acc: &mut Vec<InlayHint>,
183 sema: &Semantics<RootDatabase>, 183 sema: &Semantics<RootDatabase>,
184 config: &InlayHintsConfig, 184 config: &InlayHintsConfig,
185 pat: ast::BindPat, 185 pat: ast::IdentPat,
186) -> Option<()> { 186) -> Option<()> {
187 if !config.type_hints { 187 if !config.type_hints {
188 return None; 188 return None;
@@ -202,7 +202,7 @@ fn get_bind_pat_hints(
202 Some(()) 202 Some(())
203} 203}
204 204
205fn pat_is_enum_variant(db: &RootDatabase, bind_pat: &ast::BindPat, pat_ty: &Type) -> bool { 205fn pat_is_enum_variant(db: &RootDatabase, bind_pat: &ast::IdentPat, pat_ty: &Type) -> bool {
206 if let Some(Adt::Enum(enum_data)) = pat_ty.as_adt() { 206 if let Some(Adt::Enum(enum_data)) = pat_ty.as_adt() {
207 let pat_text = bind_pat.to_string(); 207 let pat_text = bind_pat.to_string();
208 enum_data 208 enum_data
@@ -215,7 +215,11 @@ fn pat_is_enum_variant(db: &RootDatabase, bind_pat: &ast::BindPat, pat_ty: &Type
215 } 215 }
216} 216}
217 217
218fn should_not_display_type_hint(db: &RootDatabase, bind_pat: &ast::BindPat, pat_ty: &Type) -> bool { 218fn should_not_display_type_hint(
219 db: &RootDatabase,
220 bind_pat: &ast::IdentPat,
221 pat_ty: &Type,
222) -> bool {
219 if pat_ty.is_unknown() { 223 if pat_ty.is_unknown() {
220 return true; 224 return true;
221 } 225 }
@@ -230,10 +234,10 @@ fn should_not_display_type_hint(db: &RootDatabase, bind_pat: &ast::BindPat, pat_
230 match_ast! { 234 match_ast! {
231 match node { 235 match node {
232 ast::LetStmt(it) => { 236 ast::LetStmt(it) => {
233 return it.ascribed_type().is_some() 237 return it.ty().is_some()
234 }, 238 },
235 ast::Param(it) => { 239 ast::Param(it) => {
236 return it.ascribed_type().is_some() 240 return it.ty().is_some()
237 }, 241 },
238 ast::MatchArm(_it) => { 242 ast::MatchArm(_it) => {
239 return pat_is_enum_variant(db, bind_pat, pat_ty); 243 return pat_is_enum_variant(db, bind_pat, pat_ty);
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 4c4d9f6fa..0fede0d87 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -510,9 +510,10 @@ impl Analysis {
510 query: &str, 510 query: &str,
511 parse_only: bool, 511 parse_only: bool,
512 position: FilePosition, 512 position: FilePosition,
513 selections: Vec<FileRange>,
513 ) -> Cancelable<Result<SourceChange, SsrError>> { 514 ) -> Cancelable<Result<SourceChange, SsrError>> {
514 self.with_db(|db| { 515 self.with_db(|db| {
515 let edits = ssr::parse_search_replace(query, parse_only, db, position)?; 516 let edits = ssr::parse_search_replace(query, parse_only, db, position, selections)?;
516 Ok(SourceChange::from(edits)) 517 Ok(SourceChange::from(edits))
517 }) 518 })
518 } 519 }
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs
index fe1c074d1..cf456630a 100644
--- a/crates/ra_ide/src/references.rs
+++ b/crates/ra_ide/src/references.rs
@@ -150,7 +150,7 @@ fn decl_access(def: &Definition, syntax: &SyntaxNode, range: TextRange) -> Optio
150 let stmt = find_node_at_offset::<ast::LetStmt>(syntax, range.start())?; 150 let stmt = find_node_at_offset::<ast::LetStmt>(syntax, range.start())?;
151 if stmt.initializer().is_some() { 151 if stmt.initializer().is_some() {
152 let pat = stmt.pat()?; 152 let pat = stmt.pat()?;
153 if let ast::Pat::BindPat(it) = pat { 153 if let ast::Pat::IdentPat(it) = pat {
154 if it.mut_token().is_some() { 154 if it.mut_token().is_some() {
155 return Some(ReferenceAccess::Write); 155 return Some(ReferenceAccess::Write);
156 } 156 }
@@ -172,16 +172,16 @@ fn get_struct_def_name_for_struct_literal_search(
172 if let Some(name) = 172 if let Some(name) =
173 sema.find_node_at_offset_with_descend::<ast::Name>(&syntax, left.text_range().start()) 173 sema.find_node_at_offset_with_descend::<ast::Name>(&syntax, left.text_range().start())
174 { 174 {
175 return name.syntax().ancestors().find_map(ast::StructDef::cast).and_then(|l| l.name()); 175 return name.syntax().ancestors().find_map(ast::Struct::cast).and_then(|l| l.name());
176 } 176 }
177 if sema 177 if sema
178 .find_node_at_offset_with_descend::<ast::TypeParamList>( 178 .find_node_at_offset_with_descend::<ast::GenericParamList>(
179 &syntax, 179 &syntax,
180 left.text_range().start(), 180 left.text_range().start(),
181 ) 181 )
182 .is_some() 182 .is_some()
183 { 183 {
184 return left.ancestors().find_map(ast::StructDef::cast).and_then(|l| l.name()); 184 return left.ancestors().find_map(ast::Struct::cast).and_then(|l| l.name());
185 } 185 }
186 } 186 }
187 None 187 None
@@ -212,7 +212,7 @@ fn main() {
212 ); 212 );
213 check_result( 213 check_result(
214 refs, 214 refs,
215 "Foo STRUCT_DEF FileId(1) 0..26 7..10 Other", 215 "Foo STRUCT FileId(1) 0..26 7..10 Other",
216 &["FileId(1) 101..104 StructLiteral"], 216 &["FileId(1) 101..104 StructLiteral"],
217 ); 217 );
218 } 218 }
@@ -230,7 +230,7 @@ struct Foo<|> {}
230 ); 230 );
231 check_result( 231 check_result(
232 refs, 232 refs,
233 "Foo STRUCT_DEF FileId(1) 0..13 7..10 Other", 233 "Foo STRUCT FileId(1) 0..13 7..10 Other",
234 &["FileId(1) 41..44 Other", "FileId(1) 54..57 StructLiteral"], 234 &["FileId(1) 41..44 Other", "FileId(1) 54..57 StructLiteral"],
235 ); 235 );
236 } 236 }
@@ -248,7 +248,7 @@ struct Foo<T> <|>{}
248 ); 248 );
249 check_result( 249 check_result(
250 refs, 250 refs,
251 "Foo STRUCT_DEF FileId(1) 0..16 7..10 Other", 251 "Foo STRUCT FileId(1) 0..16 7..10 Other",
252 &["FileId(1) 64..67 StructLiteral"], 252 &["FileId(1) 64..67 StructLiteral"],
253 ); 253 );
254 } 254 }
@@ -267,7 +267,7 @@ fn main() {
267 ); 267 );
268 check_result( 268 check_result(
269 refs, 269 refs,
270 "Foo STRUCT_DEF FileId(1) 0..16 7..10 Other", 270 "Foo STRUCT FileId(1) 0..16 7..10 Other",
271 &["FileId(1) 54..57 StructLiteral"], 271 &["FileId(1) 54..57 StructLiteral"],
272 ); 272 );
273 } 273 }
@@ -290,7 +290,7 @@ fn main() {
290 ); 290 );
291 check_result( 291 check_result(
292 refs, 292 refs,
293 "i BIND_PAT FileId(1) 24..25 Other Write", 293 "i IDENT_PAT FileId(1) 24..25 Other Write",
294 &[ 294 &[
295 "FileId(1) 50..51 Other Write", 295 "FileId(1) 50..51 Other Write",
296 "FileId(1) 54..55 Other Read", 296 "FileId(1) 54..55 Other Read",
@@ -316,7 +316,7 @@ fn bar() {
316 ); 316 );
317 check_result( 317 check_result(
318 refs, 318 refs,
319 "spam BIND_PAT FileId(1) 19..23 Other", 319 "spam IDENT_PAT FileId(1) 19..23 Other",
320 &["FileId(1) 34..38 Other Read", "FileId(1) 41..45 Other Read"], 320 &["FileId(1) 34..38 Other Read", "FileId(1) 41..45 Other Read"],
321 ); 321 );
322 } 322 }
@@ -330,7 +330,7 @@ fn foo(i : u32) -> u32 {
330} 330}
331"#, 331"#,
332 ); 332 );
333 check_result(refs, "i BIND_PAT FileId(1) 7..8 Other", &["FileId(1) 29..30 Other Read"]); 333 check_result(refs, "i IDENT_PAT FileId(1) 7..8 Other", &["FileId(1) 29..30 Other Read"]);
334 } 334 }
335 335
336 #[test] 336 #[test]
@@ -342,7 +342,7 @@ fn foo(i<|> : u32) -> u32 {
342} 342}
343"#, 343"#,
344 ); 344 );
345 check_result(refs, "i BIND_PAT FileId(1) 7..8 Other", &["FileId(1) 29..30 Other Read"]); 345 check_result(refs, "i IDENT_PAT FileId(1) 7..8 Other", &["FileId(1) 29..30 Other Read"]);
346 } 346 }
347 347
348 #[test] 348 #[test]
@@ -361,7 +361,7 @@ fn main(s: Foo) {
361 ); 361 );
362 check_result( 362 check_result(
363 refs, 363 refs,
364 "spam RECORD_FIELD_DEF FileId(1) 17..30 21..25 Other", 364 "spam RECORD_FIELD FileId(1) 17..30 21..25 Other",
365 &["FileId(1) 67..71 Other Read"], 365 &["FileId(1) 67..71 Other Read"],
366 ); 366 );
367 } 367 }
@@ -376,7 +376,7 @@ impl Foo {
376} 376}
377"#, 377"#,
378 ); 378 );
379 check_result(refs, "f FN_DEF FileId(1) 27..43 30..31 Other", &[]); 379 check_result(refs, "f FN FileId(1) 27..43 30..31 Other", &[]);
380 } 380 }
381 381
382 #[test] 382 #[test]
@@ -390,7 +390,7 @@ enum Foo {
390} 390}
391"#, 391"#,
392 ); 392 );
393 check_result(refs, "B ENUM_VARIANT FileId(1) 22..23 22..23 Other", &[]); 393 check_result(refs, "B VARIANT FileId(1) 22..23 22..23 Other", &[]);
394 } 394 }
395 395
396 #[test] 396 #[test]
@@ -431,7 +431,7 @@ fn f() {
431 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); 431 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
432 check_result( 432 check_result(
433 refs, 433 refs,
434 "Foo STRUCT_DEF FileId(2) 17..51 28..31 Other", 434 "Foo STRUCT FileId(2) 17..51 28..31 Other",
435 &["FileId(1) 53..56 StructLiteral", "FileId(3) 79..82 StructLiteral"], 435 &["FileId(1) 53..56 StructLiteral", "FileId(3) 79..82 StructLiteral"],
436 ); 436 );
437 } 437 }
@@ -486,7 +486,7 @@ pub(super) struct Foo<|> {
486 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); 486 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
487 check_result( 487 check_result(
488 refs, 488 refs,
489 "Foo STRUCT_DEF FileId(3) 0..41 18..21 Other", 489 "Foo STRUCT FileId(3) 0..41 18..21 Other",
490 &["FileId(2) 20..23 Other", "FileId(2) 47..50 StructLiteral"], 490 &["FileId(2) 20..23 Other", "FileId(2) 47..50 StructLiteral"],
491 ); 491 );
492 } 492 }
@@ -514,7 +514,7 @@ pub(super) struct Foo<|> {
514 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); 514 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
515 check_result( 515 check_result(
516 refs, 516 refs,
517 "quux FN_DEF FileId(1) 19..35 26..30 Other", 517 "quux FN FileId(1) 19..35 26..30 Other",
518 &["FileId(2) 16..20 StructLiteral", "FileId(3) 16..20 StructLiteral"], 518 &["FileId(2) 16..20 StructLiteral", "FileId(3) 16..20 StructLiteral"],
519 ); 519 );
520 520
@@ -522,7 +522,7 @@ pub(super) struct Foo<|> {
522 analysis.find_all_refs(pos, Some(SearchScope::single_file(bar))).unwrap().unwrap(); 522 analysis.find_all_refs(pos, Some(SearchScope::single_file(bar))).unwrap().unwrap();
523 check_result( 523 check_result(
524 refs, 524 refs,
525 "quux FN_DEF FileId(1) 19..35 26..30 Other", 525 "quux FN FileId(1) 19..35 26..30 Other",
526 &["FileId(3) 16..20 StructLiteral"], 526 &["FileId(3) 16..20 StructLiteral"],
527 ); 527 );
528 } 528 }
@@ -559,7 +559,7 @@ fn foo() {
559 ); 559 );
560 check_result( 560 check_result(
561 refs, 561 refs,
562 "i BIND_PAT FileId(1) 23..24 Other Write", 562 "i IDENT_PAT FileId(1) 23..24 Other Write",
563 &["FileId(1) 34..35 Other Write", "FileId(1) 38..39 Other Read"], 563 &["FileId(1) 34..35 Other Write", "FileId(1) 38..39 Other Read"],
564 ); 564 );
565 } 565 }
@@ -580,7 +580,7 @@ fn foo() {
580 ); 580 );
581 check_result( 581 check_result(
582 refs, 582 refs,
583 "f RECORD_FIELD_DEF FileId(1) 15..21 15..16 Other", 583 "f RECORD_FIELD FileId(1) 15..21 15..16 Other",
584 &["FileId(1) 55..56 Other Read", "FileId(1) 68..69 Other Write"], 584 &["FileId(1) 55..56 Other Read", "FileId(1) 68..69 Other Write"],
585 ); 585 );
586 } 586 }
@@ -595,7 +595,7 @@ fn foo() {
595} 595}
596"#, 596"#,
597 ); 597 );
598 check_result(refs, "i BIND_PAT FileId(1) 19..20 Other", &["FileId(1) 26..27 Other Write"]); 598 check_result(refs, "i IDENT_PAT FileId(1) 19..20 Other", &["FileId(1) 26..27 Other Write"]);
599 } 599 }
600 600
601 #[test] 601 #[test]
@@ -619,7 +619,7 @@ fn main() {
619 ); 619 );
620 check_result( 620 check_result(
621 refs, 621 refs,
622 "new FN_DEF FileId(1) 54..101 61..64 Other", 622 "new FN FileId(1) 54..101 61..64 Other",
623 &["FileId(1) 146..149 StructLiteral"], 623 &["FileId(1) 146..149 StructLiteral"],
624 ); 624 );
625 } 625 }
@@ -646,7 +646,7 @@ fn main() {
646 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); 646 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
647 check_result( 647 check_result(
648 refs, 648 refs,
649 "f FN_DEF FileId(1) 26..35 29..30 Other", 649 "f FN FileId(1) 26..35 29..30 Other",
650 &["FileId(2) 11..12 Other", "FileId(2) 28..29 StructLiteral"], 650 &["FileId(2) 11..12 Other", "FileId(2) 28..29 StructLiteral"],
651 ); 651 );
652 } 652 }
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs
index 8735ec53c..c8d80fcf7 100644
--- a/crates/ra_ide/src/references/rename.rs
+++ b/crates/ra_ide/src/references/rename.rs
@@ -7,7 +7,8 @@ use ra_ide_db::{
7 RootDatabase, 7 RootDatabase,
8}; 8};
9use ra_syntax::{ 9use ra_syntax::{
10 algo::find_node_at_offset, ast, ast::NameOwner, ast::TypeAscriptionOwner, 10 algo::find_node_at_offset,
11 ast::{self, NameOwner},
11 lex_single_valid_syntax_kind, match_ast, AstNode, SyntaxKind, SyntaxNode, SyntaxToken, 12 lex_single_valid_syntax_kind, match_ast, AstNode, SyntaxKind, SyntaxNode, SyntaxToken,
12}; 13};
13use ra_text_edit::TextEdit; 14use ra_text_edit::TextEdit;
@@ -149,14 +150,14 @@ fn rename_to_self(
149 let source_file = sema.parse(position.file_id); 150 let source_file = sema.parse(position.file_id);
150 let syn = source_file.syntax(); 151 let syn = source_file.syntax();
151 152
152 let fn_def = find_node_at_offset::<ast::FnDef>(syn, position.offset)?; 153 let fn_def = find_node_at_offset::<ast::Fn>(syn, position.offset)?;
153 let params = fn_def.param_list()?; 154 let params = fn_def.param_list()?;
154 if params.self_param().is_some() { 155 if params.self_param().is_some() {
155 return None; // method already has self param 156 return None; // method already has self param
156 } 157 }
157 let first_param = params.params().next()?; 158 let first_param = params.params().next()?;
158 let mutable = match first_param.ascribed_type() { 159 let mutable = match first_param.ty() {
159 Some(ast::TypeRef::ReferenceType(rt)) => rt.mut_token().is_some(), 160 Some(ast::Type::RefType(rt)) => rt.mut_token().is_some(),
160 _ => return None, // not renaming other types 161 _ => return None, // not renaming other types
161 }; 162 };
162 163
@@ -192,15 +193,14 @@ fn text_edit_from_self_param(
192 self_param: &ast::SelfParam, 193 self_param: &ast::SelfParam,
193 new_name: &str, 194 new_name: &str,
194) -> Option<TextEdit> { 195) -> Option<TextEdit> {
195 fn target_type_name(impl_def: &ast::ImplDef) -> Option<String> { 196 fn target_type_name(impl_def: &ast::Impl) -> Option<String> {
196 if let Some(ast::TypeRef::PathType(p)) = impl_def.target_type() { 197 if let Some(ast::Type::PathType(p)) = impl_def.self_ty() {
197 return Some(p.path()?.segment()?.name_ref()?.text().to_string()); 198 return Some(p.path()?.segment()?.name_ref()?.text().to_string());
198 } 199 }
199 None 200 None
200 } 201 }
201 202
202 let impl_def = 203 let impl_def = find_node_at_offset::<ast::Impl>(syn, self_param.syntax().text_range().start())?;
203 find_node_at_offset::<ast::ImplDef>(syn, self_param.syntax().text_range().start())?;
204 let type_name = target_type_name(&impl_def)?; 204 let type_name = target_type_name(&impl_def)?;
205 205
206 let mut replacement_text = String::from(new_name); 206 let mut replacement_text = String::from(new_name);
@@ -221,7 +221,7 @@ fn rename_self_to_param(
221 let syn = source_file.syntax(); 221 let syn = source_file.syntax();
222 222
223 let text = sema.db.file_text(position.file_id); 223 let text = sema.db.file_text(position.file_id);
224 let fn_def = find_node_at_offset::<ast::FnDef>(syn, position.offset)?; 224 let fn_def = find_node_at_offset::<ast::Fn>(syn, position.offset)?;
225 let search_range = fn_def.syntax().text_range(); 225 let search_range = fn_def.syntax().text_range();
226 226
227 let mut edits: Vec<SourceFileEdit> = vec![]; 227 let mut edits: Vec<SourceFileEdit> = vec![];
diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs
index 95a35a28d..3b7162b84 100644
--- a/crates/ra_ide/src/runnables.rs
+++ b/crates/ra_ide/src/runnables.rs
@@ -102,7 +102,7 @@ pub(crate) fn runnable(
102) -> Option<Runnable> { 102) -> Option<Runnable> {
103 match_ast! { 103 match_ast! {
104 match item { 104 match item {
105 ast::FnDef(it) => runnable_fn(sema, it, file_id), 105 ast::Fn(it) => runnable_fn(sema, it, file_id),
106 ast::Module(it) => runnable_mod(sema, it, file_id), 106 ast::Module(it) => runnable_mod(sema, it, file_id),
107 _ => None, 107 _ => None,
108 } 108 }
@@ -111,7 +111,7 @@ pub(crate) fn runnable(
111 111
112fn runnable_fn( 112fn runnable_fn(
113 sema: &Semantics<RootDatabase>, 113 sema: &Semantics<RootDatabase>,
114 fn_def: ast::FnDef, 114 fn_def: ast::Fn,
115 file_id: FileId, 115 file_id: FileId,
116) -> Option<Runnable> { 116) -> Option<Runnable> {
117 let name_string = fn_def.name()?.text().to_string(); 117 let name_string = fn_def.name()?.text().to_string();
@@ -188,7 +188,7 @@ pub struct TestAttr {
188} 188}
189 189
190impl TestAttr { 190impl TestAttr {
191 fn from_fn(fn_def: &ast::FnDef) -> TestAttr { 191 fn from_fn(fn_def: &ast::Fn) -> TestAttr {
192 let ignore = fn_def 192 let ignore = fn_def
193 .attrs() 193 .attrs()
194 .filter_map(|attr| attr.simple_name()) 194 .filter_map(|attr| attr.simple_name())
@@ -203,7 +203,7 @@ impl TestAttr {
203/// 203///
204/// It may produce false positives, for example, `#[wasm_bindgen_test]` requires a different command to run the test, 204/// It may produce false positives, for example, `#[wasm_bindgen_test]` requires a different command to run the test,
205/// but it's better than not to have the runnables for the tests at all. 205/// but it's better than not to have the runnables for the tests at all.
206fn has_test_related_attribute(fn_def: &ast::FnDef) -> bool { 206fn has_test_related_attribute(fn_def: &ast::Fn) -> bool {
207 fn_def 207 fn_def
208 .attrs() 208 .attrs()
209 .filter_map(|attr| attr.path()) 209 .filter_map(|attr| attr.path())
@@ -211,7 +211,7 @@ fn has_test_related_attribute(fn_def: &ast::FnDef) -> bool {
211 .any(|attribute_text| attribute_text.contains("test")) 211 .any(|attribute_text| attribute_text.contains("test"))
212} 212}
213 213
214fn has_doc_test(fn_def: &ast::FnDef) -> bool { 214fn has_doc_test(fn_def: &ast::Fn) -> bool {
215 fn_def.doc_comment_text().map_or(false, |comment| comment.contains("```")) 215 fn_def.doc_comment_text().map_or(false, |comment| comment.contains("```"))
216} 216}
217 217
@@ -220,15 +220,7 @@ fn runnable_mod(
220 module: ast::Module, 220 module: ast::Module,
221 file_id: FileId, 221 file_id: FileId,
222) -> Option<Runnable> { 222) -> Option<Runnable> {
223 let has_test_function = module 223 if !has_test_function_or_multiple_test_submodules(&module) {
224 .item_list()?
225 .items()
226 .filter_map(|it| match it {
227 ast::ModuleItem::FnDef(it) => Some(it),
228 _ => None,
229 })
230 .any(|f| has_test_related_attribute(&f));
231 if !has_test_function {
232 return None; 224 return None;
233 } 225 }
234 let module_def = sema.to_def(&module)?; 226 let module_def = sema.to_def(&module)?;
@@ -246,6 +238,34 @@ fn runnable_mod(
246 Some(Runnable { nav, kind: RunnableKind::TestMod { path }, cfg_exprs }) 238 Some(Runnable { nav, kind: RunnableKind::TestMod { path }, cfg_exprs })
247} 239}
248 240
241// We could create runnables for modules with number_of_test_submodules > 0,
242// but that bloats the runnables for no real benefit, since all tests can be run by the submodule already
243fn has_test_function_or_multiple_test_submodules(module: &ast::Module) -> bool {
244 if let Some(item_list) = module.item_list() {
245 let mut number_of_test_submodules = 0;
246
247 for item in item_list.items() {
248 match item {
249 ast::Item::Fn(f) => {
250 if has_test_related_attribute(&f) {
251 return true;
252 }
253 }
254 ast::Item::Module(submodule) => {
255 if has_test_function_or_multiple_test_submodules(&submodule) {
256 number_of_test_submodules += 1;
257 }
258 }
259 _ => (),
260 }
261 }
262
263 number_of_test_submodules > 1
264 } else {
265 false
266 }
267}
268
249#[cfg(test)] 269#[cfg(test)]
250mod tests { 270mod tests {
251 use expect::{expect, Expect}; 271 use expect::{expect, Expect};
@@ -300,7 +320,7 @@ fn bench() {}
300 4..8, 320 4..8,
301 ), 321 ),
302 name: "main", 322 name: "main",
303 kind: FN_DEF, 323 kind: FN,
304 container_name: None, 324 container_name: None,
305 description: None, 325 description: None,
306 docs: None, 326 docs: None,
@@ -318,7 +338,7 @@ fn bench() {}
318 26..34, 338 26..34,
319 ), 339 ),
320 name: "test_foo", 340 name: "test_foo",
321 kind: FN_DEF, 341 kind: FN,
322 container_name: None, 342 container_name: None,
323 description: None, 343 description: None,
324 docs: None, 344 docs: None,
@@ -343,7 +363,7 @@ fn bench() {}
343 62..70, 363 62..70,
344 ), 364 ),
345 name: "test_foo", 365 name: "test_foo",
346 kind: FN_DEF, 366 kind: FN,
347 container_name: None, 367 container_name: None,
348 description: None, 368 description: None,
349 docs: None, 369 docs: None,
@@ -368,7 +388,7 @@ fn bench() {}
368 89..94, 388 89..94,
369 ), 389 ),
370 name: "bench", 390 name: "bench",
371 kind: FN_DEF, 391 kind: FN,
372 container_name: None, 392 container_name: None,
373 description: None, 393 description: None,
374 docs: None, 394 docs: None,
@@ -411,7 +431,7 @@ fn foo() {}
411 4..8, 431 4..8,
412 ), 432 ),
413 name: "main", 433 name: "main",
414 kind: FN_DEF, 434 kind: FN,
415 container_name: None, 435 container_name: None,
416 description: None, 436 description: None,
417 docs: None, 437 docs: None,
@@ -427,7 +447,7 @@ fn foo() {}
427 full_range: 15..57, 447 full_range: 15..57,
428 focus_range: None, 448 focus_range: None,
429 name: "foo", 449 name: "foo",
430 kind: FN_DEF, 450 kind: FN,
431 container_name: None, 451 container_name: None,
432 description: None, 452 description: None,
433 docs: None, 453 docs: None,
@@ -473,7 +493,7 @@ impl Data {
473 4..8, 493 4..8,
474 ), 494 ),
475 name: "main", 495 name: "main",
476 kind: FN_DEF, 496 kind: FN,
477 container_name: None, 497 container_name: None,
478 description: None, 498 description: None,
479 docs: None, 499 docs: None,
@@ -489,7 +509,7 @@ impl Data {
489 full_range: 44..98, 509 full_range: 44..98,
490 focus_range: None, 510 focus_range: None,
491 name: "foo", 511 name: "foo",
492 kind: FN_DEF, 512 kind: FN,
493 container_name: None, 513 container_name: None,
494 description: None, 514 description: None,
495 docs: None, 515 docs: None,
@@ -550,7 +570,7 @@ mod test_mod {
550 35..44, 570 35..44,
551 ), 571 ),
552 name: "test_foo1", 572 name: "test_foo1",
553 kind: FN_DEF, 573 kind: FN,
554 container_name: None, 574 container_name: None,
555 description: None, 575 description: None,
556 docs: None, 576 docs: None,
@@ -571,19 +591,33 @@ mod test_mod {
571 } 591 }
572 592
573 #[test] 593 #[test]
574 fn test_runnables_one_depth_layer_module() { 594 fn only_modules_with_test_functions_or_more_than_one_test_submodule_have_runners() {
575 check( 595 check(
576 r#" 596 r#"
577//- /lib.rs 597//- /lib.rs
578<|> 598<|>
579mod foo { 599mod root_tests {
580 mod test_mod { 600 mod nested_tests_0 {
581 #[test] 601 mod nested_tests_1 {
582 fn test_foo1() {} 602 #[test]
603 fn nested_test_11() {}
604
605 #[test]
606 fn nested_test_12() {}
607 }
608
609 mod nested_tests_2 {
610 #[test]
611 fn nested_test_2() {}
612 }
613
614 mod nested_tests_3 {}
583 } 615 }
616
617 mod nested_tests_4 {}
584} 618}
585"#, 619"#,
586 &[&TEST, &TEST], 620 &[&TEST, &TEST, &TEST, &TEST, &TEST, &TEST],
587 expect![[r#" 621 expect![[r#"
588 [ 622 [
589 Runnable { 623 Runnable {
@@ -591,18 +625,18 @@ mod foo {
591 file_id: FileId( 625 file_id: FileId(
592 1, 626 1,
593 ), 627 ),
594 full_range: 15..77, 628 full_range: 22..323,
595 focus_range: Some( 629 focus_range: Some(
596 19..27, 630 26..40,
597 ), 631 ),
598 name: "test_mod", 632 name: "nested_tests_0",
599 kind: MODULE, 633 kind: MODULE,
600 container_name: None, 634 container_name: None,
601 description: None, 635 description: None,
602 docs: None, 636 docs: None,
603 }, 637 },
604 kind: TestMod { 638 kind: TestMod {
605 path: "foo::test_mod", 639 path: "root_tests::nested_tests_0",
606 }, 640 },
607 cfg_exprs: [], 641 cfg_exprs: [],
608 }, 642 },
@@ -611,19 +645,39 @@ mod foo {
611 file_id: FileId( 645 file_id: FileId(
612 1, 646 1,
613 ), 647 ),
614 full_range: 38..71, 648 full_range: 51..192,
615 focus_range: Some( 649 focus_range: Some(
616 57..66, 650 55..69,
617 ), 651 ),
618 name: "test_foo1", 652 name: "nested_tests_1",
619 kind: FN_DEF, 653 kind: MODULE,
654 container_name: None,
655 description: None,
656 docs: None,
657 },
658 kind: TestMod {
659 path: "root_tests::nested_tests_0::nested_tests_1",
660 },
661 cfg_exprs: [],
662 },
663 Runnable {
664 nav: NavigationTarget {
665 file_id: FileId(
666 1,
667 ),
668 full_range: 84..126,
669 focus_range: Some(
670 107..121,
671 ),
672 name: "nested_test_11",
673 kind: FN,
620 container_name: None, 674 container_name: None,
621 description: None, 675 description: None,
622 docs: None, 676 docs: None,
623 }, 677 },
624 kind: Test { 678 kind: Test {
625 test_id: Path( 679 test_id: Path(
626 "foo::test_mod::test_foo1", 680 "root_tests::nested_tests_0::nested_tests_1::nested_test_11",
627 ), 681 ),
628 attr: TestAttr { 682 attr: TestAttr {
629 ignore: false, 683 ignore: false,
@@ -631,46 +685,48 @@ mod foo {
631 }, 685 },
632 cfg_exprs: [], 686 cfg_exprs: [],
633 }, 687 },
634 ]
635 "#]],
636 );
637 }
638
639 #[test]
640 fn test_runnables_multiple_depth_module() {
641 check(
642 r#"
643//- /lib.rs
644<|>
645mod foo {
646 mod bar {
647 mod test_mod {
648 #[test]
649 fn test_foo1() {}
650 }
651 }
652}
653"#,
654 &[&TEST, &TEST],
655 expect![[r#"
656 [
657 Runnable { 688 Runnable {
658 nav: NavigationTarget { 689 nav: NavigationTarget {
659 file_id: FileId( 690 file_id: FileId(
660 1, 691 1,
661 ), 692 ),
662 full_range: 33..107, 693 full_range: 140..182,
663 focus_range: Some( 694 focus_range: Some(
664 37..45, 695 163..177,
665 ), 696 ),
666 name: "test_mod", 697 name: "nested_test_12",
698 kind: FN,
699 container_name: None,
700 description: None,
701 docs: None,
702 },
703 kind: Test {
704 test_id: Path(
705 "root_tests::nested_tests_0::nested_tests_1::nested_test_12",
706 ),
707 attr: TestAttr {
708 ignore: false,
709 },
710 },
711 cfg_exprs: [],
712 },
713 Runnable {
714 nav: NavigationTarget {
715 file_id: FileId(
716 1,
717 ),
718 full_range: 202..286,
719 focus_range: Some(
720 206..220,
721 ),
722 name: "nested_tests_2",
667 kind: MODULE, 723 kind: MODULE,
668 container_name: None, 724 container_name: None,
669 description: None, 725 description: None,
670 docs: None, 726 docs: None,
671 }, 727 },
672 kind: TestMod { 728 kind: TestMod {
673 path: "foo::bar::test_mod", 729 path: "root_tests::nested_tests_0::nested_tests_2",
674 }, 730 },
675 cfg_exprs: [], 731 cfg_exprs: [],
676 }, 732 },
@@ -679,19 +735,19 @@ mod foo {
679 file_id: FileId( 735 file_id: FileId(
680 1, 736 1,
681 ), 737 ),
682 full_range: 60..97, 738 full_range: 235..276,
683 focus_range: Some( 739 focus_range: Some(
684 83..92, 740 258..271,
685 ), 741 ),
686 name: "test_foo1", 742 name: "nested_test_2",
687 kind: FN_DEF, 743 kind: FN,
688 container_name: None, 744 container_name: None,
689 description: None, 745 description: None,
690 docs: None, 746 docs: None,
691 }, 747 },
692 kind: Test { 748 kind: Test {
693 test_id: Path( 749 test_id: Path(
694 "foo::bar::test_mod::test_foo1", 750 "root_tests::nested_tests_0::nested_tests_2::nested_test_2",
695 ), 751 ),
696 attr: TestAttr { 752 attr: TestAttr {
697 ignore: false, 753 ignore: false,
@@ -727,7 +783,7 @@ fn test_foo1() {}
727 36..45, 783 36..45,
728 ), 784 ),
729 name: "test_foo1", 785 name: "test_foo1",
730 kind: FN_DEF, 786 kind: FN,
731 container_name: None, 787 container_name: None,
732 description: None, 788 description: None,
733 docs: None, 789 docs: None,
@@ -775,7 +831,7 @@ fn test_foo1() {}
775 58..67, 831 58..67,
776 ), 832 ),
777 name: "test_foo1", 833 name: "test_foo1",
778 kind: FN_DEF, 834 kind: FN,
779 container_name: None, 835 container_name: None,
780 description: None, 836 description: None,
781 docs: None, 837 docs: None,
diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs
index 95d8f79b8..4348b43be 100644
--- a/crates/ra_ide/src/ssr.rs
+++ b/crates/ra_ide/src/ssr.rs
@@ -1,4 +1,4 @@
1use ra_db::FilePosition; 1use ra_db::{FilePosition, FileRange};
2use ra_ide_db::RootDatabase; 2use ra_ide_db::RootDatabase;
3 3
4use crate::SourceFileEdit; 4use crate::SourceFileEdit;
@@ -24,6 +24,9 @@ use ra_ssr::{MatchFinder, SsrError, SsrRule};
24// Method calls should generally be written in UFCS form. e.g. `foo::Bar::baz($s, $a)` will match 24// Method calls should generally be written in UFCS form. e.g. `foo::Bar::baz($s, $a)` will match
25// `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`. 25// `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`.
26// 26//
27// The scope of the search / replace will be restricted to the current selection if any, otherwise
28// it will apply to the whole workspace.
29//
27// Placeholders may be given constraints by writing them as `${<name>:<constraint1>:<constraint2>...}`. 30// Placeholders may be given constraints by writing them as `${<name>:<constraint1>:<constraint2>...}`.
28// 31//
29// Supported constraints: 32// Supported constraints:
@@ -56,10 +59,11 @@ pub fn parse_search_replace(
56 rule: &str, 59 rule: &str,
57 parse_only: bool, 60 parse_only: bool,
58 db: &RootDatabase, 61 db: &RootDatabase,
59 position: FilePosition, 62 resolve_context: FilePosition,
63 selections: Vec<FileRange>,
60) -> Result<Vec<SourceFileEdit>, SsrError> { 64) -> Result<Vec<SourceFileEdit>, SsrError> {
61 let rule: SsrRule = rule.parse()?; 65 let rule: SsrRule = rule.parse()?;
62 let mut match_finder = MatchFinder::in_context(db, position); 66 let mut match_finder = MatchFinder::in_context(db, resolve_context, selections);
63 match_finder.add_rule(rule)?; 67 match_finder.add_rule(rule)?;
64 if parse_only { 68 if parse_only {
65 return Ok(Vec::new()); 69 return Ok(Vec::new());
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index d456d5d36..f71b804fe 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -4,7 +4,7 @@ mod injection;
4#[cfg(test)] 4#[cfg(test)]
5mod tests; 5mod tests;
6 6
7use hir::{Name, Semantics}; 7use hir::{Name, Semantics, VariantDef};
8use ra_ide_db::{ 8use ra_ide_db::{
9 defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, 9 defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass},
10 RootDatabase, 10 RootDatabase,
@@ -455,6 +455,18 @@ fn macro_call_range(macro_call: &ast::MacroCall) -> Option<TextRange> {
455 Some(TextRange::new(range_start, range_end)) 455 Some(TextRange::new(range_start, range_end))
456} 456}
457 457
458fn is_possibly_unsafe(name_ref: &ast::NameRef) -> bool {
459 name_ref
460 .syntax()
461 .parent()
462 .and_then(|parent| {
463 ast::FieldExpr::cast(parent.clone())
464 .map(|_| true)
465 .or_else(|| ast::RecordPatField::cast(parent).map(|_| true))
466 })
467 .unwrap_or(false)
468}
469
458fn highlight_element( 470fn highlight_element(
459 sema: &Semantics<RootDatabase>, 471 sema: &Semantics<RootDatabase>,
460 bindings_shadow_count: &mut FxHashMap<Name, u32>, 472 bindings_shadow_count: &mut FxHashMap<Name, u32>,
@@ -464,7 +476,7 @@ fn highlight_element(
464 let db = sema.db; 476 let db = sema.db;
465 let mut binding_hash = None; 477 let mut binding_hash = None;
466 let highlight: Highlight = match element.kind() { 478 let highlight: Highlight = match element.kind() {
467 FN_DEF => { 479 FN => {
468 bindings_shadow_count.clear(); 480 bindings_shadow_count.clear();
469 return None; 481 return None;
470 } 482 }
@@ -484,10 +496,19 @@ fn highlight_element(
484 496
485 match name_kind { 497 match name_kind {
486 Some(NameClass::Definition(def)) => { 498 Some(NameClass::Definition(def)) => {
487 highlight_name(db, def) | HighlightModifier::Definition 499 highlight_name(db, def, false) | HighlightModifier::Definition
500 }
501 Some(NameClass::ConstReference(def)) => highlight_name(db, def, false),
502 Some(NameClass::FieldShorthand { field, .. }) => {
503 let mut h = HighlightTag::Field.into();
504 if let Definition::Field(field) = field {
505 if let VariantDef::Union(_) = field.parent_def(db) {
506 h |= HighlightModifier::Unsafe;
507 }
508 }
509
510 h
488 } 511 }
489 Some(NameClass::ConstReference(def)) => highlight_name(db, def),
490 Some(NameClass::FieldShorthand { .. }) => HighlightTag::Field.into(),
491 None => highlight_name_by_syntax(name) | HighlightModifier::Definition, 512 None => highlight_name_by_syntax(name) | HighlightModifier::Definition,
492 } 513 }
493 } 514 }
@@ -498,6 +519,7 @@ fn highlight_element(
498 } 519 }
499 NAME_REF => { 520 NAME_REF => {
500 let name_ref = element.into_node().and_then(ast::NameRef::cast).unwrap(); 521 let name_ref = element.into_node().and_then(ast::NameRef::cast).unwrap();
522 let possibly_unsafe = is_possibly_unsafe(&name_ref);
501 match classify_name_ref(sema, &name_ref) { 523 match classify_name_ref(sema, &name_ref) {
502 Some(name_kind) => match name_kind { 524 Some(name_kind) => match name_kind {
503 NameRefClass::Definition(def) => { 525 NameRefClass::Definition(def) => {
@@ -508,11 +530,13 @@ fn highlight_element(
508 binding_hash = Some(calc_binding_hash(&name, *shadow_count)) 530 binding_hash = Some(calc_binding_hash(&name, *shadow_count))
509 } 531 }
510 }; 532 };
511 highlight_name(db, def) 533 highlight_name(db, def, possibly_unsafe)
512 } 534 }
513 NameRefClass::FieldShorthand { .. } => HighlightTag::Field.into(), 535 NameRefClass::FieldShorthand { .. } => HighlightTag::Field.into(),
514 }, 536 },
515 None if syntactic_name_ref_highlighting => highlight_name_ref_by_syntax(name_ref), 537 None if syntactic_name_ref_highlighting => {
538 highlight_name_ref_by_syntax(name_ref, sema)
539 }
516 None => HighlightTag::UnresolvedReference.into(), 540 None => HighlightTag::UnresolvedReference.into(),
517 } 541 }
518 } 542 }
@@ -546,7 +570,7 @@ fn highlight_element(
546 T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { 570 T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => {
547 HighlightTag::Macro.into() 571 HighlightTag::Macro.into()
548 } 572 }
549 T![*] if element.parent().and_then(ast::PointerType::cast).is_some() => { 573 T![*] if element.parent().and_then(ast::PtrType::cast).is_some() => {
550 HighlightTag::Keyword.into() 574 HighlightTag::Keyword.into()
551 } 575 }
552 T![*] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => { 576 T![*] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => {
@@ -577,7 +601,7 @@ fn highlight_element(
577 _ if element.parent().and_then(ast::RangePat::cast).is_some() => { 601 _ if element.parent().and_then(ast::RangePat::cast).is_some() => {
578 HighlightTag::Operator.into() 602 HighlightTag::Operator.into()
579 } 603 }
580 _ if element.parent().and_then(ast::DotDotPat::cast).is_some() => { 604 _ if element.parent().and_then(ast::RestPat::cast).is_some() => {
581 HighlightTag::Operator.into() 605 HighlightTag::Operator.into()
582 } 606 }
583 _ if element.parent().and_then(ast::Attr::cast).is_some() => { 607 _ if element.parent().and_then(ast::Attr::cast).is_some() => {
@@ -647,15 +671,24 @@ fn highlight_element(
647 671
648fn is_child_of_impl(element: &SyntaxElement) -> bool { 672fn is_child_of_impl(element: &SyntaxElement) -> bool {
649 match element.parent() { 673 match element.parent() {
650 Some(e) => e.kind() == IMPL_DEF, 674 Some(e) => e.kind() == IMPL,
651 _ => false, 675 _ => false,
652 } 676 }
653} 677}
654 678
655fn highlight_name(db: &RootDatabase, def: Definition) -> Highlight { 679fn highlight_name(db: &RootDatabase, def: Definition, possibly_unsafe: bool) -> Highlight {
656 match def { 680 match def {
657 Definition::Macro(_) => HighlightTag::Macro, 681 Definition::Macro(_) => HighlightTag::Macro,
658 Definition::Field(_) => HighlightTag::Field, 682 Definition::Field(field) => {
683 let mut h = HighlightTag::Field.into();
684 if possibly_unsafe {
685 if let VariantDef::Union(_) = field.parent_def(db) {
686 h |= HighlightModifier::Unsafe;
687 }
688 }
689
690 return h;
691 }
659 Definition::ModuleDef(def) => match def { 692 Definition::ModuleDef(def) => match def {
660 hir::ModuleDef::Module(_) => HighlightTag::Module, 693 hir::ModuleDef::Module(_) => HighlightTag::Module,
661 hir::ModuleDef::Function(func) => { 694 hir::ModuleDef::Function(func) => {
@@ -677,6 +710,7 @@ fn highlight_name(db: &RootDatabase, def: Definition) -> Highlight {
677 let mut h = Highlight::new(HighlightTag::Static); 710 let mut h = Highlight::new(HighlightTag::Static);
678 if s.is_mut(db) { 711 if s.is_mut(db) {
679 h |= HighlightModifier::Mutable; 712 h |= HighlightModifier::Mutable;
713 h |= HighlightModifier::Unsafe;
680 } 714 }
681 return h; 715 return h;
682 } 716 }
@@ -705,26 +739,26 @@ fn highlight_name_by_syntax(name: ast::Name) -> Highlight {
705 }; 739 };
706 740
707 let tag = match parent.kind() { 741 let tag = match parent.kind() {
708 STRUCT_DEF => HighlightTag::Struct, 742 STRUCT => HighlightTag::Struct,
709 ENUM_DEF => HighlightTag::Enum, 743 ENUM => HighlightTag::Enum,
710 UNION_DEF => HighlightTag::Union, 744 UNION => HighlightTag::Union,
711 TRAIT_DEF => HighlightTag::Trait, 745 TRAIT => HighlightTag::Trait,
712 TYPE_ALIAS_DEF => HighlightTag::TypeAlias, 746 TYPE_ALIAS => HighlightTag::TypeAlias,
713 TYPE_PARAM => HighlightTag::TypeParam, 747 TYPE_PARAM => HighlightTag::TypeParam,
714 RECORD_FIELD_DEF => HighlightTag::Field, 748 RECORD_FIELD => HighlightTag::Field,
715 MODULE => HighlightTag::Module, 749 MODULE => HighlightTag::Module,
716 FN_DEF => HighlightTag::Function, 750 FN => HighlightTag::Function,
717 CONST_DEF => HighlightTag::Constant, 751 CONST => HighlightTag::Constant,
718 STATIC_DEF => HighlightTag::Static, 752 STATIC => HighlightTag::Static,
719 ENUM_VARIANT => HighlightTag::EnumVariant, 753 VARIANT => HighlightTag::EnumVariant,
720 BIND_PAT => HighlightTag::Local, 754 IDENT_PAT => HighlightTag::Local,
721 _ => default, 755 _ => default,
722 }; 756 };
723 757
724 tag.into() 758 tag.into()
725} 759}
726 760
727fn highlight_name_ref_by_syntax(name: ast::NameRef) -> Highlight { 761fn highlight_name_ref_by_syntax(name: ast::NameRef, sema: &Semantics<RootDatabase>) -> Highlight {
728 let default = HighlightTag::UnresolvedReference; 762 let default = HighlightTag::UnresolvedReference;
729 763
730 let parent = match name.syntax().parent() { 764 let parent = match name.syntax().parent() {
@@ -734,7 +768,20 @@ fn highlight_name_ref_by_syntax(name: ast::NameRef) -> Highlight {
734 768
735 let tag = match parent.kind() { 769 let tag = match parent.kind() {
736 METHOD_CALL_EXPR => HighlightTag::Function, 770 METHOD_CALL_EXPR => HighlightTag::Function,
737 FIELD_EXPR => HighlightTag::Field, 771 FIELD_EXPR => {
772 let h = HighlightTag::Field;
773 let is_union = ast::FieldExpr::cast(parent)
774 .and_then(|field_expr| {
775 let field = sema.resolve_field(&field_expr)?;
776 Some(if let VariantDef::Union(_) = field.parent_def(sema.db) {
777 true
778 } else {
779 false
780 })
781 })
782 .unwrap_or(false);
783 return if is_union { h | HighlightModifier::Unsafe } else { h.into() };
784 }
738 PATH_SEGMENT => { 785 PATH_SEGMENT => {
739 let path = match parent.parent().and_then(ast::Path::cast) { 786 let path = match parent.parent().and_then(ast::Path::cast) {
740 Some(it) => it, 787 Some(it) => it,
diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs
index 0be55bca9..a5e7d2867 100644
--- a/crates/ra_ide/src/syntax_highlighting/html.rs
+++ b/crates/ra_ide/src/syntax_highlighting/html.rs
@@ -1,5 +1,6 @@
1//! Renders a bit of code as HTML. 1//! Renders a bit of code as HTML.
2 2
3use oorandom::Rand32;
3use ra_db::SourceDatabase; 4use ra_db::SourceDatabase;
4use ra_syntax::{AstNode, TextRange, TextSize}; 5use ra_syntax::{AstNode, TextRange, TextSize};
5 6
@@ -9,13 +10,12 @@ pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: boo
9 let parse = db.parse(file_id); 10 let parse = db.parse(file_id);
10 11
11 fn rainbowify(seed: u64) -> String { 12 fn rainbowify(seed: u64) -> String {
12 use rand::prelude::*; 13 let mut rng = Rand32::new(seed);
13 let mut rng = SmallRng::seed_from_u64(seed);
14 format!( 14 format!(
15 "hsl({h},{s}%,{l}%)", 15 "hsl({h},{s}%,{l}%)",
16 h = rng.gen_range::<u16, _, _>(0, 361), 16 h = rng.rand_range(0..361),
17 s = rng.gen_range::<u16, _, _>(42, 99), 17 s = rng.rand_range(42..99),
18 l = rng.gen_range::<u16, _, _>(40, 91), 18 l = rng.rand_range(40..91),
19 ) 19 )
20 } 20 }
21 21
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs
index 87a6e2523..730efff0d 100644
--- a/crates/ra_ide/src/syntax_highlighting/tests.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tests.rs
@@ -9,6 +9,9 @@ use crate::{mock_analysis::single_file, FileRange, TextRange};
9fn test_highlighting() { 9fn test_highlighting() {
10 check_highlighting( 10 check_highlighting(
11 r#" 11 r#"
12use inner::{self as inner_mod};
13mod inner {}
14
12#[derive(Clone, Debug)] 15#[derive(Clone, Debug)]
13struct Foo { 16struct Foo {
14 pub x: i32, 17 pub x: i32,
@@ -272,19 +275,37 @@ fn test_unsafe_highlighting() {
272 r#" 275 r#"
273unsafe fn unsafe_fn() {} 276unsafe fn unsafe_fn() {}
274 277
278union Union {
279 a: u32,
280 b: f32,
281}
282
275struct HasUnsafeFn; 283struct HasUnsafeFn;
276 284
277impl HasUnsafeFn { 285impl HasUnsafeFn {
278 unsafe fn unsafe_method(&self) {} 286 unsafe fn unsafe_method(&self) {}
279} 287}
280 288
289struct TypeForStaticMut {
290 a: u8
291}
292
293static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 };
294
281fn main() { 295fn main() {
282 let x = &5 as *const usize; 296 let x = &5 as *const usize;
297 let u = Union { b: 0 };
283 unsafe { 298 unsafe {
284 unsafe_fn(); 299 unsafe_fn();
300 let b = u.b;
301 match u {
302 Union { b: 0 } => (),
303 Union { a } => (),
304 }
285 HasUnsafeFn.unsafe_method(); 305 HasUnsafeFn.unsafe_method();
286 let y = *(x); 306 let y = *(x);
287 let z = -x; 307 let z = -x;
308 let a = global_mut.a;
288 } 309 }
289} 310}
290"# 311"#
diff --git a/crates/ra_ide/src/syntax_tree.rs b/crates/ra_ide/src/syntax_tree.rs
index f716a3861..07217e808 100644
--- a/crates/ra_ide/src/syntax_tree.rs
+++ b/crates/ra_ide/src/syntax_tree.rs
@@ -116,7 +116,7 @@ mod tests {
116 syn.trim(), 116 syn.trim(),
117 r#" 117 r#"
118[email protected] 118[email protected]
119 FN_DEF@0..11 119 [email protected]
120 [email protected] "fn" 120 [email protected] "fn"
121 [email protected] " " 121 [email protected] " "
122 [email protected] 122 [email protected]
@@ -148,7 +148,7 @@ fn test() {
148 syn.trim(), 148 syn.trim(),
149 r#" 149 r#"
150[email protected] 150[email protected]
151 FN_DEF@0..60 151 [email protected]
152 [email protected] "fn" 152 [email protected] "fn"
153 [email protected] " " 153 [email protected] " "
154 [email protected] 154 [email protected]
@@ -190,7 +190,7 @@ [email protected]
190 assert_eq_text!( 190 assert_eq_text!(
191 syn.trim(), 191 syn.trim(),
192 r#" 192 r#"
193FN_DEF@0..11 193[email protected]
194 [email protected] "fn" 194 [email protected] "fn"
195 [email protected] " " 195 [email protected] " "
196 [email protected] 196 [email protected]
@@ -258,7 +258,7 @@ fn bar() {
258 syn.trim(), 258 syn.trim(),
259 r#" 259 r#"
260[email protected] 260[email protected]
261 FN_DEF@0..12 261 [email protected]
262 [email protected] "fn" 262 [email protected] "fn"
263 [email protected] " " 263 [email protected] " "
264 [email protected] 264 [email protected]
@@ -292,7 +292,7 @@ fn bar() {
292 syn.trim(), 292 syn.trim(),
293 r#" 293 r#"
294[email protected] 294[email protected]
295 FN_DEF@0..12 295 [email protected]
296 [email protected] "fn" 296 [email protected] "fn"
297 [email protected] " " 297 [email protected] " "
298 [email protected] 298 [email protected]
@@ -325,7 +325,7 @@ fn bar() {
325 syn.trim(), 325 syn.trim(),
326 r#" 326 r#"
327[email protected] 327[email protected]
328 FN_DEF@0..12 328 [email protected]
329 [email protected] "fn" 329 [email protected] "fn"
330 [email protected] " " 330 [email protected] " "
331 [email protected] 331 [email protected]
@@ -339,7 +339,7 @@ [email protected]
339 [email protected] "\n" 339 [email protected] "\n"
340 [email protected] "}" 340 [email protected] "}"
341 [email protected] "\n" 341 [email protected] "\n"
342 FN_DEF@13..25 342 [email protected]
343 [email protected] "fn" 343 [email protected] "fn"
344 [email protected] " " 344 [email protected] " "
345 [email protected] 345 [email protected]
diff --git a/crates/ra_ide/test_data/highlight_unsafe.html b/crates/ra_ide/test_data/highlight_unsafe.html
index b81b6f1c3..79409fe81 100644
--- a/crates/ra_ide/test_data/highlight_unsafe.html
+++ b/crates/ra_ide/test_data/highlight_unsafe.html
@@ -37,18 +37,36 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
37</style> 37</style>
38<pre><code><span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_fn</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> 38<pre><code><span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_fn</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span>
39 39
40<span class="keyword">union</span> <span class="union declaration">Union</span> <span class="punctuation">{</span>
41 <span class="field declaration">a</span><span class="punctuation">:</span> <span class="builtin_type">u32</span><span class="punctuation">,</span>
42 <span class="field declaration">b</span><span class="punctuation">:</span> <span class="builtin_type">f32</span><span class="punctuation">,</span>
43<span class="punctuation">}</span>
44
40<span class="keyword">struct</span> <span class="struct declaration">HasUnsafeFn</span><span class="punctuation">;</span> 45<span class="keyword">struct</span> <span class="struct declaration">HasUnsafeFn</span><span class="punctuation">;</span>
41 46
42<span class="keyword">impl</span> <span class="struct">HasUnsafeFn</span> <span class="punctuation">{</span> 47<span class="keyword">impl</span> <span class="struct">HasUnsafeFn</span> <span class="punctuation">{</span>
43 <span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_method</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> 48 <span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_method</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span>
44<span class="punctuation">}</span> 49<span class="punctuation">}</span>
45 50
51<span class="keyword">struct</span> <span class="struct declaration">TypeForStaticMut</span> <span class="punctuation">{</span>
52 <span class="field declaration">a</span><span class="punctuation">:</span> <span class="builtin_type">u8</span>
53<span class="punctuation">}</span>
54
55<span class="keyword">static</span> <span class="keyword">mut</span> <span class="static declaration mutable unsafe">global_mut</span><span class="punctuation">:</span> <span class="struct">TypeForStaticMut</span> <span class="operator">=</span> <span class="struct">TypeForStaticMut</span> <span class="punctuation">{</span> <span class="field">a</span><span class="punctuation">:</span> <span class="numeric_literal">0</span> <span class="punctuation">}</span><span class="punctuation">;</span>
56
46<span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> 57<span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
47 <span class="keyword">let</span> <span class="variable declaration">x</span> <span class="operator">=</span> <span class="operator">&</span><span class="numeric_literal">5</span> <span class="keyword">as</span> <span class="keyword">*</span><span class="keyword">const</span> <span class="builtin_type">usize</span><span class="punctuation">;</span> 58 <span class="keyword">let</span> <span class="variable declaration">x</span> <span class="operator">=</span> <span class="operator">&</span><span class="numeric_literal">5</span> <span class="keyword">as</span> <span class="keyword">*</span><span class="keyword">const</span> <span class="builtin_type">usize</span><span class="punctuation">;</span>
59 <span class="keyword">let</span> <span class="variable declaration">u</span> <span class="operator">=</span> <span class="union">Union</span> <span class="punctuation">{</span> <span class="field">b</span><span class="punctuation">:</span> <span class="numeric_literal">0</span> <span class="punctuation">}</span><span class="punctuation">;</span>
48 <span class="keyword unsafe">unsafe</span> <span class="punctuation">{</span> 60 <span class="keyword unsafe">unsafe</span> <span class="punctuation">{</span>
49 <span class="function unsafe">unsafe_fn</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> 61 <span class="function unsafe">unsafe_fn</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
62 <span class="keyword">let</span> <span class="variable declaration">b</span> <span class="operator">=</span> <span class="variable">u</span><span class="punctuation">.</span><span class="field unsafe">b</span><span class="punctuation">;</span>
63 <span class="keyword control">match</span> <span class="variable">u</span> <span class="punctuation">{</span>
64 <span class="union">Union</span> <span class="punctuation">{</span> <span class="field unsafe">b</span><span class="punctuation">:</span> <span class="numeric_literal">0</span> <span class="punctuation">}</span> <span class="operator">=&gt;</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">,</span>
65 <span class="union">Union</span> <span class="punctuation">{</span> <span class="field unsafe">a</span> <span class="punctuation">}</span> <span class="operator">=&gt;</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">,</span>
66 <span class="punctuation">}</span>
50 <span class="struct">HasUnsafeFn</span><span class="punctuation">.</span><span class="function unsafe">unsafe_method</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> 67 <span class="struct">HasUnsafeFn</span><span class="punctuation">.</span><span class="function unsafe">unsafe_method</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
51 <span class="keyword">let</span> <span class="variable declaration">y</span> <span class="operator">=</span> <span class="operator unsafe">*</span><span class="punctuation">(</span><span class="variable">x</span><span class="punctuation">)</span><span class="punctuation">;</span> 68 <span class="keyword">let</span> <span class="variable declaration">y</span> <span class="operator">=</span> <span class="operator unsafe">*</span><span class="punctuation">(</span><span class="variable">x</span><span class="punctuation">)</span><span class="punctuation">;</span>
52 <span class="keyword">let</span> <span class="variable declaration">z</span> <span class="operator">=</span> <span class="numeric_literal">-</span><span class="variable">x</span><span class="punctuation">;</span> 69 <span class="keyword">let</span> <span class="variable declaration">z</span> <span class="operator">=</span> <span class="numeric_literal">-</span><span class="variable">x</span><span class="punctuation">;</span>
70 <span class="keyword">let</span> <span class="variable declaration">a</span> <span class="operator">=</span> <span class="static mutable unsafe">global_mut</span><span class="punctuation">.</span><span class="field">a</span><span class="punctuation">;</span>
53 <span class="punctuation">}</span> 71 <span class="punctuation">}</span>
54<span class="punctuation">}</span></code></pre> \ No newline at end of file 72<span class="punctuation">}</span></code></pre> \ No newline at end of file
diff --git a/crates/ra_ide/test_data/highlighting.html b/crates/ra_ide/test_data/highlighting.html
index 345a2f023..8e0160eee 100644
--- a/crates/ra_ide/test_data/highlighting.html
+++ b/crates/ra_ide/test_data/highlighting.html
@@ -35,7 +35,10 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
35 35
36.unresolved_reference { color: #FC5555; text-decoration: wavy underline; } 36.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
37</style> 37</style>
38<pre><code><span class="attribute">#</span><span class="attribute">[</span><span class="function attribute">derive</span><span class="punctuation">(</span><span class="attribute">Clone</span><span class="punctuation">,</span><span class="attribute"> Debug</span><span class="punctuation">)</span><span class="attribute">]</span> 38<pre><code><span class="keyword">use</span> <span class="module">inner</span><span class="operator">::</span><span class="punctuation">{</span><span class="self_keyword">self</span> <span class="keyword">as</span> <span class="module declaration">inner_mod</span><span class="punctuation">}</span><span class="punctuation">;</span>
39<span class="keyword">mod</span> <span class="module declaration">inner</span> <span class="punctuation">{</span><span class="punctuation">}</span>
40
41<span class="attribute">#</span><span class="attribute">[</span><span class="function attribute">derive</span><span class="punctuation">(</span><span class="attribute">Clone</span><span class="punctuation">,</span><span class="attribute"> Debug</span><span class="punctuation">)</span><span class="attribute">]</span>
39<span class="keyword">struct</span> <span class="struct declaration">Foo</span> <span class="punctuation">{</span> 42<span class="keyword">struct</span> <span class="struct declaration">Foo</span> <span class="punctuation">{</span>
40 <span class="keyword">pub</span> <span class="field declaration">x</span><span class="punctuation">:</span> <span class="builtin_type">i32</span><span class="punctuation">,</span> 43 <span class="keyword">pub</span> <span class="field declaration">x</span><span class="punctuation">:</span> <span class="builtin_type">i32</span><span class="punctuation">,</span>
41 <span class="keyword">pub</span> <span class="field declaration">y</span><span class="punctuation">:</span> <span class="builtin_type">i32</span><span class="punctuation">,</span> 44 <span class="keyword">pub</span> <span class="field declaration">y</span><span class="punctuation">:</span> <span class="builtin_type">i32</span><span class="punctuation">,</span>
@@ -61,7 +64,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
61 <span class="punctuation">}</span> 64 <span class="punctuation">}</span>
62<span class="punctuation">}</span> 65<span class="punctuation">}</span>
63 66
64<span class="keyword">static</span> <span class="keyword">mut</span> <span class="static declaration mutable">STATIC_MUT</span><span class="punctuation">:</span> <span class="builtin_type">i32</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span> 67<span class="keyword">static</span> <span class="keyword">mut</span> <span class="static declaration mutable unsafe">STATIC_MUT</span><span class="punctuation">:</span> <span class="builtin_type">i32</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span>
65 68
66<span class="keyword">fn</span> <span class="function declaration">foo</span><span class="punctuation">&lt;</span><span class="lifetime declaration">'a</span><span class="punctuation">,</span> <span class="type_param declaration">T</span><span class="punctuation">&gt;</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="operator">-&gt;</span> <span class="type_param">T</span> <span class="punctuation">{</span> 69<span class="keyword">fn</span> <span class="function declaration">foo</span><span class="punctuation">&lt;</span><span class="lifetime declaration">'a</span><span class="punctuation">,</span> <span class="type_param declaration">T</span><span class="punctuation">&gt;</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="operator">-&gt;</span> <span class="type_param">T</span> <span class="punctuation">{</span>
67 <span class="function">foo</span><span class="operator">::</span><span class="punctuation">&lt;</span><span class="lifetime">'a</span><span class="punctuation">,</span> <span class="builtin_type">i32</span><span class="punctuation">&gt;</span><span class="punctuation">(</span><span class="punctuation">)</span> 70 <span class="function">foo</span><span class="operator">::</span><span class="punctuation">&lt;</span><span class="lifetime">'a</span><span class="punctuation">,</span> <span class="builtin_type">i32</span><span class="punctuation">&gt;</span><span class="punctuation">(</span><span class="punctuation">)</span>
@@ -94,7 +97,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
94 <span class="punctuation">}</span> 97 <span class="punctuation">}</span>
95 <span class="keyword unsafe">unsafe</span> <span class="punctuation">{</span> 98 <span class="keyword unsafe">unsafe</span> <span class="punctuation">{</span>
96 <span class="variable mutable">vec</span><span class="punctuation">.</span><span class="unresolved_reference">set_len</span><span class="punctuation">(</span><span class="numeric_literal">0</span><span class="punctuation">)</span><span class="punctuation">;</span> 99 <span class="variable mutable">vec</span><span class="punctuation">.</span><span class="unresolved_reference">set_len</span><span class="punctuation">(</span><span class="numeric_literal">0</span><span class="punctuation">)</span><span class="punctuation">;</span>
97 <span class="static mutable">STATIC_MUT</span> <span class="operator">=</span> <span class="numeric_literal">1</span><span class="punctuation">;</span> 100 <span class="static mutable unsafe">STATIC_MUT</span> <span class="operator">=</span> <span class="numeric_literal">1</span><span class="punctuation">;</span>
98 <span class="punctuation">}</span> 101 <span class="punctuation">}</span>
99 102
100 <span class="keyword control">for</span> <span class="variable declaration">e</span> <span class="keyword control">in</span> <span class="variable mutable">vec</span> <span class="punctuation">{</span> 103 <span class="keyword control">for</span> <span class="variable declaration">e</span> <span class="keyword control">in</span> <span class="variable mutable">vec</span> <span class="punctuation">{</span>
diff --git a/crates/ra_ide/test_data/rainbow_highlighting.html b/crates/ra_ide/test_data/rainbow_highlighting.html
index 08d83302c..401e87a73 100644
--- a/crates/ra_ide/test_data/rainbow_highlighting.html
+++ b/crates/ra_ide/test_data/rainbow_highlighting.html
@@ -36,14 +36,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
36.unresolved_reference { color: #FC5555; text-decoration: wavy underline; } 36.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
37</style> 37</style>
38<pre><code><span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> 38<pre><code><span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
39 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span> <span class="operator">=</span> <span class="string_literal">"hello"</span><span class="punctuation">;</span> 39 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="8121853618659664005" style="color: hsl(273,88%,88%);">hello</span> <span class="operator">=</span> <span class="string_literal">"hello"</span><span class="punctuation">;</span>
40 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="2705725358298919760" style="color: hsl(17,51%,74%);">x</span> <span class="operator">=</span> <span class="variable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span><span class="punctuation">.</span><span class="unresolved_reference">to_string</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> 40 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="2705725358298919760" style="color: hsl(76,47%,83%);">x</span> <span class="operator">=</span> <span class="variable" data-binding-hash="8121853618659664005" style="color: hsl(273,88%,88%);">hello</span><span class="punctuation">.</span><span class="unresolved_reference">to_string</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
41 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="3365759661443752373" style="color: hsl(127,76%,66%);">y</span> <span class="operator">=</span> <span class="variable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span><span class="punctuation">.</span><span class="unresolved_reference">to_string</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> 41 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="3365759661443752373" style="color: hsl(15,86%,51%);">y</span> <span class="operator">=</span> <span class="variable" data-binding-hash="8121853618659664005" style="color: hsl(273,88%,88%);">hello</span><span class="punctuation">.</span><span class="unresolved_reference">to_string</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
42 42
43 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="794745962933817518" style="color: hsl(19,74%,76%);">x</span> <span class="operator">=</span> <span class="string_literal">"other color please!"</span><span class="punctuation">;</span> 43 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="794745962933817518" style="color: hsl(127,71%,87%);">x</span> <span class="operator">=</span> <span class="string_literal">"other color please!"</span><span class="punctuation">;</span>
44 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="6717528807933952652" style="color: hsl(85,49%,84%);">y</span> <span class="operator">=</span> <span class="variable" data-binding-hash="794745962933817518" style="color: hsl(19,74%,76%);">x</span><span class="punctuation">.</span><span class="unresolved_reference">to_string</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> 44 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="6717528807933952652" style="color: hsl(90,74%,79%);">y</span> <span class="operator">=</span> <span class="variable" data-binding-hash="794745962933817518" style="color: hsl(127,71%,87%);">x</span><span class="punctuation">.</span><span class="unresolved_reference">to_string</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
45<span class="punctuation">}</span> 45<span class="punctuation">}</span>
46 46
47<span class="keyword">fn</span> <span class="function declaration">bar</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> 47<span class="keyword">fn</span> <span class="function declaration">bar</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
48 <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span> <span class="operator">=</span> <span class="string_literal">"hello"</span><span class="punctuation">;</span> 48 <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable" data-binding-hash="8121853618659664005" style="color: hsl(273,88%,88%);">hello</span> <span class="operator">=</span> <span class="string_literal">"hello"</span><span class="punctuation">;</span>
49<span class="punctuation">}</span></code></pre> \ No newline at end of file 49<span class="punctuation">}</span></code></pre> \ No newline at end of file
diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs
index 32d9a8d1f..b13df8b85 100644
--- a/crates/ra_ide_db/src/change.rs
+++ b/crates/ra_ide_db/src/change.rs
@@ -190,11 +190,24 @@ impl RootDatabase {
190 let q: $q = Default::default(); 190 let q: $q = Default::default();
191 let name = format!("{:?} (deps)", q); 191 let name = format!("{:?} (deps)", q);
192 acc.push((name, before - after)); 192 acc.push((name, before - after));
193
194 let before = memory_usage().allocated;
195 $q.in_db(self).purge();
196 let after = memory_usage().allocated;
197 let q: $q = Default::default();
198 let name = format!("{:?} (purge)", q);
199 acc.push((name, before - after));
193 )*} 200 )*}
194 } 201 }
195 sweep_each_query![ 202 sweep_each_query![
196 // SourceDatabase 203 // SourceDatabase
197 ra_db::ParseQuery 204 ra_db::ParseQuery
205 ra_db::CrateGraphQuery
206
207 // SourceDatabaseExt
208 ra_db::FileTextQuery
209 ra_db::FileSourceRootQuery
210 ra_db::SourceRootQuery
198 ra_db::SourceRootCratesQuery 211 ra_db::SourceRootCratesQuery
199 212
200 // AstDatabase 213 // AstDatabase
@@ -242,15 +255,24 @@ impl RootDatabase {
242 hir::db::TraitImplsInCrateQuery 255 hir::db::TraitImplsInCrateQuery
243 hir::db::TraitImplsInDepsQuery 256 hir::db::TraitImplsInDepsQuery
244 hir::db::AssociatedTyDataQuery 257 hir::db::AssociatedTyDataQuery
258 hir::db::AssociatedTyDataQuery
245 hir::db::TraitDatumQuery 259 hir::db::TraitDatumQuery
246 hir::db::StructDatumQuery 260 hir::db::StructDatumQuery
247 hir::db::ImplDatumQuery 261 hir::db::ImplDatumQuery
262 hir::db::FnDefDatumQuery
263 hir::db::ReturnTypeImplTraitsQuery
264 hir::db::InternCallableDefQuery
265 hir::db::InternTypeParamIdQuery
266 hir::db::InternImplTraitIdQuery
267 hir::db::InternClosureQuery
248 hir::db::AssociatedTyValueQuery 268 hir::db::AssociatedTyValueQuery
249 hir::db::TraitSolveQuery 269 hir::db::TraitSolveQuery
250 hir::db::ReturnTypeImplTraitsQuery
251 270
252 // SymbolsDatabase 271 // SymbolsDatabase
253 crate::symbol_index::FileSymbolsQuery 272 crate::symbol_index::FileSymbolsQuery
273 crate::symbol_index::LibrarySymbolsQuery
274 crate::symbol_index::LocalRootsQuery
275 crate::symbol_index::LibraryRootsQuery
254 276
255 // LineIndexDatabase 277 // LineIndexDatabase
256 crate::LineIndexQuery 278 crate::LineIndexQuery
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs
index f391a8e43..b51000b03 100644
--- a/crates/ra_ide_db/src/defs.rs
+++ b/crates/ra_ide_db/src/defs.rs
@@ -12,7 +12,7 @@ use hir::{
12use ra_prof::profile; 12use ra_prof::profile;
13use ra_syntax::{ 13use ra_syntax::{
14 ast::{self, AstNode}, 14 ast::{self, AstNode},
15 match_ast, 15 match_ast, SyntaxNode,
16}; 16};
17 17
18use crate::RootDatabase; 18use crate::RootDatabase;
@@ -111,7 +111,7 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option
111 111
112 let parent = name.syntax().parent()?; 112 let parent = name.syntax().parent()?;
113 113
114 if let Some(bind_pat) = ast::BindPat::cast(parent.clone()) { 114 if let Some(bind_pat) = ast::IdentPat::cast(parent.clone()) {
115 if let Some(def) = sema.resolve_bind_pat_to_const(&bind_pat) { 115 if let Some(def) = sema.resolve_bind_pat_to_const(&bind_pat) {
116 return Some(NameClass::ConstReference(Definition::ModuleDef(def))); 116 return Some(NameClass::ConstReference(Definition::ModuleDef(def)));
117 } 117 }
@@ -119,19 +119,38 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option
119 119
120 match_ast! { 120 match_ast! {
121 match parent { 121 match parent {
122 ast::Alias(it) => { 122 ast::Rename(it) => {
123 let use_tree = it.syntax().parent().and_then(ast::UseTree::cast)?; 123 let use_tree = it.syntax().parent().and_then(ast::UseTree::cast)?;
124 let path = use_tree.path()?; 124 let path = use_tree.path()?;
125 let path_segment = path.segment()?; 125 let path_segment = path.segment()?;
126 let name_ref = path_segment.name_ref()?; 126 let name_ref_class = path_segment
127 let name_ref_class = classify_name_ref(sema, &name_ref)?; 127 .name_ref()
128 // The rename might be from a `self` token, so fallback to the name higher
129 // in the use tree.
130 .or_else(||{
131 if path_segment.self_token().is_none() {
132 return None;
133 }
134
135 let use_tree = use_tree
136 .syntax()
137 .parent()
138 .as_ref()
139 // Skip over UseTreeList
140 .and_then(SyntaxNode::parent)
141 .and_then(ast::UseTree::cast)?;
142 let path = use_tree.path()?;
143 let path_segment = path.segment()?;
144 path_segment.name_ref()
145 })
146 .and_then(|name_ref| classify_name_ref(sema, &name_ref))?;
128 147
129 Some(NameClass::Definition(name_ref_class.definition())) 148 Some(NameClass::Definition(name_ref_class.definition()))
130 }, 149 },
131 ast::BindPat(it) => { 150 ast::IdentPat(it) => {
132 let local = sema.to_def(&it)?; 151 let local = sema.to_def(&it)?;
133 152
134 if let Some(record_field_pat) = it.syntax().parent().and_then(ast::RecordFieldPat::cast) { 153 if let Some(record_field_pat) = it.syntax().parent().and_then(ast::RecordPatField::cast) {
135 if record_field_pat.name_ref().is_none() { 154 if record_field_pat.name_ref().is_none() {
136 if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { 155 if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) {
137 let field = Definition::Field(field); 156 let field = Definition::Field(field);
@@ -142,7 +161,7 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option
142 161
143 Some(NameClass::Definition(Definition::Local(local))) 162 Some(NameClass::Definition(Definition::Local(local)))
144 }, 163 },
145 ast::RecordFieldDef(it) => { 164 ast::RecordField(it) => {
146 let field: hir::Field = sema.to_def(&it)?; 165 let field: hir::Field = sema.to_def(&it)?;
147 Some(NameClass::Definition(Definition::Field(field))) 166 Some(NameClass::Definition(Definition::Field(field)))
148 }, 167 },
@@ -150,39 +169,39 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option
150 let def = sema.to_def(&it)?; 169 let def = sema.to_def(&it)?;
151 Some(NameClass::Definition(Definition::ModuleDef(def.into()))) 170 Some(NameClass::Definition(Definition::ModuleDef(def.into())))
152 }, 171 },
153 ast::StructDef(it) => { 172 ast::Struct(it) => {
154 let def: hir::Struct = sema.to_def(&it)?; 173 let def: hir::Struct = sema.to_def(&it)?;
155 Some(NameClass::Definition(Definition::ModuleDef(def.into()))) 174 Some(NameClass::Definition(Definition::ModuleDef(def.into())))
156 }, 175 },
157 ast::UnionDef(it) => { 176 ast::Union(it) => {
158 let def: hir::Union = sema.to_def(&it)?; 177 let def: hir::Union = sema.to_def(&it)?;
159 Some(NameClass::Definition(Definition::ModuleDef(def.into()))) 178 Some(NameClass::Definition(Definition::ModuleDef(def.into())))
160 }, 179 },
161 ast::EnumDef(it) => { 180 ast::Enum(it) => {
162 let def: hir::Enum = sema.to_def(&it)?; 181 let def: hir::Enum = sema.to_def(&it)?;
163 Some(NameClass::Definition(Definition::ModuleDef(def.into()))) 182 Some(NameClass::Definition(Definition::ModuleDef(def.into())))
164 }, 183 },
165 ast::TraitDef(it) => { 184 ast::Trait(it) => {
166 let def: hir::Trait = sema.to_def(&it)?; 185 let def: hir::Trait = sema.to_def(&it)?;
167 Some(NameClass::Definition(Definition::ModuleDef(def.into()))) 186 Some(NameClass::Definition(Definition::ModuleDef(def.into())))
168 }, 187 },
169 ast::StaticDef(it) => { 188 ast::Static(it) => {
170 let def: hir::Static = sema.to_def(&it)?; 189 let def: hir::Static = sema.to_def(&it)?;
171 Some(NameClass::Definition(Definition::ModuleDef(def.into()))) 190 Some(NameClass::Definition(Definition::ModuleDef(def.into())))
172 }, 191 },
173 ast::EnumVariant(it) => { 192 ast::Variant(it) => {
174 let def: hir::EnumVariant = sema.to_def(&it)?; 193 let def: hir::EnumVariant = sema.to_def(&it)?;
175 Some(NameClass::Definition(Definition::ModuleDef(def.into()))) 194 Some(NameClass::Definition(Definition::ModuleDef(def.into())))
176 }, 195 },
177 ast::FnDef(it) => { 196 ast::Fn(it) => {
178 let def: hir::Function = sema.to_def(&it)?; 197 let def: hir::Function = sema.to_def(&it)?;
179 Some(NameClass::Definition(Definition::ModuleDef(def.into()))) 198 Some(NameClass::Definition(Definition::ModuleDef(def.into())))
180 }, 199 },
181 ast::ConstDef(it) => { 200 ast::Const(it) => {
182 let def: hir::Const = sema.to_def(&it)?; 201 let def: hir::Const = sema.to_def(&it)?;
183 Some(NameClass::Definition(Definition::ModuleDef(def.into()))) 202 Some(NameClass::Definition(Definition::ModuleDef(def.into())))
184 }, 203 },
185 ast::TypeAliasDef(it) => { 204 ast::TypeAlias(it) => {
186 let def: hir::TypeAlias = sema.to_def(&it)?; 205 let def: hir::TypeAlias = sema.to_def(&it)?;
187 Some(NameClass::Definition(Definition::ModuleDef(def.into()))) 206 Some(NameClass::Definition(Definition::ModuleDef(def.into())))
188 }, 207 },
@@ -236,7 +255,7 @@ pub fn classify_name_ref(
236 } 255 }
237 } 256 }
238 257
239 if let Some(record_field) = ast::RecordField::for_field_name(name_ref) { 258 if let Some(record_field) = ast::RecordExprField::for_field_name(name_ref) {
240 if let Some((field, local)) = sema.resolve_record_field(&record_field) { 259 if let Some((field, local)) = sema.resolve_record_field(&record_field) {
241 let field = Definition::Field(field); 260 let field = Definition::Field(field);
242 let res = match local { 261 let res = match local {
@@ -247,7 +266,7 @@ pub fn classify_name_ref(
247 } 266 }
248 } 267 }
249 268
250 if let Some(record_field_pat) = ast::RecordFieldPat::cast(parent.clone()) { 269 if let Some(record_field_pat) = ast::RecordPatField::cast(parent.clone()) {
251 if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { 270 if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) {
252 let field = Definition::Field(field); 271 let field = Definition::Field(field);
253 return Some(NameRefClass::Definition(field)); 272 return Some(NameRefClass::Definition(field));
diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs
index a7cae37b0..0b862b449 100644
--- a/crates/ra_ide_db/src/search.rs
+++ b/crates/ra_ide_db/src/search.rs
@@ -315,7 +315,7 @@ fn is_record_lit_name_ref(name_ref: &ast::NameRef) -> bool {
315 name_ref 315 name_ref
316 .syntax() 316 .syntax()
317 .ancestors() 317 .ancestors()
318 .find_map(ast::RecordLit::cast) 318 .find_map(ast::RecordExpr::cast)
319 .and_then(|l| l.path()) 319 .and_then(|l| l.path())
320 .and_then(|p| p.segment()) 320 .and_then(|p| p.segment())
321 .map(|p| p.name_ref().as_ref() == Some(name_ref)) 321 .map(|p| p.name_ref().as_ref() == Some(name_ref))
diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs
index 131e2a128..35a2c5be3 100644
--- a/crates/ra_ide_db/src/symbol_index.rs
+++ b/crates/ra_ide_db/src/symbol_index.rs
@@ -344,7 +344,7 @@ impl Query {
344} 344}
345 345
346fn is_type(kind: SyntaxKind) -> bool { 346fn is_type(kind: SyntaxKind) -> bool {
347 matches!(kind, STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF) 347 matches!(kind, STRUCT | ENUM | TRAIT | TYPE_ALIAS)
348} 348}
349 349
350/// The actual data that is stored in the index. It should be as compact as 350/// The actual data that is stored in the index. It should be as compact as
@@ -397,14 +397,14 @@ fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> {
397 } 397 }
398 match_ast! { 398 match_ast! {
399 match node { 399 match node {
400 ast::FnDef(it) => decl(it), 400 ast::Fn(it) => decl(it),
401 ast::StructDef(it) => decl(it), 401 ast::Struct(it) => decl(it),
402 ast::EnumDef(it) => decl(it), 402 ast::Enum(it) => decl(it),
403 ast::TraitDef(it) => decl(it), 403 ast::Trait(it) => decl(it),
404 ast::Module(it) => decl(it), 404 ast::Module(it) => decl(it),
405 ast::TypeAliasDef(it) => decl(it), 405 ast::TypeAlias(it) => decl(it),
406 ast::ConstDef(it) => decl(it), 406 ast::Const(it) => decl(it),
407 ast::StaticDef(it) => decl(it), 407 ast::Static(it) => decl(it),
408 ast::MacroCall(it) => { 408 ast::MacroCall(it) => {
409 if it.is_macro_rules().is_some() { 409 if it.is_macro_rules().is_some() {
410 decl(it) 410 decl(it)
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs
index fc4133a67..5fc48507f 100644
--- a/crates/ra_mbe/src/syntax_bridge.rs
+++ b/crates/ra_mbe/src/syntax_bridge.rs
@@ -825,7 +825,7 @@ mod tests {
825 #[test] 825 #[test]
826 fn test_token_tree_multi_char_punct() { 826 fn test_token_tree_multi_char_punct() {
827 let source_file = ast::SourceFile::parse("struct Foo { a: x::Y }").ok().unwrap(); 827 let source_file = ast::SourceFile::parse("struct Foo { a: x::Y }").ok().unwrap();
828 let struct_def = source_file.syntax().descendants().find_map(ast::StructDef::cast).unwrap(); 828 let struct_def = source_file.syntax().descendants().find_map(ast::Struct::cast).unwrap();
829 let tt = ast_to_token_tree(&struct_def).unwrap().0; 829 let tt = ast_to_token_tree(&struct_def).unwrap().0;
830 token_tree_to_syntax_node(&tt, FragmentKind::Item).unwrap(); 830 token_tree_to_syntax_node(&tt, FragmentKind::Item).unwrap();
831 } 831 }
diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs
index c43003fd6..286983d60 100644
--- a/crates/ra_mbe/src/tests.rs
+++ b/crates/ra_mbe/src/tests.rs
@@ -258,7 +258,7 @@ fn test_expr_order() {
258 assert_eq_text!( 258 assert_eq_text!(
259 dump.trim(), 259 dump.trim(),
260 r#"[email protected] 260 r#"[email protected]
261 FN_DEF@0..15 261 [email protected]
262 [email protected] "fn" 262 [email protected] "fn"
263 [email protected] 263 [email protected]
264 [email protected] "bar" 264 [email protected] "bar"
@@ -490,13 +490,13 @@ fn test_expand_to_item_list() {
490 format!("{:#?}", tree).trim(), 490 format!("{:#?}", tree).trim(),
491 r#" 491 r#"
492[email protected] 492[email protected]
493 STRUCT_DEF@0..20 493 [email protected]
494 [email protected] "struct" 494 [email protected] "struct"
495 [email protected] 495 [email protected]
496 [email protected] "Foo" 496 [email protected] "Foo"
497 RECORD_FIELD_DEF_[email protected] 497 [email protected]
498 [email protected] "{" 498 [email protected] "{"
499 RECORD_FIELD_DEF@10..19 499 [email protected]
500 [email protected] 500 [email protected]
501 [email protected] "field" 501 [email protected] "field"
502 [email protected] ":" 502 [email protected] ":"
@@ -506,13 +506,13 @@ [email protected]
506 [email protected] 506 [email protected]
507 [email protected] "u32" 507 [email protected] "u32"
508 [email protected] "}" 508 [email protected] "}"
509 STRUCT_DEF@20..40 509 [email protected]
510 [email protected] "struct" 510 [email protected] "struct"
511 [email protected] 511 [email protected]
512 [email protected] "Bar" 512 [email protected] "Bar"
513 RECORD_FIELD_DEF_[email protected] 513 [email protected]
514 [email protected] "{" 514 [email protected] "{"
515 RECORD_FIELD_DEF@30..39 515 [email protected]
516 [email protected] 516 [email protected]
517 [email protected] "field" 517 [email protected] "field"
518 [email protected] ":" 518 [email protected] ":"
@@ -625,7 +625,7 @@ fn test_tt_to_stmts() {
625 r#"[email protected] 625 r#"[email protected]
626 [email protected] 626 [email protected]
627 [email protected] "let" 627 [email protected] "let"
628 BIN[email protected] 628 IDENT[email protected]
629 [email protected] 629 [email protected]
630 [email protected] "a" 630 [email protected] "a"
631 [email protected] "=" 631 [email protected] "="
@@ -1116,7 +1116,7 @@ fn test_vec() {
1116 [email protected] "{" 1116 [email protected] "{"
1117 [email protected] 1117 [email protected]
1118 [email protected] "let" 1118 [email protected] "let"
1119 BIN[email protected] 1119 IDENT[email protected]
1120 [email protected] "mut" 1120 [email protected] "mut"
1121 [email protected] 1121 [email protected]
1122 [email protected] "v" 1122 [email protected] "v"
@@ -1467,7 +1467,7 @@ macro_rules! quick_error {
1467 buf [ ] 1467 buf [ ]
1468 queue [ ] 1468 queue [ ]
1469 ) => { 1469 ) => {
1470 quick_error!(ENUM_DEFINITION [enum $name $( #[$meta] )*] 1470 quick_error!(ENUMINITION [enum $name $( #[$meta] )*]
1471 body [] 1471 body []
1472 queue [$( 1472 queue [$(
1473 $( #[$imeta] )* 1473 $( #[$imeta] )*
@@ -1489,7 +1489,7 @@ quick_error ! (SORT [enum Wrapped # [derive (Debug)]] items [
1489"#, 1489"#,
1490 ); 1490 );
1491 1491
1492 assert_eq!(expanded.to_string(), "quick_error ! (ENUM_DEFINITION [enum Wrapped # [derive (Debug)]] body [] queue [=> One : UNIT [] => Two : TUPLE [s : String]]) ;"); 1492 assert_eq!(expanded.to_string(), "quick_error ! (ENUMINITION [enum Wrapped # [derive (Debug)]] body [] queue [=> One : UNIT [] => Two : TUPLE [s : String]]) ;");
1493} 1493}
1494 1494
1495#[test] 1495#[test]
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs
index caedeead0..c2e1d701e 100644
--- a/crates/ra_parser/src/grammar.rs
+++ b/crates/ra_parser/src/grammar.rs
@@ -142,19 +142,19 @@ pub(crate) fn reparser(
142) -> Option<fn(&mut Parser)> { 142) -> Option<fn(&mut Parser)> {
143 let res = match node { 143 let res = match node {
144 BLOCK_EXPR => expressions::block_expr, 144 BLOCK_EXPR => expressions::block_expr,
145 RECORD_FIELD_DEF_LIST => items::record_field_def_list, 145 RECORD_FIELD_LIST => items::record_field_def_list,
146 RECORD_FIELD_LIST => items::record_field_list, 146 RECORD_EXPR_FIELD_LIST => items::record_field_list,
147 ENUM_VARIANT_LIST => items::enum_variant_list, 147 VARIANT_LIST => items::enum_variant_list,
148 MATCH_ARM_LIST => items::match_arm_list, 148 MATCH_ARM_LIST => items::match_arm_list,
149 USE_TREE_LIST => items::use_tree_list, 149 USE_TREE_LIST => items::use_tree_list,
150 EXTERN_ITEM_LIST => items::extern_item_list, 150 EXTERN_ITEM_LIST => items::extern_item_list,
151 TOKEN_TREE if first_child? == T!['{'] => items::token_tree, 151 TOKEN_TREE if first_child? == T!['{'] => items::token_tree,
152 ITEM_LIST => match parent? { 152 ASSOC_ITEM_LIST => match parent? {
153 IMPL_DEF => items::impl_item_list, 153 IMPL => items::impl_item_list,
154 TRAIT_DEF => items::trait_item_list, 154 TRAIT => items::trait_item_list,
155 MODULE => items::mod_item_list,
156 _ => return None, 155 _ => return None,
157 }, 156 },
157 ITEM_LIST => items::mod_item_list,
158 _ => return None, 158 _ => return None,
159 }; 159 };
160 Some(res) 160 Some(res)
@@ -224,7 +224,7 @@ fn opt_alias(p: &mut Parser) {
224 if !p.eat(T![_]) { 224 if !p.eat(T![_]) {
225 name(p); 225 name(p);
226 } 226 }
227 m.complete(p, ALIAS); 227 m.complete(p, RENAME);
228 } 228 }
229} 229}
230 230
@@ -270,10 +270,6 @@ fn name_ref(p: &mut Parser) {
270 let m = p.start(); 270 let m = p.start();
271 p.bump(IDENT); 271 p.bump(IDENT);
272 m.complete(p, NAME_REF); 272 m.complete(p, NAME_REF);
273 } else if p.at(T![self]) {
274 let m = p.start();
275 p.bump(T![self]);
276 m.complete(p, T![self]);
277 } else { 273 } else {
278 p.err_and_bump("expected identifier"); 274 p.err_and_bump("expected identifier");
279 } 275 }
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs
index 6e72eea66..e1c25a838 100644
--- a/crates/ra_parser/src/grammar/expressions.rs
+++ b/crates/ra_parser/src/grammar/expressions.rs
@@ -587,7 +587,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) {
587 match p.current() { 587 match p.current() {
588 T!['{'] if !r.forbid_structs => { 588 T!['{'] if !r.forbid_structs => {
589 record_field_list(p); 589 record_field_list(p);
590 (m.complete(p, RECORD_LIT), BlockLike::NotBlock) 590 (m.complete(p, RECORD_EXPR), BlockLike::NotBlock)
591 } 591 }
592 T![!] if !p.at(T![!=]) => { 592 T![!] if !p.at(T![!=]) => {
593 let block_like = items::macro_call_after_excl(p); 593 let block_like = items::macro_call_after_excl(p);
@@ -627,7 +627,7 @@ pub(crate) fn record_field_list(p: &mut Parser) {
627 p.expect(T![:]); 627 p.expect(T![:]);
628 } 628 }
629 expr(p); 629 expr(p);
630 m.complete(p, RECORD_FIELD); 630 m.complete(p, RECORD_EXPR_FIELD);
631 } 631 }
632 T![.] if p.at(T![..]) => { 632 T![.] if p.at(T![..]) => {
633 m.abandon(p); 633 m.abandon(p);
@@ -648,5 +648,5 @@ pub(crate) fn record_field_list(p: &mut Parser) {
648 } 648 }
649 } 649 }
650 p.expect(T!['}']); 650 p.expect(T!['}']);
651 m.complete(p, RECORD_FIELD_LIST); 651 m.complete(p, RECORD_EXPR_FIELD_LIST);
652} 652}
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs
index 706a2f796..0b01d3bc6 100644
--- a/crates/ra_parser/src/grammar/expressions/atom.rs
+++ b/crates/ra_parser/src/grammar/expressions/atom.rs
@@ -250,7 +250,7 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker {
250 p.error("expected expression"); 250 p.error("expected expression");
251 } 251 }
252 } 252 }
253 m.complete(p, LAMBDA_EXPR) 253 m.complete(p, CLOSURE_EXPR)
254} 254}
255 255
256// test if_expr 256// test if_expr
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs
index 97642bc24..cca524cea 100644
--- a/crates/ra_parser/src/grammar/items.rs
+++ b/crates/ra_parser/src/grammar/items.rs
@@ -180,7 +180,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
180 // unsafe const fn bar() {} 180 // unsafe const fn bar() {}
181 T![fn] => { 181 T![fn] => {
182 fn_def(p); 182 fn_def(p);
183 m.complete(p, FN_DEF); 183 m.complete(p, FN);
184 } 184 }
185 185
186 // test unsafe_trait 186 // test unsafe_trait
@@ -193,7 +193,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
193 // unsafe auto trait T {} 193 // unsafe auto trait T {}
194 T![trait] => { 194 T![trait] => {
195 traits::trait_def(p); 195 traits::trait_def(p);
196 m.complete(p, TRAIT_DEF); 196 m.complete(p, TRAIT);
197 } 197 }
198 198
199 // test unsafe_impl 199 // test unsafe_impl
@@ -221,7 +221,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
221 // unsafe default impl Foo {} 221 // unsafe default impl Foo {}
222 T![impl] => { 222 T![impl] => {
223 traits::impl_def(p); 223 traits::impl_def(p);
224 m.complete(p, IMPL_DEF); 224 m.complete(p, IMPL);
225 } 225 }
226 226
227 // test existential_type 227 // test existential_type
@@ -304,10 +304,16 @@ fn extern_crate_item(p: &mut Parser, m: Marker) {
304 p.bump(T![extern]); 304 p.bump(T![extern]);
305 assert!(p.at(T![crate])); 305 assert!(p.at(T![crate]));
306 p.bump(T![crate]); 306 p.bump(T![crate]);
307 name_ref(p); 307
308 if p.at(T![self]) {
309 p.bump(T![self]);
310 } else {
311 name_ref(p);
312 }
313
308 opt_alias(p); 314 opt_alias(p);
309 p.expect(T![;]); 315 p.expect(T![;]);
310 m.complete(p, EXTERN_CRATE_ITEM); 316 m.complete(p, EXTERN_CRATE);
311} 317}
312 318
313pub(crate) fn extern_item_list(p: &mut Parser) { 319pub(crate) fn extern_item_list(p: &mut Parser) {
@@ -374,7 +380,7 @@ fn type_def(p: &mut Parser, m: Marker) {
374 types::type_(p); 380 types::type_(p);
375 } 381 }
376 p.expect(T![;]); 382 p.expect(T![;]);
377 m.complete(p, TYPE_ALIAS_DEF); 383 m.complete(p, TYPE_ALIAS);
378} 384}
379 385
380pub(crate) fn mod_item(p: &mut Parser, m: Marker) { 386pub(crate) fn mod_item(p: &mut Parser, m: Marker) {
diff --git a/crates/ra_parser/src/grammar/items/adt.rs b/crates/ra_parser/src/grammar/items/adt.rs
index 74b9f514b..addfb59d4 100644
--- a/crates/ra_parser/src/grammar/items/adt.rs
+++ b/crates/ra_parser/src/grammar/items/adt.rs
@@ -5,13 +5,13 @@ use super::*;
5pub(super) fn struct_def(p: &mut Parser, m: Marker) { 5pub(super) fn struct_def(p: &mut Parser, m: Marker) {
6 assert!(p.at(T![struct])); 6 assert!(p.at(T![struct]));
7 p.bump(T![struct]); 7 p.bump(T![struct]);
8 struct_or_union(p, m, T![struct], STRUCT_DEF); 8 struct_or_union(p, m, T![struct], STRUCT);
9} 9}
10 10
11pub(super) fn union_def(p: &mut Parser, m: Marker) { 11pub(super) fn union_def(p: &mut Parser, m: Marker) {
12 assert!(p.at_contextual_kw("union")); 12 assert!(p.at_contextual_kw("union"));
13 p.bump_remap(T![union]); 13 p.bump_remap(T![union]);
14 struct_or_union(p, m, T![union], UNION_DEF); 14 struct_or_union(p, m, T![union], UNION);
15} 15}
16 16
17fn struct_or_union(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) { 17fn struct_or_union(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) {
@@ -64,7 +64,7 @@ pub(super) fn enum_def(p: &mut Parser, m: Marker) {
64 } else { 64 } else {
65 p.error("expected `{`") 65 p.error("expected `{`")
66 } 66 }
67 m.complete(p, ENUM_DEF); 67 m.complete(p, ENUM);
68} 68}
69 69
70pub(crate) fn enum_variant_list(p: &mut Parser) { 70pub(crate) fn enum_variant_list(p: &mut Parser) {
@@ -91,7 +91,7 @@ pub(crate) fn enum_variant_list(p: &mut Parser) {
91 if p.eat(T![=]) { 91 if p.eat(T![=]) {
92 expressions::expr(p); 92 expressions::expr(p);
93 } 93 }
94 var.complete(p, ENUM_VARIANT); 94 var.complete(p, VARIANT);
95 } else { 95 } else {
96 var.abandon(p); 96 var.abandon(p);
97 p.err_and_bump("expected enum variant"); 97 p.err_and_bump("expected enum variant");
@@ -101,7 +101,7 @@ pub(crate) fn enum_variant_list(p: &mut Parser) {
101 } 101 }
102 } 102 }
103 p.expect(T!['}']); 103 p.expect(T!['}']);
104 m.complete(p, ENUM_VARIANT_LIST); 104 m.complete(p, VARIANT_LIST);
105} 105}
106 106
107pub(crate) fn record_field_def_list(p: &mut Parser) { 107pub(crate) fn record_field_def_list(p: &mut Parser) {
@@ -119,7 +119,7 @@ pub(crate) fn record_field_def_list(p: &mut Parser) {
119 } 119 }
120 } 120 }
121 p.expect(T!['}']); 121 p.expect(T!['}']);
122 m.complete(p, RECORD_FIELD_DEF_LIST); 122 m.complete(p, RECORD_FIELD_LIST);
123 123
124 fn record_field_def(p: &mut Parser) { 124 fn record_field_def(p: &mut Parser) {
125 let m = p.start(); 125 let m = p.start();
@@ -134,7 +134,7 @@ pub(crate) fn record_field_def_list(p: &mut Parser) {
134 name(p); 134 name(p);
135 p.expect(T![:]); 135 p.expect(T![:]);
136 types::type_(p); 136 types::type_(p);
137 m.complete(p, RECORD_FIELD_DEF); 137 m.complete(p, RECORD_FIELD);
138 } else { 138 } else {
139 m.abandon(p); 139 m.abandon(p);
140 p.err_and_bump("expected field declaration"); 140 p.err_and_bump("expected field declaration");
@@ -167,12 +167,12 @@ fn tuple_field_def_list(p: &mut Parser) {
167 break; 167 break;
168 } 168 }
169 types::type_(p); 169 types::type_(p);
170 m.complete(p, TUPLE_FIELD_DEF); 170 m.complete(p, TUPLE_FIELD);
171 171
172 if !p.at(T![')']) { 172 if !p.at(T![')']) {
173 p.expect(T![,]); 173 p.expect(T![,]);
174 } 174 }
175 } 175 }
176 p.expect(T![')']); 176 p.expect(T![')']);
177 m.complete(p, TUPLE_FIELD_DEF_LIST); 177 m.complete(p, TUPLE_FIELD_LIST);
178} 178}
diff --git a/crates/ra_parser/src/grammar/items/consts.rs b/crates/ra_parser/src/grammar/items/consts.rs
index 742a7e056..35ad766dc 100644
--- a/crates/ra_parser/src/grammar/items/consts.rs
+++ b/crates/ra_parser/src/grammar/items/consts.rs
@@ -3,11 +3,11 @@
3use super::*; 3use super::*;
4 4
5pub(super) fn static_def(p: &mut Parser, m: Marker) { 5pub(super) fn static_def(p: &mut Parser, m: Marker) {
6 const_or_static(p, m, T![static], STATIC_DEF) 6 const_or_static(p, m, T![static], STATIC)
7} 7}
8 8
9pub(super) fn const_def(p: &mut Parser, m: Marker) { 9pub(super) fn const_def(p: &mut Parser, m: Marker) {
10 const_or_static(p, m, T![const], CONST_DEF) 10 const_or_static(p, m, T![const], CONST)
11} 11}
12 12
13fn const_or_static(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) { 13fn const_or_static(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) {
diff --git a/crates/ra_parser/src/grammar/items/traits.rs b/crates/ra_parser/src/grammar/items/traits.rs
index c819e33be..ef9c8ff5b 100644
--- a/crates/ra_parser/src/grammar/items/traits.rs
+++ b/crates/ra_parser/src/grammar/items/traits.rs
@@ -50,7 +50,7 @@ pub(crate) fn trait_item_list(p: &mut Parser) {
50 item_or_macro(p, true, ItemFlavor::Trait); 50 item_or_macro(p, true, ItemFlavor::Trait);
51 } 51 }
52 p.expect(T!['}']); 52 p.expect(T!['}']);
53 m.complete(p, ITEM_LIST); 53 m.complete(p, ASSOC_ITEM_LIST);
54} 54}
55 55
56// test impl_def 56// test impl_def
@@ -107,7 +107,7 @@ pub(crate) fn impl_item_list(p: &mut Parser) {
107 item_or_macro(p, true, ItemFlavor::Mod); 107 item_or_macro(p, true, ItemFlavor::Mod);
108 } 108 }
109 p.expect(T!['}']); 109 p.expect(T!['}']);
110 m.complete(p, ITEM_LIST); 110 m.complete(p, ASSOC_ITEM_LIST);
111} 111}
112 112
113// test impl_type_params 113// test impl_type_params
diff --git a/crates/ra_parser/src/grammar/items/use_item.rs b/crates/ra_parser/src/grammar/items/use_item.rs
index 3a0c7a31a..8e836a77e 100644
--- a/crates/ra_parser/src/grammar/items/use_item.rs
+++ b/crates/ra_parser/src/grammar/items/use_item.rs
@@ -7,7 +7,7 @@ pub(super) fn use_item(p: &mut Parser, m: Marker) {
7 p.bump(T![use]); 7 p.bump(T![use]);
8 use_tree(p, true); 8 use_tree(p, true);
9 p.expect(T![;]); 9 p.expect(T![;]);
10 m.complete(p, USE_ITEM); 10 m.complete(p, USE);
11} 11}
12 12
13/// Parse a use 'tree', such as `some::path` in `use some::path;` 13/// Parse a use 'tree', such as `some::path` in `use some::path;`
diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs
index 427c0eb49..716bdc978 100644
--- a/crates/ra_parser/src/grammar/patterns.rs
+++ b/crates/ra_parser/src/grammar/patterns.rs
@@ -192,7 +192,7 @@ fn record_field_pat_list(p: &mut Parser) {
192 p.bump(T!['{']); 192 p.bump(T!['{']);
193 while !p.at(EOF) && !p.at(T!['}']) { 193 while !p.at(EOF) && !p.at(T!['}']) {
194 match p.current() { 194 match p.current() {
195 // A trailing `..` is *not* treated as a DOT_DOT_PAT. 195 // A trailing `..` is *not* treated as a REST_PAT.
196 T![.] if p.at(T![..]) => p.bump(T![..]), 196 T![.] if p.at(T![..]) => p.bump(T![..]),
197 T!['{'] => error_block(p, "expected ident"), 197 T!['{'] => error_block(p, "expected ident"),
198 198
@@ -217,7 +217,7 @@ fn record_field_pat_list(p: &mut Parser) {
217 bind_pat(p, false); 217 bind_pat(p, false);
218 } 218 }
219 } 219 }
220 m.complete(p, RECORD_FIELD_PAT); 220 m.complete(p, RECORD_PAT_FIELD);
221 } 221 }
222 } 222 }
223 if !p.at(T!['}']) { 223 if !p.at(T!['}']) {
@@ -225,7 +225,7 @@ fn record_field_pat_list(p: &mut Parser) {
225 } 225 }
226 } 226 }
227 p.expect(T!['}']); 227 p.expect(T!['}']);
228 m.complete(p, RECORD_FIELD_PAT_LIST); 228 m.complete(p, RECORD_PAT_FIELD_LIST);
229} 229}
230 230
231// test placeholder_pat 231// test placeholder_pat
@@ -234,7 +234,7 @@ fn placeholder_pat(p: &mut Parser) -> CompletedMarker {
234 assert!(p.at(T![_])); 234 assert!(p.at(T![_]));
235 let m = p.start(); 235 let m = p.start();
236 p.bump(T![_]); 236 p.bump(T![_]);
237 m.complete(p, PLACEHOLDER_PAT) 237 m.complete(p, WILDCARD_PAT)
238} 238}
239 239
240// test dot_dot_pat 240// test dot_dot_pat
@@ -267,7 +267,7 @@ fn dot_dot_pat(p: &mut Parser) -> CompletedMarker {
267 assert!(p.at(T![..])); 267 assert!(p.at(T![..]));
268 let m = p.start(); 268 let m = p.start();
269 p.bump(T![..]); 269 p.bump(T![..]);
270 m.complete(p, DOT_DOT_PAT) 270 m.complete(p, REST_PAT)
271} 271}
272 272
273// test ref_pat 273// test ref_pat
@@ -361,7 +361,7 @@ fn bind_pat(p: &mut Parser, with_at: bool) -> CompletedMarker {
361 if with_at && p.eat(T![@]) { 361 if with_at && p.eat(T![@]) {
362 pattern_single(p); 362 pattern_single(p);
363 } 363 }
364 m.complete(p, BIND_PAT) 364 m.complete(p, IDENT_PAT)
365} 365}
366 366
367// test box_pat 367// test box_pat
diff --git a/crates/ra_parser/src/grammar/type_args.rs b/crates/ra_parser/src/grammar/type_args.rs
index 2d61f9d80..aef7cd6fb 100644
--- a/crates/ra_parser/src/grammar/type_args.rs
+++ b/crates/ra_parser/src/grammar/type_args.rs
@@ -22,7 +22,7 @@ pub(super) fn opt_type_arg_list(p: &mut Parser, colon_colon_required: bool) {
22 } 22 }
23 } 23 }
24 p.expect(T![>]); 24 p.expect(T![>]);
25 m.complete(p, TYPE_ARG_LIST); 25 m.complete(p, GENERIC_ARG_LIST);
26} 26}
27 27
28// test type_arg 28// test type_arg
@@ -52,7 +52,7 @@ fn type_arg(p: &mut Parser) {
52 m.complete(p, CONST_ARG); 52 m.complete(p, CONST_ARG);
53 } 53 }
54 k if k.is_literal() => { 54 k if k.is_literal() => {
55 p.bump(k); 55 expressions::literal(p);
56 m.complete(p, CONST_ARG); 56 m.complete(p, CONST_ARG);
57 } 57 }
58 _ => { 58 _ => {
diff --git a/crates/ra_parser/src/grammar/type_params.rs b/crates/ra_parser/src/grammar/type_params.rs
index d1330d4b9..90dabb4c0 100644
--- a/crates/ra_parser/src/grammar/type_params.rs
+++ b/crates/ra_parser/src/grammar/type_params.rs
@@ -36,7 +36,7 @@ fn type_param_list(p: &mut Parser) {
36 } 36 }
37 } 37 }
38 p.expect(T![>]); 38 p.expect(T![>]);
39 m.complete(p, TYPE_PARAM_LIST); 39 m.complete(p, GENERIC_PARAM_LIST);
40} 40}
41 41
42fn lifetime_param(p: &mut Parser, m: Marker) { 42fn lifetime_param(p: &mut Parser, m: Marker) {
diff --git a/crates/ra_parser/src/grammar/types.rs b/crates/ra_parser/src/grammar/types.rs
index 9e8e3bd97..0aa173a52 100644
--- a/crates/ra_parser/src/grammar/types.rs
+++ b/crates/ra_parser/src/grammar/types.rs
@@ -117,7 +117,7 @@ fn pointer_type(p: &mut Parser) {
117 }; 117 };
118 118
119 type_no_bounds(p); 119 type_no_bounds(p);
120 m.complete(p, POINTER_TYPE); 120 m.complete(p, PTR_TYPE);
121} 121}
122 122
123fn array_or_slice_type(p: &mut Parser) { 123fn array_or_slice_type(p: &mut Parser) {
@@ -163,7 +163,7 @@ fn reference_type(p: &mut Parser) {
163 p.eat(LIFETIME); 163 p.eat(LIFETIME);
164 p.eat(T![mut]); 164 p.eat(T![mut]);
165 type_no_bounds(p); 165 type_no_bounds(p);
166 m.complete(p, REFERENCE_TYPE); 166 m.complete(p, REF_TYPE);
167} 167}
168 168
169// test placeholder_type 169// test placeholder_type
@@ -172,7 +172,7 @@ fn placeholder_type(p: &mut Parser) {
172 assert!(p.at(T![_])); 172 assert!(p.at(T![_]));
173 let m = p.start(); 173 let m = p.start();
174 p.bump(T![_]); 174 p.bump(T![_]);
175 m.complete(p, PLACEHOLDER_TYPE); 175 m.complete(p, INFER_TYPE);
176} 176}
177 177
178// test fn_pointer_type 178// test fn_pointer_type
@@ -201,7 +201,7 @@ fn fn_pointer_type(p: &mut Parser) {
201 // test fn_pointer_type_with_ret 201 // test fn_pointer_type_with_ret
202 // type F = fn() -> (); 202 // type F = fn() -> ();
203 opt_fn_ret_type(p); 203 opt_fn_ret_type(p);
204 m.complete(p, FN_POINTER_TYPE); 204 m.complete(p, FN_PTR_TYPE);
205} 205}
206 206
207pub(super) fn for_binder(p: &mut Parser) { 207pub(super) fn for_binder(p: &mut Parser) {
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs
index e7404492a..192ecd864 100644
--- a/crates/ra_parser/src/syntax_kind/generated.rs
+++ b/crates/ra_parser/src/syntax_kind/generated.rs
@@ -1,7 +1,7 @@
1//! Generated file, do not edit by hand, see `xtask/src/codegen` 1//! Generated file, do not edit by hand, see `xtask/src/codegen`
2 2
3#![allow(bad_style, missing_docs, unreachable_pub)] 3#![allow(bad_style, missing_docs, unreachable_pub)]
4#[doc = r" The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`."] 4#[doc = r" The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT`."]
5#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] 5#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
6#[repr(u16)] 6#[repr(u16)]
7pub enum SyntaxKind { 7pub enum SyntaxKind {
@@ -123,19 +123,19 @@ pub enum SyntaxKind {
123 L_DOLLAR, 123 L_DOLLAR,
124 R_DOLLAR, 124 R_DOLLAR,
125 SOURCE_FILE, 125 SOURCE_FILE,
126 STRUCT_DEF, 126 STRUCT,
127 UNION_DEF, 127 UNION,
128 ENUM_DEF, 128 ENUM,
129 FN_DEF, 129 FN,
130 RET_TYPE, 130 RET_TYPE,
131 EXTERN_CRATE_ITEM, 131 EXTERN_CRATE,
132 MODULE, 132 MODULE,
133 USE_ITEM, 133 USE,
134 STATIC_DEF, 134 STATIC,
135 CONST_DEF, 135 CONST,
136 TRAIT_DEF, 136 TRAIT,
137 IMPL_DEF, 137 IMPL,
138 TYPE_ALIAS_DEF, 138 TYPE_ALIAS,
139 MACRO_CALL, 139 MACRO_CALL,
140 TOKEN_TREE, 140 TOKEN_TREE,
141 MACRO_DEF, 141 MACRO_DEF,
@@ -143,12 +143,12 @@ pub enum SyntaxKind {
143 TUPLE_TYPE, 143 TUPLE_TYPE,
144 NEVER_TYPE, 144 NEVER_TYPE,
145 PATH_TYPE, 145 PATH_TYPE,
146 POINTER_TYPE, 146 PTR_TYPE,
147 ARRAY_TYPE, 147 ARRAY_TYPE,
148 SLICE_TYPE, 148 SLICE_TYPE,
149 REFERENCE_TYPE, 149 REF_TYPE,
150 PLACEHOLDER_TYPE, 150 INFER_TYPE,
151 FN_POINTER_TYPE, 151 FN_PTR_TYPE,
152 FOR_TYPE, 152 FOR_TYPE,
153 IMPL_TRAIT_TYPE, 153 IMPL_TRAIT_TYPE,
154 DYN_TRAIT_TYPE, 154 DYN_TRAIT_TYPE,
@@ -156,13 +156,13 @@ pub enum SyntaxKind {
156 PAREN_PAT, 156 PAREN_PAT,
157 REF_PAT, 157 REF_PAT,
158 BOX_PAT, 158 BOX_PAT,
159 BIND_PAT, 159 IDENT_PAT,
160 PLACEHOLDER_PAT, 160 WILDCARD_PAT,
161 DOT_DOT_PAT, 161 REST_PAT,
162 PATH_PAT, 162 PATH_PAT,
163 RECORD_PAT, 163 RECORD_PAT,
164 RECORD_FIELD_PAT_LIST, 164 RECORD_PAT_FIELD_LIST,
165 RECORD_FIELD_PAT, 165 RECORD_PAT_FIELD,
166 TUPLE_STRUCT_PAT, 166 TUPLE_STRUCT_PAT,
167 TUPLE_PAT, 167 TUPLE_PAT,
168 SLICE_PAT, 168 SLICE_PAT,
@@ -173,7 +173,7 @@ pub enum SyntaxKind {
173 ARRAY_EXPR, 173 ARRAY_EXPR,
174 PAREN_EXPR, 174 PAREN_EXPR,
175 PATH_EXPR, 175 PATH_EXPR,
176 LAMBDA_EXPR, 176 CLOSURE_EXPR,
177 IF_EXPR, 177 IF_EXPR,
178 WHILE_EXPR, 178 WHILE_EXPR,
179 CONDITION, 179 CONDITION,
@@ -188,9 +188,9 @@ pub enum SyntaxKind {
188 MATCH_ARM_LIST, 188 MATCH_ARM_LIST,
189 MATCH_ARM, 189 MATCH_ARM,
190 MATCH_GUARD, 190 MATCH_GUARD,
191 RECORD_LIT, 191 RECORD_EXPR,
192 RECORD_FIELD_LIST, 192 RECORD_EXPR_FIELD_LIST,
193 RECORD_FIELD, 193 RECORD_EXPR_FIELD,
194 EFFECT_EXPR, 194 EFFECT_EXPR,
195 BOX_EXPR, 195 BOX_EXPR,
196 CALL_EXPR, 196 CALL_EXPR,
@@ -206,13 +206,14 @@ pub enum SyntaxKind {
206 BIN_EXPR, 206 BIN_EXPR,
207 EXTERN_BLOCK, 207 EXTERN_BLOCK,
208 EXTERN_ITEM_LIST, 208 EXTERN_ITEM_LIST,
209 ENUM_VARIANT, 209 VARIANT,
210 RECORD_FIELD_DEF_LIST, 210 RECORD_FIELD_LIST,
211 RECORD_FIELD_DEF, 211 RECORD_FIELD,
212 TUPLE_FIELD_DEF_LIST, 212 TUPLE_FIELD_LIST,
213 TUPLE_FIELD_DEF, 213 TUPLE_FIELD,
214 ENUM_VARIANT_LIST, 214 VARIANT_LIST,
215 ITEM_LIST, 215 ITEM_LIST,
216 ASSOC_ITEM_LIST,
216 ATTR, 217 ATTR,
217 META_ITEM, 218 META_ITEM,
218 USE_TREE, 219 USE_TREE,
@@ -220,7 +221,7 @@ pub enum SyntaxKind {
220 PATH, 221 PATH,
221 PATH_SEGMENT, 222 PATH_SEGMENT,
222 LITERAL, 223 LITERAL,
223 ALIAS, 224 RENAME,
224 VISIBILITY, 225 VISIBILITY,
225 WHERE_CLAUSE, 226 WHERE_CLAUSE,
226 WHERE_PRED, 227 WHERE_PRED,
@@ -229,11 +230,12 @@ pub enum SyntaxKind {
229 NAME_REF, 230 NAME_REF,
230 LET_STMT, 231 LET_STMT,
231 EXPR_STMT, 232 EXPR_STMT,
232 TYPE_PARAM_LIST, 233 GENERIC_PARAM_LIST,
234 GENERIC_PARAM,
233 LIFETIME_PARAM, 235 LIFETIME_PARAM,
234 TYPE_PARAM, 236 TYPE_PARAM,
235 CONST_PARAM, 237 CONST_PARAM,
236 TYPE_ARG_LIST, 238 GENERIC_ARG_LIST,
237 LIFETIME_ARG, 239 LIFETIME_ARG,
238 TYPE_ARG, 240 TYPE_ARG,
239 ASSOC_TYPE_ARG, 241 ASSOC_TYPE_ARG,
@@ -362,4 +364,4 @@ impl SyntaxKind {
362 } 364 }
363} 365}
364#[macro_export] 366#[macro_export]
365macro_rules ! T { [ ; ] => { $ crate :: SyntaxKind :: SEMICOLON } ; [ , ] => { $ crate :: SyntaxKind :: COMMA } ; [ '(' ] => { $ crate :: SyntaxKind :: L_PAREN } ; [ ')' ] => { $ crate :: SyntaxKind :: R_PAREN } ; [ '{' ] => { $ crate :: SyntaxKind :: L_CURLY } ; [ '}' ] => { $ crate :: SyntaxKind :: R_CURLY } ; [ '[' ] => { $ crate :: SyntaxKind :: L_BRACK } ; [ ']' ] => { $ crate :: SyntaxKind :: R_BRACK } ; [ < ] => { $ crate :: SyntaxKind :: L_ANGLE } ; [ > ] => { $ crate :: SyntaxKind :: R_ANGLE } ; [ @ ] => { $ crate :: SyntaxKind :: AT } ; [ # ] => { $ crate :: SyntaxKind :: POUND } ; [ ~ ] => { $ crate :: SyntaxKind :: TILDE } ; [ ? ] => { $ crate :: SyntaxKind :: QUESTION } ; [ $ ] => { $ crate :: SyntaxKind :: DOLLAR } ; [ & ] => { $ crate :: SyntaxKind :: AMP } ; [ | ] => { $ crate :: SyntaxKind :: PIPE } ; [ + ] => { $ crate :: SyntaxKind :: PLUS } ; [ * ] => { $ crate :: SyntaxKind :: STAR } ; [ / ] => { $ crate :: SyntaxKind :: SLASH } ; [ ^ ] => { $ crate :: SyntaxKind :: CARET } ; [ % ] => { $ crate :: SyntaxKind :: PERCENT } ; [ _ ] => { $ crate :: SyntaxKind :: UNDERSCORE } ; [ . ] => { $ crate :: SyntaxKind :: DOT } ; [ .. ] => { $ crate :: SyntaxKind :: DOT2 } ; [ ... ] => { $ crate :: SyntaxKind :: DOT3 } ; [ ..= ] => { $ crate :: SyntaxKind :: DOT2EQ } ; [ : ] => { $ crate :: SyntaxKind :: COLON } ; [ :: ] => { $ crate :: SyntaxKind :: COLON2 } ; [ = ] => { $ crate :: SyntaxKind :: EQ } ; [ == ] => { $ crate :: SyntaxKind :: EQ2 } ; [ => ] => { $ crate :: SyntaxKind :: FAT_ARROW } ; [ ! ] => { $ crate :: SyntaxKind :: BANG } ; [ != ] => { $ crate :: SyntaxKind :: NEQ } ; [ - ] => { $ crate :: SyntaxKind :: MINUS } ; [ -> ] => { $ crate :: SyntaxKind :: THIN_ARROW } ; [ <= ] => { $ crate :: SyntaxKind :: LTEQ } ; [ >= ] => { $ crate :: SyntaxKind :: GTEQ } ; [ += ] => { $ crate :: SyntaxKind :: PLUSEQ } ; [ -= ] => { $ crate :: SyntaxKind :: MINUSEQ } ; [ |= ] => { $ crate :: SyntaxKind :: PIPEEQ } ; [ &= ] => { $ crate :: SyntaxKind :: AMPEQ } ; [ ^= ] => { $ crate :: SyntaxKind :: CARETEQ } ; [ /= ] => { $ crate :: SyntaxKind :: SLASHEQ } ; [ *= ] => { $ crate :: SyntaxKind :: STAREQ } ; [ %= ] => { $ crate :: SyntaxKind :: PERCENTEQ } ; [ && ] => { $ crate :: SyntaxKind :: AMP2 } ; [ || ] => { $ crate :: SyntaxKind :: PIPE2 } ; [ << ] => { $ crate :: SyntaxKind :: SHL } ; [ >> ] => { $ crate :: SyntaxKind :: SHR } ; [ <<= ] => { $ crate :: SyntaxKind :: SHLEQ } ; [ >>= ] => { $ crate :: SyntaxKind :: SHREQ } ; [ as ] => { $ crate :: SyntaxKind :: AS_KW } ; [ async ] => { $ crate :: SyntaxKind :: ASYNC_KW } ; [ await ] => { $ crate :: SyntaxKind :: AWAIT_KW } ; [ box ] => { $ crate :: SyntaxKind :: BOX_KW } ; [ break ] => { $ crate :: SyntaxKind :: BREAK_KW } ; [ const ] => { $ crate :: SyntaxKind :: CONST_KW } ; [ continue ] => { $ crate :: SyntaxKind :: CONTINUE_KW } ; [ crate ] => { $ crate :: SyntaxKind :: CRATE_KW } ; [ dyn ] => { $ crate :: SyntaxKind :: DYN_KW } ; [ else ] => { $ crate :: SyntaxKind :: ELSE_KW } ; [ enum ] => { $ crate :: SyntaxKind :: ENUM_KW } ; [ extern ] => { $ crate :: SyntaxKind :: EXTERN_KW } ; [ false ] => { $ crate :: SyntaxKind :: FALSE_KW } ; [ fn ] => { $ crate :: SyntaxKind :: FN_KW } ; [ for ] => { $ crate :: SyntaxKind :: FOR_KW } ; [ if ] => { $ crate :: SyntaxKind :: IF_KW } ; [ impl ] => { $ crate :: SyntaxKind :: IMPL_KW } ; [ in ] => { $ crate :: SyntaxKind :: IN_KW } ; [ let ] => { $ crate :: SyntaxKind :: LET_KW } ; [ loop ] => { $ crate :: SyntaxKind :: LOOP_KW } ; [ macro ] => { $ crate :: SyntaxKind :: MACRO_KW } ; [ match ] => { $ crate :: SyntaxKind :: MATCH_KW } ; [ mod ] => { $ crate :: SyntaxKind :: MOD_KW } ; [ move ] => { $ crate :: SyntaxKind :: MOVE_KW } ; [ mut ] => { $ crate :: SyntaxKind :: MUT_KW } ; [ pub ] => { $ crate :: SyntaxKind :: PUB_KW } ; [ ref ] => { $ crate :: SyntaxKind :: REF_KW } ; [ return ] => { $ crate :: SyntaxKind :: RETURN_KW } ; [ self ] => { $ crate :: SyntaxKind :: SELF_KW } ; [ static ] => { $ crate :: SyntaxKind :: STATIC_KW } ; [ struct ] => { $ crate :: SyntaxKind :: STRUCT_KW } ; [ super ] => { $ crate :: SyntaxKind :: SUPER_KW } ; [ trait ] => { $ crate :: SyntaxKind :: TRAIT_KW } ; [ true ] => { $ crate :: SyntaxKind :: TRUE_KW } ; [ try ] => { $ crate :: SyntaxKind :: TRY_KW } ; [ type ] => { $ crate :: SyntaxKind :: TYPE_KW } ; [ unsafe ] => { $ crate :: SyntaxKind :: UNSAFE_KW } ; [ use ] => { $ crate :: SyntaxKind :: USE_KW } ; [ where ] => { $ crate :: SyntaxKind :: WHERE_KW } ; [ while ] => { $ crate :: SyntaxKind :: WHILE_KW } ; [ auto ] => { $ crate :: SyntaxKind :: AUTO_KW } ; [ default ] => { $ crate :: SyntaxKind :: DEFAULT_KW } ; [ existential ] => { $ crate :: SyntaxKind :: EXISTENTIAL_KW } ; [ union ] => { $ crate :: SyntaxKind :: UNION_KW } ; [ raw ] => { $ crate :: SyntaxKind :: RAW_KW } ; [ lifetime ] => { $ crate :: SyntaxKind :: LIFETIME } ; [ ident ] => { $ crate :: SyntaxKind :: IDENT } ; } 367macro_rules ! T { [ ; ] => { $ crate :: SyntaxKind :: SEMICOLON } ; [ , ] => { $ crate :: SyntaxKind :: COMMA } ; [ '(' ] => { $ crate :: SyntaxKind :: L_PAREN } ; [ ')' ] => { $ crate :: SyntaxKind :: R_PAREN } ; [ '{' ] => { $ crate :: SyntaxKind :: L_CURLY } ; [ '}' ] => { $ crate :: SyntaxKind :: R_CURLY } ; [ '[' ] => { $ crate :: SyntaxKind :: L_BRACK } ; [ ']' ] => { $ crate :: SyntaxKind :: R_BRACK } ; [ < ] => { $ crate :: SyntaxKind :: L_ANGLE } ; [ > ] => { $ crate :: SyntaxKind :: R_ANGLE } ; [ @ ] => { $ crate :: SyntaxKind :: AT } ; [ # ] => { $ crate :: SyntaxKind :: POUND } ; [ ~ ] => { $ crate :: SyntaxKind :: TILDE } ; [ ? ] => { $ crate :: SyntaxKind :: QUESTION } ; [ $ ] => { $ crate :: SyntaxKind :: DOLLAR } ; [ & ] => { $ crate :: SyntaxKind :: AMP } ; [ | ] => { $ crate :: SyntaxKind :: PIPE } ; [ + ] => { $ crate :: SyntaxKind :: PLUS } ; [ * ] => { $ crate :: SyntaxKind :: STAR } ; [ / ] => { $ crate :: SyntaxKind :: SLASH } ; [ ^ ] => { $ crate :: SyntaxKind :: CARET } ; [ % ] => { $ crate :: SyntaxKind :: PERCENT } ; [ _ ] => { $ crate :: SyntaxKind :: UNDERSCORE } ; [ . ] => { $ crate :: SyntaxKind :: DOT } ; [ .. ] => { $ crate :: SyntaxKind :: DOT2 } ; [ ... ] => { $ crate :: SyntaxKind :: DOT3 } ; [ ..= ] => { $ crate :: SyntaxKind :: DOT2EQ } ; [ : ] => { $ crate :: SyntaxKind :: COLON } ; [ :: ] => { $ crate :: SyntaxKind :: COLON2 } ; [ = ] => { $ crate :: SyntaxKind :: EQ } ; [ == ] => { $ crate :: SyntaxKind :: EQ2 } ; [ => ] => { $ crate :: SyntaxKind :: FAT_ARROW } ; [ ! ] => { $ crate :: SyntaxKind :: BANG } ; [ != ] => { $ crate :: SyntaxKind :: NEQ } ; [ - ] => { $ crate :: SyntaxKind :: MINUS } ; [ -> ] => { $ crate :: SyntaxKind :: THIN_ARROW } ; [ <= ] => { $ crate :: SyntaxKind :: LTEQ } ; [ >= ] => { $ crate :: SyntaxKind :: GTEQ } ; [ += ] => { $ crate :: SyntaxKind :: PLUSEQ } ; [ -= ] => { $ crate :: SyntaxKind :: MINUSEQ } ; [ |= ] => { $ crate :: SyntaxKind :: PIPEEQ } ; [ &= ] => { $ crate :: SyntaxKind :: AMPEQ } ; [ ^= ] => { $ crate :: SyntaxKind :: CARETEQ } ; [ /= ] => { $ crate :: SyntaxKind :: SLASHEQ } ; [ *= ] => { $ crate :: SyntaxKind :: STAREQ } ; [ %= ] => { $ crate :: SyntaxKind :: PERCENTEQ } ; [ && ] => { $ crate :: SyntaxKind :: AMP2 } ; [ || ] => { $ crate :: SyntaxKind :: PIPE2 } ; [ << ] => { $ crate :: SyntaxKind :: SHL } ; [ >> ] => { $ crate :: SyntaxKind :: SHR } ; [ <<= ] => { $ crate :: SyntaxKind :: SHLEQ } ; [ >>= ] => { $ crate :: SyntaxKind :: SHREQ } ; [ as ] => { $ crate :: SyntaxKind :: AS_KW } ; [ async ] => { $ crate :: SyntaxKind :: ASYNC_KW } ; [ await ] => { $ crate :: SyntaxKind :: AWAIT_KW } ; [ box ] => { $ crate :: SyntaxKind :: BOX_KW } ; [ break ] => { $ crate :: SyntaxKind :: BREAK_KW } ; [ const ] => { $ crate :: SyntaxKind :: CONST_KW } ; [ continue ] => { $ crate :: SyntaxKind :: CONTINUE_KW } ; [ crate ] => { $ crate :: SyntaxKind :: CRATE_KW } ; [ dyn ] => { $ crate :: SyntaxKind :: DYN_KW } ; [ else ] => { $ crate :: SyntaxKind :: ELSE_KW } ; [ enum ] => { $ crate :: SyntaxKind :: ENUM_KW } ; [ extern ] => { $ crate :: SyntaxKind :: EXTERN_KW } ; [ false ] => { $ crate :: SyntaxKind :: FALSE_KW } ; [ fn ] => { $ crate :: SyntaxKind :: FN_KW } ; [ for ] => { $ crate :: SyntaxKind :: FOR_KW } ; [ if ] => { $ crate :: SyntaxKind :: IF_KW } ; [ impl ] => { $ crate :: SyntaxKind :: IMPL_KW } ; [ in ] => { $ crate :: SyntaxKind :: IN_KW } ; [ let ] => { $ crate :: SyntaxKind :: LET_KW } ; [ loop ] => { $ crate :: SyntaxKind :: LOOP_KW } ; [ macro ] => { $ crate :: SyntaxKind :: MACRO_KW } ; [ match ] => { $ crate :: SyntaxKind :: MATCH_KW } ; [ mod ] => { $ crate :: SyntaxKind :: MOD_KW } ; [ move ] => { $ crate :: SyntaxKind :: MOVE_KW } ; [ mut ] => { $ crate :: SyntaxKind :: MUT_KW } ; [ pub ] => { $ crate :: SyntaxKind :: PUB_KW } ; [ ref ] => { $ crate :: SyntaxKind :: REF_KW } ; [ return ] => { $ crate :: SyntaxKind :: RETURN_KW } ; [ self ] => { $ crate :: SyntaxKind :: SELF_KW } ; [ static ] => { $ crate :: SyntaxKind :: STATIC_KW } ; [ struct ] => { $ crate :: SyntaxKind :: STRUCT_KW } ; [ super ] => { $ crate :: SyntaxKind :: SUPER_KW } ; [ trait ] => { $ crate :: SyntaxKind :: TRAIT_KW } ; [ true ] => { $ crate :: SyntaxKind :: TRUE_KW } ; [ try ] => { $ crate :: SyntaxKind :: TRY_KW } ; [ type ] => { $ crate :: SyntaxKind :: TYPE_KW } ; [ unsafe ] => { $ crate :: SyntaxKind :: UNSAFE_KW } ; [ use ] => { $ crate :: SyntaxKind :: USE_KW } ; [ where ] => { $ crate :: SyntaxKind :: WHERE_KW } ; [ while ] => { $ crate :: SyntaxKind :: WHILE_KW } ; [ auto ] => { $ crate :: SyntaxKind :: AUTO_KW } ; [ default ] => { $ crate :: SyntaxKind :: DEFAULT_KW } ; [ existential ] => { $ crate :: SyntaxKind :: EXISTENTIAL_KW } ; [ union ] => { $ crate :: SyntaxKind :: UNION_KW } ; [ raw ] => { $ crate :: SyntaxKind :: RAW_KW } ; [ lifetime ] => { $ crate :: SyntaxKind :: LIFETIME } ; [ ident ] => { $ crate :: SyntaxKind :: IDENT } ; [ shebang ] => { $ crate :: SyntaxKind :: SHEBANG } ; }
diff --git a/crates/ra_proc_macro_srv/Cargo.toml b/crates/ra_proc_macro_srv/Cargo.toml
index 12ce497f8..bc119a6c7 100644
--- a/crates/ra_proc_macro_srv/Cargo.toml
+++ b/crates/ra_proc_macro_srv/Cargo.toml
@@ -19,7 +19,7 @@ memmap = "0.7"
19test_utils = { path = "../test_utils" } 19test_utils = { path = "../test_utils" }
20 20
21[dev-dependencies] 21[dev-dependencies]
22cargo_metadata = "0.10.0" 22cargo_metadata = "0.11.1"
23difference = "2.0.0" 23difference = "2.0.0"
24# used as proc macro test target 24# used as proc macro test target
25serde_derive = "1.0.106" 25serde_derive = "1.0.106"
diff --git a/crates/ra_prof/Cargo.toml b/crates/ra_prof/Cargo.toml
index 6c214501e..c82b9f76d 100644
--- a/crates/ra_prof/Cargo.toml
+++ b/crates/ra_prof/Cargo.toml
@@ -16,6 +16,9 @@ backtrace = { version = "0.3.44", optional = true }
16cfg-if = "0.1.10" 16cfg-if = "0.1.10"
17libc = "0.2.73" 17libc = "0.2.73"
18 18
19[target.'cfg(target_os = "linux")'.dependencies]
20perf-event = "0.4"
21
19[features] 22[features]
20cpu_profiler = [] 23cpu_profiler = []
21 24
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs
index ba5609703..eb50965ae 100644
--- a/crates/ra_prof/src/lib.rs
+++ b/crates/ra_prof/src/lib.rs
@@ -1,5 +1,6 @@
1//! A collection of tools for profiling rust-analyzer. 1//! A collection of tools for profiling rust-analyzer.
2 2
3mod stop_watch;
3mod memory_usage; 4mod memory_usage;
4#[cfg(feature = "cpu_profiler")] 5#[cfg(feature = "cpu_profiler")]
5mod google_cpu_profiler; 6mod google_cpu_profiler;
@@ -11,6 +12,7 @@ use std::cell::RefCell;
11pub use crate::{ 12pub use crate::{
12 hprof::{init, init_from, profile}, 13 hprof::{init, init_from, profile},
13 memory_usage::{Bytes, MemoryUsage}, 14 memory_usage::{Bytes, MemoryUsage},
15 stop_watch::{StopWatch, StopWatchSpan},
14}; 16};
15 17
16/// Prints backtrace to stderr, useful for debugging. 18/// Prints backtrace to stderr, useful for debugging.
diff --git a/crates/ra_prof/src/memory_usage.rs b/crates/ra_prof/src/memory_usage.rs
index 745345fac..c2ecbd33c 100644
--- a/crates/ra_prof/src/memory_usage.rs
+++ b/crates/ra_prof/src/memory_usage.rs
@@ -3,9 +3,22 @@ use std::fmt;
3 3
4use cfg_if::cfg_if; 4use cfg_if::cfg_if;
5 5
6#[derive(Copy, Clone)]
6pub struct MemoryUsage { 7pub struct MemoryUsage {
7 pub allocated: Bytes, 8 pub allocated: Bytes,
8 pub resident: Bytes, 9}
10
11impl fmt::Display for MemoryUsage {
12 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
13 write!(fmt, "{}", self.allocated)
14 }
15}
16
17impl std::ops::Sub for MemoryUsage {
18 type Output = MemoryUsage;
19 fn sub(self, rhs: MemoryUsage) -> MemoryUsage {
20 MemoryUsage { allocated: self.allocated - rhs.allocated }
21 }
9} 22}
10 23
11impl MemoryUsage { 24impl MemoryUsage {
@@ -13,26 +26,20 @@ impl MemoryUsage {
13 cfg_if! { 26 cfg_if! {
14 if #[cfg(target_os = "linux")] { 27 if #[cfg(target_os = "linux")] {
15 // Note: This is incredibly slow. 28 // Note: This is incredibly slow.
16 let alloc = unsafe { libc::mallinfo() }.uordblks as u32 as usize; 29 let alloc = unsafe { libc::mallinfo() }.uordblks as isize;
17 MemoryUsage { allocated: Bytes(alloc), resident: Bytes(0) } 30 MemoryUsage { allocated: Bytes(alloc) }
18 } else { 31 } else {
19 MemoryUsage { allocated: Bytes(0), resident: Bytes(0) } 32 MemoryUsage { allocated: Bytes(0) }
20 } 33 }
21 } 34 }
22 } 35 }
23} 36}
24 37
25impl fmt::Display for MemoryUsage {
26 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
27 write!(fmt, "{} allocated {} resident", self.allocated, self.resident,)
28 }
29}
30
31#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)] 38#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
32pub struct Bytes(usize); 39pub struct Bytes(isize);
33 40
34impl Bytes { 41impl Bytes {
35 pub fn megabytes(self) -> usize { 42 pub fn megabytes(self) -> isize {
36 self.0 / 1024 / 1024 43 self.0 / 1024 / 1024
37 } 44 }
38} 45}
@@ -42,10 +49,10 @@ impl fmt::Display for Bytes {
42 let bytes = self.0; 49 let bytes = self.0;
43 let mut value = bytes; 50 let mut value = bytes;
44 let mut suffix = "b"; 51 let mut suffix = "b";
45 if value > 4096 { 52 if value.abs() > 4096 {
46 value /= 1024; 53 value /= 1024;
47 suffix = "kb"; 54 suffix = "kb";
48 if value > 4096 { 55 if value.abs() > 4096 {
49 value /= 1024; 56 value /= 1024;
50 suffix = "mb"; 57 suffix = "mb";
51 } 58 }
@@ -56,7 +63,7 @@ impl fmt::Display for Bytes {
56 63
57impl std::ops::AddAssign<usize> for Bytes { 64impl std::ops::AddAssign<usize> for Bytes {
58 fn add_assign(&mut self, x: usize) { 65 fn add_assign(&mut self, x: usize) {
59 self.0 += x; 66 self.0 += x as isize;
60 } 67 }
61} 68}
62 69
diff --git a/crates/ra_prof/src/stop_watch.rs b/crates/ra_prof/src/stop_watch.rs
new file mode 100644
index 000000000..5e276190e
--- /dev/null
+++ b/crates/ra_prof/src/stop_watch.rs
@@ -0,0 +1,86 @@
1//! Like `std::time::Instant`, but also measures memory & CPU cycles.
2use std::{
3 fmt,
4 time::{Duration, Instant},
5};
6
7use crate::MemoryUsage;
8
9pub struct StopWatch {
10 time: Instant,
11 #[cfg(target_os = "linux")]
12 counter: Option<perf_event::Counter>,
13 memory: Option<MemoryUsage>,
14}
15
16pub struct StopWatchSpan {
17 pub time: Duration,
18 pub instructions: Option<u64>,
19 pub memory: Option<MemoryUsage>,
20}
21
22impl StopWatch {
23 pub fn start() -> StopWatch {
24 #[cfg(target_os = "linux")]
25 let counter = {
26 let mut counter = perf_event::Builder::new()
27 .build()
28 .map_err(|err| eprintln!("Failed to create perf counter: {}", err))
29 .ok();
30 if let Some(counter) = &mut counter {
31 if let Err(err) = counter.enable() {
32 eprintln!("Failed to start perf counter: {}", err)
33 }
34 }
35 counter
36 };
37 let time = Instant::now();
38 StopWatch {
39 time,
40 #[cfg(target_os = "linux")]
41 counter,
42 memory: None,
43 }
44 }
45 pub fn memory(mut self, yes: bool) -> StopWatch {
46 if yes {
47 self.memory = Some(MemoryUsage::current());
48 }
49 self
50 }
51 pub fn elapsed(&mut self) -> StopWatchSpan {
52 let time = self.time.elapsed();
53
54 #[cfg(target_os = "linux")]
55 let instructions = self.counter.as_mut().and_then(|it| {
56 it.read().map_err(|err| eprintln!("Failed to read perf counter: {}", err)).ok()
57 });
58 #[cfg(not(target_os = "linux"))]
59 let instructions = None;
60
61 let memory = self.memory.map(|it| MemoryUsage::current() - it);
62 StopWatchSpan { time, instructions, memory }
63 }
64}
65
66impl fmt::Display for StopWatchSpan {
67 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
68 write!(f, "{:.2?}", self.time)?;
69 if let Some(mut instructions) = self.instructions {
70 let mut prefix = "";
71 if instructions > 10000 {
72 instructions /= 1000;
73 prefix = "k"
74 }
75 if instructions > 10000 {
76 instructions /= 1000;
77 prefix = "m"
78 }
79 write!(f, ", {}{}i", instructions, prefix)?;
80 }
81 if let Some(memory) = self.memory {
82 write!(f, ", {}", memory)?;
83 }
84 Ok(())
85 }
86}
diff --git a/crates/ra_project_model/Cargo.toml b/crates/ra_project_model/Cargo.toml
index 827eb7e28..99adea8e4 100644
--- a/crates/ra_project_model/Cargo.toml
+++ b/crates/ra_project_model/Cargo.toml
@@ -12,7 +12,7 @@ doctest = false
12log = "0.4.8" 12log = "0.4.8"
13rustc-hash = "1.1.0" 13rustc-hash = "1.1.0"
14 14
15cargo_metadata = "0.10.0" 15cargo_metadata = "0.11.1"
16 16
17ra_arena = { path = "../ra_arena" } 17ra_arena = { path = "../ra_arena" }
18ra_cfg = { path = "../ra_cfg" } 18ra_cfg = { path = "../ra_cfg" }
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs
index fb88e0f06..10513542e 100644
--- a/crates/ra_project_model/src/cargo_workspace.rs
+++ b/crates/ra_project_model/src/cargo_workspace.rs
@@ -144,12 +144,15 @@ impl CargoWorkspace {
144 meta.manifest_path(cargo_toml.to_path_buf()); 144 meta.manifest_path(cargo_toml.to_path_buf());
145 if cargo_features.all_features { 145 if cargo_features.all_features {
146 meta.features(CargoOpt::AllFeatures); 146 meta.features(CargoOpt::AllFeatures);
147 } else if cargo_features.no_default_features { 147 } else {
148 // FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures` 148 if cargo_features.no_default_features {
149 // https://github.com/oli-obk/cargo_metadata/issues/79 149 // FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures`
150 meta.features(CargoOpt::NoDefaultFeatures); 150 // https://github.com/oli-obk/cargo_metadata/issues/79
151 } else if !cargo_features.features.is_empty() { 151 meta.features(CargoOpt::NoDefaultFeatures);
152 meta.features(CargoOpt::SomeFeatures(cargo_features.features.clone())); 152 }
153 if !cargo_features.features.is_empty() {
154 meta.features(CargoOpt::SomeFeatures(cargo_features.features.clone()));
155 }
153 } 156 }
154 if let Some(parent) = cargo_toml.parent() { 157 if let Some(parent) = cargo_toml.parent() {
155 meta.current_dir(parent.to_path_buf()); 158 meta.current_dir(parent.to_path_buf());
@@ -289,12 +292,16 @@ pub fn load_extern_resources(
289 cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml); 292 cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml);
290 if cargo_features.all_features { 293 if cargo_features.all_features {
291 cmd.arg("--all-features"); 294 cmd.arg("--all-features");
292 } else if cargo_features.no_default_features {
293 // FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures`
294 // https://github.com/oli-obk/cargo_metadata/issues/79
295 cmd.arg("--no-default-features");
296 } else { 295 } else {
297 cmd.args(&cargo_features.features); 296 if cargo_features.no_default_features {
297 // FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures`
298 // https://github.com/oli-obk/cargo_metadata/issues/79
299 cmd.arg("--no-default-features");
300 }
301 if !cargo_features.features.is_empty() {
302 cmd.arg("--features");
303 cmd.arg(cargo_features.features.join(" "));
304 }
298 } 305 }
299 306
300 let output = cmd.output()?; 307 let output = cmd.output()?;
diff --git a/crates/ra_project_model/src/cfg_flag.rs b/crates/ra_project_model/src/cfg_flag.rs
index 1bc5d4832..bd50056c6 100644
--- a/crates/ra_project_model/src/cfg_flag.rs
+++ b/crates/ra_project_model/src/cfg_flag.rs
@@ -4,7 +4,7 @@
4use std::str::FromStr; 4use std::str::FromStr;
5 5
6use ra_cfg::CfgOptions; 6use ra_cfg::CfgOptions;
7use stdx::split_delim; 7use stdx::split_once;
8 8
9#[derive(Clone, Eq, PartialEq, Debug)] 9#[derive(Clone, Eq, PartialEq, Debug)]
10pub enum CfgFlag { 10pub enum CfgFlag {
@@ -15,7 +15,7 @@ pub enum CfgFlag {
15impl FromStr for CfgFlag { 15impl FromStr for CfgFlag {
16 type Err = String; 16 type Err = String;
17 fn from_str(s: &str) -> Result<Self, Self::Err> { 17 fn from_str(s: &str) -> Result<Self, Self::Err> {
18 let res = match split_delim(s, '=') { 18 let res = match split_once(s, '=') {
19 Some((key, value)) => { 19 Some((key, value)) => {
20 if !(value.starts_with('"') && value.ends_with('"')) { 20 if !(value.starts_with('"') && value.ends_with('"')) {
21 return Err(format!("Invalid cfg ({:?}), value should be in quotes", s)); 21 return Err(format!("Invalid cfg ({:?}), value should be in quotes", s));
diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs
index 8a92acea5..a10ade375 100644
--- a/crates/ra_project_model/src/sysroot.rs
+++ b/crates/ra_project_model/src/sysroot.rs
@@ -54,6 +54,8 @@ impl Sysroot {
54 let src = get_or_install_rust_src(cargo_toml)?; 54 let src = get_or_install_rust_src(cargo_toml)?;
55 let mut sysroot = Sysroot { crates: Arena::default() }; 55 let mut sysroot = Sysroot { crates: Arena::default() };
56 for name in SYSROOT_CRATES.trim().lines() { 56 for name in SYSROOT_CRATES.trim().lines() {
57 // FIXME: remove this path when 1.47 comes out
58 // https://github.com/rust-lang/rust/pull/73265
57 let root = src.join(format!("lib{}", name)).join("lib.rs"); 59 let root = src.join(format!("lib{}", name)).join("lib.rs");
58 if root.exists() { 60 if root.exists() {
59 sysroot.crates.alloc(SysrootCrateData { 61 sysroot.crates.alloc(SysrootCrateData {
@@ -61,6 +63,15 @@ impl Sysroot {
61 root, 63 root,
62 deps: Vec::new(), 64 deps: Vec::new(),
63 }); 65 });
66 } else {
67 let root = src.join(name).join("src/lib.rs");
68 if root.exists() {
69 sysroot.crates.alloc(SysrootCrateData {
70 name: name.into(),
71 root,
72 deps: Vec::new(),
73 });
74 }
64 } 75 }
65 } 76 }
66 if let Some(std) = sysroot.std() { 77 if let Some(std) = sysroot.std() {
@@ -94,23 +105,38 @@ fn get_or_install_rust_src(cargo_toml: &AbsPath) -> Result<AbsPathBuf> {
94 rustc.current_dir(current_dir).args(&["--print", "sysroot"]); 105 rustc.current_dir(current_dir).args(&["--print", "sysroot"]);
95 let stdout = utf8_stdout(rustc)?; 106 let stdout = utf8_stdout(rustc)?;
96 let sysroot_path = AbsPath::assert(Path::new(stdout.trim())); 107 let sysroot_path = AbsPath::assert(Path::new(stdout.trim()));
97 let src_path = sysroot_path.join("lib/rustlib/src/rust/src"); 108 let mut src = get_rust_src(sysroot_path);
98 109 if src.is_none() {
99 if !src_path.exists() {
100 let mut rustup = Command::new(ra_toolchain::rustup()); 110 let mut rustup = Command::new(ra_toolchain::rustup());
101 rustup.current_dir(current_dir).args(&["component", "add", "rust-src"]); 111 rustup.current_dir(current_dir).args(&["component", "add", "rust-src"]);
102 utf8_stdout(rustup)?; 112 utf8_stdout(rustup)?;
113 src = get_rust_src(sysroot_path);
103 } 114 }
104 if !src_path.exists() { 115 match src {
105 bail!( 116 Some(r) => Ok(r),
117 None => bail!(
106 "can't load standard library from sysroot\n\ 118 "can't load standard library from sysroot\n\
107 {}\n\ 119 {}\n\
108 (discovered via `rustc --print sysroot`)\n\ 120 (discovered via `rustc --print sysroot`)\n\
109 try running `rustup component add rust-src` or set `RUST_SRC_PATH`", 121 try running `rustup component add rust-src` or set `RUST_SRC_PATH`",
110 src_path.display(), 122 sysroot_path.display(),
111 ) 123 ),
124 }
125}
126
127fn get_rust_src(sysroot_path: &AbsPath) -> Option<AbsPathBuf> {
128 // try the new path first since the old one still exists
129 let mut src_path = sysroot_path.join("lib/rustlib/src/rust/library");
130 if !src_path.exists() {
131 // FIXME: remove this path when 1.47 comes out
132 // https://github.com/rust-lang/rust/pull/73265
133 src_path = sysroot_path.join("lib/rustlib/src/rust/src");
134 }
135 if src_path.exists() {
136 Some(src_path)
137 } else {
138 None
112 } 139 }
113 Ok(src_path)
114} 140}
115 141
116impl SysrootCrateData { 142impl SysrootCrateData {
@@ -120,42 +146,28 @@ impl SysrootCrateData {
120} 146}
121 147
122const SYSROOT_CRATES: &str = " 148const SYSROOT_CRATES: &str = "
123std
124core
125alloc 149alloc
126collections 150core
127libc
128proc_macro
129rustc_unicode
130std_unicode
131test
132alloc_jemalloc
133alloc_system
134compiler_builtins
135getopts
136panic_unwind
137panic_abort 151panic_abort
138rand 152panic_unwind
153proc_macro
154profiler_builtins
155rtstartup
156std
157stdarch
139term 158term
140unwind 159test
141build_helper 160unwind";
142rustc_asan
143rustc_lsan
144rustc_msan
145rustc_tsan
146syntax";
147 161
148const STD_DEPS: &str = " 162const STD_DEPS: &str = "
149alloc 163alloc
150alloc_jemalloc
151alloc_system
152core 164core
153panic_abort 165panic_abort
154rand 166panic_unwind
155compiler_builtins 167profiler_builtins
156unwind 168rtstartup
157rustc_asan 169proc_macro
158rustc_lsan 170stdarch
159rustc_msan 171term
160rustc_tsan 172test
161build_helper"; 173unwind";
diff --git a/crates/ra_ssr/src/lib.rs b/crates/ra_ssr/src/lib.rs
index 7014a6ac6..c780b460a 100644
--- a/crates/ra_ssr/src/lib.rs
+++ b/crates/ra_ssr/src/lib.rs
@@ -52,6 +52,7 @@ pub struct MatchFinder<'db> {
52 sema: Semantics<'db, ra_ide_db::RootDatabase>, 52 sema: Semantics<'db, ra_ide_db::RootDatabase>,
53 rules: Vec<ResolvedRule>, 53 rules: Vec<ResolvedRule>,
54 resolution_scope: resolving::ResolutionScope<'db>, 54 resolution_scope: resolving::ResolutionScope<'db>,
55 restrict_ranges: Vec<FileRange>,
55} 56}
56 57
57impl<'db> MatchFinder<'db> { 58impl<'db> MatchFinder<'db> {
@@ -60,10 +61,12 @@ impl<'db> MatchFinder<'db> {
60 pub fn in_context( 61 pub fn in_context(
61 db: &'db ra_ide_db::RootDatabase, 62 db: &'db ra_ide_db::RootDatabase,
62 lookup_context: FilePosition, 63 lookup_context: FilePosition,
64 mut restrict_ranges: Vec<FileRange>,
63 ) -> MatchFinder<'db> { 65 ) -> MatchFinder<'db> {
66 restrict_ranges.retain(|range| !range.range.is_empty());
64 let sema = Semantics::new(db); 67 let sema = Semantics::new(db);
65 let resolution_scope = resolving::ResolutionScope::new(&sema, lookup_context); 68 let resolution_scope = resolving::ResolutionScope::new(&sema, lookup_context);
66 MatchFinder { sema: Semantics::new(db), rules: Vec::new(), resolution_scope } 69 MatchFinder { sema, rules: Vec::new(), resolution_scope, restrict_ranges }
67 } 70 }
68 71
69 /// Constructs an instance using the start of the first file in `db` as the lookup context. 72 /// Constructs an instance using the start of the first file in `db` as the lookup context.
@@ -79,6 +82,7 @@ impl<'db> MatchFinder<'db> {
79 Ok(MatchFinder::in_context( 82 Ok(MatchFinder::in_context(
80 db, 83 db,
81 FilePosition { file_id: first_file_id, offset: 0.into() }, 84 FilePosition { file_id: first_file_id, offset: 0.into() },
85 vec![],
82 )) 86 ))
83 } else { 87 } else {
84 bail!("No files to search"); 88 bail!("No files to search");
diff --git a/crates/ra_ssr/src/matching.rs b/crates/ra_ssr/src/matching.rs
index 4862622bd..0f72fea69 100644
--- a/crates/ra_ssr/src/matching.rs
+++ b/crates/ra_ssr/src/matching.rs
@@ -209,7 +209,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
209 // Some kinds of nodes have special handling. For everything else, we fall back to default 209 // Some kinds of nodes have special handling. For everything else, we fall back to default
210 // matching. 210 // matching.
211 match code.kind() { 211 match code.kind() {
212 SyntaxKind::RECORD_FIELD_LIST => { 212 SyntaxKind::RECORD_EXPR_FIELD_LIST => {
213 self.attempt_match_record_field_list(phase, pattern, code) 213 self.attempt_match_record_field_list(phase, pattern, code)
214 } 214 }
215 SyntaxKind::TOKEN_TREE => self.attempt_match_token_tree(phase, pattern, code), 215 SyntaxKind::TOKEN_TREE => self.attempt_match_token_tree(phase, pattern, code),
@@ -348,8 +348,8 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
348 // separately via comparing what the path resolves to below. 348 // separately via comparing what the path resolves to below.
349 self.attempt_match_opt( 349 self.attempt_match_opt(
350 phase, 350 phase,
351 pattern_segment.type_arg_list(), 351 pattern_segment.generic_arg_list(),
352 code_segment.type_arg_list(), 352 code_segment.generic_arg_list(),
353 )?; 353 )?;
354 self.attempt_match_opt( 354 self.attempt_match_opt(
355 phase, 355 phase,
@@ -399,7 +399,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
399 // Build a map keyed by field name. 399 // Build a map keyed by field name.
400 let mut fields_by_name = FxHashMap::default(); 400 let mut fields_by_name = FxHashMap::default();
401 for child in code.children() { 401 for child in code.children() {
402 if let Some(record) = ast::RecordField::cast(child.clone()) { 402 if let Some(record) = ast::RecordExprField::cast(child.clone()) {
403 if let Some(name) = record.field_name() { 403 if let Some(name) = record.field_name() {
404 fields_by_name.insert(name.text().clone(), child.clone()); 404 fields_by_name.insert(name.text().clone(), child.clone());
405 } 405 }
@@ -706,8 +706,8 @@ mod tests {
706 let rule: SsrRule = "foo($x) ==>> bar($x)".parse().unwrap(); 706 let rule: SsrRule = "foo($x) ==>> bar($x)".parse().unwrap();
707 let input = "fn foo() {} fn bar() {} fn main() { foo(1+2); }"; 707 let input = "fn foo() {} fn bar() {} fn main() { foo(1+2); }";
708 708
709 let (db, position) = crate::tests::single_file(input); 709 let (db, position, selections) = crate::tests::single_file(input);
710 let mut match_finder = MatchFinder::in_context(&db, position); 710 let mut match_finder = MatchFinder::in_context(&db, position, selections);
711 match_finder.add_rule(rule).unwrap(); 711 match_finder.add_rule(rule).unwrap();
712 let matches = match_finder.matches(); 712 let matches = match_finder.matches();
713 assert_eq!(matches.matches.len(), 1); 713 assert_eq!(matches.matches.len(), 1);
diff --git a/crates/ra_ssr/src/parsing.rs b/crates/ra_ssr/src/parsing.rs
index 2d6f4e514..f455eb5b7 100644
--- a/crates/ra_ssr/src/parsing.rs
+++ b/crates/ra_ssr/src/parsing.rs
@@ -10,6 +10,7 @@ use crate::{SsrError, SsrPattern, SsrRule};
10use ra_syntax::{ast, AstNode, SmolStr, SyntaxKind, SyntaxNode, T}; 10use ra_syntax::{ast, AstNode, SmolStr, SyntaxKind, SyntaxNode, T};
11use rustc_hash::{FxHashMap, FxHashSet}; 11use rustc_hash::{FxHashMap, FxHashSet};
12use std::str::FromStr; 12use std::str::FromStr;
13use test_utils::mark;
13 14
14#[derive(Debug)] 15#[derive(Debug)]
15pub(crate) struct ParsedRule { 16pub(crate) struct ParsedRule {
@@ -69,11 +70,8 @@ impl ParsedRule {
69 rules: Vec::new(), 70 rules: Vec::new(),
70 }; 71 };
71 builder.try_add(ast::Expr::parse(&raw_pattern), raw_template.map(ast::Expr::parse)); 72 builder.try_add(ast::Expr::parse(&raw_pattern), raw_template.map(ast::Expr::parse));
72 builder.try_add(ast::TypeRef::parse(&raw_pattern), raw_template.map(ast::TypeRef::parse)); 73 builder.try_add(ast::Type::parse(&raw_pattern), raw_template.map(ast::Type::parse));
73 builder.try_add( 74 builder.try_add(ast::Item::parse(&raw_pattern), raw_template.map(ast::Item::parse));
74 ast::ModuleItem::parse(&raw_pattern),
75 raw_template.map(ast::ModuleItem::parse),
76 );
77 builder.try_add(ast::Path::parse(&raw_pattern), raw_template.map(ast::Path::parse)); 75 builder.try_add(ast::Path::parse(&raw_pattern), raw_template.map(ast::Path::parse));
78 builder.try_add(ast::Pat::parse(&raw_pattern), raw_template.map(ast::Pat::parse)); 76 builder.try_add(ast::Pat::parse(&raw_pattern), raw_template.map(ast::Pat::parse));
79 builder.build() 77 builder.build()
@@ -102,14 +100,35 @@ impl RuleBuilder {
102 } 100 }
103 } 101 }
104 102
105 fn build(self) -> Result<Vec<ParsedRule>, SsrError> { 103 fn build(mut self) -> Result<Vec<ParsedRule>, SsrError> {
106 if self.rules.is_empty() { 104 if self.rules.is_empty() {
107 bail!("Not a valid Rust expression, type, item, path or pattern"); 105 bail!("Not a valid Rust expression, type, item, path or pattern");
108 } 106 }
107 // If any rules contain paths, then we reject any rules that don't contain paths. Allowing a
108 // mix leads to strange semantics, since the path-based rules only match things where the
109 // path refers to semantically the same thing, whereas the non-path-based rules could match
110 // anything. Specifically, if we have a rule like `foo ==>> bar` we only want to match the
111 // `foo` that is in the current scope, not any `foo`. However "foo" can be parsed as a
112 // pattern (IDENT_PAT -> NAME -> IDENT). Allowing such a rule through would result in
113 // renaming everything called `foo` to `bar`. It'd also be slow, since without a path, we'd
114 // have to use the slow-scan search mechanism.
115 if self.rules.iter().any(|rule| contains_path(&rule.pattern)) {
116 let old_len = self.rules.len();
117 self.rules.retain(|rule| contains_path(&rule.pattern));
118 if self.rules.len() < old_len {
119 mark::hit!(pattern_is_a_single_segment_path);
120 }
121 }
109 Ok(self.rules) 122 Ok(self.rules)
110 } 123 }
111} 124}
112 125
126/// Returns whether there are any paths in `node`.
127fn contains_path(node: &SyntaxNode) -> bool {
128 node.kind() == SyntaxKind::PATH
129 || node.descendants().any(|node| node.kind() == SyntaxKind::PATH)
130}
131
113impl FromStr for SsrRule { 132impl FromStr for SsrRule {
114 type Err = SsrError; 133 type Err = SsrError;
115 134
diff --git a/crates/ra_ssr/src/replacing.rs b/crates/ra_ssr/src/replacing.rs
index 4b3f5509c..0943244ff 100644
--- a/crates/ra_ssr/src/replacing.rs
+++ b/crates/ra_ssr/src/replacing.rs
@@ -3,8 +3,9 @@
3use crate::matching::Var; 3use crate::matching::Var;
4use crate::{resolving::ResolvedRule, Match, SsrMatches}; 4use crate::{resolving::ResolvedRule, Match, SsrMatches};
5use ra_syntax::ast::{self, AstToken}; 5use ra_syntax::ast::{self, AstToken};
6use ra_syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextSize}; 6use ra_syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize};
7use ra_text_edit::TextEdit; 7use ra_text_edit::TextEdit;
8use rustc_hash::{FxHashMap, FxHashSet};
8 9
9/// Returns a text edit that will replace each match in `matches` with its corresponding replacement 10/// Returns a text edit that will replace each match in `matches` with its corresponding replacement
10/// template. Placeholders in the template will have been substituted with whatever they matched to 11/// template. Placeholders in the template will have been substituted with whatever they matched to
@@ -38,62 +39,79 @@ struct ReplacementRenderer<'a> {
38 file_src: &'a str, 39 file_src: &'a str,
39 rules: &'a [ResolvedRule], 40 rules: &'a [ResolvedRule],
40 rule: &'a ResolvedRule, 41 rule: &'a ResolvedRule,
42 out: String,
43 // Map from a range within `out` to a token in `template` that represents a placeholder. This is
44 // used to validate that the generated source code doesn't split any placeholder expansions (see
45 // below).
46 placeholder_tokens_by_range: FxHashMap<TextRange, SyntaxToken>,
47 // Which placeholder tokens need to be wrapped in parenthesis in order to ensure that when `out`
48 // is parsed, placeholders don't get split. e.g. if a template of `$a.to_string()` results in `1
49 // + 2.to_string()` then the placeholder value `1 + 2` was split and needs parenthesis.
50 placeholder_tokens_requiring_parenthesis: FxHashSet<SyntaxToken>,
41} 51}
42 52
43fn render_replace(match_info: &Match, file_src: &str, rules: &[ResolvedRule]) -> String { 53fn render_replace(match_info: &Match, file_src: &str, rules: &[ResolvedRule]) -> String {
44 let mut out = String::new();
45 let rule = &rules[match_info.rule_index]; 54 let rule = &rules[match_info.rule_index];
46 let template = rule 55 let template = rule
47 .template 56 .template
48 .as_ref() 57 .as_ref()
49 .expect("You called MatchFinder::edits after calling MatchFinder::add_search_pattern"); 58 .expect("You called MatchFinder::edits after calling MatchFinder::add_search_pattern");
50 let renderer = ReplacementRenderer { match_info, file_src, rules, rule }; 59 let mut renderer = ReplacementRenderer {
51 renderer.render_node(&template.node, &mut out); 60 match_info,
61 file_src,
62 rules,
63 rule,
64 out: String::new(),
65 placeholder_tokens_requiring_parenthesis: FxHashSet::default(),
66 placeholder_tokens_by_range: FxHashMap::default(),
67 };
68 renderer.render_node(&template.node);
69 renderer.maybe_rerender_with_extra_parenthesis(&template.node);
52 for comment in &match_info.ignored_comments { 70 for comment in &match_info.ignored_comments {
53 out.push_str(&comment.syntax().to_string()); 71 renderer.out.push_str(&comment.syntax().to_string());
54 } 72 }
55 out 73 renderer.out
56} 74}
57 75
58impl ReplacementRenderer<'_> { 76impl ReplacementRenderer<'_> {
59 fn render_node_children(&self, node: &SyntaxNode, out: &mut String) { 77 fn render_node_children(&mut self, node: &SyntaxNode) {
60 for node_or_token in node.children_with_tokens() { 78 for node_or_token in node.children_with_tokens() {
61 self.render_node_or_token(&node_or_token, out); 79 self.render_node_or_token(&node_or_token);
62 } 80 }
63 } 81 }
64 82
65 fn render_node_or_token(&self, node_or_token: &SyntaxElement, out: &mut String) { 83 fn render_node_or_token(&mut self, node_or_token: &SyntaxElement) {
66 match node_or_token { 84 match node_or_token {
67 SyntaxElement::Token(token) => { 85 SyntaxElement::Token(token) => {
68 self.render_token(&token, out); 86 self.render_token(&token);
69 } 87 }
70 SyntaxElement::Node(child_node) => { 88 SyntaxElement::Node(child_node) => {
71 self.render_node(&child_node, out); 89 self.render_node(&child_node);
72 } 90 }
73 } 91 }
74 } 92 }
75 93
76 fn render_node(&self, node: &SyntaxNode, out: &mut String) { 94 fn render_node(&mut self, node: &SyntaxNode) {
77 use ra_syntax::ast::AstNode; 95 use ra_syntax::ast::AstNode;
78 if let Some(mod_path) = self.match_info.rendered_template_paths.get(&node) { 96 if let Some(mod_path) = self.match_info.rendered_template_paths.get(&node) {
79 out.push_str(&mod_path.to_string()); 97 self.out.push_str(&mod_path.to_string());
80 // Emit everything except for the segment's name-ref, since we already effectively 98 // Emit everything except for the segment's name-ref, since we already effectively
81 // emitted that as part of `mod_path`. 99 // emitted that as part of `mod_path`.
82 if let Some(path) = ast::Path::cast(node.clone()) { 100 if let Some(path) = ast::Path::cast(node.clone()) {
83 if let Some(segment) = path.segment() { 101 if let Some(segment) = path.segment() {
84 for node_or_token in segment.syntax().children_with_tokens() { 102 for node_or_token in segment.syntax().children_with_tokens() {
85 if node_or_token.kind() != SyntaxKind::NAME_REF { 103 if node_or_token.kind() != SyntaxKind::NAME_REF {
86 self.render_node_or_token(&node_or_token, out); 104 self.render_node_or_token(&node_or_token);
87 } 105 }
88 } 106 }
89 } 107 }
90 } 108 }
91 } else { 109 } else {
92 self.render_node_children(&node, out); 110 self.render_node_children(&node);
93 } 111 }
94 } 112 }
95 113
96 fn render_token(&self, token: &SyntaxToken, out: &mut String) { 114 fn render_token(&mut self, token: &SyntaxToken) {
97 if let Some(placeholder) = self.rule.get_placeholder(&token) { 115 if let Some(placeholder) = self.rule.get_placeholder(&token) {
98 if let Some(placeholder_value) = 116 if let Some(placeholder_value) =
99 self.match_info.placeholder_values.get(&Var(placeholder.ident.to_string())) 117 self.match_info.placeholder_values.get(&Var(placeholder.ident.to_string()))
@@ -107,8 +125,23 @@ impl ReplacementRenderer<'_> {
107 range.start(), 125 range.start(),
108 self.rules, 126 self.rules,
109 ); 127 );
128 let needs_parenthesis =
129 self.placeholder_tokens_requiring_parenthesis.contains(token);
110 edit.apply(&mut matched_text); 130 edit.apply(&mut matched_text);
111 out.push_str(&matched_text); 131 if needs_parenthesis {
132 self.out.push('(');
133 }
134 self.placeholder_tokens_by_range.insert(
135 TextRange::new(
136 TextSize::of(&self.out),
137 TextSize::of(&self.out) + TextSize::of(&matched_text),
138 ),
139 token.clone(),
140 );
141 self.out.push_str(&matched_text);
142 if needs_parenthesis {
143 self.out.push(')');
144 }
112 } else { 145 } else {
113 // We validated that all placeholder references were valid before we 146 // We validated that all placeholder references were valid before we
114 // started, so this shouldn't happen. 147 // started, so this shouldn't happen.
@@ -118,7 +151,44 @@ impl ReplacementRenderer<'_> {
118 ); 151 );
119 } 152 }
120 } else { 153 } else {
121 out.push_str(token.text().as_str()); 154 self.out.push_str(token.text().as_str());
155 }
156 }
157
158 // Checks if the resulting code, when parsed doesn't split any placeholders due to different
159 // order of operations between the search pattern and the replacement template. If any do, then
160 // we rerender the template and wrap the problematic placeholders with parenthesis.
161 fn maybe_rerender_with_extra_parenthesis(&mut self, template: &SyntaxNode) {
162 if let Some(node) = parse_as_kind(&self.out, template.kind()) {
163 self.remove_node_ranges(node);
164 if self.placeholder_tokens_by_range.is_empty() {
165 return;
166 }
167 self.placeholder_tokens_requiring_parenthesis =
168 self.placeholder_tokens_by_range.values().cloned().collect();
169 self.out.clear();
170 self.render_node(template);
171 }
172 }
173
174 fn remove_node_ranges(&mut self, node: SyntaxNode) {
175 self.placeholder_tokens_by_range.remove(&node.text_range());
176 for child in node.children() {
177 self.remove_node_ranges(child);
178 }
179 }
180}
181
182fn parse_as_kind(code: &str, kind: SyntaxKind) -> Option<SyntaxNode> {
183 use ra_syntax::ast::AstNode;
184 if ast::Expr::can_cast(kind) {
185 if let Ok(expr) = ast::Expr::parse(code) {
186 return Some(expr.syntax().clone());
187 }
188 } else if ast::Item::can_cast(kind) {
189 if let Ok(item) = ast::Item::parse(code) {
190 return Some(item.syntax().clone());
122 } 191 }
123 } 192 }
193 None
124} 194}
diff --git a/crates/ra_ssr/src/resolving.rs b/crates/ra_ssr/src/resolving.rs
index 123bd2bb2..df60048eb 100644
--- a/crates/ra_ssr/src/resolving.rs
+++ b/crates/ra_ssr/src/resolving.rs
@@ -11,6 +11,7 @@ use test_utils::mark;
11pub(crate) struct ResolutionScope<'db> { 11pub(crate) struct ResolutionScope<'db> {
12 scope: hir::SemanticsScope<'db>, 12 scope: hir::SemanticsScope<'db>,
13 hygiene: hir::Hygiene, 13 hygiene: hir::Hygiene,
14 node: SyntaxNode,
14} 15}
15 16
16pub(crate) struct ResolvedRule { 17pub(crate) struct ResolvedRule {
@@ -25,6 +26,7 @@ pub(crate) struct ResolvedPattern {
25 // Paths in `node` that we've resolved. 26 // Paths in `node` that we've resolved.
26 pub(crate) resolved_paths: FxHashMap<SyntaxNode, ResolvedPath>, 27 pub(crate) resolved_paths: FxHashMap<SyntaxNode, ResolvedPath>,
27 pub(crate) ufcs_function_calls: FxHashMap<SyntaxNode, hir::Function>, 28 pub(crate) ufcs_function_calls: FxHashMap<SyntaxNode, hir::Function>,
29 pub(crate) contains_self: bool,
28} 30}
29 31
30pub(crate) struct ResolvedPath { 32pub(crate) struct ResolvedPath {
@@ -68,6 +70,7 @@ struct Resolver<'a, 'db> {
68 70
69impl Resolver<'_, '_> { 71impl Resolver<'_, '_> {
70 fn resolve_pattern_tree(&self, pattern: SyntaxNode) -> Result<ResolvedPattern, SsrError> { 72 fn resolve_pattern_tree(&self, pattern: SyntaxNode) -> Result<ResolvedPattern, SsrError> {
73 use ra_syntax::{SyntaxElement, T};
71 let mut resolved_paths = FxHashMap::default(); 74 let mut resolved_paths = FxHashMap::default();
72 self.resolve(pattern.clone(), 0, &mut resolved_paths)?; 75 self.resolve(pattern.clone(), 0, &mut resolved_paths)?;
73 let ufcs_function_calls = resolved_paths 76 let ufcs_function_calls = resolved_paths
@@ -85,11 +88,17 @@ impl Resolver<'_, '_> {
85 None 88 None
86 }) 89 })
87 .collect(); 90 .collect();
91 let contains_self =
92 pattern.descendants_with_tokens().any(|node_or_token| match node_or_token {
93 SyntaxElement::Token(t) => t.kind() == T![self],
94 _ => false,
95 });
88 Ok(ResolvedPattern { 96 Ok(ResolvedPattern {
89 node: pattern, 97 node: pattern,
90 resolved_paths, 98 resolved_paths,
91 placeholders_by_stand_in: self.placeholders_by_stand_in.clone(), 99 placeholders_by_stand_in: self.placeholders_by_stand_in.clone(),
92 ufcs_function_calls, 100 ufcs_function_calls,
101 contains_self,
93 }) 102 })
94 } 103 }
95 104
@@ -101,6 +110,10 @@ impl Resolver<'_, '_> {
101 ) -> Result<(), SsrError> { 110 ) -> Result<(), SsrError> {
102 use ra_syntax::ast::AstNode; 111 use ra_syntax::ast::AstNode;
103 if let Some(path) = ast::Path::cast(node.clone()) { 112 if let Some(path) = ast::Path::cast(node.clone()) {
113 if is_self(&path) {
114 // Self cannot be resolved like other paths.
115 return Ok(());
116 }
104 // Check if this is an appropriate place in the path to resolve. If the path is 117 // Check if this is an appropriate place in the path to resolve. If the path is
105 // something like `a::B::<i32>::c` then we want to resolve `a::B`. If the path contains 118 // something like `a::B::<i32>::c` then we want to resolve `a::B`. If the path contains
106 // a placeholder. e.g. `a::$b::c` then we want to resolve `a`. 119 // a placeholder. e.g. `a::$b::c` then we want to resolve `a`.
@@ -141,14 +154,14 @@ impl Resolver<'_, '_> {
141impl<'db> ResolutionScope<'db> { 154impl<'db> ResolutionScope<'db> {
142 pub(crate) fn new( 155 pub(crate) fn new(
143 sema: &hir::Semantics<'db, ra_ide_db::RootDatabase>, 156 sema: &hir::Semantics<'db, ra_ide_db::RootDatabase>,
144 lookup_context: FilePosition, 157 resolve_context: FilePosition,
145 ) -> ResolutionScope<'db> { 158 ) -> ResolutionScope<'db> {
146 use ra_syntax::ast::AstNode; 159 use ra_syntax::ast::AstNode;
147 let file = sema.parse(lookup_context.file_id); 160 let file = sema.parse(resolve_context.file_id);
148 // Find a node at the requested position, falling back to the whole file. 161 // Find a node at the requested position, falling back to the whole file.
149 let node = file 162 let node = file
150 .syntax() 163 .syntax()
151 .token_at_offset(lookup_context.offset) 164 .token_at_offset(resolve_context.offset)
152 .left_biased() 165 .left_biased()
153 .map(|token| token.parent()) 166 .map(|token| token.parent())
154 .unwrap_or_else(|| file.syntax().clone()); 167 .unwrap_or_else(|| file.syntax().clone());
@@ -156,10 +169,16 @@ impl<'db> ResolutionScope<'db> {
156 let scope = sema.scope(&node); 169 let scope = sema.scope(&node);
157 ResolutionScope { 170 ResolutionScope {
158 scope, 171 scope,
159 hygiene: hir::Hygiene::new(sema.db, lookup_context.file_id.into()), 172 hygiene: hir::Hygiene::new(sema.db, resolve_context.file_id.into()),
173 node,
160 } 174 }
161 } 175 }
162 176
177 /// Returns the function in which SSR was invoked, if any.
178 pub(crate) fn current_function(&self) -> Option<SyntaxNode> {
179 self.node.ancestors().find(|node| node.kind() == SyntaxKind::FN).map(|node| node.clone())
180 }
181
163 fn resolve_path(&self, path: &ast::Path) -> Option<hir::PathResolution> { 182 fn resolve_path(&self, path: &ast::Path) -> Option<hir::PathResolution> {
164 let hir_path = hir::Path::from_src(path.clone(), &self.hygiene)?; 183 let hir_path = hir::Path::from_src(path.clone(), &self.hygiene)?;
165 // First try resolving the whole path. This will work for things like 184 // First try resolving the whole path. This will work for things like
@@ -186,6 +205,10 @@ impl<'db> ResolutionScope<'db> {
186 } 205 }
187} 206}
188 207
208fn is_self(path: &ast::Path) -> bool {
209 path.segment().map(|segment| segment.self_token().is_some()).unwrap_or(false)
210}
211
189/// Returns a suitable node for resolving paths in the current scope. If we create a scope based on 212/// Returns a suitable node for resolving paths in the current scope. If we create a scope based on
190/// a statement node, then we can't resolve local variables that were defined in the current scope 213/// a statement node, then we can't resolve local variables that were defined in the current scope
191/// (only in parent scopes). So we find another node, ideally a child of the statement where local 214/// (only in parent scopes). So we find another node, ideally a child of the statement where local
@@ -198,7 +221,7 @@ fn pick_node_for_resolution(node: SyntaxNode) -> SyntaxNode {
198 return n; 221 return n;
199 } 222 }
200 } 223 }
201 SyntaxKind::LET_STMT | SyntaxKind::BIND_PAT => { 224 SyntaxKind::LET_STMT | SyntaxKind::IDENT_PAT => {
202 if let Some(next) = node.next_sibling() { 225 if let Some(next) = node.next_sibling() {
203 return pick_node_for_resolution(next); 226 return pick_node_for_resolution(next);
204 } 227 }
@@ -217,7 +240,7 @@ fn pick_node_for_resolution(node: SyntaxNode) -> SyntaxNode {
217fn path_contains_type_arguments(path: Option<ast::Path>) -> bool { 240fn path_contains_type_arguments(path: Option<ast::Path>) -> bool {
218 if let Some(path) = path { 241 if let Some(path) = path {
219 if let Some(segment) = path.segment() { 242 if let Some(segment) = path.segment() {
220 if segment.type_arg_list().is_some() { 243 if segment.generic_arg_list().is_some() {
221 mark::hit!(type_arguments_within_path); 244 mark::hit!(type_arguments_within_path);
222 return true; 245 return true;
223 } 246 }
diff --git a/crates/ra_ssr/src/search.rs b/crates/ra_ssr/src/search.rs
index bcf0f0468..85ffa2ac2 100644
--- a/crates/ra_ssr/src/search.rs
+++ b/crates/ra_ssr/src/search.rs
@@ -5,12 +5,13 @@ use crate::{
5 resolving::{ResolvedPath, ResolvedPattern, ResolvedRule}, 5 resolving::{ResolvedPath, ResolvedPattern, ResolvedRule},
6 Match, MatchFinder, 6 Match, MatchFinder,
7}; 7};
8use ra_db::FileRange; 8use ra_db::{FileId, FileRange};
9use ra_ide_db::{ 9use ra_ide_db::{
10 defs::Definition, 10 defs::Definition,
11 search::{Reference, SearchScope}, 11 search::{Reference, SearchScope},
12}; 12};
13use ra_syntax::{ast, AstNode, SyntaxKind, SyntaxNode}; 13use ra_syntax::{ast, AstNode, SyntaxKind, SyntaxNode};
14use rustc_hash::FxHashSet;
14use test_utils::mark; 15use test_utils::mark;
15 16
16/// A cache for the results of find_usages. This is for when we have multiple patterns that have the 17/// A cache for the results of find_usages. This is for when we have multiple patterns that have the
@@ -32,6 +33,15 @@ impl<'db> MatchFinder<'db> {
32 usage_cache: &mut UsageCache, 33 usage_cache: &mut UsageCache,
33 matches_out: &mut Vec<Match>, 34 matches_out: &mut Vec<Match>,
34 ) { 35 ) {
36 if rule.pattern.contains_self {
37 // If the pattern contains `self` we restrict the scope of the search to just the
38 // current method. No other method can reference the same `self`. This makes the
39 // behavior of `self` consistent with other variables.
40 if let Some(current_function) = self.resolution_scope.current_function() {
41 self.slow_scan_node(&current_function, rule, &None, matches_out);
42 }
43 return;
44 }
35 if pick_path_for_usages(&rule.pattern).is_none() { 45 if pick_path_for_usages(&rule.pattern).is_none() {
36 self.slow_scan(rule, matches_out); 46 self.slow_scan(rule, matches_out);
37 return; 47 return;
@@ -54,11 +64,7 @@ impl<'db> MatchFinder<'db> {
54 mark::hit!(use_declaration_with_braces); 64 mark::hit!(use_declaration_with_braces);
55 continue; 65 continue;
56 } 66 }
57 if let Ok(m) = 67 self.try_add_match(rule, &node_to_match, &None, matches_out);
58 matching::get_match(false, rule, &node_to_match, &None, &self.sema)
59 {
60 matches_out.push(m);
61 }
62 } 68 }
63 } 69 }
64 } 70 }
@@ -121,25 +127,39 @@ impl<'db> MatchFinder<'db> {
121 // FIXME: We should ideally have a test that checks that we edit local roots and not library 127 // FIXME: We should ideally have a test that checks that we edit local roots and not library
122 // roots. This probably would require some changes to fixtures, since currently everything 128 // roots. This probably would require some changes to fixtures, since currently everything
123 // seems to get put into a single source root. 129 // seems to get put into a single source root.
124 use ra_db::SourceDatabaseExt;
125 use ra_ide_db::symbol_index::SymbolsDatabase;
126 let mut files = Vec::new(); 130 let mut files = Vec::new();
127 for &root in self.sema.db.local_roots().iter() { 131 self.search_files_do(|file_id| {
128 let sr = self.sema.db.source_root(root); 132 files.push(file_id);
129 files.extend(sr.iter()); 133 });
130 }
131 SearchScope::files(&files) 134 SearchScope::files(&files)
132 } 135 }
133 136
134 fn slow_scan(&self, rule: &ResolvedRule, matches_out: &mut Vec<Match>) { 137 fn slow_scan(&self, rule: &ResolvedRule, matches_out: &mut Vec<Match>) {
135 use ra_db::SourceDatabaseExt; 138 self.search_files_do(|file_id| {
136 use ra_ide_db::symbol_index::SymbolsDatabase; 139 let file = self.sema.parse(file_id);
137 for &root in self.sema.db.local_roots().iter() { 140 let code = file.syntax();
138 let sr = self.sema.db.source_root(root); 141 self.slow_scan_node(code, rule, &None, matches_out);
139 for file_id in sr.iter() { 142 })
140 let file = self.sema.parse(file_id); 143 }
141 let code = file.syntax(); 144
142 self.slow_scan_node(code, rule, &None, matches_out); 145 fn search_files_do(&self, mut callback: impl FnMut(FileId)) {
146 if self.restrict_ranges.is_empty() {
147 // Unrestricted search.
148 use ra_db::SourceDatabaseExt;
149 use ra_ide_db::symbol_index::SymbolsDatabase;
150 for &root in self.sema.db.local_roots().iter() {
151 let sr = self.sema.db.source_root(root);
152 for file_id in sr.iter() {
153 callback(file_id);
154 }
155 }
156 } else {
157 // Search is restricted, deduplicate file IDs (generally only one).
158 let mut files = FxHashSet::default();
159 for range in &self.restrict_ranges {
160 if files.insert(range.file_id) {
161 callback(range.file_id);
162 }
143 } 163 }
144 } 164 }
145 } 165 }
@@ -154,9 +174,7 @@ impl<'db> MatchFinder<'db> {
154 if !is_search_permitted(code) { 174 if !is_search_permitted(code) {
155 return; 175 return;
156 } 176 }
157 if let Ok(m) = matching::get_match(false, rule, &code, restrict_range, &self.sema) { 177 self.try_add_match(rule, &code, restrict_range, matches_out);
158 matches_out.push(m);
159 }
160 // If we've got a macro call, we already tried matching it pre-expansion, which is the only 178 // If we've got a macro call, we already tried matching it pre-expansion, which is the only
161 // way to match the whole macro, now try expanding it and matching the expansion. 179 // way to match the whole macro, now try expanding it and matching the expansion.
162 if let Some(macro_call) = ast::MacroCall::cast(code.clone()) { 180 if let Some(macro_call) = ast::MacroCall::cast(code.clone()) {
@@ -178,6 +196,38 @@ impl<'db> MatchFinder<'db> {
178 self.slow_scan_node(&child, rule, restrict_range, matches_out); 196 self.slow_scan_node(&child, rule, restrict_range, matches_out);
179 } 197 }
180 } 198 }
199
200 fn try_add_match(
201 &self,
202 rule: &ResolvedRule,
203 code: &SyntaxNode,
204 restrict_range: &Option<FileRange>,
205 matches_out: &mut Vec<Match>,
206 ) {
207 if !self.within_range_restrictions(code) {
208 mark::hit!(replace_nonpath_within_selection);
209 return;
210 }
211 if let Ok(m) = matching::get_match(false, rule, code, restrict_range, &self.sema) {
212 matches_out.push(m);
213 }
214 }
215
216 /// Returns whether `code` is within one of our range restrictions if we have any. No range
217 /// restrictions is considered unrestricted and always returns true.
218 fn within_range_restrictions(&self, code: &SyntaxNode) -> bool {
219 if self.restrict_ranges.is_empty() {
220 // There is no range restriction.
221 return true;
222 }
223 let node_range = self.sema.original_range(code);
224 for range in &self.restrict_ranges {
225 if range.file_id == node_range.file_id && range.range.contains_range(node_range.range) {
226 return true;
227 }
228 }
229 false
230 }
181} 231}
182 232
183/// Returns whether we support matching within `node` and all of its ancestors. 233/// Returns whether we support matching within `node` and all of its ancestors.
@@ -196,7 +246,7 @@ fn is_search_permitted(node: &SyntaxNode) -> bool {
196 // and the code is `use foo::{baz, bar}`, we'll match `bar`, since it resolves to `foo::bar`. 246 // and the code is `use foo::{baz, bar}`, we'll match `bar`, since it resolves to `foo::bar`.
197 // However we'll then replace just the part we matched `bar`. We probably need to instead remove 247 // However we'll then replace just the part we matched `bar`. We probably need to instead remove
198 // `bar` and insert a new use declaration. 248 // `bar` and insert a new use declaration.
199 node.kind() != SyntaxKind::USE_ITEM 249 node.kind() != SyntaxKind::USE
200} 250}
201 251
202impl UsageCache { 252impl UsageCache {
diff --git a/crates/ra_ssr/src/tests.rs b/crates/ra_ssr/src/tests.rs
index 18ef2506a..d483640df 100644
--- a/crates/ra_ssr/src/tests.rs
+++ b/crates/ra_ssr/src/tests.rs
@@ -1,9 +1,9 @@
1use crate::{MatchFinder, SsrRule}; 1use crate::{MatchFinder, SsrRule};
2use expect::{expect, Expect}; 2use expect::{expect, Expect};
3use ra_db::{salsa::Durability, FileId, FilePosition, SourceDatabaseExt}; 3use ra_db::{salsa::Durability, FileId, FilePosition, FileRange, SourceDatabaseExt};
4use rustc_hash::FxHashSet; 4use rustc_hash::FxHashSet;
5use std::sync::Arc; 5use std::sync::Arc;
6use test_utils::mark; 6use test_utils::{mark, RangeOrOffset};
7 7
8fn parse_error_text(query: &str) -> String { 8fn parse_error_text(query: &str) -> String {
9 format!("{}", query.parse::<SsrRule>().unwrap_err()) 9 format!("{}", query.parse::<SsrRule>().unwrap_err())
@@ -60,20 +60,32 @@ fn parser_undefined_placeholder_in_replacement() {
60} 60}
61 61
62/// `code` may optionally contain a cursor marker `<|>`. If it doesn't, then the position will be 62/// `code` may optionally contain a cursor marker `<|>`. If it doesn't, then the position will be
63/// the start of the file. 63/// the start of the file. If there's a second cursor marker, then we'll return a single range.
64pub(crate) fn single_file(code: &str) -> (ra_ide_db::RootDatabase, FilePosition) { 64pub(crate) fn single_file(code: &str) -> (ra_ide_db::RootDatabase, FilePosition, Vec<FileRange>) {
65 use ra_db::fixture::WithFixture; 65 use ra_db::fixture::WithFixture;
66 use ra_ide_db::symbol_index::SymbolsDatabase; 66 use ra_ide_db::symbol_index::SymbolsDatabase;
67 let (mut db, position) = if code.contains(test_utils::CURSOR_MARKER) { 67 let (mut db, file_id, range_or_offset) = if code.contains(test_utils::CURSOR_MARKER) {
68 ra_ide_db::RootDatabase::with_position(code) 68 ra_ide_db::RootDatabase::with_range_or_offset(code)
69 } else { 69 } else {
70 let (db, file_id) = ra_ide_db::RootDatabase::with_single_file(code); 70 let (db, file_id) = ra_ide_db::RootDatabase::with_single_file(code);
71 (db, FilePosition { file_id, offset: 0.into() }) 71 (db, file_id, RangeOrOffset::Offset(0.into()))
72 }; 72 };
73 let selections;
74 let position;
75 match range_or_offset {
76 RangeOrOffset::Range(range) => {
77 position = FilePosition { file_id, offset: range.start() };
78 selections = vec![FileRange { file_id, range: range }];
79 }
80 RangeOrOffset::Offset(offset) => {
81 position = FilePosition { file_id, offset };
82 selections = vec![];
83 }
84 }
73 let mut local_roots = FxHashSet::default(); 85 let mut local_roots = FxHashSet::default();
74 local_roots.insert(ra_db::fixture::WORKSPACE); 86 local_roots.insert(ra_db::fixture::WORKSPACE);
75 db.set_local_roots_with_durability(Arc::new(local_roots), Durability::HIGH); 87 db.set_local_roots_with_durability(Arc::new(local_roots), Durability::HIGH);
76 (db, position) 88 (db, position, selections)
77} 89}
78 90
79fn assert_ssr_transform(rule: &str, input: &str, expected: Expect) { 91fn assert_ssr_transform(rule: &str, input: &str, expected: Expect) {
@@ -81,8 +93,8 @@ fn assert_ssr_transform(rule: &str, input: &str, expected: Expect) {
81} 93}
82 94
83fn assert_ssr_transforms(rules: &[&str], input: &str, expected: Expect) { 95fn assert_ssr_transforms(rules: &[&str], input: &str, expected: Expect) {
84 let (db, position) = single_file(input); 96 let (db, position, selections) = single_file(input);
85 let mut match_finder = MatchFinder::in_context(&db, position); 97 let mut match_finder = MatchFinder::in_context(&db, position, selections);
86 for rule in rules { 98 for rule in rules {
87 let rule: SsrRule = rule.parse().unwrap(); 99 let rule: SsrRule = rule.parse().unwrap();
88 match_finder.add_rule(rule).unwrap(); 100 match_finder.add_rule(rule).unwrap();
@@ -112,8 +124,8 @@ fn print_match_debug_info(match_finder: &MatchFinder, file_id: FileId, snippet:
112} 124}
113 125
114fn assert_matches(pattern: &str, code: &str, expected: &[&str]) { 126fn assert_matches(pattern: &str, code: &str, expected: &[&str]) {
115 let (db, position) = single_file(code); 127 let (db, position, selections) = single_file(code);
116 let mut match_finder = MatchFinder::in_context(&db, position); 128 let mut match_finder = MatchFinder::in_context(&db, position, selections);
117 match_finder.add_search_pattern(pattern.parse().unwrap()).unwrap(); 129 match_finder.add_search_pattern(pattern.parse().unwrap()).unwrap();
118 let matched_strings: Vec<String> = 130 let matched_strings: Vec<String> =
119 match_finder.matches().flattened().matches.iter().map(|m| m.matched_text()).collect(); 131 match_finder.matches().flattened().matches.iter().map(|m| m.matched_text()).collect();
@@ -124,8 +136,8 @@ fn assert_matches(pattern: &str, code: &str, expected: &[&str]) {
124} 136}
125 137
126fn assert_no_match(pattern: &str, code: &str) { 138fn assert_no_match(pattern: &str, code: &str) {
127 let (db, position) = single_file(code); 139 let (db, position, selections) = single_file(code);
128 let mut match_finder = MatchFinder::in_context(&db, position); 140 let mut match_finder = MatchFinder::in_context(&db, position, selections);
129 match_finder.add_search_pattern(pattern.parse().unwrap()).unwrap(); 141 match_finder.add_search_pattern(pattern.parse().unwrap()).unwrap();
130 let matches = match_finder.matches().flattened().matches; 142 let matches = match_finder.matches().flattened().matches;
131 if !matches.is_empty() { 143 if !matches.is_empty() {
@@ -135,8 +147,8 @@ fn assert_no_match(pattern: &str, code: &str) {
135} 147}
136 148
137fn assert_match_failure_reason(pattern: &str, code: &str, snippet: &str, expected_reason: &str) { 149fn assert_match_failure_reason(pattern: &str, code: &str, snippet: &str, expected_reason: &str) {
138 let (db, position) = single_file(code); 150 let (db, position, selections) = single_file(code);
139 let mut match_finder = MatchFinder::in_context(&db, position); 151 let mut match_finder = MatchFinder::in_context(&db, position, selections);
140 match_finder.add_search_pattern(pattern.parse().unwrap()).unwrap(); 152 match_finder.add_search_pattern(pattern.parse().unwrap()).unwrap();
141 let mut reasons = Vec::new(); 153 let mut reasons = Vec::new();
142 for d in match_finder.debug_where_text_equal(position.file_id, snippet) { 154 for d in match_finder.debug_where_text_equal(position.file_id, snippet) {
@@ -490,9 +502,10 @@ fn no_match_split_expression() {
490 502
491#[test] 503#[test]
492fn replace_function_call() { 504fn replace_function_call() {
505 // This test also makes sure that we ignore empty-ranges.
493 assert_ssr_transform( 506 assert_ssr_transform(
494 "foo() ==>> bar()", 507 "foo() ==>> bar()",
495 "fn foo() {} fn bar() {} fn f1() {foo(); foo();}", 508 "fn foo() {<|><|>} fn bar() {} fn f1() {foo(); foo();}",
496 expect![["fn foo() {} fn bar() {} fn f1() {bar(); bar();}"]], 509 expect![["fn foo() {} fn bar() {} fn f1() {bar(); bar();}"]],
497 ); 510 );
498} 511}
@@ -651,7 +664,7 @@ fn replace_binary_op() {
651 assert_ssr_transform( 664 assert_ssr_transform(
652 "$a + $b ==>> $b + $a", 665 "$a + $b ==>> $b + $a",
653 "fn f() {1 + 2 + 3 + 4}", 666 "fn f() {1 + 2 + 3 + 4}",
654 expect![["fn f() {4 + 3 + 2 + 1}"]], 667 expect![[r#"fn f() {4 + (3 + (2 + 1))}"#]],
655 ); 668 );
656} 669}
657 670
@@ -760,12 +773,33 @@ fn preserves_whitespace_within_macro_expansion() {
760 macro_rules! macro1 { 773 macro_rules! macro1 {
761 ($a:expr) => {$a} 774 ($a:expr) => {$a}
762 } 775 }
763 fn f() {macro1!(4 - 3 - 1 * 2} 776 fn f() {macro1!(4 - (3 - 1 * 2)}
764 "#]], 777 "#]],
765 ) 778 )
766} 779}
767 780
768#[test] 781#[test]
782fn add_parenthesis_when_necessary() {
783 assert_ssr_transform(
784 "foo($a) ==>> $a.to_string()",
785 r#"
786 fn foo(_: i32) {}
787 fn bar3(v: i32) {
788 foo(1 + 2);
789 foo(-v);
790 }
791 "#,
792 expect![[r#"
793 fn foo(_: i32) {}
794 fn bar3(v: i32) {
795 (1 + 2).to_string();
796 (-v).to_string();
797 }
798 "#]],
799 )
800}
801
802#[test]
769fn match_failure_reasons() { 803fn match_failure_reasons() {
770 let code = r#" 804 let code = r#"
771 fn bar() {} 805 fn bar() {}
@@ -887,6 +921,45 @@ fn ufcs_matches_method_call() {
887} 921}
888 922
889#[test] 923#[test]
924fn pattern_is_a_single_segment_path() {
925 mark::check!(pattern_is_a_single_segment_path);
926 // The first function should not be altered because the `foo` in scope at the cursor position is
927 // a different `foo`. This case is special because "foo" can be parsed as a pattern (IDENT_PAT ->
928 // NAME -> IDENT), which contains no path. If we're not careful we'll end up matching the `foo`
929 // in `let foo` from the first function. Whether we should match the `let foo` in the second
930 // function is less clear. At the moment, we don't. Doing so sounds like a rename operation,
931 // which isn't really what SSR is for, especially since the replacement `bar` must be able to be
932 // resolved, which means if we rename `foo` we'll get a name collision.
933 assert_ssr_transform(
934 "foo ==>> bar",
935 r#"
936 fn f1() -> i32 {
937 let foo = 1;
938 let bar = 2;
939 foo
940 }
941 fn f1() -> i32 {
942 let foo = 1;
943 let bar = 2;
944 foo<|>
945 }
946 "#,
947 expect![[r#"
948 fn f1() -> i32 {
949 let foo = 1;
950 let bar = 2;
951 foo
952 }
953 fn f1() -> i32 {
954 let foo = 1;
955 let bar = 2;
956 bar
957 }
958 "#]],
959 );
960}
961
962#[test]
890fn replace_local_variable_reference() { 963fn replace_local_variable_reference() {
891 // The pattern references a local variable `foo` in the block containing the cursor. We should 964 // The pattern references a local variable `foo` in the block containing the cursor. We should
892 // only replace references to this variable `foo`, not other variables that just happen to have 965 // only replace references to this variable `foo`, not other variables that just happen to have
@@ -922,3 +995,87 @@ fn replace_local_variable_reference() {
922 "#]], 995 "#]],
923 ) 996 )
924} 997}
998
999#[test]
1000fn replace_path_within_selection() {
1001 assert_ssr_transform(
1002 "foo ==>> bar",
1003 r#"
1004 fn main() {
1005 let foo = 41;
1006 let bar = 42;
1007 do_stuff(foo);
1008 do_stuff(foo);<|>
1009 do_stuff(foo);
1010 do_stuff(foo);<|>
1011 do_stuff(foo);
1012 }"#,
1013 expect![[r#"
1014 fn main() {
1015 let foo = 41;
1016 let bar = 42;
1017 do_stuff(foo);
1018 do_stuff(foo);
1019 do_stuff(bar);
1020 do_stuff(bar);
1021 do_stuff(foo);
1022 }"#]],
1023 );
1024}
1025
1026#[test]
1027fn replace_nonpath_within_selection() {
1028 mark::check!(replace_nonpath_within_selection);
1029 assert_ssr_transform(
1030 "$a + $b ==>> $b * $a",
1031 r#"
1032 fn main() {
1033 let v = 1 + 2;<|>
1034 let v2 = 3 + 3;
1035 let v3 = 4 + 5;<|>
1036 let v4 = 6 + 7;
1037 }"#,
1038 expect![[r#"
1039 fn main() {
1040 let v = 1 + 2;
1041 let v2 = 3 * 3;
1042 let v3 = 5 * 4;
1043 let v4 = 6 + 7;
1044 }"#]],
1045 );
1046}
1047
1048#[test]
1049fn replace_self() {
1050 // `foo(self)` occurs twice in the code, however only the first occurrence is the `self` that's
1051 // in scope where the rule is invoked.
1052 assert_ssr_transform(
1053 "foo(self) ==>> bar(self)",
1054 r#"
1055 struct S1 {}
1056 fn foo(_: &S1) {}
1057 fn bar(_: &S1) {}
1058 impl S1 {
1059 fn f1(&self) {
1060 foo(self)<|>
1061 }
1062 fn f2(&self) {
1063 foo(self)
1064 }
1065 }
1066 "#,
1067 expect![[r#"
1068 struct S1 {}
1069 fn foo(_: &S1) {}
1070 fn bar(_: &S1) {}
1071 impl S1 {
1072 fn f1(&self) {
1073 bar(self)
1074 }
1075 fn f2(&self) {
1076 foo(self)
1077 }
1078 }
1079 "#]],
1080 );
1081}
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml
index 670f04578..fc4d7aa04 100644
--- a/crates/ra_syntax/Cargo.toml
+++ b/crates/ra_syntax/Cargo.toml
@@ -13,7 +13,7 @@ doctest = false
13[dependencies] 13[dependencies]
14itertools = "0.9.0" 14itertools = "0.9.0"
15rowan = "0.10.0" 15rowan = "0.10.0"
16rustc_lexer = { version = "669.0.0", package = "rustc-ap-rustc_lexer" } 16rustc_lexer = { version = "671.0.0", package = "rustc-ap-rustc_lexer" }
17rustc-hash = "1.1.0" 17rustc-hash = "1.1.0"
18arrayvec = "0.5.1" 18arrayvec = "0.5.1"
19once_cell = "1.3.1" 19once_cell = "1.3.1"
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index c65c485cb..d536bb1e7 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -17,7 +17,7 @@ use crate::{
17 17
18pub use self::{ 18pub use self::{
19 expr_ext::{ArrayExprKind, BinOp, Effect, ElseBranch, LiteralKind, PrefixOp, RangeOp}, 19 expr_ext::{ArrayExprKind, BinOp, Effect, ElseBranch, LiteralKind, PrefixOp, RangeOp},
20 generated::{nodes::*, tokens::*}, 20 generated::*,
21 node_ext::{ 21 node_ext::{
22 AttrKind, FieldKind, NameOrNameRef, PathSegmentKind, SelfParamKind, SlicePatComponents, 22 AttrKind, FieldKind, NameOrNameRef, PathSegmentKind, SelfParamKind, SlicePatComponents,
23 StructKind, TypeBoundKind, VisibilityKind, 23 StructKind, TypeBoundKind, VisibilityKind,
@@ -139,7 +139,7 @@ fn test_doc_comment_of_statics() {
139 ) 139 )
140 .ok() 140 .ok()
141 .unwrap(); 141 .unwrap();
142 let st = file.syntax().descendants().find_map(StaticDef::cast).unwrap(); 142 let st = file.syntax().descendants().find_map(Static::cast).unwrap();
143 assert_eq!("Number of levels", st.doc_comment_text().unwrap()); 143 assert_eq!("Number of levels", st.doc_comment_text().unwrap());
144} 144}
145 145
@@ -235,7 +235,7 @@ fn test_comments_preserve_trailing_whitespace() {
235 ) 235 )
236 .ok() 236 .ok()
237 .unwrap(); 237 .unwrap();
238 let def = file.syntax().descendants().find_map(StructDef::cast).unwrap(); 238 let def = file.syntax().descendants().find_map(Struct::cast).unwrap();
239 assert_eq!( 239 assert_eq!(
240 "Representation of a Realm. \nIn the specification these are called Realm Records.", 240 "Representation of a Realm. \nIn the specification these are called Realm Records.",
241 def.doc_comment_text().unwrap() 241 def.doc_comment_text().unwrap()
@@ -286,8 +286,8 @@ where
286 let mut bounds = pred.type_bound_list().unwrap().bounds(); 286 let mut bounds = pred.type_bound_list().unwrap().bounds();
287 287
288 assert!(pred.for_token().is_none()); 288 assert!(pred.for_token().is_none());
289 assert!(pred.type_param_list().is_none()); 289 assert!(pred.generic_param_list().is_none());
290 assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string()); 290 assert_eq!("T", pred.ty().unwrap().syntax().text().to_string());
291 assert_bound("Clone", bounds.next()); 291 assert_bound("Clone", bounds.next());
292 assert_bound("Copy", bounds.next()); 292 assert_bound("Copy", bounds.next());
293 assert_bound("Debug", bounds.next()); 293 assert_bound("Debug", bounds.next());
@@ -304,20 +304,20 @@ where
304 let pred = predicates.next().unwrap(); 304 let pred = predicates.next().unwrap();
305 let mut bounds = pred.type_bound_list().unwrap().bounds(); 305 let mut bounds = pred.type_bound_list().unwrap().bounds();
306 306
307 assert_eq!("Iterator::Item", pred.type_ref().unwrap().syntax().text().to_string()); 307 assert_eq!("Iterator::Item", pred.ty().unwrap().syntax().text().to_string());
308 assert_bound("'a", bounds.next()); 308 assert_bound("'a", bounds.next());
309 309
310 let pred = predicates.next().unwrap(); 310 let pred = predicates.next().unwrap();
311 let mut bounds = pred.type_bound_list().unwrap().bounds(); 311 let mut bounds = pred.type_bound_list().unwrap().bounds();
312 312
313 assert_eq!("Iterator::Item", pred.type_ref().unwrap().syntax().text().to_string()); 313 assert_eq!("Iterator::Item", pred.ty().unwrap().syntax().text().to_string());
314 assert_bound("Debug", bounds.next()); 314 assert_bound("Debug", bounds.next());
315 assert_bound("'a", bounds.next()); 315 assert_bound("'a", bounds.next());
316 316
317 let pred = predicates.next().unwrap(); 317 let pred = predicates.next().unwrap();
318 let mut bounds = pred.type_bound_list().unwrap().bounds(); 318 let mut bounds = pred.type_bound_list().unwrap().bounds();
319 319
320 assert_eq!("<T as Iterator>::Item", pred.type_ref().unwrap().syntax().text().to_string()); 320 assert_eq!("<T as Iterator>::Item", pred.ty().unwrap().syntax().text().to_string());
321 assert_bound("Debug", bounds.next()); 321 assert_bound("Debug", bounds.next());
322 assert_bound("'a", bounds.next()); 322 assert_bound("'a", bounds.next());
323 323
@@ -325,7 +325,7 @@ where
325 let mut bounds = pred.type_bound_list().unwrap().bounds(); 325 let mut bounds = pred.type_bound_list().unwrap().bounds();
326 326
327 assert!(pred.for_token().is_some()); 327 assert!(pred.for_token().is_some());
328 assert_eq!("<'a>", pred.type_param_list().unwrap().syntax().text().to_string()); 328 assert_eq!("<'a>", pred.generic_param_list().unwrap().syntax().text().to_string());
329 assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string()); 329 assert_eq!("F", pred.ty().unwrap().syntax().text().to_string());
330 assert_bound("Fn(&'a str)", bounds.next()); 330 assert_bound("Fn(&'a str)", bounds.next());
331} 331}
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index abc7a646c..5ed123f91 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -29,9 +29,9 @@ impl ast::BinExpr {
29 } 29 }
30} 30}
31 31
32impl ast::FnDef { 32impl ast::Fn {
33 #[must_use] 33 #[must_use]
34 pub fn with_body(&self, body: ast::BlockExpr) -> ast::FnDef { 34 pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn {
35 let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); 35 let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
36 let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { 36 let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() {
37 old_body.syntax().clone().into() 37 old_body.syntax().clone().into()
@@ -80,9 +80,12 @@ where
80 } 80 }
81} 81}
82 82
83impl ast::ItemList { 83impl ast::AssocItemList {
84 #[must_use] 84 #[must_use]
85 pub fn append_items(&self, items: impl IntoIterator<Item = ast::AssocItem>) -> ast::ItemList { 85 pub fn append_items(
86 &self,
87 items: impl IntoIterator<Item = ast::AssocItem>,
88 ) -> ast::AssocItemList {
86 let mut res = self.clone(); 89 let mut res = self.clone();
87 if !self.syntax().text().contains_char('\n') { 90 if !self.syntax().text().contains_char('\n') {
88 res = make_multiline(res); 91 res = make_multiline(res);
@@ -92,7 +95,7 @@ impl ast::ItemList {
92 } 95 }
93 96
94 #[must_use] 97 #[must_use]
95 pub fn append_item(&self, item: ast::AssocItem) -> ast::ItemList { 98 pub fn append_item(&self, item: ast::AssocItem) -> ast::AssocItemList {
96 let (indent, position) = match self.assoc_items().last() { 99 let (indent, position) = match self.assoc_items().last() {
97 Some(it) => ( 100 Some(it) => (
98 leading_indent(it.syntax()).unwrap_or_default().to_string(), 101 leading_indent(it.syntax()).unwrap_or_default().to_string(),
@@ -113,18 +116,18 @@ impl ast::ItemList {
113 } 116 }
114} 117}
115 118
116impl ast::RecordFieldList { 119impl ast::RecordExprFieldList {
117 #[must_use] 120 #[must_use]
118 pub fn append_field(&self, field: &ast::RecordField) -> ast::RecordFieldList { 121 pub fn append_field(&self, field: &ast::RecordExprField) -> ast::RecordExprFieldList {
119 self.insert_field(InsertPosition::Last, field) 122 self.insert_field(InsertPosition::Last, field)
120 } 123 }
121 124
122 #[must_use] 125 #[must_use]
123 pub fn insert_field( 126 pub fn insert_field(
124 &self, 127 &self,
125 position: InsertPosition<&'_ ast::RecordField>, 128 position: InsertPosition<&'_ ast::RecordExprField>,
126 field: &ast::RecordField, 129 field: &ast::RecordExprField,
127 ) -> ast::RecordFieldList { 130 ) -> ast::RecordExprFieldList {
128 let is_multiline = self.syntax().text().contains_char('\n'); 131 let is_multiline = self.syntax().text().contains_char('\n');
129 let ws; 132 let ws;
130 let space = if is_multiline { 133 let space = if is_multiline {
@@ -189,9 +192,9 @@ impl ast::RecordFieldList {
189 } 192 }
190} 193}
191 194
192impl ast::TypeAliasDef { 195impl ast::TypeAlias {
193 #[must_use] 196 #[must_use]
194 pub fn remove_bounds(&self) -> ast::TypeAliasDef { 197 pub fn remove_bounds(&self) -> ast::TypeAlias {
195 let colon = match self.colon_token() { 198 let colon = match self.colon_token() {
196 Some(it) => it, 199 Some(it) => it,
197 None => return self.clone(), 200 None => return self.clone(),
@@ -234,17 +237,17 @@ impl ast::Path {
234 237
235impl ast::PathSegment { 238impl ast::PathSegment {
236 #[must_use] 239 #[must_use]
237 pub fn with_type_args(&self, type_args: ast::TypeArgList) -> ast::PathSegment { 240 pub fn with_type_args(&self, type_args: ast::GenericArgList) -> ast::PathSegment {
238 self._with_type_args(type_args, false) 241 self._with_type_args(type_args, false)
239 } 242 }
240 243
241 #[must_use] 244 #[must_use]
242 pub fn with_turbo_fish(&self, type_args: ast::TypeArgList) -> ast::PathSegment { 245 pub fn with_turbo_fish(&self, type_args: ast::GenericArgList) -> ast::PathSegment {
243 self._with_type_args(type_args, true) 246 self._with_type_args(type_args, true)
244 } 247 }
245 248
246 fn _with_type_args(&self, type_args: ast::TypeArgList, turbo: bool) -> ast::PathSegment { 249 fn _with_type_args(&self, type_args: ast::GenericArgList, turbo: bool) -> ast::PathSegment {
247 if let Some(old) = self.type_arg_list() { 250 if let Some(old) = self.generic_arg_list() {
248 return self.replace_children( 251 return self.replace_children(
249 single_node(old.syntax().clone()), 252 single_node(old.syntax().clone()),
250 iter::once(type_args.syntax().clone().into()), 253 iter::once(type_args.syntax().clone().into()),
@@ -259,9 +262,9 @@ impl ast::PathSegment {
259 } 262 }
260} 263}
261 264
262impl ast::UseItem { 265impl ast::Use {
263 #[must_use] 266 #[must_use]
264 pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::UseItem { 267 pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::Use {
265 if let Some(old) = self.use_tree() { 268 if let Some(old) = self.use_tree() {
266 return self.replace_descendant(old, use_tree); 269 return self.replace_descendant(old, use_tree);
267 } 270 }
@@ -314,8 +317,12 @@ impl ast::UseTree {
314 Some(it) => it, 317 Some(it) => it,
315 None => return self.clone(), 318 None => return self.clone(),
316 }; 319 };
317 let use_tree = 320 let use_tree = make::use_tree(
318 make::use_tree(suffix, self.use_tree_list(), self.alias(), self.star_token().is_some()); 321 suffix,
322 self.use_tree_list(),
323 self.rename(),
324 self.star_token().is_some(),
325 );
319 let nested = make::use_tree_list(iter::once(use_tree)); 326 let nested = make::use_tree_list(iter::once(use_tree));
320 return make::use_tree(prefix.clone(), Some(nested), None, false); 327 return make::use_tree(prefix.clone(), Some(nested), None, false);
321 328
@@ -383,7 +390,7 @@ impl ast::MatchArmList {
383 #[must_use] 390 #[must_use]
384 pub fn remove_placeholder(&self) -> ast::MatchArmList { 391 pub fn remove_placeholder(&self) -> ast::MatchArmList {
385 let placeholder = 392 let placeholder =
386 self.arms().find(|arm| matches!(arm.pat(), Some(ast::Pat::PlaceholderPat(_)))); 393 self.arms().find(|arm| matches!(arm.pat(), Some(ast::Pat::WildcardPat(_))));
387 if let Some(placeholder) = placeholder { 394 if let Some(placeholder) = placeholder {
388 self.remove_arm(&placeholder) 395 self.remove_arm(&placeholder)
389 } else { 396 } else {
@@ -614,7 +621,7 @@ fn single_node(element: impl Into<SyntaxElement>) -> RangeInclusive<SyntaxElemen
614#[test] 621#[test]
615fn test_increase_indent() { 622fn test_increase_indent() {
616 let arm_list = { 623 let arm_list = {
617 let arm = make::match_arm(iter::once(make::placeholder_pat().into()), make::expr_unit()); 624 let arm = make::match_arm(iter::once(make::wildcard_pat().into()), make::expr_unit());
618 make::match_arm_list(vec![arm.clone(), arm]) 625 make::match_arm_list(vec![arm.clone(), arm])
619 }; 626 };
620 assert_eq!( 627 assert_eq!(
diff --git a/crates/ra_syntax/src/ast/expr_ext.rs b/crates/ra_syntax/src/ast/expr_ext.rs
index db5438d68..f5ba87223 100644
--- a/crates/ra_syntax/src/ast/expr_ext.rs
+++ b/crates/ra_syntax/src/ast/expr_ext.rs
@@ -7,6 +7,8 @@ use crate::{
7 SyntaxToken, T, 7 SyntaxToken, T,
8}; 8};
9 9
10impl ast::AttrsOwner for ast::Expr {}
11
10impl ast::Expr { 12impl ast::Expr {
11 pub fn is_block_like(&self) -> bool { 13 pub fn is_block_like(&self) -> bool {
12 match self { 14 match self {
@@ -331,13 +333,12 @@ impl ast::Literal {
331 333
332 match token.kind() { 334 match token.kind() {
333 INT_NUMBER => { 335 INT_NUMBER => {
334 // FYI: there was a bug here previously, thus an if statement bellow is necessary. 336 // FYI: there was a bug here previously, thus the if statement below is necessary.
335 // The lexer treats e.g. `1f64` as an integer literal. See 337 // The lexer treats e.g. `1f64` as an integer literal. See
336 // https://github.com/rust-analyzer/rust-analyzer/issues/1592 338 // https://github.com/rust-analyzer/rust-analyzer/issues/1592
337 // and the comments on the linked PR. 339 // and the comments on the linked PR.
338 340
339 let text = token.text(); 341 let text = token.text();
340
341 if let suffix @ Some(_) = Self::find_suffix(&text, &FLOAT_SUFFIXES) { 342 if let suffix @ Some(_) = Self::find_suffix(&text, &FLOAT_SUFFIXES) {
342 LiteralKind::FloatNumber { suffix } 343 LiteralKind::FloatNumber { suffix }
343 } else { 344 } else {
@@ -399,7 +400,7 @@ impl ast::BlockExpr {
399 Some(it) => it, 400 Some(it) => it,
400 None => return true, 401 None => return true,
401 }; 402 };
402 !matches!(parent.kind(), FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR) 403 !matches!(parent.kind(), FN | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR)
403 } 404 }
404} 405}
405 406
@@ -410,8 +411,8 @@ fn test_literal_with_attr() {
410 assert_eq!(lit.token().text(), r#""Hello""#); 411 assert_eq!(lit.token().text(), r#""Hello""#);
411} 412}
412 413
413impl ast::RecordField { 414impl ast::RecordExprField {
414 pub fn parent_record_lit(&self) -> ast::RecordLit { 415 pub fn parent_record_lit(&self) -> ast::RecordExpr {
415 self.syntax().ancestors().find_map(ast::RecordLit::cast).unwrap() 416 self.syntax().ancestors().find_map(ast::RecordExpr::cast).unwrap()
416 } 417 }
417} 418}
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index f5199e09f..4a6f41ee7 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -1,6 +1,41 @@
1//! This file is actually hand-written, but the submodules are indeed generated. 1//! This file is actually hand-written, but the submodules are indeed generated.
2
3#[rustfmt::skip] 2#[rustfmt::skip]
4pub(super) mod nodes; 3mod nodes;
5#[rustfmt::skip] 4#[rustfmt::skip]
6pub(super) mod tokens; 5mod tokens;
6
7use crate::{
8 AstNode,
9 SyntaxKind::{self, *},
10 SyntaxNode,
11};
12
13pub use {nodes::*, tokens::*};
14
15// Stmt is the only nested enum, so it's easier to just hand-write it
16impl AstNode for Stmt {
17 fn can_cast(kind: SyntaxKind) -> bool {
18 match kind {
19 LET_STMT | EXPR_STMT => true,
20 _ => Item::can_cast(kind),
21 }
22 }
23 fn cast(syntax: SyntaxNode) -> Option<Self> {
24 let res = match syntax.kind() {
25 LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
26 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
27 _ => {
28 let item = Item::cast(syntax)?;
29 Stmt::Item(item)
30 }
31 };
32 Some(res)
33 }
34 fn syntax(&self) -> &SyntaxNode {
35 match self {
36 Stmt::LetStmt(it) => &it.syntax,
37 Stmt::ExprStmt(it) => &it.syntax,
38 Stmt::Item(it) => it.syntax(),
39 }
40 }
41}
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 58141da11..3d49309d1 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -5,1189 +5,649 @@ use crate::{
5 SyntaxKind::{self, *}, 5 SyntaxKind::{self, *},
6 SyntaxNode, SyntaxToken, T, 6 SyntaxNode, SyntaxToken, T,
7}; 7};
8/// The entire Rust source file. Includes all top-level inner attributes and module items.
9///
10/// [Reference](https://doc.rust-lang.org/reference/crates-and-source-files.html)
11#[derive(Debug, Clone, PartialEq, Eq, Hash)] 8#[derive(Debug, Clone, PartialEq, Eq, Hash)]
12pub struct SourceFile { 9pub struct Name {
13 pub(crate) syntax: SyntaxNode, 10 pub(crate) syntax: SyntaxNode,
14} 11}
15impl ast::ModuleItemOwner for SourceFile {} 12impl Name {
16impl ast::AttrsOwner for SourceFile {} 13 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
17impl ast::DocCommentsOwner for SourceFile {} 14}
18impl SourceFile { 15#[derive(Debug, Clone, PartialEq, Eq, Hash)]
19 pub fn modules(&self) -> AstChildren<Module> { support::children(&self.syntax) } 16pub struct NameRef {
20}
21/// Function definition either with body or not.
22/// Includes all of its attributes and doc comments.
23///
24/// ```
25/// ❰
26/// /// Docs
27/// #[attr]
28/// pub extern "C" fn foo<T>(#[attr] Patern {p}: Pattern) -> u32
29/// where
30/// T: Debug
31/// {
32/// 42
33/// }
34/// ❱
35///
36/// extern "C" {
37/// ❰ fn fn_decl(also_variadic_ffi: u32, ...) -> u32; ❱
38/// }
39/// ```
40///
41/// - [Reference](https://doc.rust-lang.org/reference/items/functions.html)
42/// - [Nomicon](https://doc.rust-lang.org/nomicon/ffi.html#variadic-functions)
43#[derive(Debug, Clone, PartialEq, Eq, Hash)]
44pub struct FnDef {
45 pub(crate) syntax: SyntaxNode, 17 pub(crate) syntax: SyntaxNode,
46} 18}
47impl ast::VisibilityOwner for FnDef {} 19impl NameRef {
48impl ast::NameOwner for FnDef {} 20 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
49impl ast::TypeParamsOwner for FnDef {} 21}
50impl ast::DocCommentsOwner for FnDef {} 22#[derive(Debug, Clone, PartialEq, Eq, Hash)]
51impl ast::AttrsOwner for FnDef {} 23pub struct Path {
52impl FnDef { 24 pub(crate) syntax: SyntaxNode,
53 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } 25}
54 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 26impl Path {
55 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 27 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
56 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } 28 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
57 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } 29 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) }
58 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) } 30}
31#[derive(Debug, Clone, PartialEq, Eq, Hash)]
32pub struct PathSegment {
33 pub(crate) syntax: SyntaxNode,
34}
35impl PathSegment {
36 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
37 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
38 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
39 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
40 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
41 pub fn generic_arg_list(&self) -> Option<GenericArgList> { support::child(&self.syntax) }
59 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 42 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
60 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 43 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
61 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 44 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
62 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 45 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) }
46 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
47 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
48}
49#[derive(Debug, Clone, PartialEq, Eq, Hash)]
50pub struct GenericArgList {
51 pub(crate) syntax: SyntaxNode,
52}
53impl GenericArgList {
54 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
55 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
56 pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) }
57 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
58}
59#[derive(Debug, Clone, PartialEq, Eq, Hash)]
60pub struct ParamList {
61 pub(crate) syntax: SyntaxNode,
62}
63impl ParamList {
64 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
65 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
66 pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }
67 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
68 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
63} 69}
64/// Return type annotation.
65///
66/// ```
67/// fn foo(a: u32) ❰ -> Option<u32> ❱ { Some(a) }
68/// ```
69///
70/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
71#[derive(Debug, Clone, PartialEq, Eq, Hash)] 70#[derive(Debug, Clone, PartialEq, Eq, Hash)]
72pub struct RetType { 71pub struct RetType {
73 pub(crate) syntax: SyntaxNode, 72 pub(crate) syntax: SyntaxNode,
74} 73}
75impl RetType { 74impl RetType {
76 pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } 75 pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) }
77 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 76 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
78} 77}
79/// Struct definition. 78#[derive(Debug, Clone, PartialEq, Eq, Hash)]
80/// Includes all of its attributes and doc comments. 79pub struct PathType {
81///
82/// ```
83/// ❰
84/// /// Docs
85/// #[attr]
86/// struct Foo<T> where T: Debug {
87/// /// Docs
88/// #[attr]
89/// pub a: u32,
90/// b: T,
91/// }
92/// ❱
93///
94/// ❰ struct Foo; ❱
95/// ❰ struct Foo<T>(#[attr] T) where T: Debug; ❱
96/// ```
97///
98/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
99#[derive(Debug, Clone, PartialEq, Eq, Hash)]
100pub struct StructDef {
101 pub(crate) syntax: SyntaxNode, 80 pub(crate) syntax: SyntaxNode,
102} 81}
103impl ast::VisibilityOwner for StructDef {} 82impl PathType {
104impl ast::NameOwner for StructDef {} 83 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
105impl ast::TypeParamsOwner for StructDef {}
106impl ast::AttrsOwner for StructDef {}
107impl ast::DocCommentsOwner for StructDef {}
108impl StructDef {
109 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) }
110 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
111 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
112} 84}
113/// Union definition. 85#[derive(Debug, Clone, PartialEq, Eq, Hash)]
114/// Includes all of its attributes and doc comments. 86pub struct TypeArg {
115///
116/// ```
117/// ❰
118/// /// Docs
119/// #[attr]
120/// pub union Foo<T> where T: Debug {
121/// /// Docs
122/// #[attr]
123/// a: T,
124/// b: u32,
125/// }
126/// ❱
127/// ```
128///
129/// [Reference](https://doc.rust-lang.org/reference/items/unions.html)
130#[derive(Debug, Clone, PartialEq, Eq, Hash)]
131pub struct UnionDef {
132 pub(crate) syntax: SyntaxNode, 87 pub(crate) syntax: SyntaxNode,
133} 88}
134impl ast::VisibilityOwner for UnionDef {} 89impl TypeArg {
135impl ast::NameOwner for UnionDef {} 90 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
136impl ast::TypeParamsOwner for UnionDef {}
137impl ast::AttrsOwner for UnionDef {}
138impl ast::DocCommentsOwner for UnionDef {}
139impl UnionDef {
140 pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) }
141 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
142 support::child(&self.syntax)
143 }
144} 91}
145/// Record field definition list including enclosing curly braces. 92#[derive(Debug, Clone, PartialEq, Eq, Hash)]
146/// 93pub struct AssocTypeArg {
147/// ```
148/// struct Foo // same for union
149/// ❰
150/// {
151/// a: u32,
152/// b: bool,
153/// }
154/// ❱
155/// ```
156///
157/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
158#[derive(Debug, Clone, PartialEq, Eq, Hash)]
159pub struct RecordFieldDefList {
160 pub(crate) syntax: SyntaxNode, 94 pub(crate) syntax: SyntaxNode,
161} 95}
162impl RecordFieldDefList { 96impl ast::TypeBoundsOwner for AssocTypeArg {}
163 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 97impl AssocTypeArg {
164 pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) } 98 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
165 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 99 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
100 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
166} 101}
167/// Record field definition including its attributes and doc comments. 102#[derive(Debug, Clone, PartialEq, Eq, Hash)]
168/// 103pub struct LifetimeArg {
169/// ` ``
170/// same for union
171/// struct Foo {
172/// ❰
173/// /// Docs
174/// #[attr]
175/// pub a: u32
176/// ❱
177///
178/// ❰ b: bool ❱
179/// }
180/// ```
181///
182/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
183#[derive(Debug, Clone, PartialEq, Eq, Hash)]
184pub struct RecordFieldDef {
185 pub(crate) syntax: SyntaxNode, 104 pub(crate) syntax: SyntaxNode,
186} 105}
187impl ast::VisibilityOwner for RecordFieldDef {} 106impl LifetimeArg {
188impl ast::NameOwner for RecordFieldDef {} 107 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
189impl ast::AttrsOwner for RecordFieldDef {} 108 support::token(&self.syntax, T![lifetime])
190impl ast::DocCommentsOwner for RecordFieldDef {} 109 }
191impl ast::TypeAscriptionOwner for RecordFieldDef {} 110}
192impl RecordFieldDef {} 111#[derive(Debug, Clone, PartialEq, Eq, Hash)]
193/// Tuple field definition list including enclosing parens. 112pub struct ConstArg {
194///
195/// ```
196/// struct Foo ❰ (u32, String, Vec<u32>) ❱;
197/// ```
198///
199/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
200#[derive(Debug, Clone, PartialEq, Eq, Hash)]
201pub struct TupleFieldDefList {
202 pub(crate) syntax: SyntaxNode, 113 pub(crate) syntax: SyntaxNode,
203} 114}
204impl TupleFieldDefList { 115impl ConstArg {
205 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 116 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
206 pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) }
207 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
208} 117}
209/// Tuple field definition including its attributes.
210///
211/// ```
212/// struct Foo(❰ #[attr] u32 ❱);
213/// ```
214///
215/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
216#[derive(Debug, Clone, PartialEq, Eq, Hash)] 118#[derive(Debug, Clone, PartialEq, Eq, Hash)]
217pub struct TupleFieldDef { 119pub struct TypeBoundList {
218 pub(crate) syntax: SyntaxNode, 120 pub(crate) syntax: SyntaxNode,
219} 121}
220impl ast::VisibilityOwner for TupleFieldDef {} 122impl TypeBoundList {
221impl ast::AttrsOwner for TupleFieldDef {} 123 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
222impl TupleFieldDef {
223 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
224}
225/// Enum definition.
226/// Includes all of its attributes and doc comments.
227///
228/// ```
229/// ❰
230/// /// Docs
231/// #[attr]
232/// pub enum Foo<T> where T: Debug {
233/// /// Docs
234/// #[attr]
235/// Bar,
236/// Baz(#[attr] u32),
237/// Bruh {
238/// a: u32,
239/// /// Docs
240/// #[attr]
241/// b: T,
242/// }
243/// }
244/// ❱
245/// ```
246///
247/// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
249pub struct EnumDef {
250 pub(crate) syntax: SyntaxNode,
251} 124}
252impl ast::VisibilityOwner for EnumDef {} 125#[derive(Debug, Clone, PartialEq, Eq, Hash)]
253impl ast::NameOwner for EnumDef {} 126pub struct MacroCall {
254impl ast::TypeParamsOwner for EnumDef {}
255impl ast::AttrsOwner for EnumDef {}
256impl ast::DocCommentsOwner for EnumDef {}
257impl EnumDef {
258 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
259 pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) }
260}
261/// Enum variant definition list including enclosing curly braces.
262///
263/// ```
264/// enum Foo
265/// ❰
266/// {
267/// Bar,
268/// Baz(u32),
269/// Bruh {
270/// a: u32
271/// }
272/// }
273/// ❱
274/// ```
275///
276/// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
277#[derive(Debug, Clone, PartialEq, Eq, Hash)]
278pub struct EnumVariantList {
279 pub(crate) syntax: SyntaxNode, 127 pub(crate) syntax: SyntaxNode,
280} 128}
281impl EnumVariantList { 129impl ast::AttrsOwner for MacroCall {}
282 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 130impl ast::NameOwner for MacroCall {}
283 pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) } 131impl MacroCall {
284 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 132 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
133 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
134 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
135 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
285} 136}
286/// Enum variant definition including its attributes and discriminant value definition. 137#[derive(Debug, Clone, PartialEq, Eq, Hash)]
287/// 138pub struct Attr {
288/// ```
289/// enum Foo {
290/// ❰
291/// /// Docs
292/// #[attr]
293/// Bar
294/// ❱
295///
296/// // same for tuple and record variants
297/// }
298/// ```
299///
300/// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
301#[derive(Debug, Clone, PartialEq, Eq, Hash)]
302pub struct EnumVariant {
303 pub(crate) syntax: SyntaxNode, 139 pub(crate) syntax: SyntaxNode,
304} 140}
305impl ast::VisibilityOwner for EnumVariant {} 141impl Attr {
306impl ast::NameOwner for EnumVariant {} 142 pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
307impl ast::DocCommentsOwner for EnumVariant {} 143 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
308impl ast::AttrsOwner for EnumVariant {} 144 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
309impl EnumVariant { 145 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
310 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
311 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 146 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
312 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 147 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
148 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
149 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
313} 150}
314/// Trait definition. 151#[derive(Debug, Clone, PartialEq, Eq, Hash)]
315/// Includes all of its attributes and doc comments. 152pub struct TokenTree {
316///
317/// ```
318/// ❰
319/// /// Docs
320/// #[attr]
321/// pub unsafe trait Foo<T>: Debug where T: Debug {
322/// // ...
323/// }
324/// ❱
325/// ```
326///
327/// [Reference](https://doc.rust-lang.org/reference/items/traits.html)
328#[derive(Debug, Clone, PartialEq, Eq, Hash)]
329pub struct TraitDef {
330 pub(crate) syntax: SyntaxNode, 153 pub(crate) syntax: SyntaxNode,
331} 154}
332impl ast::VisibilityOwner for TraitDef {} 155impl TokenTree {
333impl ast::NameOwner for TraitDef {} 156 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
334impl ast::AttrsOwner for TraitDef {} 157 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
335impl ast::DocCommentsOwner for TraitDef {} 158 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
336impl ast::TypeParamsOwner for TraitDef {} 159 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
337impl ast::TypeBoundsOwner for TraitDef {} 160 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
338impl TraitDef { 161 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
339 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
340 pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) }
341 pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) }
342 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
343} 162}
344/// Module definition either with body or not.
345/// Includes all of its inner and outer attributes, module items, doc comments.
346///
347/// ```
348/// ❰
349/// /// Docs
350/// #[attr]
351/// pub mod foo;
352/// ❱
353///
354/// ❰
355/// /// Docs
356/// #[attr]
357/// pub mod bar {
358/// //! Inner docs
359/// #![inner_attr]
360/// }
361/// ❱
362/// ```
363///
364/// [Reference](https://doc.rust-lang.org/reference/items/modules.html)
365#[derive(Debug, Clone, PartialEq, Eq, Hash)] 163#[derive(Debug, Clone, PartialEq, Eq, Hash)]
366pub struct Module { 164pub struct MacroItems {
367 pub(crate) syntax: SyntaxNode, 165 pub(crate) syntax: SyntaxNode,
368} 166}
369impl ast::VisibilityOwner for Module {} 167impl ast::ModuleItemOwner for MacroItems {}
370impl ast::NameOwner for Module {} 168impl MacroItems {}
371impl ast::AttrsOwner for Module {} 169#[derive(Debug, Clone, PartialEq, Eq, Hash)]
372impl ast::DocCommentsOwner for Module {} 170pub struct MacroStmts {
373impl Module { 171 pub(crate) syntax: SyntaxNode,
374 pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) } 172}
375 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } 173impl MacroStmts {
376 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 174 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
175 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
377} 176}
378/// Item defintion list.
379/// This is used for both top-level items and impl block items.
380///
381/// ```
382/// ❰
383/// fn foo {}
384/// struct Bar;
385/// enum Baz;
386/// trait Bruh;
387/// const BRUUH: u32 = 42;
388/// ❱
389///
390/// impl Foo
391/// ❰
392/// {
393/// fn bar() {}
394/// const BAZ: u32 = 42;
395/// }
396/// ❱
397/// ```
398///
399/// [Reference](https://doc.rust-lang.org/reference/items.html)
400#[derive(Debug, Clone, PartialEq, Eq, Hash)] 177#[derive(Debug, Clone, PartialEq, Eq, Hash)]
401pub struct ItemList { 178pub struct SourceFile {
402 pub(crate) syntax: SyntaxNode, 179 pub(crate) syntax: SyntaxNode,
403} 180}
404impl ast::ModuleItemOwner for ItemList {} 181impl ast::AttrsOwner for SourceFile {}
405impl ItemList { 182impl ast::ModuleItemOwner for SourceFile {}
406 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 183impl SourceFile {
407 pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) } 184 pub fn shebang_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![shebang]) }
408 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
409} 185}
410/// Constant variable definition. 186#[derive(Debug, Clone, PartialEq, Eq, Hash)]
411/// Includes all of its attributes and doc comments. 187pub struct Const {
412///
413/// ```
414/// ❰
415/// /// Docs
416/// #[attr]
417/// pub const FOO: u32 = 42;
418/// ❱
419/// ```
420///
421/// [Reference](https://doc.rust-lang.org/reference/items/constant-items.html)
422#[derive(Debug, Clone, PartialEq, Eq, Hash)]
423pub struct ConstDef {
424 pub(crate) syntax: SyntaxNode, 188 pub(crate) syntax: SyntaxNode,
425} 189}
426impl ast::VisibilityOwner for ConstDef {} 190impl ast::AttrsOwner for Const {}
427impl ast::NameOwner for ConstDef {} 191impl ast::NameOwner for Const {}
428impl ast::TypeParamsOwner for ConstDef {} 192impl ast::VisibilityOwner for Const {}
429impl ast::AttrsOwner for ConstDef {} 193impl Const {
430impl ast::DocCommentsOwner for ConstDef {}
431impl ast::TypeAscriptionOwner for ConstDef {}
432impl ConstDef {
433 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 194 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
434 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 195 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
196 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
197 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
198 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
435 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 199 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
436 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 200 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
437 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 201 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
438} 202}
439/// Static variable definition. 203#[derive(Debug, Clone, PartialEq, Eq, Hash)]
440/// Includes all of its attributes and doc comments. 204pub struct Enum {
441///
442/// ```
443/// ❰
444/// /// Docs
445/// #[attr]
446/// pub static mut FOO: u32 = 42;
447/// ❱
448/// ```
449///
450/// [Reference](https://doc.rust-lang.org/reference/items/static-items.html)
451#[derive(Debug, Clone, PartialEq, Eq, Hash)]
452pub struct StaticDef {
453 pub(crate) syntax: SyntaxNode, 205 pub(crate) syntax: SyntaxNode,
454} 206}
455impl ast::VisibilityOwner for StaticDef {} 207impl ast::AttrsOwner for Enum {}
456impl ast::NameOwner for StaticDef {} 208impl ast::NameOwner for Enum {}
457impl ast::TypeParamsOwner for StaticDef {} 209impl ast::VisibilityOwner for Enum {}
458impl ast::AttrsOwner for StaticDef {} 210impl ast::GenericParamsOwner for Enum {}
459impl ast::DocCommentsOwner for StaticDef {} 211impl Enum {
460impl ast::TypeAscriptionOwner for StaticDef {} 212 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
461impl StaticDef { 213 pub fn variant_list(&self) -> Option<VariantList> { support::child(&self.syntax) }
462 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } 214}
463 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 215#[derive(Debug, Clone, PartialEq, Eq, Hash)]
464 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 216pub struct ExternBlock {
465 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 217 pub(crate) syntax: SyntaxNode,
218}
219impl ast::AttrsOwner for ExternBlock {}
220impl ExternBlock {
221 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
222 pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
223}
224#[derive(Debug, Clone, PartialEq, Eq, Hash)]
225pub struct ExternCrate {
226 pub(crate) syntax: SyntaxNode,
227}
228impl ast::AttrsOwner for ExternCrate {}
229impl ast::VisibilityOwner for ExternCrate {}
230impl ExternCrate {
231 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
232 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
233 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
234 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
235 pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) }
466 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 236 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
467} 237}
468/// Type alias definition. 238#[derive(Debug, Clone, PartialEq, Eq, Hash)]
469/// Includes associated type clauses with type bounds. 239pub struct Fn {
470///
471/// ```
472/// ❰
473/// /// Docs
474/// #[attr]
475/// pub type Foo<T> where T: Debug = T;
476/// ❱
477///
478/// trait Bar {
479/// ❰ type Baz: Debug; ❱
480/// ❰ type Bruh = String; ❱
481/// ❰ type Bruuh: Debug = u32; ❱
482/// }
483/// ```
484///
485/// [Reference](https://doc.rust-lang.org/reference/items/type-aliases.html)
486#[derive(Debug, Clone, PartialEq, Eq, Hash)]
487pub struct TypeAliasDef {
488 pub(crate) syntax: SyntaxNode, 240 pub(crate) syntax: SyntaxNode,
489} 241}
490impl ast::VisibilityOwner for TypeAliasDef {} 242impl ast::AttrsOwner for Fn {}
491impl ast::NameOwner for TypeAliasDef {} 243impl ast::NameOwner for Fn {}
492impl ast::TypeParamsOwner for TypeAliasDef {} 244impl ast::VisibilityOwner for Fn {}
493impl ast::AttrsOwner for TypeAliasDef {} 245impl ast::GenericParamsOwner for Fn {}
494impl ast::DocCommentsOwner for TypeAliasDef {} 246impl Fn {
495impl ast::TypeBoundsOwner for TypeAliasDef {}
496impl TypeAliasDef {
497 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 247 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
498 pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } 248 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
499 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 249 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
500 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 250 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
251 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
252 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) }
253 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
254 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
255 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
501 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 256 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
502} 257}
503/// Inherent and trait impl definition. 258#[derive(Debug, Clone, PartialEq, Eq, Hash)]
504/// Includes all of its inner and outer attributes. 259pub struct Impl {
505///
506/// ```
507/// ❰
508/// #[attr]
509/// unsafe impl<T> const !Foo for Bar where T: Debug {
510/// #![inner_attr]
511/// // ...
512/// }
513/// ❱
514/// ```
515///
516/// [Reference](https://doc.rust-lang.org/reference/items/implementations.html)
517#[derive(Debug, Clone, PartialEq, Eq, Hash)]
518pub struct ImplDef {
519 pub(crate) syntax: SyntaxNode, 260 pub(crate) syntax: SyntaxNode,
520} 261}
521impl ast::TypeParamsOwner for ImplDef {} 262impl ast::AttrsOwner for Impl {}
522impl ast::AttrsOwner for ImplDef {} 263impl ast::VisibilityOwner for Impl {}
523impl ast::DocCommentsOwner for ImplDef {} 264impl ast::GenericParamsOwner for Impl {}
524impl ImplDef { 265impl Impl {
525 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 266 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
526 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
527 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } 267 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
528 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } 268 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
269 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
529 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } 270 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
530 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 271 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
272 pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) }
273}
274#[derive(Debug, Clone, PartialEq, Eq, Hash)]
275pub struct Module {
276 pub(crate) syntax: SyntaxNode,
277}
278impl ast::AttrsOwner for Module {}
279impl ast::NameOwner for Module {}
280impl ast::VisibilityOwner for Module {}
281impl Module {
282 pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) }
531 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } 283 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
284 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
532} 285}
533/// Parenthesized type reference.
534/// Note: parens are only used for grouping, this is not a tuple type.
535///
536/// ```
537/// // This is effectively just `u32`.
538/// // Single-item tuple must be defined with a trailing comma: `(u32,)`
539/// type Foo = ❰ (u32) ❱;
540///
541/// let bar: &'static ❰ (dyn Debug) ❱ = "bruh";
542/// ```
543#[derive(Debug, Clone, PartialEq, Eq, Hash)] 286#[derive(Debug, Clone, PartialEq, Eq, Hash)]
544pub struct ParenType { 287pub struct Static {
545 pub(crate) syntax: SyntaxNode, 288 pub(crate) syntax: SyntaxNode,
546} 289}
547impl ParenType { 290impl ast::AttrsOwner for Static {}
548 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 291impl ast::NameOwner for Static {}
549 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 292impl ast::VisibilityOwner for Static {}
550 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 293impl Static {
294 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
295 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
296 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
297 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
298 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
299 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
300 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
551} 301}
552/// Unnamed tuple type.
553///
554/// ```
555/// let foo: ❰ (u32, bool) ❱ = (42, true);
556/// ```
557///
558/// [Reference](https://doc.rust-lang.org/reference/types/tuple.html)
559#[derive(Debug, Clone, PartialEq, Eq, Hash)] 302#[derive(Debug, Clone, PartialEq, Eq, Hash)]
560pub struct TupleType { 303pub struct Struct {
561 pub(crate) syntax: SyntaxNode, 304 pub(crate) syntax: SyntaxNode,
562} 305}
563impl TupleType { 306impl ast::AttrsOwner for Struct {}
564 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 307impl ast::NameOwner for Struct {}
565 pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) } 308impl ast::VisibilityOwner for Struct {}
566 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 309impl ast::GenericParamsOwner for Struct {}
310impl Struct {
311 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) }
312 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
313 pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) }
567} 314}
568/// The never type (i.e. the exclamation point).
569///
570/// ```
571/// type T = ❰ ! ❱;
572///
573/// fn no_return() -> ❰ ! ❱ {
574/// loop {}
575/// }
576/// ```
577///
578/// [Reference](https://doc.rust-lang.org/reference/types/never.html)
579#[derive(Debug, Clone, PartialEq, Eq, Hash)] 315#[derive(Debug, Clone, PartialEq, Eq, Hash)]
580pub struct NeverType { 316pub struct Trait {
581 pub(crate) syntax: SyntaxNode, 317 pub(crate) syntax: SyntaxNode,
582} 318}
583impl NeverType { 319impl ast::AttrsOwner for Trait {}
584 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } 320impl ast::NameOwner for Trait {}
321impl ast::VisibilityOwner for Trait {}
322impl ast::GenericParamsOwner for Trait {}
323impl ast::TypeBoundsOwner for Trait {}
324impl Trait {
325 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
326 pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) }
327 pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) }
328 pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) }
585} 329}
586/// Path to a type.
587/// Includes single identifier type names and elaborate paths with
588/// generic parameters.
589///
590/// ```
591/// type Foo = ❰ String ❱;
592/// type Bar = ❰ std::vec::Vec<T> ❱;
593/// type Baz = ❰ ::bruh::<Bruuh as Iterator>::Item ❱;
594/// ```
595///
596/// [Reference](https://doc.rust-lang.org/reference/paths.html)
597#[derive(Debug, Clone, PartialEq, Eq, Hash)] 330#[derive(Debug, Clone, PartialEq, Eq, Hash)]
598pub struct PathType { 331pub struct TypeAlias {
599 pub(crate) syntax: SyntaxNode, 332 pub(crate) syntax: SyntaxNode,
600} 333}
601impl PathType { 334impl ast::AttrsOwner for TypeAlias {}
602 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 335impl ast::NameOwner for TypeAlias {}
336impl ast::VisibilityOwner for TypeAlias {}
337impl ast::GenericParamsOwner for TypeAlias {}
338impl ast::TypeBoundsOwner for TypeAlias {}
339impl TypeAlias {
340 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
341 pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) }
342 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
343 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
344 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
603} 345}
604/// Raw pointer type.
605///
606/// ```
607/// type Foo = ❰ *const u32 ❱;
608/// type Bar = ❰ *mut u32 ❱;
609/// ```
610///
611/// [Reference](https://doc.rust-lang.org/reference/types/pointer.html#raw-pointers-const-and-mut)
612#[derive(Debug, Clone, PartialEq, Eq, Hash)] 346#[derive(Debug, Clone, PartialEq, Eq, Hash)]
613pub struct PointerType { 347pub struct Union {
614 pub(crate) syntax: SyntaxNode, 348 pub(crate) syntax: SyntaxNode,
615} 349}
616impl PointerType { 350impl ast::AttrsOwner for Union {}
617 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) } 351impl ast::NameOwner for Union {}
618 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 352impl ast::VisibilityOwner for Union {}
619 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 353impl ast::GenericParamsOwner for Union {}
620 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 354impl Union {
355 pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) }
356 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) }
621} 357}
622/// Array type.
623///
624/// ```
625/// type Foo = ❰ [u32; 24 - 3] ❱;
626/// ```
627///
628/// [Reference](https://doc.rust-lang.org/reference/types/array.html)
629#[derive(Debug, Clone, PartialEq, Eq, Hash)] 358#[derive(Debug, Clone, PartialEq, Eq, Hash)]
630pub struct ArrayType { 359pub struct Use {
631 pub(crate) syntax: SyntaxNode, 360 pub(crate) syntax: SyntaxNode,
632} 361}
633impl ArrayType { 362impl ast::AttrsOwner for Use {}
634 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 363impl ast::VisibilityOwner for Use {}
635 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 364impl Use {
365 pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
366 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
636 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 367 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
637 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
638 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
639} 368}
640/// Slice type.
641///
642/// ```
643/// type Foo = ❰ [u8] ❱;
644/// ```
645///
646/// [Reference](https://doc.rust-lang.org/reference/types/slice.html)
647#[derive(Debug, Clone, PartialEq, Eq, Hash)] 369#[derive(Debug, Clone, PartialEq, Eq, Hash)]
648pub struct SliceType { 370pub struct Visibility {
649 pub(crate) syntax: SyntaxNode, 371 pub(crate) syntax: SyntaxNode,
650} 372}
651impl SliceType { 373impl Visibility {
652 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 374 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
653 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 375 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
654 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 376 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
377 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
378 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
379 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
380 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
381 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
655} 382}
656/// Reference type.
657///
658/// ```
659/// type Foo = ❰ &'static str ❱;
660/// ```
661///
662/// [Reference](https://doc.rust-lang.org/reference/types/pointer.html)
663#[derive(Debug, Clone, PartialEq, Eq, Hash)] 383#[derive(Debug, Clone, PartialEq, Eq, Hash)]
664pub struct ReferenceType { 384pub struct ItemList {
665 pub(crate) syntax: SyntaxNode, 385 pub(crate) syntax: SyntaxNode,
666} 386}
667impl ReferenceType { 387impl ast::AttrsOwner for ItemList {}
668 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } 388impl ast::ModuleItemOwner for ItemList {}
669 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 389impl ItemList {
670 support::token(&self.syntax, T![lifetime]) 390 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
671 } 391 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
672 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
673 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
674} 392}
675/// Placeholder type (i.e. the underscore).
676///
677/// ```
678/// let foo: ❰ _ ❱ = 42_u32;
679/// ```
680///
681/// [Reference](https://doc.rust-lang.org/reference/types/inferred.html)
682#[derive(Debug, Clone, PartialEq, Eq, Hash)] 393#[derive(Debug, Clone, PartialEq, Eq, Hash)]
683pub struct PlaceholderType { 394pub struct Rename {
684 pub(crate) syntax: SyntaxNode, 395 pub(crate) syntax: SyntaxNode,
685} 396}
686impl PlaceholderType { 397impl ast::NameOwner for Rename {}
398impl Rename {
399 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
687 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } 400 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
688} 401}
689/// Function pointer type (not to be confused with `Fn*` family of traits). 402#[derive(Debug, Clone, PartialEq, Eq, Hash)]
690/// 403pub struct UseTree {
691/// ```
692/// type Foo = ❰ async fn(#[attr] u32, named: bool) -> u32 ❱;
693///
694/// type Bar = ❰ extern "C" fn(variadic: u32, #[attr] ...) ❱;
695/// ```
696///
697/// [Reference](https://doc.rust-lang.org/reference/types/function-pointer.html)
698#[derive(Debug, Clone, PartialEq, Eq, Hash)]
699pub struct FnPointerType {
700 pub(crate) syntax: SyntaxNode, 404 pub(crate) syntax: SyntaxNode,
701} 405}
702impl FnPointerType { 406impl UseTree {
703 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } 407 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
704 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } 408 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
705 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) } 409 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
706 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 410 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
707 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 411 pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) }
708} 412}
709/// Higher order type.
710///
711/// ```
712/// type Foo = ❰ for<'a> fn(&'a str) ❱;
713/// ```
714///
715/// [Reference](https://doc.rust-lang.org/nomicon/hrtb.html)
716#[derive(Debug, Clone, PartialEq, Eq, Hash)] 413#[derive(Debug, Clone, PartialEq, Eq, Hash)]
717pub struct ForType { 414pub struct UseTreeList {
718 pub(crate) syntax: SyntaxNode, 415 pub(crate) syntax: SyntaxNode,
719} 416}
720impl ForType { 417impl UseTreeList {
721 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 418 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
722 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } 419 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) }
723 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 420 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
724} 421}
725/// Opaque `impl Trait` type.
726///
727/// ```
728/// fn foo(bar: ❰ impl Debug + Eq ❱) {}
729/// ```
730///
731/// [Reference](https://doc.rust-lang.org/reference/types/impl-trait.html)
732#[derive(Debug, Clone, PartialEq, Eq, Hash)] 422#[derive(Debug, Clone, PartialEq, Eq, Hash)]
733pub struct ImplTraitType { 423pub struct Abi {
734 pub(crate) syntax: SyntaxNode, 424 pub(crate) syntax: SyntaxNode,
735} 425}
736impl ast::TypeBoundsOwner for ImplTraitType {} 426impl Abi {
737impl ImplTraitType { 427 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
738 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
739} 428}
740/// Trait object type.
741///
742/// ```
743/// type Foo = ❰ dyn Debug ❱;
744/// ```
745///
746/// [Reference](https://doc.rust-lang.org/reference/types/trait-object.html)
747#[derive(Debug, Clone, PartialEq, Eq, Hash)] 429#[derive(Debug, Clone, PartialEq, Eq, Hash)]
748pub struct DynTraitType { 430pub struct GenericParamList {
749 pub(crate) syntax: SyntaxNode, 431 pub(crate) syntax: SyntaxNode,
750} 432}
751impl ast::TypeBoundsOwner for DynTraitType {} 433impl GenericParamList {
752impl DynTraitType { 434 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
753 pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![dyn]) } 435 pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) }
436 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
754} 437}
755/// Tuple literal.
756///
757/// ```
758/// ❰ (42, true) ❱;
759/// ```
760///
761/// [Reference](https://doc.rust-lang.org/reference/expressions/tuple-expr.html)
762#[derive(Debug, Clone, PartialEq, Eq, Hash)] 438#[derive(Debug, Clone, PartialEq, Eq, Hash)]
763pub struct TupleExpr { 439pub struct WhereClause {
764 pub(crate) syntax: SyntaxNode, 440 pub(crate) syntax: SyntaxNode,
765} 441}
766impl ast::AttrsOwner for TupleExpr {} 442impl WhereClause {
767impl TupleExpr { 443 pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) }
768 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 444 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
769 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
770 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
771} 445}
772/// Array literal.
773///
774/// ```
775/// ❰ [#![inner_attr] true, false, true] ❱;
776///
777/// ❰ ["baz"; 24] ❱;
778/// ```
779///
780/// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html)
781#[derive(Debug, Clone, PartialEq, Eq, Hash)] 446#[derive(Debug, Clone, PartialEq, Eq, Hash)]
782pub struct ArrayExpr { 447pub struct BlockExpr {
783 pub(crate) syntax: SyntaxNode, 448 pub(crate) syntax: SyntaxNode,
784} 449}
785impl ast::AttrsOwner for ArrayExpr {} 450impl ast::AttrsOwner for BlockExpr {}
786impl ArrayExpr { 451impl BlockExpr {
787 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 452 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
788 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } 453 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
789 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 454 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
790 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 455 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
791} 456}
792/// Parenthesized expression.
793/// Note: parens are only used for grouping, this is not a tuple literal.
794///
795/// ```
796/// ❰ (#![inner_attr] 2 + 2) ❱ * 2;
797/// ```
798///
799/// [Reference](https://doc.rust-lang.org/reference/expressions/grouped-expr.html)
800#[derive(Debug, Clone, PartialEq, Eq, Hash)] 457#[derive(Debug, Clone, PartialEq, Eq, Hash)]
801pub struct ParenExpr { 458pub struct SelfParam {
802 pub(crate) syntax: SyntaxNode, 459 pub(crate) syntax: SyntaxNode,
803} 460}
804impl ast::AttrsOwner for ParenExpr {} 461impl ast::AttrsOwner for SelfParam {}
805impl ParenExpr { 462impl SelfParam {
806 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 463 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
807 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 464 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
808 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 465 support::token(&self.syntax, T![lifetime])
466 }
467 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
468 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
469 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
470 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
809} 471}
810/// Path to a symbol in expression context.
811/// Includes single identifier variable names and elaborate paths with
812/// generic parameters.
813///
814/// ```
815/// ❰ Some::<i32> ❱;
816/// ❰ foo ❱ + 42;
817/// ❰ Vec::<i32>::push ❱;
818/// ❰ <[i32]>::reverse ❱;
819/// ❰ <String as std::borrow::Borrow<str>>::borrow ❱;
820/// ```
821///
822/// [Reference](https://doc.rust-lang.org/reference/expressions/path-expr.html)
823#[derive(Debug, Clone, PartialEq, Eq, Hash)] 472#[derive(Debug, Clone, PartialEq, Eq, Hash)]
824pub struct PathExpr { 473pub struct Param {
825 pub(crate) syntax: SyntaxNode, 474 pub(crate) syntax: SyntaxNode,
826} 475}
827impl PathExpr { 476impl ast::AttrsOwner for Param {}
828 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 477impl Param {
478 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
479 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
480 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
481 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
829} 482}
830/// Anonymous callable object literal a.k.a. closure, lambda or functor. 483#[derive(Debug, Clone, PartialEq, Eq, Hash)]
831/// 484pub struct RecordFieldList {
832/// ```
833/// ❰ || 42 ❱;
834/// ❰ |a: u32| val + 1 ❱;
835/// ❰ async |#[attr] Pattern(_): Pattern| { bar } ❱;
836/// ❰ move || baz ❱;
837/// ❰ || -> u32 { closure_with_ret_type_annotation_requires_block_expr } ❱
838/// ```
839///
840/// [Reference](https://doc.rust-lang.org/reference/expressions/closure-expr.html)
841#[derive(Debug, Clone, PartialEq, Eq, Hash)]
842pub struct LambdaExpr {
843 pub(crate) syntax: SyntaxNode, 485 pub(crate) syntax: SyntaxNode,
844} 486}
845impl ast::AttrsOwner for LambdaExpr {} 487impl RecordFieldList {
846impl LambdaExpr { 488 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
847 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } 489 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) }
848 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } 490 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
849 pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) }
850 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
851 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
852 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
853} 491}
854/// If expression. Includes both regular `if` and `if let` forms.
855/// Beware that `else if` is a special case syntax sugar, because in general
856/// there has to be block expression after `else`.
857///
858/// ```
859/// ❰ if bool_cond { 42 } ❱
860/// ❰ if bool_cond { 42 } else { 24 } ❱
861/// ❰ if bool_cond { 42 } else if bool_cond2 { 42 } ❱
862///
863/// ❰
864/// if let Pattern(foo) = bar {
865/// foo
866/// } else {
867/// panic!();
868/// }
869/// ❱
870/// ```
871///
872/// [Reference](https://doc.rust-lang.org/reference/expressions/if-expr.html)
873#[derive(Debug, Clone, PartialEq, Eq, Hash)] 492#[derive(Debug, Clone, PartialEq, Eq, Hash)]
874pub struct IfExpr { 493pub struct TupleFieldList {
875 pub(crate) syntax: SyntaxNode, 494 pub(crate) syntax: SyntaxNode,
876} 495}
877impl ast::AttrsOwner for IfExpr {} 496impl TupleFieldList {
878impl IfExpr { 497 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
879 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) } 498 pub fn fields(&self) -> AstChildren<TupleField> { support::children(&self.syntax) }
880 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 499 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
881} 500}
882/// Unconditional loop expression.
883///
884/// ```
885/// ❰
886/// loop {
887/// // yeah, it's that simple...
888/// }
889/// ❱
890/// ```
891///
892/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html)
893#[derive(Debug, Clone, PartialEq, Eq, Hash)] 501#[derive(Debug, Clone, PartialEq, Eq, Hash)]
894pub struct LoopExpr { 502pub struct RecordField {
895 pub(crate) syntax: SyntaxNode, 503 pub(crate) syntax: SyntaxNode,
896} 504}
897impl ast::AttrsOwner for LoopExpr {} 505impl ast::AttrsOwner for RecordField {}
898impl ast::LoopBodyOwner for LoopExpr {} 506impl ast::NameOwner for RecordField {}
899impl LoopExpr { 507impl ast::VisibilityOwner for RecordField {}
900 pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) } 508impl RecordField {
509 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
510 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
901} 511}
902/// Block expression with an optional prefix (label, try ketword,
903/// unsafe keyword, async keyword...).
904///
905/// ```
906/// ❰
907/// 'label: try {
908/// None?
909/// }
910/// ❱
911/// ```
912///
913/// - [try block](https://doc.rust-lang.org/unstable-book/language-features/try-blocks.html)
914/// - [unsafe block](https://doc.rust-lang.org/reference/expressions/block-expr.html#unsafe-blocks)
915/// - [async block](https://doc.rust-lang.org/reference/expressions/block-expr.html#async-blocks)
916#[derive(Debug, Clone, PartialEq, Eq, Hash)] 512#[derive(Debug, Clone, PartialEq, Eq, Hash)]
917pub struct EffectExpr { 513pub struct TupleField {
918 pub(crate) syntax: SyntaxNode, 514 pub(crate) syntax: SyntaxNode,
919} 515}
920impl ast::AttrsOwner for EffectExpr {} 516impl ast::AttrsOwner for TupleField {}
921impl EffectExpr { 517impl ast::VisibilityOwner for TupleField {}
922 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) } 518impl TupleField {
923 pub fn try_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![try]) } 519 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
924 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
925 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
926 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
927} 520}
928/// For loop expression.
929/// Note: record struct literals are not valid as iterable expression
930/// due to ambiguity.
931///
932/// ```
933/// ❰
934/// for i in (0..4) {
935/// dbg!(i);
936/// }
937/// ❱
938/// ```
939///
940/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#iterator-loops)
941#[derive(Debug, Clone, PartialEq, Eq, Hash)] 521#[derive(Debug, Clone, PartialEq, Eq, Hash)]
942pub struct ForExpr { 522pub struct VariantList {
943 pub(crate) syntax: SyntaxNode, 523 pub(crate) syntax: SyntaxNode,
944} 524}
945impl ast::AttrsOwner for ForExpr {} 525impl VariantList {
946impl ast::LoopBodyOwner for ForExpr {} 526 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
947impl ForExpr { 527 pub fn variants(&self) -> AstChildren<Variant> { support::children(&self.syntax) }
948 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 528 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
949 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
950 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
951 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) }
952} 529}
953/// While loop expression. Includes both regular `while` and `while let` forms.
954///
955/// ```
956/// ❰
957/// while bool_cond {
958/// 42;
959/// }
960/// ❱
961/// ❰
962/// while let Pattern(foo) = bar {
963/// bar += 1;
964/// }
965/// ❱
966/// ```
967///
968/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops)
969#[derive(Debug, Clone, PartialEq, Eq, Hash)] 530#[derive(Debug, Clone, PartialEq, Eq, Hash)]
970pub struct WhileExpr { 531pub struct Variant {
971 pub(crate) syntax: SyntaxNode, 532 pub(crate) syntax: SyntaxNode,
972} 533}
973impl ast::AttrsOwner for WhileExpr {} 534impl ast::AttrsOwner for Variant {}
974impl ast::LoopBodyOwner for WhileExpr {} 535impl ast::NameOwner for Variant {}
975impl WhileExpr { 536impl ast::VisibilityOwner for Variant {}
976 pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) } 537impl Variant {
977 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 538 pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) }
539 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
540 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
978} 541}
979/// Continue expression.
980///
981/// ```
982/// while bool_cond {
983/// ❰ continue ❱;
984/// }
985///
986/// 'outer: loop {
987/// loop {
988/// ❰ continue 'outer ❱;
989/// }
990/// }
991///
992/// ```
993///
994/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#continue-expressions)
995#[derive(Debug, Clone, PartialEq, Eq, Hash)] 542#[derive(Debug, Clone, PartialEq, Eq, Hash)]
996pub struct ContinueExpr { 543pub struct AssocItemList {
997 pub(crate) syntax: SyntaxNode, 544 pub(crate) syntax: SyntaxNode,
998} 545}
999impl ast::AttrsOwner for ContinueExpr {} 546impl ast::AttrsOwner for AssocItemList {}
1000impl ContinueExpr { 547impl AssocItemList {
1001 pub fn continue_token(&self) -> Option<SyntaxToken> { 548 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1002 support::token(&self.syntax, T![continue]) 549 pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) }
1003 } 550 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1004 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1005 support::token(&self.syntax, T![lifetime])
1006 }
1007} 551}
1008/// Break expression.
1009///
1010/// ```
1011/// while bool_cond {
1012/// ❰ break ❱;
1013/// }
1014/// 'outer: loop {
1015/// for foo in bar {
1016/// ❰ break 'outer ❱;
1017/// }
1018/// }
1019/// 'outer: loop {
1020/// loop {
1021/// ❰ break 'outer 42 ❱;
1022/// }
1023/// }
1024/// ```
1025///
1026/// [Refernce](https://doc.rust-lang.org/reference/expressions/loop-expr.html#break-expressions)
1027#[derive(Debug, Clone, PartialEq, Eq, Hash)] 552#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1028pub struct BreakExpr { 553pub struct ExternItemList {
1029 pub(crate) syntax: SyntaxNode, 554 pub(crate) syntax: SyntaxNode,
1030} 555}
1031impl ast::AttrsOwner for BreakExpr {} 556impl ast::AttrsOwner for ExternItemList {}
1032impl BreakExpr { 557impl ExternItemList {
1033 pub fn break_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![break]) } 558 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1034 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 559 pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) }
1035 support::token(&self.syntax, T![lifetime]) 560 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1036 }
1037 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1038} 561}
1039/// Label.
1040///
1041/// ```
1042/// ❰ 'outer: ❱ loop {}
1043///
1044/// let foo = ❰ 'bar: ❱ loop {}
1045///
1046/// ❰ 'baz: ❱ {
1047/// break 'baz;
1048/// }
1049/// ```
1050///
1051/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html?highlight=label#loop-labels)
1052/// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md)
1053#[derive(Debug, Clone, PartialEq, Eq, Hash)] 562#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1054pub struct Label { 563pub struct ConstParam {
1055 pub(crate) syntax: SyntaxNode, 564 pub(crate) syntax: SyntaxNode,
1056} 565}
1057impl Label { 566impl ast::AttrsOwner for ConstParam {}
567impl ast::NameOwner for ConstParam {}
568impl ConstParam {
569 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
570 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
571 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
572 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
573 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
574}
575#[derive(Debug, Clone, PartialEq, Eq, Hash)]
576pub struct LifetimeParam {
577 pub(crate) syntax: SyntaxNode,
578}
579impl ast::AttrsOwner for LifetimeParam {}
580impl ast::TypeBoundsOwner for LifetimeParam {}
581impl LifetimeParam {
1058 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 582 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1059 support::token(&self.syntax, T![lifetime]) 583 support::token(&self.syntax, T![lifetime])
1060 } 584 }
1061} 585}
1062/// Block expression. Includes unsafe blocks and block labels.
1063///
1064/// ```
1065/// let foo = ❰
1066/// {
1067/// #![inner_attr]
1068/// ❰ { } ❱
1069///
1070/// ❰ 'label: { break 'label } ❱
1071/// }
1072/// ❱;
1073/// ```
1074///
1075/// [Reference](https://doc.rust-lang.org/reference/expressions/block-expr.html)
1076/// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md)
1077#[derive(Debug, Clone, PartialEq, Eq, Hash)] 586#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1078pub struct BlockExpr { 587pub struct TypeParam {
1079 pub(crate) syntax: SyntaxNode, 588 pub(crate) syntax: SyntaxNode,
1080} 589}
1081impl ast::AttrsOwner for BlockExpr {} 590impl ast::AttrsOwner for TypeParam {}
1082impl ast::ModuleItemOwner for BlockExpr {} 591impl ast::NameOwner for TypeParam {}
1083impl BlockExpr { 592impl ast::TypeBoundsOwner for TypeParam {}
1084 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) } 593impl TypeParam {
1085 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 594 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1086 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) } 595 pub fn default_type(&self) -> Option<Type> { support::child(&self.syntax) }
1087 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1088 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1089} 596}
1090/// Return expression.
1091///
1092/// ```
1093/// || ❰ return 42 ❱;
1094///
1095/// fn bar() {
1096/// ❰ return ❱;
1097/// }
1098/// ```
1099///
1100/// [Reference](https://doc.rust-lang.org/reference/expressions/return-expr.html)
1101#[derive(Debug, Clone, PartialEq, Eq, Hash)] 597#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1102pub struct ReturnExpr { 598pub struct WherePred {
1103 pub(crate) syntax: SyntaxNode, 599 pub(crate) syntax: SyntaxNode,
1104} 600}
1105impl ast::AttrsOwner for ReturnExpr {} 601impl ast::TypeBoundsOwner for WherePred {}
1106impl ReturnExpr { 602impl WherePred {
1107 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 603 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
604 pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) }
605 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
606 support::token(&self.syntax, T![lifetime])
607 }
608 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
1108} 609}
1109/// Call expression (not to be confused with method call expression, it is
1110/// a separate ast node).
1111///
1112/// ```
1113/// ❰ foo() ❱;
1114/// ❰ &str::len("bar") ❱;
1115/// ❰ <&str as PartialEq<&str>>::eq(&"", &"") ❱;
1116/// ```
1117///
1118/// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html)
1119#[derive(Debug, Clone, PartialEq, Eq, Hash)] 610#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1120pub struct CallExpr { 611pub struct Literal {
1121 pub(crate) syntax: SyntaxNode, 612 pub(crate) syntax: SyntaxNode,
1122} 613}
1123impl ast::ArgListOwner for CallExpr {} 614impl ast::AttrsOwner for Literal {}
1124impl CallExpr { 615impl Literal {}
1125 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1126}
1127/// Method call expression.
1128///
1129/// ```
1130/// ❰ receiver_expr.method() ❱;
1131/// ❰ receiver_expr.method::<T>(42, true) ❱;
1132///
1133/// ❰ ❰ ❰ foo.bar() ❱ .baz() ❱ .bruh() ❱;
1134/// ```
1135///
1136/// [Reference](https://doc.rust-lang.org/reference/expressions/method-call-expr.html)
1137#[derive(Debug, Clone, PartialEq, Eq, Hash)] 616#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1138pub struct MethodCallExpr { 617pub struct ExprStmt {
1139 pub(crate) syntax: SyntaxNode, 618 pub(crate) syntax: SyntaxNode,
1140} 619}
1141impl ast::AttrsOwner for MethodCallExpr {} 620impl ast::AttrsOwner for ExprStmt {}
1142impl ast::ArgListOwner for MethodCallExpr {} 621impl ExprStmt {
1143impl MethodCallExpr {
1144 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 622 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1145 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } 623 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
1146 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1147 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
1148} 624}
1149/// Index expression a.k.a. subscript operator call.
1150///
1151/// ```
1152/// ❰ foo[42] ❱;
1153/// ```
1154///
1155/// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html)
1156#[derive(Debug, Clone, PartialEq, Eq, Hash)] 625#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1157pub struct IndexExpr { 626pub struct LetStmt {
1158 pub(crate) syntax: SyntaxNode, 627 pub(crate) syntax: SyntaxNode,
1159} 628}
1160impl ast::AttrsOwner for IndexExpr {} 629impl ast::AttrsOwner for LetStmt {}
1161impl IndexExpr { 630impl LetStmt {
1162 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 631 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
1163 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 632 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
633 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
634 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
635 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
636 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
637 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
1164} 638}
1165/// Field access expression.
1166///
1167/// ```
1168/// ❰ expr.bar ❱;
1169///
1170/// ❰ ❰ ❰ foo.bar ❱ .baz ❱ .bruh ❱;
1171/// ```
1172///
1173/// [Reference](https://doc.rust-lang.org/reference/expressions/field-expr.html)
1174#[derive(Debug, Clone, PartialEq, Eq, Hash)] 639#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1175pub struct FieldExpr { 640pub struct ArrayExpr {
1176 pub(crate) syntax: SyntaxNode, 641 pub(crate) syntax: SyntaxNode,
1177} 642}
1178impl ast::AttrsOwner for FieldExpr {} 643impl ast::AttrsOwner for ArrayExpr {}
1179impl FieldExpr { 644impl ArrayExpr {
645 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
646 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
1180 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 647 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1181 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } 648 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
1182 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 649 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1183} 650}
1184/// Await operator call expression.
1185///
1186/// ```
1187/// ❰ expr.await ❱;
1188/// ```
1189///
1190/// [Reference](https://doc.rust-lang.org/reference/expressions/await-expr.html)
1191#[derive(Debug, Clone, PartialEq, Eq, Hash)] 651#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1192pub struct AwaitExpr { 652pub struct AwaitExpr {
1193 pub(crate) syntax: SyntaxNode, 653 pub(crate) syntax: SyntaxNode,
@@ -1198,1579 +658,739 @@ impl AwaitExpr {
1198 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } 658 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1199 pub fn await_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![await]) } 659 pub fn await_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![await]) }
1200} 660}
1201/// The question mark operator call.
1202///
1203/// ```
1204/// ❰ expr? ❱;
1205/// ```
1206///
1207/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#the-question-mark-operator)
1208#[derive(Debug, Clone, PartialEq, Eq, Hash)] 661#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1209pub struct TryExpr { 662pub struct BinExpr {
1210 pub(crate) syntax: SyntaxNode, 663 pub(crate) syntax: SyntaxNode,
1211} 664}
1212impl ast::AttrsOwner for TryExpr {} 665impl ast::AttrsOwner for BinExpr {}
1213impl TryExpr { 666impl BinExpr {}
1214 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1215 pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) }
1216}
1217/// Type cast expression.
1218///
1219/// ```
1220/// ❰ expr as T ❱;
1221/// ```
1222///
1223/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions)
1224#[derive(Debug, Clone, PartialEq, Eq, Hash)] 667#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1225pub struct CastExpr { 668pub struct BoxExpr {
1226 pub(crate) syntax: SyntaxNode, 669 pub(crate) syntax: SyntaxNode,
1227} 670}
1228impl ast::AttrsOwner for CastExpr {} 671impl ast::AttrsOwner for BoxExpr {}
1229impl CastExpr { 672impl BoxExpr {
673 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1230 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 674 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1231 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } 675}
1232 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1233}
1234/// Borrow operator call.
1235///
1236/// ```
1237/// ❰ &foo ❱;
1238/// ❰ &mut bar ❱;
1239/// ❰ &raw const bar ❱;
1240/// ❰ &raw mut bar ❱;
1241/// ```
1242///
1243/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#borrow-operators)
1244#[derive(Debug, Clone, PartialEq, Eq, Hash)] 676#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1245pub struct RefExpr { 677pub struct BreakExpr {
1246 pub(crate) syntax: SyntaxNode, 678 pub(crate) syntax: SyntaxNode,
1247} 679}
1248impl ast::AttrsOwner for RefExpr {} 680impl ast::AttrsOwner for BreakExpr {}
1249impl RefExpr { 681impl BreakExpr {
1250 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } 682 pub fn break_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![break]) }
1251 pub fn raw_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![raw]) } 683 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1252 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 684 support::token(&self.syntax, T![lifetime])
1253 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 685 }
1254 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 686 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1255} 687}
1256/// Prefix operator call. This is either `!` or `*` or `-`.
1257///
1258/// ```
1259/// ❰ !foo ❱;
1260/// ❰ *bar ❱;
1261/// ❰ -42 ❱;
1262/// ```
1263///
1264/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html)
1265#[derive(Debug, Clone, PartialEq, Eq, Hash)] 688#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1266pub struct PrefixExpr { 689pub struct CallExpr {
1267 pub(crate) syntax: SyntaxNode, 690 pub(crate) syntax: SyntaxNode,
1268} 691}
1269impl ast::AttrsOwner for PrefixExpr {} 692impl ast::AttrsOwner for CallExpr {}
1270impl PrefixExpr { 693impl ast::ArgListOwner for CallExpr {}
694impl CallExpr {
1271 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 695 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1272} 696}
1273/// Box operator call.
1274///
1275/// ```
1276/// ❰ box 42 ❱;
1277/// ```
1278///
1279/// [RFC](https://github.com/rust-lang/rfcs/blob/0806be4f282144cfcd55b1d20284b43f87cbe1c6/text/0809-box-and-in-for-stdlib.md)
1280#[derive(Debug, Clone, PartialEq, Eq, Hash)] 697#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1281pub struct BoxExpr { 698pub struct CastExpr {
1282 pub(crate) syntax: SyntaxNode, 699 pub(crate) syntax: SyntaxNode,
1283} 700}
1284impl ast::AttrsOwner for BoxExpr {} 701impl ast::AttrsOwner for CastExpr {}
1285impl BoxExpr { 702impl CastExpr {
1286 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1287 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 703 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
704 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
705 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
1288} 706}
1289/// Range operator call.
1290///
1291/// ```
1292/// ❰ 0..42 ❱;
1293/// ❰ ..42 ❱;
1294/// ❰ 0.. ❱;
1295/// ❰ .. ❱;
1296/// ❰ 0..=42 ❱;
1297/// ❰ ..=42 ❱;
1298/// ```
1299///
1300/// [Reference](https://doc.rust-lang.org/reference/expressions/range-expr.html)
1301#[derive(Debug, Clone, PartialEq, Eq, Hash)] 707#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1302pub struct RangeExpr { 708pub struct ClosureExpr {
1303 pub(crate) syntax: SyntaxNode, 709 pub(crate) syntax: SyntaxNode,
1304} 710}
1305impl ast::AttrsOwner for RangeExpr {} 711impl ast::AttrsOwner for ClosureExpr {}
1306impl RangeExpr {} 712impl ClosureExpr {
1307/// Binary operator call. 713 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
1308/// Includes all arithmetic, logic, bitwise and assignment operators. 714 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
1309/// 715 pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) }
1310/// ``` 716 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
1311/// ❰ 2 + ❰ 2 * 2 ❱ ❱; 717 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
1312/// ❰ ❰ true && false ❱ || true ❱; 718 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
1313/// ```
1314///
1315/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators)
1316#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1317pub struct BinExpr {
1318 pub(crate) syntax: SyntaxNode,
1319} 719}
1320impl ast::AttrsOwner for BinExpr {}
1321impl BinExpr {}
1322/// [Raw] string, [raw] byte string, char, byte, integer, float or bool literal.
1323///
1324/// ```
1325/// ❰ "str" ❱;
1326/// ❰ br##"raw byte str"## ❱;
1327/// ❰ 'c' ❱;
1328/// ❰ b'c' ❱;
1329/// ❰ 42 ❱;
1330/// ❰ 1e9 ❱;
1331/// ❰ true ❱;
1332/// ```
1333///
1334/// [Reference](https://doc.rust-lang.org/reference/expressions/literal-expr.html)
1335#[derive(Debug, Clone, PartialEq, Eq, Hash)] 720#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1336pub struct Literal { 721pub struct ContinueExpr {
1337 pub(crate) syntax: SyntaxNode, 722 pub(crate) syntax: SyntaxNode,
1338} 723}
1339impl Literal {} 724impl ast::AttrsOwner for ContinueExpr {}
1340/// Match expression. 725impl ContinueExpr {
1341/// 726 pub fn continue_token(&self) -> Option<SyntaxToken> {
1342/// ``` 727 support::token(&self.syntax, T![continue])
1343/// ❰ 728 }
1344/// match expr { 729 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1345/// Pat1 => {} 730 support::token(&self.syntax, T![lifetime])
1346/// Pat2(_) => 42, 731 }
1347/// } 732}
1348/// ❱
1349/// ```
1350///
1351/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1352#[derive(Debug, Clone, PartialEq, Eq, Hash)] 733#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1353pub struct MatchExpr { 734pub struct EffectExpr {
1354 pub(crate) syntax: SyntaxNode, 735 pub(crate) syntax: SyntaxNode,
1355} 736}
1356impl ast::AttrsOwner for MatchExpr {} 737impl ast::AttrsOwner for EffectExpr {}
1357impl MatchExpr { 738impl EffectExpr {
1358 pub fn match_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![match]) } 739 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
1359 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 740 pub fn try_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![try]) }
1360 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) } 741 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
742 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
743 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
1361} 744}
1362/// Match arm list part of match expression. Includes its inner attributes.
1363///
1364/// ```
1365/// match expr
1366/// ❰
1367/// {
1368/// #![inner_attr]
1369/// Pat1 => {}
1370/// Pat2(_) => 42,
1371/// }
1372/// ❱
1373/// ```
1374///
1375/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1376#[derive(Debug, Clone, PartialEq, Eq, Hash)] 745#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1377pub struct MatchArmList { 746pub struct FieldExpr {
1378 pub(crate) syntax: SyntaxNode, 747 pub(crate) syntax: SyntaxNode,
1379} 748}
1380impl ast::AttrsOwner for MatchArmList {} 749impl ast::AttrsOwner for FieldExpr {}
1381impl MatchArmList { 750impl FieldExpr {
1382 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 751 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1383 pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) } 752 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1384 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 753 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1385} 754}
1386/// Match arm.
1387/// Note: record struct literals are not valid as target match expression
1388/// due to ambiguity.
1389/// ```
1390/// match expr {
1391/// ❰ #[attr] Pattern(it) if bool_cond => it ❱,
1392/// }
1393/// ```
1394///
1395/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1396#[derive(Debug, Clone, PartialEq, Eq, Hash)] 755#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1397pub struct MatchArm { 756pub struct ForExpr {
1398 pub(crate) syntax: SyntaxNode, 757 pub(crate) syntax: SyntaxNode,
1399} 758}
1400impl ast::AttrsOwner for MatchArm {} 759impl ast::AttrsOwner for ForExpr {}
1401impl MatchArm { 760impl ast::LoopBodyOwner for ForExpr {}
761impl ForExpr {
762 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
1402 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 763 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1403 pub fn guard(&self) -> Option<MatchGuard> { support::child(&self.syntax) } 764 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
1404 pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=>]) } 765 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) }
1405 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1406} 766}
1407/// Match guard.
1408///
1409/// ```
1410/// match expr {
1411/// Pattern(it) ❰ if bool_cond ❱ => it,
1412/// }
1413/// ```
1414///
1415/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html#match-guards)
1416#[derive(Debug, Clone, PartialEq, Eq, Hash)] 767#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1417pub struct MatchGuard { 768pub struct IfExpr {
1418 pub(crate) syntax: SyntaxNode, 769 pub(crate) syntax: SyntaxNode,
1419} 770}
1420impl MatchGuard { 771impl ast::AttrsOwner for IfExpr {}
772impl IfExpr {
1421 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) } 773 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
1422 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 774 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
775 pub fn else_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![else]) }
1423} 776}
1424/// Record literal expression. The same syntax is used for structs, 777#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1425/// unions and record enum variants. 778pub struct IndexExpr {
1426///
1427/// ```
1428/// ❰
1429/// foo::Bar {
1430/// #![inner_attr]
1431/// baz: 42,
1432/// bruh: true,
1433/// ..spread
1434/// }
1435/// ❱
1436/// ```
1437///
1438/// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1439#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1440pub struct RecordLit {
1441 pub(crate) syntax: SyntaxNode, 779 pub(crate) syntax: SyntaxNode,
1442} 780}
1443impl RecordLit { 781impl ast::AttrsOwner for IndexExpr {}
1444 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 782impl IndexExpr {
1445 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } 783 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
784 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1446} 785}
1447/// Record field list including enclosing curly braces.
1448///
1449/// foo::Bar ❰
1450/// {
1451/// baz: 42,
1452/// ..spread
1453/// }
1454/// ❱
1455///
1456/// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1457#[derive(Debug, Clone, PartialEq, Eq, Hash)] 786#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1458pub struct RecordFieldList { 787pub struct LoopExpr {
1459 pub(crate) syntax: SyntaxNode, 788 pub(crate) syntax: SyntaxNode,
1460} 789}
1461impl RecordFieldList { 790impl ast::AttrsOwner for LoopExpr {}
1462 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 791impl ast::LoopBodyOwner for LoopExpr {}
1463 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) } 792impl LoopExpr {
1464 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } 793 pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) }
1465 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) }
1466 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1467} 794}
1468/// Record field.
1469///
1470/// ```
1471/// foo::Bar {
1472/// ❰ #[attr] baz: 42 ❱
1473/// }
1474/// ```
1475///
1476/// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1477#[derive(Debug, Clone, PartialEq, Eq, Hash)] 795#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1478pub struct RecordField { 796pub struct MatchExpr {
1479 pub(crate) syntax: SyntaxNode, 797 pub(crate) syntax: SyntaxNode,
1480} 798}
1481impl ast::AttrsOwner for RecordField {} 799impl ast::AttrsOwner for MatchExpr {}
1482impl RecordField { 800impl MatchExpr {
1483 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 801 pub fn match_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![match]) }
1484 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1485 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 802 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
803 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) }
1486} 804}
1487/// Disjunction of patterns.
1488///
1489/// ```
1490/// let ❰ Foo(it) | Bar(it) | Baz(it) ❱ = bruh;
1491/// ```
1492///
1493/// [Reference](https://doc.rust-lang.org/reference/patterns.html)
1494#[derive(Debug, Clone, PartialEq, Eq, Hash)] 805#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1495pub struct OrPat { 806pub struct MethodCallExpr {
1496 pub(crate) syntax: SyntaxNode, 807 pub(crate) syntax: SyntaxNode,
1497} 808}
1498impl OrPat { 809impl ast::AttrsOwner for MethodCallExpr {}
1499 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 810impl ast::ArgListOwner for MethodCallExpr {}
811impl MethodCallExpr {
812 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
813 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
814 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
815 pub fn generic_arg_list(&self) -> Option<GenericArgList> { support::child(&self.syntax) }
1500} 816}
1501/// Parenthesized pattern.
1502/// Note: parens are only used for grouping, this is not a tuple pattern.
1503///
1504/// ```
1505/// if let ❰ &(0..=42) ❱ = foo {}
1506/// ```
1507///
1508/// https://doc.rust-lang.org/reference/patterns.html#grouped-patterns
1509#[derive(Debug, Clone, PartialEq, Eq, Hash)] 817#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1510pub struct ParenPat { 818pub struct ParenExpr {
1511 pub(crate) syntax: SyntaxNode, 819 pub(crate) syntax: SyntaxNode,
1512} 820}
1513impl ParenPat { 821impl ast::AttrsOwner for ParenExpr {}
822impl ParenExpr {
1514 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 823 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1515 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 824 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1516 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 825 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1517} 826}
1518/// Reference pattern.
1519/// Note: this has nothing to do with `ref` keyword, the latter is used in bind patterns.
1520///
1521/// ```
1522/// let ❰ &mut foo ❱ = bar;
1523///
1524/// let ❰ & ❰ &mut ❰ &_ ❱ ❱ ❱ = baz;
1525/// ```
1526///
1527/// [Reference](https://doc.rust-lang.org/reference/patterns.html#reference-patterns)
1528#[derive(Debug, Clone, PartialEq, Eq, Hash)] 827#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1529pub struct RefPat { 828pub struct PathExpr {
1530 pub(crate) syntax: SyntaxNode, 829 pub(crate) syntax: SyntaxNode,
1531} 830}
1532impl RefPat { 831impl ast::AttrsOwner for PathExpr {}
1533 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } 832impl PathExpr {
1534 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 833 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1535 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1536} 834}
1537/// Box pattern.
1538///
1539/// ```
1540/// let ❰ box foo ❱ = box 42;
1541/// ```
1542///
1543/// [Unstable book](https://doc.rust-lang.org/unstable-book/language-features/box-patterns.html)
1544#[derive(Debug, Clone, PartialEq, Eq, Hash)] 835#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1545pub struct BoxPat { 836pub struct PrefixExpr {
1546 pub(crate) syntax: SyntaxNode,
1547}
1548impl BoxPat {
1549 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1550 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1551}
1552/// Bind pattern.
1553///
1554/// ```
1555/// match foo {
1556/// Some(❰ ref mut bar ❱) => {}
1557/// ❰ baz @ None ❱ => {}
1558/// }
1559/// ```
1560///
1561/// [Reference](https://doc.rust-lang.org/reference/patterns.html#identifier-patterns)
1562#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1563pub struct BindPat {
1564 pub(crate) syntax: SyntaxNode, 837 pub(crate) syntax: SyntaxNode,
1565} 838}
1566impl ast::AttrsOwner for BindPat {} 839impl ast::AttrsOwner for PrefixExpr {}
1567impl ast::NameOwner for BindPat {} 840impl PrefixExpr {
1568impl BindPat { 841 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1569 pub fn ref_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ref]) }
1570 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1571 pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) }
1572 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1573} 842}
1574/// Placeholder pattern a.k.a. the wildcard pattern or the underscore.
1575///
1576/// ```
1577/// let ❰ _ ❱ = foo;
1578/// ```
1579///
1580/// [Reference](https://doc.rust-lang.org/reference/patterns.html#wildcard-pattern)
1581#[derive(Debug, Clone, PartialEq, Eq, Hash)] 843#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1582pub struct PlaceholderPat { 844pub struct RangeExpr {
1583 pub(crate) syntax: SyntaxNode, 845 pub(crate) syntax: SyntaxNode,
1584} 846}
1585impl PlaceholderPat { 847impl ast::AttrsOwner for RangeExpr {}
1586 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } 848impl RangeExpr {}
1587} 849#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1588/// Rest-of-the record/tuple pattern. 850pub struct RecordExpr {
1589/// Note: this is not the unbonded range pattern (even more: it doesn't exist).
1590///
1591/// ```
1592/// let Foo { bar, ❰ .. ❱ } = baz;
1593/// let (❰ .. ❱, bruh) = (42, 24, 42);
1594/// let Bruuh(❰ .. ❱) = bruuuh;
1595/// ```
1596///
1597/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1598#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1599pub struct DotDotPat {
1600 pub(crate) syntax: SyntaxNode, 851 pub(crate) syntax: SyntaxNode,
1601} 852}
1602impl DotDotPat { 853impl RecordExpr {
1603 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } 854 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
855 pub fn record_expr_field_list(&self) -> Option<RecordExprFieldList> {
856 support::child(&self.syntax)
857 }
1604} 858}
1605/// Path pattern.
1606/// Doesn't include the underscore pattern (it is a special case, namely `PlaceholderPat`).
1607///
1608/// ```
1609/// let ❰ foo::bar::Baz ❱ { .. } = bruh;
1610/// if let ❰ CONST ❱ = 42 {}
1611/// ```
1612///
1613/// [Reference](https://doc.rust-lang.org/reference/patterns.html#path-patterns)
1614#[derive(Debug, Clone, PartialEq, Eq, Hash)] 859#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1615pub struct PathPat { 860pub struct RefExpr {
1616 pub(crate) syntax: SyntaxNode, 861 pub(crate) syntax: SyntaxNode,
1617} 862}
1618impl PathPat { 863impl ast::AttrsOwner for RefExpr {}
1619 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 864impl RefExpr {
865 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
866 pub fn raw_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![raw]) }
867 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
868 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
869 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1620} 870}
1621/// Slice pattern.
1622///
1623/// ```
1624/// let ❰ [foo, bar, baz] ❱ = [1, 2, 3];
1625/// ```
1626///
1627/// [Reference](https://doc.rust-lang.org/reference/patterns.html#slice-patterns)
1628#[derive(Debug, Clone, PartialEq, Eq, Hash)] 871#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1629pub struct SlicePat { 872pub struct ReturnExpr {
1630 pub(crate) syntax: SyntaxNode, 873 pub(crate) syntax: SyntaxNode,
1631} 874}
1632impl SlicePat { 875impl ast::AttrsOwner for ReturnExpr {}
1633 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 876impl ReturnExpr {
1634 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 877 pub fn return_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![return]) }
1635 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 878 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1636} 879}
1637/// Range pattern.
1638///
1639/// ```
1640/// match foo {
1641/// ❰ 0..42 ❱ => {}
1642/// ❰ 0..=42 ❱ => {}
1643/// }
1644/// ```
1645///
1646/// [Reference](https://doc.rust-lang.org/reference/patterns.html#range-patterns)
1647#[derive(Debug, Clone, PartialEq, Eq, Hash)] 880#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1648pub struct RangePat { 881pub struct TryExpr {
1649 pub(crate) syntax: SyntaxNode, 882 pub(crate) syntax: SyntaxNode,
1650} 883}
1651impl RangePat {} 884impl ast::AttrsOwner for TryExpr {}
1652/// Literal pattern. 885impl TryExpr {
1653/// Includes only bool, number, char, and string literals. 886 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1654/// 887 pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) }
1655/// ``` 888}
1656/// match foo {
1657/// Number(❰ 42 ❱) => {}
1658/// String(❰ "42" ❱) => {}
1659/// Bool(❰ true ❱) => {}
1660/// }
1661/// ```
1662///
1663/// [Reference](https://doc.rust-lang.org/reference/patterns.html#literal-patterns)
1664#[derive(Debug, Clone, PartialEq, Eq, Hash)] 889#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1665pub struct LiteralPat { 890pub struct TupleExpr {
1666 pub(crate) syntax: SyntaxNode, 891 pub(crate) syntax: SyntaxNode,
1667} 892}
1668impl LiteralPat { 893impl ast::AttrsOwner for TupleExpr {}
1669 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } 894impl TupleExpr {
895 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
896 pub fn fields(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
897 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1670} 898}
1671/// Macro invocation in pattern position.
1672///
1673/// ```
1674/// let ❰ foo!(my custom syntax) ❱ = baz;
1675///
1676/// ```
1677/// [Reference](https://doc.rust-lang.org/reference/macros.html#macro-invocation)
1678#[derive(Debug, Clone, PartialEq, Eq, Hash)] 899#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1679pub struct MacroPat { 900pub struct WhileExpr {
1680 pub(crate) syntax: SyntaxNode, 901 pub(crate) syntax: SyntaxNode,
1681} 902}
1682impl MacroPat { 903impl ast::AttrsOwner for WhileExpr {}
1683 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) } 904impl ast::LoopBodyOwner for WhileExpr {}
905impl WhileExpr {
906 pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) }
907 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
1684} 908}
1685/// Record literal pattern.
1686///
1687/// ```
1688/// let ❰ foo::Bar { baz, .. } ❱ = bruh;
1689/// ```
1690///
1691/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1692#[derive(Debug, Clone, PartialEq, Eq, Hash)] 909#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1693pub struct RecordPat { 910pub struct Label {
1694 pub(crate) syntax: SyntaxNode, 911 pub(crate) syntax: SyntaxNode,
1695} 912}
1696impl RecordPat { 913impl Label {
1697 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> { 914 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1698 support::child(&self.syntax) 915 support::token(&self.syntax, T![lifetime])
1699 } 916 }
1700 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1701} 917}
1702/// Record literal's field patterns list including enclosing curly braces.
1703///
1704/// ```
1705/// let foo::Bar ❰ { baz, bind @ bruh, .. } ❱ = bruuh;
1706/// ``
1707///
1708/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1709#[derive(Debug, Clone, PartialEq, Eq, Hash)] 918#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1710pub struct RecordFieldPatList { 919pub struct RecordExprFieldList {
1711 pub(crate) syntax: SyntaxNode, 920 pub(crate) syntax: SyntaxNode,
1712} 921}
1713impl RecordFieldPatList { 922impl ast::AttrsOwner for RecordExprFieldList {}
923impl RecordExprFieldList {
1714 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 924 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1715 pub fn pats(&self) -> AstChildren<RecordInnerPat> { support::children(&self.syntax) } 925 pub fn fields(&self) -> AstChildren<RecordExprField> { support::children(&self.syntax) }
1716 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
1717 support::children(&self.syntax)
1718 }
1719 pub fn bind_pats(&self) -> AstChildren<BindPat> { support::children(&self.syntax) }
1720 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } 926 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
927 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) }
1721 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 928 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1722} 929}
1723/// Record literal's field pattern. 930#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1724/// Note: record literal can also match tuple structs. 931pub struct RecordExprField {
1725///
1726/// ```
1727/// let Foo { ❰ bar: _ ❱ } = baz;
1728/// let TupleStruct { ❰ 0: _ ❱ } = bruh;
1729/// ```
1730///
1731/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1732#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1733pub struct RecordFieldPat {
1734 pub(crate) syntax: SyntaxNode, 932 pub(crate) syntax: SyntaxNode,
1735} 933}
1736impl ast::AttrsOwner for RecordFieldPat {} 934impl ast::AttrsOwner for RecordExprField {}
1737impl RecordFieldPat { 935impl RecordExprField {
1738 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 936 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1739 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 937 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1740 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 938 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1741} 939}
1742/// Tuple struct literal pattern.
1743///
1744/// ```
1745/// let ❰ foo::Bar(baz, bruh) ❱ = bruuh;
1746/// ```
1747///
1748/// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-struct-patterns)
1749#[derive(Debug, Clone, PartialEq, Eq, Hash)] 940#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1750pub struct TupleStructPat { 941pub struct ArgList {
1751 pub(crate) syntax: SyntaxNode, 942 pub(crate) syntax: SyntaxNode,
1752} 943}
1753impl TupleStructPat { 944impl ArgList {
1754 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1755 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 945 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1756 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 946 pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
1757 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 947 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1758} 948}
1759/// Tuple pattern.
1760/// Note: this doesn't include tuple structs (see `TupleStructPat`)
1761///
1762/// ```
1763/// let ❰ (foo, bar, .., baz) ❱ = bruh;
1764/// ```
1765///
1766/// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-patterns)
1767#[derive(Debug, Clone, PartialEq, Eq, Hash)] 949#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1768pub struct TuplePat { 950pub struct Condition {
1769 pub(crate) syntax: SyntaxNode, 951 pub(crate) syntax: SyntaxNode,
1770} 952}
1771impl TuplePat { 953impl Condition {
1772 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 954 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
1773 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 955 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1774 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 956 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
957 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1775} 958}
1776/// Visibility.
1777///
1778/// ```
1779/// ❰ pub mod ❱ foo;
1780/// ❰ pub(crate) ❱ struct Bar;
1781/// ❰ pub(self) ❱ enum Baz {}
1782/// ❰ pub(super) ❱ fn bruh() {}
1783/// ❰ pub(in bruuh::bruuuh) ❱ type T = u64;
1784/// ```
1785///
1786/// [Reference](https://doc.rust-lang.org/reference/visibility-and-privacy.html)
1787#[derive(Debug, Clone, PartialEq, Eq, Hash)] 959#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1788pub struct Visibility { 960pub struct MatchArmList {
1789 pub(crate) syntax: SyntaxNode, 961 pub(crate) syntax: SyntaxNode,
1790} 962}
1791impl Visibility { 963impl ast::AttrsOwner for MatchArmList {}
1792 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) } 964impl MatchArmList {
1793 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) } 965 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1794 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } 966 pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) }
1795 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } 967 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1796} 968}
1797/// Single identifier.
1798/// Note(@matklad): `Name` is for things that install a new name into the scope,
1799/// `NameRef` is a usage of a name. Most of the time, this definition/reference
1800/// distinction can be determined purely syntactically, ie in
1801/// ```
1802/// fn foo() { foo() }
1803/// ```
1804/// the first foo is `Name`, the second one is `NameRef`.
1805/// The notable exception are patterns, where in
1806/// ``
1807/// let x = 92
1808/// ```
1809/// `x` can be semantically either a name or a name ref, depeding on
1810/// wether there's an `x` constant in scope.
1811/// We use `Name` for patterns, and disambiguate semantically (see `NameClass` in ide_db).
1812///
1813/// ```
1814/// let ❰ foo ❱ = bar;
1815/// struct ❰ Baz ❱;
1816/// fn ❰ bruh ❱() {}
1817/// ```
1818///
1819/// [Reference](https://doc.rust-lang.org/reference/identifiers.html)
1820#[derive(Debug, Clone, PartialEq, Eq, Hash)] 969#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1821pub struct Name { 970pub struct MatchArm {
1822 pub(crate) syntax: SyntaxNode, 971 pub(crate) syntax: SyntaxNode,
1823} 972}
1824impl Name { 973impl ast::AttrsOwner for MatchArm {}
1825 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } 974impl MatchArm {
1826} 975 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1827/// Reference to a name. 976 pub fn guard(&self) -> Option<MatchGuard> { support::child(&self.syntax) }
1828/// See the explanation on the difference between `Name` and `NameRef` 977 pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=>]) }
1829/// in `Name` ast node docs. 978 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1830/// 979 pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }
1831/// ```
1832/// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱;
1833/// ```
1834///
1835/// [Reference](https://doc.rust-lang.org/reference/identifiers.html)
1836#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1837pub struct NameRef {
1838 pub(crate) syntax: SyntaxNode,
1839} 980}
1840impl NameRef {}
1841/// Macro call.
1842/// Includes all of its attributes and doc comments.
1843///
1844/// ```
1845/// ❰
1846/// /// Docs
1847/// #[attr]
1848/// macro_rules! foo { // macro rules is also a macro call
1849/// ($bar: tt) => {}
1850/// }
1851/// ❱
1852///
1853/// // semicolon is a part of `MacroCall` when it is used in item positions
1854/// ❰ foo!(); ❱
1855///
1856/// fn main() {
1857/// ❰ foo!() ❱; // macro call in expression positions doesn't include the semi
1858/// }
1859/// ```
1860///
1861/// [Reference](https://doc.rust-lang.org/reference/macros.html)
1862#[derive(Debug, Clone, PartialEq, Eq, Hash)] 981#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1863pub struct MacroCall { 982pub struct MatchGuard {
1864 pub(crate) syntax: SyntaxNode, 983 pub(crate) syntax: SyntaxNode,
1865} 984}
1866impl ast::NameOwner for MacroCall {} 985impl MatchGuard {
1867impl ast::AttrsOwner for MacroCall {} 986 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
1868impl ast::DocCommentsOwner for MacroCall {} 987 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1869impl MacroCall {
1870 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1871 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
1872 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
1873 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
1874} 988}
1875/// Attribute.
1876///
1877/// ```
1878/// ❰ #![inner_attr] ❱
1879///
1880/// ❰ #[attr] ❱
1881/// ❰ #[foo = "bar"] ❱
1882/// ❰ #[baz(bruh::bruuh = "42")] ❱
1883/// struct Foo;
1884/// ```
1885///
1886/// [Reference](https://doc.rust-lang.org/reference/attributes.html)
1887#[derive(Debug, Clone, PartialEq, Eq, Hash)] 989#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1888pub struct Attr { 990pub struct ArrayType {
1889 pub(crate) syntax: SyntaxNode, 991 pub(crate) syntax: SyntaxNode,
1890} 992}
1891impl Attr { 993impl ArrayType {
1892 pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
1893 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
1894 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 994 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1895 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 995 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
1896 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 996 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
1897 pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) } 997 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1898 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 998 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1899} 999}
1900/// Stores a list of lexer tokens and other `TokenTree`s.
1901/// It appears in attributes, macro_rules and macro call (foo!)
1902///
1903/// ```
1904/// macro_call! ❰ { my syntax here } ❱;
1905/// ```
1906///
1907/// [Reference](https://doc.rust-lang.org/reference/macros.html)
1908#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1000#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1909pub struct TokenTree { 1001pub struct DynTraitType {
1910 pub(crate) syntax: SyntaxNode,
1911}
1912impl TokenTree {}
1913/// Generic lifetime, type and constants parameters list **declaration**.
1914///
1915/// ```
1916/// fn foo❰ <'a, 'b, T, U, const BAR: u64> ❱() {}
1917///
1918/// struct Baz❰ <T> ❱(T);
1919///
1920/// impl❰ <T> ❱ Bruh<T> {}
1921///
1922/// type Bruuh = for❰ <'a> ❱ fn(&'a str) -> &'a str;
1923/// ```
1924///
1925/// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1926#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1927pub struct TypeParamList {
1928 pub(crate) syntax: SyntaxNode, 1002 pub(crate) syntax: SyntaxNode,
1929} 1003}
1930impl TypeParamList { 1004impl DynTraitType {
1931 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } 1005 pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![dyn]) }
1932 pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) } 1006 pub fn type_bound_list(&self) -> Option<TypeBoundList> { support::child(&self.syntax) }
1933 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) }
1934 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) }
1935 pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) }
1936 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
1937} 1007}
1938/// Single type parameter **declaration**.
1939///
1940/// ```
1941/// fn foo<❰ K ❱, ❰ I ❱, ❰ E: Debug ❱, ❰ V = DefaultType ❱>() {}
1942/// ```
1943///
1944/// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1945#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1008#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1946pub struct TypeParam { 1009pub struct FnPtrType {
1947 pub(crate) syntax: SyntaxNode, 1010 pub(crate) syntax: SyntaxNode,
1948} 1011}
1949impl ast::NameOwner for TypeParam {} 1012impl FnPtrType {
1950impl ast::AttrsOwner for TypeParam {} 1013 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
1951impl ast::TypeBoundsOwner for TypeParam {} 1014 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
1952impl TypeParam { 1015 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
1953 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 1016 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
1954 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1017 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) }
1018 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
1019 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
1955} 1020}
1956/// Const generic parameter **declaration**.
1957/// ```
1958/// fn foo<T, U, ❰ const BAR: usize ❱, ❰ const BAZ: bool ❱>() {}
1959/// ```
1960///
1961/// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter)
1962#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1021#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1963pub struct ConstParam { 1022pub struct ForType {
1964 pub(crate) syntax: SyntaxNode, 1023 pub(crate) syntax: SyntaxNode,
1965} 1024}
1966impl ast::NameOwner for ConstParam {} 1025impl ForType {
1967impl ast::AttrsOwner for ConstParam {} 1026 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
1968impl ast::TypeAscriptionOwner for ConstParam {} 1027 pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) }
1969impl ConstParam { 1028 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
1970 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1971 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
1972} 1029}
1973/// Lifetime parameter **declaration**.
1974///
1975/// ```
1976/// fn foo<❰ 'a ❱, ❰ 'b ❱, V, G, D>(bar: &'a str, baz: &'b mut str) {}
1977/// ```
1978///
1979/// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1980#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1030#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1981pub struct LifetimeParam { 1031pub struct ImplTraitType {
1982 pub(crate) syntax: SyntaxNode, 1032 pub(crate) syntax: SyntaxNode,
1983} 1033}
1984impl ast::AttrsOwner for LifetimeParam {} 1034impl ImplTraitType {
1985impl LifetimeParam { 1035 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
1986 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 1036 pub fn type_bound_list(&self) -> Option<TypeBoundList> { support::child(&self.syntax) }
1987 support::token(&self.syntax, T![lifetime])
1988 }
1989}
1990/// Type bound declaration clause.
1991///
1992/// ```
1993/// fn foo<T: ❰ ?Sized ❱ + ❰ Debug ❱>() {}
1994///
1995/// trait Bar<T>
1996/// where
1997/// T: ❰ Send ❱ + ❰ Sync ❱
1998/// {
1999/// type Baz: ❰ !Sync ❱ + ❰ Debug ❱ + ❰ ?const Add ❱;
2000/// }
2001/// ```
2002///
2003/// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
2004#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2005pub struct TypeBound {
2006 pub(crate) syntax: SyntaxNode,
2007} 1037}
2008impl TypeBound {
2009 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2010 support::token(&self.syntax, T![lifetime])
2011 }
2012 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
2013 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2014}
2015/// Type bounds list.
2016///
2017/// ```
2018///
2019/// fn foo<T: ❰ ?Sized + Debug ❱>() {}
2020///
2021/// trait Bar<T>
2022/// where
2023/// T: ❰ Send + Sync ❱
2024/// {
2025/// type Baz: ❰ !Sync + Debug ❱;
2026/// }
2027/// ```
2028///
2029/// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
2030#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1038#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2031pub struct TypeBoundList { 1039pub struct InferType {
2032 pub(crate) syntax: SyntaxNode, 1040 pub(crate) syntax: SyntaxNode,
2033} 1041}
2034impl TypeBoundList { 1042impl InferType {
2035 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } 1043 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
2036} 1044}
2037/// Single where predicate.
2038///
2039/// ```
2040/// trait Foo<'a, 'b, T>
2041/// where
2042/// ❰ 'a: 'b ❱,
2043/// ❰ T: IntoIterator ❱,
2044/// ❰ for<'c> <T as IntoIterator>::Item: Bar<'c> ❱
2045/// {}
2046/// ```
2047///
2048/// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
2049#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1045#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2050pub struct WherePred { 1046pub struct NeverType {
2051 pub(crate) syntax: SyntaxNode, 1047 pub(crate) syntax: SyntaxNode,
2052} 1048}
2053impl ast::TypeBoundsOwner for WherePred {} 1049impl NeverType {
2054impl WherePred { 1050 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
2055 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
2056 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) }
2057 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2058 support::token(&self.syntax, T![lifetime])
2059 }
2060 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2061} 1051}
2062/// Where clause.
2063///
2064/// ```
2065/// trait Foo<'a, T> ❰ where 'a: 'static, T: Debug ❱ {}
2066///
2067/// ```
2068///
2069/// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
2070#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1052#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2071pub struct WhereClause { 1053pub struct ParenType {
2072 pub(crate) syntax: SyntaxNode, 1054 pub(crate) syntax: SyntaxNode,
2073} 1055}
2074impl WhereClause { 1056impl ParenType {
2075 pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) } 1057 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2076 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) } 1058 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
2077} 1059 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2078/// Abi declaration.
2079/// Note: the abi string is optional.
2080///
2081/// ```
2082/// ❰ extern "C" ❱ {
2083/// fn foo() {}
2084/// }
2085///
2086/// type Bar = ❰ extern ❱ fn() -> u32;
2087///
2088/// type Baz = ❰ extern r#"stdcall"# ❱ fn() -> bool;
2089/// ```
2090///
2091/// - [Extern blocks reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2092/// - [FFI function pointers reference](https://doc.rust-lang.org/reference/items/functions.html#functions)
2093#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2094pub struct Abi {
2095 pub(crate) syntax: SyntaxNode,
2096} 1060}
2097impl Abi {}
2098/// Expression statement.
2099///
2100/// ```
2101/// ❰ 42; ❱
2102/// ❰ foo(); ❱
2103/// ❰ (); ❱
2104/// ❰ {}; ❱
2105///
2106/// // constructions with trailing curly brace can omit the semicolon
2107/// // but only when there are satements immediately after them (this is important!)
2108/// ❰ if bool_cond { } ❱
2109/// ❰ loop {} ❱
2110/// ❰ somestatment; ❱
2111/// ```
2112///
2113/// [Reference](https://doc.rust-lang.org/reference/statements.html)
2114#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1061#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2115pub struct ExprStmt { 1062pub struct PtrType {
2116 pub(crate) syntax: SyntaxNode, 1063 pub(crate) syntax: SyntaxNode,
2117} 1064}
2118impl ast::AttrsOwner for ExprStmt {} 1065impl PtrType {
2119impl ExprStmt { 1066 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
2120 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1067 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
2121 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 1068 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1069 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
2122} 1070}
2123/// Let statement.
2124///
2125/// ```
2126/// ❰ #[attr] let foo; ❱
2127/// ❰ let bar: u64; ❱
2128/// ❰ let baz = 42; ❱
2129/// ❰ let bruh: bool = true; ❱
2130/// ```
2131///
2132/// [Reference](https://doc.rust-lang.org/reference/statements.html#let-statements)
2133#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1071#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2134pub struct LetStmt { 1072pub struct RefType {
2135 pub(crate) syntax: SyntaxNode, 1073 pub(crate) syntax: SyntaxNode,
2136} 1074}
2137impl ast::AttrsOwner for LetStmt {} 1075impl RefType {
2138impl ast::TypeAscriptionOwner for LetStmt {} 1076 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
2139impl LetStmt { 1077 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2140 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) } 1078 support::token(&self.syntax, T![lifetime])
2141 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1079 }
2142 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 1080 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
2143 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } 1081 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
2144 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2145} 1082}
2146/// Condition of `if` or `while` expression.
2147///
2148/// ```
2149/// if ❰ true ❱ {}
2150/// if ❰ let Pat(foo) = bar ❱ {}
2151///
2152/// while ❰ true ❱ {}
2153/// while ❰ let Pat(baz) = bruh ❱ {}
2154/// ```
2155///
2156/// [If expression reference](https://doc.rust-lang.org/reference/expressions/if-expr.html)
2157/// [While expression reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops)
2158#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1083#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2159pub struct Condition { 1084pub struct SliceType {
2160 pub(crate) syntax: SyntaxNode, 1085 pub(crate) syntax: SyntaxNode,
2161} 1086}
2162impl Condition { 1087impl SliceType {
2163 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) } 1088 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
2164 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1089 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
2165 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 1090 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
2166 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2167} 1091}
2168/// Parameter list **declaration**.
2169///
2170/// ```
2171/// fn foo❰ (a: u32, b: bool) ❱ -> u32 {}
2172/// let bar = ❰ |a, b| ❱ {};
2173///
2174/// impl Baz {
2175/// fn bruh❰ (&self, a: u32) ❱ {}
2176/// }
2177/// ```
2178///
2179/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)ocs to codegen script
2180#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1092#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2181pub struct ParamList { 1093pub struct TupleType {
2182 pub(crate) syntax: SyntaxNode, 1094 pub(crate) syntax: SyntaxNode,
2183} 1095}
2184impl ParamList { 1096impl TupleType {
2185 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 1097 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2186 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) } 1098 pub fn fields(&self) -> AstChildren<Type> { support::children(&self.syntax) }
2187 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
2188 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1099 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2189} 1100}
2190/// Self parameter **declaration**.
2191///
2192/// ```
2193/// impl Bruh {
2194/// fn foo(❰ self ❱) {}
2195/// fn bar(❰ &self ❱) {}
2196/// fn baz(❰ &mut self ❱) {}
2197/// fn blah<'a>(❰ &'a self ❱) {}
2198/// fn blin(❰ self: Box<Self> ❱) {}
2199/// }
2200/// ```
2201///
2202/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
2203#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1101#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2204pub struct SelfParam { 1102pub struct TypeBound {
2205 pub(crate) syntax: SyntaxNode, 1103 pub(crate) syntax: SyntaxNode,
2206} 1104}
2207impl ast::TypeAscriptionOwner for SelfParam {} 1105impl TypeBound {
2208impl ast::AttrsOwner for SelfParam {}
2209impl SelfParam {
2210 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
2211 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
2212 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 1106 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2213 support::token(&self.syntax, T![lifetime]) 1107 support::token(&self.syntax, T![lifetime])
2214 } 1108 }
2215 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } 1109 pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) }
1110 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
2216} 1111}
2217/// Parameter **declaration**.
2218///
2219/// ```
2220/// fn foo(❰ #[attr] Pat(bar): Pat(u32) ❱, ❰ #[attr] _: bool ❱) {}
2221///
2222/// extern "C" {
2223/// fn bar(❰ baz: u32 ❱, ❰ ... ❱) -> u32;
2224/// }
2225/// ```
2226///
2227/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
2228#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1112#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2229pub struct Param { 1113pub struct IdentPat {
2230 pub(crate) syntax: SyntaxNode, 1114 pub(crate) syntax: SyntaxNode,
2231} 1115}
2232impl ast::TypeAscriptionOwner for Param {} 1116impl ast::AttrsOwner for IdentPat {}
2233impl ast::AttrsOwner for Param {} 1117impl ast::NameOwner for IdentPat {}
2234impl Param { 1118impl IdentPat {
1119 pub fn ref_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ref]) }
1120 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1121 pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) }
2235 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1122 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2236 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
2237} 1123}
2238/// Use declaration. 1124#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2239/// 1125pub struct BoxPat {
2240/// ```
2241/// ❰ #[attr] pub use foo; ❱
2242/// ❰ use bar as baz; ❱
2243/// ❰ use bruh::{self, bruuh}; ❱
2244/// ❰ use { blin::blen, blah::* };
2245/// ```
2246///
2247/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2249pub struct UseItem {
2250 pub(crate) syntax: SyntaxNode, 1126 pub(crate) syntax: SyntaxNode,
2251} 1127}
2252impl ast::AttrsOwner for UseItem {} 1128impl BoxPat {
2253impl ast::VisibilityOwner for UseItem {} 1129 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
2254impl UseItem { 1130 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2255 pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
2256 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
2257} 1131}
2258/// Use tree.
2259///
2260/// ```
2261/// pub use ❰ foo::❰ * ❱ ❱;
2262/// use ❰ bar as baz ❱;
2263/// use ❰ bruh::bruuh::{ ❰ self ❱, ❰ blin ❱ } ❱;
2264/// use ❰ { ❰ blin::blen ❱ } ❱
2265/// ```
2266///
2267/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2268#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1132#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2269pub struct UseTree { 1133pub struct RestPat {
2270 pub(crate) syntax: SyntaxNode, 1134 pub(crate) syntax: SyntaxNode,
2271} 1135}
2272impl UseTree { 1136impl RestPat {
2273 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1137 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
2274 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) } 1138}
2275 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) } 1139#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2276 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } 1140pub struct LiteralPat {
2277}
2278/// Item alias.
2279/// Note: this is not the type alias.
2280///
2281/// ```
2282/// use foo ❰ as bar ❱;
2283/// use baz::{bruh ❰ as _ ❱};
2284/// extern crate bruuh ❰ as blin ❱;
2285/// ```
2286///
2287/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2288#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2289pub struct Alias {
2290 pub(crate) syntax: SyntaxNode, 1141 pub(crate) syntax: SyntaxNode,
2291} 1142}
2292impl ast::NameOwner for Alias {} 1143impl LiteralPat {
2293impl Alias { 1144 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
2294 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
2295} 1145}
2296/// Sublist of use trees.
2297///
2298/// ```
2299/// use bruh::bruuh::❰ { ❰ self ❱, ❰ blin ❱ } ❱;
2300/// use ❰ { blin::blen::❰ {} ❱ } ❱
2301/// ```
2302///
2303/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2304#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1146#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2305pub struct UseTreeList { 1147pub struct MacroPat {
2306 pub(crate) syntax: SyntaxNode, 1148 pub(crate) syntax: SyntaxNode,
2307} 1149}
2308impl UseTreeList { 1150impl MacroPat {
2309 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 1151 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) }
2310 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) }
2311 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2312} 1152}
2313/// Extern crate item.
2314///
2315/// ```
2316/// ❰ #[attr] pub extern crate foo; ❱
2317/// ❰ extern crate self as bar; ❱
2318/// ```
2319///
2320/// [Reference](https://doc.rust-lang.org/reference/items/extern-crates.html)
2321#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1153#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2322pub struct ExternCrateItem { 1154pub struct OrPat {
2323 pub(crate) syntax: SyntaxNode, 1155 pub(crate) syntax: SyntaxNode,
2324} 1156}
2325impl ast::AttrsOwner for ExternCrateItem {} 1157impl OrPat {
2326impl ast::VisibilityOwner for ExternCrateItem {} 1158 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
2327impl ExternCrateItem {
2328 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
2329 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
2330 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2331 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2332} 1159}
2333/// Call site arguments list.
2334///
2335/// ```
2336/// foo::<T, U>❰ (42, true) ❱;
2337/// ```
2338///
2339/// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html)
2340#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1160#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2341pub struct ArgList { 1161pub struct ParenPat {
2342 pub(crate) syntax: SyntaxNode, 1162 pub(crate) syntax: SyntaxNode,
2343} 1163}
2344impl ArgList { 1164impl ParenPat {
2345 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 1165 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2346 pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) } 1166 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2347 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1167 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2348} 1168}
2349/// Path to a symbol. Includes single identifier names and elaborate paths with
2350/// generic parameters.
2351///
2352/// ```
2353/// (0..10).❰ ❰ collect ❱ ::<Vec<_>> ❱();
2354/// ❰ ❰ ❰ Vec ❱ ::<u8> ❱ ::with_capacity ❱(1024);
2355/// ❰ ❰ <❰ Foo ❱ as ❰ ❰ bar ❱ ::Bar ❱> ❱ ::baz ❱();
2356/// ❰ ❰ <❰ bruh ❱> ❱ ::bruuh ❱();
2357/// ```
2358///
2359/// [Reference](https://doc.rust-lang.org/reference/paths.html)
2360#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1169#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2361pub struct Path { 1170pub struct PathPat {
2362 pub(crate) syntax: SyntaxNode, 1171 pub(crate) syntax: SyntaxNode,
2363} 1172}
2364impl Path { 1173impl PathPat {
2365 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) } 1174 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2366 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
2367 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
2368} 1175}
2369/// Segment of the path to a symbol.
2370/// Only path segment of an absolute path holds the `::` token,
2371/// all other `::` tokens that connect path segments reside under `Path` itself.`
2372///
2373/// ```
2374/// (0..10).❰ collect ❱ :: ❰ <Vec<_>> ❱();
2375/// ❰ Vec ❱ :: ❰ <u8> ❱ :: ❰ with_capacity ❱(1024);
2376/// ❰ <❰ Foo ❱ as ❰ bar ❱ :: ❰ Bar ❱> ❱ :: ❰ baz ❱();
2377/// ❰ <❰ bruh ❱> ❱ :: ❰ bruuh ❱();
2378///
2379/// // Note that only in this case `::` token is inlcuded:
2380/// ❰ ::foo ❱;
2381/// ```
2382///
2383/// [Reference](https://doc.rust-lang.org/reference/paths.html)
2384#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1176#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2385pub struct PathSegment { 1177pub struct WildcardPat {
2386 pub(crate) syntax: SyntaxNode, 1178 pub(crate) syntax: SyntaxNode,
2387} 1179}
2388impl PathSegment { 1180impl WildcardPat {
2389 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } 1181 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
2390 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
2391 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
2392 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
2393 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
2394 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2395 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
2396 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
2397 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
2398 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) }
2399 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2400}
2401/// List of type arguments that are passed at generic instantiation site.
2402///
2403/// ```
2404/// type _ = Foo ❰ ::<'a, u64, Item = Bar, 42, {true}> ❱::Bar;
2405///
2406/// Vec❰ ::<bool> ❱::();
2407/// ```
2408///
2409/// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2410#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2411pub struct TypeArgList {
2412 pub(crate) syntax: SyntaxNode,
2413}
2414impl TypeArgList {
2415 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
2416 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
2417 pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) }
2418 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) }
2419 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) }
2420 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) }
2421 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) }
2422 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2423} 1182}
2424/// Type argument that is passed at generic instantiation site.
2425///
2426/// ```
2427/// type _ = Foo::<'a, ❰ u64 ❱, ❰ bool ❱, Item = Bar, 42>::Baz;
2428/// ```
2429///
2430/// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2431#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1183#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2432pub struct TypeArg { 1184pub struct RangePat {
2433 pub(crate) syntax: SyntaxNode, 1185 pub(crate) syntax: SyntaxNode,
2434} 1186}
2435impl TypeArg { 1187impl RangePat {}
2436 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2437}
2438/// Associated type argument that is passed at generic instantiation site.
2439/// ```
2440/// type Foo = Bar::<'a, u64, bool, ❰ Item = Baz ❱, 42>::Bruh;
2441///
2442/// trait Bruh<T>: Iterator<❰ Item: Debug ❱> {}
2443/// ```
2444///
2445#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1188#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2446pub struct AssocTypeArg { 1189pub struct RecordPat {
2447 pub(crate) syntax: SyntaxNode, 1190 pub(crate) syntax: SyntaxNode,
2448} 1191}
2449impl ast::TypeBoundsOwner for AssocTypeArg {} 1192impl RecordPat {
2450impl AssocTypeArg { 1193 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2451 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 1194 pub fn record_pat_field_list(&self) -> Option<RecordPatFieldList> {
2452 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 1195 support::child(&self.syntax)
2453 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1196 }
2454} 1197}
2455/// Lifetime argument that is passed at generic instantiation site.
2456///
2457/// ```
2458/// fn foo<'a>(s: &'a str) {
2459/// bar::<❰ 'a ❱>(s);
2460/// }
2461/// ```
2462///
2463/// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2464#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1198#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2465pub struct LifetimeArg { 1199pub struct RefPat {
2466 pub(crate) syntax: SyntaxNode, 1200 pub(crate) syntax: SyntaxNode,
2467} 1201}
2468impl LifetimeArg { 1202impl RefPat {
2469 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 1203 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
2470 support::token(&self.syntax, T![lifetime]) 1204 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
2471 } 1205 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2472} 1206}
2473/// Constant value argument that is passed at generic instantiation site.
2474///
2475/// ```
2476/// foo::<u32, ❰ { true } ❱>();
2477///
2478/// bar::<❰ { 2 + 2} ❱>();
2479/// ```
2480///
2481/// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter)
2482#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1207#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2483pub struct ConstArg { 1208pub struct SlicePat {
2484 pub(crate) syntax: SyntaxNode, 1209 pub(crate) syntax: SyntaxNode,
2485} 1210}
2486impl ConstArg { 1211impl SlicePat {
2487 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } 1212 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
2488 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 1213 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1214 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
2489} 1215}
2490/// FIXME: (@edwin0cheng) Remove it to use ItemList instead
2491/// https://github.com/rust-analyzer/rust-analyzer/pull/4083#discussion_r422666243
2492///
2493/// [Reference](https://doc.rust-lang.org/reference/macros.html)
2494#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1216#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2495pub struct MacroItems { 1217pub struct TuplePat {
2496 pub(crate) syntax: SyntaxNode, 1218 pub(crate) syntax: SyntaxNode,
2497} 1219}
2498impl ast::ModuleItemOwner for MacroItems {} 1220impl TuplePat {
2499impl MacroItems {} 1221 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2500/// FIXME: (@edwin0cheng) add some documentation here. As per the writing 1222 pub fn fields(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
2501/// of this comment this ast node is not used. 1223 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2502/// 1224}
2503/// ```
2504/// // FIXME: example here
2505/// ```
2506///
2507/// [Reference](https://doc.rust-lang.org/reference/macros.html)
2508#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1225#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2509pub struct MacroStmts { 1226pub struct TupleStructPat {
2510 pub(crate) syntax: SyntaxNode, 1227 pub(crate) syntax: SyntaxNode,
2511} 1228}
2512impl MacroStmts { 1229impl TupleStructPat {
2513 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) } 1230 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2514 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1231 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1232 pub fn fields(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1233 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2515} 1234}
2516/// List of items in an extern block.
2517///
2518/// ```
2519/// extern "C" ❰
2520/// {
2521/// fn foo();
2522/// static var: u32;
2523/// }
2524/// ❱
2525/// ```
2526///
2527/// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2528#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1235#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2529pub struct ExternItemList { 1236pub struct RecordPatFieldList {
2530 pub(crate) syntax: SyntaxNode, 1237 pub(crate) syntax: SyntaxNode,
2531} 1238}
2532impl ast::ModuleItemOwner for ExternItemList {} 1239impl RecordPatFieldList {
2533impl ExternItemList {
2534 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 1240 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
2535 pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) } 1241 pub fn fields(&self) -> AstChildren<RecordPatField> { support::children(&self.syntax) }
1242 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
2536 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 1243 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2537} 1244}
2538/// Extern block.
2539///
2540/// ```
2541/// ❰
2542/// extern "C" {
2543/// fn foo();
2544/// }
2545/// ❱
2546///
2547/// ```
2548///
2549/// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2550#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1245#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2551pub struct ExternBlock { 1246pub struct RecordPatField {
2552 pub(crate) syntax: SyntaxNode, 1247 pub(crate) syntax: SyntaxNode,
2553} 1248}
2554impl ExternBlock { 1249impl ast::AttrsOwner for RecordPatField {}
2555 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } 1250impl RecordPatField {
2556 pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) } 1251 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2557} 1252 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
2558/// Meta item in an attribute. 1253 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2559///
2560/// ```
2561/// #[❰ bar::baz = "42" ❱]
2562/// #[❰ bruh(bruuh("true")) ❱]
2563/// struct Foo;
2564/// ```
2565///
2566/// [Reference](https://doc.rust-lang.org/reference/attributes.html?highlight=meta,item#meta-item-attribute-syntax)
2567#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2568pub struct MetaItem {
2569 pub(crate) syntax: SyntaxNode,
2570}
2571impl MetaItem {
2572 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2573 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2574 pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
2575 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) }
2576}
2577/// Macro 2.0 definition.
2578/// Their syntax is still WIP by rustc team...
2579/// ```
2580/// ❰
2581/// macro foo { }
2582/// ❱
2583/// ```
2584///
2585/// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/1584-macros.md)
2586#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2587pub struct MacroDef {
2588 pub(crate) syntax: SyntaxNode,
2589}
2590impl MacroDef {
2591 pub fn name(&self) -> Option<Name> { support::child(&self.syntax) }
2592 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
2593}
2594/// Any kind of nominal type definition.
2595#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2596pub enum NominalDef {
2597 StructDef(StructDef),
2598 EnumDef(EnumDef),
2599 UnionDef(UnionDef),
2600}
2601impl ast::NameOwner for NominalDef {}
2602impl ast::TypeParamsOwner for NominalDef {}
2603impl ast::AttrsOwner for NominalDef {}
2604/// Any kind of **declared** generic parameter
2605#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2606pub enum GenericParam {
2607 LifetimeParam(LifetimeParam),
2608 TypeParam(TypeParam),
2609 ConstParam(ConstParam),
2610} 1254}
2611/// Any kind of generic argument passed at instantiation site
2612#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1255#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2613pub enum GenericArg { 1256pub enum GenericArg {
2614 LifetimeArg(LifetimeArg),
2615 TypeArg(TypeArg), 1257 TypeArg(TypeArg),
2616 ConstArg(ConstArg),
2617 AssocTypeArg(AssocTypeArg), 1258 AssocTypeArg(AssocTypeArg),
1259 LifetimeArg(LifetimeArg),
1260 ConstArg(ConstArg),
2618} 1261}
2619/// Any kind of construct valid in type context
2620#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1262#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2621pub enum TypeRef { 1263pub enum Type {
2622 ParenType(ParenType),
2623 TupleType(TupleType),
2624 NeverType(NeverType),
2625 PathType(PathType),
2626 PointerType(PointerType),
2627 ArrayType(ArrayType), 1264 ArrayType(ArrayType),
2628 SliceType(SliceType), 1265 DynTraitType(DynTraitType),
2629 ReferenceType(ReferenceType), 1266 FnPtrType(FnPtrType),
2630 PlaceholderType(PlaceholderType),
2631 FnPointerType(FnPointerType),
2632 ForType(ForType), 1267 ForType(ForType),
2633 ImplTraitType(ImplTraitType), 1268 ImplTraitType(ImplTraitType),
2634 DynTraitType(DynTraitType), 1269 InferType(InferType),
2635} 1270 NeverType(NeverType),
2636/// Any kind of top-level item that may appear in a module 1271 ParenType(ParenType),
2637#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1272 PathType(PathType),
2638pub enum ModuleItem { 1273 PtrType(PtrType),
2639 StructDef(StructDef), 1274 RefType(RefType),
2640 UnionDef(UnionDef), 1275 SliceType(SliceType),
2641 EnumDef(EnumDef), 1276 TupleType(TupleType),
2642 FnDef(FnDef),
2643 TraitDef(TraitDef),
2644 TypeAliasDef(TypeAliasDef),
2645 ImplDef(ImplDef),
2646 UseItem(UseItem),
2647 ExternCrateItem(ExternCrateItem),
2648 ConstDef(ConstDef),
2649 StaticDef(StaticDef),
2650 Module(Module),
2651 MacroCall(MacroCall),
2652 ExternBlock(ExternBlock),
2653}
2654impl ast::NameOwner for ModuleItem {}
2655impl ast::AttrsOwner for ModuleItem {}
2656impl ast::VisibilityOwner for ModuleItem {}
2657/// Any kind of item that may appear in an impl block
2658///
2659/// // FIXME: impl blocks can also contain MacroCall
2660#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2661pub enum AssocItem {
2662 FnDef(FnDef),
2663 TypeAliasDef(TypeAliasDef),
2664 ConstDef(ConstDef),
2665}
2666impl ast::NameOwner for AssocItem {}
2667impl ast::AttrsOwner for AssocItem {}
2668/// Any kind of item that may appear in an extern block
2669///
2670/// // FIXME: extern blocks can also contain MacroCall
2671#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2672pub enum ExternItem {
2673 FnDef(FnDef),
2674 StaticDef(StaticDef),
2675} 1277}
2676impl ast::NameOwner for ExternItem {}
2677impl ast::AttrsOwner for ExternItem {}
2678impl ast::VisibilityOwner for ExternItem {}
2679/// Any kind of expression
2680#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1278#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2681pub enum Expr { 1279pub enum Expr {
2682 TupleExpr(TupleExpr),
2683 ArrayExpr(ArrayExpr), 1280 ArrayExpr(ArrayExpr),
2684 ParenExpr(ParenExpr), 1281 AwaitExpr(AwaitExpr),
2685 PathExpr(PathExpr), 1282 BinExpr(BinExpr),
2686 LambdaExpr(LambdaExpr),
2687 IfExpr(IfExpr),
2688 LoopExpr(LoopExpr),
2689 ForExpr(ForExpr),
2690 WhileExpr(WhileExpr),
2691 ContinueExpr(ContinueExpr),
2692 BreakExpr(BreakExpr),
2693 Label(Label),
2694 BlockExpr(BlockExpr), 1283 BlockExpr(BlockExpr),
2695 ReturnExpr(ReturnExpr), 1284 BoxExpr(BoxExpr),
2696 MatchExpr(MatchExpr), 1285 BreakExpr(BreakExpr),
2697 RecordLit(RecordLit),
2698 CallExpr(CallExpr), 1286 CallExpr(CallExpr),
1287 CastExpr(CastExpr),
1288 ClosureExpr(ClosureExpr),
1289 ContinueExpr(ContinueExpr),
1290 EffectExpr(EffectExpr),
1291 FieldExpr(FieldExpr),
1292 ForExpr(ForExpr),
1293 IfExpr(IfExpr),
2699 IndexExpr(IndexExpr), 1294 IndexExpr(IndexExpr),
1295 Literal(Literal),
1296 LoopExpr(LoopExpr),
1297 MacroCall(MacroCall),
1298 MatchExpr(MatchExpr),
2700 MethodCallExpr(MethodCallExpr), 1299 MethodCallExpr(MethodCallExpr),
2701 FieldExpr(FieldExpr), 1300 ParenExpr(ParenExpr),
2702 AwaitExpr(AwaitExpr), 1301 PathExpr(PathExpr),
2703 TryExpr(TryExpr),
2704 EffectExpr(EffectExpr),
2705 CastExpr(CastExpr),
2706 RefExpr(RefExpr),
2707 PrefixExpr(PrefixExpr), 1302 PrefixExpr(PrefixExpr),
2708 RangeExpr(RangeExpr), 1303 RangeExpr(RangeExpr),
2709 BinExpr(BinExpr), 1304 RecordExpr(RecordExpr),
2710 Literal(Literal), 1305 RefExpr(RefExpr),
1306 ReturnExpr(ReturnExpr),
1307 TryExpr(TryExpr),
1308 TupleExpr(TupleExpr),
1309 WhileExpr(WhileExpr),
1310}
1311#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1312pub enum Item {
1313 Const(Const),
1314 Enum(Enum),
1315 ExternBlock(ExternBlock),
1316 ExternCrate(ExternCrate),
1317 Fn(Fn),
1318 Impl(Impl),
2711 MacroCall(MacroCall), 1319 MacroCall(MacroCall),
2712 BoxExpr(BoxExpr), 1320 Module(Module),
1321 Static(Static),
1322 Struct(Struct),
1323 Trait(Trait),
1324 TypeAlias(TypeAlias),
1325 Union(Union),
1326 Use(Use),
1327}
1328impl ast::AttrsOwner for Item {}
1329#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1330pub enum Stmt {
1331 ExprStmt(ExprStmt),
1332 Item(Item),
1333 LetStmt(LetStmt),
2713} 1334}
2714impl ast::AttrsOwner for Expr {}
2715/// Any kind of pattern
2716#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1335#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2717pub enum Pat { 1336pub enum Pat {
1337 IdentPat(IdentPat),
1338 BoxPat(BoxPat),
1339 RestPat(RestPat),
1340 LiteralPat(LiteralPat),
1341 MacroPat(MacroPat),
2718 OrPat(OrPat), 1342 OrPat(OrPat),
2719 ParenPat(ParenPat), 1343 ParenPat(ParenPat),
2720 RefPat(RefPat),
2721 BoxPat(BoxPat),
2722 BindPat(BindPat),
2723 PlaceholderPat(PlaceholderPat),
2724 DotDotPat(DotDotPat),
2725 PathPat(PathPat), 1344 PathPat(PathPat),
1345 WildcardPat(WildcardPat),
1346 RangePat(RangePat),
2726 RecordPat(RecordPat), 1347 RecordPat(RecordPat),
2727 TupleStructPat(TupleStructPat), 1348 RefPat(RefPat),
2728 TuplePat(TuplePat),
2729 SlicePat(SlicePat), 1349 SlicePat(SlicePat),
2730 RangePat(RangePat), 1350 TuplePat(TuplePat),
2731 LiteralPat(LiteralPat), 1351 TupleStructPat(TupleStructPat),
2732 MacroPat(MacroPat),
2733} 1352}
2734/// Any kind of pattern that appears directly inside of the curly
2735/// braces of a record pattern
2736#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1353#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2737pub enum RecordInnerPat { 1354pub enum FieldList {
2738 RecordFieldPat(RecordFieldPat), 1355 RecordFieldList(RecordFieldList),
2739 BindPat(BindPat), 1356 TupleFieldList(TupleFieldList),
2740} 1357}
2741/// Any kind of input to an attribute
2742#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1358#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2743pub enum AttrInput { 1359pub enum AdtDef {
2744 Literal(Literal), 1360 Enum(Enum),
2745 TokenTree(TokenTree), 1361 Struct(Struct),
1362 Union(Union),
2746} 1363}
2747/// Any kind of statement 1364impl ast::AttrsOwner for AdtDef {}
2748/// Note: there are no empty statements, these are just represented as 1365impl ast::GenericParamsOwner for AdtDef {}
2749/// bare semicolons without a dedicated statement ast node. 1366impl ast::NameOwner for AdtDef {}
1367impl ast::VisibilityOwner for AdtDef {}
2750#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1368#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2751pub enum Stmt { 1369pub enum AssocItem {
2752 LetStmt(LetStmt), 1370 Const(Const),
2753 ExprStmt(ExprStmt), 1371 Fn(Fn),
1372 MacroCall(MacroCall),
1373 TypeAlias(TypeAlias),
2754} 1374}
2755/// Any kind of fields list (record or tuple field lists) 1375impl ast::AttrsOwner for AssocItem {}
1376impl ast::NameOwner for AssocItem {}
2756#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1377#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2757pub enum FieldDefList { 1378pub enum ExternItem {
2758 RecordFieldDefList(RecordFieldDefList), 1379 Fn(Fn),
2759 TupleFieldDefList(TupleFieldDefList), 1380 MacroCall(MacroCall),
1381 Static(Static),
2760} 1382}
2761impl AstNode for SourceFile { 1383impl ast::AttrsOwner for ExternItem {}
2762 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } 1384impl ast::NameOwner for ExternItem {}
2763 fn cast(syntax: SyntaxNode) -> Option<Self> { 1385#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2764 if Self::can_cast(syntax.kind()) { 1386pub enum GenericParam {
2765 Some(Self { syntax }) 1387 ConstParam(ConstParam),
2766 } else { 1388 LifetimeParam(LifetimeParam),
2767 None 1389 TypeParam(TypeParam),
2768 }
2769 }
2770 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2771} 1390}
2772impl AstNode for FnDef { 1391impl ast::AttrsOwner for GenericParam {}
2773 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF } 1392impl AstNode for Name {
1393 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }
2774 fn cast(syntax: SyntaxNode) -> Option<Self> { 1394 fn cast(syntax: SyntaxNode) -> Option<Self> {
2775 if Self::can_cast(syntax.kind()) { 1395 if Self::can_cast(syntax.kind()) {
2776 Some(Self { syntax }) 1396 Some(Self { syntax })
@@ -2780,8 +1400,8 @@ impl AstNode for FnDef {
2780 } 1400 }
2781 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1401 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2782} 1402}
2783impl AstNode for RetType { 1403impl AstNode for NameRef {
2784 fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } 1404 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF }
2785 fn cast(syntax: SyntaxNode) -> Option<Self> { 1405 fn cast(syntax: SyntaxNode) -> Option<Self> {
2786 if Self::can_cast(syntax.kind()) { 1406 if Self::can_cast(syntax.kind()) {
2787 Some(Self { syntax }) 1407 Some(Self { syntax })
@@ -2791,8 +1411,8 @@ impl AstNode for RetType {
2791 } 1411 }
2792 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1412 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2793} 1413}
2794impl AstNode for StructDef { 1414impl AstNode for Path {
2795 fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF } 1415 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH }
2796 fn cast(syntax: SyntaxNode) -> Option<Self> { 1416 fn cast(syntax: SyntaxNode) -> Option<Self> {
2797 if Self::can_cast(syntax.kind()) { 1417 if Self::can_cast(syntax.kind()) {
2798 Some(Self { syntax }) 1418 Some(Self { syntax })
@@ -2802,8 +1422,8 @@ impl AstNode for StructDef {
2802 } 1422 }
2803 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1423 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2804} 1424}
2805impl AstNode for UnionDef { 1425impl AstNode for PathSegment {
2806 fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF } 1426 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT }
2807 fn cast(syntax: SyntaxNode) -> Option<Self> { 1427 fn cast(syntax: SyntaxNode) -> Option<Self> {
2808 if Self::can_cast(syntax.kind()) { 1428 if Self::can_cast(syntax.kind()) {
2809 Some(Self { syntax }) 1429 Some(Self { syntax })
@@ -2813,8 +1433,8 @@ impl AstNode for UnionDef {
2813 } 1433 }
2814 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1434 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2815} 1435}
2816impl AstNode for RecordFieldDefList { 1436impl AstNode for GenericArgList {
2817 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } 1437 fn can_cast(kind: SyntaxKind) -> bool { kind == GENERIC_ARG_LIST }
2818 fn cast(syntax: SyntaxNode) -> Option<Self> { 1438 fn cast(syntax: SyntaxNode) -> Option<Self> {
2819 if Self::can_cast(syntax.kind()) { 1439 if Self::can_cast(syntax.kind()) {
2820 Some(Self { syntax }) 1440 Some(Self { syntax })
@@ -2824,8 +1444,8 @@ impl AstNode for RecordFieldDefList {
2824 } 1444 }
2825 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1445 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2826} 1446}
2827impl AstNode for RecordFieldDef { 1447impl AstNode for ParamList {
2828 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF } 1448 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST }
2829 fn cast(syntax: SyntaxNode) -> Option<Self> { 1449 fn cast(syntax: SyntaxNode) -> Option<Self> {
2830 if Self::can_cast(syntax.kind()) { 1450 if Self::can_cast(syntax.kind()) {
2831 Some(Self { syntax }) 1451 Some(Self { syntax })
@@ -2835,8 +1455,8 @@ impl AstNode for RecordFieldDef {
2835 } 1455 }
2836 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1456 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2837} 1457}
2838impl AstNode for TupleFieldDefList { 1458impl AstNode for RetType {
2839 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF_LIST } 1459 fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE }
2840 fn cast(syntax: SyntaxNode) -> Option<Self> { 1460 fn cast(syntax: SyntaxNode) -> Option<Self> {
2841 if Self::can_cast(syntax.kind()) { 1461 if Self::can_cast(syntax.kind()) {
2842 Some(Self { syntax }) 1462 Some(Self { syntax })
@@ -2846,8 +1466,8 @@ impl AstNode for TupleFieldDefList {
2846 } 1466 }
2847 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1467 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2848} 1468}
2849impl AstNode for TupleFieldDef { 1469impl AstNode for PathType {
2850 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF } 1470 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE }
2851 fn cast(syntax: SyntaxNode) -> Option<Self> { 1471 fn cast(syntax: SyntaxNode) -> Option<Self> {
2852 if Self::can_cast(syntax.kind()) { 1472 if Self::can_cast(syntax.kind()) {
2853 Some(Self { syntax }) 1473 Some(Self { syntax })
@@ -2857,8 +1477,8 @@ impl AstNode for TupleFieldDef {
2857 } 1477 }
2858 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1478 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2859} 1479}
2860impl AstNode for EnumDef { 1480impl AstNode for TypeArg {
2861 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF } 1481 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG }
2862 fn cast(syntax: SyntaxNode) -> Option<Self> { 1482 fn cast(syntax: SyntaxNode) -> Option<Self> {
2863 if Self::can_cast(syntax.kind()) { 1483 if Self::can_cast(syntax.kind()) {
2864 Some(Self { syntax }) 1484 Some(Self { syntax })
@@ -2868,8 +1488,8 @@ impl AstNode for EnumDef {
2868 } 1488 }
2869 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1489 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2870} 1490}
2871impl AstNode for EnumVariantList { 1491impl AstNode for AssocTypeArg {
2872 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST } 1492 fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG }
2873 fn cast(syntax: SyntaxNode) -> Option<Self> { 1493 fn cast(syntax: SyntaxNode) -> Option<Self> {
2874 if Self::can_cast(syntax.kind()) { 1494 if Self::can_cast(syntax.kind()) {
2875 Some(Self { syntax }) 1495 Some(Self { syntax })
@@ -2879,8 +1499,8 @@ impl AstNode for EnumVariantList {
2879 } 1499 }
2880 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1500 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2881} 1501}
2882impl AstNode for EnumVariant { 1502impl AstNode for LifetimeArg {
2883 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT } 1503 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG }
2884 fn cast(syntax: SyntaxNode) -> Option<Self> { 1504 fn cast(syntax: SyntaxNode) -> Option<Self> {
2885 if Self::can_cast(syntax.kind()) { 1505 if Self::can_cast(syntax.kind()) {
2886 Some(Self { syntax }) 1506 Some(Self { syntax })
@@ -2890,8 +1510,8 @@ impl AstNode for EnumVariant {
2890 } 1510 }
2891 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1511 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2892} 1512}
2893impl AstNode for TraitDef { 1513impl AstNode for ConstArg {
2894 fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF } 1514 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG }
2895 fn cast(syntax: SyntaxNode) -> Option<Self> { 1515 fn cast(syntax: SyntaxNode) -> Option<Self> {
2896 if Self::can_cast(syntax.kind()) { 1516 if Self::can_cast(syntax.kind()) {
2897 Some(Self { syntax }) 1517 Some(Self { syntax })
@@ -2901,8 +1521,8 @@ impl AstNode for TraitDef {
2901 } 1521 }
2902 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1522 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2903} 1523}
2904impl AstNode for Module { 1524impl AstNode for TypeBoundList {
2905 fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE } 1525 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST }
2906 fn cast(syntax: SyntaxNode) -> Option<Self> { 1526 fn cast(syntax: SyntaxNode) -> Option<Self> {
2907 if Self::can_cast(syntax.kind()) { 1527 if Self::can_cast(syntax.kind()) {
2908 Some(Self { syntax }) 1528 Some(Self { syntax })
@@ -2912,8 +1532,8 @@ impl AstNode for Module {
2912 } 1532 }
2913 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1533 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2914} 1534}
2915impl AstNode for ItemList { 1535impl AstNode for MacroCall {
2916 fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST } 1536 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL }
2917 fn cast(syntax: SyntaxNode) -> Option<Self> { 1537 fn cast(syntax: SyntaxNode) -> Option<Self> {
2918 if Self::can_cast(syntax.kind()) { 1538 if Self::can_cast(syntax.kind()) {
2919 Some(Self { syntax }) 1539 Some(Self { syntax })
@@ -2923,8 +1543,8 @@ impl AstNode for ItemList {
2923 } 1543 }
2924 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1544 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2925} 1545}
2926impl AstNode for ConstDef { 1546impl AstNode for Attr {
2927 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF } 1547 fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR }
2928 fn cast(syntax: SyntaxNode) -> Option<Self> { 1548 fn cast(syntax: SyntaxNode) -> Option<Self> {
2929 if Self::can_cast(syntax.kind()) { 1549 if Self::can_cast(syntax.kind()) {
2930 Some(Self { syntax }) 1550 Some(Self { syntax })
@@ -2934,8 +1554,8 @@ impl AstNode for ConstDef {
2934 } 1554 }
2935 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1555 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2936} 1556}
2937impl AstNode for StaticDef { 1557impl AstNode for TokenTree {
2938 fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF } 1558 fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE }
2939 fn cast(syntax: SyntaxNode) -> Option<Self> { 1559 fn cast(syntax: SyntaxNode) -> Option<Self> {
2940 if Self::can_cast(syntax.kind()) { 1560 if Self::can_cast(syntax.kind()) {
2941 Some(Self { syntax }) 1561 Some(Self { syntax })
@@ -2945,8 +1565,8 @@ impl AstNode for StaticDef {
2945 } 1565 }
2946 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1566 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2947} 1567}
2948impl AstNode for TypeAliasDef { 1568impl AstNode for MacroItems {
2949 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF } 1569 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_ITEMS }
2950 fn cast(syntax: SyntaxNode) -> Option<Self> { 1570 fn cast(syntax: SyntaxNode) -> Option<Self> {
2951 if Self::can_cast(syntax.kind()) { 1571 if Self::can_cast(syntax.kind()) {
2952 Some(Self { syntax }) 1572 Some(Self { syntax })
@@ -2956,8 +1576,8 @@ impl AstNode for TypeAliasDef {
2956 } 1576 }
2957 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1577 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2958} 1578}
2959impl AstNode for ImplDef { 1579impl AstNode for MacroStmts {
2960 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF } 1580 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS }
2961 fn cast(syntax: SyntaxNode) -> Option<Self> { 1581 fn cast(syntax: SyntaxNode) -> Option<Self> {
2962 if Self::can_cast(syntax.kind()) { 1582 if Self::can_cast(syntax.kind()) {
2963 Some(Self { syntax }) 1583 Some(Self { syntax })
@@ -2967,8 +1587,8 @@ impl AstNode for ImplDef {
2967 } 1587 }
2968 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1588 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2969} 1589}
2970impl AstNode for ParenType { 1590impl AstNode for SourceFile {
2971 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE } 1591 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }
2972 fn cast(syntax: SyntaxNode) -> Option<Self> { 1592 fn cast(syntax: SyntaxNode) -> Option<Self> {
2973 if Self::can_cast(syntax.kind()) { 1593 if Self::can_cast(syntax.kind()) {
2974 Some(Self { syntax }) 1594 Some(Self { syntax })
@@ -2978,8 +1598,8 @@ impl AstNode for ParenType {
2978 } 1598 }
2979 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1599 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2980} 1600}
2981impl AstNode for TupleType { 1601impl AstNode for Const {
2982 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_TYPE } 1602 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST }
2983 fn cast(syntax: SyntaxNode) -> Option<Self> { 1603 fn cast(syntax: SyntaxNode) -> Option<Self> {
2984 if Self::can_cast(syntax.kind()) { 1604 if Self::can_cast(syntax.kind()) {
2985 Some(Self { syntax }) 1605 Some(Self { syntax })
@@ -2989,8 +1609,8 @@ impl AstNode for TupleType {
2989 } 1609 }
2990 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1610 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2991} 1611}
2992impl AstNode for NeverType { 1612impl AstNode for Enum {
2993 fn can_cast(kind: SyntaxKind) -> bool { kind == NEVER_TYPE } 1613 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM }
2994 fn cast(syntax: SyntaxNode) -> Option<Self> { 1614 fn cast(syntax: SyntaxNode) -> Option<Self> {
2995 if Self::can_cast(syntax.kind()) { 1615 if Self::can_cast(syntax.kind()) {
2996 Some(Self { syntax }) 1616 Some(Self { syntax })
@@ -3000,8 +1620,8 @@ impl AstNode for NeverType {
3000 } 1620 }
3001 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1621 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3002} 1622}
3003impl AstNode for PathType { 1623impl AstNode for ExternBlock {
3004 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE } 1624 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK }
3005 fn cast(syntax: SyntaxNode) -> Option<Self> { 1625 fn cast(syntax: SyntaxNode) -> Option<Self> {
3006 if Self::can_cast(syntax.kind()) { 1626 if Self::can_cast(syntax.kind()) {
3007 Some(Self { syntax }) 1627 Some(Self { syntax })
@@ -3011,8 +1631,8 @@ impl AstNode for PathType {
3011 } 1631 }
3012 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1632 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3013} 1633}
3014impl AstNode for PointerType { 1634impl AstNode for ExternCrate {
3015 fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } 1635 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE }
3016 fn cast(syntax: SyntaxNode) -> Option<Self> { 1636 fn cast(syntax: SyntaxNode) -> Option<Self> {
3017 if Self::can_cast(syntax.kind()) { 1637 if Self::can_cast(syntax.kind()) {
3018 Some(Self { syntax }) 1638 Some(Self { syntax })
@@ -3022,8 +1642,8 @@ impl AstNode for PointerType {
3022 } 1642 }
3023 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1643 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3024} 1644}
3025impl AstNode for ArrayType { 1645impl AstNode for Fn {
3026 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_TYPE } 1646 fn can_cast(kind: SyntaxKind) -> bool { kind == FN }
3027 fn cast(syntax: SyntaxNode) -> Option<Self> { 1647 fn cast(syntax: SyntaxNode) -> Option<Self> {
3028 if Self::can_cast(syntax.kind()) { 1648 if Self::can_cast(syntax.kind()) {
3029 Some(Self { syntax }) 1649 Some(Self { syntax })
@@ -3033,8 +1653,8 @@ impl AstNode for ArrayType {
3033 } 1653 }
3034 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1654 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3035} 1655}
3036impl AstNode for SliceType { 1656impl AstNode for Impl {
3037 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_TYPE } 1657 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL }
3038 fn cast(syntax: SyntaxNode) -> Option<Self> { 1658 fn cast(syntax: SyntaxNode) -> Option<Self> {
3039 if Self::can_cast(syntax.kind()) { 1659 if Self::can_cast(syntax.kind()) {
3040 Some(Self { syntax }) 1660 Some(Self { syntax })
@@ -3044,8 +1664,8 @@ impl AstNode for SliceType {
3044 } 1664 }
3045 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1665 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3046} 1666}
3047impl AstNode for ReferenceType { 1667impl AstNode for Module {
3048 fn can_cast(kind: SyntaxKind) -> bool { kind == REFERENCE_TYPE } 1668 fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE }
3049 fn cast(syntax: SyntaxNode) -> Option<Self> { 1669 fn cast(syntax: SyntaxNode) -> Option<Self> {
3050 if Self::can_cast(syntax.kind()) { 1670 if Self::can_cast(syntax.kind()) {
3051 Some(Self { syntax }) 1671 Some(Self { syntax })
@@ -3055,8 +1675,8 @@ impl AstNode for ReferenceType {
3055 } 1675 }
3056 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1676 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3057} 1677}
3058impl AstNode for PlaceholderType { 1678impl AstNode for Static {
3059 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_TYPE } 1679 fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC }
3060 fn cast(syntax: SyntaxNode) -> Option<Self> { 1680 fn cast(syntax: SyntaxNode) -> Option<Self> {
3061 if Self::can_cast(syntax.kind()) { 1681 if Self::can_cast(syntax.kind()) {
3062 Some(Self { syntax }) 1682 Some(Self { syntax })
@@ -3066,8 +1686,8 @@ impl AstNode for PlaceholderType {
3066 } 1686 }
3067 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1687 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3068} 1688}
3069impl AstNode for FnPointerType { 1689impl AstNode for Struct {
3070 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_POINTER_TYPE } 1690 fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT }
3071 fn cast(syntax: SyntaxNode) -> Option<Self> { 1691 fn cast(syntax: SyntaxNode) -> Option<Self> {
3072 if Self::can_cast(syntax.kind()) { 1692 if Self::can_cast(syntax.kind()) {
3073 Some(Self { syntax }) 1693 Some(Self { syntax })
@@ -3077,8 +1697,8 @@ impl AstNode for FnPointerType {
3077 } 1697 }
3078 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1698 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3079} 1699}
3080impl AstNode for ForType { 1700impl AstNode for Trait {
3081 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_TYPE } 1701 fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT }
3082 fn cast(syntax: SyntaxNode) -> Option<Self> { 1702 fn cast(syntax: SyntaxNode) -> Option<Self> {
3083 if Self::can_cast(syntax.kind()) { 1703 if Self::can_cast(syntax.kind()) {
3084 Some(Self { syntax }) 1704 Some(Self { syntax })
@@ -3088,8 +1708,8 @@ impl AstNode for ForType {
3088 } 1708 }
3089 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1709 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3090} 1710}
3091impl AstNode for ImplTraitType { 1711impl AstNode for TypeAlias {
3092 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_TRAIT_TYPE } 1712 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS }
3093 fn cast(syntax: SyntaxNode) -> Option<Self> { 1713 fn cast(syntax: SyntaxNode) -> Option<Self> {
3094 if Self::can_cast(syntax.kind()) { 1714 if Self::can_cast(syntax.kind()) {
3095 Some(Self { syntax }) 1715 Some(Self { syntax })
@@ -3099,8 +1719,8 @@ impl AstNode for ImplTraitType {
3099 } 1719 }
3100 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1720 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3101} 1721}
3102impl AstNode for DynTraitType { 1722impl AstNode for Union {
3103 fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_TRAIT_TYPE } 1723 fn can_cast(kind: SyntaxKind) -> bool { kind == UNION }
3104 fn cast(syntax: SyntaxNode) -> Option<Self> { 1724 fn cast(syntax: SyntaxNode) -> Option<Self> {
3105 if Self::can_cast(syntax.kind()) { 1725 if Self::can_cast(syntax.kind()) {
3106 Some(Self { syntax }) 1726 Some(Self { syntax })
@@ -3110,8 +1730,8 @@ impl AstNode for DynTraitType {
3110 } 1730 }
3111 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1731 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3112} 1732}
3113impl AstNode for TupleExpr { 1733impl AstNode for Use {
3114 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_EXPR } 1734 fn can_cast(kind: SyntaxKind) -> bool { kind == USE }
3115 fn cast(syntax: SyntaxNode) -> Option<Self> { 1735 fn cast(syntax: SyntaxNode) -> Option<Self> {
3116 if Self::can_cast(syntax.kind()) { 1736 if Self::can_cast(syntax.kind()) {
3117 Some(Self { syntax }) 1737 Some(Self { syntax })
@@ -3121,8 +1741,8 @@ impl AstNode for TupleExpr {
3121 } 1741 }
3122 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1742 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3123} 1743}
3124impl AstNode for ArrayExpr { 1744impl AstNode for Visibility {
3125 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_EXPR } 1745 fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY }
3126 fn cast(syntax: SyntaxNode) -> Option<Self> { 1746 fn cast(syntax: SyntaxNode) -> Option<Self> {
3127 if Self::can_cast(syntax.kind()) { 1747 if Self::can_cast(syntax.kind()) {
3128 Some(Self { syntax }) 1748 Some(Self { syntax })
@@ -3132,8 +1752,8 @@ impl AstNode for ArrayExpr {
3132 } 1752 }
3133 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1753 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3134} 1754}
3135impl AstNode for ParenExpr { 1755impl AstNode for ItemList {
3136 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_EXPR } 1756 fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST }
3137 fn cast(syntax: SyntaxNode) -> Option<Self> { 1757 fn cast(syntax: SyntaxNode) -> Option<Self> {
3138 if Self::can_cast(syntax.kind()) { 1758 if Self::can_cast(syntax.kind()) {
3139 Some(Self { syntax }) 1759 Some(Self { syntax })
@@ -3143,8 +1763,8 @@ impl AstNode for ParenExpr {
3143 } 1763 }
3144 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1764 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3145} 1765}
3146impl AstNode for PathExpr { 1766impl AstNode for Rename {
3147 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_EXPR } 1767 fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME }
3148 fn cast(syntax: SyntaxNode) -> Option<Self> { 1768 fn cast(syntax: SyntaxNode) -> Option<Self> {
3149 if Self::can_cast(syntax.kind()) { 1769 if Self::can_cast(syntax.kind()) {
3150 Some(Self { syntax }) 1770 Some(Self { syntax })
@@ -3154,8 +1774,8 @@ impl AstNode for PathExpr {
3154 } 1774 }
3155 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1775 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3156} 1776}
3157impl AstNode for LambdaExpr { 1777impl AstNode for UseTree {
3158 fn can_cast(kind: SyntaxKind) -> bool { kind == LAMBDA_EXPR } 1778 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE }
3159 fn cast(syntax: SyntaxNode) -> Option<Self> { 1779 fn cast(syntax: SyntaxNode) -> Option<Self> {
3160 if Self::can_cast(syntax.kind()) { 1780 if Self::can_cast(syntax.kind()) {
3161 Some(Self { syntax }) 1781 Some(Self { syntax })
@@ -3165,8 +1785,8 @@ impl AstNode for LambdaExpr {
3165 } 1785 }
3166 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1786 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3167} 1787}
3168impl AstNode for IfExpr { 1788impl AstNode for UseTreeList {
3169 fn can_cast(kind: SyntaxKind) -> bool { kind == IF_EXPR } 1789 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST }
3170 fn cast(syntax: SyntaxNode) -> Option<Self> { 1790 fn cast(syntax: SyntaxNode) -> Option<Self> {
3171 if Self::can_cast(syntax.kind()) { 1791 if Self::can_cast(syntax.kind()) {
3172 Some(Self { syntax }) 1792 Some(Self { syntax })
@@ -3176,8 +1796,8 @@ impl AstNode for IfExpr {
3176 } 1796 }
3177 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1797 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3178} 1798}
3179impl AstNode for LoopExpr { 1799impl AstNode for Abi {
3180 fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR } 1800 fn can_cast(kind: SyntaxKind) -> bool { kind == ABI }
3181 fn cast(syntax: SyntaxNode) -> Option<Self> { 1801 fn cast(syntax: SyntaxNode) -> Option<Self> {
3182 if Self::can_cast(syntax.kind()) { 1802 if Self::can_cast(syntax.kind()) {
3183 Some(Self { syntax }) 1803 Some(Self { syntax })
@@ -3187,8 +1807,8 @@ impl AstNode for LoopExpr {
3187 } 1807 }
3188 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1808 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3189} 1809}
3190impl AstNode for EffectExpr { 1810impl AstNode for GenericParamList {
3191 fn can_cast(kind: SyntaxKind) -> bool { kind == EFFECT_EXPR } 1811 fn can_cast(kind: SyntaxKind) -> bool { kind == GENERIC_PARAM_LIST }
3192 fn cast(syntax: SyntaxNode) -> Option<Self> { 1812 fn cast(syntax: SyntaxNode) -> Option<Self> {
3193 if Self::can_cast(syntax.kind()) { 1813 if Self::can_cast(syntax.kind()) {
3194 Some(Self { syntax }) 1814 Some(Self { syntax })
@@ -3198,8 +1818,8 @@ impl AstNode for EffectExpr {
3198 } 1818 }
3199 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1819 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3200} 1820}
3201impl AstNode for ForExpr { 1821impl AstNode for WhereClause {
3202 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_EXPR } 1822 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE }
3203 fn cast(syntax: SyntaxNode) -> Option<Self> { 1823 fn cast(syntax: SyntaxNode) -> Option<Self> {
3204 if Self::can_cast(syntax.kind()) { 1824 if Self::can_cast(syntax.kind()) {
3205 Some(Self { syntax }) 1825 Some(Self { syntax })
@@ -3209,8 +1829,8 @@ impl AstNode for ForExpr {
3209 } 1829 }
3210 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1830 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3211} 1831}
3212impl AstNode for WhileExpr { 1832impl AstNode for BlockExpr {
3213 fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_EXPR } 1833 fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR }
3214 fn cast(syntax: SyntaxNode) -> Option<Self> { 1834 fn cast(syntax: SyntaxNode) -> Option<Self> {
3215 if Self::can_cast(syntax.kind()) { 1835 if Self::can_cast(syntax.kind()) {
3216 Some(Self { syntax }) 1836 Some(Self { syntax })
@@ -3220,8 +1840,8 @@ impl AstNode for WhileExpr {
3220 } 1840 }
3221 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1841 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3222} 1842}
3223impl AstNode for ContinueExpr { 1843impl AstNode for SelfParam {
3224 fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR } 1844 fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
3225 fn cast(syntax: SyntaxNode) -> Option<Self> { 1845 fn cast(syntax: SyntaxNode) -> Option<Self> {
3226 if Self::can_cast(syntax.kind()) { 1846 if Self::can_cast(syntax.kind()) {
3227 Some(Self { syntax }) 1847 Some(Self { syntax })
@@ -3231,8 +1851,8 @@ impl AstNode for ContinueExpr {
3231 } 1851 }
3232 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1852 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3233} 1853}
3234impl AstNode for BreakExpr { 1854impl AstNode for Param {
3235 fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_EXPR } 1855 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM }
3236 fn cast(syntax: SyntaxNode) -> Option<Self> { 1856 fn cast(syntax: SyntaxNode) -> Option<Self> {
3237 if Self::can_cast(syntax.kind()) { 1857 if Self::can_cast(syntax.kind()) {
3238 Some(Self { syntax }) 1858 Some(Self { syntax })
@@ -3242,8 +1862,8 @@ impl AstNode for BreakExpr {
3242 } 1862 }
3243 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1863 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3244} 1864}
3245impl AstNode for Label { 1865impl AstNode for RecordFieldList {
3246 fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } 1866 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST }
3247 fn cast(syntax: SyntaxNode) -> Option<Self> { 1867 fn cast(syntax: SyntaxNode) -> Option<Self> {
3248 if Self::can_cast(syntax.kind()) { 1868 if Self::can_cast(syntax.kind()) {
3249 Some(Self { syntax }) 1869 Some(Self { syntax })
@@ -3253,8 +1873,8 @@ impl AstNode for Label {
3253 } 1873 }
3254 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1874 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3255} 1875}
3256impl AstNode for BlockExpr { 1876impl AstNode for TupleFieldList {
3257 fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR } 1877 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_LIST }
3258 fn cast(syntax: SyntaxNode) -> Option<Self> { 1878 fn cast(syntax: SyntaxNode) -> Option<Self> {
3259 if Self::can_cast(syntax.kind()) { 1879 if Self::can_cast(syntax.kind()) {
3260 Some(Self { syntax }) 1880 Some(Self { syntax })
@@ -3264,8 +1884,8 @@ impl AstNode for BlockExpr {
3264 } 1884 }
3265 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1885 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3266} 1886}
3267impl AstNode for ReturnExpr { 1887impl AstNode for RecordField {
3268 fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_EXPR } 1888 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD }
3269 fn cast(syntax: SyntaxNode) -> Option<Self> { 1889 fn cast(syntax: SyntaxNode) -> Option<Self> {
3270 if Self::can_cast(syntax.kind()) { 1890 if Self::can_cast(syntax.kind()) {
3271 Some(Self { syntax }) 1891 Some(Self { syntax })
@@ -3275,8 +1895,8 @@ impl AstNode for ReturnExpr {
3275 } 1895 }
3276 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1896 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3277} 1897}
3278impl AstNode for CallExpr { 1898impl AstNode for TupleField {
3279 fn can_cast(kind: SyntaxKind) -> bool { kind == CALL_EXPR } 1899 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD }
3280 fn cast(syntax: SyntaxNode) -> Option<Self> { 1900 fn cast(syntax: SyntaxNode) -> Option<Self> {
3281 if Self::can_cast(syntax.kind()) { 1901 if Self::can_cast(syntax.kind()) {
3282 Some(Self { syntax }) 1902 Some(Self { syntax })
@@ -3286,8 +1906,8 @@ impl AstNode for CallExpr {
3286 } 1906 }
3287 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1907 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3288} 1908}
3289impl AstNode for MethodCallExpr { 1909impl AstNode for VariantList {
3290 fn can_cast(kind: SyntaxKind) -> bool { kind == METHOD_CALL_EXPR } 1910 fn can_cast(kind: SyntaxKind) -> bool { kind == VARIANT_LIST }
3291 fn cast(syntax: SyntaxNode) -> Option<Self> { 1911 fn cast(syntax: SyntaxNode) -> Option<Self> {
3292 if Self::can_cast(syntax.kind()) { 1912 if Self::can_cast(syntax.kind()) {
3293 Some(Self { syntax }) 1913 Some(Self { syntax })
@@ -3297,8 +1917,8 @@ impl AstNode for MethodCallExpr {
3297 } 1917 }
3298 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1918 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3299} 1919}
3300impl AstNode for IndexExpr { 1920impl AstNode for Variant {
3301 fn can_cast(kind: SyntaxKind) -> bool { kind == INDEX_EXPR } 1921 fn can_cast(kind: SyntaxKind) -> bool { kind == VARIANT }
3302 fn cast(syntax: SyntaxNode) -> Option<Self> { 1922 fn cast(syntax: SyntaxNode) -> Option<Self> {
3303 if Self::can_cast(syntax.kind()) { 1923 if Self::can_cast(syntax.kind()) {
3304 Some(Self { syntax }) 1924 Some(Self { syntax })
@@ -3308,8 +1928,8 @@ impl AstNode for IndexExpr {
3308 } 1928 }
3309 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1929 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3310} 1930}
3311impl AstNode for FieldExpr { 1931impl AstNode for AssocItemList {
3312 fn can_cast(kind: SyntaxKind) -> bool { kind == FIELD_EXPR } 1932 fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_ITEM_LIST }
3313 fn cast(syntax: SyntaxNode) -> Option<Self> { 1933 fn cast(syntax: SyntaxNode) -> Option<Self> {
3314 if Self::can_cast(syntax.kind()) { 1934 if Self::can_cast(syntax.kind()) {
3315 Some(Self { syntax }) 1935 Some(Self { syntax })
@@ -3319,8 +1939,8 @@ impl AstNode for FieldExpr {
3319 } 1939 }
3320 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1940 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3321} 1941}
3322impl AstNode for AwaitExpr { 1942impl AstNode for ExternItemList {
3323 fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_EXPR } 1943 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST }
3324 fn cast(syntax: SyntaxNode) -> Option<Self> { 1944 fn cast(syntax: SyntaxNode) -> Option<Self> {
3325 if Self::can_cast(syntax.kind()) { 1945 if Self::can_cast(syntax.kind()) {
3326 Some(Self { syntax }) 1946 Some(Self { syntax })
@@ -3330,8 +1950,8 @@ impl AstNode for AwaitExpr {
3330 } 1950 }
3331 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1951 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3332} 1952}
3333impl AstNode for TryExpr { 1953impl AstNode for ConstParam {
3334 fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_EXPR } 1954 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_PARAM }
3335 fn cast(syntax: SyntaxNode) -> Option<Self> { 1955 fn cast(syntax: SyntaxNode) -> Option<Self> {
3336 if Self::can_cast(syntax.kind()) { 1956 if Self::can_cast(syntax.kind()) {
3337 Some(Self { syntax }) 1957 Some(Self { syntax })
@@ -3341,8 +1961,8 @@ impl AstNode for TryExpr {
3341 } 1961 }
3342 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1962 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3343} 1963}
3344impl AstNode for CastExpr { 1964impl AstNode for LifetimeParam {
3345 fn can_cast(kind: SyntaxKind) -> bool { kind == CAST_EXPR } 1965 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_PARAM }
3346 fn cast(syntax: SyntaxNode) -> Option<Self> { 1966 fn cast(syntax: SyntaxNode) -> Option<Self> {
3347 if Self::can_cast(syntax.kind()) { 1967 if Self::can_cast(syntax.kind()) {
3348 Some(Self { syntax }) 1968 Some(Self { syntax })
@@ -3352,8 +1972,8 @@ impl AstNode for CastExpr {
3352 } 1972 }
3353 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1973 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3354} 1974}
3355impl AstNode for RefExpr { 1975impl AstNode for TypeParam {
3356 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_EXPR } 1976 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM }
3357 fn cast(syntax: SyntaxNode) -> Option<Self> { 1977 fn cast(syntax: SyntaxNode) -> Option<Self> {
3358 if Self::can_cast(syntax.kind()) { 1978 if Self::can_cast(syntax.kind()) {
3359 Some(Self { syntax }) 1979 Some(Self { syntax })
@@ -3363,8 +1983,8 @@ impl AstNode for RefExpr {
3363 } 1983 }
3364 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1984 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3365} 1985}
3366impl AstNode for PrefixExpr { 1986impl AstNode for WherePred {
3367 fn can_cast(kind: SyntaxKind) -> bool { kind == PREFIX_EXPR } 1987 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_PRED }
3368 fn cast(syntax: SyntaxNode) -> Option<Self> { 1988 fn cast(syntax: SyntaxNode) -> Option<Self> {
3369 if Self::can_cast(syntax.kind()) { 1989 if Self::can_cast(syntax.kind()) {
3370 Some(Self { syntax }) 1990 Some(Self { syntax })
@@ -3374,8 +1994,8 @@ impl AstNode for PrefixExpr {
3374 } 1994 }
3375 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1995 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3376} 1996}
3377impl AstNode for BoxExpr { 1997impl AstNode for Literal {
3378 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_EXPR } 1998 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL }
3379 fn cast(syntax: SyntaxNode) -> Option<Self> { 1999 fn cast(syntax: SyntaxNode) -> Option<Self> {
3380 if Self::can_cast(syntax.kind()) { 2000 if Self::can_cast(syntax.kind()) {
3381 Some(Self { syntax }) 2001 Some(Self { syntax })
@@ -3385,8 +2005,8 @@ impl AstNode for BoxExpr {
3385 } 2005 }
3386 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2006 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3387} 2007}
3388impl AstNode for RangeExpr { 2008impl AstNode for ExprStmt {
3389 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_EXPR } 2009 fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT }
3390 fn cast(syntax: SyntaxNode) -> Option<Self> { 2010 fn cast(syntax: SyntaxNode) -> Option<Self> {
3391 if Self::can_cast(syntax.kind()) { 2011 if Self::can_cast(syntax.kind()) {
3392 Some(Self { syntax }) 2012 Some(Self { syntax })
@@ -3396,8 +2016,8 @@ impl AstNode for RangeExpr {
3396 } 2016 }
3397 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2017 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3398} 2018}
3399impl AstNode for BinExpr { 2019impl AstNode for LetStmt {
3400 fn can_cast(kind: SyntaxKind) -> bool { kind == BIN_EXPR } 2020 fn can_cast(kind: SyntaxKind) -> bool { kind == LET_STMT }
3401 fn cast(syntax: SyntaxNode) -> Option<Self> { 2021 fn cast(syntax: SyntaxNode) -> Option<Self> {
3402 if Self::can_cast(syntax.kind()) { 2022 if Self::can_cast(syntax.kind()) {
3403 Some(Self { syntax }) 2023 Some(Self { syntax })
@@ -3407,8 +2027,8 @@ impl AstNode for BinExpr {
3407 } 2027 }
3408 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2028 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3409} 2029}
3410impl AstNode for Literal { 2030impl AstNode for ArrayExpr {
3411 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } 2031 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_EXPR }
3412 fn cast(syntax: SyntaxNode) -> Option<Self> { 2032 fn cast(syntax: SyntaxNode) -> Option<Self> {
3413 if Self::can_cast(syntax.kind()) { 2033 if Self::can_cast(syntax.kind()) {
3414 Some(Self { syntax }) 2034 Some(Self { syntax })
@@ -3418,8 +2038,8 @@ impl AstNode for Literal {
3418 } 2038 }
3419 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2039 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3420} 2040}
3421impl AstNode for MatchExpr { 2041impl AstNode for AwaitExpr {
3422 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_EXPR } 2042 fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_EXPR }
3423 fn cast(syntax: SyntaxNode) -> Option<Self> { 2043 fn cast(syntax: SyntaxNode) -> Option<Self> {
3424 if Self::can_cast(syntax.kind()) { 2044 if Self::can_cast(syntax.kind()) {
3425 Some(Self { syntax }) 2045 Some(Self { syntax })
@@ -3429,8 +2049,8 @@ impl AstNode for MatchExpr {
3429 } 2049 }
3430 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2050 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3431} 2051}
3432impl AstNode for MatchArmList { 2052impl AstNode for BinExpr {
3433 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM_LIST } 2053 fn can_cast(kind: SyntaxKind) -> bool { kind == BIN_EXPR }
3434 fn cast(syntax: SyntaxNode) -> Option<Self> { 2054 fn cast(syntax: SyntaxNode) -> Option<Self> {
3435 if Self::can_cast(syntax.kind()) { 2055 if Self::can_cast(syntax.kind()) {
3436 Some(Self { syntax }) 2056 Some(Self { syntax })
@@ -3440,8 +2060,8 @@ impl AstNode for MatchArmList {
3440 } 2060 }
3441 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2061 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3442} 2062}
3443impl AstNode for MatchArm { 2063impl AstNode for BoxExpr {
3444 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM } 2064 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_EXPR }
3445 fn cast(syntax: SyntaxNode) -> Option<Self> { 2065 fn cast(syntax: SyntaxNode) -> Option<Self> {
3446 if Self::can_cast(syntax.kind()) { 2066 if Self::can_cast(syntax.kind()) {
3447 Some(Self { syntax }) 2067 Some(Self { syntax })
@@ -3451,8 +2071,8 @@ impl AstNode for MatchArm {
3451 } 2071 }
3452 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2072 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3453} 2073}
3454impl AstNode for MatchGuard { 2074impl AstNode for BreakExpr {
3455 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_GUARD } 2075 fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_EXPR }
3456 fn cast(syntax: SyntaxNode) -> Option<Self> { 2076 fn cast(syntax: SyntaxNode) -> Option<Self> {
3457 if Self::can_cast(syntax.kind()) { 2077 if Self::can_cast(syntax.kind()) {
3458 Some(Self { syntax }) 2078 Some(Self { syntax })
@@ -3462,8 +2082,8 @@ impl AstNode for MatchGuard {
3462 } 2082 }
3463 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2083 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3464} 2084}
3465impl AstNode for RecordLit { 2085impl AstNode for CallExpr {
3466 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_LIT } 2086 fn can_cast(kind: SyntaxKind) -> bool { kind == CALL_EXPR }
3467 fn cast(syntax: SyntaxNode) -> Option<Self> { 2087 fn cast(syntax: SyntaxNode) -> Option<Self> {
3468 if Self::can_cast(syntax.kind()) { 2088 if Self::can_cast(syntax.kind()) {
3469 Some(Self { syntax }) 2089 Some(Self { syntax })
@@ -3473,8 +2093,8 @@ impl AstNode for RecordLit {
3473 } 2093 }
3474 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2094 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3475} 2095}
3476impl AstNode for RecordFieldList { 2096impl AstNode for CastExpr {
3477 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST } 2097 fn can_cast(kind: SyntaxKind) -> bool { kind == CAST_EXPR }
3478 fn cast(syntax: SyntaxNode) -> Option<Self> { 2098 fn cast(syntax: SyntaxNode) -> Option<Self> {
3479 if Self::can_cast(syntax.kind()) { 2099 if Self::can_cast(syntax.kind()) {
3480 Some(Self { syntax }) 2100 Some(Self { syntax })
@@ -3484,8 +2104,8 @@ impl AstNode for RecordFieldList {
3484 } 2104 }
3485 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2105 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3486} 2106}
3487impl AstNode for RecordField { 2107impl AstNode for ClosureExpr {
3488 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD } 2108 fn can_cast(kind: SyntaxKind) -> bool { kind == CLOSURE_EXPR }
3489 fn cast(syntax: SyntaxNode) -> Option<Self> { 2109 fn cast(syntax: SyntaxNode) -> Option<Self> {
3490 if Self::can_cast(syntax.kind()) { 2110 if Self::can_cast(syntax.kind()) {
3491 Some(Self { syntax }) 2111 Some(Self { syntax })
@@ -3495,8 +2115,8 @@ impl AstNode for RecordField {
3495 } 2115 }
3496 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2116 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3497} 2117}
3498impl AstNode for OrPat { 2118impl AstNode for ContinueExpr {
3499 fn can_cast(kind: SyntaxKind) -> bool { kind == OR_PAT } 2119 fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR }
3500 fn cast(syntax: SyntaxNode) -> Option<Self> { 2120 fn cast(syntax: SyntaxNode) -> Option<Self> {
3501 if Self::can_cast(syntax.kind()) { 2121 if Self::can_cast(syntax.kind()) {
3502 Some(Self { syntax }) 2122 Some(Self { syntax })
@@ -3506,8 +2126,8 @@ impl AstNode for OrPat {
3506 } 2126 }
3507 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2127 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3508} 2128}
3509impl AstNode for ParenPat { 2129impl AstNode for EffectExpr {
3510 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_PAT } 2130 fn can_cast(kind: SyntaxKind) -> bool { kind == EFFECT_EXPR }
3511 fn cast(syntax: SyntaxNode) -> Option<Self> { 2131 fn cast(syntax: SyntaxNode) -> Option<Self> {
3512 if Self::can_cast(syntax.kind()) { 2132 if Self::can_cast(syntax.kind()) {
3513 Some(Self { syntax }) 2133 Some(Self { syntax })
@@ -3517,8 +2137,8 @@ impl AstNode for ParenPat {
3517 } 2137 }
3518 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2138 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3519} 2139}
3520impl AstNode for RefPat { 2140impl AstNode for FieldExpr {
3521 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_PAT } 2141 fn can_cast(kind: SyntaxKind) -> bool { kind == FIELD_EXPR }
3522 fn cast(syntax: SyntaxNode) -> Option<Self> { 2142 fn cast(syntax: SyntaxNode) -> Option<Self> {
3523 if Self::can_cast(syntax.kind()) { 2143 if Self::can_cast(syntax.kind()) {
3524 Some(Self { syntax }) 2144 Some(Self { syntax })
@@ -3528,8 +2148,8 @@ impl AstNode for RefPat {
3528 } 2148 }
3529 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2149 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3530} 2150}
3531impl AstNode for BoxPat { 2151impl AstNode for ForExpr {
3532 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_PAT } 2152 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_EXPR }
3533 fn cast(syntax: SyntaxNode) -> Option<Self> { 2153 fn cast(syntax: SyntaxNode) -> Option<Self> {
3534 if Self::can_cast(syntax.kind()) { 2154 if Self::can_cast(syntax.kind()) {
3535 Some(Self { syntax }) 2155 Some(Self { syntax })
@@ -3539,8 +2159,8 @@ impl AstNode for BoxPat {
3539 } 2159 }
3540 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2160 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3541} 2161}
3542impl AstNode for BindPat { 2162impl AstNode for IfExpr {
3543 fn can_cast(kind: SyntaxKind) -> bool { kind == BIND_PAT } 2163 fn can_cast(kind: SyntaxKind) -> bool { kind == IF_EXPR }
3544 fn cast(syntax: SyntaxNode) -> Option<Self> { 2164 fn cast(syntax: SyntaxNode) -> Option<Self> {
3545 if Self::can_cast(syntax.kind()) { 2165 if Self::can_cast(syntax.kind()) {
3546 Some(Self { syntax }) 2166 Some(Self { syntax })
@@ -3550,8 +2170,8 @@ impl AstNode for BindPat {
3550 } 2170 }
3551 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2171 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3552} 2172}
3553impl AstNode for PlaceholderPat { 2173impl AstNode for IndexExpr {
3554 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_PAT } 2174 fn can_cast(kind: SyntaxKind) -> bool { kind == INDEX_EXPR }
3555 fn cast(syntax: SyntaxNode) -> Option<Self> { 2175 fn cast(syntax: SyntaxNode) -> Option<Self> {
3556 if Self::can_cast(syntax.kind()) { 2176 if Self::can_cast(syntax.kind()) {
3557 Some(Self { syntax }) 2177 Some(Self { syntax })
@@ -3561,8 +2181,8 @@ impl AstNode for PlaceholderPat {
3561 } 2181 }
3562 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2182 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3563} 2183}
3564impl AstNode for DotDotPat { 2184impl AstNode for LoopExpr {
3565 fn can_cast(kind: SyntaxKind) -> bool { kind == DOT_DOT_PAT } 2185 fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR }
3566 fn cast(syntax: SyntaxNode) -> Option<Self> { 2186 fn cast(syntax: SyntaxNode) -> Option<Self> {
3567 if Self::can_cast(syntax.kind()) { 2187 if Self::can_cast(syntax.kind()) {
3568 Some(Self { syntax }) 2188 Some(Self { syntax })
@@ -3572,8 +2192,8 @@ impl AstNode for DotDotPat {
3572 } 2192 }
3573 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2193 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3574} 2194}
3575impl AstNode for PathPat { 2195impl AstNode for MatchExpr {
3576 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_PAT } 2196 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_EXPR }
3577 fn cast(syntax: SyntaxNode) -> Option<Self> { 2197 fn cast(syntax: SyntaxNode) -> Option<Self> {
3578 if Self::can_cast(syntax.kind()) { 2198 if Self::can_cast(syntax.kind()) {
3579 Some(Self { syntax }) 2199 Some(Self { syntax })
@@ -3583,8 +2203,8 @@ impl AstNode for PathPat {
3583 } 2203 }
3584 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2204 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3585} 2205}
3586impl AstNode for SlicePat { 2206impl AstNode for MethodCallExpr {
3587 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_PAT } 2207 fn can_cast(kind: SyntaxKind) -> bool { kind == METHOD_CALL_EXPR }
3588 fn cast(syntax: SyntaxNode) -> Option<Self> { 2208 fn cast(syntax: SyntaxNode) -> Option<Self> {
3589 if Self::can_cast(syntax.kind()) { 2209 if Self::can_cast(syntax.kind()) {
3590 Some(Self { syntax }) 2210 Some(Self { syntax })
@@ -3594,8 +2214,8 @@ impl AstNode for SlicePat {
3594 } 2214 }
3595 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2215 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3596} 2216}
3597impl AstNode for RangePat { 2217impl AstNode for ParenExpr {
3598 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_PAT } 2218 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_EXPR }
3599 fn cast(syntax: SyntaxNode) -> Option<Self> { 2219 fn cast(syntax: SyntaxNode) -> Option<Self> {
3600 if Self::can_cast(syntax.kind()) { 2220 if Self::can_cast(syntax.kind()) {
3601 Some(Self { syntax }) 2221 Some(Self { syntax })
@@ -3605,8 +2225,8 @@ impl AstNode for RangePat {
3605 } 2225 }
3606 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2226 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3607} 2227}
3608impl AstNode for LiteralPat { 2228impl AstNode for PathExpr {
3609 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL_PAT } 2229 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_EXPR }
3610 fn cast(syntax: SyntaxNode) -> Option<Self> { 2230 fn cast(syntax: SyntaxNode) -> Option<Self> {
3611 if Self::can_cast(syntax.kind()) { 2231 if Self::can_cast(syntax.kind()) {
3612 Some(Self { syntax }) 2232 Some(Self { syntax })
@@ -3616,8 +2236,8 @@ impl AstNode for LiteralPat {
3616 } 2236 }
3617 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2237 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3618} 2238}
3619impl AstNode for MacroPat { 2239impl AstNode for PrefixExpr {
3620 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_PAT } 2240 fn can_cast(kind: SyntaxKind) -> bool { kind == PREFIX_EXPR }
3621 fn cast(syntax: SyntaxNode) -> Option<Self> { 2241 fn cast(syntax: SyntaxNode) -> Option<Self> {
3622 if Self::can_cast(syntax.kind()) { 2242 if Self::can_cast(syntax.kind()) {
3623 Some(Self { syntax }) 2243 Some(Self { syntax })
@@ -3627,8 +2247,8 @@ impl AstNode for MacroPat {
3627 } 2247 }
3628 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2248 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3629} 2249}
3630impl AstNode for RecordPat { 2250impl AstNode for RangeExpr {
3631 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT } 2251 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_EXPR }
3632 fn cast(syntax: SyntaxNode) -> Option<Self> { 2252 fn cast(syntax: SyntaxNode) -> Option<Self> {
3633 if Self::can_cast(syntax.kind()) { 2253 if Self::can_cast(syntax.kind()) {
3634 Some(Self { syntax }) 2254 Some(Self { syntax })
@@ -3638,8 +2258,8 @@ impl AstNode for RecordPat {
3638 } 2258 }
3639 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2259 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3640} 2260}
3641impl AstNode for RecordFieldPatList { 2261impl AstNode for RecordExpr {
3642 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT_LIST } 2262 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR }
3643 fn cast(syntax: SyntaxNode) -> Option<Self> { 2263 fn cast(syntax: SyntaxNode) -> Option<Self> {
3644 if Self::can_cast(syntax.kind()) { 2264 if Self::can_cast(syntax.kind()) {
3645 Some(Self { syntax }) 2265 Some(Self { syntax })
@@ -3649,8 +2269,8 @@ impl AstNode for RecordFieldPatList {
3649 } 2269 }
3650 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2270 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3651} 2271}
3652impl AstNode for RecordFieldPat { 2272impl AstNode for RefExpr {
3653 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT } 2273 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_EXPR }
3654 fn cast(syntax: SyntaxNode) -> Option<Self> { 2274 fn cast(syntax: SyntaxNode) -> Option<Self> {
3655 if Self::can_cast(syntax.kind()) { 2275 if Self::can_cast(syntax.kind()) {
3656 Some(Self { syntax }) 2276 Some(Self { syntax })
@@ -3660,8 +2280,8 @@ impl AstNode for RecordFieldPat {
3660 } 2280 }
3661 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2281 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3662} 2282}
3663impl AstNode for TupleStructPat { 2283impl AstNode for ReturnExpr {
3664 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_STRUCT_PAT } 2284 fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_EXPR }
3665 fn cast(syntax: SyntaxNode) -> Option<Self> { 2285 fn cast(syntax: SyntaxNode) -> Option<Self> {
3666 if Self::can_cast(syntax.kind()) { 2286 if Self::can_cast(syntax.kind()) {
3667 Some(Self { syntax }) 2287 Some(Self { syntax })
@@ -3671,8 +2291,8 @@ impl AstNode for TupleStructPat {
3671 } 2291 }
3672 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2292 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3673} 2293}
3674impl AstNode for TuplePat { 2294impl AstNode for TryExpr {
3675 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_PAT } 2295 fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_EXPR }
3676 fn cast(syntax: SyntaxNode) -> Option<Self> { 2296 fn cast(syntax: SyntaxNode) -> Option<Self> {
3677 if Self::can_cast(syntax.kind()) { 2297 if Self::can_cast(syntax.kind()) {
3678 Some(Self { syntax }) 2298 Some(Self { syntax })
@@ -3682,8 +2302,8 @@ impl AstNode for TuplePat {
3682 } 2302 }
3683 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2303 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3684} 2304}
3685impl AstNode for Visibility { 2305impl AstNode for TupleExpr {
3686 fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY } 2306 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_EXPR }
3687 fn cast(syntax: SyntaxNode) -> Option<Self> { 2307 fn cast(syntax: SyntaxNode) -> Option<Self> {
3688 if Self::can_cast(syntax.kind()) { 2308 if Self::can_cast(syntax.kind()) {
3689 Some(Self { syntax }) 2309 Some(Self { syntax })
@@ -3693,8 +2313,8 @@ impl AstNode for Visibility {
3693 } 2313 }
3694 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2314 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3695} 2315}
3696impl AstNode for Name { 2316impl AstNode for WhileExpr {
3697 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME } 2317 fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_EXPR }
3698 fn cast(syntax: SyntaxNode) -> Option<Self> { 2318 fn cast(syntax: SyntaxNode) -> Option<Self> {
3699 if Self::can_cast(syntax.kind()) { 2319 if Self::can_cast(syntax.kind()) {
3700 Some(Self { syntax }) 2320 Some(Self { syntax })
@@ -3704,8 +2324,8 @@ impl AstNode for Name {
3704 } 2324 }
3705 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2325 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3706} 2326}
3707impl AstNode for NameRef { 2327impl AstNode for Label {
3708 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } 2328 fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL }
3709 fn cast(syntax: SyntaxNode) -> Option<Self> { 2329 fn cast(syntax: SyntaxNode) -> Option<Self> {
3710 if Self::can_cast(syntax.kind()) { 2330 if Self::can_cast(syntax.kind()) {
3711 Some(Self { syntax }) 2331 Some(Self { syntax })
@@ -3715,8 +2335,8 @@ impl AstNode for NameRef {
3715 } 2335 }
3716 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2336 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3717} 2337}
3718impl AstNode for MacroCall { 2338impl AstNode for RecordExprFieldList {
3719 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL } 2339 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD_LIST }
3720 fn cast(syntax: SyntaxNode) -> Option<Self> { 2340 fn cast(syntax: SyntaxNode) -> Option<Self> {
3721 if Self::can_cast(syntax.kind()) { 2341 if Self::can_cast(syntax.kind()) {
3722 Some(Self { syntax }) 2342 Some(Self { syntax })
@@ -3726,8 +2346,8 @@ impl AstNode for MacroCall {
3726 } 2346 }
3727 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2347 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3728} 2348}
3729impl AstNode for Attr { 2349impl AstNode for RecordExprField {
3730 fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR } 2350 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD }
3731 fn cast(syntax: SyntaxNode) -> Option<Self> { 2351 fn cast(syntax: SyntaxNode) -> Option<Self> {
3732 if Self::can_cast(syntax.kind()) { 2352 if Self::can_cast(syntax.kind()) {
3733 Some(Self { syntax }) 2353 Some(Self { syntax })
@@ -3737,8 +2357,8 @@ impl AstNode for Attr {
3737 } 2357 }
3738 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2358 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3739} 2359}
3740impl AstNode for TokenTree { 2360impl AstNode for ArgList {
3741 fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE } 2361 fn can_cast(kind: SyntaxKind) -> bool { kind == ARG_LIST }
3742 fn cast(syntax: SyntaxNode) -> Option<Self> { 2362 fn cast(syntax: SyntaxNode) -> Option<Self> {
3743 if Self::can_cast(syntax.kind()) { 2363 if Self::can_cast(syntax.kind()) {
3744 Some(Self { syntax }) 2364 Some(Self { syntax })
@@ -3748,8 +2368,8 @@ impl AstNode for TokenTree {
3748 } 2368 }
3749 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2369 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3750} 2370}
3751impl AstNode for TypeParamList { 2371impl AstNode for Condition {
3752 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST } 2372 fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION }
3753 fn cast(syntax: SyntaxNode) -> Option<Self> { 2373 fn cast(syntax: SyntaxNode) -> Option<Self> {
3754 if Self::can_cast(syntax.kind()) { 2374 if Self::can_cast(syntax.kind()) {
3755 Some(Self { syntax }) 2375 Some(Self { syntax })
@@ -3759,8 +2379,8 @@ impl AstNode for TypeParamList {
3759 } 2379 }
3760 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2380 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3761} 2381}
3762impl AstNode for TypeParam { 2382impl AstNode for MatchArmList {
3763 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM } 2383 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM_LIST }
3764 fn cast(syntax: SyntaxNode) -> Option<Self> { 2384 fn cast(syntax: SyntaxNode) -> Option<Self> {
3765 if Self::can_cast(syntax.kind()) { 2385 if Self::can_cast(syntax.kind()) {
3766 Some(Self { syntax }) 2386 Some(Self { syntax })
@@ -3770,8 +2390,8 @@ impl AstNode for TypeParam {
3770 } 2390 }
3771 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2391 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3772} 2392}
3773impl AstNode for ConstParam { 2393impl AstNode for MatchArm {
3774 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_PARAM } 2394 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM }
3775 fn cast(syntax: SyntaxNode) -> Option<Self> { 2395 fn cast(syntax: SyntaxNode) -> Option<Self> {
3776 if Self::can_cast(syntax.kind()) { 2396 if Self::can_cast(syntax.kind()) {
3777 Some(Self { syntax }) 2397 Some(Self { syntax })
@@ -3781,8 +2401,8 @@ impl AstNode for ConstParam {
3781 } 2401 }
3782 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2402 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3783} 2403}
3784impl AstNode for LifetimeParam { 2404impl AstNode for MatchGuard {
3785 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_PARAM } 2405 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_GUARD }
3786 fn cast(syntax: SyntaxNode) -> Option<Self> { 2406 fn cast(syntax: SyntaxNode) -> Option<Self> {
3787 if Self::can_cast(syntax.kind()) { 2407 if Self::can_cast(syntax.kind()) {
3788 Some(Self { syntax }) 2408 Some(Self { syntax })
@@ -3792,8 +2412,8 @@ impl AstNode for LifetimeParam {
3792 } 2412 }
3793 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2413 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3794} 2414}
3795impl AstNode for TypeBound { 2415impl AstNode for ArrayType {
3796 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND } 2416 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_TYPE }
3797 fn cast(syntax: SyntaxNode) -> Option<Self> { 2417 fn cast(syntax: SyntaxNode) -> Option<Self> {
3798 if Self::can_cast(syntax.kind()) { 2418 if Self::can_cast(syntax.kind()) {
3799 Some(Self { syntax }) 2419 Some(Self { syntax })
@@ -3803,8 +2423,8 @@ impl AstNode for TypeBound {
3803 } 2423 }
3804 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2424 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3805} 2425}
3806impl AstNode for TypeBoundList { 2426impl AstNode for DynTraitType {
3807 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } 2427 fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_TRAIT_TYPE }
3808 fn cast(syntax: SyntaxNode) -> Option<Self> { 2428 fn cast(syntax: SyntaxNode) -> Option<Self> {
3809 if Self::can_cast(syntax.kind()) { 2429 if Self::can_cast(syntax.kind()) {
3810 Some(Self { syntax }) 2430 Some(Self { syntax })
@@ -3814,8 +2434,8 @@ impl AstNode for TypeBoundList {
3814 } 2434 }
3815 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2435 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3816} 2436}
3817impl AstNode for WherePred { 2437impl AstNode for FnPtrType {
3818 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_PRED } 2438 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_PTR_TYPE }
3819 fn cast(syntax: SyntaxNode) -> Option<Self> { 2439 fn cast(syntax: SyntaxNode) -> Option<Self> {
3820 if Self::can_cast(syntax.kind()) { 2440 if Self::can_cast(syntax.kind()) {
3821 Some(Self { syntax }) 2441 Some(Self { syntax })
@@ -3825,8 +2445,8 @@ impl AstNode for WherePred {
3825 } 2445 }
3826 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2446 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3827} 2447}
3828impl AstNode for WhereClause { 2448impl AstNode for ForType {
3829 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } 2449 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_TYPE }
3830 fn cast(syntax: SyntaxNode) -> Option<Self> { 2450 fn cast(syntax: SyntaxNode) -> Option<Self> {
3831 if Self::can_cast(syntax.kind()) { 2451 if Self::can_cast(syntax.kind()) {
3832 Some(Self { syntax }) 2452 Some(Self { syntax })
@@ -3836,8 +2456,8 @@ impl AstNode for WhereClause {
3836 } 2456 }
3837 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2457 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3838} 2458}
3839impl AstNode for Abi { 2459impl AstNode for ImplTraitType {
3840 fn can_cast(kind: SyntaxKind) -> bool { kind == ABI } 2460 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_TRAIT_TYPE }
3841 fn cast(syntax: SyntaxNode) -> Option<Self> { 2461 fn cast(syntax: SyntaxNode) -> Option<Self> {
3842 if Self::can_cast(syntax.kind()) { 2462 if Self::can_cast(syntax.kind()) {
3843 Some(Self { syntax }) 2463 Some(Self { syntax })
@@ -3847,8 +2467,8 @@ impl AstNode for Abi {
3847 } 2467 }
3848 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2468 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3849} 2469}
3850impl AstNode for ExprStmt { 2470impl AstNode for InferType {
3851 fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT } 2471 fn can_cast(kind: SyntaxKind) -> bool { kind == INFER_TYPE }
3852 fn cast(syntax: SyntaxNode) -> Option<Self> { 2472 fn cast(syntax: SyntaxNode) -> Option<Self> {
3853 if Self::can_cast(syntax.kind()) { 2473 if Self::can_cast(syntax.kind()) {
3854 Some(Self { syntax }) 2474 Some(Self { syntax })
@@ -3858,8 +2478,8 @@ impl AstNode for ExprStmt {
3858 } 2478 }
3859 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2479 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3860} 2480}
3861impl AstNode for LetStmt { 2481impl AstNode for NeverType {
3862 fn can_cast(kind: SyntaxKind) -> bool { kind == LET_STMT } 2482 fn can_cast(kind: SyntaxKind) -> bool { kind == NEVER_TYPE }
3863 fn cast(syntax: SyntaxNode) -> Option<Self> { 2483 fn cast(syntax: SyntaxNode) -> Option<Self> {
3864 if Self::can_cast(syntax.kind()) { 2484 if Self::can_cast(syntax.kind()) {
3865 Some(Self { syntax }) 2485 Some(Self { syntax })
@@ -3869,8 +2489,8 @@ impl AstNode for LetStmt {
3869 } 2489 }
3870 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2490 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3871} 2491}
3872impl AstNode for Condition { 2492impl AstNode for ParenType {
3873 fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION } 2493 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE }
3874 fn cast(syntax: SyntaxNode) -> Option<Self> { 2494 fn cast(syntax: SyntaxNode) -> Option<Self> {
3875 if Self::can_cast(syntax.kind()) { 2495 if Self::can_cast(syntax.kind()) {
3876 Some(Self { syntax }) 2496 Some(Self { syntax })
@@ -3880,8 +2500,8 @@ impl AstNode for Condition {
3880 } 2500 }
3881 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2501 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3882} 2502}
3883impl AstNode for ParamList { 2503impl AstNode for PtrType {
3884 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } 2504 fn can_cast(kind: SyntaxKind) -> bool { kind == PTR_TYPE }
3885 fn cast(syntax: SyntaxNode) -> Option<Self> { 2505 fn cast(syntax: SyntaxNode) -> Option<Self> {
3886 if Self::can_cast(syntax.kind()) { 2506 if Self::can_cast(syntax.kind()) {
3887 Some(Self { syntax }) 2507 Some(Self { syntax })
@@ -3891,8 +2511,8 @@ impl AstNode for ParamList {
3891 } 2511 }
3892 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2512 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3893} 2513}
3894impl AstNode for SelfParam { 2514impl AstNode for RefType {
3895 fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } 2515 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_TYPE }
3896 fn cast(syntax: SyntaxNode) -> Option<Self> { 2516 fn cast(syntax: SyntaxNode) -> Option<Self> {
3897 if Self::can_cast(syntax.kind()) { 2517 if Self::can_cast(syntax.kind()) {
3898 Some(Self { syntax }) 2518 Some(Self { syntax })
@@ -3902,8 +2522,8 @@ impl AstNode for SelfParam {
3902 } 2522 }
3903 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2523 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3904} 2524}
3905impl AstNode for Param { 2525impl AstNode for SliceType {
3906 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } 2526 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_TYPE }
3907 fn cast(syntax: SyntaxNode) -> Option<Self> { 2527 fn cast(syntax: SyntaxNode) -> Option<Self> {
3908 if Self::can_cast(syntax.kind()) { 2528 if Self::can_cast(syntax.kind()) {
3909 Some(Self { syntax }) 2529 Some(Self { syntax })
@@ -3913,8 +2533,8 @@ impl AstNode for Param {
3913 } 2533 }
3914 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2534 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3915} 2535}
3916impl AstNode for UseItem { 2536impl AstNode for TupleType {
3917 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM } 2537 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_TYPE }
3918 fn cast(syntax: SyntaxNode) -> Option<Self> { 2538 fn cast(syntax: SyntaxNode) -> Option<Self> {
3919 if Self::can_cast(syntax.kind()) { 2539 if Self::can_cast(syntax.kind()) {
3920 Some(Self { syntax }) 2540 Some(Self { syntax })
@@ -3924,8 +2544,8 @@ impl AstNode for UseItem {
3924 } 2544 }
3925 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2545 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3926} 2546}
3927impl AstNode for UseTree { 2547impl AstNode for TypeBound {
3928 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE } 2548 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND }
3929 fn cast(syntax: SyntaxNode) -> Option<Self> { 2549 fn cast(syntax: SyntaxNode) -> Option<Self> {
3930 if Self::can_cast(syntax.kind()) { 2550 if Self::can_cast(syntax.kind()) {
3931 Some(Self { syntax }) 2551 Some(Self { syntax })
@@ -3935,8 +2555,8 @@ impl AstNode for UseTree {
3935 } 2555 }
3936 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2556 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3937} 2557}
3938impl AstNode for Alias { 2558impl AstNode for IdentPat {
3939 fn can_cast(kind: SyntaxKind) -> bool { kind == ALIAS } 2559 fn can_cast(kind: SyntaxKind) -> bool { kind == IDENT_PAT }
3940 fn cast(syntax: SyntaxNode) -> Option<Self> { 2560 fn cast(syntax: SyntaxNode) -> Option<Self> {
3941 if Self::can_cast(syntax.kind()) { 2561 if Self::can_cast(syntax.kind()) {
3942 Some(Self { syntax }) 2562 Some(Self { syntax })
@@ -3946,8 +2566,8 @@ impl AstNode for Alias {
3946 } 2566 }
3947 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2567 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3948} 2568}
3949impl AstNode for UseTreeList { 2569impl AstNode for BoxPat {
3950 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST } 2570 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_PAT }
3951 fn cast(syntax: SyntaxNode) -> Option<Self> { 2571 fn cast(syntax: SyntaxNode) -> Option<Self> {
3952 if Self::can_cast(syntax.kind()) { 2572 if Self::can_cast(syntax.kind()) {
3953 Some(Self { syntax }) 2573 Some(Self { syntax })
@@ -3957,8 +2577,8 @@ impl AstNode for UseTreeList {
3957 } 2577 }
3958 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2578 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3959} 2579}
3960impl AstNode for ExternCrateItem { 2580impl AstNode for RestPat {
3961 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM } 2581 fn can_cast(kind: SyntaxKind) -> bool { kind == REST_PAT }
3962 fn cast(syntax: SyntaxNode) -> Option<Self> { 2582 fn cast(syntax: SyntaxNode) -> Option<Self> {
3963 if Self::can_cast(syntax.kind()) { 2583 if Self::can_cast(syntax.kind()) {
3964 Some(Self { syntax }) 2584 Some(Self { syntax })
@@ -3968,8 +2588,8 @@ impl AstNode for ExternCrateItem {
3968 } 2588 }
3969 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2589 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3970} 2590}
3971impl AstNode for ArgList { 2591impl AstNode for LiteralPat {
3972 fn can_cast(kind: SyntaxKind) -> bool { kind == ARG_LIST } 2592 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL_PAT }
3973 fn cast(syntax: SyntaxNode) -> Option<Self> { 2593 fn cast(syntax: SyntaxNode) -> Option<Self> {
3974 if Self::can_cast(syntax.kind()) { 2594 if Self::can_cast(syntax.kind()) {
3975 Some(Self { syntax }) 2595 Some(Self { syntax })
@@ -3979,8 +2599,8 @@ impl AstNode for ArgList {
3979 } 2599 }
3980 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2600 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3981} 2601}
3982impl AstNode for Path { 2602impl AstNode for MacroPat {
3983 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } 2603 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_PAT }
3984 fn cast(syntax: SyntaxNode) -> Option<Self> { 2604 fn cast(syntax: SyntaxNode) -> Option<Self> {
3985 if Self::can_cast(syntax.kind()) { 2605 if Self::can_cast(syntax.kind()) {
3986 Some(Self { syntax }) 2606 Some(Self { syntax })
@@ -3990,8 +2610,8 @@ impl AstNode for Path {
3990 } 2610 }
3991 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2611 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3992} 2612}
3993impl AstNode for PathSegment { 2613impl AstNode for OrPat {
3994 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } 2614 fn can_cast(kind: SyntaxKind) -> bool { kind == OR_PAT }
3995 fn cast(syntax: SyntaxNode) -> Option<Self> { 2615 fn cast(syntax: SyntaxNode) -> Option<Self> {
3996 if Self::can_cast(syntax.kind()) { 2616 if Self::can_cast(syntax.kind()) {
3997 Some(Self { syntax }) 2617 Some(Self { syntax })
@@ -4001,8 +2621,8 @@ impl AstNode for PathSegment {
4001 } 2621 }
4002 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2622 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4003} 2623}
4004impl AstNode for TypeArgList { 2624impl AstNode for ParenPat {
4005 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST } 2625 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_PAT }
4006 fn cast(syntax: SyntaxNode) -> Option<Self> { 2626 fn cast(syntax: SyntaxNode) -> Option<Self> {
4007 if Self::can_cast(syntax.kind()) { 2627 if Self::can_cast(syntax.kind()) {
4008 Some(Self { syntax }) 2628 Some(Self { syntax })
@@ -4012,8 +2632,8 @@ impl AstNode for TypeArgList {
4012 } 2632 }
4013 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2633 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4014} 2634}
4015impl AstNode for TypeArg { 2635impl AstNode for PathPat {
4016 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } 2636 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_PAT }
4017 fn cast(syntax: SyntaxNode) -> Option<Self> { 2637 fn cast(syntax: SyntaxNode) -> Option<Self> {
4018 if Self::can_cast(syntax.kind()) { 2638 if Self::can_cast(syntax.kind()) {
4019 Some(Self { syntax }) 2639 Some(Self { syntax })
@@ -4023,8 +2643,8 @@ impl AstNode for TypeArg {
4023 } 2643 }
4024 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2644 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4025} 2645}
4026impl AstNode for AssocTypeArg { 2646impl AstNode for WildcardPat {
4027 fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } 2647 fn can_cast(kind: SyntaxKind) -> bool { kind == WILDCARD_PAT }
4028 fn cast(syntax: SyntaxNode) -> Option<Self> { 2648 fn cast(syntax: SyntaxNode) -> Option<Self> {
4029 if Self::can_cast(syntax.kind()) { 2649 if Self::can_cast(syntax.kind()) {
4030 Some(Self { syntax }) 2650 Some(Self { syntax })
@@ -4034,8 +2654,8 @@ impl AstNode for AssocTypeArg {
4034 } 2654 }
4035 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2655 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4036} 2656}
4037impl AstNode for LifetimeArg { 2657impl AstNode for RangePat {
4038 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } 2658 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_PAT }
4039 fn cast(syntax: SyntaxNode) -> Option<Self> { 2659 fn cast(syntax: SyntaxNode) -> Option<Self> {
4040 if Self::can_cast(syntax.kind()) { 2660 if Self::can_cast(syntax.kind()) {
4041 Some(Self { syntax }) 2661 Some(Self { syntax })
@@ -4045,8 +2665,8 @@ impl AstNode for LifetimeArg {
4045 } 2665 }
4046 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2666 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4047} 2667}
4048impl AstNode for ConstArg { 2668impl AstNode for RecordPat {
4049 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG } 2669 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT }
4050 fn cast(syntax: SyntaxNode) -> Option<Self> { 2670 fn cast(syntax: SyntaxNode) -> Option<Self> {
4051 if Self::can_cast(syntax.kind()) { 2671 if Self::can_cast(syntax.kind()) {
4052 Some(Self { syntax }) 2672 Some(Self { syntax })
@@ -4056,8 +2676,8 @@ impl AstNode for ConstArg {
4056 } 2676 }
4057 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2677 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4058} 2678}
4059impl AstNode for MacroItems { 2679impl AstNode for RefPat {
4060 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_ITEMS } 2680 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_PAT }
4061 fn cast(syntax: SyntaxNode) -> Option<Self> { 2681 fn cast(syntax: SyntaxNode) -> Option<Self> {
4062 if Self::can_cast(syntax.kind()) { 2682 if Self::can_cast(syntax.kind()) {
4063 Some(Self { syntax }) 2683 Some(Self { syntax })
@@ -4067,8 +2687,8 @@ impl AstNode for MacroItems {
4067 } 2687 }
4068 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2688 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4069} 2689}
4070impl AstNode for MacroStmts { 2690impl AstNode for SlicePat {
4071 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS } 2691 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_PAT }
4072 fn cast(syntax: SyntaxNode) -> Option<Self> { 2692 fn cast(syntax: SyntaxNode) -> Option<Self> {
4073 if Self::can_cast(syntax.kind()) { 2693 if Self::can_cast(syntax.kind()) {
4074 Some(Self { syntax }) 2694 Some(Self { syntax })
@@ -4078,8 +2698,8 @@ impl AstNode for MacroStmts {
4078 } 2698 }
4079 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2699 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4080} 2700}
4081impl AstNode for ExternItemList { 2701impl AstNode for TuplePat {
4082 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST } 2702 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_PAT }
4083 fn cast(syntax: SyntaxNode) -> Option<Self> { 2703 fn cast(syntax: SyntaxNode) -> Option<Self> {
4084 if Self::can_cast(syntax.kind()) { 2704 if Self::can_cast(syntax.kind()) {
4085 Some(Self { syntax }) 2705 Some(Self { syntax })
@@ -4089,8 +2709,8 @@ impl AstNode for ExternItemList {
4089 } 2709 }
4090 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2710 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4091} 2711}
4092impl AstNode for ExternBlock { 2712impl AstNode for TupleStructPat {
4093 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK } 2713 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_STRUCT_PAT }
4094 fn cast(syntax: SyntaxNode) -> Option<Self> { 2714 fn cast(syntax: SyntaxNode) -> Option<Self> {
4095 if Self::can_cast(syntax.kind()) { 2715 if Self::can_cast(syntax.kind()) {
4096 Some(Self { syntax }) 2716 Some(Self { syntax })
@@ -4100,8 +2720,8 @@ impl AstNode for ExternBlock {
4100 } 2720 }
4101 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2721 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4102} 2722}
4103impl AstNode for MetaItem { 2723impl AstNode for RecordPatFieldList {
4104 fn can_cast(kind: SyntaxKind) -> bool { kind == META_ITEM } 2724 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT_FIELD_LIST }
4105 fn cast(syntax: SyntaxNode) -> Option<Self> { 2725 fn cast(syntax: SyntaxNode) -> Option<Self> {
4106 if Self::can_cast(syntax.kind()) { 2726 if Self::can_cast(syntax.kind()) {
4107 Some(Self { syntax }) 2727 Some(Self { syntax })
@@ -4111,8 +2731,8 @@ impl AstNode for MetaItem {
4111 } 2731 }
4112 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2732 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4113} 2733}
4114impl AstNode for MacroDef { 2734impl AstNode for RecordPatField {
4115 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF } 2735 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT_FIELD }
4116 fn cast(syntax: SyntaxNode) -> Option<Self> { 2736 fn cast(syntax: SyntaxNode) -> Option<Self> {
4117 if Self::can_cast(syntax.kind()) { 2737 if Self::can_cast(syntax.kind()) {
4118 Some(Self { syntax }) 2738 Some(Self { syntax })
@@ -4122,420 +2742,194 @@ impl AstNode for MacroDef {
4122 } 2742 }
4123 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2743 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4124} 2744}
4125impl From<StructDef> for NominalDef { 2745impl From<TypeArg> for GenericArg {
4126 fn from(node: StructDef) -> NominalDef { NominalDef::StructDef(node) } 2746 fn from(node: TypeArg) -> GenericArg { GenericArg::TypeArg(node) }
4127}
4128impl From<EnumDef> for NominalDef {
4129 fn from(node: EnumDef) -> NominalDef { NominalDef::EnumDef(node) }
4130}
4131impl From<UnionDef> for NominalDef {
4132 fn from(node: UnionDef) -> NominalDef { NominalDef::UnionDef(node) }
4133}
4134impl AstNode for NominalDef {
4135 fn can_cast(kind: SyntaxKind) -> bool {
4136 match kind {
4137 STRUCT_DEF | ENUM_DEF | UNION_DEF => true,
4138 _ => false,
4139 }
4140 }
4141 fn cast(syntax: SyntaxNode) -> Option<Self> {
4142 let res = match syntax.kind() {
4143 STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
4144 ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
4145 UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }),
4146 _ => return None,
4147 };
4148 Some(res)
4149 }
4150 fn syntax(&self) -> &SyntaxNode {
4151 match self {
4152 NominalDef::StructDef(it) => &it.syntax,
4153 NominalDef::EnumDef(it) => &it.syntax,
4154 NominalDef::UnionDef(it) => &it.syntax,
4155 }
4156 }
4157}
4158impl From<LifetimeParam> for GenericParam {
4159 fn from(node: LifetimeParam) -> GenericParam { GenericParam::LifetimeParam(node) }
4160}
4161impl From<TypeParam> for GenericParam {
4162 fn from(node: TypeParam) -> GenericParam { GenericParam::TypeParam(node) }
4163}
4164impl From<ConstParam> for GenericParam {
4165 fn from(node: ConstParam) -> GenericParam { GenericParam::ConstParam(node) }
4166} 2747}
4167impl AstNode for GenericParam { 2748impl From<AssocTypeArg> for GenericArg {
4168 fn can_cast(kind: SyntaxKind) -> bool { 2749 fn from(node: AssocTypeArg) -> GenericArg { GenericArg::AssocTypeArg(node) }
4169 match kind {
4170 LIFETIME_PARAM | TYPE_PARAM | CONST_PARAM => true,
4171 _ => false,
4172 }
4173 }
4174 fn cast(syntax: SyntaxNode) -> Option<Self> {
4175 let res = match syntax.kind() {
4176 LIFETIME_PARAM => GenericParam::LifetimeParam(LifetimeParam { syntax }),
4177 TYPE_PARAM => GenericParam::TypeParam(TypeParam { syntax }),
4178 CONST_PARAM => GenericParam::ConstParam(ConstParam { syntax }),
4179 _ => return None,
4180 };
4181 Some(res)
4182 }
4183 fn syntax(&self) -> &SyntaxNode {
4184 match self {
4185 GenericParam::LifetimeParam(it) => &it.syntax,
4186 GenericParam::TypeParam(it) => &it.syntax,
4187 GenericParam::ConstParam(it) => &it.syntax,
4188 }
4189 }
4190} 2750}
4191impl From<LifetimeArg> for GenericArg { 2751impl From<LifetimeArg> for GenericArg {
4192 fn from(node: LifetimeArg) -> GenericArg { GenericArg::LifetimeArg(node) } 2752 fn from(node: LifetimeArg) -> GenericArg { GenericArg::LifetimeArg(node) }
4193} 2753}
4194impl From<TypeArg> for GenericArg {
4195 fn from(node: TypeArg) -> GenericArg { GenericArg::TypeArg(node) }
4196}
4197impl From<ConstArg> for GenericArg { 2754impl From<ConstArg> for GenericArg {
4198 fn from(node: ConstArg) -> GenericArg { GenericArg::ConstArg(node) } 2755 fn from(node: ConstArg) -> GenericArg { GenericArg::ConstArg(node) }
4199} 2756}
4200impl From<AssocTypeArg> for GenericArg {
4201 fn from(node: AssocTypeArg) -> GenericArg { GenericArg::AssocTypeArg(node) }
4202}
4203impl AstNode for GenericArg { 2757impl AstNode for GenericArg {
4204 fn can_cast(kind: SyntaxKind) -> bool { 2758 fn can_cast(kind: SyntaxKind) -> bool {
4205 match kind { 2759 match kind {
4206 LIFETIME_ARG | TYPE_ARG | CONST_ARG | ASSOC_TYPE_ARG => true, 2760 TYPE_ARG | ASSOC_TYPE_ARG | LIFETIME_ARG | CONST_ARG => true,
4207 _ => false, 2761 _ => false,
4208 } 2762 }
4209 } 2763 }
4210 fn cast(syntax: SyntaxNode) -> Option<Self> { 2764 fn cast(syntax: SyntaxNode) -> Option<Self> {
4211 let res = match syntax.kind() { 2765 let res = match syntax.kind() {
4212 LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }),
4213 TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }), 2766 TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }),
4214 CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }),
4215 ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }), 2767 ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }),
2768 LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }),
2769 CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }),
4216 _ => return None, 2770 _ => return None,
4217 }; 2771 };
4218 Some(res) 2772 Some(res)
4219 } 2773 }
4220 fn syntax(&self) -> &SyntaxNode { 2774 fn syntax(&self) -> &SyntaxNode {
4221 match self { 2775 match self {
4222 GenericArg::LifetimeArg(it) => &it.syntax,
4223 GenericArg::TypeArg(it) => &it.syntax, 2776 GenericArg::TypeArg(it) => &it.syntax,
4224 GenericArg::ConstArg(it) => &it.syntax,
4225 GenericArg::AssocTypeArg(it) => &it.syntax, 2777 GenericArg::AssocTypeArg(it) => &it.syntax,
2778 GenericArg::LifetimeArg(it) => &it.syntax,
2779 GenericArg::ConstArg(it) => &it.syntax,
4226 } 2780 }
4227 } 2781 }
4228} 2782}
4229impl From<ParenType> for TypeRef { 2783impl From<ArrayType> for Type {
4230 fn from(node: ParenType) -> TypeRef { TypeRef::ParenType(node) } 2784 fn from(node: ArrayType) -> Type { Type::ArrayType(node) }
4231}
4232impl From<TupleType> for TypeRef {
4233 fn from(node: TupleType) -> TypeRef { TypeRef::TupleType(node) }
4234}
4235impl From<NeverType> for TypeRef {
4236 fn from(node: NeverType) -> TypeRef { TypeRef::NeverType(node) }
4237}
4238impl From<PathType> for TypeRef {
4239 fn from(node: PathType) -> TypeRef { TypeRef::PathType(node) }
4240}
4241impl From<PointerType> for TypeRef {
4242 fn from(node: PointerType) -> TypeRef { TypeRef::PointerType(node) }
4243}
4244impl From<ArrayType> for TypeRef {
4245 fn from(node: ArrayType) -> TypeRef { TypeRef::ArrayType(node) }
4246}
4247impl From<SliceType> for TypeRef {
4248 fn from(node: SliceType) -> TypeRef { TypeRef::SliceType(node) }
4249}
4250impl From<ReferenceType> for TypeRef {
4251 fn from(node: ReferenceType) -> TypeRef { TypeRef::ReferenceType(node) }
4252}
4253impl From<PlaceholderType> for TypeRef {
4254 fn from(node: PlaceholderType) -> TypeRef { TypeRef::PlaceholderType(node) }
4255}
4256impl From<FnPointerType> for TypeRef {
4257 fn from(node: FnPointerType) -> TypeRef { TypeRef::FnPointerType(node) }
4258}
4259impl From<ForType> for TypeRef {
4260 fn from(node: ForType) -> TypeRef { TypeRef::ForType(node) }
4261}
4262impl From<ImplTraitType> for TypeRef {
4263 fn from(node: ImplTraitType) -> TypeRef { TypeRef::ImplTraitType(node) }
4264}
4265impl From<DynTraitType> for TypeRef {
4266 fn from(node: DynTraitType) -> TypeRef { TypeRef::DynTraitType(node) }
4267}
4268impl AstNode for TypeRef {
4269 fn can_cast(kind: SyntaxKind) -> bool {
4270 match kind {
4271 PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
4272 | SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
4273 | IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
4274 _ => false,
4275 }
4276 }
4277 fn cast(syntax: SyntaxNode) -> Option<Self> {
4278 let res = match syntax.kind() {
4279 PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }),
4280 TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }),
4281 NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }),
4282 PATH_TYPE => TypeRef::PathType(PathType { syntax }),
4283 POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }),
4284 ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }),
4285 SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }),
4286 REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }),
4287 PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }),
4288 FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }),
4289 FOR_TYPE => TypeRef::ForType(ForType { syntax }),
4290 IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }),
4291 DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }),
4292 _ => return None,
4293 };
4294 Some(res)
4295 }
4296 fn syntax(&self) -> &SyntaxNode {
4297 match self {
4298 TypeRef::ParenType(it) => &it.syntax,
4299 TypeRef::TupleType(it) => &it.syntax,
4300 TypeRef::NeverType(it) => &it.syntax,
4301 TypeRef::PathType(it) => &it.syntax,
4302 TypeRef::PointerType(it) => &it.syntax,
4303 TypeRef::ArrayType(it) => &it.syntax,
4304 TypeRef::SliceType(it) => &it.syntax,
4305 TypeRef::ReferenceType(it) => &it.syntax,
4306 TypeRef::PlaceholderType(it) => &it.syntax,
4307 TypeRef::FnPointerType(it) => &it.syntax,
4308 TypeRef::ForType(it) => &it.syntax,
4309 TypeRef::ImplTraitType(it) => &it.syntax,
4310 TypeRef::DynTraitType(it) => &it.syntax,
4311 }
4312 }
4313}
4314impl From<StructDef> for ModuleItem {
4315 fn from(node: StructDef) -> ModuleItem { ModuleItem::StructDef(node) }
4316}
4317impl From<UnionDef> for ModuleItem {
4318 fn from(node: UnionDef) -> ModuleItem { ModuleItem::UnionDef(node) }
4319} 2785}
4320impl From<EnumDef> for ModuleItem { 2786impl From<DynTraitType> for Type {
4321 fn from(node: EnumDef) -> ModuleItem { ModuleItem::EnumDef(node) } 2787 fn from(node: DynTraitType) -> Type { Type::DynTraitType(node) }
4322} 2788}
4323impl From<FnDef> for ModuleItem { 2789impl From<FnPtrType> for Type {
4324 fn from(node: FnDef) -> ModuleItem { ModuleItem::FnDef(node) } 2790 fn from(node: FnPtrType) -> Type { Type::FnPtrType(node) }
4325} 2791}
4326impl From<TraitDef> for ModuleItem { 2792impl From<ForType> for Type {
4327 fn from(node: TraitDef) -> ModuleItem { ModuleItem::TraitDef(node) } 2793 fn from(node: ForType) -> Type { Type::ForType(node) }
4328} 2794}
4329impl From<TypeAliasDef> for ModuleItem { 2795impl From<ImplTraitType> for Type {
4330 fn from(node: TypeAliasDef) -> ModuleItem { ModuleItem::TypeAliasDef(node) } 2796 fn from(node: ImplTraitType) -> Type { Type::ImplTraitType(node) }
4331} 2797}
4332impl From<ImplDef> for ModuleItem { 2798impl From<InferType> for Type {
4333 fn from(node: ImplDef) -> ModuleItem { ModuleItem::ImplDef(node) } 2799 fn from(node: InferType) -> Type { Type::InferType(node) }
4334} 2800}
4335impl From<UseItem> for ModuleItem { 2801impl From<NeverType> for Type {
4336 fn from(node: UseItem) -> ModuleItem { ModuleItem::UseItem(node) } 2802 fn from(node: NeverType) -> Type { Type::NeverType(node) }
4337} 2803}
4338impl From<ExternCrateItem> for ModuleItem { 2804impl From<ParenType> for Type {
4339 fn from(node: ExternCrateItem) -> ModuleItem { ModuleItem::ExternCrateItem(node) } 2805 fn from(node: ParenType) -> Type { Type::ParenType(node) }
4340} 2806}
4341impl From<ConstDef> for ModuleItem { 2807impl From<PathType> for Type {
4342 fn from(node: ConstDef) -> ModuleItem { ModuleItem::ConstDef(node) } 2808 fn from(node: PathType) -> Type { Type::PathType(node) }
4343} 2809}
4344impl From<StaticDef> for ModuleItem { 2810impl From<PtrType> for Type {
4345 fn from(node: StaticDef) -> ModuleItem { ModuleItem::StaticDef(node) } 2811 fn from(node: PtrType) -> Type { Type::PtrType(node) }
4346} 2812}
4347impl From<Module> for ModuleItem { 2813impl From<RefType> for Type {
4348 fn from(node: Module) -> ModuleItem { ModuleItem::Module(node) } 2814 fn from(node: RefType) -> Type { Type::RefType(node) }
4349} 2815}
4350impl From<MacroCall> for ModuleItem { 2816impl From<SliceType> for Type {
4351 fn from(node: MacroCall) -> ModuleItem { ModuleItem::MacroCall(node) } 2817 fn from(node: SliceType) -> Type { Type::SliceType(node) }
4352} 2818}
4353impl From<ExternBlock> for ModuleItem { 2819impl From<TupleType> for Type {
4354 fn from(node: ExternBlock) -> ModuleItem { ModuleItem::ExternBlock(node) } 2820 fn from(node: TupleType) -> Type { Type::TupleType(node) }
4355} 2821}
4356impl AstNode for ModuleItem { 2822impl AstNode for Type {
4357 fn can_cast(kind: SyntaxKind) -> bool { 2823 fn can_cast(kind: SyntaxKind) -> bool {
4358 match kind { 2824 match kind {
4359 STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF 2825 ARRAY_TYPE | DYN_TRAIT_TYPE | FN_PTR_TYPE | FOR_TYPE | IMPL_TRAIT_TYPE | INFER_TYPE
4360 | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL 2826 | NEVER_TYPE | PAREN_TYPE | PATH_TYPE | PTR_TYPE | REF_TYPE | SLICE_TYPE
4361 | EXTERN_BLOCK => true, 2827 | TUPLE_TYPE => true,
4362 _ => false, 2828 _ => false,
4363 } 2829 }
4364 } 2830 }
4365 fn cast(syntax: SyntaxNode) -> Option<Self> { 2831 fn cast(syntax: SyntaxNode) -> Option<Self> {
4366 let res = match syntax.kind() { 2832 let res = match syntax.kind() {
4367 STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }), 2833 ARRAY_TYPE => Type::ArrayType(ArrayType { syntax }),
4368 UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }), 2834 DYN_TRAIT_TYPE => Type::DynTraitType(DynTraitType { syntax }),
4369 ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }), 2835 FN_PTR_TYPE => Type::FnPtrType(FnPtrType { syntax }),
4370 FN_DEF => ModuleItem::FnDef(FnDef { syntax }), 2836 FOR_TYPE => Type::ForType(ForType { syntax }),
4371 TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }), 2837 IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }),
4372 TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }), 2838 INFER_TYPE => Type::InferType(InferType { syntax }),
4373 IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }), 2839 NEVER_TYPE => Type::NeverType(NeverType { syntax }),
4374 USE_ITEM => ModuleItem::UseItem(UseItem { syntax }), 2840 PAREN_TYPE => Type::ParenType(ParenType { syntax }),
4375 EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }), 2841 PATH_TYPE => Type::PathType(PathType { syntax }),
4376 CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }), 2842 PTR_TYPE => Type::PtrType(PtrType { syntax }),
4377 STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }), 2843 REF_TYPE => Type::RefType(RefType { syntax }),
4378 MODULE => ModuleItem::Module(Module { syntax }), 2844 SLICE_TYPE => Type::SliceType(SliceType { syntax }),
4379 MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }), 2845 TUPLE_TYPE => Type::TupleType(TupleType { syntax }),
4380 EXTERN_BLOCK => ModuleItem::ExternBlock(ExternBlock { syntax }),
4381 _ => return None, 2846 _ => return None,
4382 }; 2847 };
4383 Some(res) 2848 Some(res)
4384 } 2849 }
4385 fn syntax(&self) -> &SyntaxNode { 2850 fn syntax(&self) -> &SyntaxNode {
4386 match self { 2851 match self {
4387 ModuleItem::StructDef(it) => &it.syntax, 2852 Type::ArrayType(it) => &it.syntax,
4388 ModuleItem::UnionDef(it) => &it.syntax, 2853 Type::DynTraitType(it) => &it.syntax,
4389 ModuleItem::EnumDef(it) => &it.syntax, 2854 Type::FnPtrType(it) => &it.syntax,
4390 ModuleItem::FnDef(it) => &it.syntax, 2855 Type::ForType(it) => &it.syntax,
4391 ModuleItem::TraitDef(it) => &it.syntax, 2856 Type::ImplTraitType(it) => &it.syntax,
4392 ModuleItem::TypeAliasDef(it) => &it.syntax, 2857 Type::InferType(it) => &it.syntax,
4393 ModuleItem::ImplDef(it) => &it.syntax, 2858 Type::NeverType(it) => &it.syntax,
4394 ModuleItem::UseItem(it) => &it.syntax, 2859 Type::ParenType(it) => &it.syntax,
4395 ModuleItem::ExternCrateItem(it) => &it.syntax, 2860 Type::PathType(it) => &it.syntax,
4396 ModuleItem::ConstDef(it) => &it.syntax, 2861 Type::PtrType(it) => &it.syntax,
4397 ModuleItem::StaticDef(it) => &it.syntax, 2862 Type::RefType(it) => &it.syntax,
4398 ModuleItem::Module(it) => &it.syntax, 2863 Type::SliceType(it) => &it.syntax,
4399 ModuleItem::MacroCall(it) => &it.syntax, 2864 Type::TupleType(it) => &it.syntax,
4400 ModuleItem::ExternBlock(it) => &it.syntax,
4401 } 2865 }
4402 } 2866 }
4403} 2867}
4404impl From<FnDef> for AssocItem { 2868impl From<ArrayExpr> for Expr {
4405 fn from(node: FnDef) -> AssocItem { AssocItem::FnDef(node) } 2869 fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) }
4406}
4407impl From<TypeAliasDef> for AssocItem {
4408 fn from(node: TypeAliasDef) -> AssocItem { AssocItem::TypeAliasDef(node) }
4409}
4410impl From<ConstDef> for AssocItem {
4411 fn from(node: ConstDef) -> AssocItem { AssocItem::ConstDef(node) }
4412} 2870}
4413impl AstNode for AssocItem { 2871impl From<AwaitExpr> for Expr {
4414 fn can_cast(kind: SyntaxKind) -> bool { 2872 fn from(node: AwaitExpr) -> Expr { Expr::AwaitExpr(node) }
4415 match kind {
4416 FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true,
4417 _ => false,
4418 }
4419 }
4420 fn cast(syntax: SyntaxNode) -> Option<Self> {
4421 let res = match syntax.kind() {
4422 FN_DEF => AssocItem::FnDef(FnDef { syntax }),
4423 TYPE_ALIAS_DEF => AssocItem::TypeAliasDef(TypeAliasDef { syntax }),
4424 CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }),
4425 _ => return None,
4426 };
4427 Some(res)
4428 }
4429 fn syntax(&self) -> &SyntaxNode {
4430 match self {
4431 AssocItem::FnDef(it) => &it.syntax,
4432 AssocItem::TypeAliasDef(it) => &it.syntax,
4433 AssocItem::ConstDef(it) => &it.syntax,
4434 }
4435 }
4436} 2873}
4437impl From<FnDef> for ExternItem { 2874impl From<BinExpr> for Expr {
4438 fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) } 2875 fn from(node: BinExpr) -> Expr { Expr::BinExpr(node) }
4439} 2876}
4440impl From<StaticDef> for ExternItem { 2877impl From<BlockExpr> for Expr {
4441 fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) } 2878 fn from(node: BlockExpr) -> Expr { Expr::BlockExpr(node) }
4442} 2879}
4443impl AstNode for ExternItem { 2880impl From<BoxExpr> for Expr {
4444 fn can_cast(kind: SyntaxKind) -> bool { 2881 fn from(node: BoxExpr) -> Expr { Expr::BoxExpr(node) }
4445 match kind {
4446 FN_DEF | STATIC_DEF => true,
4447 _ => false,
4448 }
4449 }
4450 fn cast(syntax: SyntaxNode) -> Option<Self> {
4451 let res = match syntax.kind() {
4452 FN_DEF => ExternItem::FnDef(FnDef { syntax }),
4453 STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }),
4454 _ => return None,
4455 };
4456 Some(res)
4457 }
4458 fn syntax(&self) -> &SyntaxNode {
4459 match self {
4460 ExternItem::FnDef(it) => &it.syntax,
4461 ExternItem::StaticDef(it) => &it.syntax,
4462 }
4463 }
4464} 2882}
4465impl From<TupleExpr> for Expr { 2883impl From<BreakExpr> for Expr {
4466 fn from(node: TupleExpr) -> Expr { Expr::TupleExpr(node) } 2884 fn from(node: BreakExpr) -> Expr { Expr::BreakExpr(node) }
4467} 2885}
4468impl From<ArrayExpr> for Expr { 2886impl From<CallExpr> for Expr {
4469 fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) } 2887 fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) }
4470} 2888}
4471impl From<ParenExpr> for Expr { 2889impl From<CastExpr> for Expr {
4472 fn from(node: ParenExpr) -> Expr { Expr::ParenExpr(node) } 2890 fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) }
4473} 2891}
4474impl From<PathExpr> for Expr { 2892impl From<ClosureExpr> for Expr {
4475 fn from(node: PathExpr) -> Expr { Expr::PathExpr(node) } 2893 fn from(node: ClosureExpr) -> Expr { Expr::ClosureExpr(node) }
4476} 2894}
4477impl From<LambdaExpr> for Expr { 2895impl From<ContinueExpr> for Expr {
4478 fn from(node: LambdaExpr) -> Expr { Expr::LambdaExpr(node) } 2896 fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) }
4479} 2897}
4480impl From<IfExpr> for Expr { 2898impl From<EffectExpr> for Expr {
4481 fn from(node: IfExpr) -> Expr { Expr::IfExpr(node) } 2899 fn from(node: EffectExpr) -> Expr { Expr::EffectExpr(node) }
4482} 2900}
4483impl From<LoopExpr> for Expr { 2901impl From<FieldExpr> for Expr {
4484 fn from(node: LoopExpr) -> Expr { Expr::LoopExpr(node) } 2902 fn from(node: FieldExpr) -> Expr { Expr::FieldExpr(node) }
4485} 2903}
4486impl From<ForExpr> for Expr { 2904impl From<ForExpr> for Expr {
4487 fn from(node: ForExpr) -> Expr { Expr::ForExpr(node) } 2905 fn from(node: ForExpr) -> Expr { Expr::ForExpr(node) }
4488} 2906}
4489impl From<WhileExpr> for Expr { 2907impl From<IfExpr> for Expr {
4490 fn from(node: WhileExpr) -> Expr { Expr::WhileExpr(node) } 2908 fn from(node: IfExpr) -> Expr { Expr::IfExpr(node) }
4491}
4492impl From<ContinueExpr> for Expr {
4493 fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) }
4494} 2909}
4495impl From<BreakExpr> for Expr { 2910impl From<IndexExpr> for Expr {
4496 fn from(node: BreakExpr) -> Expr { Expr::BreakExpr(node) } 2911 fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) }
4497} 2912}
4498impl From<Label> for Expr { 2913impl From<Literal> for Expr {
4499 fn from(node: Label) -> Expr { Expr::Label(node) } 2914 fn from(node: Literal) -> Expr { Expr::Literal(node) }
4500} 2915}
4501impl From<BlockExpr> for Expr { 2916impl From<LoopExpr> for Expr {
4502 fn from(node: BlockExpr) -> Expr { Expr::BlockExpr(node) } 2917 fn from(node: LoopExpr) -> Expr { Expr::LoopExpr(node) }
4503} 2918}
4504impl From<ReturnExpr> for Expr { 2919impl From<MacroCall> for Expr {
4505 fn from(node: ReturnExpr) -> Expr { Expr::ReturnExpr(node) } 2920 fn from(node: MacroCall) -> Expr { Expr::MacroCall(node) }
4506} 2921}
4507impl From<MatchExpr> for Expr { 2922impl From<MatchExpr> for Expr {
4508 fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) } 2923 fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) }
4509} 2924}
4510impl From<RecordLit> for Expr {
4511 fn from(node: RecordLit) -> Expr { Expr::RecordLit(node) }
4512}
4513impl From<CallExpr> for Expr {
4514 fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) }
4515}
4516impl From<IndexExpr> for Expr {
4517 fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) }
4518}
4519impl From<MethodCallExpr> for Expr { 2925impl From<MethodCallExpr> for Expr {
4520 fn from(node: MethodCallExpr) -> Expr { Expr::MethodCallExpr(node) } 2926 fn from(node: MethodCallExpr) -> Expr { Expr::MethodCallExpr(node) }
4521} 2927}
4522impl From<FieldExpr> for Expr { 2928impl From<ParenExpr> for Expr {
4523 fn from(node: FieldExpr) -> Expr { Expr::FieldExpr(node) } 2929 fn from(node: ParenExpr) -> Expr { Expr::ParenExpr(node) }
4524}
4525impl From<AwaitExpr> for Expr {
4526 fn from(node: AwaitExpr) -> Expr { Expr::AwaitExpr(node) }
4527}
4528impl From<TryExpr> for Expr {
4529 fn from(node: TryExpr) -> Expr { Expr::TryExpr(node) }
4530}
4531impl From<EffectExpr> for Expr {
4532 fn from(node: EffectExpr) -> Expr { Expr::EffectExpr(node) }
4533}
4534impl From<CastExpr> for Expr {
4535 fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) }
4536} 2930}
4537impl From<RefExpr> for Expr { 2931impl From<PathExpr> for Expr {
4538 fn from(node: RefExpr) -> Expr { Expr::RefExpr(node) } 2932 fn from(node: PathExpr) -> Expr { Expr::PathExpr(node) }
4539} 2933}
4540impl From<PrefixExpr> for Expr { 2934impl From<PrefixExpr> for Expr {
4541 fn from(node: PrefixExpr) -> Expr { Expr::PrefixExpr(node) } 2935 fn from(node: PrefixExpr) -> Expr { Expr::PrefixExpr(node) }
@@ -4543,349 +2937,485 @@ impl From<PrefixExpr> for Expr {
4543impl From<RangeExpr> for Expr { 2937impl From<RangeExpr> for Expr {
4544 fn from(node: RangeExpr) -> Expr { Expr::RangeExpr(node) } 2938 fn from(node: RangeExpr) -> Expr { Expr::RangeExpr(node) }
4545} 2939}
4546impl From<BinExpr> for Expr { 2940impl From<RecordExpr> for Expr {
4547 fn from(node: BinExpr) -> Expr { Expr::BinExpr(node) } 2941 fn from(node: RecordExpr) -> Expr { Expr::RecordExpr(node) }
4548} 2942}
4549impl From<Literal> for Expr { 2943impl From<RefExpr> for Expr {
4550 fn from(node: Literal) -> Expr { Expr::Literal(node) } 2944 fn from(node: RefExpr) -> Expr { Expr::RefExpr(node) }
4551} 2945}
4552impl From<MacroCall> for Expr { 2946impl From<ReturnExpr> for Expr {
4553 fn from(node: MacroCall) -> Expr { Expr::MacroCall(node) } 2947 fn from(node: ReturnExpr) -> Expr { Expr::ReturnExpr(node) }
4554} 2948}
4555impl From<BoxExpr> for Expr { 2949impl From<TryExpr> for Expr {
4556 fn from(node: BoxExpr) -> Expr { Expr::BoxExpr(node) } 2950 fn from(node: TryExpr) -> Expr { Expr::TryExpr(node) }
2951}
2952impl From<TupleExpr> for Expr {
2953 fn from(node: TupleExpr) -> Expr { Expr::TupleExpr(node) }
2954}
2955impl From<WhileExpr> for Expr {
2956 fn from(node: WhileExpr) -> Expr { Expr::WhileExpr(node) }
4557} 2957}
4558impl AstNode for Expr { 2958impl AstNode for Expr {
4559 fn can_cast(kind: SyntaxKind) -> bool { 2959 fn can_cast(kind: SyntaxKind) -> bool {
4560 match kind { 2960 match kind {
4561 TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR 2961 ARRAY_EXPR | AWAIT_EXPR | BIN_EXPR | BLOCK_EXPR | BOX_EXPR | BREAK_EXPR | CALL_EXPR
4562 | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL 2962 | CAST_EXPR | CLOSURE_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR
4563 | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR 2963 | IF_EXPR | INDEX_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR
4564 | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | EFFECT_EXPR | CAST_EXPR 2964 | METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR
4565 | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | BOX_EXPR => { 2965 | RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true,
4566 true
4567 }
4568 _ => false, 2966 _ => false,
4569 } 2967 }
4570 } 2968 }
4571 fn cast(syntax: SyntaxNode) -> Option<Self> { 2969 fn cast(syntax: SyntaxNode) -> Option<Self> {
4572 let res = match syntax.kind() { 2970 let res = match syntax.kind() {
4573 TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }),
4574 ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }), 2971 ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }),
4575 PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }), 2972 AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }),
4576 PATH_EXPR => Expr::PathExpr(PathExpr { syntax }), 2973 BIN_EXPR => Expr::BinExpr(BinExpr { syntax }),
4577 LAMBDA_EXPR => Expr::LambdaExpr(LambdaExpr { syntax }),
4578 IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
4579 LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }),
4580 FOR_EXPR => Expr::ForExpr(ForExpr { syntax }),
4581 WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }),
4582 CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }),
4583 BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }),
4584 LABEL => Expr::Label(Label { syntax }),
4585 BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), 2974 BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
4586 RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), 2975 BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }),
4587 MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), 2976 BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }),
4588 RECORD_LIT => Expr::RecordLit(RecordLit { syntax }),
4589 CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), 2977 CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
2978 CAST_EXPR => Expr::CastExpr(CastExpr { syntax }),
2979 CLOSURE_EXPR => Expr::ClosureExpr(ClosureExpr { syntax }),
2980 CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }),
2981 EFFECT_EXPR => Expr::EffectExpr(EffectExpr { syntax }),
2982 FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }),
2983 FOR_EXPR => Expr::ForExpr(ForExpr { syntax }),
2984 IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
4590 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), 2985 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
2986 LITERAL => Expr::Literal(Literal { syntax }),
2987 LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }),
2988 MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
2989 MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
4591 METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), 2990 METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
4592 FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }), 2991 PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }),
4593 AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }), 2992 PATH_EXPR => Expr::PathExpr(PathExpr { syntax }),
4594 TRY_EXPR => Expr::TryExpr(TryExpr { syntax }),
4595 EFFECT_EXPR => Expr::EffectExpr(EffectExpr { syntax }),
4596 CAST_EXPR => Expr::CastExpr(CastExpr { syntax }),
4597 REF_EXPR => Expr::RefExpr(RefExpr { syntax }),
4598 PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }), 2993 PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }),
4599 RANGE_EXPR => Expr::RangeExpr(RangeExpr { syntax }), 2994 RANGE_EXPR => Expr::RangeExpr(RangeExpr { syntax }),
4600 BIN_EXPR => Expr::BinExpr(BinExpr { syntax }), 2995 RECORD_EXPR => Expr::RecordExpr(RecordExpr { syntax }),
4601 LITERAL => Expr::Literal(Literal { syntax }), 2996 REF_EXPR => Expr::RefExpr(RefExpr { syntax }),
4602 MACRO_CALL => Expr::MacroCall(MacroCall { syntax }), 2997 RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }),
4603 BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }), 2998 TRY_EXPR => Expr::TryExpr(TryExpr { syntax }),
2999 TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }),
3000 WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }),
4604 _ => return None, 3001 _ => return None,
4605 }; 3002 };
4606 Some(res) 3003 Some(res)
4607 } 3004 }
4608 fn syntax(&self) -> &SyntaxNode { 3005 fn syntax(&self) -> &SyntaxNode {
4609 match self { 3006 match self {
4610 Expr::TupleExpr(it) => &it.syntax,
4611 Expr::ArrayExpr(it) => &it.syntax, 3007 Expr::ArrayExpr(it) => &it.syntax,
4612 Expr::ParenExpr(it) => &it.syntax, 3008 Expr::AwaitExpr(it) => &it.syntax,
4613 Expr::PathExpr(it) => &it.syntax, 3009 Expr::BinExpr(it) => &it.syntax,
4614 Expr::LambdaExpr(it) => &it.syntax,
4615 Expr::IfExpr(it) => &it.syntax,
4616 Expr::LoopExpr(it) => &it.syntax,
4617 Expr::ForExpr(it) => &it.syntax,
4618 Expr::WhileExpr(it) => &it.syntax,
4619 Expr::ContinueExpr(it) => &it.syntax,
4620 Expr::BreakExpr(it) => &it.syntax,
4621 Expr::Label(it) => &it.syntax,
4622 Expr::BlockExpr(it) => &it.syntax, 3010 Expr::BlockExpr(it) => &it.syntax,
4623 Expr::ReturnExpr(it) => &it.syntax, 3011 Expr::BoxExpr(it) => &it.syntax,
4624 Expr::MatchExpr(it) => &it.syntax, 3012 Expr::BreakExpr(it) => &it.syntax,
4625 Expr::RecordLit(it) => &it.syntax,
4626 Expr::CallExpr(it) => &it.syntax, 3013 Expr::CallExpr(it) => &it.syntax,
3014 Expr::CastExpr(it) => &it.syntax,
3015 Expr::ClosureExpr(it) => &it.syntax,
3016 Expr::ContinueExpr(it) => &it.syntax,
3017 Expr::EffectExpr(it) => &it.syntax,
3018 Expr::FieldExpr(it) => &it.syntax,
3019 Expr::ForExpr(it) => &it.syntax,
3020 Expr::IfExpr(it) => &it.syntax,
4627 Expr::IndexExpr(it) => &it.syntax, 3021 Expr::IndexExpr(it) => &it.syntax,
3022 Expr::Literal(it) => &it.syntax,
3023 Expr::LoopExpr(it) => &it.syntax,
3024 Expr::MacroCall(it) => &it.syntax,
3025 Expr::MatchExpr(it) => &it.syntax,
4628 Expr::MethodCallExpr(it) => &it.syntax, 3026 Expr::MethodCallExpr(it) => &it.syntax,
4629 Expr::FieldExpr(it) => &it.syntax, 3027 Expr::ParenExpr(it) => &it.syntax,
4630 Expr::AwaitExpr(it) => &it.syntax, 3028 Expr::PathExpr(it) => &it.syntax,
4631 Expr::TryExpr(it) => &it.syntax,
4632 Expr::EffectExpr(it) => &it.syntax,
4633 Expr::CastExpr(it) => &it.syntax,
4634 Expr::RefExpr(it) => &it.syntax,
4635 Expr::PrefixExpr(it) => &it.syntax, 3029 Expr::PrefixExpr(it) => &it.syntax,
4636 Expr::RangeExpr(it) => &it.syntax, 3030 Expr::RangeExpr(it) => &it.syntax,
4637 Expr::BinExpr(it) => &it.syntax, 3031 Expr::RecordExpr(it) => &it.syntax,
4638 Expr::Literal(it) => &it.syntax, 3032 Expr::RefExpr(it) => &it.syntax,
4639 Expr::MacroCall(it) => &it.syntax, 3033 Expr::ReturnExpr(it) => &it.syntax,
4640 Expr::BoxExpr(it) => &it.syntax, 3034 Expr::TryExpr(it) => &it.syntax,
3035 Expr::TupleExpr(it) => &it.syntax,
3036 Expr::WhileExpr(it) => &it.syntax,
4641 } 3037 }
4642 } 3038 }
4643} 3039}
4644impl From<OrPat> for Pat { 3040impl From<Const> for Item {
4645 fn from(node: OrPat) -> Pat { Pat::OrPat(node) } 3041 fn from(node: Const) -> Item { Item::Const(node) }
4646} 3042}
4647impl From<ParenPat> for Pat { 3043impl From<Enum> for Item {
4648 fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } 3044 fn from(node: Enum) -> Item { Item::Enum(node) }
4649} 3045}
4650impl From<RefPat> for Pat { 3046impl From<ExternBlock> for Item {
4651 fn from(node: RefPat) -> Pat { Pat::RefPat(node) } 3047 fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) }
3048}
3049impl From<ExternCrate> for Item {
3050 fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) }
3051}
3052impl From<Fn> for Item {
3053 fn from(node: Fn) -> Item { Item::Fn(node) }
3054}
3055impl From<Impl> for Item {
3056 fn from(node: Impl) -> Item { Item::Impl(node) }
3057}
3058impl From<MacroCall> for Item {
3059 fn from(node: MacroCall) -> Item { Item::MacroCall(node) }
3060}
3061impl From<Module> for Item {
3062 fn from(node: Module) -> Item { Item::Module(node) }
3063}
3064impl From<Static> for Item {
3065 fn from(node: Static) -> Item { Item::Static(node) }
3066}
3067impl From<Struct> for Item {
3068 fn from(node: Struct) -> Item { Item::Struct(node) }
3069}
3070impl From<Trait> for Item {
3071 fn from(node: Trait) -> Item { Item::Trait(node) }
3072}
3073impl From<TypeAlias> for Item {
3074 fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) }
3075}
3076impl From<Union> for Item {
3077 fn from(node: Union) -> Item { Item::Union(node) }
3078}
3079impl From<Use> for Item {
3080 fn from(node: Use) -> Item { Item::Use(node) }
3081}
3082impl AstNode for Item {
3083 fn can_cast(kind: SyntaxKind) -> bool {
3084 match kind {
3085 CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL | MACRO_CALL | MODULE
3086 | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true,
3087 _ => false,
3088 }
3089 }
3090 fn cast(syntax: SyntaxNode) -> Option<Self> {
3091 let res = match syntax.kind() {
3092 CONST => Item::Const(Const { syntax }),
3093 ENUM => Item::Enum(Enum { syntax }),
3094 EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }),
3095 EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }),
3096 FN => Item::Fn(Fn { syntax }),
3097 IMPL => Item::Impl(Impl { syntax }),
3098 MACRO_CALL => Item::MacroCall(MacroCall { syntax }),
3099 MODULE => Item::Module(Module { syntax }),
3100 STATIC => Item::Static(Static { syntax }),
3101 STRUCT => Item::Struct(Struct { syntax }),
3102 TRAIT => Item::Trait(Trait { syntax }),
3103 TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }),
3104 UNION => Item::Union(Union { syntax }),
3105 USE => Item::Use(Use { syntax }),
3106 _ => return None,
3107 };
3108 Some(res)
3109 }
3110 fn syntax(&self) -> &SyntaxNode {
3111 match self {
3112 Item::Const(it) => &it.syntax,
3113 Item::Enum(it) => &it.syntax,
3114 Item::ExternBlock(it) => &it.syntax,
3115 Item::ExternCrate(it) => &it.syntax,
3116 Item::Fn(it) => &it.syntax,
3117 Item::Impl(it) => &it.syntax,
3118 Item::MacroCall(it) => &it.syntax,
3119 Item::Module(it) => &it.syntax,
3120 Item::Static(it) => &it.syntax,
3121 Item::Struct(it) => &it.syntax,
3122 Item::Trait(it) => &it.syntax,
3123 Item::TypeAlias(it) => &it.syntax,
3124 Item::Union(it) => &it.syntax,
3125 Item::Use(it) => &it.syntax,
3126 }
3127 }
3128}
3129impl From<ExprStmt> for Stmt {
3130 fn from(node: ExprStmt) -> Stmt { Stmt::ExprStmt(node) }
3131}
3132impl From<Item> for Stmt {
3133 fn from(node: Item) -> Stmt { Stmt::Item(node) }
3134}
3135impl From<LetStmt> for Stmt {
3136 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) }
3137}
3138impl From<IdentPat> for Pat {
3139 fn from(node: IdentPat) -> Pat { Pat::IdentPat(node) }
4652} 3140}
4653impl From<BoxPat> for Pat { 3141impl From<BoxPat> for Pat {
4654 fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } 3142 fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) }
4655} 3143}
4656impl From<BindPat> for Pat { 3144impl From<RestPat> for Pat {
4657 fn from(node: BindPat) -> Pat { Pat::BindPat(node) } 3145 fn from(node: RestPat) -> Pat { Pat::RestPat(node) }
4658} 3146}
4659impl From<PlaceholderPat> for Pat { 3147impl From<LiteralPat> for Pat {
4660 fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } 3148 fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) }
4661} 3149}
4662impl From<DotDotPat> for Pat { 3150impl From<MacroPat> for Pat {
4663 fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } 3151 fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) }
3152}
3153impl From<OrPat> for Pat {
3154 fn from(node: OrPat) -> Pat { Pat::OrPat(node) }
3155}
3156impl From<ParenPat> for Pat {
3157 fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) }
4664} 3158}
4665impl From<PathPat> for Pat { 3159impl From<PathPat> for Pat {
4666 fn from(node: PathPat) -> Pat { Pat::PathPat(node) } 3160 fn from(node: PathPat) -> Pat { Pat::PathPat(node) }
4667} 3161}
3162impl From<WildcardPat> for Pat {
3163 fn from(node: WildcardPat) -> Pat { Pat::WildcardPat(node) }
3164}
3165impl From<RangePat> for Pat {
3166 fn from(node: RangePat) -> Pat { Pat::RangePat(node) }
3167}
4668impl From<RecordPat> for Pat { 3168impl From<RecordPat> for Pat {
4669 fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } 3169 fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) }
4670} 3170}
4671impl From<TupleStructPat> for Pat { 3171impl From<RefPat> for Pat {
4672 fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } 3172 fn from(node: RefPat) -> Pat { Pat::RefPat(node) }
4673}
4674impl From<TuplePat> for Pat {
4675 fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) }
4676} 3173}
4677impl From<SlicePat> for Pat { 3174impl From<SlicePat> for Pat {
4678 fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } 3175 fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) }
4679} 3176}
4680impl From<RangePat> for Pat { 3177impl From<TuplePat> for Pat {
4681 fn from(node: RangePat) -> Pat { Pat::RangePat(node) } 3178 fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) }
4682}
4683impl From<LiteralPat> for Pat {
4684 fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) }
4685} 3179}
4686impl From<MacroPat> for Pat { 3180impl From<TupleStructPat> for Pat {
4687 fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } 3181 fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) }
4688} 3182}
4689impl AstNode for Pat { 3183impl AstNode for Pat {
4690 fn can_cast(kind: SyntaxKind) -> bool { 3184 fn can_cast(kind: SyntaxKind) -> bool {
4691 match kind { 3185 match kind {
4692 OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT 3186 IDENT_PAT | BOX_PAT | REST_PAT | LITERAL_PAT | MACRO_PAT | OR_PAT | PAREN_PAT
4693 | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT 3187 | PATH_PAT | WILDCARD_PAT | RANGE_PAT | RECORD_PAT | REF_PAT | SLICE_PAT
4694 | LITERAL_PAT | MACRO_PAT => true, 3188 | TUPLE_PAT | TUPLE_STRUCT_PAT => true,
4695 _ => false, 3189 _ => false,
4696 } 3190 }
4697 } 3191 }
4698 fn cast(syntax: SyntaxNode) -> Option<Self> { 3192 fn cast(syntax: SyntaxNode) -> Option<Self> {
4699 let res = match syntax.kind() { 3193 let res = match syntax.kind() {
3194 IDENT_PAT => Pat::IdentPat(IdentPat { syntax }),
3195 BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
3196 REST_PAT => Pat::RestPat(RestPat { syntax }),
3197 LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
3198 MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
4700 OR_PAT => Pat::OrPat(OrPat { syntax }), 3199 OR_PAT => Pat::OrPat(OrPat { syntax }),
4701 PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), 3200 PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
4702 REF_PAT => Pat::RefPat(RefPat { syntax }),
4703 BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
4704 BIND_PAT => Pat::BindPat(BindPat { syntax }),
4705 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
4706 DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
4707 PATH_PAT => Pat::PathPat(PathPat { syntax }), 3201 PATH_PAT => Pat::PathPat(PathPat { syntax }),
3202 WILDCARD_PAT => Pat::WildcardPat(WildcardPat { syntax }),
3203 RANGE_PAT => Pat::RangePat(RangePat { syntax }),
4708 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), 3204 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
4709 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), 3205 REF_PAT => Pat::RefPat(RefPat { syntax }),
4710 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
4711 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), 3206 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
4712 RANGE_PAT => Pat::RangePat(RangePat { syntax }), 3207 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
4713 LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), 3208 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
4714 MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
4715 _ => return None, 3209 _ => return None,
4716 }; 3210 };
4717 Some(res) 3211 Some(res)
4718 } 3212 }
4719 fn syntax(&self) -> &SyntaxNode { 3213 fn syntax(&self) -> &SyntaxNode {
4720 match self { 3214 match self {
3215 Pat::IdentPat(it) => &it.syntax,
3216 Pat::BoxPat(it) => &it.syntax,
3217 Pat::RestPat(it) => &it.syntax,
3218 Pat::LiteralPat(it) => &it.syntax,
3219 Pat::MacroPat(it) => &it.syntax,
4721 Pat::OrPat(it) => &it.syntax, 3220 Pat::OrPat(it) => &it.syntax,
4722 Pat::ParenPat(it) => &it.syntax, 3221 Pat::ParenPat(it) => &it.syntax,
4723 Pat::RefPat(it) => &it.syntax,
4724 Pat::BoxPat(it) => &it.syntax,
4725 Pat::BindPat(it) => &it.syntax,
4726 Pat::PlaceholderPat(it) => &it.syntax,
4727 Pat::DotDotPat(it) => &it.syntax,
4728 Pat::PathPat(it) => &it.syntax, 3222 Pat::PathPat(it) => &it.syntax,
3223 Pat::WildcardPat(it) => &it.syntax,
3224 Pat::RangePat(it) => &it.syntax,
4729 Pat::RecordPat(it) => &it.syntax, 3225 Pat::RecordPat(it) => &it.syntax,
4730 Pat::TupleStructPat(it) => &it.syntax, 3226 Pat::RefPat(it) => &it.syntax,
4731 Pat::TuplePat(it) => &it.syntax,
4732 Pat::SlicePat(it) => &it.syntax, 3227 Pat::SlicePat(it) => &it.syntax,
4733 Pat::RangePat(it) => &it.syntax, 3228 Pat::TuplePat(it) => &it.syntax,
4734 Pat::LiteralPat(it) => &it.syntax, 3229 Pat::TupleStructPat(it) => &it.syntax,
4735 Pat::MacroPat(it) => &it.syntax,
4736 } 3230 }
4737 } 3231 }
4738} 3232}
4739impl From<RecordFieldPat> for RecordInnerPat { 3233impl From<RecordFieldList> for FieldList {
4740 fn from(node: RecordFieldPat) -> RecordInnerPat { RecordInnerPat::RecordFieldPat(node) } 3234 fn from(node: RecordFieldList) -> FieldList { FieldList::RecordFieldList(node) }
4741} 3235}
4742impl From<BindPat> for RecordInnerPat { 3236impl From<TupleFieldList> for FieldList {
4743 fn from(node: BindPat) -> RecordInnerPat { RecordInnerPat::BindPat(node) } 3237 fn from(node: TupleFieldList) -> FieldList { FieldList::TupleFieldList(node) }
4744} 3238}
4745impl AstNode for RecordInnerPat { 3239impl AstNode for FieldList {
4746 fn can_cast(kind: SyntaxKind) -> bool { 3240 fn can_cast(kind: SyntaxKind) -> bool {
4747 match kind { 3241 match kind {
4748 RECORD_FIELD_PAT | BIND_PAT => true, 3242 RECORD_FIELD_LIST | TUPLE_FIELD_LIST => true,
4749 _ => false, 3243 _ => false,
4750 } 3244 }
4751 } 3245 }
4752 fn cast(syntax: SyntaxNode) -> Option<Self> { 3246 fn cast(syntax: SyntaxNode) -> Option<Self> {
4753 let res = match syntax.kind() { 3247 let res = match syntax.kind() {
4754 RECORD_FIELD_PAT => RecordInnerPat::RecordFieldPat(RecordFieldPat { syntax }), 3248 RECORD_FIELD_LIST => FieldList::RecordFieldList(RecordFieldList { syntax }),
4755 BIND_PAT => RecordInnerPat::BindPat(BindPat { syntax }), 3249 TUPLE_FIELD_LIST => FieldList::TupleFieldList(TupleFieldList { syntax }),
4756 _ => return None, 3250 _ => return None,
4757 }; 3251 };
4758 Some(res) 3252 Some(res)
4759 } 3253 }
4760 fn syntax(&self) -> &SyntaxNode { 3254 fn syntax(&self) -> &SyntaxNode {
4761 match self { 3255 match self {
4762 RecordInnerPat::RecordFieldPat(it) => &it.syntax, 3256 FieldList::RecordFieldList(it) => &it.syntax,
4763 RecordInnerPat::BindPat(it) => &it.syntax, 3257 FieldList::TupleFieldList(it) => &it.syntax,
4764 } 3258 }
4765 } 3259 }
4766} 3260}
4767impl From<Literal> for AttrInput { 3261impl From<Enum> for AdtDef {
4768 fn from(node: Literal) -> AttrInput { AttrInput::Literal(node) } 3262 fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) }
3263}
3264impl From<Struct> for AdtDef {
3265 fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) }
4769} 3266}
4770impl From<TokenTree> for AttrInput { 3267impl From<Union> for AdtDef {
4771 fn from(node: TokenTree) -> AttrInput { AttrInput::TokenTree(node) } 3268 fn from(node: Union) -> AdtDef { AdtDef::Union(node) }
4772} 3269}
4773impl AstNode for AttrInput { 3270impl AstNode for AdtDef {
4774 fn can_cast(kind: SyntaxKind) -> bool { 3271 fn can_cast(kind: SyntaxKind) -> bool {
4775 match kind { 3272 match kind {
4776 LITERAL | TOKEN_TREE => true, 3273 ENUM | STRUCT | UNION => true,
4777 _ => false, 3274 _ => false,
4778 } 3275 }
4779 } 3276 }
4780 fn cast(syntax: SyntaxNode) -> Option<Self> { 3277 fn cast(syntax: SyntaxNode) -> Option<Self> {
4781 let res = match syntax.kind() { 3278 let res = match syntax.kind() {
4782 LITERAL => AttrInput::Literal(Literal { syntax }), 3279 ENUM => AdtDef::Enum(Enum { syntax }),
4783 TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }), 3280 STRUCT => AdtDef::Struct(Struct { syntax }),
3281 UNION => AdtDef::Union(Union { syntax }),
4784 _ => return None, 3282 _ => return None,
4785 }; 3283 };
4786 Some(res) 3284 Some(res)
4787 } 3285 }
4788 fn syntax(&self) -> &SyntaxNode { 3286 fn syntax(&self) -> &SyntaxNode {
4789 match self { 3287 match self {
4790 AttrInput::Literal(it) => &it.syntax, 3288 AdtDef::Enum(it) => &it.syntax,
4791 AttrInput::TokenTree(it) => &it.syntax, 3289 AdtDef::Struct(it) => &it.syntax,
3290 AdtDef::Union(it) => &it.syntax,
4792 } 3291 }
4793 } 3292 }
4794} 3293}
4795impl From<LetStmt> for Stmt { 3294impl From<Const> for AssocItem {
4796 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } 3295 fn from(node: Const) -> AssocItem { AssocItem::Const(node) }
4797} 3296}
4798impl From<ExprStmt> for Stmt { 3297impl From<Fn> for AssocItem {
4799 fn from(node: ExprStmt) -> Stmt { Stmt::ExprStmt(node) } 3298 fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) }
3299}
3300impl From<MacroCall> for AssocItem {
3301 fn from(node: MacroCall) -> AssocItem { AssocItem::MacroCall(node) }
4800} 3302}
4801impl AstNode for Stmt { 3303impl From<TypeAlias> for AssocItem {
3304 fn from(node: TypeAlias) -> AssocItem { AssocItem::TypeAlias(node) }
3305}
3306impl AstNode for AssocItem {
4802 fn can_cast(kind: SyntaxKind) -> bool { 3307 fn can_cast(kind: SyntaxKind) -> bool {
4803 match kind { 3308 match kind {
4804 LET_STMT | EXPR_STMT => true, 3309 CONST | FN | MACRO_CALL | TYPE_ALIAS => true,
4805 _ => false, 3310 _ => false,
4806 } 3311 }
4807 } 3312 }
4808 fn cast(syntax: SyntaxNode) -> Option<Self> { 3313 fn cast(syntax: SyntaxNode) -> Option<Self> {
4809 let res = match syntax.kind() { 3314 let res = match syntax.kind() {
4810 LET_STMT => Stmt::LetStmt(LetStmt { syntax }), 3315 CONST => AssocItem::Const(Const { syntax }),
4811 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }), 3316 FN => AssocItem::Fn(Fn { syntax }),
3317 MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }),
3318 TYPE_ALIAS => AssocItem::TypeAlias(TypeAlias { syntax }),
4812 _ => return None, 3319 _ => return None,
4813 }; 3320 };
4814 Some(res) 3321 Some(res)
4815 } 3322 }
4816 fn syntax(&self) -> &SyntaxNode { 3323 fn syntax(&self) -> &SyntaxNode {
4817 match self { 3324 match self {
4818 Stmt::LetStmt(it) => &it.syntax, 3325 AssocItem::Const(it) => &it.syntax,
4819 Stmt::ExprStmt(it) => &it.syntax, 3326 AssocItem::Fn(it) => &it.syntax,
3327 AssocItem::MacroCall(it) => &it.syntax,
3328 AssocItem::TypeAlias(it) => &it.syntax,
4820 } 3329 }
4821 } 3330 }
4822} 3331}
4823impl From<RecordFieldDefList> for FieldDefList { 3332impl From<Fn> for ExternItem {
4824 fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) } 3333 fn from(node: Fn) -> ExternItem { ExternItem::Fn(node) }
4825} 3334}
4826impl From<TupleFieldDefList> for FieldDefList { 3335impl From<MacroCall> for ExternItem {
4827 fn from(node: TupleFieldDefList) -> FieldDefList { FieldDefList::TupleFieldDefList(node) } 3336 fn from(node: MacroCall) -> ExternItem { ExternItem::MacroCall(node) }
4828} 3337}
4829impl AstNode for FieldDefList { 3338impl From<Static> for ExternItem {
3339 fn from(node: Static) -> ExternItem { ExternItem::Static(node) }
3340}
3341impl AstNode for ExternItem {
4830 fn can_cast(kind: SyntaxKind) -> bool { 3342 fn can_cast(kind: SyntaxKind) -> bool {
4831 match kind { 3343 match kind {
4832 RECORD_FIELD_DEF_LIST | TUPLE_FIELD_DEF_LIST => true, 3344 FN | MACRO_CALL | STATIC => true,
4833 _ => false, 3345 _ => false,
4834 } 3346 }
4835 } 3347 }
4836 fn cast(syntax: SyntaxNode) -> Option<Self> { 3348 fn cast(syntax: SyntaxNode) -> Option<Self> {
4837 let res = match syntax.kind() { 3349 let res = match syntax.kind() {
4838 RECORD_FIELD_DEF_LIST => { 3350 FN => ExternItem::Fn(Fn { syntax }),
4839 FieldDefList::RecordFieldDefList(RecordFieldDefList { syntax }) 3351 MACRO_CALL => ExternItem::MacroCall(MacroCall { syntax }),
4840 } 3352 STATIC => ExternItem::Static(Static { syntax }),
4841 TUPLE_FIELD_DEF_LIST => FieldDefList::TupleFieldDefList(TupleFieldDefList { syntax }),
4842 _ => return None, 3353 _ => return None,
4843 }; 3354 };
4844 Some(res) 3355 Some(res)
4845 } 3356 }
4846 fn syntax(&self) -> &SyntaxNode { 3357 fn syntax(&self) -> &SyntaxNode {
4847 match self { 3358 match self {
4848 FieldDefList::RecordFieldDefList(it) => &it.syntax, 3359 ExternItem::Fn(it) => &it.syntax,
4849 FieldDefList::TupleFieldDefList(it) => &it.syntax, 3360 ExternItem::MacroCall(it) => &it.syntax,
3361 ExternItem::Static(it) => &it.syntax,
4850 } 3362 }
4851 } 3363 }
4852} 3364}
4853impl std::fmt::Display for NominalDef { 3365impl From<ConstParam> for GenericParam {
4854 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3366 fn from(node: ConstParam) -> GenericParam { GenericParam::ConstParam(node) }
4855 std::fmt::Display::fmt(self.syntax(), f)
4856 }
4857} 3367}
4858impl std::fmt::Display for GenericParam { 3368impl From<LifetimeParam> for GenericParam {
4859 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3369 fn from(node: LifetimeParam) -> GenericParam { GenericParam::LifetimeParam(node) }
4860 std::fmt::Display::fmt(self.syntax(), f)
4861 }
4862} 3370}
4863impl std::fmt::Display for GenericArg { 3371impl From<TypeParam> for GenericParam {
4864 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3372 fn from(node: TypeParam) -> GenericParam { GenericParam::TypeParam(node) }
4865 std::fmt::Display::fmt(self.syntax(), f) 3373}
3374impl AstNode for GenericParam {
3375 fn can_cast(kind: SyntaxKind) -> bool {
3376 match kind {
3377 CONST_PARAM | LIFETIME_PARAM | TYPE_PARAM => true,
3378 _ => false,
3379 }
3380 }
3381 fn cast(syntax: SyntaxNode) -> Option<Self> {
3382 let res = match syntax.kind() {
3383 CONST_PARAM => GenericParam::ConstParam(ConstParam { syntax }),
3384 LIFETIME_PARAM => GenericParam::LifetimeParam(LifetimeParam { syntax }),
3385 TYPE_PARAM => GenericParam::TypeParam(TypeParam { syntax }),
3386 _ => return None,
3387 };
3388 Some(res)
3389 }
3390 fn syntax(&self) -> &SyntaxNode {
3391 match self {
3392 GenericParam::ConstParam(it) => &it.syntax,
3393 GenericParam::LifetimeParam(it) => &it.syntax,
3394 GenericParam::TypeParam(it) => &it.syntax,
3395 }
4866 } 3396 }
4867} 3397}
4868impl std::fmt::Display for TypeRef { 3398impl std::fmt::Display for GenericArg {
4869 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3399 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4870 std::fmt::Display::fmt(self.syntax(), f) 3400 std::fmt::Display::fmt(self.syntax(), f)
4871 } 3401 }
4872} 3402}
4873impl std::fmt::Display for ModuleItem { 3403impl std::fmt::Display for Type {
4874 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3404 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4875 std::fmt::Display::fmt(self.syntax(), f) 3405 std::fmt::Display::fmt(self.syntax(), f)
4876 } 3406 }
4877} 3407}
4878impl std::fmt::Display for AssocItem { 3408impl std::fmt::Display for Expr {
4879 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3409 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4880 std::fmt::Display::fmt(self.syntax(), f) 3410 std::fmt::Display::fmt(self.syntax(), f)
4881 } 3411 }
4882} 3412}
4883impl std::fmt::Display for ExternItem { 3413impl std::fmt::Display for Item {
4884 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3414 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4885 std::fmt::Display::fmt(self.syntax(), f) 3415 std::fmt::Display::fmt(self.syntax(), f)
4886 } 3416 }
4887} 3417}
4888impl std::fmt::Display for Expr { 3418impl std::fmt::Display for Stmt {
4889 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3419 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4890 std::fmt::Display::fmt(self.syntax(), f) 3420 std::fmt::Display::fmt(self.syntax(), f)
4891 } 3421 }
@@ -4895,642 +3425,642 @@ impl std::fmt::Display for Pat {
4895 std::fmt::Display::fmt(self.syntax(), f) 3425 std::fmt::Display::fmt(self.syntax(), f)
4896 } 3426 }
4897} 3427}
4898impl std::fmt::Display for RecordInnerPat { 3428impl std::fmt::Display for FieldList {
4899 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3429 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4900 std::fmt::Display::fmt(self.syntax(), f) 3430 std::fmt::Display::fmt(self.syntax(), f)
4901 } 3431 }
4902} 3432}
4903impl std::fmt::Display for AttrInput { 3433impl std::fmt::Display for AdtDef {
4904 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3434 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4905 std::fmt::Display::fmt(self.syntax(), f) 3435 std::fmt::Display::fmt(self.syntax(), f)
4906 } 3436 }
4907} 3437}
4908impl std::fmt::Display for Stmt { 3438impl std::fmt::Display for AssocItem {
4909 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3439 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4910 std::fmt::Display::fmt(self.syntax(), f) 3440 std::fmt::Display::fmt(self.syntax(), f)
4911 } 3441 }
4912} 3442}
4913impl std::fmt::Display for FieldDefList { 3443impl std::fmt::Display for ExternItem {
4914 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3444 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4915 std::fmt::Display::fmt(self.syntax(), f) 3445 std::fmt::Display::fmt(self.syntax(), f)
4916 } 3446 }
4917} 3447}
4918impl std::fmt::Display for SourceFile { 3448impl std::fmt::Display for GenericParam {
4919 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3449 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4920 std::fmt::Display::fmt(self.syntax(), f) 3450 std::fmt::Display::fmt(self.syntax(), f)
4921 } 3451 }
4922} 3452}
4923impl std::fmt::Display for FnDef { 3453impl std::fmt::Display for Name {
4924 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3454 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4925 std::fmt::Display::fmt(self.syntax(), f) 3455 std::fmt::Display::fmt(self.syntax(), f)
4926 } 3456 }
4927} 3457}
4928impl std::fmt::Display for RetType { 3458impl std::fmt::Display for NameRef {
4929 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3459 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4930 std::fmt::Display::fmt(self.syntax(), f) 3460 std::fmt::Display::fmt(self.syntax(), f)
4931 } 3461 }
4932} 3462}
4933impl std::fmt::Display for StructDef { 3463impl std::fmt::Display for Path {
4934 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3464 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4935 std::fmt::Display::fmt(self.syntax(), f) 3465 std::fmt::Display::fmt(self.syntax(), f)
4936 } 3466 }
4937} 3467}
4938impl std::fmt::Display for UnionDef { 3468impl std::fmt::Display for PathSegment {
4939 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3469 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4940 std::fmt::Display::fmt(self.syntax(), f) 3470 std::fmt::Display::fmt(self.syntax(), f)
4941 } 3471 }
4942} 3472}
4943impl std::fmt::Display for RecordFieldDefList { 3473impl std::fmt::Display for GenericArgList {
4944 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3474 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4945 std::fmt::Display::fmt(self.syntax(), f) 3475 std::fmt::Display::fmt(self.syntax(), f)
4946 } 3476 }
4947} 3477}
4948impl std::fmt::Display for RecordFieldDef { 3478impl std::fmt::Display for ParamList {
4949 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3479 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4950 std::fmt::Display::fmt(self.syntax(), f) 3480 std::fmt::Display::fmt(self.syntax(), f)
4951 } 3481 }
4952} 3482}
4953impl std::fmt::Display for TupleFieldDefList { 3483impl std::fmt::Display for RetType {
4954 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3484 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4955 std::fmt::Display::fmt(self.syntax(), f) 3485 std::fmt::Display::fmt(self.syntax(), f)
4956 } 3486 }
4957} 3487}
4958impl std::fmt::Display for TupleFieldDef { 3488impl std::fmt::Display for PathType {
4959 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3489 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4960 std::fmt::Display::fmt(self.syntax(), f) 3490 std::fmt::Display::fmt(self.syntax(), f)
4961 } 3491 }
4962} 3492}
4963impl std::fmt::Display for EnumDef { 3493impl std::fmt::Display for TypeArg {
4964 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3494 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4965 std::fmt::Display::fmt(self.syntax(), f) 3495 std::fmt::Display::fmt(self.syntax(), f)
4966 } 3496 }
4967} 3497}
4968impl std::fmt::Display for EnumVariantList { 3498impl std::fmt::Display for AssocTypeArg {
4969 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3499 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4970 std::fmt::Display::fmt(self.syntax(), f) 3500 std::fmt::Display::fmt(self.syntax(), f)
4971 } 3501 }
4972} 3502}
4973impl std::fmt::Display for EnumVariant { 3503impl std::fmt::Display for LifetimeArg {
4974 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3504 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4975 std::fmt::Display::fmt(self.syntax(), f) 3505 std::fmt::Display::fmt(self.syntax(), f)
4976 } 3506 }
4977} 3507}
4978impl std::fmt::Display for TraitDef { 3508impl std::fmt::Display for ConstArg {
4979 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3509 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4980 std::fmt::Display::fmt(self.syntax(), f) 3510 std::fmt::Display::fmt(self.syntax(), f)
4981 } 3511 }
4982} 3512}
4983impl std::fmt::Display for Module { 3513impl std::fmt::Display for TypeBoundList {
4984 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3514 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4985 std::fmt::Display::fmt(self.syntax(), f) 3515 std::fmt::Display::fmt(self.syntax(), f)
4986 } 3516 }
4987} 3517}
4988impl std::fmt::Display for ItemList { 3518impl std::fmt::Display for MacroCall {
4989 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3519 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4990 std::fmt::Display::fmt(self.syntax(), f) 3520 std::fmt::Display::fmt(self.syntax(), f)
4991 } 3521 }
4992} 3522}
4993impl std::fmt::Display for ConstDef { 3523impl std::fmt::Display for Attr {
4994 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3524 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4995 std::fmt::Display::fmt(self.syntax(), f) 3525 std::fmt::Display::fmt(self.syntax(), f)
4996 } 3526 }
4997} 3527}
4998impl std::fmt::Display for StaticDef { 3528impl std::fmt::Display for TokenTree {
4999 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3529 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5000 std::fmt::Display::fmt(self.syntax(), f) 3530 std::fmt::Display::fmt(self.syntax(), f)
5001 } 3531 }
5002} 3532}
5003impl std::fmt::Display for TypeAliasDef { 3533impl std::fmt::Display for MacroItems {
5004 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3534 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5005 std::fmt::Display::fmt(self.syntax(), f) 3535 std::fmt::Display::fmt(self.syntax(), f)
5006 } 3536 }
5007} 3537}
5008impl std::fmt::Display for ImplDef { 3538impl std::fmt::Display for MacroStmts {
5009 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3539 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5010 std::fmt::Display::fmt(self.syntax(), f) 3540 std::fmt::Display::fmt(self.syntax(), f)
5011 } 3541 }
5012} 3542}
5013impl std::fmt::Display for ParenType { 3543impl std::fmt::Display for SourceFile {
5014 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3544 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5015 std::fmt::Display::fmt(self.syntax(), f) 3545 std::fmt::Display::fmt(self.syntax(), f)
5016 } 3546 }
5017} 3547}
5018impl std::fmt::Display for TupleType { 3548impl std::fmt::Display for Const {
5019 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3549 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5020 std::fmt::Display::fmt(self.syntax(), f) 3550 std::fmt::Display::fmt(self.syntax(), f)
5021 } 3551 }
5022} 3552}
5023impl std::fmt::Display for NeverType { 3553impl std::fmt::Display for Enum {
5024 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3554 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5025 std::fmt::Display::fmt(self.syntax(), f) 3555 std::fmt::Display::fmt(self.syntax(), f)
5026 } 3556 }
5027} 3557}
5028impl std::fmt::Display for PathType { 3558impl std::fmt::Display for ExternBlock {
5029 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3559 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5030 std::fmt::Display::fmt(self.syntax(), f) 3560 std::fmt::Display::fmt(self.syntax(), f)
5031 } 3561 }
5032} 3562}
5033impl std::fmt::Display for PointerType { 3563impl std::fmt::Display for ExternCrate {
5034 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3564 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5035 std::fmt::Display::fmt(self.syntax(), f) 3565 std::fmt::Display::fmt(self.syntax(), f)
5036 } 3566 }
5037} 3567}
5038impl std::fmt::Display for ArrayType { 3568impl std::fmt::Display for Fn {
5039 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3569 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5040 std::fmt::Display::fmt(self.syntax(), f) 3570 std::fmt::Display::fmt(self.syntax(), f)
5041 } 3571 }
5042} 3572}
5043impl std::fmt::Display for SliceType { 3573impl std::fmt::Display for Impl {
5044 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3574 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5045 std::fmt::Display::fmt(self.syntax(), f) 3575 std::fmt::Display::fmt(self.syntax(), f)
5046 } 3576 }
5047} 3577}
5048impl std::fmt::Display for ReferenceType { 3578impl std::fmt::Display for Module {
5049 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3579 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5050 std::fmt::Display::fmt(self.syntax(), f) 3580 std::fmt::Display::fmt(self.syntax(), f)
5051 } 3581 }
5052} 3582}
5053impl std::fmt::Display for PlaceholderType { 3583impl std::fmt::Display for Static {
5054 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3584 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5055 std::fmt::Display::fmt(self.syntax(), f) 3585 std::fmt::Display::fmt(self.syntax(), f)
5056 } 3586 }
5057} 3587}
5058impl std::fmt::Display for FnPointerType { 3588impl std::fmt::Display for Struct {
5059 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3589 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5060 std::fmt::Display::fmt(self.syntax(), f) 3590 std::fmt::Display::fmt(self.syntax(), f)
5061 } 3591 }
5062} 3592}
5063impl std::fmt::Display for ForType { 3593impl std::fmt::Display for Trait {
5064 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3594 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5065 std::fmt::Display::fmt(self.syntax(), f) 3595 std::fmt::Display::fmt(self.syntax(), f)
5066 } 3596 }
5067} 3597}
5068impl std::fmt::Display for ImplTraitType { 3598impl std::fmt::Display for TypeAlias {
5069 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3599 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5070 std::fmt::Display::fmt(self.syntax(), f) 3600 std::fmt::Display::fmt(self.syntax(), f)
5071 } 3601 }
5072} 3602}
5073impl std::fmt::Display for DynTraitType { 3603impl std::fmt::Display for Union {
5074 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3604 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5075 std::fmt::Display::fmt(self.syntax(), f) 3605 std::fmt::Display::fmt(self.syntax(), f)
5076 } 3606 }
5077} 3607}
5078impl std::fmt::Display for TupleExpr { 3608impl std::fmt::Display for Use {
5079 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3609 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5080 std::fmt::Display::fmt(self.syntax(), f) 3610 std::fmt::Display::fmt(self.syntax(), f)
5081 } 3611 }
5082} 3612}
5083impl std::fmt::Display for ArrayExpr { 3613impl std::fmt::Display for Visibility {
5084 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3614 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5085 std::fmt::Display::fmt(self.syntax(), f) 3615 std::fmt::Display::fmt(self.syntax(), f)
5086 } 3616 }
5087} 3617}
5088impl std::fmt::Display for ParenExpr { 3618impl std::fmt::Display for ItemList {
5089 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3619 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5090 std::fmt::Display::fmt(self.syntax(), f) 3620 std::fmt::Display::fmt(self.syntax(), f)
5091 } 3621 }
5092} 3622}
5093impl std::fmt::Display for PathExpr { 3623impl std::fmt::Display for Rename {
5094 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3624 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5095 std::fmt::Display::fmt(self.syntax(), f) 3625 std::fmt::Display::fmt(self.syntax(), f)
5096 } 3626 }
5097} 3627}
5098impl std::fmt::Display for LambdaExpr { 3628impl std::fmt::Display for UseTree {
5099 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3629 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5100 std::fmt::Display::fmt(self.syntax(), f) 3630 std::fmt::Display::fmt(self.syntax(), f)
5101 } 3631 }
5102} 3632}
5103impl std::fmt::Display for IfExpr { 3633impl std::fmt::Display for UseTreeList {
5104 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3634 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5105 std::fmt::Display::fmt(self.syntax(), f) 3635 std::fmt::Display::fmt(self.syntax(), f)
5106 } 3636 }
5107} 3637}
5108impl std::fmt::Display for LoopExpr { 3638impl std::fmt::Display for Abi {
5109 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3639 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5110 std::fmt::Display::fmt(self.syntax(), f) 3640 std::fmt::Display::fmt(self.syntax(), f)
5111 } 3641 }
5112} 3642}
5113impl std::fmt::Display for EffectExpr { 3643impl std::fmt::Display for GenericParamList {
5114 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3644 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5115 std::fmt::Display::fmt(self.syntax(), f) 3645 std::fmt::Display::fmt(self.syntax(), f)
5116 } 3646 }
5117} 3647}
5118impl std::fmt::Display for ForExpr { 3648impl std::fmt::Display for WhereClause {
5119 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3649 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5120 std::fmt::Display::fmt(self.syntax(), f) 3650 std::fmt::Display::fmt(self.syntax(), f)
5121 } 3651 }
5122} 3652}
5123impl std::fmt::Display for WhileExpr { 3653impl std::fmt::Display for BlockExpr {
5124 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3654 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5125 std::fmt::Display::fmt(self.syntax(), f) 3655 std::fmt::Display::fmt(self.syntax(), f)
5126 } 3656 }
5127} 3657}
5128impl std::fmt::Display for ContinueExpr { 3658impl std::fmt::Display for SelfParam {
5129 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3659 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5130 std::fmt::Display::fmt(self.syntax(), f) 3660 std::fmt::Display::fmt(self.syntax(), f)
5131 } 3661 }
5132} 3662}
5133impl std::fmt::Display for BreakExpr { 3663impl std::fmt::Display for Param {
5134 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3664 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5135 std::fmt::Display::fmt(self.syntax(), f) 3665 std::fmt::Display::fmt(self.syntax(), f)
5136 } 3666 }
5137} 3667}
5138impl std::fmt::Display for Label { 3668impl std::fmt::Display for RecordFieldList {
5139 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3669 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5140 std::fmt::Display::fmt(self.syntax(), f) 3670 std::fmt::Display::fmt(self.syntax(), f)
5141 } 3671 }
5142} 3672}
5143impl std::fmt::Display for BlockExpr { 3673impl std::fmt::Display for TupleFieldList {
5144 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3674 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5145 std::fmt::Display::fmt(self.syntax(), f) 3675 std::fmt::Display::fmt(self.syntax(), f)
5146 } 3676 }
5147} 3677}
5148impl std::fmt::Display for ReturnExpr { 3678impl std::fmt::Display for RecordField {
5149 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3679 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5150 std::fmt::Display::fmt(self.syntax(), f) 3680 std::fmt::Display::fmt(self.syntax(), f)
5151 } 3681 }
5152} 3682}
5153impl std::fmt::Display for CallExpr { 3683impl std::fmt::Display for TupleField {
5154 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3684 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5155 std::fmt::Display::fmt(self.syntax(), f) 3685 std::fmt::Display::fmt(self.syntax(), f)
5156 } 3686 }
5157} 3687}
5158impl std::fmt::Display for MethodCallExpr { 3688impl std::fmt::Display for VariantList {
5159 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3689 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5160 std::fmt::Display::fmt(self.syntax(), f) 3690 std::fmt::Display::fmt(self.syntax(), f)
5161 } 3691 }
5162} 3692}
5163impl std::fmt::Display for IndexExpr { 3693impl std::fmt::Display for Variant {
5164 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3694 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5165 std::fmt::Display::fmt(self.syntax(), f) 3695 std::fmt::Display::fmt(self.syntax(), f)
5166 } 3696 }
5167} 3697}
5168impl std::fmt::Display for FieldExpr { 3698impl std::fmt::Display for AssocItemList {
5169 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3699 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5170 std::fmt::Display::fmt(self.syntax(), f) 3700 std::fmt::Display::fmt(self.syntax(), f)
5171 } 3701 }
5172} 3702}
5173impl std::fmt::Display for AwaitExpr { 3703impl std::fmt::Display for ExternItemList {
5174 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3704 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5175 std::fmt::Display::fmt(self.syntax(), f) 3705 std::fmt::Display::fmt(self.syntax(), f)
5176 } 3706 }
5177} 3707}
5178impl std::fmt::Display for TryExpr { 3708impl std::fmt::Display for ConstParam {
5179 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3709 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5180 std::fmt::Display::fmt(self.syntax(), f) 3710 std::fmt::Display::fmt(self.syntax(), f)
5181 } 3711 }
5182} 3712}
5183impl std::fmt::Display for CastExpr { 3713impl std::fmt::Display for LifetimeParam {
5184 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3714 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5185 std::fmt::Display::fmt(self.syntax(), f) 3715 std::fmt::Display::fmt(self.syntax(), f)
5186 } 3716 }
5187} 3717}
5188impl std::fmt::Display for RefExpr { 3718impl std::fmt::Display for TypeParam {
5189 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3719 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5190 std::fmt::Display::fmt(self.syntax(), f) 3720 std::fmt::Display::fmt(self.syntax(), f)
5191 } 3721 }
5192} 3722}
5193impl std::fmt::Display for PrefixExpr { 3723impl std::fmt::Display for WherePred {
5194 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3724 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5195 std::fmt::Display::fmt(self.syntax(), f) 3725 std::fmt::Display::fmt(self.syntax(), f)
5196 } 3726 }
5197} 3727}
5198impl std::fmt::Display for BoxExpr { 3728impl std::fmt::Display for Literal {
5199 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3729 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5200 std::fmt::Display::fmt(self.syntax(), f) 3730 std::fmt::Display::fmt(self.syntax(), f)
5201 } 3731 }
5202} 3732}
5203impl std::fmt::Display for RangeExpr { 3733impl std::fmt::Display for ExprStmt {
5204 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3734 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5205 std::fmt::Display::fmt(self.syntax(), f) 3735 std::fmt::Display::fmt(self.syntax(), f)
5206 } 3736 }
5207} 3737}
5208impl std::fmt::Display for BinExpr { 3738impl std::fmt::Display for LetStmt {
5209 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3739 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5210 std::fmt::Display::fmt(self.syntax(), f) 3740 std::fmt::Display::fmt(self.syntax(), f)
5211 } 3741 }
5212} 3742}
5213impl std::fmt::Display for Literal { 3743impl std::fmt::Display for ArrayExpr {
5214 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3744 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5215 std::fmt::Display::fmt(self.syntax(), f) 3745 std::fmt::Display::fmt(self.syntax(), f)
5216 } 3746 }
5217} 3747}
5218impl std::fmt::Display for MatchExpr { 3748impl std::fmt::Display for AwaitExpr {
5219 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3749 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5220 std::fmt::Display::fmt(self.syntax(), f) 3750 std::fmt::Display::fmt(self.syntax(), f)
5221 } 3751 }
5222} 3752}
5223impl std::fmt::Display for MatchArmList { 3753impl std::fmt::Display for BinExpr {
5224 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3754 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5225 std::fmt::Display::fmt(self.syntax(), f) 3755 std::fmt::Display::fmt(self.syntax(), f)
5226 } 3756 }
5227} 3757}
5228impl std::fmt::Display for MatchArm { 3758impl std::fmt::Display for BoxExpr {
5229 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3759 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5230 std::fmt::Display::fmt(self.syntax(), f) 3760 std::fmt::Display::fmt(self.syntax(), f)
5231 } 3761 }
5232} 3762}
5233impl std::fmt::Display for MatchGuard { 3763impl std::fmt::Display for BreakExpr {
5234 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3764 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5235 std::fmt::Display::fmt(self.syntax(), f) 3765 std::fmt::Display::fmt(self.syntax(), f)
5236 } 3766 }
5237} 3767}
5238impl std::fmt::Display for RecordLit { 3768impl std::fmt::Display for CallExpr {
5239 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3769 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5240 std::fmt::Display::fmt(self.syntax(), f) 3770 std::fmt::Display::fmt(self.syntax(), f)
5241 } 3771 }
5242} 3772}
5243impl std::fmt::Display for RecordFieldList { 3773impl std::fmt::Display for CastExpr {
5244 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3774 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5245 std::fmt::Display::fmt(self.syntax(), f) 3775 std::fmt::Display::fmt(self.syntax(), f)
5246 } 3776 }
5247} 3777}
5248impl std::fmt::Display for RecordField { 3778impl std::fmt::Display for ClosureExpr {
5249 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3779 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5250 std::fmt::Display::fmt(self.syntax(), f) 3780 std::fmt::Display::fmt(self.syntax(), f)
5251 } 3781 }
5252} 3782}
5253impl std::fmt::Display for OrPat { 3783impl std::fmt::Display for ContinueExpr {
5254 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3784 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5255 std::fmt::Display::fmt(self.syntax(), f) 3785 std::fmt::Display::fmt(self.syntax(), f)
5256 } 3786 }
5257} 3787}
5258impl std::fmt::Display for ParenPat { 3788impl std::fmt::Display for EffectExpr {
5259 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3789 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5260 std::fmt::Display::fmt(self.syntax(), f) 3790 std::fmt::Display::fmt(self.syntax(), f)
5261 } 3791 }
5262} 3792}
5263impl std::fmt::Display for RefPat { 3793impl std::fmt::Display for FieldExpr {
5264 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3794 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5265 std::fmt::Display::fmt(self.syntax(), f) 3795 std::fmt::Display::fmt(self.syntax(), f)
5266 } 3796 }
5267} 3797}
5268impl std::fmt::Display for BoxPat { 3798impl std::fmt::Display for ForExpr {
5269 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3799 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5270 std::fmt::Display::fmt(self.syntax(), f) 3800 std::fmt::Display::fmt(self.syntax(), f)
5271 } 3801 }
5272} 3802}
5273impl std::fmt::Display for BindPat { 3803impl std::fmt::Display for IfExpr {
5274 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3804 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5275 std::fmt::Display::fmt(self.syntax(), f) 3805 std::fmt::Display::fmt(self.syntax(), f)
5276 } 3806 }
5277} 3807}
5278impl std::fmt::Display for PlaceholderPat { 3808impl std::fmt::Display for IndexExpr {
5279 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3809 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5280 std::fmt::Display::fmt(self.syntax(), f) 3810 std::fmt::Display::fmt(self.syntax(), f)
5281 } 3811 }
5282} 3812}
5283impl std::fmt::Display for DotDotPat { 3813impl std::fmt::Display for LoopExpr {
5284 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3814 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5285 std::fmt::Display::fmt(self.syntax(), f) 3815 std::fmt::Display::fmt(self.syntax(), f)
5286 } 3816 }
5287} 3817}
5288impl std::fmt::Display for PathPat { 3818impl std::fmt::Display for MatchExpr {
5289 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3819 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5290 std::fmt::Display::fmt(self.syntax(), f) 3820 std::fmt::Display::fmt(self.syntax(), f)
5291 } 3821 }
5292} 3822}
5293impl std::fmt::Display for SlicePat { 3823impl std::fmt::Display for MethodCallExpr {
5294 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3824 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5295 std::fmt::Display::fmt(self.syntax(), f) 3825 std::fmt::Display::fmt(self.syntax(), f)
5296 } 3826 }
5297} 3827}
5298impl std::fmt::Display for RangePat { 3828impl std::fmt::Display for ParenExpr {
5299 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3829 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5300 std::fmt::Display::fmt(self.syntax(), f) 3830 std::fmt::Display::fmt(self.syntax(), f)
5301 } 3831 }
5302} 3832}
5303impl std::fmt::Display for LiteralPat { 3833impl std::fmt::Display for PathExpr {
5304 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3834 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5305 std::fmt::Display::fmt(self.syntax(), f) 3835 std::fmt::Display::fmt(self.syntax(), f)
5306 } 3836 }
5307} 3837}
5308impl std::fmt::Display for MacroPat { 3838impl std::fmt::Display for PrefixExpr {
5309 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3839 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5310 std::fmt::Display::fmt(self.syntax(), f) 3840 std::fmt::Display::fmt(self.syntax(), f)
5311 } 3841 }
5312} 3842}
5313impl std::fmt::Display for RecordPat { 3843impl std::fmt::Display for RangeExpr {
5314 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3844 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5315 std::fmt::Display::fmt(self.syntax(), f) 3845 std::fmt::Display::fmt(self.syntax(), f)
5316 } 3846 }
5317} 3847}
5318impl std::fmt::Display for RecordFieldPatList { 3848impl std::fmt::Display for RecordExpr {
5319 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3849 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5320 std::fmt::Display::fmt(self.syntax(), f) 3850 std::fmt::Display::fmt(self.syntax(), f)
5321 } 3851 }
5322} 3852}
5323impl std::fmt::Display for RecordFieldPat { 3853impl std::fmt::Display for RefExpr {
5324 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3854 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5325 std::fmt::Display::fmt(self.syntax(), f) 3855 std::fmt::Display::fmt(self.syntax(), f)
5326 } 3856 }
5327} 3857}
5328impl std::fmt::Display for TupleStructPat { 3858impl std::fmt::Display for ReturnExpr {
5329 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3859 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5330 std::fmt::Display::fmt(self.syntax(), f) 3860 std::fmt::Display::fmt(self.syntax(), f)
5331 } 3861 }
5332} 3862}
5333impl std::fmt::Display for TuplePat { 3863impl std::fmt::Display for TryExpr {
5334 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3864 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5335 std::fmt::Display::fmt(self.syntax(), f) 3865 std::fmt::Display::fmt(self.syntax(), f)
5336 } 3866 }
5337} 3867}
5338impl std::fmt::Display for Visibility { 3868impl std::fmt::Display for TupleExpr {
5339 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3869 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5340 std::fmt::Display::fmt(self.syntax(), f) 3870 std::fmt::Display::fmt(self.syntax(), f)
5341 } 3871 }
5342} 3872}
5343impl std::fmt::Display for Name { 3873impl std::fmt::Display for WhileExpr {
5344 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3874 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5345 std::fmt::Display::fmt(self.syntax(), f) 3875 std::fmt::Display::fmt(self.syntax(), f)
5346 } 3876 }
5347} 3877}
5348impl std::fmt::Display for NameRef { 3878impl std::fmt::Display for Label {
5349 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3879 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5350 std::fmt::Display::fmt(self.syntax(), f) 3880 std::fmt::Display::fmt(self.syntax(), f)
5351 } 3881 }
5352} 3882}
5353impl std::fmt::Display for MacroCall { 3883impl std::fmt::Display for RecordExprFieldList {
5354 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3884 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5355 std::fmt::Display::fmt(self.syntax(), f) 3885 std::fmt::Display::fmt(self.syntax(), f)
5356 } 3886 }
5357} 3887}
5358impl std::fmt::Display for Attr { 3888impl std::fmt::Display for RecordExprField {
5359 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3889 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5360 std::fmt::Display::fmt(self.syntax(), f) 3890 std::fmt::Display::fmt(self.syntax(), f)
5361 } 3891 }
5362} 3892}
5363impl std::fmt::Display for TokenTree { 3893impl std::fmt::Display for ArgList {
5364 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3894 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5365 std::fmt::Display::fmt(self.syntax(), f) 3895 std::fmt::Display::fmt(self.syntax(), f)
5366 } 3896 }
5367} 3897}
5368impl std::fmt::Display for TypeParamList { 3898impl std::fmt::Display for Condition {
5369 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3899 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5370 std::fmt::Display::fmt(self.syntax(), f) 3900 std::fmt::Display::fmt(self.syntax(), f)
5371 } 3901 }
5372} 3902}
5373impl std::fmt::Display for TypeParam { 3903impl std::fmt::Display for MatchArmList {
5374 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3904 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5375 std::fmt::Display::fmt(self.syntax(), f) 3905 std::fmt::Display::fmt(self.syntax(), f)
5376 } 3906 }
5377} 3907}
5378impl std::fmt::Display for ConstParam { 3908impl std::fmt::Display for MatchArm {
5379 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3909 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5380 std::fmt::Display::fmt(self.syntax(), f) 3910 std::fmt::Display::fmt(self.syntax(), f)
5381 } 3911 }
5382} 3912}
5383impl std::fmt::Display for LifetimeParam { 3913impl std::fmt::Display for MatchGuard {
5384 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3914 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5385 std::fmt::Display::fmt(self.syntax(), f) 3915 std::fmt::Display::fmt(self.syntax(), f)
5386 } 3916 }
5387} 3917}
5388impl std::fmt::Display for TypeBound { 3918impl std::fmt::Display for ArrayType {
5389 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3919 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5390 std::fmt::Display::fmt(self.syntax(), f) 3920 std::fmt::Display::fmt(self.syntax(), f)
5391 } 3921 }
5392} 3922}
5393impl std::fmt::Display for TypeBoundList { 3923impl std::fmt::Display for DynTraitType {
5394 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3924 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5395 std::fmt::Display::fmt(self.syntax(), f) 3925 std::fmt::Display::fmt(self.syntax(), f)
5396 } 3926 }
5397} 3927}
5398impl std::fmt::Display for WherePred { 3928impl std::fmt::Display for FnPtrType {
5399 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3929 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5400 std::fmt::Display::fmt(self.syntax(), f) 3930 std::fmt::Display::fmt(self.syntax(), f)
5401 } 3931 }
5402} 3932}
5403impl std::fmt::Display for WhereClause { 3933impl std::fmt::Display for ForType {
5404 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3934 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5405 std::fmt::Display::fmt(self.syntax(), f) 3935 std::fmt::Display::fmt(self.syntax(), f)
5406 } 3936 }
5407} 3937}
5408impl std::fmt::Display for Abi { 3938impl std::fmt::Display for ImplTraitType {
5409 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3939 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5410 std::fmt::Display::fmt(self.syntax(), f) 3940 std::fmt::Display::fmt(self.syntax(), f)
5411 } 3941 }
5412} 3942}
5413impl std::fmt::Display for ExprStmt { 3943impl std::fmt::Display for InferType {
5414 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3944 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5415 std::fmt::Display::fmt(self.syntax(), f) 3945 std::fmt::Display::fmt(self.syntax(), f)
5416 } 3946 }
5417} 3947}
5418impl std::fmt::Display for LetStmt { 3948impl std::fmt::Display for NeverType {
5419 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3949 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5420 std::fmt::Display::fmt(self.syntax(), f) 3950 std::fmt::Display::fmt(self.syntax(), f)
5421 } 3951 }
5422} 3952}
5423impl std::fmt::Display for Condition { 3953impl std::fmt::Display for ParenType {
5424 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3954 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5425 std::fmt::Display::fmt(self.syntax(), f) 3955 std::fmt::Display::fmt(self.syntax(), f)
5426 } 3956 }
5427} 3957}
5428impl std::fmt::Display for ParamList { 3958impl std::fmt::Display for PtrType {
5429 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3959 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5430 std::fmt::Display::fmt(self.syntax(), f) 3960 std::fmt::Display::fmt(self.syntax(), f)
5431 } 3961 }
5432} 3962}
5433impl std::fmt::Display for SelfParam { 3963impl std::fmt::Display for RefType {
5434 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3964 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5435 std::fmt::Display::fmt(self.syntax(), f) 3965 std::fmt::Display::fmt(self.syntax(), f)
5436 } 3966 }
5437} 3967}
5438impl std::fmt::Display for Param { 3968impl std::fmt::Display for SliceType {
5439 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3969 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5440 std::fmt::Display::fmt(self.syntax(), f) 3970 std::fmt::Display::fmt(self.syntax(), f)
5441 } 3971 }
5442} 3972}
5443impl std::fmt::Display for UseItem { 3973impl std::fmt::Display for TupleType {
5444 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3974 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5445 std::fmt::Display::fmt(self.syntax(), f) 3975 std::fmt::Display::fmt(self.syntax(), f)
5446 } 3976 }
5447} 3977}
5448impl std::fmt::Display for UseTree { 3978impl std::fmt::Display for TypeBound {
5449 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3979 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5450 std::fmt::Display::fmt(self.syntax(), f) 3980 std::fmt::Display::fmt(self.syntax(), f)
5451 } 3981 }
5452} 3982}
5453impl std::fmt::Display for Alias { 3983impl std::fmt::Display for IdentPat {
5454 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3984 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5455 std::fmt::Display::fmt(self.syntax(), f) 3985 std::fmt::Display::fmt(self.syntax(), f)
5456 } 3986 }
5457} 3987}
5458impl std::fmt::Display for UseTreeList { 3988impl std::fmt::Display for BoxPat {
5459 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3989 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5460 std::fmt::Display::fmt(self.syntax(), f) 3990 std::fmt::Display::fmt(self.syntax(), f)
5461 } 3991 }
5462} 3992}
5463impl std::fmt::Display for ExternCrateItem { 3993impl std::fmt::Display for RestPat {
5464 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3994 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5465 std::fmt::Display::fmt(self.syntax(), f) 3995 std::fmt::Display::fmt(self.syntax(), f)
5466 } 3996 }
5467} 3997}
5468impl std::fmt::Display for ArgList { 3998impl std::fmt::Display for LiteralPat {
5469 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3999 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5470 std::fmt::Display::fmt(self.syntax(), f) 4000 std::fmt::Display::fmt(self.syntax(), f)
5471 } 4001 }
5472} 4002}
5473impl std::fmt::Display for Path { 4003impl std::fmt::Display for MacroPat {
5474 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4004 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5475 std::fmt::Display::fmt(self.syntax(), f) 4005 std::fmt::Display::fmt(self.syntax(), f)
5476 } 4006 }
5477} 4007}
5478impl std::fmt::Display for PathSegment { 4008impl std::fmt::Display for OrPat {
5479 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4009 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5480 std::fmt::Display::fmt(self.syntax(), f) 4010 std::fmt::Display::fmt(self.syntax(), f)
5481 } 4011 }
5482} 4012}
5483impl std::fmt::Display for TypeArgList { 4013impl std::fmt::Display for ParenPat {
5484 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4014 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5485 std::fmt::Display::fmt(self.syntax(), f) 4015 std::fmt::Display::fmt(self.syntax(), f)
5486 } 4016 }
5487} 4017}
5488impl std::fmt::Display for TypeArg { 4018impl std::fmt::Display for PathPat {
5489 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4019 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5490 std::fmt::Display::fmt(self.syntax(), f) 4020 std::fmt::Display::fmt(self.syntax(), f)
5491 } 4021 }
5492} 4022}
5493impl std::fmt::Display for AssocTypeArg { 4023impl std::fmt::Display for WildcardPat {
5494 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4024 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5495 std::fmt::Display::fmt(self.syntax(), f) 4025 std::fmt::Display::fmt(self.syntax(), f)
5496 } 4026 }
5497} 4027}
5498impl std::fmt::Display for LifetimeArg { 4028impl std::fmt::Display for RangePat {
5499 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4029 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5500 std::fmt::Display::fmt(self.syntax(), f) 4030 std::fmt::Display::fmt(self.syntax(), f)
5501 } 4031 }
5502} 4032}
5503impl std::fmt::Display for ConstArg { 4033impl std::fmt::Display for RecordPat {
5504 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4034 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5505 std::fmt::Display::fmt(self.syntax(), f) 4035 std::fmt::Display::fmt(self.syntax(), f)
5506 } 4036 }
5507} 4037}
5508impl std::fmt::Display for MacroItems { 4038impl std::fmt::Display for RefPat {
5509 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4039 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5510 std::fmt::Display::fmt(self.syntax(), f) 4040 std::fmt::Display::fmt(self.syntax(), f)
5511 } 4041 }
5512} 4042}
5513impl std::fmt::Display for MacroStmts { 4043impl std::fmt::Display for SlicePat {
5514 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4044 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5515 std::fmt::Display::fmt(self.syntax(), f) 4045 std::fmt::Display::fmt(self.syntax(), f)
5516 } 4046 }
5517} 4047}
5518impl std::fmt::Display for ExternItemList { 4048impl std::fmt::Display for TuplePat {
5519 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4049 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5520 std::fmt::Display::fmt(self.syntax(), f) 4050 std::fmt::Display::fmt(self.syntax(), f)
5521 } 4051 }
5522} 4052}
5523impl std::fmt::Display for ExternBlock { 4053impl std::fmt::Display for TupleStructPat {
5524 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4054 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5525 std::fmt::Display::fmt(self.syntax(), f) 4055 std::fmt::Display::fmt(self.syntax(), f)
5526 } 4056 }
5527} 4057}
5528impl std::fmt::Display for MetaItem { 4058impl std::fmt::Display for RecordPatFieldList {
5529 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4059 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5530 std::fmt::Display::fmt(self.syntax(), f) 4060 std::fmt::Display::fmt(self.syntax(), f)
5531 } 4061 }
5532} 4062}
5533impl std::fmt::Display for MacroDef { 4063impl std::fmt::Display for RecordPatField {
5534 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4064 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5535 std::fmt::Display::fmt(self.syntax(), f) 4065 std::fmt::Display::fmt(self.syntax(), f)
5536 } 4066 }
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 192c610f1..254a37fe3 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -17,7 +17,7 @@ pub fn name_ref(text: &str) -> ast::NameRef {
17 ast_from_text(&format!("fn f() {{ {}; }}", text)) 17 ast_from_text(&format!("fn f() {{ {}; }}", text))
18} 18}
19 19
20pub fn type_ref(text: &str) -> ast::TypeRef { 20pub fn ty(text: &str) -> ast::Type {
21 ast_from_text(&format!("impl {} for D {{}};", text)) 21 ast_from_text(&format!("impl {} for D {{}};", text))
22} 22}
23 23
@@ -30,14 +30,14 @@ pub fn path_unqualified(segment: ast::PathSegment) -> ast::Path {
30pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path { 30pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path {
31 path_from_text(&format!("{}::{}", qual, segment)) 31 path_from_text(&format!("{}::{}", qual, segment))
32} 32}
33fn path_from_text(text: &str) -> ast::Path { 33pub fn path_from_text(text: &str) -> ast::Path {
34 ast_from_text(text) 34 ast_from_text(text)
35} 35}
36 36
37pub fn use_tree( 37pub fn use_tree(
38 path: ast::Path, 38 path: ast::Path,
39 use_tree_list: Option<ast::UseTreeList>, 39 use_tree_list: Option<ast::UseTreeList>,
40 alias: Option<ast::Alias>, 40 alias: Option<ast::Rename>,
41 add_star: bool, 41 add_star: bool,
42) -> ast::UseTree { 42) -> ast::UseTree {
43 let mut buf = "use ".to_string(); 43 let mut buf = "use ".to_string();
@@ -60,22 +60,22 @@ pub fn use_tree_list(use_trees: impl IntoIterator<Item = ast::UseTree>) -> ast::
60 ast_from_text(&format!("use {{{}}};", use_trees)) 60 ast_from_text(&format!("use {{{}}};", use_trees))
61} 61}
62 62
63pub fn use_item(use_tree: ast::UseTree) -> ast::UseItem { 63pub fn use_(use_tree: ast::UseTree) -> ast::Use {
64 ast_from_text(&format!("use {};", use_tree)) 64 ast_from_text(&format!("use {};", use_tree))
65} 65}
66 66
67pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordField { 67pub fn record_expr_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordExprField {
68 return match expr { 68 return match expr {
69 Some(expr) => from_text(&format!("{}: {}", name, expr)), 69 Some(expr) => from_text(&format!("{}: {}", name, expr)),
70 None => from_text(&name.to_string()), 70 None => from_text(&name.to_string()),
71 }; 71 };
72 72
73 fn from_text(text: &str) -> ast::RecordField { 73 fn from_text(text: &str) -> ast::RecordExprField {
74 ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text)) 74 ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text))
75 } 75 }
76} 76}
77 77
78pub fn record_field_def(name: ast::NameRef, ty: ast::TypeRef) -> ast::RecordFieldDef { 78pub fn record_field(name: ast::NameRef, ty: ast::Type) -> ast::RecordField {
79 ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty)) 79 ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty))
80} 80}
81 81
@@ -148,18 +148,18 @@ pub fn condition(expr: ast::Expr, pattern: Option<ast::Pat>) -> ast::Condition {
148 } 148 }
149} 149}
150 150
151pub fn bind_pat(name: ast::Name) -> ast::BindPat { 151pub fn ident_pat(name: ast::Name) -> ast::IdentPat {
152 return from_text(name.text()); 152 return from_text(name.text());
153 153
154 fn from_text(text: &str) -> ast::BindPat { 154 fn from_text(text: &str) -> ast::IdentPat {
155 ast_from_text(&format!("fn f({}: ())", text)) 155 ast_from_text(&format!("fn f({}: ())", text))
156 } 156 }
157} 157}
158 158
159pub fn placeholder_pat() -> ast::PlaceholderPat { 159pub fn wildcard_pat() -> ast::WildcardPat {
160 return from_text("_"); 160 return from_text("_");
161 161
162 fn from_text(text: &str) -> ast::PlaceholderPat { 162 fn from_text(text: &str) -> ast::WildcardPat {
163 ast_from_text(&format!("fn f({}: ())", text)) 163 ast_from_text(&format!("fn f({}: ())", text))
164 } 164 }
165} 165}
@@ -288,13 +288,13 @@ pub fn visibility_pub_crate() -> ast::Visibility {
288 ast_from_text("pub(crate) struct S") 288 ast_from_text("pub(crate) struct S")
289} 289}
290 290
291pub fn fn_def( 291pub fn fn_(
292 visibility: Option<ast::Visibility>, 292 visibility: Option<ast::Visibility>,
293 fn_name: ast::Name, 293 fn_name: ast::Name,
294 type_params: Option<ast::TypeParamList>, 294 type_params: Option<ast::GenericParamList>,
295 params: ast::ParamList, 295 params: ast::ParamList,
296 body: ast::BlockExpr, 296 body: ast::BlockExpr,
297) -> ast::FnDef { 297) -> ast::Fn {
298 let type_params = 298 let type_params =
299 if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() }; 299 if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() };
300 let visibility = match visibility { 300 let visibility = match visibility {
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs
index 662c6f73e..733e97877 100644
--- a/crates/ra_syntax/src/ast/node_ext.rs
+++ b/crates/ra_syntax/src/ast/node_ext.rs
@@ -7,7 +7,7 @@ use itertools::Itertools;
7use ra_parser::SyntaxKind; 7use ra_parser::SyntaxKind;
8 8
9use crate::{ 9use crate::{
10 ast::{self, support, AstNode, AttrInput, NameOwner, SyntaxNode}, 10 ast::{self, support, AstNode, NameOwner, SyntaxNode},
11 SmolStr, SyntaxElement, SyntaxToken, T, 11 SmolStr, SyntaxElement, SyntaxToken, T,
12}; 12};
13 13
@@ -39,29 +39,23 @@ pub enum AttrKind {
39 39
40impl ast::Attr { 40impl ast::Attr {
41 pub fn as_simple_atom(&self) -> Option<SmolStr> { 41 pub fn as_simple_atom(&self) -> Option<SmolStr> {
42 match self.input() { 42 if self.eq_token().is_some() || self.token_tree().is_some() {
43 None => self.simple_name(), 43 return None;
44 Some(_) => None,
45 } 44 }
45 self.simple_name()
46 } 46 }
47 47
48 pub fn as_simple_call(&self) -> Option<(SmolStr, ast::TokenTree)> { 48 pub fn as_simple_call(&self) -> Option<(SmolStr, ast::TokenTree)> {
49 match self.input() { 49 let tt = self.token_tree()?;
50 Some(AttrInput::TokenTree(tt)) => Some((self.simple_name()?, tt)), 50 Some((self.simple_name()?, tt))
51 _ => None,
52 }
53 } 51 }
54 52
55 pub fn as_simple_key_value(&self) -> Option<(SmolStr, SmolStr)> { 53 pub fn as_simple_key_value(&self) -> Option<(SmolStr, SmolStr)> {
56 match self.input() { 54 let lit = self.literal()?;
57 Some(AttrInput::Literal(lit)) => { 55 let key = self.simple_name()?;
58 let key = self.simple_name()?; 56 // FIXME: escape? raw string?
59 // FIXME: escape? raw string? 57 let value = lit.syntax().first_token()?.text().trim_matches('"').into();
60 let value = lit.syntax().first_token()?.text().trim_matches('"').into(); 58 Some((key, value))
61 Some((key, value))
62 }
63 _ => None,
64 }
65 } 59 }
66 60
67 pub fn simple_name(&self) -> Option<SmolStr> { 61 pub fn simple_name(&self) -> Option<SmolStr> {
@@ -88,7 +82,7 @@ impl ast::Attr {
88#[derive(Debug, Clone, PartialEq, Eq)] 82#[derive(Debug, Clone, PartialEq, Eq)]
89pub enum PathSegmentKind { 83pub enum PathSegmentKind {
90 Name(ast::NameRef), 84 Name(ast::NameRef),
91 Type { type_ref: Option<ast::TypeRef>, trait_ref: Option<ast::PathType> }, 85 Type { type_ref: Option<ast::Type>, trait_ref: Option<ast::PathType> },
92 SelfKw, 86 SelfKw,
93 SuperKw, 87 SuperKw,
94 CrateKw, 88 CrateKw,
@@ -114,8 +108,8 @@ impl ast::PathSegment {
114 // <T> or <T as Trait> 108 // <T> or <T as Trait>
115 // T is any TypeRef, Trait has to be a PathType 109 // T is any TypeRef, Trait has to be a PathType
116 let mut type_refs = 110 let mut type_refs =
117 self.syntax().children().filter(|node| ast::TypeRef::can_cast(node.kind())); 111 self.syntax().children().filter(|node| ast::Type::can_cast(node.kind()));
118 let type_ref = type_refs.next().and_then(ast::TypeRef::cast); 112 let type_ref = type_refs.next().and_then(ast::Type::cast);
119 let trait_ref = type_refs.next().and_then(ast::PathType::cast); 113 let trait_ref = type_refs.next().and_then(ast::PathType::cast);
120 PathSegmentKind::Type { type_ref, trait_ref } 114 PathSegmentKind::Type { type_ref, trait_ref }
121 } 115 }
@@ -141,22 +135,22 @@ impl ast::UseTreeList {
141 } 135 }
142} 136}
143 137
144impl ast::ImplDef { 138impl ast::Impl {
145 pub fn target_type(&self) -> Option<ast::TypeRef> { 139 pub fn self_ty(&self) -> Option<ast::Type> {
146 match self.target() { 140 match self.target() {
147 (Some(t), None) | (_, Some(t)) => Some(t), 141 (Some(t), None) | (_, Some(t)) => Some(t),
148 _ => None, 142 _ => None,
149 } 143 }
150 } 144 }
151 145
152 pub fn target_trait(&self) -> Option<ast::TypeRef> { 146 pub fn trait_(&self) -> Option<ast::Type> {
153 match self.target() { 147 match self.target() {
154 (Some(t), Some(_)) => Some(t), 148 (Some(t), Some(_)) => Some(t),
155 _ => None, 149 _ => None,
156 } 150 }
157 } 151 }
158 152
159 fn target(&self) -> (Option<ast::TypeRef>, Option<ast::TypeRef>) { 153 fn target(&self) -> (Option<ast::Type>, Option<ast::Type>) {
160 let mut types = support::children(self.syntax()); 154 let mut types = support::children(self.syntax());
161 let first = types.next(); 155 let first = types.next();
162 let second = types.next(); 156 let second = types.next();
@@ -166,16 +160,16 @@ impl ast::ImplDef {
166 160
167#[derive(Debug, Clone, PartialEq, Eq)] 161#[derive(Debug, Clone, PartialEq, Eq)]
168pub enum StructKind { 162pub enum StructKind {
169 Record(ast::RecordFieldDefList), 163 Record(ast::RecordFieldList),
170 Tuple(ast::TupleFieldDefList), 164 Tuple(ast::TupleFieldList),
171 Unit, 165 Unit,
172} 166}
173 167
174impl StructKind { 168impl StructKind {
175 fn from_node<N: AstNode>(node: &N) -> StructKind { 169 fn from_node<N: AstNode>(node: &N) -> StructKind {
176 if let Some(nfdl) = support::child::<ast::RecordFieldDefList>(node.syntax()) { 170 if let Some(nfdl) = support::child::<ast::RecordFieldList>(node.syntax()) {
177 StructKind::Record(nfdl) 171 StructKind::Record(nfdl)
178 } else if let Some(pfl) = support::child::<ast::TupleFieldDefList>(node.syntax()) { 172 } else if let Some(pfl) = support::child::<ast::TupleFieldList>(node.syntax()) {
179 StructKind::Tuple(pfl) 173 StructKind::Tuple(pfl)
180 } else { 174 } else {
181 StructKind::Unit 175 StructKind::Unit
@@ -183,17 +177,17 @@ impl StructKind {
183 } 177 }
184} 178}
185 179
186impl ast::StructDef { 180impl ast::Struct {
187 pub fn kind(&self) -> StructKind { 181 pub fn kind(&self) -> StructKind {
188 StructKind::from_node(self) 182 StructKind::from_node(self)
189 } 183 }
190} 184}
191 185
192impl ast::RecordField { 186impl ast::RecordExprField {
193 pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordField> { 187 pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordExprField> {
194 let candidate = 188 let candidate =
195 field_name.syntax().parent().and_then(ast::RecordField::cast).or_else(|| { 189 field_name.syntax().parent().and_then(ast::RecordExprField::cast).or_else(|| {
196 field_name.syntax().ancestors().nth(4).and_then(ast::RecordField::cast) 190 field_name.syntax().ancestors().nth(4).and_then(ast::RecordExprField::cast)
197 })?; 191 })?;
198 if candidate.field_name().as_ref() == Some(field_name) { 192 if candidate.field_name().as_ref() == Some(field_name) {
199 Some(candidate) 193 Some(candidate)
@@ -233,13 +227,13 @@ impl fmt::Display for NameOrNameRef {
233 } 227 }
234} 228}
235 229
236impl ast::RecordFieldPat { 230impl ast::RecordPatField {
237 /// Deals with field init shorthand 231 /// Deals with field init shorthand
238 pub fn field_name(&self) -> Option<NameOrNameRef> { 232 pub fn field_name(&self) -> Option<NameOrNameRef> {
239 if let Some(name_ref) = self.name_ref() { 233 if let Some(name_ref) = self.name_ref() {
240 return Some(NameOrNameRef::NameRef(name_ref)); 234 return Some(NameOrNameRef::NameRef(name_ref));
241 } 235 }
242 if let Some(ast::Pat::BindPat(pat)) = self.pat() { 236 if let Some(ast::Pat::IdentPat(pat)) = self.pat() {
243 let name = pat.name()?; 237 let name = pat.name()?;
244 return Some(NameOrNameRef::Name(name)); 238 return Some(NameOrNameRef::Name(name));
245 } 239 }
@@ -247,12 +241,12 @@ impl ast::RecordFieldPat {
247 } 241 }
248} 242}
249 243
250impl ast::EnumVariant { 244impl ast::Variant {
251 pub fn parent_enum(&self) -> ast::EnumDef { 245 pub fn parent_enum(&self) -> ast::Enum {
252 self.syntax() 246 self.syntax()
253 .parent() 247 .parent()
254 .and_then(|it| it.parent()) 248 .and_then(|it| it.parent())
255 .and_then(ast::EnumDef::cast) 249 .and_then(ast::Enum::cast)
256 .expect("EnumVariants are always nested in Enums") 250 .expect("EnumVariants are always nested in Enums")
257 } 251 }
258 pub fn kind(&self) -> StructKind { 252 pub fn kind(&self) -> StructKind {
@@ -296,18 +290,18 @@ pub struct SlicePatComponents {
296 290
297impl ast::SlicePat { 291impl ast::SlicePat {
298 pub fn components(&self) -> SlicePatComponents { 292 pub fn components(&self) -> SlicePatComponents {
299 let mut args = self.args().peekable(); 293 let mut args = self.pats().peekable();
300 let prefix = args 294 let prefix = args
301 .peeking_take_while(|p| match p { 295 .peeking_take_while(|p| match p {
302 ast::Pat::DotDotPat(_) => false, 296 ast::Pat::RestPat(_) => false,
303 ast::Pat::BindPat(bp) => match bp.pat() { 297 ast::Pat::IdentPat(bp) => match bp.pat() {
304 Some(ast::Pat::DotDotPat(_)) => false, 298 Some(ast::Pat::RestPat(_)) => false,
305 _ => true, 299 _ => true,
306 }, 300 },
307 ast::Pat::RefPat(rp) => match rp.pat() { 301 ast::Pat::RefPat(rp) => match rp.pat() {
308 Some(ast::Pat::DotDotPat(_)) => false, 302 Some(ast::Pat::RestPat(_)) => false,
309 Some(ast::Pat::BindPat(bp)) => match bp.pat() { 303 Some(ast::Pat::IdentPat(bp)) => match bp.pat() {
310 Some(ast::Pat::DotDotPat(_)) => false, 304 Some(ast::Pat::RestPat(_)) => false,
311 _ => true, 305 _ => true,
312 }, 306 },
313 _ => true, 307 _ => true,
@@ -368,26 +362,6 @@ impl ast::TypeBound {
368 unreachable!() 362 unreachable!()
369 } 363 }
370 } 364 }
371
372 pub fn const_question_token(&self) -> Option<SyntaxToken> {
373 self.syntax()
374 .children_with_tokens()
375 .filter_map(|it| it.into_token())
376 .take_while(|it| it.kind() != T![const])
377 .find(|it| it.kind() == T![?])
378 }
379
380 pub fn question_token(&self) -> Option<SyntaxToken> {
381 if self.const_token().is_some() {
382 self.syntax()
383 .children_with_tokens()
384 .filter_map(|it| it.into_token())
385 .skip_while(|it| it.kind() != T![const])
386 .find(|it| it.kind() == T![?])
387 } else {
388 support::token(&self.syntax, T![?])
389 }
390 }
391} 365}
392 366
393pub enum VisibilityKind { 367pub enum VisibilityKind {
@@ -472,3 +446,40 @@ impl ast::TokenTree {
472 .filter(|it| matches!(it.kind(), T!['}'] | T![')'] | T![']'])) 446 .filter(|it| matches!(it.kind(), T!['}'] | T![')'] | T![']']))
473 } 447 }
474} 448}
449
450impl ast::GenericParamList {
451 pub fn lifetime_params(&self) -> impl Iterator<Item = ast::LifetimeParam> {
452 self.generic_params().filter_map(|param| match param {
453 ast::GenericParam::LifetimeParam(it) => Some(it),
454 ast::GenericParam::TypeParam(_) | ast::GenericParam::ConstParam(_) => None,
455 })
456 }
457 pub fn type_params(&self) -> impl Iterator<Item = ast::TypeParam> {
458 self.generic_params().filter_map(|param| match param {
459 ast::GenericParam::TypeParam(it) => Some(it),
460 ast::GenericParam::LifetimeParam(_) | ast::GenericParam::ConstParam(_) => None,
461 })
462 }
463 pub fn const_params(&self) -> impl Iterator<Item = ast::ConstParam> {
464 self.generic_params().filter_map(|param| match param {
465 ast::GenericParam::ConstParam(it) => Some(it),
466 ast::GenericParam::TypeParam(_) | ast::GenericParam::LifetimeParam(_) => None,
467 })
468 }
469}
470
471impl ast::DocCommentsOwner for ast::SourceFile {}
472impl ast::DocCommentsOwner for ast::Fn {}
473impl ast::DocCommentsOwner for ast::Struct {}
474impl ast::DocCommentsOwner for ast::Union {}
475impl ast::DocCommentsOwner for ast::RecordField {}
476impl ast::DocCommentsOwner for ast::TupleField {}
477impl ast::DocCommentsOwner for ast::Enum {}
478impl ast::DocCommentsOwner for ast::Variant {}
479impl ast::DocCommentsOwner for ast::Trait {}
480impl ast::DocCommentsOwner for ast::Module {}
481impl ast::DocCommentsOwner for ast::Static {}
482impl ast::DocCommentsOwner for ast::Const {}
483impl ast::DocCommentsOwner for ast::TypeAlias {}
484impl ast::DocCommentsOwner for ast::Impl {}
485impl ast::DocCommentsOwner for ast::MacroCall {}
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs
index a8f2454fd..3a56b1674 100644
--- a/crates/ra_syntax/src/ast/traits.rs
+++ b/crates/ra_syntax/src/ast/traits.rs
@@ -9,12 +9,6 @@ use crate::{
9 SyntaxToken, T, 9 SyntaxToken, T,
10}; 10};
11 11
12pub trait TypeAscriptionOwner: AstNode {
13 fn ascribed_type(&self) -> Option<ast::TypeRef> {
14 support::child(self.syntax())
15 }
16}
17
18pub trait NameOwner: AstNode { 12pub trait NameOwner: AstNode {
19 fn name(&self) -> Option<ast::Name> { 13 fn name(&self) -> Option<ast::Name> {
20 support::child(self.syntax()) 14 support::child(self.syntax())
@@ -44,13 +38,13 @@ pub trait ArgListOwner: AstNode {
44} 38}
45 39
46pub trait ModuleItemOwner: AstNode { 40pub trait ModuleItemOwner: AstNode {
47 fn items(&self) -> AstChildren<ast::ModuleItem> { 41 fn items(&self) -> AstChildren<ast::Item> {
48 support::children(self.syntax()) 42 support::children(self.syntax())
49 } 43 }
50} 44}
51 45
52pub trait TypeParamsOwner: AstNode { 46pub trait GenericParamsOwner: AstNode {
53 fn type_param_list(&self) -> Option<ast::TypeParamList> { 47 fn generic_param_list(&self) -> Option<ast::GenericParamList> {
54 support::child(self.syntax()) 48 support::child(self.syntax())
55 } 49 }
56 50
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index ac59455e7..8a4d45386 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -187,14 +187,14 @@ impl ast::Expr {
187 } 187 }
188} 188}
189 189
190impl ast::ModuleItem { 190impl ast::Item {
191 /// Returns `text`, parsed as an item, but only if it has no errors. 191 /// Returns `text`, parsed as an item, but only if it has no errors.
192 pub fn parse(text: &str) -> Result<Self, ()> { 192 pub fn parse(text: &str) -> Result<Self, ()> {
193 parsing::parse_text_fragment(text, ra_parser::FragmentKind::Item) 193 parsing::parse_text_fragment(text, ra_parser::FragmentKind::Item)
194 } 194 }
195} 195}
196 196
197impl ast::TypeRef { 197impl ast::Type {
198 /// Returns `text`, parsed as an type reference, but only if it has no errors. 198 /// Returns `text`, parsed as an type reference, but only if it has no errors.
199 pub fn parse(text: &str) -> Result<Self, ()> { 199 pub fn parse(text: &str) -> Result<Self, ()> {
200 parsing::parse_text_fragment(text, ra_parser::FragmentKind::Type) 200 parsing::parse_text_fragment(text, ra_parser::FragmentKind::Type)
@@ -255,11 +255,11 @@ fn api_walkthrough() {
255 let mut func = None; 255 let mut func = None;
256 for item in file.items() { 256 for item in file.items() {
257 match item { 257 match item {
258 ast::ModuleItem::FnDef(f) => func = Some(f), 258 ast::Item::Fn(f) => func = Some(f),
259 _ => unreachable!(), 259 _ => unreachable!(),
260 } 260 }
261 } 261 }
262 let func: ast::FnDef = func.unwrap(); 262 let func: ast::Fn = func.unwrap();
263 263
264 // Each AST node has a bunch of getters for children. All getters return 264 // Each AST node has a bunch of getters for children. All getters return
265 // `Option`s though, to account for incomplete code. Some getters are common 265 // `Option`s though, to account for incomplete code. Some getters are common
@@ -316,7 +316,7 @@ fn api_walkthrough() {
316 ); 316 );
317 317
318 // As well as some iterator helpers: 318 // As well as some iterator helpers:
319 let f = expr_syntax.ancestors().find_map(ast::FnDef::cast); 319 let f = expr_syntax.ancestors().find_map(ast::Fn::cast);
320 assert_eq!(f, Some(func)); 320 assert_eq!(f, Some(func));
321 assert!(expr_syntax.siblings_with_tokens(Direction::Next).any(|it| it.kind() == T!['}'])); 321 assert!(expr_syntax.siblings_with_tokens(Direction::Next).any(|it| it.kind() == T!['}']));
322 assert_eq!( 322 assert_eq!(
diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs
index c6b30a02a..6d1828d20 100644
--- a/crates/ra_syntax/src/parsing/text_tree_sink.rs
+++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs
@@ -146,8 +146,8 @@ fn n_attached_trivias<'a>(
146 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>, 146 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>,
147) -> usize { 147) -> usize {
148 match kind { 148 match kind {
149 MACRO_CALL | CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF 149 MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT | MODULE
150 | TRAIT_DEF | MODULE | RECORD_FIELD_DEF | STATIC_DEF => { 150 | RECORD_FIELD | STATIC => {
151 let mut res = 0; 151 let mut res = 0;
152 let mut trivias = trivias.enumerate().peekable(); 152 let mut trivias = trivias.enumerate().peekable();
153 153
diff --git a/crates/ra_syntax/src/ptr.rs b/crates/ra_syntax/src/ptr.rs
index 62f03e93d..ca7957747 100644
--- a/crates/ra_syntax/src/ptr.rs
+++ b/crates/ra_syntax/src/ptr.rs
@@ -98,7 +98,7 @@ fn test_local_syntax_ptr() {
98 use crate::{ast, AstNode, SourceFile}; 98 use crate::{ast, AstNode, SourceFile};
99 99
100 let file = SourceFile::parse("struct Foo { f: u32, }").ok().unwrap(); 100 let file = SourceFile::parse("struct Foo { f: u32, }").ok().unwrap();
101 let field = file.syntax().descendants().find_map(ast::RecordFieldDef::cast).unwrap(); 101 let field = file.syntax().descendants().find_map(ast::RecordField::cast).unwrap();
102 let ptr = SyntaxNodePtr::new(field.syntax()); 102 let ptr = SyntaxNodePtr::new(field.syntax());
103 let field_syntax = ptr.to_node(file.syntax()); 103 let field_syntax = ptr.to_node(file.syntax());
104 assert_eq!(field.syntax(), &field_syntax); 104 assert_eq!(field.syntax(), &field_syntax);
diff --git a/crates/ra_syntax/src/tests.rs b/crates/ra_syntax/src/tests.rs
index 8447dcad7..00b957f43 100644
--- a/crates/ra_syntax/src/tests.rs
+++ b/crates/ra_syntax/src/tests.rs
@@ -89,7 +89,7 @@ fn item_parser_tests() {
89 fragment_parser_dir_test( 89 fragment_parser_dir_test(
90 &["parser/fragments/item/ok"], 90 &["parser/fragments/item/ok"],
91 &["parser/fragments/item/err"], 91 &["parser/fragments/item/err"],
92 crate::ast::ModuleItem::parse, 92 crate::ast::Item::parse,
93 ); 93 );
94} 94}
95 95
@@ -98,7 +98,7 @@ fn type_parser_tests() {
98 fragment_parser_dir_test( 98 fragment_parser_dir_test(
99 &["parser/fragments/type/ok"], 99 &["parser/fragments/type/ok"],
100 &["parser/fragments/type/err"], 100 &["parser/fragments/type/err"],
101 crate::ast::TypeRef::parse, 101 crate::ast::Type::parse,
102 ); 102 );
103} 103}
104 104
diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs
index fdec48fb0..2dddaf09a 100644
--- a/crates/ra_syntax/src/validation.rs
+++ b/crates/ra_syntax/src/validation.rs
@@ -4,7 +4,7 @@ mod block;
4 4
5use crate::{ 5use crate::{
6 ast, match_ast, AstNode, SyntaxError, 6 ast, match_ast, AstNode, SyntaxError,
7 SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST_DEF, FN_DEF, INT_NUMBER, STRING, TYPE_ALIAS_DEF}, 7 SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST, FN, INT_NUMBER, STRING, TYPE_ALIAS},
8 SyntaxNode, SyntaxToken, TextSize, T, 8 SyntaxNode, SyntaxToken, TextSize, T,
9}; 9};
10use rustc_lexer::unescape::{ 10use rustc_lexer::unescape::{
@@ -91,7 +91,7 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec<SyntaxError> {
91 ast::Literal(it) => validate_literal(it, &mut errors), 91 ast::Literal(it) => validate_literal(it, &mut errors),
92 ast::BlockExpr(it) => block::validate_block_expr(it, &mut errors), 92 ast::BlockExpr(it) => block::validate_block_expr(it, &mut errors),
93 ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), &mut errors), 93 ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), &mut errors),
94 ast::RecordField(it) => validate_numeric_name(it.name_ref(), &mut errors), 94 ast::RecordExprField(it) => validate_numeric_name(it.name_ref(), &mut errors),
95 ast::Visibility(it) => validate_visibility(it, &mut errors), 95 ast::Visibility(it) => validate_visibility(it, &mut errors),
96 ast::RangeExpr(it) => validate_range_expr(it, &mut errors), 96 ast::RangeExpr(it) => validate_range_expr(it, &mut errors),
97 ast::PathSegment(it) => validate_path_keywords(it, &mut errors), 97 ast::PathSegment(it) => validate_path_keywords(it, &mut errors),
@@ -200,15 +200,15 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec<SyntaxError>) {
200 None => return, 200 None => return,
201 }; 201 };
202 match parent.kind() { 202 match parent.kind() {
203 FN_DEF | CONST_DEF | TYPE_ALIAS_DEF => (), 203 FN | CONST | TYPE_ALIAS => (),
204 _ => return, 204 _ => return,
205 } 205 }
206 206
207 let impl_def = match parent.parent().and_then(|it| it.parent()).and_then(ast::ImplDef::cast) { 207 let impl_def = match parent.parent().and_then(|it| it.parent()).and_then(ast::Impl::cast) {
208 Some(it) => it, 208 Some(it) => it,
209 None => return, 209 None => return,
210 }; 210 };
211 if impl_def.target_trait().is_some() { 211 if impl_def.trait_().is_some() {
212 errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range())); 212 errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range()));
213 } 213 }
214} 214}
diff --git a/crates/ra_syntax/src/validation/block.rs b/crates/ra_syntax/src/validation/block.rs
index 2c08f7e6e..ad9901468 100644
--- a/crates/ra_syntax/src/validation/block.rs
+++ b/crates/ra_syntax/src/validation/block.rs
@@ -9,7 +9,7 @@ use crate::{
9pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<SyntaxError>) { 9pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<SyntaxError>) {
10 if let Some(parent) = block.syntax().parent() { 10 if let Some(parent) = block.syntax().parent() {
11 match parent.kind() { 11 match parent.kind() {
12 FN_DEF | EXPR_STMT | BLOCK_EXPR => return, 12 FN | EXPR_STMT | BLOCK_EXPR => return,
13 _ => {} 13 _ => {}
14 } 14 }
15 } 15 }
diff --git a/crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.rast b/crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.rast
index 81f0f575c..bbbf496c8 100644
--- a/crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.rast
+++ b/crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.rast
@@ -1,14 +1,14 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..34 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "S" 6 [email protected] "S"
7 [email protected] " " 7 [email protected] " "
8 RECORD_FIELD_DEF_[email protected] 8 [email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] "\n " 10 [email protected] "\n "
11 RECORD_FIELD_DEF@15..21 11 [email protected]
12 [email protected] 12 [email protected]
13 [email protected] "a" 13 [email protected] "a"
14 [email protected] ":" 14 [email protected] ":"
@@ -19,7 +19,7 @@ [email protected]
19 [email protected] 19 [email protected]
20 [email protected] "u32" 20 [email protected] "u32"
21 [email protected] "\n " 21 [email protected] "\n "
22 RECORD_FIELD_DEF@26..32 22 [email protected]
23 [email protected] 23 [email protected]
24 [email protected] "b" 24 [email protected] "b"
25 [email protected] ":" 25 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.rast b/crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.rast
index 97d0fe910..6dc73bfdb 100644
--- a/crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.rast
+++ b/crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.rast
@@ -5,13 +5,13 @@ [email protected]
5 [email protected] 5 [email protected]
6 [email protected] "match" 6 [email protected] "match"
7 [email protected] "\n\n" 7 [email protected] "\n\n"
8 STRUCT_DEF@10..21 8 [email protected]
9 [email protected] "struct" 9 [email protected] "struct"
10 [email protected] " " 10 [email protected] " "
11 [email protected] 11 [email protected]
12 [email protected] "S" 12 [email protected] "S"
13 [email protected] " " 13 [email protected] " "
14 RECORD_FIELD_DEF_[email protected] 14 [email protected]
15 [email protected] "{" 15 [email protected] "{"
16 [email protected] "}" 16 [email protected] "}"
17error 0..0: expected an item 17error 0..0: expected an item
diff --git a/crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast b/crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast
index 6717995e9..4cfd1bce4 100644
--- a/crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast
+++ b/crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast
@@ -6,7 +6,7 @@ [email protected]
6 [email protected] "!" 6 [email protected] "!"
7 [email protected] 7 [email protected]
8 [email protected] "/" 8 [email protected] "/"
9 USE_ITEM@24..28 9 [email protected]
10 [email protected] "use" 10 [email protected] "use"
11 [email protected] 11 [email protected]
12 [email protected] "/" 12 [email protected] "/"
diff --git a/crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.rast b/crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.rast
index 21c255698..7763fad84 100644
--- a/crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.rast
+++ b/crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.rast
@@ -1,14 +1,14 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..39 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "S" 6 [email protected] "S"
7 [email protected] " " 7 [email protected] " "
8 RECORD_FIELD_DEF_[email protected] 8 [email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] "\n " 10 [email protected] "\n "
11 RECORD_FIELD_DEF@15..21 11 [email protected]
12 [email protected] 12 [email protected]
13 [email protected] "a" 13 [email protected] "a"
14 [email protected] ":" 14 [email protected] ":"
@@ -20,7 +20,7 @@ [email protected]
20 [email protected] "i32" 20 [email protected] "i32"
21 [email protected] "," 21 [email protected] ","
22 [email protected] "\n " 22 [email protected] "\n "
23 RECORD_FIELD_DEF@27..36 23 [email protected]
24 [email protected] 24 [email protected]
25 [email protected] "b" 25 [email protected] "b"
26 [email protected] ":" 26 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast b/crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast
index b3bcf472a..9a0f4665e 100644
--- a/crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast
+++ b/crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..12 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0005_attribute_recover.rast b/crates/ra_syntax/test_data/parser/err/0005_attribute_recover.rast
index 375ed45e0..4845a6563 100644
--- a/crates/ra_syntax/test_data/parser/err/0005_attribute_recover.rast
+++ b/crates/ra_syntax/test_data/parser/err/0005_attribute_recover.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..31 2 [email protected]
3 [email protected] 3 [email protected]
4 [email protected] "#" 4 [email protected] "#"
5 [email protected] "[" 5 [email protected] "["
diff --git a/crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.rast b/crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.rast
index 2d6364998..5f85c3943 100644
--- a/crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.rast
+++ b/crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.rast
@@ -1,14 +1,14 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..73 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "S" 6 [email protected] "S"
7 [email protected] " " 7 [email protected] " "
8 RECORD_FIELD_DEF_[email protected] 8 [email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] "\n " 10 [email protected] "\n "
11 RECORD_FIELD_DEF@15..21 11 [email protected]
12 [email protected] 12 [email protected]
13 [email protected] "f" 13 [email protected] "f"
14 [email protected] ":" 14 [email protected] ":"
@@ -35,7 +35,7 @@ [email protected]
35 [email protected] 35 [email protected]
36 [email protected] "*" 36 [email protected] "*"
37 [email protected] "\n " 37 [email protected] "\n "
38 RECORD_FIELD_DEF@48..58 38 [email protected]
39 [email protected] 39 [email protected]
40 [email protected] "pub" 40 [email protected] "pub"
41 [email protected] " " 41 [email protected] " "
@@ -50,7 +50,7 @@ [email protected]
50 [email protected] "u32" 50 [email protected] "u32"
51 [email protected] "," 51 [email protected] ","
52 [email protected] "\n " 52 [email protected] "\n "
53 RECORD_FIELD_DEF@64..70 53 [email protected]
54 [email protected] 54 [email protected]
55 [email protected] "z" 55 [email protected] "z"
56 [email protected] ":" 56 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.rast b/crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.rast
index b72c92c33..560bfd751 100644
--- a/crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.rast
+++ b/crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.rast
@@ -2,7 +2,7 @@ [email protected]
2 [email protected] 2 [email protected]
3 [email protected] "}" 3 [email protected] "}"
4 [email protected] "\n\n" 4 [email protected] "\n\n"
5 STRUCT_DEF@3..12 5 [email protected]
6 [email protected] "struct" 6 [email protected] "struct"
7 [email protected] " " 7 [email protected] " "
8 [email protected] 8 [email protected]
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] 12 [email protected]
13 [email protected] "}" 13 [email protected] "}"
14 [email protected] "\n\n" 14 [email protected] "\n\n"
15 FN_DEF@17..27 15 [email protected]
16 [email protected] "fn" 16 [email protected] "fn"
17 [email protected] " " 17 [email protected] " "
18 [email protected] 18 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.rast b/crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.rast
index 33953d8d7..1e9637c26 100644
--- a/crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.rast
+++ b/crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..12 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -58,7 +58,7 @@ [email protected]
58 [email protected] "\n" 58 [email protected] "\n"
59 [email protected] "}" 59 [email protected] "}"
60 [email protected] "\n\n" 60 [email protected] "\n\n"
61 FN_DEF@82..94 61 [email protected]
62 [email protected] "fn" 62 [email protected] "fn"
63 [email protected] " " 63 [email protected] " "
64 [email protected] 64 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.rast b/crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.rast
index aca02ece4..dacf71aa1 100644
--- a/crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.rast
+++ b/crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..11 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "S" 6 [email protected] "S"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] "90" 10 [email protected] "90"
@@ -38,7 +38,7 @@ [email protected]
38 [email protected] "\n" 38 [email protected] "\n"
39 [email protected] "}" 39 [email protected] "}"
40 [email protected] "\n\n" 40 [email protected] "\n\n"
41 STRUCT_DEF@33..42 41 [email protected]
42 [email protected] "struct" 42 [email protected] "struct"
43 [email protected] " " 43 [email protected] " "
44 [email protected] 44 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast b/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast
index 3bf57eacc..e0f1d0c27 100644
--- a/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast
+++ b/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..41 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 [email protected] 14 [email protected]
15 LAMBDA[email protected] 15 CLOSURE[email protected]
16 [email protected] 16 [email protected]
17 [email protected] "|" 17 [email protected] "|"
18 [email protected] "|" 18 [email protected] "|"
diff --git a/crates/ra_syntax/test_data/parser/err/0011_extern_struct.rast b/crates/ra_syntax/test_data/parser/err/0011_extern_struct.rast
index 87c54c32c..b02d390af 100644
--- a/crates/ra_syntax/test_data/parser/err/0011_extern_struct.rast
+++ b/crates/ra_syntax/test_data/parser/err/0011_extern_struct.rast
@@ -3,7 +3,7 @@ [email protected]
3 [email protected] 3 [email protected]
4 [email protected] "extern" 4 [email protected] "extern"
5 [email protected] " " 5 [email protected] " "
6 STRUCT_DEF@7..18 6 [email protected]
7 [email protected] "struct" 7 [email protected] "struct"
8 [email protected] " " 8 [email protected] " "
9 [email protected] 9 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast b/crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast
index e1e782f5f..f31c27633 100644
--- a/crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast
+++ b/crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..389 2 [email protected]
3 [email protected] 3 [email protected]
4 [email protected] 4 [email protected]
5 [email protected] 5 [email protected]
@@ -10,7 +10,7 @@ [email protected]
10 [email protected] 10 [email protected]
11 [email protected] 11 [email protected]
12 [email protected] "process" 12 [email protected] "process"
13 TYP[email protected] 13 GENERIC[email protected]
14 [email protected] 14 [email protected]
15 [email protected] 15 [email protected]
16 [email protected] "'a" 16 [email protected] "'a"
@@ -25,7 +25,7 @@ [email protected]
25 [email protected] 25 [email protected]
26 [email protected] 26 [email protected]
27 [email protected] "Sink" 27 [email protected] "Sink"
28 TYP[email protected] 28 GENERIC[email protected]
29 [email protected] 29 [email protected]
30 [email protected] 30 [email protected]
31 [email protected] "'a" 31 [email protected] "'a"
@@ -34,12 +34,12 @@ [email protected]
34 [email protected] 34 [email protected]
35 [email protected] 35 [email protected]
36 [email protected] 36 [email protected]
37 BIN[email protected] 37 IDENT[email protected]
38 [email protected] 38 [email protected]
39 [email protected] "builder" 39 [email protected] "builder"
40 [email protected] 40 [email protected]
41 [email protected] 41 [email protected]
42 REFERENCE[email protected] 42 [email protected]
43 [email protected] 43 [email protected]
44 [email protected] 44 [email protected]
45 [email protected] 45 [email protected]
@@ -51,12 +51,12 @@ [email protected]
51 [email protected] 51 [email protected]
52 [email protected] 52 [email protected]
53 [email protected] 53 [email protected]
54 BIN[email protected] 54 IDENT[email protected]
55 [email protected] 55 [email protected]
56 [email protected] "tokens" 56 [email protected] "tokens"
57 [email protected] 57 [email protected]
58 [email protected] 58 [email protected]
59 REFERENCE[email protected] 59 [email protected]
60 [email protected] 60 [email protected]
61 [email protected] 61 [email protected]
62 [email protected] 62 [email protected]
@@ -69,7 +69,7 @@ [email protected]
69 [email protected] 69 [email protected]
70 [email protected] 70 [email protected]
71 [email protected] 71 [email protected]
72 BIN[email protected] 72 IDENT[email protected]
73 [email protected] 73 [email protected]
74 [email protected] "events" 74 [email protected] "events"
75 [email protected] 75 [email protected]
@@ -79,7 +79,7 @@ [email protected]
79 [email protected] 79 [email protected]
80 [email protected] 80 [email protected]
81 [email protected] "Vec" 81 [email protected] "Vec"
82 TYP[email protected] 82 GENERIC[email protected]
83 [email protected] 83 [email protected]
84 [email protected] 84 [email protected]
85 [email protected] 85 [email protected]
@@ -96,7 +96,7 @@ [email protected]
96 [email protected] 96 [email protected]
97 [email protected] 97 [email protected]
98 [email protected] 98 [email protected]
99 BIN[email protected] 99 IDENT[email protected]
100 [email protected] 100 [email protected]
101 [email protected] 101 [email protected]
102 [email protected] 102 [email protected]
@@ -111,22 +111,22 @@ [email protected]
111 [email protected] 111 [email protected]
112 [email protected] 112 [email protected]
113 [email protected] 113 [email protected]
114 BIN[email protected] 114 IDENT[email protected]
115 [email protected] 115 [email protected]
116 [email protected] "eat_ws" 116 [email protected] "eat_ws"
117 [email protected] 117 [email protected]
118 [email protected] 118 [email protected]
119 [email protected] 119 [email protected]
120 LAMBDA[email protected] 120 CLOSURE[email protected]
121 [email protected] 121 [email protected]
122 [email protected] 122 [email protected]
123 [email protected] 123 [email protected]
124 BIN[email protected] 124 IDENT[email protected]
125 [email protected] 125 [email protected]
126 [email protected] "idx" 126 [email protected] "idx"
127 [email protected] 127 [email protected]
128 [email protected] 128 [email protected]
129 REFERENCE[email protected] 129 [email protected]
130 [email protected] 130 [email protected]
131 [email protected] 131 [email protected]
132 [email protected] 132 [email protected]
@@ -172,7 +172,7 @@ [email protected]
172 [email protected] 172 [email protected]
173 [email protected] "Some" 173 [email protected] "Some"
174 [email protected] 174 [email protected]
175 BIN[email protected] 175 IDENT[email protected]
176 [email protected] 176 [email protected]
177 [email protected] "token" 177 [email protected] "token"
178 [email protected] 178 [email protected]
@@ -185,7 +185,7 @@ [email protected]
185 err: `expected COMMA` 185 err: `expected COMMA`
186 [email protected] 186 [email protected]
187 [email protected] 187 [email protected]
188 BIN[email protected] 188 IDENT[email protected]
189 [email protected] 189 [email protected]
190 [email protected] "tokens" 190 [email protected] "tokens"
191 err: `expected COMMA` 191 err: `expected COMMA`
@@ -205,7 +205,7 @@ [email protected]
205 [email protected] 205 [email protected]
206 [email protected] 206 [email protected]
207 err: `expected COMMA` 207 err: `expected COMMA`
208 BIN[email protected] 208 IDENT[email protected]
209 [email protected] 209 [email protected]
210 [email protected] "idx" 210 [email protected] "idx"
211 [email protected] 211 [email protected]
@@ -229,7 +229,7 @@ [email protected]
229 [email protected] 229 [email protected]
230 err: `expected COMMA` 230 err: `expected COMMA`
231 [email protected] 231 [email protected]
232 BIN[email protected] 232 IDENT[email protected]
233 [email protected] 233 [email protected]
234 [email protected] "token" 234 [email protected] "token"
235 err: `expected COMMA` 235 err: `expected COMMA`
@@ -239,7 +239,7 @@ [email protected]
239 [email protected] 239 [email protected]
240 err: `expected COMMA` 240 err: `expected COMMA`
241 [email protected] 241 [email protected]
242 BIN[email protected] 242 IDENT[email protected]
243 [email protected] 243 [email protected]
244 [email protected] "kind" 244 [email protected] "kind"
245 err: `expected COMMA` 245 err: `expected COMMA`
@@ -265,7 +265,7 @@ [email protected]
265 err: `expected COMMA` 265 err: `expected COMMA`
266 [email protected] 266 [email protected]
267 [email protected] 267 [email protected]
268 BIN[email protected] 268 IDENT[email protected]
269 [email protected] 269 [email protected]
270 [email protected] "break" 270 [email protected] "break"
271 err: `expected COMMA` 271 err: `expected COMMA`
@@ -282,7 +282,7 @@ [email protected]
282 err: `expected COMMA` 282 err: `expected COMMA`
283 [email protected] 283 [email protected]
284 [email protected] 284 [email protected]
285 BIN[email protected] 285 IDENT[email protected]
286 [email protected] 286 [email protected]
287 [email protected] "builder" 287 [email protected] "builder"
288 err: `expected COMMA` 288 err: `expected COMMA`
@@ -298,7 +298,7 @@ [email protected]
298 [email protected] 298 [email protected]
299 [email protected] "leaf" 299 [email protected] "leaf"
300 [email protected] 300 [email protected]
301 BIN[email protected] 301 IDENT[email protected]
302 [email protected] 302 [email protected]
303 [email protected] "token" 303 [email protected] "token"
304 err: `expected COMMA` 304 err: `expected COMMA`
@@ -306,12 +306,12 @@ [email protected]
306 [email protected] 306 [email protected]
307 [email protected] 307 [email protected]
308 err: `expected COMMA` 308 err: `expected COMMA`
309 BIN[email protected] 309 IDENT[email protected]
310 [email protected] 310 [email protected]
311 [email protected] "kind" 311 [email protected] "kind"
312 [email protected] 312 [email protected]
313 [email protected] 313 [email protected]
314 BIN[email protected] 314 IDENT[email protected]
315 [email protected] 315 [email protected]
316 [email protected] "token" 316 [email protected] "token"
317 err: `expected COMMA` 317 err: `expected COMMA`
@@ -319,7 +319,7 @@ [email protected]
319 [email protected] 319 [email protected]
320 [email protected] 320 [email protected]
321 err: `expected COMMA` 321 err: `expected COMMA`
322 BIN[email protected] 322 IDENT[email protected]
323 [email protected] 323 [email protected]
324 [email protected] "len" 324 [email protected] "len"
325 [email protected] 325 [email protected]
@@ -336,7 +336,7 @@ [email protected]
336 [email protected] 336 [email protected]
337 err: `expected COMMA` 337 err: `expected COMMA`
338 [email protected] 338 [email protected]
339 BIN[email protected] 339 IDENT[email protected]
340 [email protected] 340 [email protected]
341 [email protected] "idx" 341 [email protected] "idx"
342 err: `expected COMMA` 342 err: `expected COMMA`
diff --git a/crates/ra_syntax/test_data/parser/err/0013_invalid_type.rast b/crates/ra_syntax/test_data/parser/err/0013_invalid_type.rast
index 211e5fd46..f48ab6e71 100644
--- a/crates/ra_syntax/test_data/parser/err/0013_invalid_type.rast
+++ b/crates/ra_syntax/test_data/parser/err/0013_invalid_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..72 2 [email protected]
3 [email protected] 3 [email protected]
4 [email protected] "pub" 4 [email protected] "pub"
5 [email protected] " " 5 [email protected] " "
@@ -7,16 +7,16 @@ [email protected]
7 [email protected] " " 7 [email protected] " "
8 [email protected] 8 [email protected]
9 [email protected] "Cache" 9 [email protected] "Cache"
10 TUPLE_FIELD_DEF_[email protected] 10 [email protected]
11 [email protected] "(" 11 [email protected] "("
12 [email protected] "\n " 12 [email protected] "\n "
13 TUPLE_FIELD_DEF@22..68 13 [email protected]
14 [email protected] 14 [email protected]
15 [email protected] 15 [email protected]
16 [email protected] 16 [email protected]
17 [email protected] 17 [email protected]
18 [email protected] "RefCell" 18 [email protected] "RefCell"
19 TYP[email protected] 19 GENERIC[email protected]
20 [email protected] "<" 20 [email protected] "<"
21 [email protected] 21 [email protected]
22 [email protected] 22 [email protected]
@@ -24,7 +24,7 @@ [email protected]
24 [email protected] 24 [email protected]
25 [email protected] 25 [email protected]
26 [email protected] "HashMap" 26 [email protected] "HashMap"
27 TYP[email protected] 27 GENERIC[email protected]
28 [email protected] "<" 28 [email protected] "<"
29 [email protected] "\n " 29 [email protected] "\n "
30 [email protected] 30 [email protected]
@@ -41,13 +41,13 @@ [email protected]
41 [email protected] 41 [email protected]
42 [email protected] 42 [email protected]
43 [email protected] "Box" 43 [email protected] "Box"
44 TYP[email protected] 44 GENERIC[email protected]
45 [email protected] "<" 45 [email protected] "<"
46 [email protected] 46 [email protected]
47 [email protected] 47 [email protected]
48 [email protected] "@" 48 [email protected] "@"
49 [email protected] " " 49 [email protected] " "
50 TUPLE_FIELD_DEF@69..72 50 [email protected]
51 [email protected] 51 [email protected]
52 [email protected] 52 [email protected]
53 [email protected] 53 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.rast b/crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.rast
index 9323b7890..a1f39b22a 100644
--- a/crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.rast
+++ b/crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 FN_DEF@0..22 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "foo" 6 [email protected] "foo"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0015_curly_in_params.rast b/crates/ra_syntax/test_data/parser/err/0015_curly_in_params.rast
index b18378cff..a3c25b450 100644
--- a/crates/ra_syntax/test_data/parser/err/0015_curly_in_params.rast
+++ b/crates/ra_syntax/test_data/parser/err/0015_curly_in_params.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..7 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0016_missing_semi.rast b/crates/ra_syntax/test_data/parser/err/0016_missing_semi.rast
index 93434f34f..66157c3dc 100644
--- a/crates/ra_syntax/test_data/parser/err/0016_missing_semi.rast
+++ b/crates/ra_syntax/test_data/parser/err/0016_missing_semi.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..55 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.rast b/crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.rast
index 628315c78..fe094f61c 100644
--- a/crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.rast
+++ b/crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..46 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -7,7 +7,7 @@ [email protected]
7 [email protected] 7 [email protected]
8 [email protected] "(" 8 [email protected] "("
9 [email protected] 9 [email protected]
10 BIN[email protected] 10 IDENT[email protected]
11 [email protected] 11 [email protected]
12 [email protected] "foo" 12 [email protected] "foo"
13 [email protected] ":" 13 [email protected] ":"
@@ -25,7 +25,7 @@ [email protected]
25 [email protected] 25 [email protected]
26 [email protected] "let" 26 [email protected] "let"
27 [email protected] " " 27 [email protected] " "
28 BIN[email protected] 28 IDENT[email protected]
29 [email protected] 29 [email protected]
30 [email protected] "bar" 30 [email protected] "bar"
31 [email protected] " " 31 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast b/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast
index 31cc4e551..72939fc98 100644
--- a/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast
+++ b/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..182 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -8,10 +8,10 @@ [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "FnScopes" 9 [email protected] "FnScopes"
10 [email protected] " " 10 [email protected] " "
11 [email protected] 11 ASSOC_[email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 FN_DEF@20..161 14 [email protected]
15 [email protected] "fn" 15 [email protected] "fn"
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 [email protected]
@@ -38,7 +38,7 @@ [email protected]
38 [email protected] 38 [email protected]
39 [email protected] "let" 39 [email protected] "let"
40 [email protected] " " 40 [email protected] " "
41 BIN[email protected] 41 IDENT[email protected]
42 [email protected] 42 [email protected]
43 [email protected] "res" 43 [email protected] "res"
44 [email protected] " " 44 [email protected] " "
@@ -75,16 +75,16 @@ [email protected]
75 [email protected] "push" 75 [email protected] "push"
76 [email protected] 76 [email protected]
77 [email protected] "(" 77 [email protected] "("
78 RECORD_LIT@111..154 78 RECORD_EXPR@111..154
79 [email protected] 79 [email protected]
80 [email protected] 80 [email protected]
81 [email protected] 81 [email protected]
82 [email protected] "ScopeData" 82 [email protected] "ScopeData"
83 [email protected] " " 83 [email protected] " "
84 [email protected] 84 RECORD_EXPR_[email protected]
85 [email protected] "{" 85 [email protected] "{"
86 [email protected] " " 86 [email protected] " "
87 [email protected] 87 RECORD_EXPR_[email protected]
88 [email protected] 88 [email protected]
89 [email protected] "parent" 89 [email protected] "parent"
90 [email protected] ":" 90 [email protected] ":"
@@ -96,7 +96,7 @@ [email protected]
96 [email protected] "None" 96 [email protected] "None"
97 [email protected] "," 97 [email protected] ","
98 [email protected] " " 98 [email protected] " "
99 [email protected] 99 RECORD_EXPR_[email protected]
100 [email protected] 100 [email protected]
101 [email protected] "entries" 101 [email protected] "entries"
102 [email protected] ":" 102 [email protected] ":"
@@ -116,7 +116,7 @@ [email protected]
116 [email protected] "\n " 116 [email protected] "\n "
117 [email protected] "}" 117 [email protected] "}"
118 [email protected] "\n\n " 118 [email protected] "\n\n "
119 FN_DEF@167..180 119 [email protected]
120 [email protected] "fn" 120 [email protected] "fn"
121 [email protected] " " 121 [email protected] " "
122 [email protected] 122 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0019_let_recover.rast b/crates/ra_syntax/test_data/parser/err/0019_let_recover.rast
index 4ff27f5c8..72c05bd96 100644
--- a/crates/ra_syntax/test_data/parser/err/0019_let_recover.rast
+++ b/crates/ra_syntax/test_data/parser/err/0019_let_recover.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..138 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 BIN[email protected] 17 IDENT[email protected]
18 [email protected] 18 [email protected]
19 [email protected] "foo" 19 [email protected] "foo"
20 [email protected] " " 20 [email protected] " "
@@ -23,7 +23,7 @@ [email protected]
23 [email protected] 23 [email protected]
24 [email protected] "let" 24 [email protected] "let"
25 [email protected] " " 25 [email protected] " "
26 BIN[email protected] 26 IDENT[email protected]
27 [email protected] 27 [email protected]
28 [email protected] "bar" 28 [email protected] "bar"
29 [email protected] " " 29 [email protected] " "
@@ -39,7 +39,7 @@ [email protected]
39 [email protected] 39 [email protected]
40 [email protected] "let" 40 [email protected] "let"
41 [email protected] " " 41 [email protected] " "
42 BIN[email protected] 42 IDENT[email protected]
43 [email protected] 43 [email protected]
44 [email protected] "baz" 44 [email protected] "baz"
45 [email protected] " " 45 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/err/0020_fn_recover.rast b/crates/ra_syntax/test_data/parser/err/0020_fn_recover.rast
index 5f3a31473..6f6feba5a 100644
--- a/crates/ra_syntax/test_data/parser/err/0020_fn_recover.rast
+++ b/crates/ra_syntax/test_data/parser/err/0020_fn_recover.rast
@@ -1,8 +1,8 @@
1[email protected] 1[email protected]
2 FN_DEF@0..2 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] "\n\n" 4 [email protected] "\n\n"
5 FN_DEF@4..15 5 [email protected]
6 [email protected] "fn" 6 [email protected] "fn"
7 [email protected] " " 7 [email protected] " "
8 [email protected] 8 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0021_incomplete_param.rast b/crates/ra_syntax/test_data/parser/err/0021_incomplete_param.rast
index 1746bd3c1..b32845537 100644
--- a/crates/ra_syntax/test_data/parser/err/0021_incomplete_param.rast
+++ b/crates/ra_syntax/test_data/parser/err/0021_incomplete_param.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..21 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -7,7 +7,7 @@ [email protected]
7 [email protected] 7 [email protected]
8 [email protected] "(" 8 [email protected] "("
9 [email protected] 9 [email protected]
10 BIN[email protected] 10 IDENT[email protected]
11 [email protected] 11 [email protected]
12 [email protected] "x" 12 [email protected] "x"
13 [email protected] ":" 13 [email protected] ":"
@@ -20,7 +20,7 @@ [email protected]
20 [email protected] "," 20 [email protected] ","
21 [email protected] " " 21 [email protected] " "
22 [email protected] 22 [email protected]
23 BIN[email protected] 23 IDENT[email protected]
24 [email protected] 24 [email protected]
25 [email protected] "y" 25 [email protected] "y"
26 [email protected] ")" 26 [email protected] ")"
diff --git a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast b/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast
index 28146f44e..71fb19783 100644
--- a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast
+++ b/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..33 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -28,7 +28,7 @@ [email protected]
28 [email protected] 28 [email protected]
29 [email protected] "," 29 [email protected] ","
30 [email protected] " " 30 [email protected] " "
31 STRUCT_DEF@19..26 31 [email protected]
32 [email protected] "struct" 32 [email protected] "struct"
33 [email protected] 33 [email protected]
34 [email protected] "," 34 [email protected] ","
@@ -40,7 +40,7 @@ [email protected]
40 [email protected] " " 40 [email protected] " "
41 [email protected] "}" 41 [email protected] "}"
42 [email protected] "\n" 42 [email protected] "\n"
43 FN_DEF@34..68 43 [email protected]
44 [email protected] "fn" 44 [email protected] "fn"
45 [email protected] " " 45 [email protected] " "
46 [email protected] 46 [email protected]
@@ -75,7 +75,7 @@ [email protected]
75 [email protected] 75 [email protected]
76 [email protected] "," 76 [email protected] ","
77 [email protected] " " 77 [email protected] " "
78 IMPL_DEF@56..60 78 [email protected]
79 [email protected] "impl" 79 [email protected] "impl"
80 [email protected] 80 [email protected]
81 [email protected] 81 [email protected]
@@ -88,7 +88,7 @@ [email protected]
88 [email protected] " " 88 [email protected] " "
89 [email protected] "}" 89 [email protected] "}"
90 [email protected] "\n" 90 [email protected] "\n"
91 FN_DEF@69..111 91 [email protected]
92 [email protected] "fn" 92 [email protected] "fn"
93 [email protected] " " 93 [email protected] " "
94 [email protected] 94 [email protected]
@@ -133,7 +133,7 @@ [email protected]
133 [email protected] 133 [email protected]
134 [email protected] "," 134 [email protected] ","
135 [email protected] " " 135 [email protected] " "
136 TRAIT_DEF@98..104 136 [email protected]
137 [email protected] "trait" 137 [email protected] "trait"
138 [email protected] 138 [email protected]
139 [email protected] "," 139 [email protected] ","
diff --git a/crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.rast b/crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.rast
index 9ea9d715e..5ffefd742 100644
--- a/crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.rast
+++ b/crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..55 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast b/crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast
index 48610a5eb..e3be6b22e 100644
--- a/crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast
+++ b/crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 FN_DEF@0..53 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "f" 6 [email protected] "f"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
@@ -39,7 +39,7 @@ [email protected]
39 [email protected] "(" 39 [email protected] "("
40 [email protected] 40 [email protected]
41 [email protected] "for" 41 [email protected] "for"
42 TYP[email protected] 42 GENERIC[email protected]
43 [email protected] "<" 43 [email protected] "<"
44 [email protected] 44 [email protected]
45 [email protected] "\'a" 45 [email protected] "\'a"
@@ -50,7 +50,7 @@ [email protected]
50 [email protected] 50 [email protected]
51 [email protected] 51 [email protected]
52 [email protected] "Trait" 52 [email protected] "Trait"
53 TYP[email protected] 53 GENERIC[email protected]
54 [email protected] "<" 54 [email protected] "<"
55 [email protected] 55 [email protected]
56 [email protected] "\'a" 56 [email protected] "\'a"
@@ -65,7 +65,7 @@ [email protected]
65 [email protected] "{" 65 [email protected] "{"
66 [email protected] "}" 66 [email protected] "}"
67 [email protected] "\n\n" 67 [email protected] "\n\n"
68 FN_DEF@55..239 68 [email protected]
69 [email protected] "fn" 69 [email protected] "fn"
70 [email protected] " " 70 [email protected] " "
71 [email protected] 71 [email protected]
@@ -80,7 +80,7 @@ [email protected]
80 [email protected] 80 [email protected]
81 [email protected] "let" 81 [email protected] "let"
82 [email protected] " " 82 [email protected] " "
83 PLACEHOLDE[email protected] 83 WILDCARD[email protected]
84 [email protected] "_" 84 [email protected] "_"
85 [email protected] ":" 85 [email protected] ":"
86 [email protected] " " 86 [email protected] " "
@@ -92,7 +92,7 @@ [email protected]
92 [email protected] 92 [email protected]
93 [email protected] 93 [email protected]
94 [email protected] "Box" 94 [email protected] "Box"
95 TYP[email protected] 95 GENERIC[email protected]
96 [email protected] "<" 96 [email protected] "<"
97 [email protected] 97 [email protected]
98 [email protected] 98 [email protected]
@@ -122,7 +122,7 @@ [email protected]
122 [email protected] "(" 122 [email protected] "("
123 [email protected] 123 [email protected]
124 [email protected] "for" 124 [email protected] "for"
125 TYP[email protected] 125 GENERIC[email protected]
126 [email protected] "<" 126 [email protected] "<"
127 [email protected] 127 [email protected]
128 [email protected] "\'a" 128 [email protected] "\'a"
@@ -133,7 +133,7 @@ [email protected]
133 [email protected] 133 [email protected]
134 [email protected] 134 [email protected]
135 [email protected] "Trait" 135 [email protected] "Trait"
136 TYP[email protected] 136 GENERIC[email protected]
137 [email protected] "<" 137 [email protected] "<"
138 [email protected] 138 [email protected]
139 [email protected] "\'a" 139 [email protected] "\'a"
@@ -147,7 +147,7 @@ [email protected]
147 [email protected] 147 [email protected]
148 [email protected] "let" 148 [email protected] "let"
149 [email protected] " " 149 [email protected] " "
150 PLACEHOLDE[email protected] 150 WILDCARD[email protected]
151 [email protected] "_" 151 [email protected] "_"
152 [email protected] ":" 152 [email protected] ":"
153 [email protected] " " 153 [email protected] " "
@@ -156,7 +156,7 @@ [email protected]
156 [email protected] 156 [email protected]
157 [email protected] 157 [email protected]
158 [email protected] "Box" 158 [email protected] "Box"
159 TYP[email protected] 159 GENERIC[email protected]
160 [email protected] "<" 160 [email protected] "<"
161 [email protected] 161 [email protected]
162 [email protected] 162 [email protected]
@@ -223,7 +223,7 @@ [email protected]
223 [email protected] 223 [email protected]
224 [email protected] "let" 224 [email protected] "let"
225 [email protected] " " 225 [email protected] " "
226 PLACEHOLDE[email protected] 226 WILDCARD[email protected]
227 [email protected] "_" 227 [email protected] "_"
228 [email protected] ":" 228 [email protected] ":"
229 [email protected] " " 229 [email protected] " "
@@ -235,14 +235,14 @@ [email protected]
235 [email protected] 235 [email protected]
236 [email protected] 236 [email protected]
237 [email protected] "Box" 237 [email protected] "Box"
238 TYP[email protected] 238 GENERIC[email protected]
239 [email protected] "<" 239 [email protected] "<"
240 [email protected] 240 [email protected]
241 [email protected] 241 [email protected]
242 [email protected] "(" 242 [email protected] "("
243 [email protected] 243 [email protected]
244 [email protected] "for" 244 [email protected] "for"
245 TYP[email protected] 245 GENERIC[email protected]
246 [email protected] "<" 246 [email protected] "<"
247 [email protected] 247 [email protected]
248 [email protected] "\'a" 248 [email protected] "\'a"
@@ -253,7 +253,7 @@ [email protected]
253 [email protected] 253 [email protected]
254 [email protected] 254 [email protected]
255 [email protected] "Trait" 255 [email protected] "Trait"
256 TYP[email protected] 256 GENERIC[email protected]
257 [email protected] "<" 257 [email protected] "<"
258 [email protected] 258 [email protected]
259 [email protected] "\'a" 259 [email protected] "\'a"
diff --git a/crates/ra_syntax/test_data/parser/err/0025_nope.rast b/crates/ra_syntax/test_data/parser/err/0025_nope.rast
index 88b086daf..83fc9fe77 100644
--- a/crates/ra_syntax/test_data/parser/err/0025_nope.rast
+++ b/crates/ra_syntax/test_data/parser/err/0025_nope.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..574 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -11,26 +11,26 @@ [email protected]
11 [email protected] 11 [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 ENUM_DEF@16..152 14 [email protected]
15 [email protected] "enum" 15 [email protected] "enum"
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 [email protected]
18 [email protected] "Test" 18 [email protected] "Test"
19 [email protected] " " 19 [email protected] " "
20 ENUM_[email protected] 20 [email protected]
21 [email protected] "{" 21 [email protected] "{"
22 [email protected] "\n " 22 [email protected] "\n "
23 ENUM_[email protected] 23 [email protected]
24 [email protected] 24 [email protected]
25 [email protected] "Var1" 25 [email protected] "Var1"
26 [email protected] "," 26 [email protected] ","
27 [email protected] "\n " 27 [email protected] "\n "
28 ENUM_[email protected] 28 [email protected]
29 [email protected] 29 [email protected]
30 [email protected] "Var2" 30 [email protected] "Var2"
31 TUPLE_FIELD_DEF_[email protected] 31 [email protected]
32 [email protected] "(" 32 [email protected] "("
33 TUPLE_FIELD_DEF@55..61 33 [email protected]
34 [email protected] 34 [email protected]
35 [email protected] 35 [email protected]
36 [email protected] 36 [email protected]
@@ -39,14 +39,14 @@ [email protected]
39 [email protected] ")" 39 [email protected] ")"
40 [email protected] "," 40 [email protected] ","
41 [email protected] "\n " 41 [email protected] "\n "
42 ENUM_[email protected] 42 [email protected]
43 [email protected] 43 [email protected]
44 [email protected] "Var3" 44 [email protected] "Var3"
45 [email protected] " " 45 [email protected] " "
46 RECORD_FIELD_DEF_[email protected] 46 [email protected]
47 [email protected] "{" 47 [email protected] "{"
48 [email protected] "\n " 48 [email protected] "\n "
49 RECORD_FIELD_DEF@91..95 49 [email protected]
50 [email protected] 50 [email protected]
51 [email protected] "abc" 51 [email protected] "abc"
52 [email protected] ":" 52 [email protected] ":"
@@ -69,7 +69,7 @@ [email protected]
69 [email protected] 69 [email protected]
70 [email protected] "let" 70 [email protected] "let"
71 [email protected] " " 71 [email protected] " "
72 BIN[email protected] 72 IDENT[email protected]
73 [email protected] 73 [email protected]
74 [email protected] "a" 74 [email protected] "a"
75 [email protected] " " 75 [email protected] " "
@@ -79,39 +79,39 @@ [email protected]
79 [email protected] "1" 79 [email protected] "1"
80 [email protected] ";" 80 [email protected] ";"
81 [email protected] "\n " 81 [email protected] "\n "
82 ENUM_DEF@191..223 82 [email protected]
83 [email protected] "enum" 83 [email protected] "enum"
84 [email protected] " " 84 [email protected] " "
85 [email protected] 85 [email protected]
86 [email protected] "Test2" 86 [email protected] "Test2"
87 [email protected] " " 87 [email protected] " "
88 ENUM_[email protected] 88 [email protected]
89 [email protected] "{" 89 [email protected] "{"
90 [email protected] "\n " 90 [email protected] "\n "
91 ENUM_[email protected] 91 [email protected]
92 [email protected] 92 [email protected]
93 [email protected] "Fine" 93 [email protected] "Fine"
94 [email protected] "," 94 [email protected] ","
95 [email protected] "\n " 95 [email protected] "\n "
96 [email protected] "}" 96 [email protected] "}"
97 [email protected] "\n\n " 97 [email protected] "\n\n "
98 ENUM_DEF@229..300 98 [email protected]
99 [email protected] "enum" 99 [email protected] "enum"
100 [email protected] " " 100 [email protected] " "
101 [email protected] 101 [email protected]
102 [email protected] "Test3" 102 [email protected] "Test3"
103 [email protected] " " 103 [email protected] " "
104 ENUM_[email protected] 104 [email protected]
105 [email protected] "{" 105 [email protected] "{"
106 [email protected] "\n " 106 [email protected] "\n "
107 ENUM_[email protected] 107 [email protected]
108 [email protected] 108 [email protected]
109 [email protected] "StillFine" 109 [email protected] "StillFine"
110 [email protected] " " 110 [email protected] " "
111 RECORD_FIELD_DEF_[email protected] 111 [email protected]
112 [email protected] "{" 112 [email protected] "{"
113 [email protected] "\n " 113 [email protected] "\n "
114 RECORD_FIELD_DEF@274..282 114 [email protected]
115 [email protected] 115 [email protected]
116 [email protected] "def" 116 [email protected] "def"
117 [email protected] ":" 117 [email protected] ":"
@@ -132,7 +132,7 @@ [email protected]
132 [email protected] 132 [email protected]
133 [email protected] "{" 133 [email protected] "{"
134 [email protected] "\n " 134 [email protected] "\n "
135 ENUM_DEF@316..453 135 [email protected]
136 [email protected] "// fail again" 136 [email protected] "// fail again"
137 [email protected] "\n " 137 [email protected] "\n "
138 [email protected] "enum" 138 [email protected] "enum"
@@ -140,15 +140,15 @@ [email protected]
140 [email protected] 140 [email protected]
141 [email protected] "Test4" 141 [email protected] "Test4"
142 [email protected] " " 142 [email protected] " "
143 ENUM_[email protected] 143 [email protected]
144 [email protected] "{" 144 [email protected] "{"
145 [email protected] "\n " 145 [email protected] "\n "
146 ENUM_[email protected] 146 [email protected]
147 [email protected] 147 [email protected]
148 [email protected] "Nope" 148 [email protected] "Nope"
149 TUPLE_FIELD_DEF_[email protected] 149 [email protected]
150 [email protected] "(" 150 [email protected] "("
151 TUPLE_FIELD_DEF@368..371 151 [email protected]
152 [email protected] 152 [email protected]
153 [email protected] 153 [email protected]
154 [email protected] 154 [email protected]
@@ -175,7 +175,7 @@ [email protected]
175 [email protected] 175 [email protected]
176 [email protected] "let" 176 [email protected] "let"
177 [email protected] " " 177 [email protected] " "
178 BIN[email protected] 178 IDENT[email protected]
179 [email protected] 179 [email protected]
180 [email protected] "bad_syntax" 180 [email protected] "bad_syntax"
181 [email protected] " " 181 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast b/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast
index bf07409fb..1b08c834e 100644
--- a/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast
+++ b/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast
@@ -1,7 +1,7 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..14 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 TYP[email protected] 4 GENERIC[email protected]
5 [email protected] "<" 5 [email protected] "<"
6 [email protected] 6 [email protected]
7 [email protected] 7 [email protected]
@@ -17,9 +17,9 @@ [email protected]
17 [email protected] "Clone" 17 [email protected] "Clone"
18 [email protected] ">" 18 [email protected] ">"
19 [email protected] "\n" 19 [email protected] "\n"
20 IMPL_DEF@15..37 20 [email protected]
21 [email protected] "impl" 21 [email protected] "impl"
22 TYP[email protected] 22 GENERIC[email protected]
23 [email protected] "<" 23 [email protected] "<"
24 [email protected] 24 [email protected]
25 [email protected] 25 [email protected]
@@ -31,7 +31,7 @@ [email protected]
31 [email protected] 31 [email protected]
32 [email protected] 32 [email protected]
33 [email protected] "OnceCell" 33 [email protected] "OnceCell"
34 TYP[email protected] 34 GENERIC[email protected]
35 [email protected] "<" 35 [email protected] "<"
36 [email protected] 36 [email protected]
37 [email protected] 37 [email protected]
@@ -41,7 +41,7 @@ [email protected]
41 [email protected] "T" 41 [email protected] "T"
42 [email protected] ">" 42 [email protected] ">"
43 [email protected] " " 43 [email protected] " "
44 [email protected] 44 ASSOC_[email protected]
45 [email protected] "{" 45 [email protected] "{"
46 [email protected] "}" 46 [email protected] "}"
47 [email protected] "\n" 47 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast b/crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast
index 4d6461d1e..a8e42e6ea 100644
--- a/crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast
+++ b/crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..29 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -13,7 +13,7 @@ [email protected]
13 [email protected] " " 13 [email protected] " "
14 [email protected] 14 [email protected]
15 [email protected] "for" 15 [email protected] "for"
16 TYP[email protected] 16 GENERIC[email protected]
17 [email protected] "<" 17 [email protected] "<"
18 [email protected] 18 [email protected]
19 [email protected] "\'a" 19 [email protected] "\'a"
diff --git a/crates/ra_syntax/test_data/parser/err/0029_field_completion.rast b/crates/ra_syntax/test_data/parser/err/0029_field_completion.rast
index 0da8f59f0..c6402cdd8 100644
--- a/crates/ra_syntax/test_data/parser/err/0029_field_completion.rast
+++ b/crates/ra_syntax/test_data/parser/err/0029_field_completion.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..23 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -7,7 +7,7 @@ [email protected]
7 [email protected] 7 [email protected]
8 [email protected] "(" 8 [email protected] "("
9 [email protected] 9 [email protected]
10 BIN[email protected] 10 IDENT[email protected]
11 [email protected] 11 [email protected]
12 [email protected] "a" 12 [email protected] "a"
13 [email protected] ":" 13 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.rast b/crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.rast
index 515819e42..a443b37db 100644
--- a/crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.rast
+++ b/crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..349 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 BIN[email protected] 17 IDENT[email protected]
18 [email protected] 18 [email protected]
19 [email protected] "inner" 19 [email protected] "inner"
20 [email protected] " " 20 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast b/crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast
index c6859eca8..672dd054a 100644
--- a/crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast
+++ b/crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..292 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -23,7 +23,7 @@ [email protected]
23 [email protected] "{" 23 [email protected] "{"
24 [email protected] "\n " 24 [email protected] "\n "
25 [email protected] 25 [email protected]
26 PLACEHOLDE[email protected] 26 WILDCARD[email protected]
27 [email protected] "_" 27 [email protected] "_"
28 [email protected] " " 28 [email protected] " "
29 [email protected] "=>" 29 [email protected] "=>"
@@ -54,7 +54,7 @@ [email protected]
54 [email protected] "]" 54 [email protected] "]"
55 [email protected] "\n " 55 [email protected] "\n "
56 [email protected] 56 [email protected]
57 PLACEHOLDE[email protected] 57 WILDCARD[email protected]
58 [email protected] "_" 58 [email protected] "_"
59 [email protected] " " 59 [email protected] " "
60 [email protected] "=>" 60 [email protected] "=>"
@@ -78,7 +78,7 @@ [email protected]
78 [email protected] "{" 78 [email protected] "{"
79 [email protected] "\n " 79 [email protected] "\n "
80 [email protected] 80 [email protected]
81 PLACEHOLDE[email protected] 81 WILDCARD[email protected]
82 [email protected] "_" 82 [email protected] "_"
83 [email protected] " " 83 [email protected] " "
84 [email protected] "=>" 84 [email protected] "=>"
@@ -89,7 +89,7 @@ [email protected]
89 [email protected] "," 89 [email protected] ","
90 [email protected] "\n " 90 [email protected] "\n "
91 [email protected] 91 [email protected]
92 PLACEHOLDE[email protected] 92 WILDCARD[email protected]
93 [email protected] "_" 93 [email protected] "_"
94 [email protected] " " 94 [email protected] " "
95 [email protected] "=>" 95 [email protected] "=>"
@@ -165,7 +165,7 @@ [email protected]
165 [email protected] "]" 165 [email protected] "]"
166 [email protected] "\n " 166 [email protected] "\n "
167 [email protected] 167 [email protected]
168 PLACEHOLDE[email protected] 168 WILDCARD[email protected]
169 [email protected] "_" 169 [email protected] "_"
170 [email protected] " " 170 [email protected] " "
171 [email protected] "=>" 171 [email protected] "=>"
@@ -176,7 +176,7 @@ [email protected]
176 [email protected] "," 176 [email protected] ","
177 [email protected] "\n " 177 [email protected] "\n "
178 [email protected] 178 [email protected]
179 PLACEHOLDE[email protected] 179 WILDCARD[email protected]
180 [email protected] "_" 180 [email protected] "_"
181 [email protected] " " 181 [email protected] " "
182 [email protected] "=>" 182 [email protected] "=>"
diff --git a/crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast b/crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast
index 53e445459..33bb085e9 100644
--- a/crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast
+++ b/crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..88 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -22,7 +22,7 @@ [email protected]
22 [email protected] "{" 22 [email protected] "{"
23 [email protected] "\n " 23 [email protected] "\n "
24 [email protected] 24 [email protected]
25 PLACEHOLDE[email protected] 25 WILDCARD[email protected]
26 [email protected] "_" 26 [email protected] "_"
27 [email protected] " " 27 [email protected] " "
28 [email protected] "=>" 28 [email protected] "=>"
@@ -33,7 +33,7 @@ [email protected]
33 [email protected] "," 33 [email protected] ","
34 [email protected] "\n " 34 [email protected] "\n "
35 [email protected] 35 [email protected]
36 PLACEHOLDE[email protected] 36 WILDCARD[email protected]
37 [email protected] "_" 37 [email protected] "_"
38 [email protected] " " 38 [email protected] " "
39 [email protected] "=>" 39 [email protected] "=>"
diff --git a/crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.rast b/crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.rast
index 1b2ac5011..d9d49bfb5 100644
--- a/crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.rast
+++ b/crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..89 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 BIN[email protected] 17 IDENT[email protected]
18 [email protected] "ref" 18 [email protected] "ref"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 [email protected]
@@ -38,7 +38,7 @@ [email protected]
38 [email protected] 38 [email protected]
39 [email protected] "let" 39 [email protected] "let"
40 [email protected] " " 40 [email protected] " "
41 BIN[email protected] 41 IDENT[email protected]
42 [email protected] "mut" 42 [email protected] "mut"
43 [email protected] " " 43 [email protected] " "
44 [email protected] 44 [email protected]
@@ -62,7 +62,7 @@ [email protected]
62 [email protected] 62 [email protected]
63 [email protected] "let" 63 [email protected] "let"
64 [email protected] " " 64 [email protected] " "
65 BIN[email protected] 65 IDENT[email protected]
66 [email protected] "ref" 66 [email protected] "ref"
67 [email protected] " " 67 [email protected] " "
68 [email protected] "mut" 68 [email protected] "mut"
diff --git a/crates/ra_syntax/test_data/parser/err/0035_use_recover.rast b/crates/ra_syntax/test_data/parser/err/0035_use_recover.rast
index 9588cf3b3..2f03709eb 100644
--- a/crates/ra_syntax/test_data/parser/err/0035_use_recover.rast
+++ b/crates/ra_syntax/test_data/parser/err/0035_use_recover.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..13 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,10 +14,10 @@ [email protected]
14 [email protected] "bar" 14 [email protected] "bar"
15 [email protected] ";" 15 [email protected] ";"
16 [email protected] "\n" 16 [email protected] "\n"
17 USE_ITEM@14..17 17 [email protected]
18 [email protected] "use" 18 [email protected] "use"
19 [email protected] "\n" 19 [email protected] "\n"
20 USE_ITEM@18..33 20 [email protected]
21 [email protected] "use" 21 [email protected] "use"
22 [email protected] " " 22 [email protected] " "
23 [email protected] 23 [email protected]
@@ -31,10 +31,10 @@ [email protected]
31 [email protected] "baz" 31 [email protected] "baz"
32 [email protected] ";" 32 [email protected] ";"
33 [email protected] "\n" 33 [email protected] "\n"
34 USE_ITEM@34..37 34 [email protected]
35 [email protected] "use" 35 [email protected] "use"
36 [email protected] "\n" 36 [email protected] "\n"
37 FN_DEF@38..47 37 [email protected]
38 [email protected] "fn" 38 [email protected] "fn"
39 [email protected] " " 39 [email protected] " "
40 [email protected] 40 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0036_partial_use.rast b/crates/ra_syntax/test_data/parser/err/0036_partial_use.rast
index f926b67d2..ef6172f8a 100644
--- a/crates/ra_syntax/test_data/parser/err/0036_partial_use.rast
+++ b/crates/ra_syntax/test_data/parser/err/0036_partial_use.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..36 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast b/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast
index e3cda7c43..faf87d6e5 100644
--- a/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast
+++ b/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..117 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,10 +14,10 @@ [email protected]
14 [email protected] "(" 14 [email protected] "("
15 [email protected] ")" 15 [email protected] ")"
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 ASSOC_[email protected]
18 [email protected] "{" 18 [email protected] "{"
19 [email protected] "\n " 19 [email protected] "\n "
20 FN_DEF@20..31 20 [email protected]
21 [email protected] "fn" 21 [email protected] "fn"
22 [email protected] " " 22 [email protected] " "
23 [email protected] 23 [email protected]
@@ -30,7 +30,7 @@ [email protected]
30 [email protected] "{" 30 [email protected] "{"
31 [email protected] "}" 31 [email protected] "}"
32 [email protected] "\n " 32 [email protected] "\n "
33 FN_DEF@36..51 33 [email protected]
34 [email protected] 34 [email protected]
35 [email protected] "pub" 35 [email protected] "pub"
36 [email protected] " " 36 [email protected] " "
@@ -46,7 +46,7 @@ [email protected]
46 [email protected] "{" 46 [email protected] "{"
47 [email protected] "}" 47 [email protected] "}"
48 [email protected] "\n " 48 [email protected] "\n "
49 TYPE_ALIAS_DEF@56..81 49 [email protected]
50 [email protected] 50 [email protected]
51 [email protected] "pub" 51 [email protected] "pub"
52 [email protected] "(" 52 [email protected] "("
@@ -65,7 +65,7 @@ [email protected]
65 [email protected] ")" 65 [email protected] ")"
66 [email protected] ";" 66 [email protected] ";"
67 [email protected] "\n " 67 [email protected] "\n "
68 CONST_DEF@86..115 68 [email protected]
69 [email protected] 69 [email protected]
70 [email protected] "pub" 70 [email protected] "pub"
71 [email protected] "(" 71 [email protected] "("
diff --git a/crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.rast b/crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.rast
index 21db9ee85..bed7ad6c3 100644
--- a/crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.rast
+++ b/crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..32 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast b/crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast
index ec950381b..a9c5b70fd 100644
--- a/crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast
+++ b/crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..82 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -49,11 +49,11 @@ [email protected]
49 [email protected] "map" 49 [email protected] "map"
50 [email protected] 50 [email protected]
51 [email protected] "(" 51 [email protected] "("
52 LAMBDA[email protected] 52 CLOSURE[email protected]
53 [email protected] 53 [email protected]
54 [email protected] "|" 54 [email protected] "|"
55 [email protected] 55 [email protected]
56 BIN[email protected] 56 IDENT[email protected]
57 [email protected] 57 [email protected]
58 [email protected] "it" 58 [email protected] "it"
59 [email protected] "|" 59 [email protected] "|"
@@ -62,7 +62,7 @@ [email protected]
62 [email protected] "." 62 [email protected] "."
63 [email protected] 63 [email protected]
64 [email protected] "max" 64 [email protected] "max"
65 TYP[email protected] 65 GENERIC[email protected]
66 [email protected] "::" 66 [email protected] "::"
67 [email protected] "<" 67 [email protected] "<"
68 [email protected] 68 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast b/crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast
index d2a549273..284c8715b 100644
--- a/crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast
+++ b/crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..12 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -9,7 +9,7 @@ [email protected]
9 [email protected] "crate" 9 [email protected] "crate"
10 [email protected] ";" 10 [email protected] ";"
11 [email protected] "\n" 11 [email protected] "\n"
12 USE_ITEM@13..54 12 [email protected]
13 [email protected] "use" 13 [email protected] "use"
14 [email protected] " " 14 [email protected] " "
15 [email protected] 15 [email protected]
@@ -52,7 +52,7 @@ [email protected]
52 [email protected] "}" 52 [email protected] "}"
53 [email protected] ";" 53 [email protected] ";"
54 [email protected] "\n" 54 [email protected] "\n"
55 USE_ITEM@55..72 55 [email protected]
56 [email protected] "use" 56 [email protected] "use"
57 [email protected] " " 57 [email protected] " "
58 [email protected] 58 [email protected]
@@ -66,7 +66,7 @@ [email protected]
66 [email protected] "crate" 66 [email protected] "crate"
67 [email protected] ";" 67 [email protected] ";"
68 [email protected] "\n" 68 [email protected] "\n"
69 USE_ITEM@73..97 69 [email protected]
70 [email protected] "use" 70 [email protected] "use"
71 [email protected] " " 71 [email protected] " "
72 [email protected] 72 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast b/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast
index d0360c467..2049a9d72 100644
--- a/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast
+++ b/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..12 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -9,7 +9,7 @@ [email protected]
9 [email protected] "super" 9 [email protected] "super"
10 [email protected] ";" 10 [email protected] ";"
11 [email protected] "\n" 11 [email protected] "\n"
12 USE_ITEM@13..26 12 [email protected]
13 [email protected] "use" 13 [email protected] "use"
14 [email protected] " " 14 [email protected] " "
15 [email protected] 15 [email protected]
@@ -23,7 +23,7 @@ [email protected]
23 [email protected] "super" 23 [email protected] "super"
24 [email protected] ";" 24 [email protected] ";"
25 [email protected] "\n" 25 [email protected] "\n"
26 USE_ITEM@27..47 26 [email protected]
27 [email protected] "use" 27 [email protected] "use"
28 [email protected] " " 28 [email protected] " "
29 [email protected] 29 [email protected]
@@ -41,7 +41,7 @@ [email protected]
41 [email protected] "super" 41 [email protected] "super"
42 [email protected] ";" 42 [email protected] ";"
43 [email protected] "\n" 43 [email protected] "\n"
44 USE_ITEM@48..66 44 [email protected]
45 [email protected] "use" 45 [email protected] "use"
46 [email protected] " " 46 [email protected] " "
47 [email protected] 47 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast b/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast
index 4f382b06c..deadf56b4 100644
--- a/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast
+++ b/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..11 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -9,7 +9,7 @@ [email protected]
9 [email protected] "self" 9 [email protected] "self"
10 [email protected] ";" 10 [email protected] ";"
11 [email protected] "\n" 11 [email protected] "\n"
12 USE_ITEM@12..24 12 [email protected]
13 [email protected] "use" 13 [email protected] "use"
14 [email protected] " " 14 [email protected] " "
15 [email protected] 15 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0043_default_const.rast b/crates/ra_syntax/test_data/parser/err/0043_default_const.rast
index 8eb583ef8..51ad2a846 100644
--- a/crates/ra_syntax/test_data/parser/err/0043_default_const.rast
+++ b/crates/ra_syntax/test_data/parser/err/0043_default_const.rast
@@ -1,11 +1,11 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..38 2 [email protected]
3 [email protected] "trait" 3 [email protected] "trait"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "T" 6 [email protected] "T"
7 [email protected] " " 7 [email protected] " "
8 [email protected] 8 ASSOC_[email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] "\n " 10 [email protected] "\n "
11 [email protected] 11 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "default" 15 [email protected] "default"
16 [email protected] " " 16 [email protected] " "
17 CONST_DEF@20..36 17 [email protected]
18 [email protected] "const" 18 [email protected] "const"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rast b/crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rast
index cb90f28bc..71aa86494 100644
--- a/crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rast
+++ b/crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..30 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -9,13 +9,13 @@ [email protected]
9 [email protected] " " 9 [email protected] " "
10 [email protected] 10 [email protected]
11 [email protected] "for" 11 [email protected] "for"
12 TYP[email protected] 12 GENERIC[email protected]
13 [email protected] "<" 13 [email protected] "<"
14 [email protected] 14 [email protected]
15 [email protected] "\'a" 15 [email protected] "\'a"
16 [email protected] ">" 16 [email protected] ">"
17 [email protected] " " 17 [email protected] " "
18 REFERENCE[email protected] 18 [email protected]
19 [email protected] "&" 19 [email protected] "&"
20 [email protected] "\'a" 20 [email protected] "\'a"
21 [email protected] " " 21 [email protected] " "
@@ -26,7 +26,7 @@ [email protected]
26 [email protected] "u32" 26 [email protected] "u32"
27 [email protected] ";" 27 [email protected] ";"
28 [email protected] "\n" 28 [email protected] "\n"
29 TYPE_ALIAS_DEF@31..64 29 [email protected]
30 [email protected] "type" 30 [email protected] "type"
31 [email protected] " " 31 [email protected] " "
32 [email protected] 32 [email protected]
@@ -36,7 +36,7 @@ [email protected]
36 [email protected] " " 36 [email protected] " "
37 [email protected] 37 [email protected]
38 [email protected] "for" 38 [email protected] "for"
39 TYP[email protected] 39 GENERIC[email protected]
40 [email protected] "<" 40 [email protected] "<"
41 [email protected] 41 [email protected]
42 [email protected] "\'a" 42 [email protected] "\'a"
@@ -44,7 +44,7 @@ [email protected]
44 [email protected] " " 44 [email protected] " "
45 [email protected] 45 [email protected]
46 [email protected] "(" 46 [email protected] "("
47 REFERENCE[email protected] 47 [email protected]
48 [email protected] "&" 48 [email protected] "&"
49 [email protected] "\'a" 49 [email protected] "\'a"
50 [email protected] " " 50 [email protected] " "
@@ -57,7 +57,7 @@ [email protected]
57 [email protected] ")" 57 [email protected] ")"
58 [email protected] ";" 58 [email protected] ";"
59 [email protected] "\n" 59 [email protected] "\n"
60 TYPE_ALIAS_DEF@65..95 60 [email protected]
61 [email protected] "type" 61 [email protected] "type"
62 [email protected] " " 62 [email protected] " "
63 [email protected] 63 [email protected]
@@ -67,7 +67,7 @@ [email protected]
67 [email protected] " " 67 [email protected] " "
68 [email protected] 68 [email protected]
69 [email protected] "for" 69 [email protected] "for"
70 TYP[email protected] 70 GENERIC[email protected]
71 [email protected] "<" 71 [email protected] "<"
72 [email protected] 72 [email protected]
73 [email protected] "\'a" 73 [email protected] "\'a"
@@ -83,7 +83,7 @@ [email protected]
83 [email protected] "]" 83 [email protected] "]"
84 [email protected] ";" 84 [email protected] ";"
85 [email protected] "\n" 85 [email protected] "\n"
86 TYPE_ALIAS_DEF@96..149 86 [email protected]
87 [email protected] "type" 87 [email protected] "type"
88 [email protected] " " 88 [email protected] " "
89 [email protected] 89 [email protected]
@@ -93,7 +93,7 @@ [email protected]
93 [email protected] " " 93 [email protected] " "
94 [email protected] 94 [email protected]
95 [email protected] "for" 95 [email protected] "for"
96 TYP[email protected] 96 GENERIC[email protected]
97 [email protected] "<" 97 [email protected] "<"
98 [email protected] 98 [email protected]
99 [email protected] "\'a" 99 [email protected] "\'a"
@@ -101,18 +101,18 @@ [email protected]
101 [email protected] " " 101 [email protected] " "
102 [email protected] 102 [email protected]
103 [email protected] "for" 103 [email protected] "for"
104 TYP[email protected] 104 GENERIC[email protected]
105 [email protected] "<" 105 [email protected] "<"
106 [email protected] 106 [email protected]
107 [email protected] "\'b" 107 [email protected] "\'b"
108 [email protected] ">" 108 [email protected] ">"
109 [email protected] " " 109 [email protected] " "
110 FN_POINTE[email protected] 110 [email protected]
111 [email protected] "fn" 111 [email protected] "fn"
112 [email protected] 112 [email protected]
113 [email protected] "(" 113 [email protected] "("
114 [email protected] 114 [email protected]
115 REFERENCE[email protected] 115 [email protected]
116 [email protected] "&" 116 [email protected] "&"
117 [email protected] "\'a" 117 [email protected] "\'a"
118 [email protected] " " 118 [email protected] " "
@@ -124,7 +124,7 @@ [email protected]
124 [email protected] "," 124 [email protected] ","
125 [email protected] " " 125 [email protected] " "
126 [email protected] 126 [email protected]
127 REFERENCE[email protected] 127 [email protected]
128 [email protected] "&" 128 [email protected] "&"
129 [email protected] "\'b" 129 [email protected] "\'b"
130 [email protected] " " 130 [email protected] " "
@@ -136,12 +136,12 @@ [email protected]
136 [email protected] ")" 136 [email protected] ")"
137 [email protected] ";" 137 [email protected] ";"
138 [email protected] "\n" 138 [email protected] "\n"
139 FN_DEF@150..238 139 [email protected]
140 [email protected] "fn" 140 [email protected] "fn"
141 [email protected] " " 141 [email protected] " "
142 [email protected] 142 [email protected]
143 [email protected] "for_for_for" 143 [email protected] "for_for_for"
144 TYP[email protected] 144 GENERIC[email protected]
145 [email protected] "<" 145 [email protected] "<"
146 [email protected] 146 [email protected]
147 [email protected] 147 [email protected]
@@ -156,7 +156,7 @@ [email protected]
156 [email protected] "\n " 156 [email protected] "\n "
157 [email protected] 157 [email protected]
158 [email protected] "for" 158 [email protected] "for"
159 TYP[email protected] 159 GENERIC[email protected]
160 [email protected] "<" 160 [email protected] "<"
161 [email protected] 161 [email protected]
162 [email protected] "\'a" 162 [email protected] "\'a"
@@ -164,7 +164,7 @@ [email protected]
164 [email protected] " " 164 [email protected] " "
165 [email protected] 165 [email protected]
166 [email protected] "for" 166 [email protected] "for"
167 TYP[email protected] 167 GENERIC[email protected]
168 [email protected] "<" 168 [email protected] "<"
169 [email protected] 169 [email protected]
170 [email protected] "\'b" 170 [email protected] "\'b"
@@ -172,18 +172,18 @@ [email protected]
172 [email protected] " " 172 [email protected] " "
173 [email protected] 173 [email protected]
174 [email protected] "for" 174 [email protected] "for"
175 TYP[email protected] 175 GENERIC[email protected]
176 [email protected] "<" 176 [email protected] "<"
177 [email protected] 177 [email protected]
178 [email protected] "\'c" 178 [email protected] "\'c"
179 [email protected] ">" 179 [email protected] ">"
180 [email protected] " " 180 [email protected] " "
181 FN_POINTE[email protected] 181 [email protected]
182 [email protected] "fn" 182 [email protected] "fn"
183 [email protected] 183 [email protected]
184 [email protected] "(" 184 [email protected] "("
185 [email protected] 185 [email protected]
186 REFERENCE[email protected] 186 [email protected]
187 [email protected] "&" 187 [email protected] "&"
188 [email protected] "\'a" 188 [email protected] "\'a"
189 [email protected] " " 189 [email protected] " "
@@ -195,7 +195,7 @@ [email protected]
195 [email protected] "," 195 [email protected] ","
196 [email protected] " " 196 [email protected] " "
197 [email protected] 197 [email protected]
198 REFERENCE[email protected] 198 [email protected]
199 [email protected] "&" 199 [email protected] "&"
200 [email protected] "\'b" 200 [email protected] "\'b"
201 [email protected] " " 201 [email protected] " "
@@ -207,7 +207,7 @@ [email protected]
207 [email protected] "," 207 [email protected] ","
208 [email protected] " " 208 [email protected] " "
209 [email protected] 209 [email protected]
210 REFERENCE[email protected] 210 [email protected]
211 [email protected] "&" 211 [email protected] "&"
212 [email protected] "\'c" 212 [email protected] "\'c"
213 [email protected] " " 213 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast b/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast
index e46456384..df29017e7 100644
--- a/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast
+++ b/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..82 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rast b/crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rast
index f1e78f388..93c429e12 100644
--- a/crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rast
+++ b/crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rast
@@ -1,4 +1,4 @@
1FN_DEF@0..11 1[email protected]
2 [email protected] "fn" 2 [email protected] "fn"
3 [email protected] " " 3 [email protected] " "
4 [email protected] 4 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rast b/crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rast
index 15eb7f9c6..dcf102339 100644
--- a/crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rast
+++ b/crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rast
@@ -4,7 +4,7 @@ [email protected]
4 [email protected] 4 [email protected]
5 [email protected] "Some" 5 [email protected] "Some"
6 [email protected] "(" 6 [email protected] "("
7 BIN[email protected] 7 IDENT[email protected]
8 [email protected] 8 [email protected]
9 [email protected] "x" 9 [email protected] "x"
10 [email protected] ")" 10 [email protected] ")"
diff --git a/crates/ra_syntax/test_data/parser/fragments/type/ok/0000_result.rast b/crates/ra_syntax/test_data/parser/fragments/type/ok/0000_result.rast
index 8831cfa6c..38c15b581 100644
--- a/crates/ra_syntax/test_data/parser/fragments/type/ok/0000_result.rast
+++ b/crates/ra_syntax/test_data/parser/fragments/type/ok/0000_result.rast
@@ -3,7 +3,7 @@ [email protected]
3 [email protected] 3 [email protected]
4 [email protected] 4 [email protected]
5 [email protected] "Result" 5 [email protected] "Result"
6 TYP[email protected] 6 GENERIC[email protected]
7 [email protected] "<" 7 [email protected] "<"
8 [email protected] 8 [email protected]
9 [email protected] 9 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/fuzz-failures/0000.rs b/crates/ra_syntax/test_data/parser/fuzz-failures/0000.rs
index 0e6e0ccc3..f1d0dc343 100644
--- a/crates/ra_syntax/test_data/parser/fuzz-failures/0000.rs
+++ b/crates/ra_syntax/test_data/parser/fuzz-failures/0000.rs
@@ -86,7 +86,7 @@ fn find_reparsable_node(node: SyntaxNodeRef, range: TextRange) -> Option<(Syntax
86 fn reparser(node: SyntaxNodeRef) -> Option<fn(&mut Parser)> { 86 fn reparser(node: SyntaxNodeRef) -> Option<fn(&mut Parser)> {
87 let res = match node.kind() { 87 let res = match node.kind() {
88 BLOCK => grammar::block, 88 BLOCK => grammar::block,
89 RECORD_FIELD_DEF_LIST => grammar::record_field_def_list, 89 RECORD_FIELD_LIST => grammar::record_field_list,
90 _ => return None, 90 _ => return None,
91 }; 91 };
92 Some(res) 92 Some(res)
@@ -138,7 +138,7 @@ fn find_reparsable_node(node: SyntaxNodeRef, range: TextRange) -> Option<(Syntax
138 let res = match node.kind() { 138 let res = match node.kind() {
139 ; 139 ;
140 let end = u32::from(range.end()) as usize; 140 let end = u32::from(range.end()) as usize;
141 text.replaT => grammar::record_field_def_list, 141 text.replaT => grammar::record_field_list,
142 _ => return None, 142 _ => return None,
143 }; 143 };
144 Some(res) 144 Some(res)
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rast b/crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rast
index bf70ebca4..0b9bbec07 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..12 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast b/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast
index 75668c818..a4271fc87 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..29 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -17,7 +17,7 @@ [email protected]
17 [email protected] "\'loop" 17 [email protected] "\'loop"
18 [email protected] ":" 18 [email protected] ":"
19 [email protected] " " 19 [email protected] " "
20 IMPL_DEF@23..27 20 [email protected]
21 [email protected] "impl" 21 [email protected] "impl"
22 [email protected] "\n" 22 [email protected] "\n"
23 [email protected] "}" 23 [email protected] "}"
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast b/crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast
index 95bcc3c0a..0d8bf6dd6 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..13 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -7,7 +7,7 @@ [email protected]
7 [email protected] " " 7 [email protected] " "
8 [email protected] "=" 8 [email protected] "="
9 [email protected] " " 9 [email protected] " "
10 POINTE[email protected] 10 [email protected]
11 [email protected] "*" 11 [email protected] "*"
12 [email protected] 12 [email protected]
13 [email protected] "(" 13 [email protected] "("
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast b/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast
index fd939be8d..29d6b3974 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..12 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -8,11 +8,11 @@ [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "Type" 9 [email protected] "Type"
10 [email protected] " " 10 [email protected] " "
11 [email protected] 11 ASSOC_[email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "}" 13 [email protected] "}"
14 [email protected] "\n" 14 [email protected] "\n"
15 IMPL_DEF@13..33 15 [email protected]
16 [email protected] "impl" 16 [email protected] "impl"
17 [email protected] " " 17 [email protected] " "
18 [email protected] 18 [email protected]
@@ -29,14 +29,14 @@ [email protected]
29 [email protected] 29 [email protected]
30 [email protected] "T" 30 [email protected] "T"
31 [email protected] " " 31 [email protected] " "
32 [email protected] 32 ASSOC_[email protected]
33 [email protected] "{" 33 [email protected] "{"
34 [email protected] "}" 34 [email protected] "}"
35 [email protected] "\n" 35 [email protected] "\n"
36 IMPL_DEF@34..38 36 [email protected]
37 [email protected] "impl" 37 [email protected] "impl"
38 [email protected] " " 38 [email protected] " "
39 IMPL_DEF@39..54 39 [email protected]
40 [email protected] "impl" 40 [email protected] "impl"
41 [email protected] " " 41 [email protected] " "
42 [email protected] 42 [email protected]
@@ -45,11 +45,11 @@ [email protected]
45 [email protected] 45 [email protected]
46 [email protected] "NotType" 46 [email protected] "NotType"
47 [email protected] " " 47 [email protected] " "
48 [email protected] 48 ASSOC_[email protected]
49 [email protected] "{" 49 [email protected] "{"
50 [email protected] "}" 50 [email protected] "}"
51 [email protected] "\n" 51 [email protected] "\n"
52 IMPL_DEF@55..70 52 [email protected]
53 [email protected] "impl" 53 [email protected] "impl"
54 [email protected] " " 54 [email protected] " "
55 [email protected] 55 [email protected]
@@ -60,7 +60,7 @@ [email protected]
60 [email protected] " " 60 [email protected] " "
61 [email protected] "for" 61 [email protected] "for"
62 [email protected] " " 62 [email protected] " "
63 IMPL_DEF@71..86 63 [email protected]
64 [email protected] "impl" 64 [email protected] "impl"
65 [email protected] " " 65 [email protected] " "
66 [email protected] 66 [email protected]
@@ -69,7 +69,7 @@ [email protected]
69 [email protected] 69 [email protected]
70 [email protected] "NotType" 70 [email protected] "NotType"
71 [email protected] " " 71 [email protected] " "
72 [email protected] 72 ASSOC_[email protected]
73 [email protected] "{" 73 [email protected] "{"
74 [email protected] "}" 74 [email protected] "}"
75 [email protected] "\n" 75 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast b/crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast
index 90202d764..776022fd9 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..15 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast b/crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast
index c789e8d82..cc0f8bcaf 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..10 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -19,7 +19,7 @@ [email protected]
19 [email protected] " " 19 [email protected] " "
20 [email protected] "}" 20 [email protected] "}"
21 [email protected] " " 21 [email protected] " "
22 FN_DEF@22..32 22 [email protected]
23 [email protected] "fn" 23 [email protected] "fn"
24 [email protected] " " 24 [email protected] " "
25 [email protected] 25 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.rast b/crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.rast
index cd24313d4..2c9570678 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..29 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 PLACEHOLDE[email protected] 17 WILDCARD[email protected]
18 [email protected] "_" 18 [email protected] "_"
19 [email protected] " " 19 [email protected] " "
20 [email protected] "=" 20 [email protected] "="
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.rast b/crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.rast
index c5fa7a404..63a10127d 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..20 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast b/crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast
index 4e3fa704e..8fd8d5e59 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..47 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast b/crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast
index e1abc5633..fa14e1e6d 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..46 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast b/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast
index 53f7ebaf9..a6e6552a9 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast
@@ -2,7 +2,7 @@ [email protected]
2 [email protected] 2 [email protected]
3 [email protected] "unsafe" 3 [email protected] "unsafe"
4 [email protected] " " 4 [email protected] " "
5 FN_DEF@7..24 5 [email protected]
6 [email protected] "async" 6 [email protected] "async"
7 [email protected] " " 7 [email protected] " "
8 [email protected] "fn" 8 [email protected] "fn"
@@ -17,7 +17,7 @@ [email protected]
17 [email protected] "{" 17 [email protected] "{"
18 [email protected] "}" 18 [email protected] "}"
19 [email protected] "\n" 19 [email protected] "\n"
20 CONST_DEF@25..46 20 [email protected]
21 [email protected] "unsafe" 21 [email protected] "unsafe"
22 [email protected] " " 22 [email protected] " "
23 [email protected] "const" 23 [email protected] "const"
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast b/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast
index ebcc26e0d..8d761b907 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 STATIC_DEF@0..18 2 [email protected]
3 [email protected] "static" 3 [email protected] "static"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast b/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast
index b8cd0587d..acd72094b 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast
@@ -1,11 +1,11 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..61 2 [email protected]
3 [email protected] "trait" 3 [email protected] "trait"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "T" 6 [email protected] "T"
7 [email protected] " " 7 [email protected] " "
8 [email protected] 8 ASSOC_[email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] "\n " 10 [email protected] "\n "
11 [email protected] 11 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "default" 15 [email protected] "default"
16 [email protected] " " 16 [email protected] " "
17 TYPE_ALIAS_DEF@22..35 17 [email protected]
18 [email protected] "type" 18 [email protected] "type"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 [email protected]
@@ -35,7 +35,7 @@ [email protected]
35 [email protected] 35 [email protected]
36 [email protected] "default" 36 [email protected] "default"
37 [email protected] " " 37 [email protected] " "
38 FN_DEF@48..59 38 [email protected]
39 [email protected] "fn" 39 [email protected] "fn"
40 [email protected] " " 40 [email protected] " "
41 [email protected] 41 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast b/crates/ra_syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast
index a9de44b57..a81c442c0 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..44 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -11,16 +11,16 @@ [email protected]
11 [email protected] 11 [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 RECORD_LIT@16..42 14 RECORD_EXPR@16..42
15 [email protected] 15 [email protected]
16 [email protected] 16 [email protected]
17 [email protected] 17 [email protected]
18 [email protected] "S" 18 [email protected] "S"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 RECORD_EXPR_[email protected]
21 [email protected] "{" 21 [email protected] "{"
22 [email protected] " " 22 [email protected] " "
23 [email protected] 23 RECORD_EXPR_[email protected]
24 [email protected] 24 [email protected]
25 [email protected] "field" 25 [email protected] "field"
26 [email protected] " " 26 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rast b/crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rast
index da8505607..2f59d0606 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..12 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast b/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast
index a38b4f573..c7289e400 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..82 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -8,10 +8,10 @@ [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "F" 9 [email protected] "F"
10 [email protected] " " 10 [email protected] " "
11 [email protected] 11 ASSOC_[email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 TYPE_ALIAS_DEF@13..27 14 [email protected]
15 [email protected] "type" 15 [email protected] "type"
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 [email protected]
@@ -27,7 +27,7 @@ [email protected]
27 [email protected] "Clone" 27 [email protected] "Clone"
28 [email protected] ";" 28 [email protected] ";"
29 [email protected] "\n " 29 [email protected] "\n "
30 CONST_DEF@32..45 30 [email protected]
31 [email protected] "const" 31 [email protected] "const"
32 [email protected] " " 32 [email protected] " "
33 [email protected] 33 [email protected]
@@ -41,7 +41,7 @@ [email protected]
41 [email protected] "i32" 41 [email protected] "i32"
42 [email protected] ";" 42 [email protected] ";"
43 [email protected] "\n " 43 [email protected] "\n "
44 FN_DEF@50..61 44 [email protected]
45 [email protected] "fn" 45 [email protected] "fn"
46 [email protected] " " 46 [email protected] " "
47 [email protected] 47 [email protected]
@@ -54,7 +54,7 @@ [email protected]
54 [email protected] "{" 54 [email protected] "{"
55 [email protected] "}" 55 [email protected] "}"
56 [email protected] "\n " 56 [email protected] "\n "
57 FN_DEF@66..80 57 [email protected]
58 [email protected] "fn" 58 [email protected] "fn"
59 [email protected] " " 59 [email protected] " "
60 [email protected] 60 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast b/crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast
index cf3a90400..1e80dd7e2 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..58 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -51,7 +51,7 @@ [email protected]
51 [email protected] " " 51 [email protected] " "
52 [email protected] "// Rust 2018 (with a ..." 52 [email protected] "// Rust 2018 (with a ..."
53 [email protected] "\n" 53 [email protected] "\n"
54 USE_ITEM@98..121 54 [email protected]
55 [email protected] "use" 55 [email protected] "use"
56 [email protected] " " 56 [email protected] " "
57 [email protected] 57 [email protected]
@@ -77,7 +77,7 @@ [email protected]
77 [email protected] " " 77 [email protected] " "
78 [email protected] "// Rust 2015" 78 [email protected] "// Rust 2015"
79 [email protected] "\n" 79 [email protected] "\n"
80 USE_ITEM@135..166 80 [email protected]
81 [email protected] "use" 81 [email protected] "use"
82 [email protected] " " 82 [email protected] " "
83 [email protected] 83 [email protected]
@@ -104,7 +104,7 @@ [email protected]
104 [email protected] " " 104 [email protected] " "
105 [email protected] "// Rust 2015" 105 [email protected] "// Rust 2015"
106 [email protected] "\n" 106 [email protected] "\n"
107 USE_ITEM@180..205 107 [email protected]
108 [email protected] "use" 108 [email protected] "use"
109 [email protected] " " 109 [email protected] " "
110 [email protected] 110 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast b/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast
index cd0892451..62da7b887 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 FN_DEF@0..53 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "for_trait" 6 [email protected] "for_trait"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
@@ -19,7 +19,7 @@ [email protected]
19 [email protected] "\n " 19 [email protected] "\n "
20 [email protected] 20 [email protected]
21 [email protected] "for" 21 [email protected] "for"
22 TYP[email protected] 22 GENERIC[email protected]
23 [email protected] "<" 23 [email protected] "<"
24 [email protected] 24 [email protected]
25 [email protected] "\'a" 25 [email protected] "\'a"
@@ -42,7 +42,7 @@ [email protected]
42 [email protected] 42 [email protected]
43 [email protected] "(" 43 [email protected] "("
44 [email protected] 44 [email protected]
45 REFERENCE[email protected] 45 [email protected]
46 [email protected] "&" 46 [email protected] "&"
47 [email protected] "\'a" 47 [email protected] "\'a"
48 [email protected] " " 48 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast b/crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast
index 20eba09f5..b650735ba 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..38 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] 12 [email protected]
13 [email protected] 13 [email protected]
14 [email protected] "Box" 14 [email protected] "Box"
15 TYP[email protected] 15 GENERIC[email protected]
16 [email protected] "<" 16 [email protected] "<"
17 [email protected] 17 [email protected]
18 [email protected] 18 [email protected]
@@ -31,7 +31,7 @@ [email protected]
31 [email protected] "," 31 [email protected] ","
32 [email protected] " " 32 [email protected] " "
33 [email protected] 33 [email protected]
34 REFERENCE[email protected] 34 [email protected]
35 [email protected] "&" 35 [email protected] "&"
36 [email protected] 36 [email protected]
37 [email protected] 37 [email protected]
@@ -41,7 +41,7 @@ [email protected]
41 [email protected] "," 41 [email protected] ","
42 [email protected] " " 42 [email protected] " "
43 [email protected] 43 [email protected]
44 REFERENCE[email protected] 44 [email protected]
45 [email protected] "&" 45 [email protected] "&"
46 [email protected] 46 [email protected]
47 [email protected] 47 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.rast b/crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.rast
index 6c8c1e24b..8e0252ce7 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 FN_DEF@0..27 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "foo" 6 [email protected] "foo"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast b/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast
index 9f4a9e69b..d24ad7423 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..127 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -8,10 +8,10 @@ [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "S" 9 [email protected] "S"
10 [email protected] " " 10 [email protected] " "
11 [email protected] 11 ASSOC_[email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 FN_DEF@13..26 14 [email protected]
15 [email protected] "fn" 15 [email protected] "fn"
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 [email protected]
@@ -26,7 +26,7 @@ [email protected]
26 [email protected] "{" 26 [email protected] "{"
27 [email protected] "}" 27 [email protected] "}"
28 [email protected] "\n " 28 [email protected] "\n "
29 FN_DEF@31..46 29 [email protected]
30 [email protected] "fn" 30 [email protected] "fn"
31 [email protected] " " 31 [email protected] " "
32 [email protected] 32 [email protected]
@@ -43,7 +43,7 @@ [email protected]
43 [email protected] "{" 43 [email protected] "{"
44 [email protected] "}" 44 [email protected] "}"
45 [email protected] "\n " 45 [email protected] "\n "
46 FN_DEF@51..69 46 [email protected]
47 [email protected] "fn" 47 [email protected] "fn"
48 [email protected] " " 48 [email protected] " "
49 [email protected] 49 [email protected]
@@ -62,7 +62,7 @@ [email protected]
62 [email protected] "{" 62 [email protected] "{"
63 [email protected] "}" 63 [email protected] "}"
64 [email protected] "\n " 64 [email protected] "\n "
65 FN_DEF@74..103 65 [email protected]
66 [email protected] "fn" 66 [email protected] "fn"
67 [email protected] " " 67 [email protected] " "
68 [email protected] 68 [email protected]
@@ -79,7 +79,7 @@ [email protected]
79 [email protected] "," 79 [email protected] ","
80 [email protected] " " 80 [email protected] " "
81 [email protected] 81 [email protected]
82 BIN[email protected] 82 IDENT[email protected]
83 [email protected] 83 [email protected]
84 [email protected] "x" 84 [email protected] "x"
85 [email protected] ":" 85 [email protected] ":"
@@ -95,7 +95,7 @@ [email protected]
95 [email protected] "{" 95 [email protected] "{"
96 [email protected] "}" 96 [email protected] "}"
97 [email protected] "\n " 97 [email protected] "\n "
98 FN_DEF@108..125 98 [email protected]
99 [email protected] "fn" 99 [email protected] "fn"
100 [email protected] " " 100 [email protected] " "
101 [email protected] 101 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.rast b/crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.rast
index 7cb9e1d55..e95688f56 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..34 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "S" 6 [email protected] "S"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rast b/crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rast
index 10eb31d68..7d2f7eab0 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..102 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -58,7 +58,7 @@ [email protected]
58 [email protected] 58 [email protected]
59 [email protected] "Bar" 59 [email protected] "Bar"
60 [email protected] " " 60 [email protected] " "
61 RECORD_FIELD_PAT_[email protected] 61 RECORD_PAT_[email protected]
62 [email protected] "{" 62 [email protected] "{"
63 [email protected] " " 63 [email protected] " "
64 [email protected] ".." 64 [email protected] ".."
@@ -81,7 +81,7 @@ [email protected]
81 [email protected] 81 [email protected]
82 [email protected] "Bar" 82 [email protected] "Bar"
83 [email protected] "(" 83 [email protected] "("
84 DOT_DOT_[email protected] 84 RES[email protected]
85 [email protected] ".." 85 [email protected] ".."
86 [email protected] ")" 86 [email protected] ")"
87 [email protected] " " 87 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.rast
index 425e5196c..f62826fd5 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..25 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.rast
index d823c08fc..66a609346 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..47 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rast b/crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rast
index 283442a8b..28c94bfd6 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..30 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rast b/crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rast
index e2e871dda..d33215b50 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..17 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -7,7 +7,7 @@ [email protected]
7 [email protected] " " 7 [email protected] " "
8 [email protected] "=" 8 [email protected] "="
9 [email protected] " " 9 [email protected] " "
10 POINTE[email protected] 10 [email protected]
11 [email protected] "*" 11 [email protected] "*"
12 [email protected] "mut" 12 [email protected] "mut"
13 [email protected] " " 13 [email protected] " "
@@ -16,7 +16,7 @@ [email protected]
16 [email protected] ")" 16 [email protected] ")"
17 [email protected] ";" 17 [email protected] ";"
18 [email protected] "\n" 18 [email protected] "\n"
19 TYPE_ALIAS_DEF@18..35 19 [email protected]
20 [email protected] "type" 20 [email protected] "type"
21 [email protected] " " 21 [email protected] " "
22 [email protected] 22 [email protected]
@@ -24,7 +24,7 @@ [email protected]
24 [email protected] " " 24 [email protected] " "
25 [email protected] "=" 25 [email protected] "="
26 [email protected] " " 26 [email protected] " "
27 POINTE[email protected] 27 [email protected]
28 [email protected] "*" 28 [email protected] "*"
29 [email protected] "mut" 29 [email protected] "mut"
30 [email protected] " " 30 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.rast
index a60940fcf..b1d5106ce 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..15 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.rast
index 422912e3c..104e153ce 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..68 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast b/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast
index d59c6006d..625ab4c2d 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..17 2 [email protected]
3 [email protected] "unsafe" 3 [email protected] "unsafe"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "trait" 5 [email protected] "trait"
@@ -7,7 +7,7 @@ [email protected]
7 [email protected] 7 [email protected]
8 [email protected] "T" 8 [email protected] "T"
9 [email protected] " " 9 [email protected] " "
10 [email protected] 10 ASSOC_[email protected]
11 [email protected] "{" 11 [email protected] "{"
12 [email protected] "}" 12 [email protected] "}"
13 [email protected] "\n" 13 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.rast
index 61a0b22f4..c131df1c9 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..18 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast b/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast
index 15da6fdd6..ddbd66588 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..68 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -8,10 +8,10 @@ [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "S" 9 [email protected] "S"
10 [email protected] " " 10 [email protected] " "
11 [email protected] 11 ASSOC_[email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 FN_DEF@13..33 14 [email protected]
15 [email protected] "fn" 15 [email protected] "fn"
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 [email protected]
@@ -22,7 +22,7 @@ [email protected]
22 [email protected] "self" 22 [email protected] "self"
23 [email protected] ":" 23 [email protected] ":"
24 [email protected] " " 24 [email protected] " "
25 REFERENCE[email protected] 25 [email protected]
26 [email protected] "&" 26 [email protected] "&"
27 [email protected] 27 [email protected]
28 [email protected] 28 [email protected]
@@ -35,7 +35,7 @@ [email protected]
35 [email protected] "{" 35 [email protected] "{"
36 [email protected] "}" 36 [email protected] "}"
37 [email protected] "\n " 37 [email protected] "\n "
38 FN_DEF@38..66 38 [email protected]
39 [email protected] "fn" 39 [email protected] "fn"
40 [email protected] " " 40 [email protected] " "
41 [email protected] 41 [email protected]
@@ -53,7 +53,7 @@ [email protected]
53 [email protected] 53 [email protected]
54 [email protected] 54 [email protected]
55 [email protected] "Box" 55 [email protected] "Box"
56 TYP[email protected] 56 GENERIC[email protected]
57 [email protected] "<" 57 [email protected] "<"
58 [email protected] 58 [email protected]
59 [email protected] 59 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rast
index 10d6b2fde..7db38ea4d 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..43 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast b/crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast
index 9e898b7b9..b3623c445 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast
@@ -1,12 +1,12 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..6 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "*" 6 [email protected] "*"
7 [email protected] ";" 7 [email protected] ";"
8 [email protected] "\n" 8 [email protected] "\n"
9 USE_ITEM@7..15 9 [email protected]
10 [email protected] "use" 10 [email protected] "use"
11 [email protected] " " 11 [email protected] " "
12 [email protected] 12 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] "*" 14 [email protected] "*"
15 [email protected] ";" 15 [email protected] ";"
16 [email protected] "\n" 16 [email protected] "\n"
17 USE_ITEM@16..36 17 [email protected]
18 [email protected] "use" 18 [email protected] "use"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 [email protected]
@@ -35,7 +35,7 @@ [email protected]
35 [email protected] "}" 35 [email protected] "}"
36 [email protected] ";" 36 [email protected] ";"
37 [email protected] "\n" 37 [email protected] "\n"
38 USE_ITEM@37..59 38 [email protected]
39 [email protected] "use" 39 [email protected] "use"
40 [email protected] " " 40 [email protected] " "
41 [email protected] 41 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast b/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast
index c204aeb63..ca0702aba 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..88 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -8,10 +8,10 @@ [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "F" 9 [email protected] "F"
10 [email protected] " " 10 [email protected] " "
11 [email protected] 11 ASSOC_[email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 TYPE_ALIAS_DEF@13..26 14 [email protected]
15 [email protected] "type" 15 [email protected] "type"
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 [email protected]
@@ -26,7 +26,7 @@ [email protected]
26 [email protected] "i32" 26 [email protected] "i32"
27 [email protected] ";" 27 [email protected] ";"
28 [email protected] "\n " 28 [email protected] "\n "
29 CONST_DEF@31..49 29 [email protected]
30 [email protected] "const" 30 [email protected] "const"
31 [email protected] " " 31 [email protected] " "
32 [email protected] 32 [email protected]
@@ -45,7 +45,7 @@ [email protected]
45 [email protected] "92" 45 [email protected] "92"
46 [email protected] ";" 46 [email protected] ";"
47 [email protected] "\n " 47 [email protected] "\n "
48 FN_DEF@54..65 48 [email protected]
49 [email protected] "fn" 49 [email protected] "fn"
50 [email protected] " " 50 [email protected] " "
51 [email protected] 51 [email protected]
@@ -58,7 +58,7 @@ [email protected]
58 [email protected] "{" 58 [email protected] "{"
59 [email protected] "}" 59 [email protected] "}"
60 [email protected] "\n " 60 [email protected] "\n "
61 FN_DEF@70..86 61 [email protected]
62 [email protected] "fn" 62 [email protected] "fn"
63 [email protected] " " 63 [email protected] " "
64 [email protected] 64 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.rast b/crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.rast
index 1b810607e..50742cbcf 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..20 2 [email protected]
3 [email protected] 3 [email protected]
4 [email protected] "pub" 4 [email protected] "pub"
5 [email protected] "(" 5 [email protected] "("
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] "S" 12 [email protected] "S"
13 [email protected] ";" 13 [email protected] ";"
14 [email protected] "\n" 14 [email protected] "\n"
15 STRUCT_DEF@21..40 15 [email protected]
16 [email protected] 16 [email protected]
17 [email protected] "pub" 17 [email protected] "pub"
18 [email protected] "(" 18 [email protected] "("
@@ -25,7 +25,7 @@ [email protected]
25 [email protected] "S" 25 [email protected] "S"
26 [email protected] ";" 26 [email protected] ";"
27 [email protected] "\n" 27 [email protected] "\n"
28 STRUCT_DEF@41..60 28 [email protected]
29 [email protected] 29 [email protected]
30 [email protected] "pub" 30 [email protected] "pub"
31 [email protected] "(" 31 [email protected] "("
@@ -38,7 +38,7 @@ [email protected]
38 [email protected] "S" 38 [email protected] "S"
39 [email protected] ";" 39 [email protected] ";"
40 [email protected] "\n" 40 [email protected] "\n"
41 STRUCT_DEF@61..80 41 [email protected]
42 [email protected] 42 [email protected]
43 [email protected] "pub" 43 [email protected] "pub"
44 [email protected] "(" 44 [email protected] "("
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rast
index 17687617b..e4fe2b948 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..21 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -7,7 +7,7 @@ [email protected]
7 [email protected] " " 7 [email protected] " "
8 [email protected] "=" 8 [email protected] "="
9 [email protected] " " 9 [email protected] " "
10 PLACEHOLDE[email protected] 10 INF[email protected]
11 [email protected] "_" 11 [email protected] "_"
12 [email protected] ";" 12 [email protected] ";"
13 [email protected] "\n" 13 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rast b/crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rast
index 7eb27d5e1..2dbce34b6 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..38 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -16,17 +16,17 @@ [email protected]
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 [email protected]
18 [email protected] "[" 18 [email protected] "["
19 BIN[email protected] 19 IDENT[email protected]
20 [email protected] 20 [email protected]
21 [email protected] "a" 21 [email protected] "a"
22 [email protected] "," 22 [email protected] ","
23 [email protected] " " 23 [email protected] " "
24 BIN[email protected] 24 IDENT[email protected]
25 [email protected] 25 [email protected]
26 [email protected] "b" 26 [email protected] "b"
27 [email protected] "," 27 [email protected] ","
28 [email protected] " " 28 [email protected] " "
29 DOT_DOT_[email protected] 29 RES[email protected]
30 [email protected] ".." 30 [email protected] ".."
31 [email protected] "]" 31 [email protected] "]"
32 [email protected] " " 32 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.rast
index 0a6d77f45..fd819ea37 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..14 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast b/crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast
index b4598768e..467a30134 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..96 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -38,7 +38,7 @@ [email protected]
38 [email protected] 38 [email protected]
39 [email protected] "S" 39 [email protected] "S"
40 [email protected] "(" 40 [email protected] "("
41 PLACEHOLDE[email protected] 41 WILDCARD[email protected]
42 [email protected] "_" 42 [email protected] "_"
43 [email protected] ")" 43 [email protected] ")"
44 [email protected] " " 44 [email protected] " "
@@ -58,7 +58,7 @@ [email protected]
58 [email protected] 58 [email protected]
59 [email protected] "S" 59 [email protected] "S"
60 [email protected] "(" 60 [email protected] "("
61 PLACEHOLDE[email protected] 61 WILDCARD[email protected]
62 [email protected] "_" 62 [email protected] "_"
63 [email protected] "," 63 [email protected] ","
64 [email protected] ")" 64 [email protected] ")"
@@ -79,16 +79,16 @@ [email protected]
79 [email protected] 79 [email protected]
80 [email protected] "S" 80 [email protected] "S"
81 [email protected] "(" 81 [email protected] "("
82 PLACEHOLDE[email protected] 82 WILDCARD[email protected]
83 [email protected] "_" 83 [email protected] "_"
84 [email protected] "," 84 [email protected] ","
85 [email protected] " " 85 [email protected] " "
86 DOT_DOT_[email protected] 86 RES[email protected]
87 [email protected] ".." 87 [email protected] ".."
88 [email protected] " " 88 [email protected] " "
89 [email protected] "," 89 [email protected] ","
90 [email protected] " " 90 [email protected] " "
91 BIN[email protected] 91 IDENT[email protected]
92 [email protected] 92 [email protected]
93 [email protected] "x" 93 [email protected] "x"
94 [email protected] ")" 94 [email protected] ")"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.rast b/crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.rast
index b824c10a8..348b54dc9 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..51 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -16,7 +16,7 @@ [email protected]
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 [email protected]
18 [email protected] "&" 18 [email protected] "&"
19 BIN[email protected] 19 IDENT[email protected]
20 [email protected] 20 [email protected]
21 [email protected] "a" 21 [email protected] "a"
22 [email protected] " " 22 [email protected] " "
@@ -34,7 +34,7 @@ [email protected]
34 [email protected] "&" 34 [email protected] "&"
35 [email protected] "mut" 35 [email protected] "mut"
36 [email protected] " " 36 [email protected] " "
37 BIN[email protected] 37 IDENT[email protected]
38 [email protected] 38 [email protected]
39 [email protected] "b" 39 [email protected] "b"
40 [email protected] " " 40 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.rast
index 93f5c738c..32b2959bd 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..42 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -17,7 +17,7 @@ [email protected]
17 [email protected] 17 [email protected]
18 [email protected] 18 [email protected]
19 [email protected] "Iterator" 19 [email protected] "Iterator"
20 TYP[email protected] 20 GENERIC[email protected]
21 [email protected] "<" 21 [email protected] "<"
22 [email protected] 22 [email protected]
23 [email protected] 23 [email protected]
@@ -28,7 +28,7 @@ [email protected]
28 [email protected] 28 [email protected]
29 [email protected] 29 [email protected]
30 [email protected] "Foo" 30 [email protected] "Foo"
31 TYP[email protected] 31 GENERIC[email protected]
32 [email protected] "<" 32 [email protected] "<"
33 [email protected] 33 [email protected]
34 [email protected] "\'a" 34 [email protected] "\'a"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.rast
index fabb09937..e096b3a1f 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..88 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0030_cond.rast b/crates/ra_syntax/test_data/parser/inline/ok/0030_cond.rast
index 3aed26732..58a97d3ad 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0030_cond.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0030_cond.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..37 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -23,7 +23,7 @@ [email protected]
23 [email protected] 23 [email protected]
24 [email protected] "Some" 24 [email protected] "Some"
25 [email protected] "(" 25 [email protected] "("
26 PLACEHOLDE[email protected] 26 WILDCARD[email protected]
27 [email protected] "_" 27 [email protected] "_"
28 [email protected] ")" 28 [email protected] ")"
29 [email protected] " " 29 [email protected] " "
@@ -41,7 +41,7 @@ [email protected]
41 [email protected] " " 41 [email protected] " "
42 [email protected] "}" 42 [email protected] "}"
43 [email protected] "\n" 43 [email protected] "\n"
44 FN_DEF@38..196 44 [email protected]
45 [email protected] "fn" 45 [email protected] "fn"
46 [email protected] " " 46 [email protected] " "
47 [email protected] 47 [email protected]
@@ -67,7 +67,7 @@ [email protected]
67 [email protected] 67 [email protected]
68 [email protected] "Some" 68 [email protected] "Some"
69 [email protected] "(" 69 [email protected] "("
70 PLACEHOLDE[email protected] 70 WILDCARD[email protected]
71 [email protected] "_" 71 [email protected] "_"
72 [email protected] ")" 72 [email protected] ")"
73 [email protected] " " 73 [email protected] " "
@@ -79,7 +79,7 @@ [email protected]
79 [email protected] 79 [email protected]
80 [email protected] "Some" 80 [email protected] "Some"
81 [email protected] "(" 81 [email protected] "("
82 PLACEHOLDE[email protected] 82 WILDCARD[email protected]
83 [email protected] "_" 83 [email protected] "_"
84 [email protected] ")" 84 [email protected] ")"
85 [email protected] " " 85 [email protected] " "
@@ -110,7 +110,7 @@ [email protected]
110 [email protected] 110 [email protected]
111 [email protected] "Some" 111 [email protected] "Some"
112 [email protected] "(" 112 [email protected] "("
113 PLACEHOLDE[email protected] 113 WILDCARD[email protected]
114 [email protected] "_" 114 [email protected] "_"
115 [email protected] ")" 115 [email protected] ")"
116 [email protected] " " 116 [email protected] " "
@@ -140,7 +140,7 @@ [email protected]
140 [email protected] 140 [email protected]
141 [email protected] "Some" 141 [email protected] "Some"
142 [email protected] "(" 142 [email protected] "("
143 PLACEHOLDE[email protected] 143 WILDCARD[email protected]
144 [email protected] "_" 144 [email protected] "_"
145 [email protected] ")" 145 [email protected] ")"
146 [email protected] " " 146 [email protected] " "
@@ -152,7 +152,7 @@ [email protected]
152 [email protected] 152 [email protected]
153 [email protected] "Some" 153 [email protected] "Some"
154 [email protected] "(" 154 [email protected] "("
155 PLACEHOLDE[email protected] 155 WILDCARD[email protected]
156 [email protected] "_" 156 [email protected] "_"
157 [email protected] ")" 157 [email protected] ")"
158 [email protected] " " 158 [email protected] " "
@@ -182,7 +182,7 @@ [email protected]
182 [email protected] 182 [email protected]
183 [email protected] "Some" 183 [email protected] "Some"
184 [email protected] "(" 184 [email protected] "("
185 PLACEHOLDE[email protected] 185 WILDCARD[email protected]
186 [email protected] "_" 186 [email protected] "_"
187 [email protected] ")" 187 [email protected] ")"
188 [email protected] " " 188 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.rast
index 899b63aac..173cecf6d 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..92 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -37,7 +37,7 @@ [email protected]
37 [email protected] 37 [email protected]
38 [email protected] "Some" 38 [email protected] "Some"
39 [email protected] "(" 39 [email protected] "("
40 BIN[email protected] 40 IDENT[email protected]
41 [email protected] 41 [email protected]
42 [email protected] "x" 42 [email protected] "x"
43 [email protected] ")" 43 [email protected] ")"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rast
index 72705e148..dda6577ed 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..14 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -7,14 +7,14 @@ [email protected]
7 [email protected] " " 7 [email protected] " "
8 [email protected] "=" 8 [email protected] "="
9 [email protected] " " 9 [email protected] " "
10 FN_POINTE[email protected] 10 [email protected]
11 [email protected] "fn" 11 [email protected] "fn"
12 [email protected] 12 [email protected]
13 [email protected] "(" 13 [email protected] "("
14 [email protected] ")" 14 [email protected] ")"
15 [email protected] ";" 15 [email protected] ";"
16 [email protected] "\n" 16 [email protected] "\n"
17 TYPE_ALIAS_DEF@15..36 17 [email protected]
18 [email protected] "type" 18 [email protected] "type"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 [email protected]
@@ -22,7 +22,7 @@ [email protected]
22 [email protected] " " 22 [email protected] " "
23 [email protected] "=" 23 [email protected] "="
24 [email protected] " " 24 [email protected] " "
25 FN_POINTE[email protected] 25 [email protected]
26 [email protected] "unsafe" 26 [email protected] "unsafe"
27 [email protected] " " 27 [email protected] " "
28 [email protected] "fn" 28 [email protected] "fn"
@@ -31,7 +31,7 @@ [email protected]
31 [email protected] ")" 31 [email protected] ")"
32 [email protected] ";" 32 [email protected] ";"
33 [email protected] "\n" 33 [email protected] "\n"
34 TYPE_ALIAS_DEF@37..69 34 [email protected]
35 [email protected] "type" 35 [email protected] "type"
36 [email protected] " " 36 [email protected] " "
37 [email protected] 37 [email protected]
@@ -39,7 +39,7 @@ [email protected]
39 [email protected] " " 39 [email protected] " "
40 [email protected] "=" 40 [email protected] "="
41 [email protected] " " 41 [email protected] " "
42 FN_POINTE[email protected] 42 [email protected]
43 [email protected] "unsafe" 43 [email protected] "unsafe"
44 [email protected] " " 44 [email protected] " "
45 [email protected] 45 [email protected]
@@ -53,7 +53,7 @@ [email protected]
53 [email protected] ")" 53 [email protected] ")"
54 [email protected] ";" 54 [email protected] ";"
55 [email protected] "\n" 55 [email protected] "\n"
56 TYPE_ALIAS_DEF@70..112 56 [email protected]
57 [email protected] "type" 57 [email protected] "type"
58 [email protected] " " 58 [email protected] " "
59 [email protected] 59 [email protected]
@@ -61,7 +61,7 @@ [email protected]
61 [email protected] " " 61 [email protected] " "
62 [email protected] "=" 62 [email protected] "="
63 [email protected] " " 63 [email protected] " "
64 FN_POINTE[email protected] 64 [email protected]
65 [email protected] 65 [email protected]
66 [email protected] "extern" 66 [email protected] "extern"
67 [email protected] " " 67 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.rast b/crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.rast
index 784fbb592..974df9f9a 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..13 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -7,14 +7,14 @@ [email protected]
7 [email protected] " " 7 [email protected] " "
8 [email protected] "=" 8 [email protected] "="
9 [email protected] " " 9 [email protected] " "
10 REFERENCE[email protected] 10 [email protected]
11 [email protected] "&" 11 [email protected] "&"
12 [email protected] 12 [email protected]
13 [email protected] "(" 13 [email protected] "("
14 [email protected] ")" 14 [email protected] ")"
15 [email protected] ";" 15 [email protected] ";"
16 [email protected] "\n" 16 [email protected] "\n"
17 TYPE_ALIAS_DEF@14..35 17 [email protected]
18 [email protected] "type" 18 [email protected] "type"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 [email protected]
@@ -22,7 +22,7 @@ [email protected]
22 [email protected] " " 22 [email protected] " "
23 [email protected] "=" 23 [email protected] "="
24 [email protected] " " 24 [email protected] " "
25 REFERENCE[email protected] 25 [email protected]
26 [email protected] "&" 26 [email protected] "&"
27 [email protected] "\'static" 27 [email protected] "\'static"
28 [email protected] " " 28 [email protected] " "
@@ -31,7 +31,7 @@ [email protected]
31 [email protected] ")" 31 [email protected] ")"
32 [email protected] ";" 32 [email protected] ";"
33 [email protected] "\n" 33 [email protected] "\n"
34 TYPE_ALIAS_DEF@36..53 34 [email protected]
35 [email protected] "type" 35 [email protected] "type"
36 [email protected] " " 36 [email protected] " "
37 [email protected] 37 [email protected]
@@ -39,7 +39,7 @@ [email protected]
39 [email protected] " " 39 [email protected] " "
40 [email protected] "=" 40 [email protected] "="
41 [email protected] " " 41 [email protected] " "
42 REFERENCE[email protected] 42 [email protected]
43 [email protected] "&" 43 [email protected] "&"
44 [email protected] "mut" 44 [email protected] "mut"
45 [email protected] " " 45 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.rast
index e064aafaf..f905def6f 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..101 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast
index cf5825593..293b1d64c 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..29 2 [email protected]
3 [email protected] "unsafe" 3 [email protected] "unsafe"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.rast b/crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.rast
index fbd90bc0f..b6379e62f 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..26 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -32,7 +32,7 @@ [email protected]
32 [email protected] "Output" 32 [email protected] "Output"
33 [email protected] ";" 33 [email protected] ";"
34 [email protected] "\n" 34 [email protected] "\n"
35 FN_DEF@27..70 35 [email protected]
36 [email protected] "fn" 36 [email protected] "fn"
37 [email protected] " " 37 [email protected] " "
38 [email protected] 38 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.rast
index a767f145d..64e705fb3 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..20 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.rast b/crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.rast
index e92ea2bf2..69e98b9d6 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..45 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] 12 [email protected]
13 [email protected] 13 [email protected]
14 [email protected] "B" 14 [email protected] "B"
15 TYP[email protected] 15 GENERIC[email protected]
16 [email protected] "<" 16 [email protected] "<"
17 [email protected] 17 [email protected]
18 [email protected] "\'static" 18 [email protected] "\'static"
@@ -27,7 +27,8 @@ [email protected]
27 [email protected] "," 27 [email protected] ","
28 [email protected] " " 28 [email protected] " "
29 [email protected] 29 [email protected]
30 [email protected] "1" 30 [email protected]
31 [email protected] "1"
31 [email protected] "," 32 [email protected] ","
32 [email protected] " " 33 [email protected] " "
33 [email protected] 34 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rast b/crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rast
index aa582516a..db5bd2849 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..19 2 [email protected]
3 [email protected] 3 [email protected]
4 [email protected] "crate" 4 [email protected] "crate"
5 [email protected] " " 5 [email protected] " "
@@ -16,16 +16,16 @@ [email protected]
16 [email protected] " " 16 [email protected] " "
17 [email protected] "}" 17 [email protected] "}"
18 [email protected] "\n" 18 [email protected] "\n"
19 STRUCT_DEF@20..49 19 [email protected]
20 [email protected] "struct" 20 [email protected] "struct"
21 [email protected] " " 21 [email protected] " "
22 [email protected] 22 [email protected]
23 [email protected] "S" 23 [email protected] "S"
24 [email protected] " " 24 [email protected] " "
25 RECORD_FIELD_DEF_[email protected] 25 [email protected]
26 [email protected] "{" 26 [email protected] "{"
27 [email protected] " " 27 [email protected] " "
28 RECORD_FIELD_DEF@31..47 28 [email protected]
29 [email protected] 29 [email protected]
30 [email protected] "crate" 30 [email protected] "crate"
31 [email protected] " " 31 [email protected] " "
@@ -41,14 +41,14 @@ [email protected]
41 [email protected] " " 41 [email protected] " "
42 [email protected] "}" 42 [email protected] "}"
43 [email protected] "\n" 43 [email protected] "\n"
44 STRUCT_DEF@50..70 44 [email protected]
45 [email protected] "struct" 45 [email protected] "struct"
46 [email protected] " " 46 [email protected] " "
47 [email protected] 47 [email protected]
48 [email protected] "T" 48 [email protected] "T"
49 TUPLE_FIELD_DEF_[email protected] 49 [email protected]
50 [email protected] "(" 50 [email protected] "("
51 TUPLE_FIELD_DEF@59..68 51 [email protected]
52 [email protected] 52 [email protected]
53 [email protected] "crate" 53 [email protected] "crate"
54 [email protected] " " 54 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast b/crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast
index 1ae791361..3638462f8 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..41 2 [email protected]
3 [email protected] "trait" 3 [email protected] "trait"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "T" 6 [email protected] "T"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
@@ -48,16 +48,16 @@ [email protected]
48 [email protected] 48 [email protected]
49 [email protected] "Copy" 49 [email protected] "Copy"
50 [email protected] " " 50 [email protected] " "
51 [email protected] 51 ASSOC_[email protected]
52 [email protected] "{" 52 [email protected] "{"
53 [email protected] "}" 53 [email protected] "}"
54 [email protected] "\n" 54 [email protected] "\n"
55 TRAIT_DEF@42..100 55 [email protected]
56 [email protected] "trait" 56 [email protected] "trait"
57 [email protected] " " 57 [email protected] " "
58 [email protected] 58 [email protected]
59 [email protected] "X" 59 [email protected] "X"
60 TYP[email protected] 60 GENERIC[email protected]
61 [email protected] "<" 61 [email protected] "<"
62 [email protected] 62 [email protected]
63 [email protected] 63 [email protected]
@@ -119,7 +119,7 @@ [email protected]
119 [email protected] 119 [email protected]
120 [email protected] "Copy" 120 [email protected] "Copy"
121 [email protected] " " 121 [email protected] " "
122 [email protected] 122 ASSOC_[email protected]
123 [email protected] "{" 123 [email protected] "{"
124 [email protected] "}" 124 [email protected] "}"
125 [email protected] "\n" 125 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.rast
index 0c1c6e877..fa38e9466 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..117 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 PLACEHOLDE[email protected] 17 WILDCARD[email protected]
18 [email protected] "_" 18 [email protected] "_"
19 [email protected] " " 19 [email protected] " "
20 [email protected] "=" 20 [email protected] "="
@@ -33,7 +33,7 @@ [email protected]
33 [email protected] 33 [email protected]
34 [email protected] "let" 34 [email protected] "let"
35 [email protected] " " 35 [email protected] " "
36 PLACEHOLDE[email protected] 36 WILDCARD[email protected]
37 [email protected] "_" 37 [email protected] "_"
38 [email protected] " " 38 [email protected] " "
39 [email protected] "=" 39 [email protected] "="
@@ -69,7 +69,7 @@ [email protected]
69 [email protected] 69 [email protected]
70 [email protected] "let" 70 [email protected] "let"
71 [email protected] " " 71 [email protected] " "
72 PLACEHOLDE[email protected] 72 WILDCARD[email protected]
73 [email protected] "_" 73 [email protected] "_"
74 [email protected] " " 74 [email protected] " "
75 [email protected] "=" 75 [email protected] "="
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast b/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast
index f0e09d40d..60b517230 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..28 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -13,14 +13,14 @@ [email protected]
13 [email protected] 13 [email protected]
14 [email protected] "path" 14 [email protected] "path"
15 [email protected] " " 15 [email protected] " "
16 ALIAS@15..27 16 RENAME@15..27
17 [email protected] "as" 17 [email protected] "as"
18 [email protected] " " 18 [email protected] " "
19 [email protected] 19 [email protected]
20 [email protected] "some_name" 20 [email protected] "some_name"
21 [email protected] ";" 21 [email protected] ";"
22 [email protected] "\n" 22 [email protected] "\n"
23 USE_ITEM@29..181 23 [email protected]
24 [email protected] "use" 24 [email protected] "use"
25 [email protected] " " 25 [email protected] " "
26 [email protected] 26 [email protected]
@@ -43,7 +43,7 @@ [email protected]
43 [email protected] 43 [email protected]
44 [email protected] "path" 44 [email protected] "path"
45 [email protected] " " 45 [email protected] " "
46 ALIAS@54..72 46 RENAME@54..72
47 [email protected] "as" 47 [email protected] "as"
48 [email protected] " " 48 [email protected] " "
49 [email protected] 49 [email protected]
@@ -61,7 +61,7 @@ [email protected]
61 [email protected] 61 [email protected]
62 [email protected] "path" 62 [email protected] "path"
63 [email protected] " " 63 [email protected] " "
64 ALIAS@91..108 64 RENAME@91..108
65 [email protected] "as" 65 [email protected] "as"
66 [email protected] " " 66 [email protected] " "
67 [email protected] 67 [email protected]
@@ -121,7 +121,7 @@ [email protected]
121 [email protected] "}" 121 [email protected] "}"
122 [email protected] ";" 122 [email protected] ";"
123 [email protected] "\n" 123 [email protected] "\n"
124 USE_ITEM@182..197 124 [email protected]
125 [email protected] "use" 125 [email protected] "use"
126 [email protected] " " 126 [email protected] " "
127 [email protected] 127 [email protected]
@@ -130,7 +130,7 @@ [email protected]
130 [email protected] 130 [email protected]
131 [email protected] "Trait" 131 [email protected] "Trait"
132 [email protected] " " 132 [email protected] " "
133 ALIAS@192..196 133 RENAME@192..196
134 [email protected] "as" 134 [email protected] "as"
135 [email protected] " " 135 [email protected] " "
136 [email protected] "_" 136 [email protected] "_"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.rast b/crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.rast
index c23b3b67c..1fd3cd0e7 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..20 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -11,7 +11,7 @@ [email protected]
11 [email protected] 11 [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] " " 13 [email protected] " "
14 FN_DEF@9..18 14 [email protected]
15 [email protected] "fn" 15 [email protected] "fn"
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast b/crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast
index 9ca2165ba..6baea6e3c 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 FN_DEF@0..34 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "foo" 6 [email protected] "foo"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
@@ -21,7 +21,7 @@ [email protected]
21 [email protected] 21 [email protected]
22 [email protected] "(" 22 [email protected] "("
23 [email protected] 23 [email protected]
24 REFERENCE[email protected] 24 [email protected]
25 [email protected] "&" 25 [email protected] "&"
26 [email protected] "mut" 26 [email protected] "mut"
27 [email protected] " " 27 [email protected] " "
@@ -30,7 +30,7 @@ [email protected]
30 [email protected] 30 [email protected]
31 [email protected] 31 [email protected]
32 [email protected] "Foo" 32 [email protected] "Foo"
33 TYP[email protected] 33 GENERIC[email protected]
34 [email protected] "<" 34 [email protected] "<"
35 [email protected] 35 [email protected]
36 [email protected] "\'a" 36 [email protected] "\'a"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rast
index c28dc9d61..e89284c14 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..16 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast
index 52de6023b..d6dfa83b7 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..26 2 [email protected]
3 [email protected] "unsafe" 3 [email protected] "unsafe"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "default" 5 [email protected] "default"
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] 12 [email protected]
13 [email protected] "Foo" 13 [email protected] "Foo"
14 [email protected] " " 14 [email protected] " "
15 [email protected] 15 ASSOC_[email protected]
16 [email protected] "{" 16 [email protected] "{"
17 [email protected] "}" 17 [email protected] "}"
18 [email protected] "\n" 18 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rast b/crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rast
index b209f67f8..4d8404e7c 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..26 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -16,7 +16,7 @@ [email protected]
16 [email protected] 16 [email protected]
17 [email protected] 17 [email protected]
18 [email protected] "Box" 18 [email protected] "Box"
19 TYP[email protected] 19 GENERIC[email protected]
20 [email protected] "<" 20 [email protected] "<"
21 [email protected] 21 [email protected]
22 [email protected] 22 [email protected]
@@ -38,7 +38,7 @@ [email protected]
38 [email protected] "{" 38 [email protected] "{"
39 [email protected] "}" 39 [email protected] "}"
40 [email protected] "\n" 40 [email protected] "\n"
41 FN_DEF@27..57 41 [email protected]
42 [email protected] "fn" 42 [email protected] "fn"
43 [email protected] " " 43 [email protected] " "
44 [email protected] 44 [email protected]
@@ -55,7 +55,7 @@ [email protected]
55 [email protected] 55 [email protected]
56 [email protected] 56 [email protected]
57 [email protected] "Box" 57 [email protected] "Box"
58 TYP[email protected] 58 GENERIC[email protected]
59 [email protected] "<" 59 [email protected] "<"
60 [email protected] 60 [email protected]
61 [email protected] 61 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast
index 8bf62cda9..a5bf55131 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast
@@ -1,14 +1,14 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..21 2 [email protected]
3 [email protected] "trait" 3 [email protected] "trait"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "T" 6 [email protected] "T"
7 [email protected] " " 7 [email protected] " "
8 [email protected] 8 ASSOC_[email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] " " 10 [email protected] " "
11 FN_DEF@10..19 11 [email protected]
12 [email protected] "fn" 12 [email protected] "fn"
13 [email protected] " " 13 [email protected] " "
14 [email protected] 14 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.rast
index 798ef2a48..6330dbf9e 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..12 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.rast
index 0d2f5ff56..9bc36bea7 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..13 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] "Foo" 14 [email protected] "Foo"
15 [email protected] ";" 15 [email protected] ";"
16 [email protected] "\n" 16 [email protected] "\n"
17 TYPE_ALIAS_DEF@14..29 17 [email protected]
18 [email protected] "type" 18 [email protected] "type"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 [email protected]
@@ -30,7 +30,7 @@ [email protected]
30 [email protected] "Foo" 30 [email protected] "Foo"
31 [email protected] ";" 31 [email protected] ";"
32 [email protected] "\n" 32 [email protected] "\n"
33 TYPE_ALIAS_DEF@30..49 33 [email protected]
34 [email protected] "type" 34 [email protected] "type"
35 [email protected] " " 35 [email protected] " "
36 [email protected] 36 [email protected]
@@ -49,7 +49,7 @@ [email protected]
49 [email protected] "Foo" 49 [email protected] "Foo"
50 [email protected] ";" 50 [email protected] ";"
51 [email protected] "\n" 51 [email protected] "\n"
52 TYPE_ALIAS_DEF@50..70 52 [email protected]
53 [email protected] "type" 53 [email protected] "type"
54 [email protected] " " 54 [email protected] " "
55 [email protected] 55 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.rast
index 70232a3b2..c34cfeb31 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..90 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 PLACEHOLDE[email protected] 17 WILDCARD[email protected]
18 [email protected] "_" 18 [email protected] "_"
19 [email protected] " " 19 [email protected] " "
20 [email protected] "=" 20 [email protected] "="
@@ -29,7 +29,7 @@ [email protected]
29 [email protected] 29 [email protected]
30 [email protected] "let" 30 [email protected] "let"
31 [email protected] " " 31 [email protected] " "
32 PLACEHOLDE[email protected] 32 WILDCARD[email protected]
33 [email protected] "_" 33 [email protected] "_"
34 [email protected] " " 34 [email protected] " "
35 [email protected] "=" 35 [email protected] "="
@@ -49,7 +49,7 @@ [email protected]
49 [email protected] 49 [email protected]
50 [email protected] "let" 50 [email protected] "let"
51 [email protected] " " 51 [email protected] " "
52 PLACEHOLDE[email protected] 52 WILDCARD[email protected]
53 [email protected] "_" 53 [email protected] "_"
54 [email protected] " " 54 [email protected] " "
55 [email protected] "=" 55 [email protected] "="
@@ -60,7 +60,7 @@ [email protected]
60 [email protected] "::" 60 [email protected] "::"
61 [email protected] 61 [email protected]
62 [email protected] "a" 62 [email protected] "a"
63 TYP[email protected] 63 GENERIC[email protected]
64 [email protected] "::" 64 [email protected] "::"
65 [email protected] "<" 65 [email protected] "<"
66 [email protected] 66 [email protected]
@@ -75,7 +75,7 @@ [email protected]
75 [email protected] 75 [email protected]
76 [email protected] "let" 76 [email protected] "let"
77 [email protected] " " 77 [email protected] " "
78 PLACEHOLDE[email protected] 78 WILDCARD[email protected]
79 [email protected] "_" 79 [email protected] "_"
80 [email protected] " " 80 [email protected] " "
81 [email protected] "=" 81 [email protected] "="
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast b/crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast
index 6362aa02d..9ae271817 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast
@@ -1,14 +1,14 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..63 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "S" 6 [email protected] "S"
7 [email protected] " " 7 [email protected] " "
8 RECORD_FIELD_DEF_[email protected] 8 [email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] "\n " 10 [email protected] "\n "
11 RECORD_FIELD_DEF@15..60 11 [email protected]
12 [email protected] 12 [email protected]
13 [email protected] "#" 13 [email protected] "#"
14 [email protected] "[" 14 [email protected] "["
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.rast b/crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.rast
index 03c52525e..68bb43852 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..112 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.rast b/crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.rast
index 24f89b83f..28129c50c 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..115 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast
index bb43d1eaf..97548a5ee 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..17 2 [email protected]
3 [email protected] "const" 3 [email protected] "const"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "fn" 5 [email protected] "fn"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.rast b/crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.rast
index 8bd94a868..3e72f9671 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..111 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.rast b/crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.rast
index 9210f155c..984829317 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..82 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -22,7 +22,7 @@ [email protected]
22 [email protected] "{" 22 [email protected] "{"
23 [email protected] "\n " 23 [email protected] "\n "
24 [email protected] 24 [email protected]
25 PLACEHOLDE[email protected] 25 WILDCARD[email protected]
26 [email protected] "_" 26 [email protected] "_"
27 [email protected] " " 27 [email protected] " "
28 [email protected] "=>" 28 [email protected] "=>"
@@ -33,7 +33,7 @@ [email protected]
33 [email protected] "," 33 [email protected] ","
34 [email protected] "\n " 34 [email protected] "\n "
35 [email protected] 35 [email protected]
36 PLACEHOLDE[email protected] 36 WILDCARD[email protected]
37 [email protected] "_" 37 [email protected] "_"
38 [email protected] " " 38 [email protected] " "
39 [email protected] "=>" 39 [email protected] "=>"
@@ -43,7 +43,7 @@ [email protected]
43 [email protected] "}" 43 [email protected] "}"
44 [email protected] "\n " 44 [email protected] "\n "
45 [email protected] 45 [email protected]
46 PLACEHOLDE[email protected] 46 WILDCARD[email protected]
47 [email protected] "_" 47 [email protected] "_"
48 [email protected] " " 48 [email protected] " "
49 [email protected] "=>" 49 [email protected] "=>"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.rast b/crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.rast
index d06fc0be5..25e1777d1 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 EXTERN_CRATE_ITEM@0..17 2 [email protected]
3 [email protected] "extern" 3 [email protected] "extern"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "crate" 5 [email protected] "crate"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast b/crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast
index 850465d82..a9ae1aa59 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..111 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -12,28 +12,28 @@ [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 [email protected] 14 [email protected]
15 RECORD_LIT@15..19 15 RECORD_EXPR@15..19
16 [email protected] 16 [email protected]
17 [email protected] 17 [email protected]
18 [email protected] 18 [email protected]
19 [email protected] "S" 19 [email protected] "S"
20 [email protected] " " 20 [email protected] " "
21 [email protected] 21 RECORD_EXPR_[email protected]
22 [email protected] "{" 22 [email protected] "{"
23 [email protected] "}" 23 [email protected] "}"
24 [email protected] ";" 24 [email protected] ";"
25 [email protected] "\n " 25 [email protected] "\n "
26 [email protected] 26 [email protected]
27 RECORD_LIT@25..40 27 RECORD_EXPR@25..40
28 [email protected] 28 [email protected]
29 [email protected] 29 [email protected]
30 [email protected] 30 [email protected]
31 [email protected] "S" 31 [email protected] "S"
32 [email protected] " " 32 [email protected] " "
33 [email protected] 33 RECORD_EXPR_[email protected]
34 [email protected] "{" 34 [email protected] "{"
35 [email protected] " " 35 [email protected] " "
36 [email protected] 36 RECORD_EXPR_[email protected]
37 [email protected] 37 [email protected]
38 [email protected] 38 [email protected]
39 [email protected] 39 [email protected]
@@ -41,7 +41,7 @@ [email protected]
41 [email protected] "x" 41 [email protected] "x"
42 [email protected] "," 42 [email protected] ","
43 [email protected] " " 43 [email protected] " "
44 [email protected] 44 RECORD_EXPR_[email protected]
45 [email protected] 45 [email protected]
46 [email protected] "y" 46 [email protected] "y"
47 [email protected] ":" 47 [email protected] ":"
@@ -54,16 +54,16 @@ [email protected]
54 [email protected] ";" 54 [email protected] ";"
55 [email protected] "\n " 55 [email protected] "\n "
56 [email protected] 56 [email protected]
57 RECORD_LIT@46..82 57 RECORD_EXPR@46..82
58 [email protected] 58 [email protected]
59 [email protected] 59 [email protected]
60 [email protected] 60 [email protected]
61 [email protected] "S" 61 [email protected] "S"
62 [email protected] " " 62 [email protected] " "
63 [email protected] 63 RECORD_EXPR_[email protected]
64 [email protected] "{" 64 [email protected] "{"
65 [email protected] " " 65 [email protected] " "
66 [email protected] 66 RECORD_EXPR_[email protected]
67 [email protected] 67 [email protected]
68 [email protected] 68 [email protected]
69 [email protected] 69 [email protected]
@@ -71,7 +71,7 @@ [email protected]
71 [email protected] "x" 71 [email protected] "x"
72 [email protected] "," 72 [email protected] ","
73 [email protected] " " 73 [email protected] " "
74 [email protected] 74 RECORD_EXPR_[email protected]
75 [email protected] 75 [email protected]
76 [email protected] "y" 76 [email protected] "y"
77 [email protected] ":" 77 [email protected] ":"
@@ -100,16 +100,16 @@ [email protected]
100 [email protected] ";" 100 [email protected] ";"
101 [email protected] "\n " 101 [email protected] "\n "
102 [email protected] 102 [email protected]
103 RECORD_LIT@88..108 103 RECORD_EXPR@88..108
104 [email protected] 104 [email protected]
105 [email protected] 105 [email protected]
106 [email protected] 106 [email protected]
107 [email protected] "TupleStruct" 107 [email protected] "TupleStruct"
108 [email protected] " " 108 [email protected] " "
109 [email protected] 109 RECORD_EXPR_[email protected]
110 [email protected] "{" 110 [email protected] "{"
111 [email protected] " " 111 [email protected] " "
112 [email protected] 112 RECORD_EXPR_[email protected]
113 [email protected] 113 [email protected]
114 [email protected] "0" 114 [email protected] "0"
115 [email protected] ":" 115 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.rast b/crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.rast
index 02656df31..de8217064 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..11 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -57,7 +57,7 @@ [email protected]
57 [email protected] "{" 57 [email protected] "{"
58 [email protected] "}" 58 [email protected] "}"
59 [email protected] "\n" 59 [email protected] "\n"
60 STRUCT_DEF@60..69 60 [email protected]
61 [email protected] "struct" 61 [email protected] "struct"
62 [email protected] " " 62 [email protected] " "
63 [email protected] 63 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast
index 24b9a1f46..4368930cc 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..19 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "!" 5 [email protected] "!"
@@ -17,7 +17,7 @@ [email protected]
17 [email protected] 17 [email protected]
18 [email protected] "X" 18 [email protected] "X"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 ASSOC_[email protected]
21 [email protected] "{" 21 [email protected] "{"
22 [email protected] "}" 22 [email protected] "}"
23 [email protected] "\n" 23 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.rast
index 445d8d309..587160003 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..136 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rast
index 8e10f3673..3a7fcfe24 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..41 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -17,7 +17,7 @@ [email protected]
17 [email protected] 17 [email protected]
18 [email protected] 18 [email protected]
19 [email protected] "Iterator" 19 [email protected] "Iterator"
20 TYP[email protected] 20 GENERIC[email protected]
21 [email protected] "<" 21 [email protected] "<"
22 [email protected] 22 [email protected]
23 [email protected] 23 [email protected]
@@ -28,7 +28,7 @@ [email protected]
28 [email protected] 28 [email protected]
29 [email protected] 29 [email protected]
30 [email protected] "Foo" 30 [email protected] "Foo"
31 TYP[email protected] 31 GENERIC[email protected]
32 [email protected] "<" 32 [email protected] "<"
33 [email protected] 33 [email protected]
34 [email protected] "\'a" 34 [email protected] "\'a"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast b/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast
index 177bb5514..57d0661a5 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..166 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -23,7 +23,7 @@ [email protected]
23 [email protected] "{" 23 [email protected] "{"
24 [email protected] "\n " 24 [email protected] "\n "
25 [email protected] 25 [email protected]
26 PLACEHOLDE[email protected] 26 WILDCARD[email protected]
27 [email protected] "_" 27 [email protected] "_"
28 [email protected] " " 28 [email protected] " "
29 [email protected] "=>" 29 [email protected] "=>"
@@ -34,7 +34,7 @@ [email protected]
34 [email protected] "," 34 [email protected] ","
35 [email protected] "\n " 35 [email protected] "\n "
36 [email protected] 36 [email protected]
37 PLACEHOLDE[email protected] 37 WILDCARD[email protected]
38 [email protected] "_" 38 [email protected] "_"
39 [email protected] " " 39 [email protected] " "
40 [email protected] 40 [email protected]
@@ -49,14 +49,14 @@ [email protected]
49 [email protected] " " 49 [email protected] " "
50 [email protected] ">" 50 [email protected] ">"
51 [email protected] " " 51 [email protected] " "
52 RECORD_LIT@63..77 52 RECORD_EXPR@63..77
53 [email protected] 53 [email protected]
54 [email protected] 54 [email protected]
55 [email protected] 55 [email protected]
56 [email protected] "Test" 56 [email protected] "Test"
57 [email protected] 57 RECORD_EXPR_[email protected]
58 [email protected] "{" 58 [email protected] "{"
59 [email protected] 59 RECORD_EXPR_[email protected]
60 [email protected] 60 [email protected]
61 [email protected] "field" 61 [email protected] "field"
62 [email protected] ":" 62 [email protected] ":"
@@ -74,13 +74,13 @@ [email protected]
74 [email protected] "\n " 74 [email protected] "\n "
75 [email protected] 75 [email protected]
76 [email protected] 76 [email protected]
77 BIN[email protected] 77 IDENT[email protected]
78 [email protected] 78 [email protected]
79 [email protected] "X" 79 [email protected] "X"
80 [email protected] " " 80 [email protected] " "
81 [email protected] "|" 81 [email protected] "|"
82 [email protected] " " 82 [email protected] " "
83 BIN[email protected] 83 IDENT[email protected]
84 [email protected] 84 [email protected]
85 [email protected] "Y" 85 [email protected] "Y"
86 [email protected] " " 86 [email protected] " "
@@ -104,13 +104,13 @@ [email protected]
104 [email protected] "|" 104 [email protected] "|"
105 [email protected] " " 105 [email protected] " "
106 [email protected] 106 [email protected]
107 BIN[email protected] 107 IDENT[email protected]
108 [email protected] 108 [email protected]
109 [email protected] "X" 109 [email protected] "X"
110 [email protected] " " 110 [email protected] " "
111 [email protected] "|" 111 [email protected] "|"
112 [email protected] " " 112 [email protected] " "
113 BIN[email protected] 113 IDENT[email protected]
114 [email protected] 114 [email protected]
115 [email protected] "Y" 115 [email protected] "Y"
116 [email protected] " " 116 [email protected] " "
@@ -133,7 +133,7 @@ [email protected]
133 [email protected] 133 [email protected]
134 [email protected] "|" 134 [email protected] "|"
135 [email protected] " " 135 [email protected] " "
136 BIN[email protected] 136 IDENT[email protected]
137 [email protected] 137 [email protected]
138 [email protected] "X" 138 [email protected] "X"
139 [email protected] " " 139 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast b/crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast
index caa76fe8a..702f2e0b0 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..15 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.rast b/crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.rast
index ec2496072..6589e4795 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.rast
@@ -1,24 +1,24 @@
1[email protected] 1[email protected]
2 UNION_DEF@0..12 2 [email protected]
3 [email protected] "union" 3 [email protected] "union"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "Foo" 6 [email protected] "Foo"
7 [email protected] " " 7 [email protected] " "
8 RECORD_FIELD_DEF_[email protected] 8 [email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] "}" 10 [email protected] "}"
11 [email protected] "\n" 11 [email protected] "\n"
12 UNION_DEF@13..50 12 [email protected]
13 [email protected] "union" 13 [email protected] "union"
14 [email protected] " " 14 [email protected] " "
15 [email protected] 15 [email protected]
16 [email protected] "Foo" 16 [email protected] "Foo"
17 [email protected] " " 17 [email protected] " "
18 RECORD_FIELD_DEF_[email protected] 18 [email protected]
19 [email protected] "{" 19 [email protected] "{"
20 [email protected] "\n " 20 [email protected] "\n "
21 RECORD_FIELD_DEF@29..35 21 [email protected]
22 [email protected] 22 [email protected]
23 [email protected] "a" 23 [email protected] "a"
24 [email protected] ":" 24 [email protected] ":"
@@ -30,7 +30,7 @@ [email protected]
30 [email protected] "i32" 30 [email protected] "i32"
31 [email protected] "," 31 [email protected] ","
32 [email protected] "\n " 32 [email protected] "\n "
33 RECORD_FIELD_DEF@41..47 33 [email protected]
34 [email protected] 34 [email protected]
35 [email protected] "b" 35 [email protected] "b"
36 [email protected] ":" 36 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast b/crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast
index 18cd5271f..c4c5bc51e 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..18 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -17,7 +17,7 @@ [email protected]
17 [email protected] "}" 17 [email protected] "}"
18 [email protected] ";" 18 [email protected] ";"
19 [email protected] "\n" 19 [email protected] "\n"
20 USE_ITEM@19..36 20 [email protected]
21 [email protected] "use" 21 [email protected] "use"
22 [email protected] " " 22 [email protected] " "
23 [email protected] 23 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast b/crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast
index f8ff7079b..36c9cd5bb 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..45 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 PLACEHOLDE[email protected] 17 WILDCARD[email protected]
18 [email protected] "_" 18 [email protected] "_"
19 [email protected] " " 19 [email protected] " "
20 [email protected] "=" 20 [email protected] "="
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast
index 07b3d1435..d34d98ced 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..96 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -53,7 +53,7 @@ [email protected]
53 [email protected] "{" 53 [email protected] "{"
54 [email protected] " " 54 [email protected] " "
55 [email protected] 55 [email protected]
56 PLACEHOLDE[email protected] 56 WILDCARD[email protected]
57 [email protected] "_" 57 [email protected] "_"
58 [email protected] " " 58 [email protected] " "
59 [email protected] "=>" 59 [email protected] "=>"
@@ -72,13 +72,13 @@ [email protected]
72 [email protected] 72 [email protected]
73 [email protected] "{" 73 [email protected] "{"
74 [email protected] " " 74 [email protected] " "
75 RECORD_LIT@84..88 75 RECORD_EXPR@84..88
76 [email protected] 76 [email protected]
77 [email protected] 77 [email protected]
78 [email protected] 78 [email protected]
79 [email protected] "S" 79 [email protected] "S"
80 [email protected] " " 80 [email protected] " "
81 [email protected] 81 RECORD_EXPR_[email protected]
82 [email protected] "{" 82 [email protected] "{"
83 [email protected] "}" 83 [email protected] "}"
84 [email protected] " " 84 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.rast
index 665f716a8..437d7ac04 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..39 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.rast b/crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.rast
index cc871ac0c..00cce69e6 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..20 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "Result" 6 [email protected] "Result"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast b/crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast
index 3fd3a4391..3a789b9f5 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..83 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -22,7 +22,7 @@ [email protected]
22 [email protected] "{" 22 [email protected] "{"
23 [email protected] "\n " 23 [email protected] "\n "
24 [email protected] 24 [email protected]
25 PLACEHOLDE[email protected] 25 WILDCARD[email protected]
26 [email protected] "_" 26 [email protected] "_"
27 [email protected] " " 27 [email protected] " "
28 [email protected] "=>" 28 [email protected] "=>"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0075_block.rast b/crates/ra_syntax/test_data/parser/inline/ok/0075_block.rast
index 97c6e6a9d..e847ce9b2 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0075_block.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0075_block.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..9 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "}" 13 [email protected] "}"
14 [email protected] "\n" 14 [email protected] "\n"
15 FN_DEF@10..31 15 [email protected]
16 [email protected] "fn" 16 [email protected] "fn"
17 [email protected] " " 17 [email protected] " "
18 [email protected] 18 [email protected]
@@ -27,7 +27,7 @@ [email protected]
27 [email protected] 27 [email protected]
28 [email protected] "let" 28 [email protected] "let"
29 [email protected] " " 29 [email protected] " "
30 PLACEHOLDE[email protected] 30 WILDCARD[email protected]
31 [email protected] "_" 31 [email protected] "_"
32 [email protected] " " 32 [email protected] " "
33 [email protected] "=" 33 [email protected] "="
@@ -38,7 +38,7 @@ [email protected]
38 [email protected] " " 38 [email protected] " "
39 [email protected] "}" 39 [email protected] "}"
40 [email protected] "\n" 40 [email protected] "\n"
41 FN_DEF@32..48 41 [email protected]
42 [email protected] "fn" 42 [email protected] "fn"
43 [email protected] " " 43 [email protected] " "
44 [email protected] 44 [email protected]
@@ -62,7 +62,7 @@ [email protected]
62 [email protected] " " 62 [email protected] " "
63 [email protected] "}" 63 [email protected] "}"
64 [email protected] "\n" 64 [email protected] "\n"
65 FN_DEF@49..64 65 [email protected]
66 [email protected] "fn" 66 [email protected] "fn"
67 [email protected] " " 67 [email protected] " "
68 [email protected] 68 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.rast b/crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.rast
index e2c1a507d..96217a7fd 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 FN_DEF@0..28 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "foo" 6 [email protected] "foo"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.rast
index 4f3a8ed24..33e6fb93f 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..20 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.rast b/crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.rast
index a08e16fab..2befc8388 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..15 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast
index a00ab40f9..209711fc4 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..11 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -8,7 +8,7 @@ [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "Foo" 9 [email protected] "Foo"
10 [email protected] " " 10 [email protected] " "
11 [email protected] 11 ASSOC_[email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "}" 13 [email protected] "}"
14 [email protected] "\n" 14 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.rast b/crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.rast
index 462d1a8bb..b3003577c 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..88 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 BIN[email protected] 17 IDENT[email protected]
18 [email protected] 18 [email protected]
19 [email protected] "x" 19 [email protected] "x"
20 [email protected] " " 20 [email protected] " "
@@ -39,7 +39,7 @@ [email protected]
39 [email protected] "{" 39 [email protected] "{"
40 [email protected] " " 40 [email protected] " "
41 [email protected] 41 [email protected]
42 PLACEHOLDE[email protected] 42 WILDCARD[email protected]
43 [email protected] "_" 43 [email protected] "_"
44 [email protected] " " 44 [email protected] " "
45 [email protected] "=>" 45 [email protected] "=>"
@@ -79,7 +79,7 @@ [email protected]
79 [email protected] "{" 79 [email protected] "{"
80 [email protected] " " 80 [email protected] " "
81 [email protected] 81 [email protected]
82 PLACEHOLDE[email protected] 82 WILDCARD[email protected]
83 [email protected] "_" 83 [email protected] "_"
84 [email protected] " " 84 [email protected] " "
85 [email protected] "=>" 85 [email protected] "=>"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast
index b26ac2d36..f319d5141 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..28 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -9,13 +9,13 @@ [email protected]
9 [email protected] " " 9 [email protected] " "
10 [email protected] 10 [email protected]
11 [email protected] "for" 11 [email protected] "for"
12 TYP[email protected] 12 GENERIC[email protected]
13 [email protected] "<" 13 [email protected] "<"
14 [email protected] 14 [email protected]
15 [email protected] "\'a" 15 [email protected] "\'a"
16 [email protected] ">" 16 [email protected] ">"
17 [email protected] " " 17 [email protected] " "
18 FN_POINTE[email protected] 18 [email protected]
19 [email protected] "fn" 19 [email protected] "fn"
20 [email protected] 20 [email protected]
21 [email protected] "(" 21 [email protected] "("
@@ -29,7 +29,7 @@ [email protected]
29 [email protected] ")" 29 [email protected] ")"
30 [email protected] ";" 30 [email protected] ";"
31 [email protected] "\n" 31 [email protected] "\n"
32 TYPE_ALIAS_DEF@29..81 32 [email protected]
33 [email protected] "type" 33 [email protected] "type"
34 [email protected] " " 34 [email protected] " "
35 [email protected] 35 [email protected]
@@ -39,13 +39,13 @@ [email protected]
39 [email protected] " " 39 [email protected] " "
40 [email protected] 40 [email protected]
41 [email protected] "for" 41 [email protected] "for"
42 TYP[email protected] 42 GENERIC[email protected]
43 [email protected] "<" 43 [email protected] "<"
44 [email protected] 44 [email protected]
45 [email protected] "\'a" 45 [email protected] "\'a"
46 [email protected] ">" 46 [email protected] ">"
47 [email protected] " " 47 [email protected] " "
48 FN_POINTE[email protected] 48 [email protected]
49 [email protected] "unsafe" 49 [email protected] "unsafe"
50 [email protected] " " 50 [email protected] " "
51 [email protected] 51 [email protected]
@@ -57,7 +57,7 @@ [email protected]
57 [email protected] 57 [email protected]
58 [email protected] "(" 58 [email protected] "("
59 [email protected] 59 [email protected]
60 REFERENCE[email protected] 60 [email protected]
61 [email protected] "&" 61 [email protected] "&"
62 [email protected] "\'a" 62 [email protected] "\'a"
63 [email protected] " " 63 [email protected] " "
@@ -74,7 +74,7 @@ [email protected]
74 [email protected] ")" 74 [email protected] ")"
75 [email protected] ";" 75 [email protected] ";"
76 [email protected] "\n" 76 [email protected] "\n"
77 TYPE_ALIAS_DEF@82..120 77 [email protected]
78 [email protected] "type" 78 [email protected] "type"
79 [email protected] " " 79 [email protected] " "
80 [email protected] 80 [email protected]
@@ -84,7 +84,7 @@ [email protected]
84 [email protected] " " 84 [email protected] " "
85 [email protected] 85 [email protected]
86 [email protected] "for" 86 [email protected] "for"
87 TYP[email protected] 87 GENERIC[email protected]
88 [email protected] "<" 88 [email protected] "<"
89 [email protected] 89 [email protected]
90 [email protected] "\'a" 90 [email protected] "\'a"
@@ -95,10 +95,10 @@ [email protected]
95 [email protected] 95 [email protected]
96 [email protected] 96 [email protected]
97 [email protected] "PartialEq" 97 [email protected] "PartialEq"
98 TYP[email protected] 98 GENERIC[email protected]
99 [email protected] "<" 99 [email protected] "<"
100 [email protected] 100 [email protected]
101 REFERENCE[email protected] 101 [email protected]
102 [email protected] "&" 102 [email protected] "&"
103 [email protected] "\'a" 103 [email protected] "\'a"
104 [email protected] " " 104 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rast
index 58bdf7e34..70b975c0b 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..199 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -16,7 +16,7 @@ [email protected]
16 [email protected] 16 [email protected]
17 [email protected] "let" 17 [email protected] "let"
18 [email protected] " " 18 [email protected] " "
19 PLACEHOLDE[email protected] 19 WILDCARD[email protected]
20 [email protected] "_" 20 [email protected] "_"
21 [email protected] " " 21 [email protected] " "
22 [email protected] "=" 22 [email protected] "="
@@ -30,7 +30,7 @@ [email protected]
30 [email protected] 30 [email protected]
31 [email protected] "let" 31 [email protected] "let"
32 [email protected] " " 32 [email protected] " "
33 PLACEHOLDE[email protected] 33 WILDCARD[email protected]
34 [email protected] "_" 34 [email protected] "_"
35 [email protected] " " 35 [email protected] " "
36 [email protected] "=" 36 [email protected] "="
@@ -55,7 +55,7 @@ [email protected]
55 [email protected] 55 [email protected]
56 [email protected] "let" 56 [email protected] "let"
57 [email protected] " " 57 [email protected] " "
58 PLACEHOLDE[email protected] 58 WILDCARD[email protected]
59 [email protected] "_" 59 [email protected] "_"
60 [email protected] " " 60 [email protected] " "
61 [email protected] "=" 61 [email protected] "="
@@ -72,7 +72,7 @@ [email protected]
72 [email protected] 72 [email protected]
73 [email protected] "let" 73 [email protected] "let"
74 [email protected] " " 74 [email protected] " "
75 PLACEHOLDE[email protected] 75 WILDCARD[email protected]
76 [email protected] "_" 76 [email protected] "_"
77 [email protected] " " 77 [email protected] " "
78 [email protected] "=" 78 [email protected] "="
@@ -95,7 +95,7 @@ [email protected]
95 [email protected] 95 [email protected]
96 [email protected] "let" 96 [email protected] "let"
97 [email protected] " " 97 [email protected] " "
98 PLACEHOLDE[email protected] 98 WILDCARD[email protected]
99 [email protected] "_" 99 [email protected] "_"
100 [email protected] " " 100 [email protected] " "
101 [email protected] "=" 101 [email protected] "="
@@ -116,7 +116,7 @@ [email protected]
116 [email protected] 116 [email protected]
117 [email protected] "let" 117 [email protected] "let"
118 [email protected] " " 118 [email protected] " "
119 PLACEHOLDE[email protected] 119 WILDCARD[email protected]
120 [email protected] "_" 120 [email protected] "_"
121 [email protected] " " 121 [email protected] " "
122 [email protected] "=" 122 [email protected] "="
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.rast b/crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.rast
index 217b07e59..cdbc40fe0 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.rast
@@ -1,39 +1,39 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..11 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "Foo" 6 [email protected] "Foo"
7 [email protected] ";" 7 [email protected] ";"
8 [email protected] "\n" 8 [email protected] "\n"
9 STRUCT_DEF@12..25 9 [email protected]
10 [email protected] "struct" 10 [email protected] "struct"
11 [email protected] " " 11 [email protected] " "
12 [email protected] 12 [email protected]
13 [email protected] "Foo" 13 [email protected] "Foo"
14 [email protected] " " 14 [email protected] " "
15 RECORD_FIELD_DEF_[email protected] 15 [email protected]
16 [email protected] "{" 16 [email protected] "{"
17 [email protected] "}" 17 [email protected] "}"
18 [email protected] "\n" 18 [email protected] "\n"
19 STRUCT_DEF@26..39 19 [email protected]
20 [email protected] "struct" 20 [email protected] "struct"
21 [email protected] " " 21 [email protected] " "
22 [email protected] 22 [email protected]
23 [email protected] "Foo" 23 [email protected] "Foo"
24 TUPLE_FIELD_DEF_[email protected] 24 [email protected]
25 [email protected] "(" 25 [email protected] "("
26 [email protected] ")" 26 [email protected] ")"
27 [email protected] ";" 27 [email protected] ";"
28 [email protected] "\n" 28 [email protected] "\n"
29 STRUCT_DEF@40..66 29 [email protected]
30 [email protected] "struct" 30 [email protected] "struct"
31 [email protected] " " 31 [email protected] " "
32 [email protected] 32 [email protected]
33 [email protected] "Foo" 33 [email protected] "Foo"
34 TUPLE_FIELD_DEF_[email protected] 34 [email protected]
35 [email protected] "(" 35 [email protected] "("
36 TUPLE_FIELD_DEF@51..57 36 [email protected]
37 [email protected] 37 [email protected]
38 [email protected] 38 [email protected]
39 [email protected] 39 [email protected]
@@ -41,7 +41,7 @@ [email protected]
41 [email protected] "String" 41 [email protected] "String"
42 [email protected] "," 42 [email protected] ","
43 [email protected] " " 43 [email protected] " "
44 TUPLE_FIELD_DEF@59..64 44 [email protected]
45 [email protected] 45 [email protected]
46 [email protected] 46 [email protected]
47 [email protected] 47 [email protected]
@@ -50,16 +50,16 @@ [email protected]
50 [email protected] ")" 50 [email protected] ")"
51 [email protected] ";" 51 [email protected] ";"
52 [email protected] "\n" 52 [email protected] "\n"
53 STRUCT_DEF@67..105 53 [email protected]
54 [email protected] "struct" 54 [email protected] "struct"
55 [email protected] " " 55 [email protected] " "
56 [email protected] 56 [email protected]
57 [email protected] "Foo" 57 [email protected] "Foo"
58 [email protected] " " 58 [email protected] " "
59 RECORD_FIELD_DEF_[email protected] 59 [email protected]
60 [email protected] "{" 60 [email protected] "{"
61 [email protected] "\n " 61 [email protected] "\n "
62 RECORD_FIELD_DEF@84..90 62 [email protected]
63 [email protected] 63 [email protected]
64 [email protected] "a" 64 [email protected] "a"
65 [email protected] ":" 65 [email protected] ":"
@@ -71,7 +71,7 @@ [email protected]
71 [email protected] "i32" 71 [email protected] "i32"
72 [email protected] "," 72 [email protected] ","
73 [email protected] "\n " 73 [email protected] "\n "
74 RECORD_FIELD_DEF@96..102 74 [email protected]
75 [email protected] 75 [email protected]
76 [email protected] "b" 76 [email protected] "b"
77 [email protected] ":" 77 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.rast
index 9cd8910d4..ee8894966 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..15 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.rast b/crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.rast
index 9fcb7899e..9a87b5b93 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..188 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 PLACEHOLDE[email protected] 17 WILDCARD[email protected]
18 [email protected] "_" 18 [email protected] "_"
19 [email protected] " " 19 [email protected] " "
20 [email protected] "=" 20 [email protected] "="
@@ -26,7 +26,7 @@ [email protected]
26 [email protected] 26 [email protected]
27 [email protected] "let" 27 [email protected] "let"
28 [email protected] " " 28 [email protected] " "
29 PLACEHOLDE[email protected] 29 WILDCARD[email protected]
30 [email protected] "_" 30 [email protected] "_"
31 [email protected] " " 31 [email protected] " "
32 [email protected] "=" 32 [email protected] "="
@@ -38,7 +38,7 @@ [email protected]
38 [email protected] 38 [email protected]
39 [email protected] "let" 39 [email protected] "let"
40 [email protected] " " 40 [email protected] " "
41 PLACEHOLDE[email protected] 41 WILDCARD[email protected]
42 [email protected] "_" 42 [email protected] "_"
43 [email protected] " " 43 [email protected] " "
44 [email protected] "=" 44 [email protected] "="
@@ -50,7 +50,7 @@ [email protected]
50 [email protected] 50 [email protected]
51 [email protected] "let" 51 [email protected] "let"
52 [email protected] " " 52 [email protected] " "
53 PLACEHOLDE[email protected] 53 WILDCARD[email protected]
54 [email protected] "_" 54 [email protected] "_"
55 [email protected] " " 55 [email protected] " "
56 [email protected] "=" 56 [email protected] "="
@@ -62,7 +62,7 @@ [email protected]
62 [email protected] 62 [email protected]
63 [email protected] "let" 63 [email protected] "let"
64 [email protected] " " 64 [email protected] " "
65 PLACEHOLDE[email protected] 65 WILDCARD[email protected]
66 [email protected] "_" 66 [email protected] "_"
67 [email protected] " " 67 [email protected] " "
68 [email protected] "=" 68 [email protected] "="
@@ -74,7 +74,7 @@ [email protected]
74 [email protected] 74 [email protected]
75 [email protected] "let" 75 [email protected] "let"
76 [email protected] " " 76 [email protected] " "
77 PLACEHOLDE[email protected] 77 WILDCARD[email protected]
78 [email protected] "_" 78 [email protected] "_"
79 [email protected] " " 79 [email protected] " "
80 [email protected] "=" 80 [email protected] "="
@@ -86,7 +86,7 @@ [email protected]
86 [email protected] 86 [email protected]
87 [email protected] "let" 87 [email protected] "let"
88 [email protected] " " 88 [email protected] " "
89 PLACEHOLDE[email protected] 89 WILDCARD[email protected]
90 [email protected] "_" 90 [email protected] "_"
91 [email protected] " " 91 [email protected] " "
92 [email protected] "=" 92 [email protected] "="
@@ -98,7 +98,7 @@ [email protected]
98 [email protected] 98 [email protected]
99 [email protected] "let" 99 [email protected] "let"
100 [email protected] " " 100 [email protected] " "
101 PLACEHOLDE[email protected] 101 WILDCARD[email protected]
102 [email protected] "_" 102 [email protected] "_"
103 [email protected] " " 103 [email protected] " "
104 [email protected] "=" 104 [email protected] "="
@@ -110,7 +110,7 @@ [email protected]
110 [email protected] 110 [email protected]
111 [email protected] "let" 111 [email protected] "let"
112 [email protected] " " 112 [email protected] " "
113 PLACEHOLDE[email protected] 113 WILDCARD[email protected]
114 [email protected] "_" 114 [email protected] "_"
115 [email protected] " " 115 [email protected] " "
116 [email protected] "=" 116 [email protected] "="
@@ -122,7 +122,7 @@ [email protected]
122 [email protected] 122 [email protected]
123 [email protected] "let" 123 [email protected] "let"
124 [email protected] " " 124 [email protected] " "
125 PLACEHOLDE[email protected] 125 WILDCARD[email protected]
126 [email protected] "_" 126 [email protected] "_"
127 [email protected] " " 127 [email protected] " "
128 [email protected] "=" 128 [email protected] "="
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.rast
index a42abc189..70e05a859 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..11 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "}" 13 [email protected] "}"
14 [email protected] "\n" 14 [email protected] "\n"
15 FN_DEF@12..29 15 [email protected]
16 [email protected] "fn" 16 [email protected] "fn"
17 [email protected] " " 17 [email protected] " "
18 [email protected] 18 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast
index 01ed3afca..43c09affe 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..18 2 [email protected]
3 [email protected] "unsafe" 3 [email protected] "unsafe"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "impl" 5 [email protected] "impl"
@@ -10,7 +10,7 @@ [email protected]
10 [email protected] 10 [email protected]
11 [email protected] "Foo" 11 [email protected] "Foo"
12 [email protected] " " 12 [email protected] " "
13 [email protected] 13 ASSOC_[email protected]
14 [email protected] "{" 14 [email protected] "{"
15 [email protected] "}" 15 [email protected] "}"
16 [email protected] "\n" 16 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.rast b/crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.rast
index 7e71d7373..f7b839303 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..87 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -38,7 +38,7 @@ [email protected]
38 [email protected] 38 [email protected]
39 [email protected] "for" 39 [email protected] "for"
40 [email protected] " " 40 [email protected] " "
41 BIN[email protected] 41 IDENT[email protected]
42 [email protected] 42 [email protected]
43 [email protected] "i" 43 [email protected] "i"
44 [email protected] " " 44 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast
index 48aaf1004..405b6a259 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..18 2 [email protected]
3 [email protected] 3 [email protected]
4 [email protected] "extern" 4 [email protected] "extern"
5 [email protected] " " 5 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.rast b/crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.rast
index cee2bc906..2ef026e37 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..18 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "S" 6 [email protected] "S"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast b/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast
index 800412cef..0cac9ac43 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..15 2 [email protected]
3 [email protected] "auto" 3 [email protected] "auto"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "trait" 5 [email protected] "trait"
@@ -7,7 +7,7 @@ [email protected]
7 [email protected] 7 [email protected]
8 [email protected] "T" 8 [email protected] "T"
9 [email protected] " " 9 [email protected] " "
10 [email protected] 10 ASSOC_[email protected]
11 [email protected] "{" 11 [email protected] "{"
12 [email protected] "}" 12 [email protected] "}"
13 [email protected] "\n" 13 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast b/crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast
index 1e2d7db7c..f80326465 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..20 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -7,7 +7,7 @@ [email protected]
7 [email protected] " " 7 [email protected] " "
8 [email protected] "=" 8 [email protected] "="
9 [email protected] " " 9 [email protected] " "
10 FN_POINTE[email protected] 10 [email protected]
11 [email protected] "fn" 11 [email protected] "fn"
12 [email protected] 12 [email protected]
13 [email protected] "(" 13 [email protected] "("
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.rast
index aed81f9b0..82f03f9c1 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..25 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast b/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast
index 9370f6ae7..0ef11c682 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..22 2 [email protected]
3 [email protected] "unsafe" 3 [email protected] "unsafe"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "auto" 5 [email protected] "auto"
@@ -9,7 +9,7 @@ [email protected]
9 [email protected] 9 [email protected]
10 [email protected] "T" 10 [email protected] "T"
11 [email protected] " " 11 [email protected] " "
12 [email protected] 12 ASSOC_[email protected]
13 [email protected] "{" 13 [email protected] "{"
14 [email protected] "}" 14 [email protected] "}"
15 [email protected] "\n" 15 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.rast b/crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.rast
index 67d9595d3..c1fdc6e25 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..25 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 PLACEHOLDE[email protected] 17 WILDCARD[email protected]
18 [email protected] "_" 18 [email protected] "_"
19 [email protected] " " 19 [email protected] " "
20 [email protected] "=" 20 [email protected] "="
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rast b/crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rast
index 031e74652..e757249f0 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..166 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -59,7 +59,7 @@ [email protected]
59 [email protected] 59 [email protected]
60 [email protected] "for" 60 [email protected] "for"
61 [email protected] " " 61 [email protected] " "
62 PLACEHOLDE[email protected] 62 WILDCARD[email protected]
63 [email protected] "_" 63 [email protected] "_"
64 [email protected] " " 64 [email protected] " "
65 [email protected] "in" 65 [email protected] "in"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast
index 80bda4ba7..0a1b21d6e 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..19 2 [email protected]
3 [email protected] "default" 3 [email protected] "default"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "impl" 5 [email protected] "impl"
@@ -10,7 +10,7 @@ [email protected]
10 [email protected] 10 [email protected]
11 [email protected] "Foo" 11 [email protected] "Foo"
12 [email protected] " " 12 [email protected] " "
13 [email protected] 13 ASSOC_[email protected]
14 [email protected] "{" 14 [email protected] "{"
15 [email protected] "}" 15 [email protected] "}"
16 [email protected] "\n" 16 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast
index 816e49310..32a77ba49 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..24 2 [email protected]
3 [email protected] "const" 3 [email protected] "const"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "unsafe" 5 [email protected] "unsafe"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.rast b/crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.rast
index d48ef865c..f19e9fd52 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..9 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "}" 13 [email protected] "}"
14 [email protected] "\n" 14 [email protected] "\n"
15 FN_DEF@10..25 15 [email protected]
16 [email protected] "fn" 16 [email protected] "fn"
17 [email protected] " " 17 [email protected] " "
18 [email protected] 18 [email protected]
@@ -20,7 +20,7 @@ [email protected]
20 [email protected] 20 [email protected]
21 [email protected] "(" 21 [email protected] "("
22 [email protected] 22 [email protected]
23 BIN[email protected] 23 IDENT[email protected]
24 [email protected] 24 [email protected]
25 [email protected] "x" 25 [email protected] "x"
26 [email protected] ":" 26 [email protected] ":"
@@ -36,7 +36,7 @@ [email protected]
36 [email protected] "{" 36 [email protected] "{"
37 [email protected] "}" 37 [email protected] "}"
38 [email protected] "\n" 38 [email protected] "\n"
39 FN_DEF@26..43 39 [email protected]
40 [email protected] "fn" 40 [email protected] "fn"
41 [email protected] " " 41 [email protected] " "
42 [email protected] 42 [email protected]
@@ -44,7 +44,7 @@ [email protected]
44 [email protected] 44 [email protected]
45 [email protected] "(" 45 [email protected] "("
46 [email protected] 46 [email protected]
47 BIN[email protected] 47 IDENT[email protected]
48 [email protected] 48 [email protected]
49 [email protected] "x" 49 [email protected] "x"
50 [email protected] ":" 50 [email protected] ":"
@@ -62,7 +62,7 @@ [email protected]
62 [email protected] "{" 62 [email protected] "{"
63 [email protected] "}" 63 [email protected] "}"
64 [email protected] "\n" 64 [email protected] "\n"
65 FN_DEF@44..66 65 [email protected]
66 [email protected] "fn" 66 [email protected] "fn"
67 [email protected] " " 67 [email protected] " "
68 [email protected] 68 [email protected]
@@ -70,7 +70,7 @@ [email protected]
70 [email protected] 70 [email protected]
71 [email protected] "(" 71 [email protected] "("
72 [email protected] 72 [email protected]
73 BIN[email protected] 73 IDENT[email protected]
74 [email protected] 74 [email protected]
75 [email protected] "x" 75 [email protected] "x"
76 [email protected] ":" 76 [email protected] ":"
@@ -83,7 +83,7 @@ [email protected]
83 [email protected] "," 83 [email protected] ","
84 [email protected] " " 84 [email protected] " "
85 [email protected] 85 [email protected]
86 BIN[email protected] 86 IDENT[email protected]
87 [email protected] 87 [email protected]
88 [email protected] "y" 88 [email protected] "y"
89 [email protected] ":" 89 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.rast
index e4455cd3e..5c4055e44 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..32 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -15,7 +15,7 @@ [email protected]
15 [email protected] 15 [email protected]
16 [email protected] "for" 16 [email protected] "for"
17 [email protected] " " 17 [email protected] " "
18 BIN[email protected] 18 IDENT[email protected]
19 [email protected] 19 [email protected]
20 [email protected] "x" 20 [email protected] "x"
21 [email protected] " " 21 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast
index 8a8743060..73c94e5d4 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..18 2 [email protected]
3 [email protected] "unsafe" 3 [email protected] "unsafe"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "fn" 5 [email protected] "fn"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast b/crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast
index 9f966ff8a..866e60ed8 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..118 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -20,7 +20,7 @@ [email protected]
20 [email protected] 20 [email protected]
21 [email protected] "S" 21 [email protected] "S"
22 [email protected] " " 22 [email protected] " "
23 RECORD_FIELD_PAT_[email protected] 23 RECORD_PAT_[email protected]
24 [email protected] "{" 24 [email protected] "{"
25 [email protected] "}" 25 [email protected] "}"
26 [email protected] " " 26 [email protected] " "
@@ -40,17 +40,17 @@ [email protected]
40 [email protected] 40 [email protected]
41 [email protected] "S" 41 [email protected] "S"
42 [email protected] " " 42 [email protected] " "
43 RECORD_FIELD_PAT_[email protected] 43 RECORD_PAT_[email protected]
44 [email protected] "{" 44 [email protected] "{"
45 [email protected] " " 45 [email protected] " "
46 RECORD_FIELD_PAT@42..43 46 RECORD_PAT_[email protected]
47 BIN[email protected] 47 IDENT[email protected]
48 [email protected] 48 [email protected]
49 [email protected] "f" 49 [email protected] "f"
50 [email protected] "," 50 [email protected] ","
51 [email protected] " " 51 [email protected] " "
52 RECORD_FIELD_PAT@45..54 52 RECORD_PAT_[email protected]
53 BIN[email protected] 53 IDENT[email protected]
54 [email protected] "ref" 54 [email protected] "ref"
55 [email protected] " " 55 [email protected] " "
56 [email protected] "mut" 56 [email protected] "mut"
@@ -76,15 +76,15 @@ [email protected]
76 [email protected] 76 [email protected]
77 [email protected] "S" 77 [email protected] "S"
78 [email protected] " " 78 [email protected] " "
79 RECORD_FIELD_PAT_[email protected] 79 RECORD_PAT_[email protected]
80 [email protected] "{" 80 [email protected] "{"
81 [email protected] " " 81 [email protected] " "
82 RECORD_FIELD_PAT@75..79 82 RECORD_PAT_[email protected]
83 [email protected] 83 [email protected]
84 [email protected] "h" 84 [email protected] "h"
85 [email protected] ":" 85 [email protected] ":"
86 [email protected] " " 86 [email protected] " "
87 PLACEHOLDE[email protected] 87 WILDCARD[email protected]
88 [email protected] "_" 88 [email protected] "_"
89 [email protected] "," 89 [email protected] ","
90 [email protected] " " 90 [email protected] " "
@@ -107,15 +107,15 @@ [email protected]
107 [email protected] 107 [email protected]
108 [email protected] "S" 108 [email protected] "S"
109 [email protected] " " 109 [email protected] " "
110 RECORD_FIELD_PAT_[email protected] 110 RECORD_PAT_[email protected]
111 [email protected] "{" 111 [email protected] "{"
112 [email protected] " " 112 [email protected] " "
113 RECORD_FIELD_PAT@103..107 113 RECORD_PAT_[email protected]
114 [email protected] 114 [email protected]
115 [email protected] "h" 115 [email protected] "h"
116 [email protected] ":" 116 [email protected] ":"
117 [email protected] " " 117 [email protected] " "
118 PLACEHOLDE[email protected] 118 WILDCARD[email protected]
119 [email protected] "_" 119 [email protected] "_"
120 [email protected] "," 120 [email protected] ","
121 [email protected] " " 121 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.rast
index 9b3bef04e..c4c0a0568 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..54 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rast b/crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rast
index e3c4cfeb3..1244a5031 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..28 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] 12 [email protected]
13 [email protected] 13 [email protected]
14 [email protected] "Box" 14 [email protected] "Box"
15 TYP[email protected] 15 GENERIC[email protected]
16 [email protected] "<" 16 [email protected] "<"
17 [email protected] 17 [email protected]
18 [email protected] 18 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast
index e64717152..9b8381619 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..133 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 [email protected] 14 [email protected]
15 LAMBDA[email protected] 15 CLOSURE[email protected]
16 [email protected] 16 [email protected]
17 [email protected] "|" 17 [email protected] "|"
18 [email protected] "|" 18 [email protected] "|"
@@ -23,7 +23,7 @@ [email protected]
23 [email protected] ";" 23 [email protected] ";"
24 [email protected] "\n " 24 [email protected] "\n "
25 [email protected] 25 [email protected]
26 LAMBDA[email protected] 26 CLOSURE[email protected]
27 [email protected] 27 [email protected]
28 [email protected] "|" 28 [email protected] "|"
29 [email protected] "|" 29 [email protected] "|"
@@ -47,11 +47,11 @@ [email protected]
47 [email protected] ";" 47 [email protected] ";"
48 [email protected] "\n " 48 [email protected] "\n "
49 [email protected] 49 [email protected]
50 LAMBDA[email protected] 50 CLOSURE[email protected]
51 [email protected] 51 [email protected]
52 [email protected] "|" 52 [email protected] "|"
53 [email protected] 53 [email protected]
54 BIN[email protected] 54 IDENT[email protected]
55 [email protected] 55 [email protected]
56 [email protected] "x" 56 [email protected] "x"
57 [email protected] "|" 57 [email protected] "|"
@@ -64,13 +64,13 @@ [email protected]
64 [email protected] ";" 64 [email protected] ";"
65 [email protected] "\n " 65 [email protected] "\n "
66 [email protected] 66 [email protected]
67 LAMBDA[email protected] 67 CLOSURE[email protected]
68 [email protected] "move" 68 [email protected] "move"
69 [email protected] " " 69 [email protected] " "
70 [email protected] 70 [email protected]
71 [email protected] "|" 71 [email protected] "|"
72 [email protected] 72 [email protected]
73 BIN[email protected] 73 IDENT[email protected]
74 [email protected] 74 [email protected]
75 [email protected] "x" 75 [email protected] "x"
76 [email protected] ":" 76 [email protected] ":"
@@ -91,7 +91,7 @@ [email protected]
91 [email protected] ";" 91 [email protected] ";"
92 [email protected] "\n " 92 [email protected] "\n "
93 [email protected] 93 [email protected]
94 LAMBDA[email protected] 94 CLOSURE[email protected]
95 [email protected] "async" 95 [email protected] "async"
96 [email protected] " " 96 [email protected] " "
97 [email protected] 97 [email protected]
@@ -104,7 +104,7 @@ [email protected]
104 [email protected] ";" 104 [email protected] ";"
105 [email protected] "\n " 105 [email protected] "\n "
106 [email protected] 106 [email protected]
107 LAMBDA[email protected] 107 CLOSURE[email protected]
108 [email protected] "move" 108 [email protected] "move"
109 [email protected] " " 109 [email protected] " "
110 [email protected] 110 [email protected]
@@ -117,7 +117,7 @@ [email protected]
117 [email protected] ";" 117 [email protected] ";"
118 [email protected] "\n " 118 [email protected] "\n "
119 [email protected] 119 [email protected]
120 LAMBDA[email protected] 120 CLOSURE[email protected]
121 [email protected] "async" 121 [email protected] "async"
122 [email protected] " " 122 [email protected] " "
123 [email protected] "move" 123 [email protected] "move"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.rast
index 98963dc62..be8365e05 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..48 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -36,7 +36,7 @@ [email protected]
36 [email protected] "." 36 [email protected] "."
37 [email protected] 37 [email protected]
38 [email protected] "bar" 38 [email protected] "bar"
39 TYP[email protected] 39 GENERIC[email protected]
40 [email protected] "::" 40 [email protected] "::"
41 [email protected] "<" 41 [email protected] "<"
42 [email protected] 42 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.rast
index ea603e2c9..ca7e4a5c3 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..39 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0109_label.rast b/crates/ra_syntax/test_data/parser/inline/ok/0109_label.rast
index 30ff96a7c..c9588025c 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0109_label.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0109_label.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..73 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -46,7 +46,7 @@ [email protected]
46 [email protected] " " 46 [email protected] " "
47 [email protected] "for" 47 [email protected] "for"
48 [email protected] " " 48 [email protected] " "
49 BIN[email protected] 49 IDENT[email protected]
50 [email protected] 50 [email protected]
51 [email protected] "x" 51 [email protected] "x"
52 [email protected] " " 52 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast b/crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast
index 015a7a7d2..82028096f 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..17 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] " " 12 [email protected] " "
13 [email protected] "// Rust 2018 - All fl ..." 13 [email protected] "// Rust 2018 - All fl ..."
14 [email protected] "\n" 14 [email protected] "\n"
15 USE_ITEM@46..61 15 [email protected]
16 [email protected] "use" 16 [email protected] "use"
17 [email protected] " " 17 [email protected] " "
18 [email protected] 18 [email protected]
@@ -24,7 +24,7 @@ [email protected]
24 [email protected] " " 24 [email protected] " "
25 [email protected] "// Rust 2018 - Anchor ..." 25 [email protected] "// Rust 2018 - Anchor ..."
26 [email protected] "\n" 26 [email protected] "\n"
27 USE_ITEM@92..124 27 [email protected]
28 [email protected] "use" 28 [email protected] "use"
29 [email protected] " " 29 [email protected] " "
30 [email protected] 30 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rast b/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rast
index b58f40ac1..b82ed0230 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..93 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -16,17 +16,17 @@ [email protected]
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 [email protected]
18 [email protected] "(" 18 [email protected] "("
19 BIN[email protected] 19 IDENT[email protected]
20 [email protected] 20 [email protected]
21 [email protected] "a" 21 [email protected] "a"
22 [email protected] "," 22 [email protected] ","
23 [email protected] " " 23 [email protected] " "
24 BIN[email protected] 24 IDENT[email protected]
25 [email protected] 25 [email protected]
26 [email protected] "b" 26 [email protected] "b"
27 [email protected] "," 27 [email protected] ","
28 [email protected] " " 28 [email protected] " "
29 DOT_DOT_[email protected] 29 RES[email protected]
30 [email protected] ".." 30 [email protected] ".."
31 [email protected] ")" 31 [email protected] ")"
32 [email protected] " " 32 [email protected] " "
@@ -42,7 +42,7 @@ [email protected]
42 [email protected] " " 42 [email protected] " "
43 [email protected] 43 [email protected]
44 [email protected] "(" 44 [email protected] "("
45 BIN[email protected] 45 IDENT[email protected]
46 [email protected] 46 [email protected]
47 [email protected] "a" 47 [email protected] "a"
48 [email protected] "," 48 [email protected] ","
@@ -60,7 +60,7 @@ [email protected]
60 [email protected] " " 60 [email protected] " "
61 [email protected] 61 [email protected]
62 [email protected] "(" 62 [email protected] "("
63 DOT_DOT_[email protected] 63 RES[email protected]
64 [email protected] ".." 64 [email protected] ".."
65 [email protected] ")" 65 [email protected] ")"
66 [email protected] " " 66 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.rast b/crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.rast
index b67714c17..7b9a498c8 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..145 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 BIN[email protected] 17 IDENT[email protected]
18 [email protected] 18 [email protected]
19 [email protected] "a" 19 [email protected] "a"
20 [email protected] " " 20 [email protected] " "
@@ -28,7 +28,7 @@ [email protected]
28 [email protected] 28 [email protected]
29 [email protected] "let" 29 [email protected] "let"
30 [email protected] " " 30 [email protected] " "
31 BIN[email protected] 31 IDENT[email protected]
32 [email protected] "mut" 32 [email protected] "mut"
33 [email protected] " " 33 [email protected] " "
34 [email protected] 34 [email protected]
@@ -44,7 +44,7 @@ [email protected]
44 [email protected] 44 [email protected]
45 [email protected] "let" 45 [email protected] "let"
46 [email protected] " " 46 [email protected] " "
47 BIN[email protected] 47 IDENT[email protected]
48 [email protected] "ref" 48 [email protected] "ref"
49 [email protected] " " 49 [email protected] " "
50 [email protected] 50 [email protected]
@@ -60,7 +60,7 @@ [email protected]
60 [email protected] 60 [email protected]
61 [email protected] "let" 61 [email protected] "let"
62 [email protected] " " 62 [email protected] " "
63 BIN[email protected] 63 IDENT[email protected]
64 [email protected] "ref" 64 [email protected] "ref"
65 [email protected] " " 65 [email protected] " "
66 [email protected] "mut" 66 [email protected] "mut"
@@ -78,13 +78,13 @@ [email protected]
78 [email protected] 78 [email protected]
79 [email protected] "let" 79 [email protected] "let"
80 [email protected] " " 80 [email protected] " "
81 BIN[email protected] 81 IDENT[email protected]
82 [email protected] 82 [email protected]
83 [email protected] "e" 83 [email protected] "e"
84 [email protected] " " 84 [email protected] " "
85 [email protected] "@" 85 [email protected] "@"
86 [email protected] " " 86 [email protected] " "
87 PLACEHOLDE[email protected] 87 WILDCARD[email protected]
88 [email protected] "_" 88 [email protected] "_"
89 [email protected] " " 89 [email protected] " "
90 [email protected] "=" 90 [email protected] "="
@@ -97,7 +97,7 @@ [email protected]
97 [email protected] 97 [email protected]
98 [email protected] "let" 98 [email protected] "let"
99 [email protected] " " 99 [email protected] " "
100 BIN[email protected] 100 IDENT[email protected]
101 [email protected] "ref" 101 [email protected] "ref"
102 [email protected] " " 102 [email protected] " "
103 [email protected] "mut" 103 [email protected] "mut"
@@ -107,13 +107,13 @@ [email protected]
107 [email protected] " " 107 [email protected] " "
108 [email protected] "@" 108 [email protected] "@"
109 [email protected] " " 109 [email protected] " "
110 BIN[email protected] 110 IDENT[email protected]
111 [email protected] 111 [email protected]
112 [email protected] "g" 112 [email protected] "g"
113 [email protected] " " 113 [email protected] " "
114 [email protected] "@" 114 [email protected] "@"
115 [email protected] " " 115 [email protected] " "
116 PLACEHOLDE[email protected] 116 WILDCARD[email protected]
117 [email protected] "_" 117 [email protected] "_"
118 [email protected] " " 118 [email protected] " "
119 [email protected] "=" 119 [email protected] "="
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.rast
index 5de480da9..d761c1c68 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..49 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rast b/crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rast
index 01d717d6b..0e1594dc4 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rast
@@ -1,18 +1,18 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..33 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "Test" 6 [email protected] "Test"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
11 [email protected] "T" 11 [email protected] "T"
12 [email protected] ">" 12 [email protected] ">"
13 TUPLE_FIELD_DEF_[email protected] 13 [email protected]
14 [email protected] "(" 14 [email protected] "("
15 TUPLE_FIELD_DEF@15..16 15 [email protected]
16 [email protected] 16 [email protected]
17 [email protected] 17 [email protected]
18 [email protected] 18 [email protected]
@@ -40,20 +40,20 @@ [email protected]
40 [email protected] "Clone" 40 [email protected] "Clone"
41 [email protected] ";" 41 [email protected] ";"
42 [email protected] "\n" 42 [email protected] "\n"
43 STRUCT_DEF@34..52 43 [email protected]
44 [email protected] "struct" 44 [email protected] "struct"
45 [email protected] " " 45 [email protected] " "
46 [email protected] 46 [email protected]
47 [email protected] "Test" 47 [email protected] "Test"
48 TYP[email protected] 48 GENERIC[email protected]
49 [email protected] "<" 49 [email protected] "<"
50 [email protected] 50 [email protected]
51 [email protected] 51 [email protected]
52 [email protected] "T" 52 [email protected] "T"
53 [email protected] ">" 53 [email protected] ">"
54 TUPLE_FIELD_DEF_[email protected] 54 [email protected]
55 [email protected] "(" 55 [email protected] "("
56 TUPLE_FIELD_DEF@49..50 56 [email protected]
57 [email protected] 57 [email protected]
58 [email protected] 58 [email protected]
59 [email protected] 59 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast b/crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast
index 3c0ef9005..4d09c9f50 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast
@@ -1,14 +1,14 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..59 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "S" 6 [email protected] "S"
7 [email protected] " " 7 [email protected] " "
8 TUPLE_FIELD_DEF_[email protected] 8 [email protected]
9 [email protected] "(" 9 [email protected] "("
10 [email protected] "\n " 10 [email protected] "\n "
11 TUPLE_FIELD_DEF@15..55 11 [email protected]
12 [email protected] 12 [email protected]
13 [email protected] "#" 13 [email protected] "#"
14 [email protected] "[" 14 [email protected] "["
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.rast
index ddfcf974e..f3d4ad72c 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..16 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -18,7 +18,7 @@ [email protected]
18 [email protected] ")" 18 [email protected] ")"
19 [email protected] ";" 19 [email protected] ";"
20 [email protected] "\n" 20 [email protected] "\n"
21 TYPE_ALIAS_DEF@17..40 21 [email protected]
22 [email protected] "type" 22 [email protected] "type"
23 [email protected] " " 23 [email protected] " "
24 [email protected] 24 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast b/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast
index a65a5c85f..141a7b203 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast
@@ -1,14 +1,14 @@
1[email protected] 1[email protected]
2 ENUM_DEF@0..8 2 [email protected]
3 [email protected] "enum" 3 [email protected] "enum"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "F" 6 [email protected] "F"
7 ENUM_[email protected] 7 [email protected]
8 [email protected] "{" 8 [email protected] "{"
9 [email protected] "}" 9 [email protected] "}"
10 [email protected] "\n" 10 [email protected] "\n"
11 IMPL_DEF@9..93 11 [email protected]
12 [email protected] "impl" 12 [email protected] "impl"
13 [email protected] " " 13 [email protected] " "
14 [email protected] 14 [email protected]
@@ -17,7 +17,7 @@ [email protected]
17 [email protected] 17 [email protected]
18 [email protected] "F" 18 [email protected] "F"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 ASSOC_[email protected]
21 [email protected] "{" 21 [email protected] "{"
22 [email protected] "\n " 22 [email protected] "\n "
23 [email protected] "//! This is a doc com ..." 23 [email protected] "//! This is a doc com ..."
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.rast b/crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.rast
index e152c6b6c..0cf4eb0a5 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..57 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -22,7 +22,7 @@ [email protected]
22 [email protected] "{" 22 [email protected] "{"
23 [email protected] "\n " 23 [email protected] "\n "
24 [email protected] 24 [email protected]
25 PLACEHOLDE[email protected] 25 WILDCARD[email protected]
26 [email protected] "_" 26 [email protected] "_"
27 [email protected] " " 27 [email protected] " "
28 [email protected] 28 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast b/crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast
index b283ab804..ec7a00f1d 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..138 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -64,7 +64,7 @@ [email protected]
64 [email protected] "]" 64 [email protected] "]"
65 [email protected] "\n " 65 [email protected] "\n "
66 [email protected] 66 [email protected]
67 PLACEHOLDE[email protected] 67 WILDCARD[email protected]
68 [email protected] "_" 68 [email protected] "_"
69 [email protected] " " 69 [email protected] " "
70 [email protected] "=>" 70 [email protected] "=>"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast b/crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast
index 9d5470914..97924da05 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..258 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -39,7 +39,7 @@ [email protected]
39 [email protected] ")" 39 [email protected] ")"
40 [email protected] "]" 40 [email protected] "]"
41 [email protected] "\n " 41 [email protected] "\n "
42 PLACEHOLDE[email protected] 42 WILDCARD[email protected]
43 [email protected] "_" 43 [email protected] "_"
44 [email protected] " " 44 [email protected] " "
45 [email protected] "=>" 45 [email protected] "=>"
@@ -67,7 +67,7 @@ [email protected]
67 [email protected] ")" 67 [email protected] ")"
68 [email protected] "]" 68 [email protected] "]"
69 [email protected] "\n " 69 [email protected] "\n "
70 PLACEHOLDE[email protected] 70 WILDCARD[email protected]
71 [email protected] "_" 71 [email protected] "_"
72 [email protected] " " 72 [email protected] " "
73 [email protected] "=>" 73 [email protected] "=>"
@@ -129,7 +129,7 @@ [email protected]
129 [email protected] ")" 129 [email protected] ")"
130 [email protected] "]" 130 [email protected] "]"
131 [email protected] "\n " 131 [email protected] "\n "
132 PLACEHOLDE[email protected] 132 WILDCARD[email protected]
133 [email protected] "_" 133 [email protected] "_"
134 [email protected] " " 134 [email protected] " "
135 [email protected] "=>" 135 [email protected] "=>"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast b/crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast
index ada2fc54e..570b95205 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 FN_DEF@0..63 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "foo" 6 [email protected] "foo"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
@@ -43,11 +43,11 @@ [email protected]
43 [email protected] 43 [email protected]
44 [email protected] "(" 44 [email protected] "("
45 [email protected] 45 [email protected]
46 PLACEHOLDE[email protected] 46 WILDCARD[email protected]
47 [email protected] "_" 47 [email protected] "_"
48 [email protected] ":" 48 [email protected] ":"
49 [email protected] " " 49 [email protected] " "
50 REFERENCE[email protected] 50 [email protected]
51 [email protected] "&" 51 [email protected] "&"
52 [email protected] "\'a" 52 [email protected] "\'a"
53 [email protected] " " 53 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.rast b/crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.rast
index b3a33c14d..7cdec6634 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.rast
@@ -8,7 +8,7 @@ [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] " " 10 [email protected] " "
11 FN_DEF@13..54 11 [email protected]
12 [email protected] "fn" 12 [email protected] "fn"
13 [email protected] " " 13 [email protected] " "
14 [email protected] 14 [email protected]
@@ -16,12 +16,12 @@ [email protected]
16 [email protected] 16 [email protected]
17 [email protected] "(" 17 [email protected] "("
18 [email protected] 18 [email protected]
19 BIN[email protected] 19 IDENT[email protected]
20 [email protected] 20 [email protected]
21 [email protected] "format" 21 [email protected] "format"
22 [email protected] ":" 22 [email protected] ":"
23 [email protected] " " 23 [email protected] " "
24 POINTE[email protected] 24 [email protected]
25 [email protected] "*" 25 [email protected] "*"
26 [email protected] "const" 26 [email protected] "const"
27 [email protected] " " 27 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast
index 6178dfe59..a7df188bd 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..17 2 [email protected]
3 [email protected] "async" 3 [email protected] "async"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "fn" 5 [email protected] "fn"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast b/crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast
index ced59b7c1..aa4d7a784 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..26 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast
index 97611f7f3..54ea2c7c6 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..45 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -11,16 +11,16 @@ [email protected]
11 [email protected] 11 [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 RECORD_LIT@16..43 14 RECORD_EXPR@16..43
15 [email protected] 15 [email protected]
16 [email protected] 16 [email protected]
17 [email protected] 17 [email protected]
18 [email protected] "S" 18 [email protected] "S"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 RECORD_EXPR_[email protected]
21 [email protected] "{" 21 [email protected] "{"
22 [email protected] " " 22 [email protected] " "
23 [email protected] 23 RECORD_EXPR_[email protected]
24 [email protected] 24 [email protected]
25 [email protected] "#" 25 [email protected] "#"
26 [email protected] "[" 26 [email protected] "["
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast b/crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast
index 09221fc54..0342e64f3 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..81 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast b/crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast
index 93cc41533..3b46e5b47 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..46 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast b/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast
index 0901f2348..98a20f36d 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..24 2 [email protected]
3 [email protected] "async" 3 [email protected] "async"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "unsafe" 5 [email protected] "unsafe"
@@ -16,7 +16,7 @@ [email protected]
16 [email protected] "{" 16 [email protected] "{"
17 [email protected] "}" 17 [email protected] "}"
18 [email protected] "\n" 18 [email protected] "\n"
19 FN_DEF@25..49 19 [email protected]
20 [email protected] "const" 20 [email protected] "const"
21 [email protected] " " 21 [email protected] " "
22 [email protected] "unsafe" 22 [email protected] "unsafe"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.rast b/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.rast
index 28291afc2..e283966ca 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..32 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast b/crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast
index bb94a05c6..4c07cefa6 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..134 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 BIN[email protected] 17 IDENT[email protected]
18 [email protected] 18 [email protected]
19 [email protected] "a" 19 [email protected] "a"
20 [email protected] ";" 20 [email protected] ";"
@@ -22,7 +22,7 @@ [email protected]
22 [email protected] 22 [email protected]
23 [email protected] "let" 23 [email protected] "let"
24 [email protected] " " 24 [email protected] " "
25 BIN[email protected] 25 IDENT[email protected]
26 [email protected] 26 [email protected]
27 [email protected] "b" 27 [email protected] "b"
28 [email protected] ":" 28 [email protected] ":"
@@ -37,7 +37,7 @@ [email protected]
37 [email protected] 37 [email protected]
38 [email protected] "let" 38 [email protected] "let"
39 [email protected] " " 39 [email protected] " "
40 BIN[email protected] 40 IDENT[email protected]
41 [email protected] 41 [email protected]
42 [email protected] "c" 42 [email protected] "c"
43 [email protected] " " 43 [email protected] " "
@@ -50,7 +50,7 @@ [email protected]
50 [email protected] 50 [email protected]
51 [email protected] "let" 51 [email protected] "let"
52 [email protected] " " 52 [email protected] " "
53 BIN[email protected] 53 IDENT[email protected]
54 [email protected] 54 [email protected]
55 [email protected] "d" 55 [email protected] "d"
56 [email protected] ":" 56 [email protected] ":"
@@ -70,7 +70,7 @@ [email protected]
70 [email protected] 70 [email protected]
71 [email protected] "let" 71 [email protected] "let"
72 [email protected] " " 72 [email protected] " "
73 BIN[email protected] 73 IDENT[email protected]
74 [email protected] 74 [email protected]
75 [email protected] "e" 75 [email protected] "e"
76 [email protected] ":" 76 [email protected] ":"
@@ -82,7 +82,7 @@ [email protected]
82 [email protected] 82 [email protected]
83 [email protected] "let" 83 [email protected] "let"
84 [email protected] " " 84 [email protected] " "
85 PLACEHOLDE[email protected] 85 WILDCARD[email protected]
86 [email protected] "_" 86 [email protected] "_"
87 [email protected] ":" 87 [email protected] ":"
88 [email protected] " " 88 [email protected] " "
@@ -99,13 +99,13 @@ [email protected]
99 [email protected] 99 [email protected]
100 [email protected] "let" 100 [email protected] "let"
101 [email protected] " " 101 [email protected] " "
102 BIN[email protected] 102 IDENT[email protected]
103 [email protected] 103 [email protected]
104 [email protected] "f" 104 [email protected] "f"
105 [email protected] " " 105 [email protected] " "
106 [email protected] "=" 106 [email protected] "="
107 [email protected] " " 107 [email protected] " "
108 LAMBDA[email protected] 108 CLOSURE[email protected]
109 [email protected] 109 [email protected]
110 [email protected] "#" 110 [email protected] "#"
111 [email protected] "[" 111 [email protected] "["
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.rast
index 8f2f144c7..ffdffe2f8 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..32 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 PLACEHOLDE[email protected] 17 WILDCARD[email protected]
18 [email protected] "_" 18 [email protected] "_"
19 [email protected] " " 19 [email protected] " "
20 [email protected] "=" 20 [email protected] "="
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.rast
index 4a1c2b3a4..d47071a91 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..36 2 [email protected]
3 [email protected] "existential" 3 [email protected] "existential"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "type" 5 [email protected] "type"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.rast
index 87ac42748..c55038247 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..105 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 BIN[email protected] 17 IDENT[email protected]
18 [email protected] 18 [email protected]
19 [email protected] "x" 19 [email protected] "x"
20 [email protected] " " 20 [email protected] " "
@@ -30,7 +30,7 @@ [email protected]
30 [email protected] 30 [email protected]
31 [email protected] "let" 31 [email protected] "let"
32 [email protected] " " 32 [email protected] " "
33 BIN[email protected] 33 IDENT[email protected]
34 [email protected] 34 [email protected]
35 [email protected] "y" 35 [email protected] "y"
36 [email protected] " " 36 [email protected] " "
@@ -56,7 +56,7 @@ [email protected]
56 [email protected] 56 [email protected]
57 [email protected] "let" 57 [email protected] "let"
58 [email protected] " " 58 [email protected] " "
59 BIN[email protected] 59 IDENT[email protected]
60 [email protected] 60 [email protected]
61 [email protected] "z" 61 [email protected] "z"
62 [email protected] " " 62 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast
index 00ce5ecf0..b8d26a53a 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..68 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -16,10 +16,10 @@ [email protected]
16 [email protected] 16 [email protected]
17 [email protected] "Foo" 17 [email protected] "Foo"
18 [email protected] " " 18 [email protected] " "
19 [email protected] 19 ASSOC_[email protected]
20 [email protected] "{" 20 [email protected] "{"
21 [email protected] "\n " 21 [email protected] "\n "
22 TYPE_ALIAS_DEF@21..42 22 [email protected]
23 [email protected] "default" 23 [email protected] "default"
24 [email protected] " " 24 [email protected] " "
25 [email protected] "type" 25 [email protected] "type"
@@ -36,7 +36,7 @@ [email protected]
36 [email protected] "Bar" 36 [email protected] "Bar"
37 [email protected] ";" 37 [email protected] ";"
38 [email protected] "\n " 38 [email protected] "\n "
39 FN_DEF@47..66 39 [email protected]
40 [email protected] "default" 40 [email protected] "default"
41 [email protected] " " 41 [email protected] " "
42 [email protected] "fn" 42 [email protected] "fn"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast b/crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast
index b330a0932..429a0506e 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..110 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -11,21 +11,21 @@ [email protected]
11 [email protected] 11 [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 ENUM_DEF@27..75 14 [email protected]
15 [email protected] "enum" 15 [email protected] "enum"
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 [email protected]
18 [email protected] "LocalEnum" 18 [email protected] "LocalEnum"
19 [email protected] " " 19 [email protected] " "
20 ENUM_[email protected] 20 [email protected]
21 [email protected] "{" 21 [email protected] "{"
22 [email protected] "\n " 22 [email protected] "\n "
23 ENUM_[email protected] 23 [email protected]
24 [email protected] 24 [email protected]
25 [email protected] "One" 25 [email protected] "One"
26 [email protected] "," 26 [email protected] ","
27 [email protected] "\n " 27 [email protected] "\n "
28 ENUM_[email protected] 28 [email protected]
29 [email protected] 29 [email protected]
30 [email protected] "Two" 30 [email protected] "Two"
31 [email protected] "," 31 [email protected] ","
@@ -33,7 +33,7 @@ [email protected]
33 [email protected] "}" 33 [email protected] "}"
34 [email protected] ";" 34 [email protected] ";"
35 [email protected] "\n " 35 [email protected] "\n "
36 FN_DEF@81..90 36 [email protected]
37 [email protected] "fn" 37 [email protected] "fn"
38 [email protected] " " 38 [email protected] " "
39 [email protected] 39 [email protected]
@@ -47,13 +47,13 @@ [email protected]
47 [email protected] "}" 47 [email protected] "}"
48 [email protected] ";" 48 [email protected] ";"
49 [email protected] "\n " 49 [email protected] "\n "
50 STRUCT_DEF@96..107 50 [email protected]
51 [email protected] "struct" 51 [email protected] "struct"
52 [email protected] " " 52 [email protected] " "
53 [email protected] 53 [email protected]
54 [email protected] "S" 54 [email protected] "S"
55 [email protected] " " 55 [email protected] " "
56 RECORD_FIELD_DEF_[email protected] 56 [email protected]
57 [email protected] "{" 57 [email protected] "{"
58 [email protected] "}" 58 [email protected] "}"
59 [email protected] ";" 59 [email protected] ";"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast
index 8e8d9e992..923effe38 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..66 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rast b/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rast
index c457851c9..3870ec135 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 FN_DEF@0..58 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "print_all" 6 [email protected] "print_all"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
@@ -18,7 +18,7 @@ [email protected]
18 [email protected] 18 [email protected]
19 [email protected] 19 [email protected]
20 [email protected] "Iterator" 20 [email protected] "Iterator"
21 TYP[email protected] 21 GENERIC[email protected]
22 [email protected] "<" 22 [email protected] "<"
23 [email protected] 23 [email protected]
24 [email protected] 24 [email protected]
@@ -37,7 +37,7 @@ [email protected]
37 [email protected] 37 [email protected]
38 [email protected] "(" 38 [email protected] "("
39 [email protected] 39 [email protected]
40 BIN[email protected] 40 IDENT[email protected]
41 [email protected] 41 [email protected]
42 [email protected] "printables" 42 [email protected] "printables"
43 [email protected] ":" 43 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast b/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast
index ea325831e..f7c0e0ab0 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..51 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 BIN[email protected] 17 IDENT[email protected]
18 [email protected] "mut" 18 [email protected] "mut"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 [email protected]
@@ -22,14 +22,14 @@ [email protected]
22 [email protected] " " 22 [email protected] " "
23 [email protected] "=" 23 [email protected] "="
24 [email protected] " " 24 [email protected] " "
25 RECORD_LIT@26..33 25 RECORD_EXPR@26..33
26 [email protected] 26 [email protected]
27 [email protected] 27 [email protected]
28 [email protected] 28 [email protected]
29 [email protected] "F" 29 [email protected] "F"
30 [email protected] 30 RECORD_EXPR_[email protected]
31 [email protected] "{" 31 [email protected] "{"
32 [email protected] 32 RECORD_EXPR_[email protected]
33 [email protected] 33 [email protected]
34 [email protected] "x" 34 [email protected] "x"
35 [email protected] ":" 35 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast
index 9135de9df..6403ff8d5 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..25 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast b/crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast
index 14610a0a2..495e4c51b 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..27 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -16,7 +16,7 @@ [email protected]
16 [email protected] "]" 16 [email protected] "]"
17 [email protected] " " 17 [email protected] " "
18 [email protected] 18 [email protected]
19 BIN[email protected] 19 IDENT[email protected]
20 [email protected] 20 [email protected]
21 [email protected] "pat" 21 [email protected] "pat"
22 [email protected] ":" 22 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rast b/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rast
index e6be8b7e4..36e448c94 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..50 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "for" 15 [email protected] "for"
16 [email protected] " " 16 [email protected] " "
17 BIN[email protected] 17 IDENT[email protected]
18 [email protected] 18 [email protected]
19 [email protected] "x" 19 [email protected] "x"
20 [email protected] " " 20 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.rast b/crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.rast
index 57fba5fd5..65887b962 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..117 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -17,7 +17,7 @@ [email protected]
17 [email protected] 17 [email protected]
18 [email protected] "box" 18 [email protected] "box"
19 [email protected] " " 19 [email protected] " "
20 BIN[email protected] 20 IDENT[email protected]
21 [email protected] 21 [email protected]
22 [email protected] "i" 22 [email protected] "i"
23 [email protected] " " 23 [email protected] " "
@@ -40,19 +40,19 @@ [email protected]
40 [email protected] 40 [email protected]
41 [email protected] "Outer" 41 [email protected] "Outer"
42 [email protected] " " 42 [email protected] " "
43 RECORD_FIELD_PAT_[email protected] 43 RECORD_PAT_[email protected]
44 [email protected] "{" 44 [email protected] "{"
45 [email protected] " " 45 [email protected] " "
46 RECORD_FIELD_PAT@52..57 46 RECORD_PAT_[email protected]
47 [email protected] 47 [email protected]
48 [email protected] "box" 48 [email protected] "box"
49 [email protected] " " 49 [email protected] " "
50 BIN[email protected] 50 IDENT[email protected]
51 [email protected] 51 [email protected]
52 [email protected] "i" 52 [email protected] "i"
53 [email protected] "," 53 [email protected] ","
54 [email protected] " " 54 [email protected] " "
55 RECORD_FIELD_PAT@59..79 55 RECORD_PAT_[email protected]
56 [email protected] 56 [email protected]
57 [email protected] "j" 57 [email protected] "j"
58 [email protected] ":" 58 [email protected] ":"
@@ -71,7 +71,7 @@ [email protected]
71 [email protected] " " 71 [email protected] " "
72 [email protected] 72 [email protected]
73 [email protected] "&" 73 [email protected] "&"
74 BIN[email protected] 74 IDENT[email protected]
75 [email protected] 75 [email protected]
76 [email protected] "x" 76 [email protected] "x"
77 [email protected] ")" 77 [email protected] ")"
@@ -91,7 +91,7 @@ [email protected]
91 [email protected] 91 [email protected]
92 [email protected] "box" 92 [email protected] "box"
93 [email protected] " " 93 [email protected] " "
94 BIN[email protected] 94 IDENT[email protected]
95 [email protected] "ref" 95 [email protected] "ref"
96 [email protected] " " 96 [email protected] " "
97 [email protected] "mut" 97 [email protected] "mut"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rast b/crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rast
index 8d8b9597b..8a5bde0b6 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..554 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 DOT_DOT_[email protected] 17 RES[email protected]
18 [email protected] ".." 18 [email protected] ".."
19 [email protected] " " 19 [email protected] " "
20 [email protected] "=" 20 [email protected] "="
@@ -35,12 +35,12 @@ [email protected]
35 [email protected] " " 35 [email protected] " "
36 [email protected] 36 [email protected]
37 [email protected] "(" 37 [email protected] "("
38 BIN[email protected] 38 IDENT[email protected]
39 [email protected] 39 [email protected]
40 [email protected] "a" 40 [email protected] "a"
41 [email protected] "," 41 [email protected] ","
42 [email protected] " " 42 [email protected] " "
43 DOT_DOT_[email protected] 43 RES[email protected]
44 [email protected] ".." 44 [email protected] ".."
45 [email protected] ")" 45 [email protected] ")"
46 [email protected] " " 46 [email protected] " "
@@ -56,12 +56,12 @@ [email protected]
56 [email protected] " " 56 [email protected] " "
57 [email protected] 57 [email protected]
58 [email protected] "(" 58 [email protected] "("
59 BIN[email protected] 59 IDENT[email protected]
60 [email protected] 60 [email protected]
61 [email protected] "a" 61 [email protected] "a"
62 [email protected] "," 62 [email protected] ","
63 [email protected] " " 63 [email protected] " "
64 DOT_DOT_[email protected] 64 RES[email protected]
65 [email protected] ".." 65 [email protected] ".."
66 [email protected] "," 66 [email protected] ","
67 [email protected] ")" 67 [email protected] ")"
@@ -82,12 +82,12 @@ [email protected]
82 [email protected] 82 [email protected]
83 [email protected] "Tuple" 83 [email protected] "Tuple"
84 [email protected] "(" 84 [email protected] "("
85 BIN[email protected] 85 IDENT[email protected]
86 [email protected] 86 [email protected]
87 [email protected] "a" 87 [email protected] "a"
88 [email protected] "," 88 [email protected] ","
89 [email protected] " " 89 [email protected] " "
90 DOT_DOT_[email protected] 90 RES[email protected]
91 [email protected] ".." 91 [email protected] ".."
92 [email protected] ")" 92 [email protected] ")"
93 [email protected] " " 93 [email protected] " "
@@ -107,12 +107,12 @@ [email protected]
107 [email protected] 107 [email protected]
108 [email protected] "Tuple" 108 [email protected] "Tuple"
109 [email protected] "(" 109 [email protected] "("
110 BIN[email protected] 110 IDENT[email protected]
111 [email protected] 111 [email protected]
112 [email protected] "a" 112 [email protected] "a"
113 [email protected] "," 113 [email protected] ","
114 [email protected] " " 114 [email protected] " "
115 DOT_DOT_[email protected] 115 RES[email protected]
116 [email protected] ".." 116 [email protected] ".."
117 [email protected] "," 117 [email protected] ","
118 [email protected] ")" 118 [email protected] ")"
@@ -129,11 +129,11 @@ [email protected]
129 [email protected] " " 129 [email protected] " "
130 [email protected] 130 [email protected]
131 [email protected] "(" 131 [email protected] "("
132 DOT_DOT_[email protected] 132 RES[email protected]
133 [email protected] ".." 133 [email protected] ".."
134 [email protected] "," 134 [email protected] ","
135 [email protected] " " 135 [email protected] " "
136 DOT_DOT_[email protected] 136 RES[email protected]
137 [email protected] ".." 137 [email protected] ".."
138 [email protected] ")" 138 [email protected] ")"
139 [email protected] " " 139 [email protected] " "
@@ -153,11 +153,11 @@ [email protected]
153 [email protected] 153 [email protected]
154 [email protected] "Tuple" 154 [email protected] "Tuple"
155 [email protected] "(" 155 [email protected] "("
156 DOT_DOT_[email protected] 156 RES[email protected]
157 [email protected] ".." 157 [email protected] ".."
158 [email protected] "," 158 [email protected] ","
159 [email protected] " " 159 [email protected] " "
160 DOT_DOT_[email protected] 160 RES[email protected]
161 [email protected] ".." 161 [email protected] ".."
162 [email protected] ")" 162 [email protected] ")"
163 [email protected] " " 163 [email protected] " "
@@ -173,16 +173,16 @@ [email protected]
173 [email protected] " " 173 [email protected] " "
174 [email protected] 174 [email protected]
175 [email protected] "(" 175 [email protected] "("
176 DOT_DOT_[email protected] 176 RES[email protected]
177 [email protected] ".." 177 [email protected] ".."
178 [email protected] "," 178 [email protected] ","
179 [email protected] " " 179 [email protected] " "
180 BIN[email protected] 180 IDENT[email protected]
181 [email protected] 181 [email protected]
182 [email protected] "a" 182 [email protected] "a"
183 [email protected] "," 183 [email protected] ","
184 [email protected] " " 184 [email protected] " "
185 DOT_DOT_[email protected] 185 RES[email protected]
186 [email protected] ".." 186 [email protected] ".."
187 [email protected] ")" 187 [email protected] ")"
188 [email protected] " " 188 [email protected] " "
@@ -202,16 +202,16 @@ [email protected]
202 [email protected] 202 [email protected]
203 [email protected] "Tuple" 203 [email protected] "Tuple"
204 [email protected] "(" 204 [email protected] "("
205 DOT_DOT_[email protected] 205 RES[email protected]
206 [email protected] ".." 206 [email protected] ".."
207 [email protected] "," 207 [email protected] ","
208 [email protected] " " 208 [email protected] " "
209 BIN[email protected] 209 IDENT[email protected]
210 [email protected] 210 [email protected]
211 [email protected] "a" 211 [email protected] "a"
212 [email protected] "," 212 [email protected] ","
213 [email protected] " " 213 [email protected] " "
214 DOT_DOT_[email protected] 214 RES[email protected]
215 [email protected] ".." 215 [email protected] ".."
216 [email protected] ")" 216 [email protected] ")"
217 [email protected] " " 217 [email protected] " "
@@ -233,7 +233,7 @@ [email protected]
233 [email protected] " " 233 [email protected] " "
234 [email protected] 234 [email protected]
235 [email protected] "[" 235 [email protected] "["
236 DOT_DOT_[email protected] 236 RES[email protected]
237 [email protected] ".." 237 [email protected] ".."
238 [email protected] "]" 238 [email protected] "]"
239 [email protected] " " 239 [email protected] " "
@@ -249,12 +249,12 @@ [email protected]
249 [email protected] " " 249 [email protected] " "
250 [email protected] 250 [email protected]
251 [email protected] "[" 251 [email protected] "["
252 BIN[email protected] 252 IDENT[email protected]
253 [email protected] 253 [email protected]
254 [email protected] "head" 254 [email protected] "head"
255 [email protected] "," 255 [email protected] ","
256 [email protected] " " 256 [email protected] " "
257 DOT_DOT_[email protected] 257 RES[email protected]
258 [email protected] ".." 258 [email protected] ".."
259 [email protected] "]" 259 [email protected] "]"
260 [email protected] " " 260 [email protected] " "
@@ -270,18 +270,18 @@ [email protected]
270 [email protected] " " 270 [email protected] " "
271 [email protected] 271 [email protected]
272 [email protected] "[" 272 [email protected] "["
273 BIN[email protected] 273 IDENT[email protected]
274 [email protected] 274 [email protected]
275 [email protected] "head" 275 [email protected] "head"
276 [email protected] "," 276 [email protected] ","
277 [email protected] " " 277 [email protected] " "
278 BIN[email protected] 278 IDENT[email protected]
279 [email protected] 279 [email protected]
280 [email protected] "tail" 280 [email protected] "tail"
281 [email protected] " " 281 [email protected] " "
282 [email protected] "@" 282 [email protected] "@"
283 [email protected] " " 283 [email protected] " "
284 DOT_DOT_[email protected] 284 RES[email protected]
285 [email protected] ".." 285 [email protected] ".."
286 [email protected] "]" 286 [email protected] "]"
287 [email protected] " " 287 [email protected] " "
@@ -297,16 +297,16 @@ [email protected]
297 [email protected] " " 297 [email protected] " "
298 [email protected] 298 [email protected]
299 [email protected] "[" 299 [email protected] "["
300 BIN[email protected] 300 IDENT[email protected]
301 [email protected] 301 [email protected]
302 [email protected] "head" 302 [email protected] "head"
303 [email protected] "," 303 [email protected] ","
304 [email protected] " " 304 [email protected] " "
305 DOT_DOT_[email protected] 305 RES[email protected]
306 [email protected] ".." 306 [email protected] ".."
307 [email protected] "," 307 [email protected] ","
308 [email protected] " " 308 [email protected] " "
309 BIN[email protected] 309 IDENT[email protected]
310 [email protected] 310 [email protected]
311 [email protected] "cons" 311 [email protected] "cons"
312 [email protected] "]" 312 [email protected] "]"
@@ -323,22 +323,22 @@ [email protected]
323 [email protected] " " 323 [email protected] " "
324 [email protected] 324 [email protected]
325 [email protected] "[" 325 [email protected] "["
326 BIN[email protected] 326 IDENT[email protected]
327 [email protected] 327 [email protected]
328 [email protected] "head" 328 [email protected] "head"
329 [email protected] "," 329 [email protected] ","
330 [email protected] " " 330 [email protected] " "
331 BIN[email protected] 331 IDENT[email protected]
332 [email protected] 332 [email protected]
333 [email protected] "mid" 333 [email protected] "mid"
334 [email protected] " " 334 [email protected] " "
335 [email protected] "@" 335 [email protected] "@"
336 [email protected] " " 336 [email protected] " "
337 DOT_DOT_[email protected] 337 RES[email protected]
338 [email protected] ".." 338 [email protected] ".."
339 [email protected] "," 339 [email protected] ","
340 [email protected] " " 340 [email protected] " "
341 BIN[email protected] 341 IDENT[email protected]
342 [email protected] 342 [email protected]
343 [email protected] "cons" 343 [email protected] "cons"
344 [email protected] "]" 344 [email protected] "]"
@@ -355,20 +355,20 @@ [email protected]
355 [email protected] " " 355 [email protected] " "
356 [email protected] 356 [email protected]
357 [email protected] "[" 357 [email protected] "["
358 BIN[email protected] 358 IDENT[email protected]
359 [email protected] 359 [email protected]
360 [email protected] "head" 360 [email protected] "head"
361 [email protected] "," 361 [email protected] ","
362 [email protected] " " 362 [email protected] " "
363 DOT_DOT_[email protected] 363 RES[email protected]
364 [email protected] ".." 364 [email protected] ".."
365 [email protected] "," 365 [email protected] ","
366 [email protected] " " 366 [email protected] " "
367 DOT_DOT_[email protected] 367 RES[email protected]
368 [email protected] ".." 368 [email protected] ".."
369 [email protected] "," 369 [email protected] ","
370 [email protected] " " 370 [email protected] " "
371 BIN[email protected] 371 IDENT[email protected]
372 [email protected] 372 [email protected]
373 [email protected] "cons" 373 [email protected] "cons"
374 [email protected] "]" 374 [email protected] "]"
@@ -385,27 +385,27 @@ [email protected]
385 [email protected] " " 385 [email protected] " "
386 [email protected] 386 [email protected]
387 [email protected] "[" 387 [email protected] "["
388 BIN[email protected] 388 IDENT[email protected]
389 [email protected] 389 [email protected]
390 [email protected] "head" 390 [email protected] "head"
391 [email protected] "," 391 [email protected] ","
392 [email protected] " " 392 [email protected] " "
393 DOT_DOT_[email protected] 393 RES[email protected]
394 [email protected] ".." 394 [email protected] ".."
395 [email protected] "," 395 [email protected] ","
396 [email protected] " " 396 [email protected] " "
397 BIN[email protected] 397 IDENT[email protected]
398 [email protected] 398 [email protected]
399 [email protected] "mid" 399 [email protected] "mid"
400 [email protected] "," 400 [email protected] ","
401 [email protected] " " 401 [email protected] " "
402 BIN[email protected] 402 IDENT[email protected]
403 [email protected] 403 [email protected]
404 [email protected] "tail" 404 [email protected] "tail"
405 [email protected] " " 405 [email protected] " "
406 [email protected] "@" 406 [email protected] "@"
407 [email protected] " " 407 [email protected] " "
408 DOT_DOT_[email protected] 408 RES[email protected]
409 [email protected] ".." 409 [email protected] ".."
410 [email protected] "]" 410 [email protected] "]"
411 [email protected] " " 411 [email protected] " "
@@ -421,25 +421,25 @@ [email protected]
421 [email protected] " " 421 [email protected] " "
422 [email protected] 422 [email protected]
423 [email protected] "[" 423 [email protected] "["
424 BIN[email protected] 424 IDENT[email protected]
425 [email protected] 425 [email protected]
426 [email protected] "head" 426 [email protected] "head"
427 [email protected] "," 427 [email protected] ","
428 [email protected] " " 428 [email protected] " "
429 DOT_DOT_[email protected] 429 RES[email protected]
430 [email protected] ".." 430 [email protected] ".."
431 [email protected] "," 431 [email protected] ","
432 [email protected] " " 432 [email protected] " "
433 BIN[email protected] 433 IDENT[email protected]
434 [email protected] 434 [email protected]
435 [email protected] "mid" 435 [email protected] "mid"
436 [email protected] "," 436 [email protected] ","
437 [email protected] " " 437 [email protected] " "
438 DOT_DOT_[email protected] 438 RES[email protected]
439 [email protected] ".." 439 [email protected] ".."
440 [email protected] "," 440 [email protected] ","
441 [email protected] " " 441 [email protected] " "
442 BIN[email protected] 442 IDENT[email protected]
443 [email protected] 443 [email protected]
444 [email protected] "cons" 444 [email protected] "cons"
445 [email protected] "]" 445 [email protected] "]"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.rast b/crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.rast
index 7c092d518..925409bdf 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..62 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -20,10 +20,10 @@ [email protected]
20 [email protected] 20 [email protected]
21 [email protected] "S" 21 [email protected] "S"
22 [email protected] " " 22 [email protected] " "
23 RECORD_FIELD_PAT_[email protected] 23 RECORD_PAT_[email protected]
24 [email protected] "{" 24 [email protected] "{"
25 [email protected] " " 25 [email protected] " "
26 RECORD_FIELD_PAT@23..27 26 RECORD_PAT_[email protected]
27 [email protected] 27 [email protected]
28 [email protected] "0" 28 [email protected] "0"
29 [email protected] ":" 29 [email protected] ":"
@@ -50,10 +50,10 @@ [email protected]
50 [email protected] 50 [email protected]
51 [email protected] "S" 51 [email protected] "S"
52 [email protected] " " 52 [email protected] " "
53 RECORD_FIELD_PAT_[email protected] 53 RECORD_PAT_[email protected]
54 [email protected] "{" 54 [email protected] "{"
55 [email protected] " " 55 [email protected] " "
56 RECORD_FIELD_PAT@48..52 56 RECORD_PAT_[email protected]
57 [email protected] 57 [email protected]
58 [email protected] "x" 58 [email protected] "x"
59 [email protected] ":" 59 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rast b/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rast
index 8382a4f96..a36cc8dab 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..42 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 PLACEHOLDE[email protected] 17 WILDCARD[email protected]
18 [email protected] "_" 18 [email protected] "_"
19 [email protected] " " 19 [email protected] " "
20 [email protected] "=" 20 [email protected] "="
@@ -27,7 +27,7 @@ [email protected]
27 [email protected] " " 27 [email protected] " "
28 [email protected] "as" 28 [email protected] "as"
29 [email protected] " " 29 [email protected] " "
30 POINTE[email protected] 30 [email protected]
31 [email protected] "*" 31 [email protected] "*"
32 [email protected] "const" 32 [email protected] "const"
33 [email protected] " " 33 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rast b/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rast
index 4b9b8e0ab..9312eab65 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..23 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "S" 6 [email protected] "S"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] "const" 10 [email protected] "const"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast b/crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast
index 3c00a2647..f284aafcd 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast
@@ -1,12 +1,12 @@
1[email protected] 1[email protected]
2 CONST_DEF@0..39 2 [email protected]
3 [email protected] "const" 3 [email protected] "const"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "A" 6 [email protected] "A"
7 [email protected] ":" 7 [email protected] ":"
8 [email protected] " " 8 [email protected] " "
9 REFERENCE[email protected] 9 [email protected]
10 [email protected] "&" 10 [email protected] "&"
11 [email protected] 11 [email protected]
12 [email protected] "[" 12 [email protected] "["
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast b/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast
index e70c3b710..12194abda 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast
@@ -1,7 +1,7 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..28 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 TYP[email protected] 4 GENERIC[email protected]
5 [email protected] "<" 5 [email protected] "<"
6 [email protected] 6 [email protected]
7 [email protected] "const" 7 [email protected] "const"
@@ -22,7 +22,7 @@ [email protected]
22 [email protected] 22 [email protected]
23 [email protected] 23 [email protected]
24 [email protected] "Bar" 24 [email protected] "Bar"
25 TYP[email protected] 25 GENERIC[email protected]
26 [email protected] "<" 26 [email protected] "<"
27 [email protected] 27 [email protected]
28 [email protected] 28 [email protected]
@@ -32,7 +32,7 @@ [email protected]
32 [email protected] "N" 32 [email protected] "N"
33 [email protected] ">" 33 [email protected] ">"
34 [email protected] " " 34 [email protected] " "
35 [email protected] 35 ASSOC_[email protected]
36 [email protected] "{" 36 [email protected] "{"
37 [email protected] "}" 37 [email protected] "}"
38 [email protected] "\n" 38 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast b/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast
index 48d73a4e7..dac50410e 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..18 2 [email protected]
3 [email protected] "trait" 3 [email protected] "trait"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "Z" 6 [email protected] "Z"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
@@ -20,7 +20,7 @@ [email protected]
20 [email protected] 20 [email protected]
21 [email protected] 21 [email protected]
22 [email protected] "T" 22 [email protected] "T"
23 TYP[email protected] 23 GENERIC[email protected]
24 [email protected] "<" 24 [email protected] "<"
25 [email protected] 25 [email protected]
26 [email protected] 26 [email protected]
@@ -31,12 +31,12 @@ [email protected]
31 [email protected] ">" 31 [email protected] ">"
32 [email protected] ";" 32 [email protected] ";"
33 [email protected] "\n" 33 [email protected] "\n"
34 TRAIT_DEF@19..51 34 [email protected]
35 [email protected] "trait" 35 [email protected] "trait"
36 [email protected] " " 36 [email protected] " "
37 [email protected] 37 [email protected]
38 [email protected] "Z" 38 [email protected] "Z"
39 TYP[email protected] 39 GENERIC[email protected]
40 [email protected] "<" 40 [email protected] "<"
41 [email protected] 41 [email protected]
42 [email protected] 42 [email protected]
@@ -52,7 +52,7 @@ [email protected]
52 [email protected] 52 [email protected]
53 [email protected] 53 [email protected]
54 [email protected] "T" 54 [email protected] "T"
55 TYP[email protected] 55 GENERIC[email protected]
56 [email protected] "<" 56 [email protected] "<"
57 [email protected] 57 [email protected]
58 [email protected] 58 [email protected]
@@ -82,12 +82,12 @@ [email protected]
82 [email protected] "Copy" 82 [email protected] "Copy"
83 [email protected] ";" 83 [email protected] ";"
84 [email protected] "\n" 84 [email protected] "\n"
85 TRAIT_DEF@52..82 85 [email protected]
86 [email protected] "trait" 86 [email protected] "trait"
87 [email protected] " " 87 [email protected] " "
88 [email protected] 88 [email protected]
89 [email protected] "Z" 89 [email protected] "Z"
90 TYP[email protected] 90 GENERIC[email protected]
91 [email protected] "<" 91 [email protected] "<"
92 [email protected] 92 [email protected]
93 [email protected] 93 [email protected]
@@ -115,7 +115,7 @@ [email protected]
115 [email protected] 115 [email protected]
116 [email protected] 116 [email protected]
117 [email protected] "T" 117 [email protected] "T"
118 TYP[email protected] 118 GENERIC[email protected]
119 [email protected] "<" 119 [email protected] "<"
120 [email protected] 120 [email protected]
121 [email protected] 121 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast
index f43dfbe63..2905c5f1a 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..33 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast b/crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast
index 861065362..e6aff7b37 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..24 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -7,7 +7,7 @@ [email protected]
7 [email protected] " " 7 [email protected] " "
8 [email protected] "=" 8 [email protected] "="
9 [email protected] " " 9 [email protected] " "
10 FN_POINTE[email protected] 10 [email protected]
11 [email protected] "fn" 11 [email protected] "fn"
12 [email protected] 12 [email protected]
13 [email protected] "(" 13 [email protected] "("
@@ -25,7 +25,7 @@ [email protected]
25 [email protected] ")" 25 [email protected] ")"
26 [email protected] ";" 26 [email protected] ";"
27 [email protected] "\n" 27 [email protected] "\n"
28 TYPE_ALIAS_DEF@25..54 28 [email protected]
29 [email protected] "type" 29 [email protected] "type"
30 [email protected] " " 30 [email protected] " "
31 [email protected] 31 [email protected]
@@ -33,12 +33,12 @@ [email protected]
33 [email protected] " " 33 [email protected] " "
34 [email protected] "=" 34 [email protected] "="
35 [email protected] " " 35 [email protected] " "
36 FN_POINTE[email protected] 36 [email protected]
37 [email protected] "fn" 37 [email protected] "fn"
38 [email protected] 38 [email protected]
39 [email protected] "(" 39 [email protected] "("
40 [email protected] 40 [email protected]
41 BIN[email protected] 41 IDENT[email protected]
42 [email protected] 42 [email protected]
43 [email protected] "baz" 43 [email protected] "baz"
44 [email protected] ":" 44 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast b/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast
index ecac05950..31671b420 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..62 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,23 +14,23 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 BIN[email protected] 17 IDENT[email protected]
18 [email protected] 18 [email protected]
19 [email protected] "foo" 19 [email protected] "foo"
20 [email protected] " " 20 [email protected] " "
21 [email protected] "=" 21 [email protected] "="
22 [email protected] " " 22 [email protected] " "
23 LAMBDA[email protected] 23 CLOSURE[email protected]
24 [email protected] 24 [email protected]
25 [email protected] "|" 25 [email protected] "|"
26 [email protected] 26 [email protected]
27 BIN[email protected] 27 IDENT[email protected]
28 [email protected] 28 [email protected]
29 [email protected] "bar" 29 [email protected] "bar"
30 [email protected] "," 30 [email protected] ","
31 [email protected] " " 31 [email protected] " "
32 [email protected] 32 [email protected]
33 BIN[email protected] 33 IDENT[email protected]
34 [email protected] 34 [email protected]
35 [email protected] "baz" 35 [email protected] "baz"
36 [email protected] ":" 36 [email protected] ":"
@@ -43,7 +43,7 @@ [email protected]
43 [email protected] "," 43 [email protected] ","
44 [email protected] " " 44 [email protected] " "
45 [email protected] 45 [email protected]
46 BIN[email protected] 46 IDENT[email protected]
47 [email protected] 47 [email protected]
48 [email protected] "qux" 48 [email protected] "qux"
49 [email protected] ":" 49 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rast b/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rast
index 092833417..508b4aca7 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..29 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -9,12 +9,12 @@ [email protected]
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
11 [email protected] "(" 11 [email protected] "("
12 BIN[email protected] 12 IDENT[email protected]
13 [email protected] 13 [email protected]
14 [email protected] "x" 14 [email protected] "x"
15 [email protected] "," 15 [email protected] ","
16 [email protected] " " 16 [email protected] " "
17 BIN[email protected] 17 IDENT[email protected]
18 [email protected] 18 [email protected]
19 [email protected] "y" 19 [email protected] "y"
20 [email protected] ")" 20 [email protected] ")"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rast b/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rast
index 88d512f1a..88a513cee 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..129 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -25,12 +25,12 @@ [email protected]
25 [email protected] 25 [email protected]
26 [email protected] "(" 26 [email protected] "("
27 [email protected] 27 [email protected]
28 PLACEHOLDE[email protected] 28 WILDCARD[email protected]
29 [email protected] "_" 29 [email protected] "_"
30 [email protected] " " 30 [email protected] " "
31 [email protected] "|" 31 [email protected] "|"
32 [email protected] " " 32 [email protected] " "
33 PLACEHOLDE[email protected] 33 WILDCARD[email protected]
34 [email protected] "_" 34 [email protected] "_"
35 [email protected] ")" 35 [email protected] ")"
36 [email protected] " " 36 [email protected] " "
@@ -47,12 +47,12 @@ [email protected]
47 [email protected] 47 [email protected]
48 [email protected] "(" 48 [email protected] "("
49 [email protected] 49 [email protected]
50 PLACEHOLDE[email protected] 50 WILDCARD[email protected]
51 [email protected] "_" 51 [email protected] "_"
52 [email protected] " " 52 [email protected] " "
53 [email protected] "|" 53 [email protected] "|"
54 [email protected] " " 54 [email protected] " "
55 PLACEHOLDE[email protected] 55 WILDCARD[email protected]
56 [email protected] "_" 56 [email protected] "_"
57 [email protected] ")" 57 [email protected] ")"
58 [email protected] " " 58 [email protected] " "
@@ -67,12 +67,12 @@ [email protected]
67 [email protected] 67 [email protected]
68 [email protected] "(" 68 [email protected] "("
69 [email protected] 69 [email protected]
70 PLACEHOLDE[email protected] 70 WILDCARD[email protected]
71 [email protected] "_" 71 [email protected] "_"
72 [email protected] " " 72 [email protected] " "
73 [email protected] "|" 73 [email protected] "|"
74 [email protected] " " 74 [email protected] " "
75 PLACEHOLDE[email protected] 75 WILDCARD[email protected]
76 [email protected] "_" 76 [email protected] "_"
77 [email protected] "," 77 [email protected] ","
78 [email protected] ")" 78 [email protected] ")"
@@ -88,12 +88,12 @@ [email protected]
88 [email protected] 88 [email protected]
89 [email protected] "[" 89 [email protected] "["
90 [email protected] 90 [email protected]
91 PLACEHOLDE[email protected] 91 WILDCARD[email protected]
92 [email protected] "_" 92 [email protected] "_"
93 [email protected] " " 93 [email protected] " "
94 [email protected] "|" 94 [email protected] "|"
95 [email protected] " " 95 [email protected] " "
96 PLACEHOLDE[email protected] 96 WILDCARD[email protected]
97 [email protected] "_" 97 [email protected] "_"
98 [email protected] "," 98 [email protected] ","
99 [email protected] "]" 99 [email protected] "]"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast b/crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast
index fad9df007..6abb4fe5a 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..22 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -7,12 +7,12 @@ [email protected]
7 [email protected] " " 7 [email protected] " "
8 [email protected] "=" 8 [email protected] "="
9 [email protected] " " 9 [email protected] " "
10 FN_POINTE[email protected] 10 [email protected]
11 [email protected] "fn" 11 [email protected] "fn"
12 [email protected] 12 [email protected]
13 [email protected] "(" 13 [email protected] "("
14 [email protected] 14 [email protected]
15 PLACEHOLDE[email protected] 15 WILDCARD[email protected]
16 [email protected] "_" 16 [email protected] "_"
17 [email protected] ":" 17 [email protected] ":"
18 [email protected] " " 18 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast b/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast
index e8a0e9ddd..a2e05eb2e 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast
@@ -1,19 +1,19 @@
1[email protected] 1[email protected]
2 ENUM_DEF@0..22 2 [email protected]
3 [email protected] "enum" 3 [email protected] "enum"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "E" 6 [email protected] "E"
7 [email protected] " " 7 [email protected] " "
8 ENUM_[email protected] 8 [email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] " " 10 [email protected] " "
11 ENUM_[email protected] 11 [email protected]
12 [email protected] 12 [email protected]
13 [email protected] "X" 13 [email protected] "X"
14 TUPLE_FIELD_DEF_[email protected] 14 [email protected]
15 [email protected] "(" 15 [email protected] "("
16 TUPLE_FIELD_DEF@11..14 16 [email protected]
17 [email protected] 17 [email protected]
18 [email protected] 18 [email protected]
19 [email protected] 19 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast b/crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast
index bd9e8d40f..8ae24b9c1 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..27 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast b/crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast
index 08333a325..aa4099a92 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..33 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -13,7 +13,7 @@ [email protected]
13 [email protected] " " 13 [email protected] " "
14 [email protected] 14 [email protected]
15 [email protected] 15 [email protected]
16 LAMBDA[email protected] 16 CLOSURE[email protected]
17 [email protected] 17 [email protected]
18 [email protected] "|" 18 [email protected] "|"
19 [email protected] "|" 19 [email protected] "|"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rast b/crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rast
index 5f09e4f4a..fb46d4ce4 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..26 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rast b/crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rast
index 9efebd8b8..9e9a5f9c5 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..22 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rast b/crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rast
index 4991f2c36..ca9a1183d 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..21 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast
index adb6159f4..1269621dc 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..49 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -16,10 +16,10 @@ [email protected]
16 [email protected] 16 [email protected]
17 [email protected] "Foo" 17 [email protected] "Foo"
18 [email protected] " " 18 [email protected] " "
19 [email protected] 19 ASSOC_[email protected]
20 [email protected] "{" 20 [email protected] "{"
21 [email protected] "\n " 21 [email protected] "\n "
22 FN_DEF@21..47 22 [email protected]
23 [email protected] "default" 23 [email protected] "default"
24 [email protected] " " 24 [email protected] " "
25 [email protected] "unsafe" 25 [email protected] "unsafe"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast
index a9eda5668..6bfe925af 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..26 2 [email protected]
3 [email protected] "default" 3 [email protected] "default"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "unsafe" 5 [email protected] "unsafe"
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] 12 [email protected]
13 [email protected] "Foo" 13 [email protected] "Foo"
14 [email protected] " " 14 [email protected] " "
15 [email protected] 15 ASSOC_[email protected]
16 [email protected] "{" 16 [email protected] "{"
17 [email protected] "}" 17 [email protected] "}"
18 [email protected] "\n" 18 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast b/crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast
index 868899275..f8910677b 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..32 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -19,7 +19,7 @@ [email protected]
19 [email protected] 19 [email protected]
20 [email protected] 20 [email protected]
21 [email protected] "<" 21 [email protected] "<"
22 PLACEHOLDE[email protected] 22 INF[email protected]
23 [email protected] "_" 23 [email protected] "_"
24 [email protected] ">" 24 [email protected] ">"
25 [email protected] "::" 25 [email protected] "::"
diff --git a/crates/ra_syntax/test_data/parser/ok/0001_struct_item.rast b/crates/ra_syntax/test_data/parser/ok/0001_struct_item.rast
index 705f7e001..a171fe7a8 100644
--- a/crates/ra_syntax/test_data/parser/ok/0001_struct_item.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0001_struct_item.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..31 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "S" 6 [email protected] "S"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
@@ -20,10 +20,10 @@ [email protected]
20 [email protected] "Copy" 20 [email protected] "Copy"
21 [email protected] ">" 21 [email protected] ">"
22 [email protected] " " 22 [email protected] " "
23 RECORD_FIELD_DEF_[email protected] 23 [email protected]
24 [email protected] "{" 24 [email protected] "{"
25 [email protected] "\n " 25 [email protected] "\n "
26 RECORD_FIELD_DEF@24..28 26 [email protected]
27 [email protected] 27 [email protected]
28 [email protected] "f" 28 [email protected] "f"
29 [email protected] ":" 29 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.rast b/crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.rast
index a1d546491..362892b91 100644
--- a/crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.rast
@@ -1,14 +1,14 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..25 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "S" 6 [email protected] "S"
7 [email protected] " " 7 [email protected] " "
8 RECORD_FIELD_DEF_[email protected] 8 [email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] "\n " 10 [email protected] "\n "
11 RECORD_FIELD_DEF@15..23 11 [email protected]
12 [email protected] 12 [email protected]
13 [email protected] "foo" 13 [email protected] "foo"
14 [email protected] ":" 14 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/ok/0005_fn_item.rast b/crates/ra_syntax/test_data/parser/ok/0005_fn_item.rast
index 0ec237f8e..a7a2b11a7 100644
--- a/crates/ra_syntax/test_data/parser/ok/0005_fn_item.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0005_fn_item.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..12 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast b/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast
index b5bdf0aa9..594c2f8f2 100644
--- a/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 EXTERN_CRATE_ITEM@0..17 2 [email protected]
3 [email protected] "extern" 3 [email protected] "extern"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "crate" 5 [email protected] "crate"
@@ -8,7 +8,7 @@ [email protected]
8 [email protected] "foo" 8 [email protected] "foo"
9 [email protected] ";" 9 [email protected] ";"
10 [email protected] "\n" 10 [email protected] "\n"
11 EXTERN_CRATE_ITEM@18..42 11 [email protected]
12 [email protected] "extern" 12 [email protected] "extern"
13 [email protected] " " 13 [email protected] " "
14 [email protected] "crate" 14 [email protected] "crate"
@@ -16,22 +16,21 @@ [email protected]
16 [email protected] 16 [email protected]
17 [email protected] "foo" 17 [email protected] "foo"
18 [email protected] " " 18 [email protected] " "
19 ALIAS@35..41 19 RENAME@35..41
20 [email protected] "as" 20 [email protected] "as"
21 [email protected] " " 21 [email protected] " "
22 [email protected] 22 [email protected]
23 [email protected] "bar" 23 [email protected] "bar"
24 [email protected] ";" 24 [email protected] ";"
25 [email protected] "\n" 25 [email protected] "\n"
26 EXTERN_CRATE_ITEM@43..68 26 [email protected]
27 [email protected] "extern" 27 [email protected] "extern"
28 [email protected] " " 28 [email protected] " "
29 [email protected] "crate" 29 [email protected] "crate"
30 [email protected] " " 30 [email protected] " "
31 [email protected] 31 [email protected] "self"
32 [email protected] "self"
33 [email protected] " " 32 [email protected] " "
34 ALIAS@61..67 33 RENAME@61..67
35 [email protected] "as" 34 [email protected] "as"
36 [email protected] " " 35 [email protected] " "
37 [email protected] 36 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0008_mod_item.rast b/crates/ra_syntax/test_data/parser/ok/0008_mod_item.rast
index 37b452ec4..b2c1d791f 100644
--- a/crates/ra_syntax/test_data/parser/ok/0008_mod_item.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0008_mod_item.rast
@@ -26,7 +26,7 @@ [email protected]
26 [email protected] 26 [email protected]
27 [email protected] "{" 27 [email protected] "{"
28 [email protected] "\n " 28 [email protected] "\n "
29 FN_DEF@31..47 29 [email protected]
30 [email protected] "fn" 30 [email protected] "fn"
31 [email protected] " " 31 [email protected] " "
32 [email protected] 32 [email protected]
@@ -40,13 +40,13 @@ [email protected]
40 [email protected] "\n " 40 [email protected] "\n "
41 [email protected] "}" 41 [email protected] "}"
42 [email protected] "\n " 42 [email protected] "\n "
43 STRUCT_DEF@52..63 43 [email protected]
44 [email protected] "struct" 44 [email protected] "struct"
45 [email protected] " " 45 [email protected] " "
46 [email protected] 46 [email protected]
47 [email protected] "S" 47 [email protected] "S"
48 [email protected] " " 48 [email protected] " "
49 RECORD_FIELD_DEF_[email protected] 49 [email protected]
50 [email protected] "{" 50 [email protected] "{"
51 [email protected] "}" 51 [email protected] "}"
52 [email protected] "\n" 52 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/ok/0009_use_item.rast b/crates/ra_syntax/test_data/parser/ok/0009_use_item.rast
index 96b8a94fc..6be1cf9fc 100644
--- a/crates/ra_syntax/test_data/parser/ok/0009_use_item.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0009_use_item.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..8 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -9,7 +9,7 @@ [email protected]
9 [email protected] "foo" 9 [email protected] "foo"
10 [email protected] ";" 10 [email protected] ";"
11 [email protected] "\n" 11 [email protected] "\n"
12 USE_ITEM@9..19 12 [email protected]
13 [email protected] "use" 13 [email protected] "use"
14 [email protected] " " 14 [email protected] " "
15 [email protected] 15 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast b/crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast
index 07272dc3c..4d49e7933 100644
--- a/crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..20 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -20,7 +20,7 @@ [email protected]
20 [email protected] "baz" 20 [email protected] "baz"
21 [email protected] ";" 21 [email protected] ";"
22 [email protected] "\n" 22 [email protected] "\n"
23 USE_ITEM@21..39 23 [email protected]
24 [email protected] "use" 24 [email protected] "use"
25 [email protected] " " 25 [email protected] " "
26 [email protected] 26 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.rast b/crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.rast
index 0b9bc58e8..478fdba75 100644
--- a/crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..34 2 [email protected]
3 [email protected] 3 [email protected]
4 [email protected] "#" 4 [email protected] "#"
5 [email protected] "[" 5 [email protected] "["
diff --git a/crates/ra_syntax/test_data/parser/ok/0012_visibility.rast b/crates/ra_syntax/test_data/parser/ok/0012_visibility.rast
index 980b34049..83a93b5a9 100644
--- a/crates/ra_syntax/test_data/parser/ok/0012_visibility.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0012_visibility.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..9 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "}" 13 [email protected] "}"
14 [email protected] "\n" 14 [email protected] "\n"
15 FN_DEF@10..23 15 [email protected]
16 [email protected] 16 [email protected]
17 [email protected] "pub" 17 [email protected] "pub"
18 [email protected] " " 18 [email protected] " "
@@ -28,7 +28,7 @@ [email protected]
28 [email protected] "{" 28 [email protected] "{"
29 [email protected] "}" 29 [email protected] "}"
30 [email protected] "\n" 30 [email protected] "\n"
31 FN_DEF@24..44 31 [email protected]
32 [email protected] 32 [email protected]
33 [email protected] "pub" 33 [email protected] "pub"
34 [email protected] "(" 34 [email protected] "("
@@ -47,7 +47,7 @@ [email protected]
47 [email protected] "{" 47 [email protected] "{"
48 [email protected] "}" 48 [email protected] "}"
49 [email protected] "\n" 49 [email protected] "\n"
50 FN_DEF@45..65 50 [email protected]
51 [email protected] 51 [email protected]
52 [email protected] "pub" 52 [email protected] "pub"
53 [email protected] "(" 53 [email protected] "("
@@ -66,7 +66,7 @@ [email protected]
66 [email protected] "{" 66 [email protected] "{"
67 [email protected] "}" 67 [email protected] "}"
68 [email protected] "\n" 68 [email protected] "\n"
69 FN_DEF@66..97 69 [email protected]
70 [email protected] 70 [email protected]
71 [email protected] "pub" 71 [email protected] "pub"
72 [email protected] "(" 72 [email protected] "("
diff --git a/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast b/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast
index 05d9c05ad..66ab13660 100644
--- a/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..14 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -13,7 +13,7 @@ [email protected]
13 [email protected] "foo" 13 [email protected] "foo"
14 [email protected] ";" 14 [email protected] ";"
15 [email protected] "\n" 15 [email protected] "\n"
16 USE_ITEM@15..37 16 [email protected]
17 [email protected] "use" 17 [email protected] "use"
18 [email protected] " " 18 [email protected] " "
19 [email protected] 19 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast b/crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast
index 3642c107b..4389d2d4b 100644
--- a/crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast
@@ -1,12 +1,12 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..6 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "*" 6 [email protected] "*"
7 [email protected] ";" 7 [email protected] ";"
8 [email protected] "\n" 8 [email protected] "\n"
9 USE_ITEM@7..15 9 [email protected]
10 [email protected] "use" 10 [email protected] "use"
11 [email protected] " " 11 [email protected] " "
12 [email protected] 12 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] "*" 14 [email protected] "*"
15 [email protected] ";" 15 [email protected] ";"
16 [email protected] "\n" 16 [email protected] "\n"
17 USE_ITEM@16..25 17 [email protected]
18 [email protected] "use" 18 [email protected] "use"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 [email protected]
@@ -24,7 +24,7 @@ [email protected]
24 [email protected] "}" 24 [email protected] "}"
25 [email protected] ";" 25 [email protected] ";"
26 [email protected] "\n" 26 [email protected] "\n"
27 USE_ITEM@26..33 27 [email protected]
28 [email protected] "use" 28 [email protected] "use"
29 [email protected] " " 29 [email protected] " "
30 [email protected] 30 [email protected]
@@ -33,7 +33,7 @@ [email protected]
33 [email protected] "}" 33 [email protected] "}"
34 [email protected] ";" 34 [email protected] ";"
35 [email protected] "\n" 35 [email protected] "\n"
36 USE_ITEM@34..45 36 [email protected]
37 [email protected] "use" 37 [email protected] "use"
38 [email protected] " " 38 [email protected] " "
39 [email protected] 39 [email protected]
@@ -45,7 +45,7 @@ [email protected]
45 [email protected] "*" 45 [email protected] "*"
46 [email protected] ";" 46 [email protected] ";"
47 [email protected] "\n" 47 [email protected] "\n"
48 USE_ITEM@46..58 48 [email protected]
49 [email protected] "use" 49 [email protected] "use"
50 [email protected] " " 50 [email protected] " "
51 [email protected] 51 [email protected]
@@ -59,7 +59,7 @@ [email protected]
59 [email protected] "}" 59 [email protected] "}"
60 [email protected] ";" 60 [email protected] ";"
61 [email protected] "\n" 61 [email protected] "\n"
62 USE_ITEM@59..80 62 [email protected]
63 [email protected] "use" 63 [email protected] "use"
64 [email protected] " " 64 [email protected] " "
65 [email protected] 65 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast b/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast
index 09e0050f0..d7e93f7eb 100644
--- a/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 USE_ITEM@0..15 2 [email protected]
3 [email protected] "use" 3 [email protected] "use"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -8,14 +8,14 @@ [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "foo" 9 [email protected] "foo"
10 [email protected] " " 10 [email protected] " "
11 ALIAS@8..14 11 RENAME@8..14
12 [email protected] "as" 12 [email protected] "as"
13 [email protected] " " 13 [email protected] " "
14 [email protected] 14 [email protected]
15 [email protected] "bar" 15 [email protected] "bar"
16 [email protected] ";" 16 [email protected] ";"
17 [email protected] "\n" 17 [email protected] "\n"
18 USE_ITEM@16..54 18 [email protected]
19 [email protected] "use" 19 [email protected] "use"
20 [email protected] " " 20 [email protected] " "
21 [email protected] 21 [email protected]
@@ -32,7 +32,7 @@ [email protected]
32 [email protected] 32 [email protected]
33 [email protected] "a" 33 [email protected] "a"
34 [email protected] " " 34 [email protected] " "
35 ALIAS@28..32 35 RENAME@28..32
36 [email protected] "as" 36 [email protected] "as"
37 [email protected] " " 37 [email protected] " "
38 [email protected] 38 [email protected]
@@ -55,7 +55,7 @@ [email protected]
55 [email protected] 55 [email protected]
56 [email protected] "foo" 56 [email protected] "foo"
57 [email protected] " " 57 [email protected] " "
58 ALIAS@48..52 58 RENAME@48..52
59 [email protected] "as" 59 [email protected] "as"
60 [email protected] " " 60 [email protected] " "
61 [email protected] 61 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.rast b/crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.rast
index 95656d19b..b15f41dd7 100644
--- a/crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.rast
@@ -1,41 +1,41 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..9 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "A" 6 [email protected] "A"
7 [email protected] ";" 7 [email protected] ";"
8 [email protected] "\n" 8 [email protected] "\n"
9 STRUCT_DEF@10..21 9 [email protected]
10 [email protected] "struct" 10 [email protected] "struct"
11 [email protected] " " 11 [email protected] " "
12 [email protected] 12 [email protected]
13 [email protected] "B" 13 [email protected] "B"
14 [email protected] " " 14 [email protected] " "
15 RECORD_FIELD_DEF_[email protected] 15 [email protected]
16 [email protected] "{" 16 [email protected] "{"
17 [email protected] "}" 17 [email protected] "}"
18 [email protected] "\n" 18 [email protected] "\n"
19 STRUCT_DEF@22..33 19 [email protected]
20 [email protected] "struct" 20 [email protected] "struct"
21 [email protected] " " 21 [email protected] " "
22 [email protected] 22 [email protected]
23 [email protected] "C" 23 [email protected] "C"
24 TUPLE_FIELD_DEF_[email protected] 24 [email protected]
25 [email protected] "(" 25 [email protected] "("
26 [email protected] ")" 26 [email protected] ")"
27 [email protected] ";" 27 [email protected] ";"
28 [email protected] "\n\n" 28 [email protected] "\n\n"
29 STRUCT_DEF@35..74 29 [email protected]
30 [email protected] "struct" 30 [email protected] "struct"
31 [email protected] " " 31 [email protected] " "
32 [email protected] 32 [email protected]
33 [email protected] "D" 33 [email protected] "D"
34 [email protected] " " 34 [email protected] " "
35 RECORD_FIELD_DEF_[email protected] 35 [email protected]
36 [email protected] "{" 36 [email protected] "{"
37 [email protected] "\n " 37 [email protected] "\n "
38 RECORD_FIELD_DEF@50..56 38 [email protected]
39 [email protected] 39 [email protected]
40 [email protected] "a" 40 [email protected] "a"
41 [email protected] ":" 41 [email protected] ":"
@@ -47,7 +47,7 @@ [email protected]
47 [email protected] "u32" 47 [email protected] "u32"
48 [email protected] "," 48 [email protected] ","
49 [email protected] "\n " 49 [email protected] "\n "
50 RECORD_FIELD_DEF@62..72 50 [email protected]
51 [email protected] 51 [email protected]
52 [email protected] "pub" 52 [email protected] "pub"
53 [email protected] " " 53 [email protected] " "
@@ -63,14 +63,14 @@ [email protected]
63 [email protected] "\n" 63 [email protected] "\n"
64 [email protected] "}" 64 [email protected] "}"
65 [email protected] "\n\n" 65 [email protected] "\n\n"
66 STRUCT_DEF@76..96 66 [email protected]
67 [email protected] "struct" 67 [email protected] "struct"
68 [email protected] " " 68 [email protected] " "
69 [email protected] 69 [email protected]
70 [email protected] "E" 70 [email protected] "E"
71 TUPLE_FIELD_DEF_[email protected] 71 [email protected]
72 [email protected] "(" 72 [email protected] "("
73 TUPLE_FIELD_DEF@85..90 73 [email protected]
74 [email protected] 74 [email protected]
75 [email protected] "pub" 75 [email protected] "pub"
76 [email protected] " " 76 [email protected] " "
@@ -81,7 +81,7 @@ [email protected]
81 [email protected] "x" 81 [email protected] "x"
82 [email protected] "," 82 [email protected] ","
83 [email protected] " " 83 [email protected] " "
84 TUPLE_FIELD_DEF@92..93 84 [email protected]
85 [email protected] 85 [email protected]
86 [email protected] 86 [email protected]
87 [email protected] 87 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.rast b/crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.rast
index 964cbf5dd..a3e091ad3 100644
--- a/crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..22 2 [email protected]
3 [email protected] 3 [email protected]
4 [email protected] "#" 4 [email protected] "#"
5 [email protected] "[" 5 [email protected] "["
diff --git a/crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.rast b/crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.rast
index 451634e3f..630aa0708 100644
--- a/crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..13 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "S1" 6 [email protected] "S1"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
@@ -12,20 +12,20 @@ [email protected]
12 [email protected] ">" 12 [email protected] ">"
13 [email protected] ";" 13 [email protected] ";"
14 [email protected] "\n" 14 [email protected] "\n"
15 STRUCT_DEF@14..32 15 [email protected]
16 [email protected] "struct" 16 [email protected] "struct"
17 [email protected] " " 17 [email protected] " "
18 [email protected] 18 [email protected]
19 [email protected] "S2" 19 [email protected] "S2"
20 TYP[email protected] 20 GENERIC[email protected]
21 [email protected] "<" 21 [email protected] "<"
22 [email protected] 22 [email protected]
23 [email protected] 23 [email protected]
24 [email protected] "T" 24 [email protected] "T"
25 [email protected] ">" 25 [email protected] ">"
26 TUPLE_FIELD_DEF_[email protected] 26 [email protected]
27 [email protected] "(" 27 [email protected] "("
28 TUPLE_FIELD_DEF@27..30 28 [email protected]
29 [email protected] 29 [email protected]
30 [email protected] 30 [email protected]
31 [email protected] 31 [email protected]
@@ -34,22 +34,22 @@ [email protected]
34 [email protected] ")" 34 [email protected] ")"
35 [email protected] ";" 35 [email protected] ";"
36 [email protected] "\n" 36 [email protected] "\n"
37 STRUCT_DEF@33..56 37 [email protected]
38 [email protected] "struct" 38 [email protected] "struct"
39 [email protected] " " 39 [email protected] " "
40 [email protected] 40 [email protected]
41 [email protected] "S3" 41 [email protected] "S3"
42 TYP[email protected] 42 GENERIC[email protected]
43 [email protected] "<" 43 [email protected] "<"
44 [email protected] 44 [email protected]
45 [email protected] 45 [email protected]
46 [email protected] "T" 46 [email protected] "T"
47 [email protected] ">" 47 [email protected] ">"
48 [email protected] " " 48 [email protected] " "
49 RECORD_FIELD_DEF_[email protected] 49 [email protected]
50 [email protected] "{" 50 [email protected] "{"
51 [email protected] " " 51 [email protected] " "
52 RECORD_FIELD_DEF@48..54 52 [email protected]
53 [email protected] 53 [email protected]
54 [email protected] "u" 54 [email protected] "u"
55 [email protected] ":" 55 [email protected] ":"
@@ -62,34 +62,34 @@ [email protected]
62 [email protected] " " 62 [email protected] " "
63 [email protected] "}" 63 [email protected] "}"
64 [email protected] "\n\n" 64 [email protected] "\n\n"
65 STRUCT_DEF@58..70 65 [email protected]
66 [email protected] "struct" 66 [email protected] "struct"
67 [email protected] " " 67 [email protected] " "
68 [email protected] 68 [email protected]
69 [email protected] "S4" 69 [email protected] "S4"
70 TYP[email protected] 70 GENERIC[email protected]
71 [email protected] "<" 71 [email protected] "<"
72 [email protected] ">" 72 [email protected] ">"
73 [email protected] ";" 73 [email protected] ";"
74 [email protected] "\n" 74 [email protected] "\n"
75 STRUCT_DEF@71..85 75 [email protected]
76 [email protected] "struct" 76 [email protected] "struct"
77 [email protected] " " 77 [email protected] " "
78 [email protected] 78 [email protected]
79 [email protected] "S5" 79 [email protected] "S5"
80 TYP[email protected] 80 GENERIC[email protected]
81 [email protected] "<" 81 [email protected] "<"
82 [email protected] 82 [email protected]
83 [email protected] "\'a" 83 [email protected] "\'a"
84 [email protected] ">" 84 [email protected] ">"
85 [email protected] ";" 85 [email protected] ";"
86 [email protected] "\n" 86 [email protected] "\n"
87 STRUCT_DEF@86..101 87 [email protected]
88 [email protected] "struct" 88 [email protected] "struct"
89 [email protected] " " 89 [email protected] " "
90 [email protected] 90 [email protected]
91 [email protected] "S6" 91 [email protected] "S6"
92 TYP[email protected] 92 GENERIC[email protected]
93 [email protected] "<" 93 [email protected] "<"
94 [email protected] 94 [email protected]
95 [email protected] "\'a" 95 [email protected] "\'a"
@@ -97,12 +97,12 @@ [email protected]
97 [email protected] ">" 97 [email protected] ">"
98 [email protected] ";" 98 [email protected] ";"
99 [email protected] "\n" 99 [email protected] "\n"
100 STRUCT_DEF@102..120 100 [email protected]
101 [email protected] "struct" 101 [email protected] "struct"
102 [email protected] " " 102 [email protected] " "
103 [email protected] 103 [email protected]
104 [email protected] "S7" 104 [email protected] "S7"
105 TYP[email protected] 105 GENERIC[email protected]
106 [email protected] "<" 106 [email protected] "<"
107 [email protected] 107 [email protected]
108 [email protected] "\'a" 108 [email protected] "\'a"
@@ -112,12 +112,12 @@ [email protected]
112 [email protected] ">" 112 [email protected] ">"
113 [email protected] ";" 113 [email protected] ";"
114 [email protected] "\n" 114 [email protected] "\n"
115 STRUCT_DEF@121..142 115 [email protected]
116 [email protected] "struct" 116 [email protected] "struct"
117 [email protected] " " 117 [email protected] " "
118 [email protected] 118 [email protected]
119 [email protected] "S8" 119 [email protected] "S8"
120 TYP[email protected] 120 GENERIC[email protected]
121 [email protected] "<" 121 [email protected] "<"
122 [email protected] 122 [email protected]
123 [email protected] "\'a" 123 [email protected] "\'a"
@@ -130,12 +130,12 @@ [email protected]
130 [email protected] ">" 130 [email protected] ">"
131 [email protected] ";" 131 [email protected] ";"
132 [email protected] "\n" 132 [email protected] "\n"
133 STRUCT_DEF@143..166 133 [email protected]
134 [email protected] "struct" 134 [email protected] "struct"
135 [email protected] " " 135 [email protected] " "
136 [email protected] 136 [email protected]
137 [email protected] "S9" 137 [email protected] "S9"
138 TYP[email protected] 138 GENERIC[email protected]
139 [email protected] "<" 139 [email protected] "<"
140 [email protected] 140 [email protected]
141 [email protected] "\'a" 141 [email protected] "\'a"
@@ -149,12 +149,12 @@ [email protected]
149 [email protected] ">" 149 [email protected] ">"
150 [email protected] ";" 150 [email protected] ";"
151 [email protected] "\n" 151 [email protected] "\n"
152 STRUCT_DEF@167..183 152 [email protected]
153 [email protected] "struct" 153 [email protected] "struct"
154 [email protected] " " 154 [email protected] " "
155 [email protected] 155 [email protected]
156 [email protected] "S10" 156 [email protected] "S10"
157 TYP[email protected] 157 GENERIC[email protected]
158 [email protected] "<" 158 [email protected] "<"
159 [email protected] 159 [email protected]
160 [email protected] "\'a" 160 [email protected] "\'a"
@@ -162,12 +162,12 @@ [email protected]
162 [email protected] ">" 162 [email protected] ">"
163 [email protected] ";" 163 [email protected] ";"
164 [email protected] "\n" 164 [email protected] "\n"
165 STRUCT_DEF@184..203 165 [email protected]
166 [email protected] "struct" 166 [email protected] "struct"
167 [email protected] " " 167 [email protected] " "
168 [email protected] 168 [email protected]
169 [email protected] "S11" 169 [email protected] "S11"
170 TYP[email protected] 170 GENERIC[email protected]
171 [email protected] "<" 171 [email protected] "<"
172 [email protected] 172 [email protected]
173 [email protected] "\'a" 173 [email protected] "\'a"
@@ -178,12 +178,12 @@ [email protected]
178 [email protected] ">" 178 [email protected] ">"
179 [email protected] ";" 179 [email protected] ";"
180 [email protected] "\n" 180 [email protected] "\n"
181 STRUCT_DEF@204..233 181 [email protected]
182 [email protected] "struct" 182 [email protected] "struct"
183 [email protected] " " 183 [email protected] " "
184 [email protected] 184 [email protected]
185 [email protected] "S12" 185 [email protected] "S12"
186 TYP[email protected] 186 GENERIC[email protected]
187 [email protected] "<" 187 [email protected] "<"
188 [email protected] 188 [email protected]
189 [email protected] "\'a" 189 [email protected] "\'a"
@@ -202,12 +202,12 @@ [email protected]
202 [email protected] ">" 202 [email protected] ">"
203 [email protected] ";" 203 [email protected] ";"
204 [email protected] "\n\n" 204 [email protected] "\n\n"
205 STRUCT_DEF@235..249 205 [email protected]
206 [email protected] "struct" 206 [email protected] "struct"
207 [email protected] " " 207 [email protected] " "
208 [email protected] 208 [email protected]
209 [email protected] "S13" 209 [email protected] "S13"
210 TYP[email protected] 210 GENERIC[email protected]
211 [email protected] "<" 211 [email protected] "<"
212 [email protected] 212 [email protected]
213 [email protected] 213 [email protected]
@@ -215,12 +215,12 @@ [email protected]
215 [email protected] ">" 215 [email protected] ">"
216 [email protected] ";" 216 [email protected] ";"
217 [email protected] "\n" 217 [email protected] "\n"
218 STRUCT_DEF@250..267 218 [email protected]
219 [email protected] "struct" 219 [email protected] "struct"
220 [email protected] " " 220 [email protected] " "
221 [email protected] 221 [email protected]
222 [email protected] "S14" 222 [email protected] "S14"
223 TYP[email protected] 223 GENERIC[email protected]
224 [email protected] "<" 224 [email protected] "<"
225 [email protected] 225 [email protected]
226 [email protected] 226 [email protected]
@@ -233,12 +233,12 @@ [email protected]
233 [email protected] ">" 233 [email protected] ">"
234 [email protected] ";" 234 [email protected] ";"
235 [email protected] "\n" 235 [email protected] "\n"
236 STRUCT_DEF@268..289 236 [email protected]
237 [email protected] "struct" 237 [email protected] "struct"
238 [email protected] " " 238 [email protected] " "
239 [email protected] 239 [email protected]
240 [email protected] "S15" 240 [email protected] "S15"
241 TYP[email protected] 241 GENERIC[email protected]
242 [email protected] "<" 242 [email protected] "<"
243 [email protected] 243 [email protected]
244 [email protected] "\'a" 244 [email protected] "\'a"
diff --git a/crates/ra_syntax/test_data/parser/ok/0019_enums.rast b/crates/ra_syntax/test_data/parser/ok/0019_enums.rast
index f767e9e19..c3df00814 100644
--- a/crates/ra_syntax/test_data/parser/ok/0019_enums.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0019_enums.rast
@@ -1,78 +1,78 @@
1[email protected] 1[email protected]
2 ENUM_DEF@0..11 2 [email protected]
3 [email protected] "enum" 3 [email protected] "enum"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "E1" 6 [email protected] "E1"
7 [email protected] " " 7 [email protected] " "
8 ENUM_[email protected] 8 [email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] "\n" 10 [email protected] "\n"
11 [email protected] "}" 11 [email protected] "}"
12 [email protected] "\n\n" 12 [email protected] "\n\n"
13 ENUM_DEF@13..27 13 [email protected]
14 [email protected] "enum" 14 [email protected] "enum"
15 [email protected] " " 15 [email protected] " "
16 [email protected] 16 [email protected]
17 [email protected] "E2" 17 [email protected] "E2"
18 TYP[email protected] 18 GENERIC[email protected]
19 [email protected] "<" 19 [email protected] "<"
20 [email protected] 20 [email protected]
21 [email protected] 21 [email protected]
22 [email protected] "T" 22 [email protected] "T"
23 [email protected] ">" 23 [email protected] ">"
24 [email protected] " " 24 [email protected] " "
25 ENUM_[email protected] 25 [email protected]
26 [email protected] "{" 26 [email protected] "{"
27 [email protected] "\n" 27 [email protected] "\n"
28 [email protected] "}" 28 [email protected] "}"
29 [email protected] "\n\n" 29 [email protected] "\n\n"
30 ENUM_DEF@29..46 30 [email protected]
31 [email protected] "enum" 31 [email protected] "enum"
32 [email protected] " " 32 [email protected] " "
33 [email protected] 33 [email protected]
34 [email protected] "E3" 34 [email protected] "E3"
35 [email protected] " " 35 [email protected] " "
36 ENUM_[email protected] 36 [email protected]
37 [email protected] "{" 37 [email protected] "{"
38 [email protected] "\n " 38 [email protected] "\n "
39 ENUM_[email protected] 39 [email protected]
40 [email protected] 40 [email protected]
41 [email protected] "X" 41 [email protected] "X"
42 [email protected] "\n" 42 [email protected] "\n"
43 [email protected] "}" 43 [email protected] "}"
44 [email protected] "\n\n" 44 [email protected] "\n\n"
45 ENUM_DEF@48..66 45 [email protected]
46 [email protected] "enum" 46 [email protected] "enum"
47 [email protected] " " 47 [email protected] " "
48 [email protected] 48 [email protected]
49 [email protected] "E4" 49 [email protected] "E4"
50 [email protected] " " 50 [email protected] " "
51 ENUM_[email protected] 51 [email protected]
52 [email protected] "{" 52 [email protected] "{"
53 [email protected] "\n " 53 [email protected] "\n "
54 ENUM_[email protected] 54 [email protected]
55 [email protected] 55 [email protected]
56 [email protected] "X" 56 [email protected] "X"
57 [email protected] "," 57 [email protected] ","
58 [email protected] "\n" 58 [email protected] "\n"
59 [email protected] "}" 59 [email protected] "}"
60 [email protected] "\n\n" 60 [email protected] "\n\n"
61 ENUM_DEF@68..181 61 [email protected]
62 [email protected] "enum" 62 [email protected] "enum"
63 [email protected] " " 63 [email protected] " "
64 [email protected] 64 [email protected]
65 [email protected] "E5" 65 [email protected] "E5"
66 [email protected] " " 66 [email protected] " "
67 ENUM_[email protected] 67 [email protected]
68 [email protected] "{" 68 [email protected] "{"
69 [email protected] "\n " 69 [email protected] "\n "
70 ENUM_[email protected] 70 [email protected]
71 [email protected] 71 [email protected]
72 [email protected] "A" 72 [email protected] "A"
73 [email protected] "," 73 [email protected] ","
74 [email protected] "\n " 74 [email protected] "\n "
75 ENUM_[email protected] 75 [email protected]
76 [email protected] 76 [email protected]
77 [email protected] "B" 77 [email protected] "B"
78 [email protected] " " 78 [email protected] " "
@@ -82,14 +82,14 @@ [email protected]
82 [email protected] "92" 82 [email protected] "92"
83 [email protected] "," 83 [email protected] ","
84 [email protected] "\n " 84 [email protected] "\n "
85 ENUM_[email protected] 85 [email protected]
86 [email protected] 86 [email protected]
87 [email protected] "C" 87 [email protected] "C"
88 [email protected] " " 88 [email protected] " "
89 RECORD_FIELD_DEF_[email protected] 89 [email protected]
90 [email protected] "{" 90 [email protected] "{"
91 [email protected] "\n " 91 [email protected] "\n "
92 RECORD_FIELD_DEF@113..119 92 [email protected]
93 [email protected] 93 [email protected]
94 [email protected] "a" 94 [email protected] "a"
95 [email protected] ":" 95 [email protected] ":"
@@ -101,7 +101,7 @@ [email protected]
101 [email protected] "u32" 101 [email protected] "u32"
102 [email protected] "," 102 [email protected] ","
103 [email protected] "\n " 103 [email protected] "\n "
104 RECORD_FIELD_DEF@129..139 104 [email protected]
105 [email protected] 105 [email protected]
106 [email protected] "pub" 106 [email protected] "pub"
107 [email protected] " " 107 [email protected] " "
@@ -119,21 +119,21 @@ [email protected]
119 [email protected] "}" 119 [email protected] "}"
120 [email protected] "," 120 [email protected] ","
121 [email protected] "\n " 121 [email protected] "\n "
122 ENUM_[email protected] 122 [email protected]
123 [email protected] 123 [email protected]
124 [email protected] "F" 124 [email protected] "F"
125 [email protected] " " 125 [email protected] " "
126 RECORD_FIELD_DEF_[email protected] 126 [email protected]
127 [email protected] "{" 127 [email protected] "{"
128 [email protected] "}" 128 [email protected] "}"
129 [email protected] "," 129 [email protected] ","
130 [email protected] "\n " 130 [email protected] "\n "
131 ENUM_[email protected] 131 [email protected]
132 [email protected] 132 [email protected]
133 [email protected] "D" 133 [email protected] "D"
134 TUPLE_FIELD_DEF_[email protected] 134 [email protected]
135 [email protected] "(" 135 [email protected] "("
136 TUPLE_FIELD_DEF@164..167 136 [email protected]
137 [email protected] 137 [email protected]
138 [email protected] 138 [email protected]
139 [email protected] 139 [email protected]
@@ -143,10 +143,10 @@ [email protected]
143 [email protected] ")" 143 [email protected] ")"
144 [email protected] "," 144 [email protected] ","
145 [email protected] "\n " 145 [email protected] "\n "
146 ENUM_[email protected] 146 [email protected]
147 [email protected] 147 [email protected]
148 [email protected] "E" 148 [email protected] "E"
149 TUPLE_FIELD_DEF_[email protected] 149 [email protected]
150 [email protected] "(" 150 [email protected] "("
151 [email protected] ")" 151 [email protected] ")"
152 [email protected] "," 152 [email protected] ","
diff --git a/crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.rast b/crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.rast
index 4fb4baf56..9bdc50e1e 100644
--- a/crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..12 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "A" 6 [email protected] "A"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
@@ -12,12 +12,12 @@ [email protected]
12 [email protected] ">" 12 [email protected] ">"
13 [email protected] ";" 13 [email protected] ";"
14 [email protected] "\n" 14 [email protected] "\n"
15 STRUCT_DEF@13..26 15 [email protected]
16 [email protected] "struct" 16 [email protected] "struct"
17 [email protected] " " 17 [email protected] " "
18 [email protected] 18 [email protected]
19 [email protected] "B" 19 [email protected] "B"
20 TYP[email protected] 20 GENERIC[email protected]
21 [email protected] "<" 21 [email protected] "<"
22 [email protected] 22 [email protected]
23 [email protected] 23 [email protected]
@@ -27,12 +27,12 @@ [email protected]
27 [email protected] ">" 27 [email protected] ">"
28 [email protected] ";" 28 [email protected] ";"
29 [email protected] "\n" 29 [email protected] "\n"
30 STRUCT_DEF@27..43 30 [email protected]
31 [email protected] "struct" 31 [email protected] "struct"
32 [email protected] " " 32 [email protected] " "
33 [email protected] 33 [email protected]
34 [email protected] "C" 34 [email protected] "C"
35 TYP[email protected] 35 GENERIC[email protected]
36 [email protected] "<" 36 [email protected] "<"
37 [email protected] 37 [email protected]
38 [email protected] 38 [email protected]
@@ -45,12 +45,12 @@ [email protected]
45 [email protected] ">" 45 [email protected] ">"
46 [email protected] ";" 46 [email protected] ";"
47 [email protected] "\n" 47 [email protected] "\n"
48 STRUCT_DEF@44..63 48 [email protected]
49 [email protected] "struct" 49 [email protected] "struct"
50 [email protected] " " 50 [email protected] " "
51 [email protected] 51 [email protected]
52 [email protected] "D" 52 [email protected] "D"
53 TYP[email protected] 53 GENERIC[email protected]
54 [email protected] "<" 54 [email protected] "<"
55 [email protected] 55 [email protected]
56 [email protected] 56 [email protected]
@@ -66,12 +66,12 @@ [email protected]
66 [email protected] ">" 66 [email protected] ">"
67 [email protected] ";" 67 [email protected] ";"
68 [email protected] "\n" 68 [email protected] "\n"
69 STRUCT_DEF@64..86 69 [email protected]
70 [email protected] "struct" 70 [email protected] "struct"
71 [email protected] " " 71 [email protected] " "
72 [email protected] 72 [email protected]
73 [email protected] "E" 73 [email protected] "E"
74 TYP[email protected] 74 GENERIC[email protected]
75 [email protected] "<" 75 [email protected] "<"
76 [email protected] 76 [email protected]
77 [email protected] 77 [email protected]
@@ -90,12 +90,12 @@ [email protected]
90 [email protected] ">" 90 [email protected] ">"
91 [email protected] ";" 91 [email protected] ";"
92 [email protected] "\n" 92 [email protected] "\n"
93 STRUCT_DEF@87..116 93 [email protected]
94 [email protected] "struct" 94 [email protected] "struct"
95 [email protected] " " 95 [email protected] " "
96 [email protected] 96 [email protected]
97 [email protected] "F" 97 [email protected] "F"
98 TYP[email protected] 98 GENERIC[email protected]
99 [email protected] "<" 99 [email protected] "<"
100 [email protected] 100 [email protected]
101 [email protected] 101 [email protected]
@@ -122,12 +122,12 @@ [email protected]
122 [email protected] ">" 122 [email protected] ">"
123 [email protected] ";" 123 [email protected] ";"
124 [email protected] "\n" 124 [email protected] "\n"
125 STRUCT_DEF@117..143 125 [email protected]
126 [email protected] "struct" 126 [email protected] "struct"
127 [email protected] " " 127 [email protected] " "
128 [email protected] 128 [email protected]
129 [email protected] "G" 129 [email protected] "G"
130 TYP[email protected] 130 GENERIC[email protected]
131 [email protected] "<" 131 [email protected] "<"
132 [email protected] 132 [email protected]
133 [email protected] 133 [email protected]
@@ -153,12 +153,12 @@ [email protected]
153 [email protected] ">" 153 [email protected] ">"
154 [email protected] ";" 154 [email protected] ";"
155 [email protected] "\n" 155 [email protected] "\n"
156 STRUCT_DEF@144..180 156 [email protected]
157 [email protected] "struct" 157 [email protected] "struct"
158 [email protected] " " 158 [email protected] " "
159 [email protected] 159 [email protected]
160 [email protected] "H" 160 [email protected] "H"
161 TYP[email protected] 161 GENERIC[email protected]
162 [email protected] "<" 162 [email protected] "<"
163 [email protected] 163 [email protected]
164 [email protected] 164 [email protected]
@@ -194,12 +194,12 @@ [email protected]
194 [email protected] ">" 194 [email protected] ">"
195 [email protected] ";" 195 [email protected] ";"
196 [email protected] "\n" 196 [email protected] "\n"
197 STRUCT_DEF@181..199 197 [email protected]
198 [email protected] "struct" 198 [email protected] "struct"
199 [email protected] " " 199 [email protected] " "
200 [email protected] 200 [email protected]
201 [email protected] "I" 201 [email protected] "I"
202 TYP[email protected] 202 GENERIC[email protected]
203 [email protected] "<" 203 [email protected] "<"
204 [email protected] 204 [email protected]
205 [email protected] 205 [email protected]
@@ -217,12 +217,12 @@ [email protected]
217 [email protected] ">" 217 [email protected] ">"
218 [email protected] ";" 218 [email protected] ";"
219 [email protected] "\n" 219 [email protected] "\n"
220 STRUCT_DEF@200..250 220 [email protected]
221 [email protected] "struct" 221 [email protected] "struct"
222 [email protected] " " 222 [email protected] " "
223 [email protected] 223 [email protected]
224 [email protected] "K" 224 [email protected] "K"
225 TYP[email protected] 225 GENERIC[email protected]
226 [email protected] "<" 226 [email protected] "<"
227 [email protected] 227 [email protected]
228 [email protected] "\'a" 228 [email protected] "\'a"
diff --git a/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast b/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast
index 873791f50..5524efaaf 100644
--- a/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..19 2 [email protected]
3 [email protected] 3 [email protected]
4 [email protected] "extern" 4 [email protected] "extern"
5 [email protected] " " 5 [email protected] " "
@@ -16,7 +16,7 @@ [email protected]
16 [email protected] "\n" 16 [email protected] "\n"
17 [email protected] "}" 17 [email protected] "}"
18 [email protected] "\n\n" 18 [email protected] "\n\n"
19 FN_DEF@21..44 19 [email protected]
20 [email protected] 20 [email protected]
21 [email protected] "extern" 21 [email protected] "extern"
22 [email protected] " " 22 [email protected] " "
@@ -35,7 +35,7 @@ [email protected]
35 [email protected] "\n" 35 [email protected] "\n"
36 [email protected] "}" 36 [email protected] "}"
37 [email protected] "\n\n" 37 [email protected] "\n\n"
38 FN_DEF@46..70 38 [email protected]
39 [email protected] 39 [email protected]
40 [email protected] "extern" 40 [email protected] "extern"
41 [email protected] " " 41 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/ok/0023_static_items.rast b/crates/ra_syntax/test_data/parser/ok/0023_static_items.rast
index 97d90dc75..9374cf5e9 100644
--- a/crates/ra_syntax/test_data/parser/ok/0023_static_items.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0023_static_items.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 STATIC_DEF@0..20 2 [email protected]
3 [email protected] "static" 3 [email protected] "static"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -18,7 +18,7 @@ [email protected]
18 [email protected] "1" 18 [email protected] "1"
19 [email protected] ";" 19 [email protected] ";"
20 [email protected] "\n" 20 [email protected] "\n"
21 STATIC_DEF@21..46 21 [email protected]
22 [email protected] "static" 22 [email protected] "static"
23 [email protected] " " 23 [email protected] " "
24 [email protected] "mut" 24 [email protected] "mut"
diff --git a/crates/ra_syntax/test_data/parser/ok/0024_const_item.rast b/crates/ra_syntax/test_data/parser/ok/0024_const_item.rast
index d241f034c..dd1b9c9a0 100644
--- a/crates/ra_syntax/test_data/parser/ok/0024_const_item.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0024_const_item.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 CONST_DEF@0..17 2 [email protected]
3 [email protected] "const" 3 [email protected] "const"
4 [email protected] " " 4 [email protected] " "
5 [email protected] "_" 5 [email protected] "_"
@@ -17,7 +17,7 @@ [email protected]
17 [email protected] "0" 17 [email protected] "0"
18 [email protected] ";" 18 [email protected] ";"
19 [email protected] "\n" 19 [email protected] "\n"
20 CONST_DEF@18..38 20 [email protected]
21 [email protected] "const" 21 [email protected] "const"
22 [email protected] " " 22 [email protected] " "
23 [email protected] 23 [email protected]
@@ -36,7 +36,7 @@ [email protected]
36 [email protected] "92" 36 [email protected] "92"
37 [email protected] ";" 37 [email protected] ";"
38 [email protected] "\n" 38 [email protected] "\n"
39 CONST_DEF@39..63 39 [email protected]
40 [email protected] "const" 40 [email protected] "const"
41 [email protected] " " 41 [email protected] " "
42 [email protected] "mut" 42 [email protected] "mut"
diff --git a/crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.rast b/crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.rast
index 5701f566e..bb6527b48 100644
--- a/crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..34 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -11,7 +11,7 @@ [email protected]
11 [email protected] 11 [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 FN_DEF@16..32 14 [email protected]
15 [email protected] 15 [email protected]
16 [email protected] "extern" 16 [email protected] "extern"
17 [email protected] " " 17 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.rast b/crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.rast
index b029d8692..5bcf54deb 100644
--- a/crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..33 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -11,7 +11,7 @@ [email protected]
11 [email protected] 11 [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 FN_DEF@16..31 14 [email protected]
15 [email protected] "const" 15 [email protected] "const"
16 [email protected] " " 16 [email protected] " "
17 [email protected] "fn" 17 [email protected] "fn"
diff --git a/crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rast b/crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rast
index 299bbd136..a7cc12295 100644
--- a/crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..52 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -11,7 +11,7 @@ [email protected]
11 [email protected] 11 [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 FN_DEF@16..32 14 [email protected]
15 [email protected] "unsafe" 15 [email protected] "unsafe"
16 [email protected] " " 16 [email protected] " "
17 [email protected] "fn" 17 [email protected] "fn"
diff --git a/crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.rast b/crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.rast
index de3c4b786..3271a4695 100644
--- a/crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..247 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 BIN[email protected] 17 IDENT[email protected]
18 [email protected] 18 [email protected]
19 [email protected] "x" 19 [email protected] "x"
20 [email protected] " " 20 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/ok/0029_range_forms.rast b/crates/ra_syntax/test_data/parser/ok/0029_range_forms.rast
index dc47d68a6..a732f11c4 100644
--- a/crates/ra_syntax/test_data/parser/ok/0029_range_forms.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0029_range_forms.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..152 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -67,7 +67,7 @@ [email protected]
67 [email protected] 67 [email protected]
68 [email protected] "let" 68 [email protected] "let"
69 [email protected] " " 69 [email protected] " "
70 BIN[email protected] 70 IDENT[email protected]
71 [email protected] 71 [email protected]
72 [email protected] "x" 72 [email protected] "x"
73 [email protected] " " 73 [email protected] " "
@@ -135,7 +135,7 @@ [email protected]
135 [email protected] 135 [email protected]
136 [email protected] "let" 136 [email protected] "let"
137 [email protected] " " 137 [email protected] " "
138 BIN[email protected] 138 IDENT[email protected]
139 [email protected] 139 [email protected]
140 [email protected] "x" 140 [email protected] "x"
141 [email protected] " " 141 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.rast b/crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.rast
index 86c3b46c4..80f7f5942 100644
--- a/crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..111 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 PLACEHOLDE[email protected] 17 WILDCARD[email protected]
18 [email protected] "_" 18 [email protected] "_"
19 [email protected] " " 19 [email protected] " "
20 [email protected] "=" 20 [email protected] "="
@@ -26,7 +26,7 @@ [email protected]
26 [email protected] 26 [email protected]
27 [email protected] "let" 27 [email protected] "let"
28 [email protected] " " 28 [email protected] " "
29 PLACEHOLDE[email protected] 29 WILDCARD[email protected]
30 [email protected] "_" 30 [email protected] "_"
31 [email protected] " " 31 [email protected] " "
32 [email protected] "=" 32 [email protected] "="
@@ -38,7 +38,7 @@ [email protected]
38 [email protected] 38 [email protected]
39 [email protected] "let" 39 [email protected] "let"
40 [email protected] " " 40 [email protected] " "
41 PLACEHOLDE[email protected] 41 WILDCARD[email protected]
42 [email protected] "_" 42 [email protected] "_"
43 [email protected] " " 43 [email protected] " "
44 [email protected] "=" 44 [email protected] "="
@@ -50,7 +50,7 @@ [email protected]
50 [email protected] 50 [email protected]
51 [email protected] "let" 51 [email protected] "let"
52 [email protected] " " 52 [email protected] " "
53 PLACEHOLDE[email protected] 53 WILDCARD[email protected]
54 [email protected] "_" 54 [email protected] "_"
55 [email protected] " " 55 [email protected] " "
56 [email protected] "=" 56 [email protected] "="
diff --git a/crates/ra_syntax/test_data/parser/ok/0030_traits.rast b/crates/ra_syntax/test_data/parser/ok/0030_traits.rast
index 0aadc11a4..d07c6683a 100644
--- a/crates/ra_syntax/test_data/parser/ok/0030_traits.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0030_traits.rast
@@ -1,14 +1,14 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..36 2 [email protected]
3 [email protected] "trait" 3 [email protected] "trait"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "Runnable" 6 [email protected] "Runnable"
7 [email protected] " " 7 [email protected] " "
8 [email protected] 8 ASSOC_[email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] "\n " 10 [email protected] "\n "
11 FN_DEF@21..34 11 [email protected]
12 [email protected] "fn" 12 [email protected] "fn"
13 [email protected] " " 13 [email protected] " "
14 [email protected] 14 [email protected]
@@ -20,16 +20,16 @@ [email protected]
20 [email protected] "\n" 20 [email protected] "\n"
21 [email protected] "}" 21 [email protected] "}"
22 [email protected] "\n\n" 22 [email protected] "\n\n"
23 TRAIT_DEF@38..95 23 [email protected]
24 [email protected] "trait" 24 [email protected] "trait"
25 [email protected] " " 25 [email protected] " "
26 [email protected] 26 [email protected]
27 [email protected] "TraitWithExpr" 27 [email protected] "TraitWithExpr"
28 [email protected] " " 28 [email protected] " "
29 [email protected] 29 ASSOC_[email protected]
30 [email protected] "{" 30 [email protected] "{"
31 [email protected] "\n " 31 [email protected] "\n "
32 FN_DEF@64..93 32 [email protected]
33 [email protected] "fn" 33 [email protected] "fn"
34 [email protected] " " 34 [email protected] " "
35 [email protected] 35 [email protected]
@@ -37,7 +37,7 @@ [email protected]
37 [email protected] 37 [email protected]
38 [email protected] "(" 38 [email protected] "("
39 [email protected] 39 [email protected]
40 BIN[email protected] 40 IDENT[email protected]
41 [email protected] 41 [email protected]
42 [email protected] "x" 42 [email protected] "x"
43 [email protected] ":" 43 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/ok/0031_extern.rast b/crates/ra_syntax/test_data/parser/ok/0031_extern.rast
index ea285f52f..8150d445f 100644
--- a/crates/ra_syntax/test_data/parser/ok/0031_extern.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0031_extern.rast
@@ -6,7 +6,7 @@ [email protected]
6 [email protected] 6 [email protected]
7 [email protected] "{" 7 [email protected] "{"
8 [email protected] "\n " 8 [email protected] "\n "
9 FN_DEF@13..87 9 [email protected]
10 [email protected] 10 [email protected]
11 [email protected] "pub" 11 [email protected] "pub"
12 [email protected] " " 12 [email protected] " "
@@ -17,7 +17,7 @@ [email protected]
17 [email protected] 17 [email protected]
18 [email protected] "(" 18 [email protected] "("
19 [email protected] 19 [email protected]
20 BIN[email protected] 20 IDENT[email protected]
21 [email protected] 21 [email protected]
22 [email protected] "domain" 22 [email protected] "domain"
23 [email protected] ":" 23 [email protected] ":"
@@ -31,7 +31,7 @@ [email protected]
31 [email protected] "," 31 [email protected] ","
32 [email protected] " " 32 [email protected] " "
33 [email protected] 33 [email protected]
34 BIN[email protected] 34 IDENT[email protected]
35 [email protected] 35 [email protected]
36 [email protected] "ty" 36 [email protected] "ty"
37 [email protected] ":" 37 [email protected] ":"
@@ -45,7 +45,7 @@ [email protected]
45 [email protected] "," 45 [email protected] ","
46 [email protected] " " 46 [email protected] " "
47 [email protected] 47 [email protected]
48 BIN[email protected] 48 IDENT[email protected]
49 [email protected] 49 [email protected]
50 [email protected] "protocol" 50 [email protected] "protocol"
51 [email protected] ":" 51 [email protected] ":"
@@ -69,7 +69,7 @@ [email protected]
69 [email protected] "c_int" 69 [email protected] "c_int"
70 [email protected] ";" 70 [email protected] ";"
71 [email protected] "\n " 71 [email protected] "\n "
72 FN_DEF@92..167 72 [email protected]
73 [email protected] 73 [email protected]
74 [email protected] "pub" 74 [email protected] "pub"
75 [email protected] " " 75 [email protected] " "
@@ -80,7 +80,7 @@ [email protected]
80 [email protected] 80 [email protected]
81 [email protected] "(" 81 [email protected] "("
82 [email protected] 82 [email protected]
83 BIN[email protected] 83 IDENT[email protected]
84 [email protected] 84 [email protected]
85 [email protected] "fd" 85 [email protected] "fd"
86 [email protected] ":" 86 [email protected] ":"
@@ -94,12 +94,12 @@ [email protected]
94 [email protected] "," 94 [email protected] ","
95 [email protected] " " 95 [email protected] " "
96 [email protected] 96 [email protected]
97 BIN[email protected] 97 IDENT[email protected]
98 [email protected] 98 [email protected]
99 [email protected] "addr" 99 [email protected] "addr"
100 [email protected] ":" 100 [email protected] ":"
101 [email protected] " " 101 [email protected] " "
102 POINTE[email protected] 102 [email protected]
103 [email protected] "*" 103 [email protected] "*"
104 [email protected] "const" 104 [email protected] "const"
105 [email protected] " " 105 [email protected] " "
@@ -111,7 +111,7 @@ [email protected]
111 [email protected] "," 111 [email protected] ","
112 [email protected] " " 112 [email protected] " "
113 [email protected] 113 [email protected]
114 BIN[email protected] 114 IDENT[email protected]
115 [email protected] 115 [email protected]
116 [email protected] "len" 116 [email protected] "len"
117 [email protected] ":" 117 [email protected] ":"
@@ -134,7 +134,7 @@ [email protected]
134 [email protected] "c_int" 134 [email protected] "c_int"
135 [email protected] ";" 135 [email protected] ";"
136 [email protected] "\n " 136 [email protected] "\n "
137 FN_DEF@172..276 137 [email protected]
138 [email protected] 138 [email protected]
139 [email protected] "pub" 139 [email protected] "pub"
140 [email protected] " " 140 [email protected] " "
@@ -145,7 +145,7 @@ [email protected]
145 [email protected] 145 [email protected]
146 [email protected] "(" 146 [email protected] "("
147 [email protected] 147 [email protected]
148 BIN[email protected] 148 IDENT[email protected]
149 [email protected] 149 [email protected]
150 [email protected] "socket" 150 [email protected] "socket"
151 [email protected] ":" 151 [email protected] ":"
@@ -159,12 +159,12 @@ [email protected]
159 [email protected] "," 159 [email protected] ","
160 [email protected] " " 160 [email protected] " "
161 [email protected] 161 [email protected]
162 BIN[email protected] 162 IDENT[email protected]
163 [email protected] 163 [email protected]
164 [email protected] "address" 164 [email protected] "address"
165 [email protected] ":" 165 [email protected] ":"
166 [email protected] " " 166 [email protected] " "
167 POINTE[email protected] 167 [email protected]
168 [email protected] "*" 168 [email protected] "*"
169 [email protected] "const" 169 [email protected] "const"
170 [email protected] " " 170 [email protected] " "
@@ -176,7 +176,7 @@ [email protected]
176 [email protected] "," 176 [email protected] ","
177 [email protected] "\n " 177 [email protected] "\n "
178 [email protected] 178 [email protected]
179 BIN[email protected] 179 IDENT[email protected]
180 [email protected] 180 [email protected]
181 [email protected] "len" 181 [email protected] "len"
182 [email protected] ":" 182 [email protected] ":"
@@ -199,7 +199,7 @@ [email protected]
199 [email protected] "c_int" 199 [email protected] "c_int"
200 [email protected] ";" 200 [email protected] ";"
201 [email protected] "\n " 201 [email protected] "\n "
202 FN_DEF@281..341 202 [email protected]
203 [email protected] 203 [email protected]
204 [email protected] "pub" 204 [email protected] "pub"
205 [email protected] " " 205 [email protected] " "
@@ -210,7 +210,7 @@ [email protected]
210 [email protected] 210 [email protected]
211 [email protected] "(" 211 [email protected] "("
212 [email protected] 212 [email protected]
213 BIN[email protected] 213 IDENT[email protected]
214 [email protected] 214 [email protected]
215 [email protected] "socket" 215 [email protected] "socket"
216 [email protected] ":" 216 [email protected] ":"
@@ -224,7 +224,7 @@ [email protected]
224 [email protected] "," 224 [email protected] ","
225 [email protected] " " 225 [email protected] " "
226 [email protected] 226 [email protected]
227 BIN[email protected] 227 IDENT[email protected]
228 [email protected] 228 [email protected]
229 [email protected] "backlog" 229 [email protected] "backlog"
230 [email protected] ":" 230 [email protected] ":"
@@ -248,7 +248,7 @@ [email protected]
248 [email protected] "c_int" 248 [email protected] "c_int"
249 [email protected] ";" 249 [email protected] ";"
250 [email protected] "\n " 250 [email protected] "\n "
251 FN_DEF@346..469 251 [email protected]
252 [email protected] 252 [email protected]
253 [email protected] "pub" 253 [email protected] "pub"
254 [email protected] " " 254 [email protected] " "
@@ -259,7 +259,7 @@ [email protected]
259 [email protected] 259 [email protected]
260 [email protected] "(" 260 [email protected] "("
261 [email protected] 261 [email protected]
262 BIN[email protected] 262 IDENT[email protected]
263 [email protected] 263 [email protected]
264 [email protected] "socket" 264 [email protected] "socket"
265 [email protected] ":" 265 [email protected] ":"
@@ -273,12 +273,12 @@ [email protected]
273 [email protected] "," 273 [email protected] ","
274 [email protected] " " 274 [email protected] " "
275 [email protected] 275 [email protected]
276 BIN[email protected] 276 IDENT[email protected]
277 [email protected] 277 [email protected]
278 [email protected] "address" 278 [email protected] "address"
279 [email protected] ":" 279 [email protected] ":"
280 [email protected] " " 280 [email protected] " "
281 POINTE[email protected] 281 [email protected]
282 [email protected] "*" 282 [email protected] "*"
283 [email protected] "mut" 283 [email protected] "mut"
284 [email protected] " " 284 [email protected] " "
@@ -290,12 +290,12 @@ [email protected]
290 [email protected] "," 290 [email protected] ","
291 [email protected] "\n " 291 [email protected] "\n "
292 [email protected] 292 [email protected]
293 BIN[email protected] 293 IDENT[email protected]
294 [email protected] 294 [email protected]
295 [email protected] "address_len" 295 [email protected] "address_len"
296 [email protected] ":" 296 [email protected] ":"
297 [email protected] " " 297 [email protected] " "
298 POINTE[email protected] 298 [email protected]
299 [email protected] "*" 299 [email protected] "*"
300 [email protected] "mut" 300 [email protected] "mut"
301 [email protected] " " 301 [email protected] " "
@@ -317,7 +317,7 @@ [email protected]
317 [email protected] "c_int" 317 [email protected] "c_int"
318 [email protected] ";" 318 [email protected] ";"
319 [email protected] "\n " 319 [email protected] "\n "
320 FN_DEF@474..691 320 [email protected]
321 [email protected] 321 [email protected]
322 [email protected] "pub" 322 [email protected] "pub"
323 [email protected] " " 323 [email protected] " "
@@ -328,7 +328,7 @@ [email protected]
328 [email protected] 328 [email protected]
329 [email protected] "(" 329 [email protected] "("
330 [email protected] 330 [email protected]
331 BIN[email protected] 331 IDENT[email protected]
332 [email protected] 332 [email protected]
333 [email protected] "sockfd" 333 [email protected] "sockfd"
334 [email protected] ":" 334 [email protected] ":"
@@ -342,7 +342,7 @@ [email protected]
342 [email protected] "," 342 [email protected] ","
343 [email protected] "\n " 343 [email protected] "\n "
344 [email protected] 344 [email protected]
345 BIN[email protected] 345 IDENT[email protected]
346 [email protected] 346 [email protected]
347 [email protected] "level" 347 [email protected] "level"
348 [email protected] ":" 348 [email protected] ":"
@@ -356,7 +356,7 @@ [email protected]
356 [email protected] "," 356 [email protected] ","
357 [email protected] "\n " 357 [email protected] "\n "
358 [email protected] 358 [email protected]
359 BIN[email protected] 359 IDENT[email protected]
360 [email protected] 360 [email protected]
361 [email protected] "optname" 361 [email protected] "optname"
362 [email protected] ":" 362 [email protected] ":"
@@ -370,12 +370,12 @@ [email protected]
370 [email protected] "," 370 [email protected] ","
371 [email protected] "\n " 371 [email protected] "\n "
372 [email protected] 372 [email protected]
373 BIN[email protected] 373 IDENT[email protected]
374 [email protected] 374 [email protected]
375 [email protected] "optval" 375 [email protected] "optval"
376 [email protected] ":" 376 [email protected] ":"
377 [email protected] " " 377 [email protected] " "
378 POINTE[email protected] 378 [email protected]
379 [email protected] "*" 379 [email protected] "*"
380 [email protected] "mut" 380 [email protected] "mut"
381 [email protected] " " 381 [email protected] " "
@@ -388,12 +388,12 @@ [email protected]
388 [email protected] "," 388 [email protected] ","
389 [email protected] "\n " 389 [email protected] "\n "
390 [email protected] 390 [email protected]
391 BIN[email protected] 391 IDENT[email protected]
392 [email protected] 392 [email protected]
393 [email protected] "optlen" 393 [email protected] "optlen"
394 [email protected] ":" 394 [email protected] ":"
395 [email protected] " " 395 [email protected] " "
396 POINTE[email protected] 396 [email protected]
397 [email protected] "*" 397 [email protected] "*"
398 [email protected] "mut" 398 [email protected] "mut"
399 [email protected] " " 399 [email protected] " "
@@ -416,7 +416,7 @@ [email protected]
416 [email protected] "c_int" 416 [email protected] "c_int"
417 [email protected] ";" 417 [email protected] ";"
418 [email protected] "\n " 418 [email protected] "\n "
419 FN_DEF@696..864 419 [email protected]
420 [email protected] 420 [email protected]
421 [email protected] "pub" 421 [email protected] "pub"
422 [email protected] " " 422 [email protected] " "
@@ -427,7 +427,7 @@ [email protected]
427 [email protected] 427 [email protected]
428 [email protected] "(" 428 [email protected] "("
429 [email protected] 429 [email protected]
430 BIN[email protected] 430 IDENT[email protected]
431 [email protected] 431 [email protected]
432 [email protected] "socket" 432 [email protected] "socket"
433 [email protected] ":" 433 [email protected] ":"
@@ -441,7 +441,7 @@ [email protected]
441 [email protected] "," 441 [email protected] ","
442 [email protected] " " 442 [email protected] " "
443 [email protected] 443 [email protected]
444 BIN[email protected] 444 IDENT[email protected]
445 [email protected] 445 [email protected]
446 [email protected] "level" 446 [email protected] "level"
447 [email protected] ":" 447 [email protected] ":"
@@ -455,7 +455,7 @@ [email protected]
455 [email protected] "," 455 [email protected] ","
456 [email protected] " " 456 [email protected] " "
457 [email protected] 457 [email protected]
458 BIN[email protected] 458 IDENT[email protected]
459 [email protected] 459 [email protected]
460 [email protected] "name" 460 [email protected] "name"
461 [email protected] ":" 461 [email protected] ":"
@@ -469,12 +469,12 @@ [email protected]
469 [email protected] "," 469 [email protected] ","
470 [email protected] "\n " 470 [email protected] "\n "
471 [email protected] 471 [email protected]
472 BIN[email protected] 472 IDENT[email protected]
473 [email protected] 473 [email protected]
474 [email protected] "value" 474 [email protected] "value"
475 [email protected] ":" 475 [email protected] ":"
476 [email protected] " " 476 [email protected] " "
477 POINTE[email protected] 477 [email protected]
478 [email protected] "*" 478 [email protected] "*"
479 [email protected] "const" 479 [email protected] "const"
480 [email protected] " " 480 [email protected] " "
@@ -487,7 +487,7 @@ [email protected]
487 [email protected] "," 487 [email protected] ","
488 [email protected] "\n " 488 [email protected] "\n "
489 [email protected] 489 [email protected]
490 BIN[email protected] 490 IDENT[email protected]
491 [email protected] 491 [email protected]
492 [email protected] "option_len" 492 [email protected] "option_len"
493 [email protected] ":" 493 [email protected] ":"
@@ -510,7 +510,7 @@ [email protected]
510 [email protected] "c_int" 510 [email protected] "c_int"
511 [email protected] ";" 511 [email protected] ";"
512 [email protected] "\n " 512 [email protected] "\n "
513 FN_DEF@869..992 513 [email protected]
514 [email protected] 514 [email protected]
515 [email protected] "pub" 515 [email protected] "pub"
516 [email protected] " " 516 [email protected] " "
@@ -521,7 +521,7 @@ [email protected]
521 [email protected] 521 [email protected]
522 [email protected] "(" 522 [email protected] "("
523 [email protected] 523 [email protected]
524 BIN[email protected] 524 IDENT[email protected]
525 [email protected] 525 [email protected]
526 [email protected] "socket" 526 [email protected] "socket"
527 [email protected] ":" 527 [email protected] ":"
@@ -535,12 +535,12 @@ [email protected]
535 [email protected] "," 535 [email protected] ","
536 [email protected] " " 536 [email protected] " "
537 [email protected] 537 [email protected]
538 BIN[email protected] 538 IDENT[email protected]
539 [email protected] 539 [email protected]
540 [email protected] "address" 540 [email protected] "address"
541 [email protected] ":" 541 [email protected] ":"
542 [email protected] " " 542 [email protected] " "
543 POINTE[email protected] 543 [email protected]
544 [email protected] "*" 544 [email protected] "*"
545 [email protected] "mut" 545 [email protected] "mut"
546 [email protected] " " 546 [email protected] " "
@@ -552,12 +552,12 @@ [email protected]
552 [email protected] "," 552 [email protected] ","
553 [email protected] "\n " 553 [email protected] "\n "
554 [email protected] 554 [email protected]
555 BIN[email protected] 555 IDENT[email protected]
556 [email protected] 556 [email protected]
557 [email protected] "address_len" 557 [email protected] "address_len"
558 [email protected] ":" 558 [email protected] ":"
559 [email protected] " " 559 [email protected] " "
560 POINTE[email protected] 560 [email protected]
561 [email protected] "*" 561 [email protected] "*"
562 [email protected] "mut" 562 [email protected] "mut"
563 [email protected] " " 563 [email protected] " "
@@ -579,7 +579,7 @@ [email protected]
579 [email protected] "c_int" 579 [email protected] "c_int"
580 [email protected] ";" 580 [email protected] ";"
581 [email protected] "\n " 581 [email protected] "\n "
582 FN_DEF@997..1173 582 [email protected]
583 [email protected] 583 [email protected]
584 [email protected] "pub" 584 [email protected] "pub"
585 [email protected] " " 585 [email protected] " "
@@ -590,7 +590,7 @@ [email protected]
590 [email protected] 590 [email protected]
591 [email protected] "(" 591 [email protected] "("
592 [email protected] 592 [email protected]
593 BIN[email protected] 593 IDENT[email protected]
594 [email protected] 594 [email protected]
595 [email protected] "socket" 595 [email protected] "socket"
596 [email protected] ":" 596 [email protected] ":"
@@ -604,12 +604,12 @@ [email protected]
604 [email protected] "," 604 [email protected] ","
605 [email protected] " " 605 [email protected] " "
606 [email protected] 606 [email protected]
607 BIN[email protected] 607 IDENT[email protected]
608 [email protected] 608 [email protected]
609 [email protected] "buf" 609 [email protected] "buf"
610 [email protected] ":" 610 [email protected] ":"
611 [email protected] " " 611 [email protected] " "
612 POINTE[email protected] 612 [email protected]
613 [email protected] "*" 613 [email protected] "*"
614 [email protected] "const" 614 [email protected] "const"
615 [email protected] " " 615 [email protected] " "
@@ -622,7 +622,7 @@ [email protected]
622 [email protected] "," 622 [email protected] ","
623 [email protected] " " 623 [email protected] " "
624 [email protected] 624 [email protected]
625 BIN[email protected] 625 IDENT[email protected]
626 [email protected] 626 [email protected]
627 [email protected] "len" 627 [email protected] "len"
628 [email protected] ":" 628 [email protected] ":"
@@ -636,7 +636,7 @@ [email protected]
636 [email protected] "," 636 [email protected] ","
637 [email protected] "\n " 637 [email protected] "\n "
638 [email protected] 638 [email protected]
639 BIN[email protected] 639 IDENT[email protected]
640 [email protected] 640 [email protected]
641 [email protected] "flags" 641 [email protected] "flags"
642 [email protected] ":" 642 [email protected] ":"
@@ -650,12 +650,12 @@ [email protected]
650 [email protected] "," 650 [email protected] ","
651 [email protected] " " 651 [email protected] " "
652 [email protected] 652 [email protected]
653 BIN[email protected] 653 IDENT[email protected]
654 [email protected] 654 [email protected]
655 [email protected] "addr" 655 [email protected] "addr"
656 [email protected] ":" 656 [email protected] ":"
657 [email protected] " " 657 [email protected] " "
658 POINTE[email protected] 658 [email protected]
659 [email protected] "*" 659 [email protected] "*"
660 [email protected] "const" 660 [email protected] "const"
661 [email protected] " " 661 [email protected] " "
@@ -667,7 +667,7 @@ [email protected]
667 [email protected] "," 667 [email protected] ","
668 [email protected] "\n " 668 [email protected] "\n "
669 [email protected] 669 [email protected]
670 BIN[email protected] 670 IDENT[email protected]
671 [email protected] 671 [email protected]
672 [email protected] "addrlen" 672 [email protected] "addrlen"
673 [email protected] ":" 673 [email protected] ":"
@@ -690,7 +690,7 @@ [email protected]
690 [email protected] "ssize_t" 690 [email protected] "ssize_t"
691 [email protected] ";" 691 [email protected] ";"
692 [email protected] "\n " 692 [email protected] "\n "
693 FN_DEF@1178..1289 693 [email protected]
694 [email protected] 694 [email protected]
695 [email protected] "pub" 695 [email protected] "pub"
696 [email protected] " " 696 [email protected] " "
@@ -701,7 +701,7 @@ [email protected]
701 [email protected] 701 [email protected]
702 [email protected] "(" 702 [email protected] "("
703 [email protected] 703 [email protected]
704 BIN[email protected] 704 IDENT[email protected]
705 [email protected] 705 [email protected]
706 [email protected] "socket" 706 [email protected] "socket"
707 [email protected] ":" 707 [email protected] ":"
@@ -715,12 +715,12 @@ [email protected]
715 [email protected] "," 715 [email protected] ","
716 [email protected] " " 716 [email protected] " "
717 [email protected] 717 [email protected]
718 BIN[email protected] 718 IDENT[email protected]
719 [email protected] 719 [email protected]
720 [email protected] "buf" 720 [email protected] "buf"
721 [email protected] ":" 721 [email protected] ":"
722 [email protected] " " 722 [email protected] " "
723 POINTE[email protected] 723 [email protected]
724 [email protected] "*" 724 [email protected] "*"
725 [email protected] "const" 725 [email protected] "const"
726 [email protected] " " 726 [email protected] " "
@@ -733,7 +733,7 @@ [email protected]
733 [email protected] "," 733 [email protected] ","
734 [email protected] " " 734 [email protected] " "
735 [email protected] 735 [email protected]
736 BIN[email protected] 736 IDENT[email protected]
737 [email protected] 737 [email protected]
738 [email protected] "len" 738 [email protected] "len"
739 [email protected] ":" 739 [email protected] ":"
@@ -747,7 +747,7 @@ [email protected]
747 [email protected] "," 747 [email protected] ","
748 [email protected] "\n " 748 [email protected] "\n "
749 [email protected] 749 [email protected]
750 BIN[email protected] 750 IDENT[email protected]
751 [email protected] 751 [email protected]
752 [email protected] "flags" 752 [email protected] "flags"
753 [email protected] ":" 753 [email protected] ":"
@@ -771,7 +771,7 @@ [email protected]
771 [email protected] "ssize_t" 771 [email protected] "ssize_t"
772 [email protected] ";" 772 [email protected] ";"
773 [email protected] "\n " 773 [email protected] "\n "
774 FN_DEF@1294..1481 774 [email protected]
775 [email protected] 775 [email protected]
776 [email protected] "pub" 776 [email protected] "pub"
777 [email protected] " " 777 [email protected] " "
@@ -782,7 +782,7 @@ [email protected]
782 [email protected] 782 [email protected]
783 [email protected] "(" 783 [email protected] "("
784 [email protected] 784 [email protected]
785 BIN[email protected] 785 IDENT[email protected]
786 [email protected] 786 [email protected]
787 [email protected] "socket" 787 [email protected] "socket"
788 [email protected] ":" 788 [email protected] ":"
@@ -796,12 +796,12 @@ [email protected]
796 [email protected] "," 796 [email protected] ","
797 [email protected] " " 797 [email protected] " "
798 [email protected] 798 [email protected]
799 BIN[email protected] 799 IDENT[email protected]
800 [email protected] 800 [email protected]
801 [email protected] "buf" 801 [email protected] "buf"
802 [email protected] ":" 802 [email protected] ":"
803 [email protected] " " 803 [email protected] " "
804 POINTE[email protected] 804 [email protected]
805 [email protected] "*" 805 [email protected] "*"
806 [email protected] "mut" 806 [email protected] "mut"
807 [email protected] " " 807 [email protected] " "
@@ -814,7 +814,7 @@ [email protected]
814 [email protected] "," 814 [email protected] ","
815 [email protected] " " 815 [email protected] " "
816 [email protected] 816 [email protected]
817 BIN[email protected] 817 IDENT[email protected]
818 [email protected] 818 [email protected]
819 [email protected] "len" 819 [email protected] "len"
820 [email protected] ":" 820 [email protected] ":"
@@ -828,7 +828,7 @@ [email protected]
828 [email protected] "," 828 [email protected] ","
829 [email protected] "\n " 829 [email protected] "\n "
830 [email protected] 830 [email protected]
831 BIN[email protected] 831 IDENT[email protected]
832 [email protected] 832 [email protected]
833 [email protected] "flags" 833 [email protected] "flags"
834 [email protected] ":" 834 [email protected] ":"
@@ -842,12 +842,12 @@ [email protected]
842 [email protected] "," 842 [email protected] ","
843 [email protected] " " 843 [email protected] " "
844 [email protected] 844 [email protected]
845 BIN[email protected] 845 IDENT[email protected]
846 [email protected] 846 [email protected]
847 [email protected] "addr" 847 [email protected] "addr"
848 [email protected] ":" 848 [email protected] ":"
849 [email protected] " " 849 [email protected] " "
850 POINTE[email protected] 850 [email protected]
851 [email protected] "*" 851 [email protected] "*"
852 [email protected] "mut" 852 [email protected] "mut"
853 [email protected] " " 853 [email protected] " "
@@ -860,12 +860,12 @@ [email protected]
860 [email protected] "," 860 [email protected] ","
861 [email protected] "\n " 861 [email protected] "\n "
862 [email protected] 862 [email protected]
863 BIN[email protected] 863 IDENT[email protected]
864 [email protected] 864 [email protected]
865 [email protected] "addrlen" 865 [email protected] "addrlen"
866 [email protected] ":" 866 [email protected] ":"
867 [email protected] " " 867 [email protected] " "
868 POINTE[email protected] 868 [email protected]
869 [email protected] "*" 869 [email protected] "*"
870 [email protected] "mut" 870 [email protected] "mut"
871 [email protected] " " 871 [email protected] " "
@@ -888,7 +888,7 @@ [email protected]
888 [email protected] "ssize_t" 888 [email protected] "ssize_t"
889 [email protected] ";" 889 [email protected] ";"
890 [email protected] "\n " 890 [email protected] "\n "
891 FN_DEF@1486..1595 891 [email protected]
892 [email protected] 892 [email protected]
893 [email protected] "pub" 893 [email protected] "pub"
894 [email protected] " " 894 [email protected] " "
@@ -899,7 +899,7 @@ [email protected]
899 [email protected] 899 [email protected]
900 [email protected] "(" 900 [email protected] "("
901 [email protected] 901 [email protected]
902 BIN[email protected] 902 IDENT[email protected]
903 [email protected] 903 [email protected]
904 [email protected] "socket" 904 [email protected] "socket"
905 [email protected] ":" 905 [email protected] ":"
@@ -913,12 +913,12 @@ [email protected]
913 [email protected] "," 913 [email protected] ","
914 [email protected] " " 914 [email protected] " "
915 [email protected] 915 [email protected]
916 BIN[email protected] 916 IDENT[email protected]
917 [email protected] 917 [email protected]
918 [email protected] "buf" 918 [email protected] "buf"
919 [email protected] ":" 919 [email protected] ":"
920 [email protected] " " 920 [email protected] " "
921 POINTE[email protected] 921 [email protected]
922 [email protected] "*" 922 [email protected] "*"
923 [email protected] "mut" 923 [email protected] "mut"
924 [email protected] " " 924 [email protected] " "
@@ -931,7 +931,7 @@ [email protected]
931 [email protected] "," 931 [email protected] ","
932 [email protected] " " 932 [email protected] " "
933 [email protected] 933 [email protected]
934 BIN[email protected] 934 IDENT[email protected]
935 [email protected] 935 [email protected]
936 [email protected] "len" 936 [email protected] "len"
937 [email protected] ":" 937 [email protected] ":"
@@ -945,7 +945,7 @@ [email protected]
945 [email protected] "," 945 [email protected] ","
946 [email protected] "\n " 946 [email protected] "\n "
947 [email protected] 947 [email protected]
948 BIN[email protected] 948 IDENT[email protected]
949 [email protected] 949 [email protected]
950 [email protected] "flags" 950 [email protected] "flags"
951 [email protected] ":" 951 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/ok/0032_where_for.rast b/crates/ra_syntax/test_data/parser/ok/0032_where_for.rast
index 8d76c4e0b..d59548f21 100644
--- a/crates/ra_syntax/test_data/parser/ok/0032_where_for.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0032_where_for.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 FN_DEF@0..115 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "test_serialization" 6 [email protected] "test_serialization"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
@@ -38,7 +38,7 @@ [email protected]
38 [email protected] 38 [email protected]
39 [email protected] 39 [email protected]
40 [email protected] "for" 40 [email protected] "for"
41 TYP[email protected] 41 GENERIC[email protected]
42 [email protected] "<" 42 [email protected] "<"
43 [email protected] 43 [email protected]
44 [email protected] "\'de" 44 [email protected] "\'de"
@@ -49,7 +49,7 @@ [email protected]
49 [email protected] 49 [email protected]
50 [email protected] 50 [email protected]
51 [email protected] "Deserialize" 51 [email protected] "Deserialize"
52 TYP[email protected] 52 GENERIC[email protected]
53 [email protected] "<" 53 [email protected] "<"
54 [email protected] 54 [email protected]
55 [email protected] "\'de" 55 [email protected] "\'de"
diff --git a/crates/ra_syntax/test_data/parser/ok/0033_label_break.rast b/crates/ra_syntax/test_data/parser/ok/0033_label_break.rast
index 13b730ded..88800ca7a 100644
--- a/crates/ra_syntax/test_data/parser/ok/0033_label_break.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0033_label_break.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..505 2 [email protected]
3 [email protected] "// format with label ..." 3 [email protected] "// format with label ..."
4 [email protected] "\n" 4 [email protected] "\n"
5 [email protected] "fn" 5 [email protected] "fn"
@@ -127,7 +127,7 @@ [email protected]
127 [email protected] 127 [email protected]
128 [email protected] "let" 128 [email protected] "let"
129 [email protected] " " 129 [email protected] " "
130 BIN[email protected] 130 IDENT[email protected]
131 [email protected] 131 [email protected]
132 [email protected] "result" 132 [email protected] "result"
133 [email protected] " " 133 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.rast b/crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.rast
index 21874ae3a..5ad8c570d 100644
--- a/crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..61 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast b/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast
index eb59d6e17..7c61b5006 100644
--- a/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast
@@ -78,7 +78,7 @@ [email protected]
78 [email protected] "\"128\"" 78 [email protected] "\"128\""
79 [email protected] "]" 79 [email protected] "]"
80 [email protected] "\n\n" 80 [email protected] "\n\n"
81 USE_ITEM@407..427 81 [email protected]
82 [email protected] "use" 82 [email protected] "use"
83 [email protected] " " 83 [email protected] " "
84 [email protected] 84 [email protected]
@@ -98,7 +98,7 @@ [email protected]
98 [email protected] "Cell" 98 [email protected] "Cell"
99 [email protected] ";" 99 [email protected] ";"
100 [email protected] "\n" 100 [email protected] "\n"
101 USE_ITEM@428..447 101 [email protected]
102 [email protected] "use" 102 [email protected] "use"
103 [email protected] " " 103 [email protected] " "
104 [email protected] 104 [email protected]
@@ -120,7 +120,7 @@ [email protected]
120 [email protected] "\n\n" 120 [email protected] "\n\n"
121 [email protected] "// Just a grab bag of ..." 121 [email protected] "// Just a grab bag of ..."
122 [email protected] "\n\n" 122 [email protected] "\n\n"
123 FN_DEF@520..572 123 [email protected]
124 [email protected] "fn" 124 [email protected] "fn"
125 [email protected] " " 125 [email protected] " "
126 [email protected] 126 [email protected]
@@ -144,7 +144,7 @@ [email protected]
144 [email protected] 144 [email protected]
145 [email protected] "let" 145 [email protected] "let"
146 [email protected] " " 146 [email protected] " "
147 BIN[email protected] 147 IDENT[email protected]
148 [email protected] 148 [email protected]
149 [email protected] "_x" 149 [email protected] "_x"
150 [email protected] ":" 150 [email protected] ":"
@@ -166,7 +166,7 @@ [email protected]
166 [email protected] " " 166 [email protected] " "
167 [email protected] "}" 167 [email protected] "}"
168 [email protected] "\n\n" 168 [email protected] "\n\n"
169 FN_DEF@574..624 169 [email protected]
170 [email protected] "fn" 170 [email protected] "fn"
171 [email protected] " " 171 [email protected] " "
172 [email protected] 172 [email protected]
@@ -178,7 +178,7 @@ [email protected]
178 [email protected] 178 [email protected]
179 [email protected] "{" 179 [email protected] "{"
180 [email protected] "\n " 180 [email protected] "\n "
181 FN_DEF@591..607 181 [email protected]
182 [email protected] "fn" 182 [email protected] "fn"
183 [email protected] " " 183 [email protected] " "
184 [email protected] 184 [email protected]
@@ -186,7 +186,7 @@ [email protected]
186 [email protected] 186 [email protected]
187 [email protected] "(" 187 [email protected] "("
188 [email protected] 188 [email protected]
189 BIN[email protected] 189 IDENT[email protected]
190 [email protected] 190 [email protected]
191 [email protected] "_x" 191 [email protected] "_x"
192 [email protected] ":" 192 [email protected] ":"
@@ -217,7 +217,7 @@ [email protected]
217 [email protected] "\n" 217 [email protected] "\n"
218 [email protected] "}" 218 [email protected] "}"
219 [email protected] "\n\n" 219 [email protected] "\n\n"
220 FN_DEF@626..816 220 [email protected]
221 [email protected] "fn" 221 [email protected] "fn"
222 [email protected] " " 222 [email protected] " "
223 [email protected] 223 [email protected]
@@ -229,7 +229,7 @@ [email protected]
229 [email protected] 229 [email protected]
230 [email protected] "{" 230 [email protected] "{"
231 [email protected] "\n " 231 [email protected] "\n "
232 FN_DEF@642..720 232 [email protected]
233 [email protected] "fn" 233 [email protected] "fn"
234 [email protected] " " 234 [email protected] " "
235 [email protected] 235 [email protected]
@@ -237,19 +237,19 @@ [email protected]
237 [email protected] 237 [email protected]
238 [email protected] "(" 238 [email protected] "("
239 [email protected] 239 [email protected]
240 BIN[email protected] 240 IDENT[email protected]
241 [email protected] 241 [email protected]
242 [email protected] "x" 242 [email protected] "x"
243 [email protected] ":" 243 [email protected] ":"
244 [email protected] " " 244 [email protected] " "
245 REFERENCE[email protected] 245 [email protected]
246 [email protected] "&" 246 [email protected] "&"
247 [email protected] 247 [email protected]
248 [email protected] 248 [email protected]
249 [email protected] 249 [email protected]
250 [email protected] 250 [email protected]
251 [email protected] "Cell" 251 [email protected] "Cell"
252 TYP[email protected] 252 GENERIC[email protected]
253 [email protected] "<" 253 [email protected] "<"
254 [email protected] 254 [email protected]
255 [email protected] 255 [email protected]
@@ -314,7 +314,7 @@ [email protected]
314 [email protected] 314 [email protected]
315 [email protected] "let" 315 [email protected] "let"
316 [email protected] " " 316 [email protected] " "
317 BIN[email protected] 317 IDENT[email protected]
318 [email protected] 318 [email protected]
319 [email protected] "i" 319 [email protected] "i"
320 [email protected] " " 320 [email protected] " "
@@ -343,7 +343,7 @@ [email protected]
343 [email protected] 343 [email protected]
344 [email protected] "let" 344 [email protected] "let"
345 [email protected] " " 345 [email protected] " "
346 BIN[email protected] 346 IDENT[email protected]
347 [email protected] 347 [email protected]
348 [email protected] "dont" 348 [email protected] "dont"
349 [email protected] " " 349 [email protected] " "
@@ -351,7 +351,7 @@ [email protected]
351 [email protected] " " 351 [email protected] " "
352 [email protected] 352 [email protected]
353 [email protected] "{" 353 [email protected] "{"
354 LAMBDA[email protected] 354 CLOSURE[email protected]
355 [email protected] 355 [email protected]
356 [email protected] "|" 356 [email protected] "|"
357 [email protected] "|" 357 [email protected] "|"
@@ -407,7 +407,7 @@ [email protected]
407 [email protected] "\n" 407 [email protected] "\n"
408 [email protected] "}" 408 [email protected] "}"
409 [email protected] "\n\n" 409 [email protected] "\n\n"
410 FN_DEF@818..1322 410 [email protected]
411 [email protected] "fn" 411 [email protected] "fn"
412 [email protected] " " 412 [email protected] " "
413 [email protected] 413 [email protected]
@@ -506,7 +506,7 @@ [email protected]
506 [email protected] "}" 506 [email protected] "}"
507 [email protected] "\n " 507 [email protected] "\n "
508 [email protected] 508 [email protected]
509 PLACEHOLDE[email protected] 509 WILDCARD[email protected]
510 [email protected] "_" 510 [email protected] "_"
511 [email protected] " " 511 [email protected] " "
512 [email protected] "=>" 512 [email protected] "=>"
@@ -572,7 +572,7 @@ [email protected]
572 [email protected] "\n" 572 [email protected] "\n"
573 [email protected] "}" 573 [email protected] "}"
574 [email protected] "\n\n" 574 [email protected] "\n\n"
575 FN_DEF@1324..1539 575 [email protected]
576 [email protected] "fn" 576 [email protected] "fn"
577 [email protected] " " 577 [email protected] " "
578 [email protected] 578 [email protected]
@@ -587,7 +587,7 @@ [email protected]
587 [email protected] 587 [email protected]
588 [email protected] "let" 588 [email protected] "let"
589 [email protected] " " 589 [email protected] " "
590 BIN[email protected] 590 IDENT[email protected]
591 [email protected] "mut" 591 [email protected] "mut"
592 [email protected] " " 592 [email protected] " "
593 [email protected] 593 [email protected]
@@ -604,7 +604,7 @@ [email protected]
604 [email protected] 604 [email protected]
605 [email protected] "let" 605 [email protected] "let"
606 [email protected] " " 606 [email protected] " "
607 BIN[email protected] 607 IDENT[email protected]
608 [email protected] "mut" 608 [email protected] "mut"
609 [email protected] " " 609 [email protected] " "
610 [email protected] 610 [email protected]
@@ -649,7 +649,7 @@ [email protected]
649 [email protected] 649 [email protected]
650 [email protected] "let" 650 [email protected] "let"
651 [email protected] " " 651 [email protected] " "
652 BIN[email protected] 652 IDENT[email protected]
653 [email protected] "mut" 653 [email protected] "mut"
654 [email protected] " " 654 [email protected] " "
655 [email protected] 655 [email protected]
@@ -694,7 +694,7 @@ [email protected]
694 [email protected] 694 [email protected]
695 [email protected] "let" 695 [email protected] "let"
696 [email protected] " " 696 [email protected] " "
697 BIN[email protected] 697 IDENT[email protected]
698 [email protected] 698 [email protected]
699 [email protected] "_a" 699 [email protected] "_a"
700 [email protected] " " 700 [email protected] " "
@@ -737,7 +737,7 @@ [email protected]
737 [email protected] 737 [email protected]
738 [email protected] "let" 738 [email protected] "let"
739 [email protected] " " 739 [email protected] " "
740 BIN[email protected] 740 IDENT[email protected]
741 [email protected] 741 [email protected]
742 [email protected] "_b" 742 [email protected] "_b"
743 [email protected] " " 743 [email protected] " "
@@ -809,7 +809,7 @@ [email protected]
809 [email protected] "\n" 809 [email protected] "\n"
810 [email protected] "}" 810 [email protected] "}"
811 [email protected] "\n\n" 811 [email protected] "\n\n"
812 FN_DEF@1541..1741 812 [email protected]
813 [email protected] "fn" 813 [email protected] "fn"
814 [email protected] " " 814 [email protected] " "
815 [email protected] 815 [email protected]
@@ -830,7 +830,7 @@ [email protected]
830 [email protected] 830 [email protected]
831 [email protected] "{" 831 [email protected] "{"
832 [email protected] "\n " 832 [email protected] "\n "
833 FN_DEF@1575..1598 833 [email protected]
834 [email protected] "fn" 834 [email protected] "fn"
835 [email protected] " " 835 [email protected] " "
836 [email protected] 836 [email protected]
@@ -859,7 +859,7 @@ [email protected]
859 [email protected] 859 [email protected]
860 [email protected] "let" 860 [email protected] "let"
861 [email protected] " " 861 [email protected] " "
862 BIN[email protected] 862 IDENT[email protected]
863 [email protected] 863 [email protected]
864 [email protected] "_a" 864 [email protected] "_a"
865 [email protected] " " 865 [email protected] " "
@@ -906,7 +906,7 @@ [email protected]
906 [email protected] 906 [email protected]
907 [email protected] "let" 907 [email protected] "let"
908 [email protected] " " 908 [email protected] " "
909 BIN[email protected] 909 IDENT[email protected]
910 [email protected] 910 [email protected]
911 [email protected] "_c" 911 [email protected] "_c"
912 [email protected] " " 912 [email protected] " "
@@ -943,7 +943,7 @@ [email protected]
943 [email protected] 943 [email protected]
944 [email protected] "let" 944 [email protected] "let"
945 [email protected] " " 945 [email protected] " "
946 BIN[email protected] 946 IDENT[email protected]
947 [email protected] 947 [email protected]
948 [email protected] "_b" 948 [email protected] "_b"
949 [email protected] ":" 949 [email protected] ":"
@@ -988,7 +988,7 @@ [email protected]
988 [email protected] "\n" 988 [email protected] "\n"
989 [email protected] "}" 989 [email protected] "}"
990 [email protected] "\n\n" 990 [email protected] "\n\n"
991 FN_DEF@1743..1904 991 [email protected]
992 [email protected] "fn" 992 [email protected] "fn"
993 [email protected] " " 993 [email protected] " "
994 [email protected] 994 [email protected]
@@ -1024,7 +1024,7 @@ [email protected]
1024 [email protected] 1024 [email protected]
1025 [email protected] "let" 1025 [email protected] "let"
1026 [email protected] " " 1026 [email protected] " "
1027 BIN[email protected] 1027 IDENT[email protected]
1028 [email protected] "mut" 1028 [email protected] "mut"
1029 [email protected] " " 1029 [email protected] " "
1030 [email protected] 1030 [email protected]
@@ -1102,7 +1102,7 @@ [email protected]
1102 [email protected] "," 1102 [email protected] ","
1103 [email protected] " " 1103 [email protected] " "
1104 [email protected] 1104 [email protected]
1105 PLACEHOLDE[email protected] 1105 WILDCARD[email protected]
1106 [email protected] "_" 1106 [email protected] "_"
1107 [email protected] " " 1107 [email protected] " "
1108 [email protected] "=>" 1108 [email protected] "=>"
@@ -1131,7 +1131,7 @@ [email protected]
1131 [email protected] "\n" 1131 [email protected] "\n"
1132 [email protected] "}" 1132 [email protected] "}"
1133 [email protected] "\n\n" 1133 [email protected] "\n\n"
1134 FN_DEF@1906..1960 1134 [email protected]
1135 [email protected] "fn" 1135 [email protected] "fn"
1136 [email protected] " " 1136 [email protected] " "
1137 [email protected] 1137 [email protected]
@@ -1146,7 +1146,7 @@ [email protected]
1146 [email protected] 1146 [email protected]
1147 [email protected] "let" 1147 [email protected] "let"
1148 [email protected] " " 1148 [email protected] " "
1149 BIN[email protected] 1149 IDENT[email protected]
1150 [email protected] 1150 [email protected]
1151 [email protected] "_evil" 1151 [email protected] "_evil"
1152 [email protected] " " 1152 [email protected] " "
@@ -1166,7 +1166,7 @@ [email protected]
1166 [email protected] " " 1166 [email protected] " "
1167 [email protected] "}" 1167 [email protected] "}"
1168 [email protected] "\n\n" 1168 [email protected] "\n\n"
1169 FN_DEF@1962..2198 1169 [email protected]
1170 [email protected] "fn" 1170 [email protected] "fn"
1171 [email protected] " " 1171 [email protected] " "
1172 [email protected] 1172 [email protected]
@@ -1284,7 +1284,7 @@ [email protected]
1284 [email protected] "\n" 1284 [email protected] "\n"
1285 [email protected] "}" 1285 [email protected] "}"
1286 [email protected] "\n\n" 1286 [email protected] "\n\n"
1287 FN_DEF@2200..2693 1287 [email protected]
1288 [email protected] "fn" 1288 [email protected] "fn"
1289 [email protected] " " 1289 [email protected] " "
1290 [email protected] 1290 [email protected]
@@ -1292,7 +1292,7 @@ [email protected]
1292 [email protected] 1292 [email protected]
1293 [email protected] "(" 1293 [email protected] "("
1294 [email protected] 1294 [email protected]
1295 BIN[email protected] 1295 IDENT[email protected]
1296 [email protected] 1296 [email protected]
1297 [email protected] "u8" 1297 [email protected] "u8"
1298 [email protected] ":" 1298 [email protected] ":"
@@ -1468,7 +1468,7 @@ [email protected]
1468 [email protected] "\n" 1468 [email protected] "\n"
1469 [email protected] "}" 1469 [email protected] "}"
1470 [email protected] "\n\n" 1470 [email protected] "\n\n"
1471 FN_DEF@2695..2832 1471 [email protected]
1472 [email protected] "fn" 1472 [email protected] "fn"
1473 [email protected] " " 1473 [email protected] " "
1474 [email protected] 1474 [email protected]
@@ -1548,7 +1548,7 @@ [email protected]
1548 [email protected] "\n" 1548 [email protected] "\n"
1549 [email protected] "}" 1549 [email protected] "}"
1550 [email protected] "\n\n" 1550 [email protected] "\n\n"
1551 FN_DEF@2834..2906 1551 [email protected]
1552 [email protected] "fn" 1552 [email protected] "fn"
1553 [email protected] " " 1553 [email protected] " "
1554 [email protected] 1554 [email protected]
@@ -1560,26 +1560,26 @@ [email protected]
1560 [email protected] 1560 [email protected]
1561 [email protected] "{" 1561 [email protected] "{"
1562 [email protected] "\n " 1562 [email protected] "\n "
1563 UNION_DEF@2851..2904 1563 [email protected]
1564 [email protected] "union" 1564 [email protected] "union"
1565 [email protected] " " 1565 [email protected] " "
1566 [email protected] 1566 [email protected]
1567 [email protected] "union" 1567 [email protected] "union"
1568 TYP[email protected] 1568 GENERIC[email protected]
1569 [email protected] "<" 1569 [email protected] "<"
1570 [email protected] 1570 [email protected]
1571 [email protected] "\'union" 1571 [email protected] "\'union"
1572 [email protected] ">" 1572 [email protected] ">"
1573 [email protected] " " 1573 [email protected] " "
1574 RECORD_FIELD_DEF_[email protected] 1574 [email protected]
1575 [email protected] "{" 1575 [email protected] "{"
1576 [email protected] " " 1576 [email protected] " "
1577 RECORD_FIELD_DEF@2873..2901 1577 [email protected]
1578 [email protected] 1578 [email protected]
1579 [email protected] "union" 1579 [email protected] "union"
1580 [email protected] ":" 1580 [email protected] ":"
1581 [email protected] " " 1581 [email protected] " "
1582 REFERENCE[email protected] 1582 [email protected]
1583 [email protected] "&" 1583 [email protected] "&"
1584 [email protected] "\'union" 1584 [email protected] "\'union"
1585 [email protected] " " 1585 [email protected] " "
@@ -1588,7 +1588,7 @@ [email protected]
1588 [email protected] 1588 [email protected]
1589 [email protected] 1589 [email protected]
1590 [email protected] "union" 1590 [email protected] "union"
1591 TYP[email protected] 1591 GENERIC[email protected]
1592 [email protected] "<" 1592 [email protected] "<"
1593 [email protected] 1593 [email protected]
1594 [email protected] "\'union" 1594 [email protected] "\'union"
@@ -1599,7 +1599,7 @@ [email protected]
1599 [email protected] "\n" 1599 [email protected] "\n"
1600 [email protected] "}" 1600 [email protected] "}"
1601 [email protected] "\n\n" 1601 [email protected] "\n\n"
1602 FN_DEF@2908..3042 1602 [email protected]
1603 [email protected] "fn" 1603 [email protected] "fn"
1604 [email protected] " " 1604 [email protected] " "
1605 [email protected] 1605 [email protected]
@@ -1614,7 +1614,7 @@ [email protected]
1614 [email protected] 1614 [email protected]
1615 [email protected] "let" 1615 [email protected] "let"
1616 [email protected] " " 1616 [email protected] " "
1617 BIN[email protected] 1617 IDENT[email protected]
1618 [email protected] 1618 [email protected]
1619 [email protected] "val" 1619 [email protected] "val"
1620 [email protected] " " 1620 [email protected] " "
@@ -1628,31 +1628,31 @@ [email protected]
1628 [email protected] 1628 [email protected]
1629 [email protected] 1629 [email protected]
1630 [email protected] "(" 1630 [email protected] "("
1631 LAMBDA[email protected] 1631 CLOSURE[email protected]
1632 [email protected] 1632 [email protected]
1633 [email protected] "|" 1633 [email protected] "|"
1634 [email protected] 1634 [email protected]
1635 [email protected] 1635 [email protected]
1636 [email protected] "(" 1636 [email protected] "("
1637 DOT_DOT_[email protected] 1637 RES[email protected]
1638 [email protected] ".." 1638 [email protected] ".."
1639 [email protected] ")" 1639 [email protected] ")"
1640 [email protected] ":" 1640 [email protected] ":"
1641 [email protected] 1641 [email protected]
1642 [email protected] "(" 1642 [email protected] "("
1643 PLACEHOLDE[email protected] 1643 INF[email protected]
1644 [email protected] "_" 1644 [email protected] "_"
1645 [email protected] "," 1645 [email protected] ","
1646 PLACEHOLDE[email protected] 1646 INF[email protected]
1647 [email protected] "_" 1647 [email protected] "_"
1648 [email protected] ")" 1648 [email protected] ")"
1649 [email protected] "," 1649 [email protected] ","
1650 [email protected] 1650 [email protected]
1651 BIN[email protected] 1651 IDENT[email protected]
1652 [email protected] 1652 [email protected]
1653 [email protected] "__" 1653 [email protected] "__"
1654 [email protected] "@" 1654 [email protected] "@"
1655 PLACEHOLDE[email protected] 1655 WILDCARD[email protected]
1656 [email protected] "_" 1656 [email protected] "_"
1657 [email protected] "|" 1657 [email protected] "|"
1658 [email protected] 1658 [email protected]
@@ -1722,7 +1722,7 @@ [email protected]
1722 [email protected] "\n" 1722 [email protected] "\n"
1723 [email protected] "}" 1723 [email protected] "}"
1724 [email protected] "\n\n" 1724 [email protected] "\n\n"
1725 FN_DEF@3044..3514 1725 [email protected]
1726 [email protected] "fn" 1726 [email protected] "fn"
1727 [email protected] " " 1727 [email protected] " "
1728 [email protected] 1728 [email protected]
@@ -2056,7 +2056,7 @@ [email protected]
2056 [email protected] "\n" 2056 [email protected] "\n"
2057 [email protected] "}" 2057 [email protected] "}"
2058 [email protected] "\n\n" 2058 [email protected] "\n\n"
2059 FN_DEF@3516..3552 2059 [email protected]
2060 [email protected] "fn" 2060 [email protected] "fn"
2061 [email protected] " " 2061 [email protected] " "
2062 [email protected] 2062 [email protected]
@@ -2090,7 +2090,7 @@ [email protected]
2090 [email protected] "\n" 2090 [email protected] "\n"
2091 [email protected] "}" 2091 [email protected] "}"
2092 [email protected] "\n\n" 2092 [email protected] "\n\n"
2093 FN_DEF@3554..3812 2093 [email protected]
2094 [email protected] 2094 [email protected]
2095 [email protected] "pub" 2095 [email protected] "pub"
2096 [email protected] " " 2096 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.rast b/crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.rast
index a64a82e94..c4da317b9 100644
--- a/crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.rast
@@ -1,7 +1,7 @@
1[email protected] 1[email protected]
2 [email protected] "// https://github.com ..." 2 [email protected] "// https://github.com ..."
3 [email protected] "\n\n" 3 [email protected] "\n\n"
4 FN_DEF@62..156 4 [email protected]
5 [email protected] 5 [email protected]
6 [email protected] "pub" 6 [email protected] "pub"
7 [email protected] " " 7 [email protected] " "
@@ -9,7 +9,7 @@ [email protected]
9 [email protected] " " 9 [email protected] " "
10 [email protected] 10 [email protected]
11 [email protected] "foo" 11 [email protected] "foo"
12 TYP[email protected] 12 GENERIC[email protected]
13 [email protected] "<" 13 [email protected] "<"
14 [email protected] 14 [email protected]
15 [email protected] 15 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.rast b/crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.rast
index 7fd414090..22168eaf1 100644
--- a/crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..34 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.rast b/crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.rast
index 17be2c238..68a366354 100644
--- a/crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..14 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.rast b/crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.rast
index 5640bae0a..8cfc14f49 100644
--- a/crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.rast
@@ -1,14 +1,14 @@
1[email protected] 1[email protected]
2 STRUCT_DEF@0..27 2 [email protected]
3 [email protected] "struct" 3 [email protected] "struct"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "S" 6 [email protected] "S"
7 [email protected] " " 7 [email protected] " "
8 RECORD_FIELD_DEF_[email protected] 8 [email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] "\n " 10 [email protected] "\n "
11 RECORD_FIELD_DEF@15..25 11 [email protected]
12 [email protected] 12 [email protected]
13 [email protected] "r#foo" 13 [email protected] "r#foo"
14 [email protected] ":" 14 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.rast b/crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.rast
index acf32a852..4035aef6f 100644
--- a/crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..59 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "let" 15 [email protected] "let"
16 [email protected] " " 16 [email protected] " "
17 BIN[email protected] 17 IDENT[email protected]
18 [email protected] 18 [email protected]
19 [email protected] "r#struct" 19 [email protected] "r#struct"
20 [email protected] " " 20 [email protected] " "
@@ -27,7 +27,7 @@ [email protected]
27 [email protected] 27 [email protected]
28 [email protected] "let" 28 [email protected] "let"
29 [email protected] " " 29 [email protected] " "
30 BIN[email protected] 30 IDENT[email protected]
31 [email protected] 31 [email protected]
32 [email protected] "r#trait" 32 [email protected] "r#trait"
33 [email protected] " " 33 [email protected] " "
diff --git a/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast b/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast
index 468982b74..e71e069f1 100644
--- a/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast
@@ -1,14 +1,14 @@
1[email protected] 1[email protected]
2 [email protected] "// https://github.com ..." 2 [email protected] "// https://github.com ..."
3 [email protected] "\n\n" 3 [email protected] "\n\n"
4 STRUCT_DEF@62..73 4 [email protected]
5 [email protected] "struct" 5 [email protected] "struct"
6 [email protected] " " 6 [email protected] " "
7 [email protected] 7 [email protected]
8 [email protected] "Foo" 8 [email protected] "Foo"
9 [email protected] ";" 9 [email protected] ";"
10 [email protected] "\n\n" 10 [email protected] "\n\n"
11 IMPL_DEF@75..141 11 [email protected]
12 [email protected] "impl" 12 [email protected] "impl"
13 [email protected] " " 13 [email protected] " "
14 [email protected] 14 [email protected]
@@ -17,10 +17,10 @@ [email protected]
17 [email protected] 17 [email protected]
18 [email protected] "Foo" 18 [email protected] "Foo"
19 [email protected] " " 19 [email protected] " "
20 [email protected] 20 ASSOC_[email protected]
21 [email protected] "{" 21 [email protected] "{"
22 [email protected] "\n " 22 [email protected] "\n "
23 FN_DEF@90..139 23 [email protected]
24 [email protected] "fn" 24 [email protected] "fn"
25 [email protected] " " 25 [email protected] " "
26 [email protected] 26 [email protected]
@@ -55,7 +55,7 @@ [email protected]
55 [email protected] "\n" 55 [email protected] "\n"
56 [email protected] "}" 56 [email protected] "}"
57 [email protected] "\n\n" 57 [email protected] "\n\n"
58 FN_DEF@143..161 58 [email protected]
59 [email protected] "fn" 59 [email protected] "fn"
60 [email protected] " " 60 [email protected] " "
61 [email protected] 61 [email protected]
@@ -63,7 +63,7 @@ [email protected]
63 [email protected] 63 [email protected]
64 [email protected] "(" 64 [email protected] "("
65 [email protected] 65 [email protected]
66 PLACEHOLDE[email protected] 66 WILDCARD[email protected]
67 [email protected] "_" 67 [email protected] "_"
68 [email protected] ":" 68 [email protected] ":"
69 [email protected] " " 69 [email protected] " "
@@ -78,7 +78,7 @@ [email protected]
78 [email protected] "{" 78 [email protected] "{"
79 [email protected] "}" 79 [email protected] "}"
80 [email protected] "\n\n" 80 [email protected] "\n\n"
81 FN_DEF@163..198 81 [email protected]
82 [email protected] "fn" 82 [email protected] "fn"
83 [email protected] " " 83 [email protected] " "
84 [email protected] 84 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast b/crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast
index 900eeb445..adc4a22e9 100644
--- a/crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast
@@ -1,16 +1,16 @@
1[email protected] 1[email protected]
2 [email protected] "// https://github.com ..." 2 [email protected] "// https://github.com ..."
3 [email protected] "\n\n" 3 [email protected] "\n\n"
4 STRUCT_DEF@62..90 4 [email protected]
5 [email protected] "struct" 5 [email protected] "struct"
6 [email protected] " " 6 [email protected] " "
7 [email protected] 7 [email protected]
8 [email protected] "Repr" 8 [email protected] "Repr"
9 [email protected] " " 9 [email protected] " "
10 RECORD_FIELD_DEF_[email protected] 10 [email protected]
11 [email protected] "{" 11 [email protected] "{"
12 [email protected] " " 12 [email protected] " "
13 RECORD_FIELD_DEF@76..88 13 [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "raw" 15 [email protected] "raw"
16 [email protected] ":" 16 [email protected] ":"
@@ -30,7 +30,7 @@ [email protected]
30 [email protected] " " 30 [email protected] " "
31 [email protected] "}" 31 [email protected] "}"
32 [email protected] "\n\n" 32 [email protected] "\n\n"
33 FN_DEF@92..159 33 [email protected]
34 [email protected] "fn" 34 [email protected] "fn"
35 [email protected] " " 35 [email protected] " "
36 [email protected] 36 [email protected]
@@ -46,16 +46,16 @@ [email protected]
46 [email protected] 46 [email protected]
47 [email protected] 47 [email protected]
48 [email protected] 48 [email protected]
49 RECORD_LIT@107..124 49 RECORD_EXPR@107..124
50 [email protected] 50 [email protected]
51 [email protected] 51 [email protected]
52 [email protected] 52 [email protected]
53 [email protected] "Repr" 53 [email protected] "Repr"
54 [email protected] " " 54 [email protected] " "
55 [email protected] 55 RECORD_EXPR_[email protected]
56 [email protected] "{" 56 [email protected] "{"
57 [email protected] " " 57 [email protected] " "
58 [email protected] 58 RECORD_EXPR_[email protected]
59 [email protected] 59 [email protected]
60 [email protected] "raw" 60 [email protected] "raw"
61 [email protected] ":" 61 [email protected] ":"
@@ -83,14 +83,14 @@ [email protected]
83 [email protected] "\n " 83 [email protected] "\n "
84 [email protected] 84 [email protected]
85 [email protected] 85 [email protected]
86 RECORD_LIT@141..154 86 RECORD_EXPR@141..154
87 [email protected] 87 [email protected]
88 [email protected] 88 [email protected]
89 [email protected] 89 [email protected]
90 [email protected] "Repr" 90 [email protected] "Repr"
91 [email protected] 91 RECORD_EXPR_[email protected]
92 [email protected] "{" 92 [email protected] "{"
93 [email protected] 93 RECORD_EXPR_[email protected]
94 [email protected] 94 [email protected]
95 [email protected] "raw" 95 [email protected] "raw"
96 [email protected] ":" 96 [email protected] ":"
diff --git a/crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast b/crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast
index 6d941487b..af44a4dbe 100644
--- a/crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..165 2 [email protected]
3 [email protected] "// https://github.com ..." 3 [email protected] "// https://github.com ..."
4 [email protected] "\n" 4 [email protected] "\n"
5 [email protected] "fn" 5 [email protected] "fn"
@@ -33,7 +33,7 @@ [email protected]
33 [email protected] "\n " 33 [email protected] "\n "
34 [email protected] "let" 34 [email protected] "let"
35 [email protected] " " 35 [email protected] " "
36 BIN[email protected] 36 IDENT[email protected]
37 [email protected] 37 [email protected]
38 [email protected] "exit_code" 38 [email protected] "exit_code"
39 [email protected] " " 39 [email protected] " "
@@ -52,7 +52,7 @@ [email protected]
52 [email protected] "catch_unwind" 52 [email protected] "catch_unwind"
53 [email protected] 53 [email protected]
54 [email protected] "(" 54 [email protected] "("
55 LAMBDA[email protected] 55 CLOSURE[email protected]
56 [email protected] "move" 56 [email protected] "move"
57 [email protected] " " 57 [email protected] " "
58 [email protected] 58 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast b/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast
index e8b095251..0ac56df6d 100644
--- a/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..461 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -89,7 +89,7 @@ [email protected]
89 [email protected] "\n\n" 89 [email protected] "\n\n"
90 [email protected] "// https://github.com ..." 90 [email protected] "// https://github.com ..."
91 [email protected] "\n" 91 [email protected] "\n"
92 IMPL_DEF@524..685 92 [email protected]
93 [email protected] "impl" 93 [email protected] "impl"
94 [email protected] " " 94 [email protected] " "
95 [email protected] 95 [email protected]
@@ -98,10 +98,10 @@ [email protected]
98 [email protected] 98 [email protected]
99 [email protected] "Whatever" 99 [email protected] "Whatever"
100 [email protected] " " 100 [email protected] " "
101 [email protected] 101 ASSOC_[email protected]
102 [email protected] "{" 102 [email protected] "{"
103 [email protected] "\n " 103 [email protected] "\n "
104 FN_DEF@544..683 104 [email protected]
105 [email protected] "fn" 105 [email protected] "fn"
106 [email protected] " " 106 [email protected] " "
107 [email protected] 107 [email protected]
@@ -114,7 +114,7 @@ [email protected]
114 [email protected] "," 114 [email protected] ","
115 [email protected] " " 115 [email protected] " "
116 [email protected] 116 [email protected]
117 BIN[email protected] 117 IDENT[email protected]
118 [email protected] 118 [email protected]
119 [email protected] "event_fn" 119 [email protected] "event_fn"
120 [email protected] ":" 120 [email protected] ":"
@@ -141,7 +141,7 @@ [email protected]
141 [email protected] 141 [email protected]
142 [email protected] 142 [email protected]
143 [email protected] "Event" 143 [email protected] "Event"
144 TYP[email protected] 144 GENERIC[email protected]
145 [email protected] "<" 145 [email protected] "<"
146 [email protected] 146 [email protected]
147 [email protected] 147 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast b/crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast
index 38e44e48a..4f8dff909 100644
--- a/crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast
@@ -1,7 +1,7 @@
1[email protected] 1[email protected]
2 [email protected] "// https://github.com ..." 2 [email protected] "// https://github.com ..."
3 [email protected] "\n\n" 3 [email protected] "\n\n"
4 FN_DEF@62..341 4 [email protected]
5 [email protected] "fn" 5 [email protected] "fn"
6 [email protected] " " 6 [email protected] " "
7 [email protected] 7 [email protected]
@@ -55,7 +55,7 @@ [email protected]
55 [email protected] "," 55 [email protected] ","
56 [email protected] "\n " 56 [email protected] "\n "
57 [email protected] 57 [email protected]
58 PLACEHOLDE[email protected] 58 WILDCARD[email protected]
59 [email protected] "_" 59 [email protected] "_"
60 [email protected] " " 60 [email protected] " "
61 [email protected] "=>" 61 [email protected] "=>"
@@ -127,7 +127,7 @@ [email protected]
127 [email protected] "," 127 [email protected] ","
128 [email protected] "\n " 128 [email protected] "\n "
129 [email protected] 129 [email protected]
130 PLACEHOLDE[email protected] 130 WILDCARD[email protected]
131 [email protected] "_" 131 [email protected] "_"
132 [email protected] " " 132 [email protected] " "
133 [email protected] "=>" 133 [email protected] "=>"
@@ -203,7 +203,7 @@ [email protected]
203 [email protected] "," 203 [email protected] ","
204 [email protected] "\n " 204 [email protected] "\n "
205 [email protected] 205 [email protected]
206 PLACEHOLDE[email protected] 206 WILDCARD[email protected]
207 [email protected] "_" 207 [email protected] "_"
208 [email protected] " " 208 [email protected] " "
209 [email protected] "=>" 209 [email protected] "=>"
@@ -256,21 +256,21 @@ [email protected]
256 [email protected] "\n" 256 [email protected] "\n"
257 [email protected] "}" 257 [email protected] "}"
258 [email protected] "\n\n" 258 [email protected] "\n\n"
259 ENUM_DEF@343..367 259 [email protected]
260 [email protected] "enum" 260 [email protected] "enum"
261 [email protected] " " 261 [email protected] " "
262 [email protected] 262 [email protected]
263 [email protected] "A" 263 [email protected] "A"
264 [email protected] " " 264 [email protected] " "
265 ENUM_[email protected] 265 [email protected]
266 [email protected] "{" 266 [email protected] "{"
267 [email protected] "\n " 267 [email protected] "\n "
268 ENUM_[email protected] 268 [email protected]
269 [email protected] 269 [email protected]
270 [email protected] "B" 270 [email protected] "B"
271 TUPLE_FIELD_DEF_[email protected] 271 [email protected]
272 [email protected] "(" 272 [email protected] "("
273 TUPLE_FIELD_DEF@358..360 273 [email protected]
274 [email protected] 274 [email protected]
275 [email protected] 275 [email protected]
276 [email protected] 276 [email protected]
@@ -278,7 +278,7 @@ [email protected]
278 [email protected] "i8" 278 [email protected] "i8"
279 [email protected] "," 279 [email protected] ","
280 [email protected] " " 280 [email protected] " "
281 TUPLE_FIELD_DEF@362..364 281 [email protected]
282 [email protected] 282 [email protected]
283 [email protected] 283 [email protected]
284 [email protected] 284 [email protected]
@@ -288,7 +288,7 @@ [email protected]
288 [email protected] "\n" 288 [email protected] "\n"
289 [email protected] "}" 289 [email protected] "}"
290 [email protected] "\n\n" 290 [email protected] "\n\n"
291 FN_DEF@369..394 291 [email protected]
292 [email protected] "fn" 292 [email protected] "fn"
293 [email protected] " " 293 [email protected] " "
294 [email protected] 294 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.rast b/crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.rast
index 28233c5d0..eaab47843 100644
--- a/crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.rast
@@ -1,7 +1,7 @@
1[email protected] 1[email protected]
2 [email protected] "// https://github.com ..." 2 [email protected] "// https://github.com ..."
3 [email protected] "\n\n" 3 [email protected] "\n\n"
4 FN_DEF@60..256 4 [email protected]
5 [email protected] "fn" 5 [email protected] "fn"
6 [email protected] " " 6 [email protected] " "
7 [email protected] 7 [email protected]
@@ -16,7 +16,7 @@ [email protected]
16 [email protected] 16 [email protected]
17 [email protected] "let" 17 [email protected] "let"
18 [email protected] " " 18 [email protected] " "
19 BIN[email protected] 19 IDENT[email protected]
20 [email protected] "mut" 20 [email protected] "mut"
21 [email protected] " " 21 [email protected] " "
22 [email protected] 22 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0049_async_block.rast b/crates/ra_syntax/test_data/parser/ok/0049_async_block.rast
index 0569488f8..57ecad3cf 100644
--- a/crates/ra_syntax/test_data/parser/ok/0049_async_block.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0049_async_block.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..45 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.rast b/crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.rast
index 7847da085..c7ce12e93 100644
--- a/crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..52 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -7,7 +7,7 @@ [email protected]
7 [email protected] 7 [email protected]
8 [email protected] "(" 8 [email protected] "("
9 [email protected] 9 [email protected]
10 BIN[email protected] 10 IDENT[email protected]
11 [email protected] 11 [email protected]
12 [email protected] "x" 12 [email protected] "x"
13 [email protected] ":" 13 [email protected] ":"
@@ -32,7 +32,7 @@ [email protected]
32 [email protected] 32 [email protected]
33 [email protected] 33 [email protected]
34 [email protected] "Future" 34 [email protected] "Future"
35 TYP[email protected] 35 GENERIC[email protected]
36 [email protected] "<" 36 [email protected] "<"
37 [email protected] 37 [email protected]
38 [email protected] 38 [email protected]
@@ -52,7 +52,7 @@ [email protected]
52 [email protected] "{" 52 [email protected] "{"
53 [email protected] "}" 53 [email protected] "}"
54 [email protected] "\n\n" 54 [email protected] "\n\n"
55 FN_DEF@54..94 55 [email protected]
56 [email protected] "fn" 56 [email protected] "fn"
57 [email protected] " " 57 [email protected] " "
58 [email protected] 58 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast b/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast
index 816740a7c..d4f05f279 100644
--- a/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..37 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -25,7 +25,7 @@ [email protected]
25 [email protected] "]" 25 [email protected] "]"
26 [email protected] " " 26 [email protected] " "
27 [email protected] 27 [email protected]
28 BIN[email protected] 28 IDENT[email protected]
29 [email protected] 29 [email protected]
30 [email protected] "pat" 30 [email protected] "pat"
31 [email protected] ":" 31 [email protected] ":"
@@ -41,7 +41,7 @@ [email protected]
41 [email protected] "{" 41 [email protected] "{"
42 [email protected] "}" 42 [email protected] "}"
43 [email protected] "\n" 43 [email protected] "\n"
44 FN_DEF@38..62 44 [email protected]
45 [email protected] "fn" 45 [email protected] "fn"
46 [email protected] " " 46 [email protected] " "
47 [email protected] 47 [email protected]
@@ -58,7 +58,7 @@ [email protected]
58 [email protected] "]" 58 [email protected] "]"
59 [email protected] " " 59 [email protected] " "
60 [email protected] 60 [email protected]
61 BIN[email protected] 61 IDENT[email protected]
62 [email protected] 62 [email protected]
63 [email protected] "x" 63 [email protected] "x"
64 [email protected] ":" 64 [email protected] ":"
@@ -83,7 +83,7 @@ [email protected]
83 [email protected] 83 [email protected]
84 [email protected] "{" 84 [email protected] "{"
85 [email protected] " " 85 [email protected] " "
86 FN_DEF@77..126 86 [email protected]
87 [email protected] "fn" 87 [email protected] "fn"
88 [email protected] " " 88 [email protected] " "
89 [email protected] 89 [email protected]
@@ -91,12 +91,12 @@ [email protected]
91 [email protected] 91 [email protected]
92 [email protected] "(" 92 [email protected] "("
93 [email protected] 93 [email protected]
94 BIN[email protected] 94 IDENT[email protected]
95 [email protected] 95 [email protected]
96 [email protected] "format" 96 [email protected] "format"
97 [email protected] ":" 97 [email protected] ":"
98 [email protected] " " 98 [email protected] " "
99 POINTE[email protected] 99 [email protected]
100 [email protected] "*" 100 [email protected] "*"
101 [email protected] "const" 101 [email protected] "const"
102 [email protected] " " 102 [email protected] " "
@@ -132,12 +132,12 @@ [email protected]
132 [email protected] " " 132 [email protected] " "
133 [email protected] "}" 133 [email protected] "}"
134 [email protected] "\n\n" 134 [email protected] "\n\n"
135 FN_DEF@130..172 135 [email protected]
136 [email protected] "fn" 136 [email protected] "fn"
137 [email protected] " " 137 [email protected] " "
138 [email protected] 138 [email protected]
139 [email protected] "foo" 139 [email protected] "foo"
140 TYP[email protected] 140 GENERIC[email protected]
141 [email protected] "<" 141 [email protected] "<"
142 [email protected] 142 [email protected]
143 [email protected] 143 [email protected]
@@ -163,7 +163,7 @@ [email protected]
163 [email protected] "]" 163 [email protected] "]"
164 [email protected] " " 164 [email protected] " "
165 [email protected] 165 [email protected]
166 REFERENCE[email protected] 166 [email protected]
167 [email protected] "&" 167 [email protected] "&"
168 [email protected] "mut" 168 [email protected] "mut"
169 [email protected] " " 169 [email protected] " "
@@ -172,7 +172,7 @@ [email protected]
172 [email protected] 172 [email protected]
173 [email protected] 173 [email protected]
174 [email protected] "Foo" 174 [email protected] "Foo"
175 TYP[email protected] 175 GENERIC[email protected]
176 [email protected] "<" 176 [email protected] "<"
177 [email protected] 177 [email protected]
178 [email protected] "\'a" 178 [email protected] "\'a"
@@ -186,16 +186,16 @@ [email protected]
186 [email protected] "{" 186 [email protected] "{"
187 [email protected] "}" 187 [email protected] "}"
188 [email protected] "\n\n" 188 [email protected] "\n\n"
189 TRAIT_DEF@174..236 189 [email protected]
190 [email protected] "trait" 190 [email protected] "trait"
191 [email protected] " " 191 [email protected] " "
192 [email protected] 192 [email protected]
193 [email protected] "Foo" 193 [email protected] "Foo"
194 [email protected] " " 194 [email protected] " "
195 [email protected] 195 ASSOC_[email protected]
196 [email protected] "{" 196 [email protected] "{"
197 [email protected] "\n " 197 [email protected] "\n "
198 FN_DEF@190..234 198 [email protected]
199 [email protected] "fn" 199 [email protected] "fn"
200 [email protected] " " 200 [email protected] " "
201 [email protected] 201 [email protected]
@@ -212,7 +212,7 @@ [email protected]
212 [email protected] "]" 212 [email protected] "]"
213 [email protected] " " 213 [email protected] " "
214 [email protected] 214 [email protected]
215 PLACEHOLDE[email protected] 215 WILDCARD[email protected]
216 [email protected] "_" 216 [email protected] "_"
217 [email protected] ":" 217 [email protected] ":"
218 [email protected] " " 218 [email protected] " "
@@ -234,7 +234,7 @@ [email protected]
234 [email protected] "]" 234 [email protected] "]"
235 [email protected] " " 235 [email protected] " "
236 [email protected] 236 [email protected]
237 BIN[email protected] 237 IDENT[email protected]
238 [email protected] "mut" 238 [email protected] "mut"
239 [email protected] " " 239 [email protected] " "
240 [email protected] 240 [email protected]
@@ -251,7 +251,7 @@ [email protected]
251 [email protected] "\n" 251 [email protected] "\n"
252 [email protected] "}" 252 [email protected] "}"
253 [email protected] "\n\n" 253 [email protected] "\n\n"
254 IMPL_DEF@238..519 254 [email protected]
255 [email protected] "impl" 255 [email protected] "impl"
256 [email protected] " " 256 [email protected] " "
257 [email protected] 257 [email protected]
@@ -260,10 +260,10 @@ [email protected]
260 [email protected] 260 [email protected]
261 [email protected] "S" 261 [email protected] "S"
262 [email protected] " " 262 [email protected] " "
263 [email protected] 263 ASSOC_[email protected]
264 [email protected] "{" 264 [email protected] "{"
265 [email protected] "\n " 265 [email protected] "\n "
266 FN_DEF@252..277 266 [email protected]
267 [email protected] "fn" 267 [email protected] "fn"
268 [email protected] " " 268 [email protected] " "
269 [email protected] 269 [email protected]
@@ -287,7 +287,7 @@ [email protected]
287 [email protected] "{" 287 [email protected] "{"
288 [email protected] "}" 288 [email protected] "}"
289 [email protected] "\n " 289 [email protected] "\n "
290 FN_DEF@283..305 290 [email protected]
291 [email protected] "fn" 291 [email protected] "fn"
292 [email protected] " " 292 [email protected] " "
293 [email protected] 293 [email protected]
@@ -311,7 +311,7 @@ [email protected]
311 [email protected] "{" 311 [email protected] "{"
312 [email protected] "}" 312 [email protected] "}"
313 [email protected] "\n " 313 [email protected] "\n "
314 FN_DEF@311..334 314 [email protected]
315 [email protected] "fn" 315 [email protected] "fn"
316 [email protected] " " 316 [email protected] " "
317 [email protected] 317 [email protected]
@@ -336,12 +336,12 @@ [email protected]
336 [email protected] "{" 336 [email protected] "{"
337 [email protected] "}" 337 [email protected] "}"
338 [email protected] "\n " 338 [email protected] "\n "
339 FN_DEF@340..371 339 [email protected]
340 [email protected] "fn" 340 [email protected] "fn"
341 [email protected] " " 341 [email protected] " "
342 [email protected] 342 [email protected]
343 [email protected] "g3" 343 [email protected] "g3"
344 TYP[email protected] 344 GENERIC[email protected]
345 [email protected] "<" 345 [email protected] "<"
346 [email protected] 346 [email protected]
347 [email protected] "\'a" 347 [email protected] "\'a"
@@ -368,12 +368,12 @@ [email protected]
368 [email protected] "{" 368 [email protected] "{"
369 [email protected] "}" 369 [email protected] "}"
370 [email protected] "\n " 370 [email protected] "\n "
371 FN_DEF@377..407 371 [email protected]
372 [email protected] "fn" 372 [email protected] "fn"
373 [email protected] " " 373 [email protected] " "
374 [email protected] 374 [email protected]
375 [email protected] "g4" 375 [email protected] "g4"
376 TYP[email protected] 376 GENERIC[email protected]
377 [email protected] "<" 377 [email protected] "<"
378 [email protected] 378 [email protected]
379 [email protected] "\'a" 379 [email protected] "\'a"
@@ -400,12 +400,12 @@ [email protected]
400 [email protected] "{" 400 [email protected] "{"
401 [email protected] "}" 401 [email protected] "}"
402 [email protected] "\n " 402 [email protected] "\n "
403 FN_DEF@413..447 403 [email protected]
404 [email protected] "fn" 404 [email protected] "fn"
405 [email protected] " " 405 [email protected] " "
406 [email protected] 406 [email protected]
407 [email protected] "g5" 407 [email protected] "g5"
408 TYP[email protected] 408 GENERIC[email protected]
409 [email protected] "<" 409 [email protected] "<"
410 [email protected] 410 [email protected]
411 [email protected] "\'a" 411 [email protected] "\'a"
@@ -434,7 +434,7 @@ [email protected]
434 [email protected] "{" 434 [email protected] "{"
435 [email protected] "}" 435 [email protected] "}"
436 [email protected] "\n " 436 [email protected] "\n "
437 FN_DEF@453..480 437 [email protected]
438 [email protected] "fn" 438 [email protected] "fn"
439 [email protected] " " 439 [email protected] " "
440 [email protected] 440 [email protected]
@@ -465,7 +465,7 @@ [email protected]
465 [email protected] "{" 465 [email protected] "{"
466 [email protected] "}" 466 [email protected] "}"
467 [email protected] "\n " 467 [email protected] "\n "
468 FN_DEF@486..517 468 [email protected]
469 [email protected] "fn" 469 [email protected] "fn"
470 [email protected] " " 470 [email protected] " "
471 [email protected] 471 [email protected]
@@ -490,7 +490,7 @@ [email protected]
490 [email protected] 490 [email protected]
491 [email protected] 491 [email protected]
492 [email protected] "Rc" 492 [email protected] "Rc"
493 TYP[email protected] 493 GENERIC[email protected]
494 [email protected] "<" 494 [email protected] "<"
495 [email protected] 495 [email protected]
496 [email protected] 496 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rast b/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rast
index 65cfa7bc5..350823ba3 100644
--- a/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..79 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -14,7 +14,7 @@ [email protected]
14 [email protected] 14 [email protected]
15 [email protected] "for" 15 [email protected] "for"
16 [email protected] " " 16 [email protected] " "
17 BIN[email protected] 17 IDENT[email protected]
18 [email protected] 18 [email protected]
19 [email protected] "_x" 19 [email protected] "_x"
20 [email protected] " " 20 [email protected] " "
@@ -50,7 +50,7 @@ [email protected]
50 [email protected] "." 50 [email protected] "."
51 [email protected] 51 [email protected]
52 [email protected] "sum" 52 [email protected] "sum"
53 TYP[email protected] 53 GENERIC[email protected]
54 [email protected] "::" 54 [email protected] "::"
55 [email protected] "<" 55 [email protected] "<"
56 [email protected] 56 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rast b/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rast
index d6aec7ab9..f25c9ac36 100644
--- a/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..26 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -16,7 +16,7 @@ [email protected]
16 [email protected] 16 [email protected]
17 [email protected] 17 [email protected]
18 [email protected] "Foo" 18 [email protected] "Foo"
19 TYP[email protected] 19 GENERIC[email protected]
20 [email protected] "<" 20 [email protected] "<"
21 [email protected] 21 [email protected]
22 [email protected] 22 [email protected]
@@ -35,7 +35,7 @@ [email protected]
35 [email protected] "{" 35 [email protected] "{"
36 [email protected] "}" 36 [email protected] "}"
37 [email protected] "\n\n" 37 [email protected] "\n\n"
38 FN_DEF@28..56 38 [email protected]
39 [email protected] "fn" 39 [email protected] "fn"
40 [email protected] " " 40 [email protected] " "
41 [email protected] 41 [email protected]
@@ -43,7 +43,7 @@ [email protected]
43 [email protected] 43 [email protected]
44 [email protected] "(" 44 [email protected] "("
45 [email protected] 45 [email protected]
46 PLACEHOLDE[email protected] 46 WILDCARD[email protected]
47 [email protected] "_" 47 [email protected] "_"
48 [email protected] ":" 48 [email protected] ":"
49 [email protected] " " 49 [email protected] " "
@@ -77,7 +77,7 @@ [email protected]
77 [email protected] "{" 77 [email protected] "{"
78 [email protected] "}" 78 [email protected] "}"
79 [email protected] "\n\n" 79 [email protected] "\n\n"
80 FN_DEF@58..87 80 [email protected]
81 [email protected] "fn" 81 [email protected] "fn"
82 [email protected] " " 82 [email protected] " "
83 [email protected] 83 [email protected]
@@ -85,7 +85,7 @@ [email protected]
85 [email protected] 85 [email protected]
86 [email protected] "(" 86 [email protected] "("
87 [email protected] 87 [email protected]
88 PLACEHOLDE[email protected] 88 WILDCARD[email protected]
89 [email protected] "_" 89 [email protected] "_"
90 [email protected] ":" 90 [email protected] ":"
91 [email protected] " " 91 [email protected] " "
@@ -102,7 +102,7 @@ [email protected]
102 [email protected] 102 [email protected]
103 [email protected] "(" 103 [email protected] "("
104 [email protected] 104 [email protected]
105 REFERENCE[email protected] 105 [email protected]
106 [email protected] "&" 106 [email protected] "&"
107 [email protected] 107 [email protected]
108 [email protected] 108 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.rast b/crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.rast
index 9e0cec35f..7447d516e 100644
--- a/crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 TYPE_ALIAS_DEF@0..12 2 [email protected]
3 [email protected] "type" 3 [email protected] "type"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -12,7 +12,7 @@ [email protected]
12 [email protected] ")" 12 [email protected] ")"
13 [email protected] ";" 13 [email protected] ";"
14 [email protected] "\n\n" 14 [email protected] "\n\n"
15 FN_DEF@14..48 15 [email protected]
16 [email protected] "fn" 16 [email protected] "fn"
17 [email protected] " " 17 [email protected] " "
18 [email protected] 18 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.rast b/crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.rast
index 7fa3033ac..3ef916e55 100644
--- a/crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..70 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.rast b/crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.rast
index d93968016..76301004a 100644
--- a/crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..17 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -7,7 +7,7 @@ [email protected]
7 [email protected] 7 [email protected]
8 [email protected] "(" 8 [email protected] "("
9 [email protected] 9 [email protected]
10 BIN[email protected] 10 IDENT[email protected]
11 [email protected] 11 [email protected]
12 [email protected] "x" 12 [email protected] "x"
13 [email protected] ":" 13 [email protected] ":"
@@ -23,7 +23,7 @@ [email protected]
23 [email protected] "{" 23 [email protected] "{"
24 [email protected] "}" 24 [email protected] "}"
25 [email protected] "\n\n" 25 [email protected] "\n\n"
26 FN_DEF@19..50 26 [email protected]
27 [email protected] "fn" 27 [email protected] "fn"
28 [email protected] " " 28 [email protected] " "
29 [email protected] 29 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rast b/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rast
index b5c72ee36..a1dfd58f2 100644
--- a/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..78 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.rast b/crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.rast
index ddcb139c1..213f7b381 100644
--- a/crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..104 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -23,7 +23,7 @@ [email protected]
23 [email protected] 23 [email protected]
24 [email protected] "for" 24 [email protected] "for"
25 [email protected] " " 25 [email protected] " "
26 PLACEHOLDE[email protected] 26 WILDCARD[email protected]
27 [email protected] "_" 27 [email protected] "_"
28 [email protected] " " 28 [email protected] " "
29 [email protected] "in" 29 [email protected] "in"
diff --git a/crates/ra_syntax/test_data/parser/ok/0060_as_range.rast b/crates/ra_syntax/test_data/parser/ok/0060_as_range.rast
index 098152fc3..1fd1a2888 100644
--- a/crates/ra_syntax/test_data/parser/ok/0060_as_range.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0060_as_range.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..55 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0061_match_full_range.rast b/crates/ra_syntax/test_data/parser/ok/0061_match_full_range.rast
index c6e982976..ba49c115b 100644
--- a/crates/ra_syntax/test_data/parser/ok/0061_match_full_range.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0061_match_full_range.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..34 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.rast b/crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.rast
index bf791ee2b..0c22c31a4 100644
--- a/crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.rast
@@ -51,7 +51,7 @@ [email protected]
51 [email protected] "\n" 51 [email protected] "\n"
52 [email protected] "}" 52 [email protected] "}"
53 [email protected] "\n\n" 53 [email protected] "\n\n"
54 FN_DEF@95..348 54 [email protected]
55 [email protected] 55 [email protected]
56 [email protected] "#" 56 [email protected] "#"
57 [email protected] "[" 57 [email protected] "["
diff --git a/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast b/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast
index 886b211d0..8eda59976 100644
--- a/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast
@@ -1,14 +1,14 @@
1[email protected] 1[email protected]
2 TRAIT_DEF@0..169 2 [email protected]
3 [email protected] "trait" 3 [email protected] "trait"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "T" 6 [email protected] "T"
7 [email protected] " " 7 [email protected] " "
8 [email protected] 8 ASSOC_[email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] "\n " 10 [email protected] "\n "
11 FN_DEF@14..46 11 [email protected]
12 [email protected] "fn" 12 [email protected] "fn"
13 [email protected] " " 13 [email protected] " "
14 [email protected] 14 [email protected]
@@ -18,12 +18,12 @@ [email protected]
18 [email protected] 18 [email protected]
19 [email protected] 19 [email protected]
20 [email protected] "(" 20 [email protected] "("
21 BIN[email protected] 21 IDENT[email protected]
22 [email protected] 22 [email protected]
23 [email protected] "a" 23 [email protected] "a"
24 [email protected] "," 24 [email protected] ","
25 [email protected] " " 25 [email protected] " "
26 BIN[email protected] 26 IDENT[email protected]
27 [email protected] 27 [email protected]
28 [email protected] "b" 28 [email protected] "b"
29 [email protected] ")" 29 [email protected] ")"
@@ -50,7 +50,7 @@ [email protected]
50 [email protected] "{" 50 [email protected] "{"
51 [email protected] "}" 51 [email protected] "}"
52 [email protected] "\n " 52 [email protected] "\n "
53 FN_DEF@51..74 53 [email protected]
54 [email protected] "fn" 54 [email protected] "fn"
55 [email protected] " " 55 [email protected] " "
56 [email protected] 56 [email protected]
@@ -64,17 +64,17 @@ [email protected]
64 [email protected] 64 [email protected]
65 [email protected] "S" 65 [email protected] "S"
66 [email protected] " " 66 [email protected] " "
67 RECORD_FIELD_PAT_[email protected] 67 RECORD_PAT_[email protected]
68 [email protected] "{" 68 [email protected] "{"
69 [email protected] " " 69 [email protected] " "
70 RECORD_FIELD_PAT@61..62 70 RECORD_PAT_[email protected]
71 BIN[email protected] 71 IDENT[email protected]
72 [email protected] 72 [email protected]
73 [email protected] "a" 73 [email protected] "a"
74 [email protected] "," 74 [email protected] ","
75 [email protected] " " 75 [email protected] " "
76 RECORD_FIELD_PAT@64..65 76 RECORD_PAT_[email protected]
77 BIN[email protected] 77 IDENT[email protected]
78 [email protected] 78 [email protected]
79 [email protected] "b" 79 [email protected] "b"
80 [email protected] " " 80 [email protected] " "
@@ -92,7 +92,7 @@ [email protected]
92 [email protected] "{" 92 [email protected] "{"
93 [email protected] "}" 93 [email protected] "}"
94 [email protected] "\n " 94 [email protected] "\n "
95 FN_DEF@79..108 95 [email protected]
96 [email protected] "fn" 96 [email protected] "fn"
97 [email protected] " " 97 [email protected] " "
98 [email protected] 98 [email protected]
@@ -106,7 +106,7 @@ [email protected]
106 [email protected] 106 [email protected]
107 [email protected] "NewType" 107 [email protected] "NewType"
108 [email protected] "(" 108 [email protected] "("
109 BIN[email protected] 109 IDENT[email protected]
110 [email protected] 110 [email protected]
111 [email protected] "a" 111 [email protected] "a"
112 [email protected] ")" 112 [email protected] ")"
@@ -123,7 +123,7 @@ [email protected]
123 [email protected] "{" 123 [email protected] "{"
124 [email protected] "}" 124 [email protected] "}"
125 [email protected] "\n " 125 [email protected] "\n "
126 FN_DEF@113..135 126 [email protected]
127 [email protected] "fn" 127 [email protected] "fn"
128 [email protected] " " 128 [email protected] " "
129 [email protected] 129 [email protected]
@@ -135,14 +135,14 @@ [email protected]
135 [email protected] "&" 135 [email protected] "&"
136 [email protected] 136 [email protected]
137 [email protected] "&" 137 [email protected] "&"
138 BIN[email protected] 138 IDENT[email protected]
139 [email protected] 139 [email protected]
140 [email protected] "a" 140 [email protected] "a"
141 [email protected] ":" 141 [email protected] ":"
142 [email protected] " " 142 [email protected] " "
143 REFERENCE[email protected] 143 [email protected]
144 [email protected] "&" 144 [email protected] "&"
145 REFERENCE[email protected] 145 [email protected]
146 [email protected] "&" 146 [email protected] "&"
147 [email protected] 147 [email protected]
148 [email protected] 148 [email protected]
@@ -155,7 +155,7 @@ [email protected]
155 [email protected] "{" 155 [email protected] "{"
156 [email protected] "}" 156 [email protected] "}"
157 [email protected] "\n " 157 [email protected] "\n "
158 FN_DEF@140..167 158 [email protected]
159 [email protected] "fn" 159 [email protected] "fn"
160 [email protected] " " 160 [email protected] " "
161 [email protected] 161 [email protected]
@@ -163,7 +163,7 @@ [email protected]
163 [email protected] 163 [email protected]
164 [email protected] "(" 164 [email protected] "("
165 [email protected] 165 [email protected]
166 PLACEHOLDE[email protected] 166 WILDCARD[email protected]
167 [email protected] "_" 167 [email protected] "_"
168 [email protected] ":" 168 [email protected] ":"
169 [email protected] " " 169 [email protected] " "
@@ -175,7 +175,7 @@ [email protected]
175 [email protected] "," 175 [email protected] ","
176 [email protected] " " 176 [email protected] " "
177 [email protected] 177 [email protected]
178 BIN[email protected] 178 IDENT[email protected]
179 [email protected] "mut" 179 [email protected] "mut"
180 [email protected] " " 180 [email protected] " "
181 [email protected] 181 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.rast b/crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.rast
index 5a9f07c89..4009b3ff8 100644
--- a/crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.rast
@@ -8,7 +8,7 @@ [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "{" 9 [email protected] "{"
10 [email protected] "\n " 10 [email protected] "\n "
11 FN_DEF@17..40 11 [email protected]
12 [email protected] "fn" 12 [email protected] "fn"
13 [email protected] " " 13 [email protected] " "
14 [email protected] 14 [email protected]
@@ -16,11 +16,11 @@ [email protected]
16 [email protected] 16 [email protected]
17 [email protected] "(" 17 [email protected] "("
18 [email protected] 18 [email protected]
19 PLACEHOLDE[email protected] 19 WILDCARD[email protected]
20 [email protected] "_" 20 [email protected] "_"
21 [email protected] ":" 21 [email protected] ":"
22 [email protected] " " 22 [email protected] " "
23 POINTE[email protected] 23 [email protected]
24 [email protected] "*" 24 [email protected] "*"
25 [email protected] "mut" 25 [email protected] "mut"
26 [email protected] " " 26 [email protected] " "
@@ -37,7 +37,7 @@ [email protected]
37 [email protected] ")" 37 [email protected] ")"
38 [email protected] ";" 38 [email protected] ";"
39 [email protected] "\n " 39 [email protected] "\n "
40 FN_DEF@45..70 40 [email protected]
41 [email protected] "fn" 41 [email protected] "fn"
42 [email protected] " " 42 [email protected] " "
43 [email protected] 43 [email protected]
@@ -45,11 +45,11 @@ [email protected]
45 [email protected] 45 [email protected]
46 [email protected] "(" 46 [email protected] "("
47 [email protected] 47 [email protected]
48 PLACEHOLDE[email protected] 48 WILDCARD[email protected]
49 [email protected] "_" 49 [email protected] "_"
50 [email protected] ":" 50 [email protected] ":"
51 [email protected] " " 51 [email protected] " "
52 POINTE[email protected] 52 [email protected]
53 [email protected] "*" 53 [email protected] "*"
54 [email protected] "mut" 54 [email protected] "mut"
55 [email protected] " " 55 [email protected] " "
@@ -61,7 +61,7 @@ [email protected]
61 [email protected] "," 61 [email protected] ","
62 [email protected] " " 62 [email protected] " "
63 [email protected] 63 [email protected]
64 PLACEHOLDE[email protected] 64 WILDCARD[email protected]
65 [email protected] "_" 65 [email protected] "_"
66 [email protected] ":" 66 [email protected] ":"
67 [email protected] " " 67 [email protected] " "
@@ -69,7 +69,7 @@ [email protected]
69 [email protected] ")" 69 [email protected] ")"
70 [email protected] ";" 70 [email protected] ";"
71 [email protected] "\n " 71 [email protected] "\n "
72 FN_DEF@75..123 72 [email protected]
73 [email protected] "fn" 73 [email protected] "fn"
74 [email protected] " " 74 [email protected] " "
75 [email protected] 75 [email protected]
@@ -77,11 +77,11 @@ [email protected]
77 [email protected] 77 [email protected]
78 [email protected] "(" 78 [email protected] "("
79 [email protected] 79 [email protected]
80 PLACEHOLDE[email protected] 80 WILDCARD[email protected]
81 [email protected] "_" 81 [email protected] "_"
82 [email protected] ":" 82 [email protected] ":"
83 [email protected] " " 83 [email protected] " "
84 POINTE[email protected] 84 [email protected]
85 [email protected] "*" 85 [email protected] "*"
86 [email protected] "mut" 86 [email protected] "mut"
87 [email protected] " " 87 [email protected] " "
@@ -108,17 +108,17 @@ [email protected]
108 [email protected] 108 [email protected]
109 [email protected] 109 [email protected]
110 [email protected] "[" 110 [email protected] "["
111 BIN[email protected] 111 IDENT[email protected]
112 [email protected] 112 [email protected]
113 [email protected] "w" 113 [email protected] "w"
114 [email protected] "," 114 [email protected] ","
115 [email protected] " " 115 [email protected] " "
116 BIN[email protected] 116 IDENT[email protected]
117 [email protected] 117 [email protected]
118 [email protected] "t" 118 [email protected] "t"
119 [email protected] "," 119 [email protected] ","
120 [email protected] " " 120 [email protected] " "
121 BIN[email protected] 121 IDENT[email protected]
122 [email protected] 122 [email protected]
123 [email protected] "f" 123 [email protected] "f"
124 [email protected] "]" 124 [email protected] "]"
diff --git a/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast b/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast
index a0423806c..a3c6ed82e 100644
--- a/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..136 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -8,10 +8,10 @@ [email protected]
8 [email protected] 8 [email protected]
9 [email protected] "U" 9 [email protected] "U"
10 [email protected] " " 10 [email protected] " "
11 [email protected] 11 ASSOC_[email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 FN_DEF@13..45 14 [email protected]
15 [email protected] "fn" 15 [email protected] "fn"
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 [email protected]
@@ -21,12 +21,12 @@ [email protected]
21 [email protected] 21 [email protected]
22 [email protected] 22 [email protected]
23 [email protected] "(" 23 [email protected] "("
24 BIN[email protected] 24 IDENT[email protected]
25 [email protected] 25 [email protected]
26 [email protected] "a" 26 [email protected] "a"
27 [email protected] "," 27 [email protected] ","
28 [email protected] " " 28 [email protected] " "
29 BIN[email protected] 29 IDENT[email protected]
30 [email protected] 30 [email protected]
31 [email protected] "b" 31 [email protected] "b"
32 [email protected] ")" 32 [email protected] ")"
@@ -53,7 +53,7 @@ [email protected]
53 [email protected] "{" 53 [email protected] "{"
54 [email protected] "}" 54 [email protected] "}"
55 [email protected] "\n " 55 [email protected] "\n "
56 FN_DEF@50..73 56 [email protected]
57 [email protected] "fn" 57 [email protected] "fn"
58 [email protected] " " 58 [email protected] " "
59 [email protected] 59 [email protected]
@@ -67,17 +67,17 @@ [email protected]
67 [email protected] 67 [email protected]
68 [email protected] "S" 68 [email protected] "S"
69 [email protected] " " 69 [email protected] " "
70 RECORD_FIELD_PAT_[email protected] 70 RECORD_PAT_[email protected]
71 [email protected] "{" 71 [email protected] "{"
72 [email protected] " " 72 [email protected] " "
73 RECORD_FIELD_PAT@60..61 73 RECORD_PAT_[email protected]
74 BIN[email protected] 74 IDENT[email protected]
75 [email protected] 75 [email protected]
76 [email protected] "a" 76 [email protected] "a"
77 [email protected] "," 77 [email protected] ","
78 [email protected] " " 78 [email protected] " "
79 RECORD_FIELD_PAT@63..64 79 RECORD_PAT_[email protected]
80 BIN[email protected] 80 IDENT[email protected]
81 [email protected] 81 [email protected]
82 [email protected] "b" 82 [email protected] "b"
83 [email protected] " " 83 [email protected] " "
@@ -95,7 +95,7 @@ [email protected]
95 [email protected] "{" 95 [email protected] "{"
96 [email protected] "}" 96 [email protected] "}"
97 [email protected] "\n " 97 [email protected] "\n "
98 FN_DEF@78..107 98 [email protected]
99 [email protected] "fn" 99 [email protected] "fn"
100 [email protected] " " 100 [email protected] " "
101 [email protected] 101 [email protected]
@@ -109,7 +109,7 @@ [email protected]
109 [email protected] 109 [email protected]
110 [email protected] "NewType" 110 [email protected] "NewType"
111 [email protected] "(" 111 [email protected] "("
112 BIN[email protected] 112 IDENT[email protected]
113 [email protected] 113 [email protected]
114 [email protected] "a" 114 [email protected] "a"
115 [email protected] ")" 115 [email protected] ")"
@@ -126,7 +126,7 @@ [email protected]
126 [email protected] "{" 126 [email protected] "{"
127 [email protected] "}" 127 [email protected] "}"
128 [email protected] "\n " 128 [email protected] "\n "
129 FN_DEF@112..134 129 [email protected]
130 [email protected] "fn" 130 [email protected] "fn"
131 [email protected] " " 131 [email protected] " "
132 [email protected] 132 [email protected]
@@ -138,14 +138,14 @@ [email protected]
138 [email protected] "&" 138 [email protected] "&"
139 [email protected] 139 [email protected]
140 [email protected] "&" 140 [email protected] "&"
141 BIN[email protected] 141 IDENT[email protected]
142 [email protected] 142 [email protected]
143 [email protected] "a" 143 [email protected] "a"
144 [email protected] ":" 144 [email protected] ":"
145 [email protected] " " 145 [email protected] " "
146 REFERENCE[email protected] 146 [email protected]
147 [email protected] "&" 147 [email protected] "&"
148 REFERENCE[email protected] 148 [email protected]
149 [email protected] "&" 149 [email protected] "&"
150 [email protected] 150 [email protected]
151 [email protected] 151 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0065_comment_newline.rast b/crates/ra_syntax/test_data/parser/ok/0065_comment_newline.rast
index d1fffdd63..29bd38c05 100644
--- a/crates/ra_syntax/test_data/parser/ok/0065_comment_newline.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0065_comment_newline.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 FN_DEF@0..25 2 [email protected]
3 [email protected] "/// Example" 3 [email protected] "/// Example"
4 [email protected] "\n\n" 4 [email protected] "\n\n"
5 [email protected] "fn" 5 [email protected] "fn"
diff --git a/crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast b/crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast
index eb2f8eb3c..2c699ffcb 100644
--- a/crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 FN_DEF@0..39 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "f" 6 [email protected] "f"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
diff --git a/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast b/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast
index dab0247ee..6246a31a6 100644
--- a/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast
@@ -1,5 +1,5 @@
1[email protected] 1[email protected]
2 IMPL_DEF@0..45 2 [email protected]
3 [email protected] "impl" 3 [email protected] "impl"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -16,10 +16,10 @@ [email protected]
16 [email protected] 16 [email protected]
17 [email protected] "Foo" 17 [email protected] "Foo"
18 [email protected] " " 18 [email protected] " "
19 [email protected] 19 ASSOC_[email protected]
20 [email protected] "{" 20 [email protected] "{"
21 [email protected] "\n " 21 [email protected] "\n "
22 CONST_DEF@19..43 22 [email protected]
23 [email protected] "default" 23 [email protected] "default"
24 [email protected] " " 24 [email protected] " "
25 [email protected] "const" 25 [email protected] "const"
diff --git a/crates/ra_syntax/test_data/parser/ok/0067_where_for_pred.rast b/crates/ra_syntax/test_data/parser/ok/0067_where_for_pred.rast
index 503585103..8f8639a37 100644
--- a/crates/ra_syntax/test_data/parser/ok/0067_where_for_pred.rast
+++ b/crates/ra_syntax/test_data/parser/ok/0067_where_for_pred.rast
@@ -1,10 +1,10 @@
1[email protected] 1[email protected]
2 FN_DEF@0..55 2 [email protected]
3 [email protected] "fn" 3 [email protected] "fn"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
6 [email protected] "for_trait" 6 [email protected] "for_trait"
7 TYP[email protected] 7 GENERIC[email protected]
8 [email protected] "<" 8 [email protected] "<"
9 [email protected] 9 [email protected]
10 [email protected] 10 [email protected]
@@ -19,7 +19,7 @@ [email protected]
19 [email protected] "\n " 19 [email protected] "\n "
20 [email protected] 20 [email protected]
21 [email protected] "for" 21 [email protected] "for"
22 TYP[email protected] 22 GENERIC[email protected]
23 [email protected] "<" 23 [email protected] "<"
24 [email protected] 24 [email protected]
25 [email protected] "\'a" 25 [email protected] "\'a"
@@ -42,7 +42,7 @@ [email protected]
42 [email protected] 42 [email protected]
43 [email protected] "(" 43 [email protected] "("
44 [email protected] 44 [email protected]
45 REFERENCE[email protected] 45 [email protected]
46 [email protected] "&" 46 [email protected] "&"
47 [email protected] "\'a" 47 [email protected] "\'a"
48 [email protected] " " 48 [email protected] " "
@@ -59,12 +59,12 @@ [email protected]
59 [email protected] "\n" 59 [email protected] "\n"
60 [email protected] "}" 60 [email protected] "}"
61 [email protected] "\n" 61 [email protected] "\n"
62 FN_DEF@56..107 62 [email protected]
63 [email protected] "fn" 63 [email protected] "fn"
64 [email protected] " " 64 [email protected] " "
65 [email protected] 65 [email protected]
66 [email protected] "for_ref" 66 [email protected] "for_ref"
67 TYP[email protected] 67 GENERIC[email protected]
68 [email protected] "<" 68 [email protected] "<"
69 [email protected] 69 [email protected]
70 [email protected] 70 [email protected]
@@ -79,13 +79,13 @@ [email protected]
79 [email protected] "\n " 79 [email protected] "\n "
80 [email protected] 80 [email protected]
81 [email protected] "for" 81 [email protected] "for"
82 TYP[email protected] 82 GENERIC[email protected]
83 [email protected] "<" 83 [email protected] "<"
84 [email protected] 84 [email protected]
85 [email protected] "\'a" 85 [email protected] "\'a"
86 [email protected] ">" 86 [email protected] ">"
87 [email protected] " " 87 [email protected] " "
88 REFERENCE[email protected] 88 [email protected]
89 [email protected] "&" 89 [email protected] "&"
90 [email protected] "\'a" 90 [email protected] "\'a"
91 [email protected] " " 91 [email protected] " "
@@ -110,12 +110,12 @@ [email protected]
110 [email protected] "\n" 110 [email protected] "\n"
111 [email protected] "}" 111 [email protected] "}"
112 [email protected] "\n" 112 [email protected] "\n"
113 FN_DEF@108..170 113 [email protected]
114 [email protected] "fn" 114 [email protected] "fn"
115 [email protected] " " 115 [email protected] " "
116 [email protected] 116 [email protected]
117 [email protected] "for_parens" 117 [email protected] "for_parens"
118 TYP[email protected] 118 GENERIC[email protected]
119 [email protected] "<" 119 [email protected] "<"
120 [email protected] 120 [email protected]
121 [email protected] 121 [email protected]
@@ -130,7 +130,7 @@ [email protected]
130 [email protected] "\n " 130 [email protected] "\n "
131 [email protected] 131 [email protected]
132 [email protected] "for" 132 [email protected] "for"
133 TYP[email protected] 133 GENERIC[email protected]
134 [email protected] "<" 134 [email protected] "<"
135 [email protected] 135 [email protected]
136 [email protected] "\'a" 136 [email protected] "\'a"
@@ -138,7 +138,7 @@ [email protected]
138 [email protected] " " 138 [email protected] " "
139 [email protected] 139 [email protected]
140 [email protected] "(" 140 [email protected] "("
141 REFERENCE[email protected] 141 [email protected]
142 [email protected] "&" 142 [email protected] "&"
143 [email protected] "\'a" 143 [email protected] "\'a"
144 [email protected] " " 144 [email protected] " "
@@ -160,7 +160,7 @@ [email protected]
160 [email protected] 160 [email protected]
161 [email protected] "(" 161 [email protected] "("
162 [email protected] 162 [email protected]
163 REFERENCE[email protected] 163 [email protected]
164 [email protected] "&" 164 [email protected] "&"
165 [email protected] "\'a" 165 [email protected] "\'a"
166 [email protected] " " 166 [email protected] " "
@@ -177,12 +177,12 @@ [email protected]
177 [email protected] "\n" 177 [email protected] "\n"
178 [email protected] "}" 178 [email protected] "}"
179 [email protected] "\n" 179 [email protected] "\n"
180 FN_DEF@171..223 180 [email protected]
181 [email protected] "fn" 181 [email protected] "fn"
182 [email protected] " " 182 [email protected] " "
183 [email protected] 183 [email protected]
184 [email protected] "for_slice" 184 [email protected] "for_slice"
185 TYP[email protected] 185 GENERIC[email protected]
186 [email protected] "<" 186 [email protected] "<"
187 [email protected] 187 [email protected]
188 [email protected] 188 [email protected]
@@ -197,7 +197,7 @@ [email protected]
197 [email protected] "\n " 197 [email protected] "\n "
198 [email protected] 198 [email protected]
199 [email protected] "for" 199 [email protected] "for"
200 TYP[email protected] 200 GENERIC[email protected]
201 [email protected] "<" 201 [email protected] "<"
202 [email protected] 202 [email protected]
203 [email protected] "\'a" 203 [email protected] "\'a"
@@ -205,7 +205,7 @@ [email protected]
205 [email protected] " " 205 [email protected] " "
206 [email protected] 206 [email protected]
207 [email protected] "[" 207 [email protected] "["
208 REFERENCE[email protected] 208 [email protected]
209 [email protected] "&" 209 [email protected] "&"
210 [email protected] "\'a" 210 [email protected] "\'a"
211 [email protected] " " 211 [email protected] " "
@@ -231,12 +231,12 @@ [email protected]
231 [email protected] "\n" 231 [email protected] "\n"
232 [email protected] "}" 232 [email protected] "}"
233 [email protected] "\n" 233 [email protected] "\n"
234 FN_DEF@224..300 234 [email protected]
235 [email protected] "fn" 235 [email protected] "fn"
236 [email protected] " " 236 [email protected] " "
237 [email protected] 237 [email protected]
238 [email protected] "for_qpath" 238 [email protected] "for_qpath"
239 TYP[email protected] 239 GENERIC[email protected]
240 [email protected] "<" 240 [email protected] "<"
241 [email protected] 241 [email protected]
242 [email protected] 242 [email protected]
@@ -245,12 +245,12 @@ [email protected]
245 [email protected] 245 [email protected]
246 [email protected] "(" 246 [email protected] "("
247 [email protected] 247 [email protected]
248 BIN[email protected] 248 IDENT[email protected]
249 [email protected] 249 [email protected]
250 [email protected] "_t" 250 [email protected] "_t"
251 [email protected] ":" 251 [email protected] ":"
252 [email protected] " " 252 [email protected] " "
253 REFERENCE[email protected] 253 [email protected]
254 [email protected] "&" 254 [email protected] "&"
255 [email protected] 255 [email protected]
256 [email protected] 256 [email protected]
@@ -264,7 +264,7 @@ [email protected]
264 [email protected] "\n " 264 [email protected] "\n "
265 [email protected] 265 [email protected]
266 [email protected] "for" 266 [email protected] "for"
267 TYP[email protected] 267 GENERIC[email protected]
268 [email protected] "<" 268 [email protected] "<"
269 [email protected] 269 [email protected]
270 [email protected] "\'a" 270 [email protected] "\'a"
@@ -275,7 +275,7 @@ [email protected]
275 [email protected] 275 [email protected]
276 [email protected] 276 [email protected]
277 [email protected] "<" 277 [email protected] "<"
278 REFERENCE[email protected] 278 [email protected]
279 [email protected] "&" 279 [email protected] "&"
280 [email protected] "\'a" 280 [email protected] "\'a"
281 [email protected] " " 281 [email protected] " "
@@ -313,12 +313,12 @@ [email protected]
313 [email protected] "\n" 313 [email protected] "\n"
314 [email protected] "}" 314 [email protected] "}"
315 [email protected] "\n" 315 [email protected] "\n"
316 FN_DEF@301..373 316 [email protected]
317 [email protected] "fn" 317 [email protected] "fn"
318 [email protected] " " 318 [email protected] " "
319 [email protected] 319 [email protected]
320 [email protected] "for_for_fn" 320 [email protected] "for_for_fn"
321 TYP[email protected] 321 GENERIC[email protected]
322 [email protected] "<" 322 [email protected] "<"
323 [email protected] 323 [email protected]
324 [email protected] 324 [email protected]
@@ -333,7 +333,7 @@ [email protected]
333 [email protected] "\n " 333 [email protected] "\n "
334 [email protected] 334 [email protected]
335 [email protected] "for" 335 [email protected] "for"
336 TYP[email protected] 336 GENERIC[email protected]
337 [email protected] "<" 337 [email protected] "<"
338 [email protected] 338 [email protected]
339 [email protected] "\'a" 339 [email protected] "\'a"
@@ -341,18 +341,18 @@ [email protected]
341 [email protected] " " 341 [email protected] " "
342 [email protected] 342 [email protected]
343 [email protected] "for" 343 [email protected] "for"
344 TYP[email protected] 344 GENERIC[email protected]
345 [email protected] "<" 345 [email protected] "<"
346 [email protected] 346 [email protected]
347 [email protected] "\'b" 347 [email protected] "\'b"
348 [email protected] ">" 348 [email protected] ">"
349 [email protected] " " 349 [email protected] " "
350 FN_POINTE[email protected] 350 [email protected]
351 [email protected] "fn" 351 [email protected] "fn"
352 [email protected] 352 [email protected]
353 [email protected] "(" 353 [email protected] "("
354 [email protected] 354 [email protected]
355 REFERENCE[email protected] 355 [email protected]
356 [email protected] "&" 356 [email protected] "&"
357 [email protected] "\'a" 357 [email protected] "\'a"
358 [email protected] " " 358 [email protected] " "
@@ -364,7 +364,7 @@ [email protected]
364 [email protected] "," 364 [email protected] ","
365 [email protected] " " 365 [email protected] " "
366 [email protected] 366 [email protected]
367 REFERENCE[email protected] 367 [email protected]
368 [email protected] "&" 368 [email protected] "&"
369 [email protected] "\'b" 369 [email protected] "\'b"
370 [email protected] " " 370 [email protected] " "
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml
index 3f9c820c5..02c1371ac 100644
--- a/crates/rust-analyzer/Cargo.toml
+++ b/crates/rust-analyzer/Cargo.toml
@@ -20,10 +20,10 @@ env_logger = { version = "0.7.1", default-features = false }
20itertools = "0.9.0" 20itertools = "0.9.0"
21jod-thread = "0.1.0" 21jod-thread = "0.1.0"
22log = "0.4.8" 22log = "0.4.8"
23lsp-types = { version = "0.78.0", features = ["proposed"] } 23lsp-types = { version = "0.79.0", features = ["proposed"] }
24parking_lot = "0.11.0" 24parking_lot = "0.11.0"
25pico-args = "0.3.1" 25pico-args = "0.3.1"
26rand = { version = "0.7.3", features = ["small_rng"] } 26oorandom = "11.1.2"
27rustc-hash = "1.1.0" 27rustc-hash = "1.1.0"
28serde = { version = "1.0.106", features = ["derive"] } 28serde = { version = "1.0.106", features = ["derive"] }
29serde_json = "1.0.48" 29serde_json = "1.0.48"
@@ -42,7 +42,7 @@ ra_syntax = { path = "../ra_syntax" }
42ra_text_edit = { path = "../ra_text_edit" } 42ra_text_edit = { path = "../ra_text_edit" }
43vfs = { path = "../vfs" } 43vfs = { path = "../vfs" }
44vfs-notify = { path = "../vfs-notify" } 44vfs-notify = { path = "../vfs-notify" }
45ra_cfg = { path = "../ra_cfg"} 45ra_cfg = { path = "../ra_cfg" }
46ra_toolchain = { path = "../ra_toolchain" } 46ra_toolchain = { path = "../ra_toolchain" }
47 47
48# This should only be used in CLI 48# This should only be used in CLI
diff --git a/crates/rust-analyzer/src/bin/args.rs b/crates/rust-analyzer/src/bin/args.rs
index 741a2a951..d3081e88b 100644
--- a/crates/rust-analyzer/src/bin/args.rs
+++ b/crates/rust-analyzer/src/bin/args.rs
@@ -8,7 +8,7 @@ use std::{env, fmt::Write, path::PathBuf};
8use anyhow::{bail, Result}; 8use anyhow::{bail, Result};
9use pico_args::Arguments; 9use pico_args::Arguments;
10use ra_ssr::{SsrPattern, SsrRule}; 10use ra_ssr::{SsrPattern, SsrRule};
11use rust_analyzer::cli::{BenchWhat, Position, Verbosity}; 11use rust_analyzer::cli::{AnalysisStatsCmd, BenchCmd, BenchWhat, Position, Verbosity};
12use vfs::AbsPathBuf; 12use vfs::AbsPathBuf;
13 13
14pub(crate) struct Args { 14pub(crate) struct Args {
@@ -24,23 +24,8 @@ pub(crate) enum Command {
24 Highlight { 24 Highlight {
25 rainbow: bool, 25 rainbow: bool,
26 }, 26 },
27 Stats { 27 AnalysisStats(AnalysisStatsCmd),
28 randomize: bool, 28 Bench(BenchCmd),
29 parallel: bool,
30 memory_usage: bool,
31 only: Option<String>,
32 with_deps: bool,
33 path: PathBuf,
34 load_output_dirs: bool,
35 with_proc_macro: bool,
36 },
37 Bench {
38 memory_usage: bool,
39 path: PathBuf,
40 what: BenchWhat,
41 load_output_dirs: bool,
42 with_proc_macro: bool,
43 },
44 Diagnostics { 29 Diagnostics {
45 path: PathBuf, 30 path: PathBuf,
46 load_output_dirs: bool, 31 load_output_dirs: bool,
@@ -59,15 +44,16 @@ pub(crate) enum Command {
59 ProcMacro, 44 ProcMacro,
60 RunServer, 45 RunServer,
61 Version, 46 Version,
47 Help,
62} 48}
63 49
64impl Args { 50impl Args {
65 pub(crate) fn parse() -> Result<Result<Args, HelpPrinted>> { 51 pub(crate) fn parse() -> Result<Args> {
66 let mut matches = Arguments::from_env(); 52 let mut matches = Arguments::from_env();
67 53
68 if matches.contains("--version") { 54 if matches.contains("--version") {
69 matches.finish().or_else(handle_extra_flags)?; 55 matches.finish().or_else(handle_extra_flags)?;
70 return Ok(Ok(Args { verbosity: Verbosity::Normal, command: Command::Version })); 56 return Ok(Args { verbosity: Verbosity::Normal, command: Command::Version });
71 } 57 }
72 58
73 let verbosity = match ( 59 let verbosity = match (
@@ -83,15 +69,16 @@ impl Args {
83 (false, true, true) => bail!("Invalid flags: -q conflicts with -v"), 69 (false, true, true) => bail!("Invalid flags: -q conflicts with -v"),
84 }; 70 };
85 71
72 let help = Ok(Args { verbosity, command: Command::Help });
86 let subcommand = match matches.subcommand()? { 73 let subcommand = match matches.subcommand()? {
87 Some(it) => it, 74 Some(it) => it,
88 None => { 75 None => {
89 if matches.contains(["-h", "--help"]) { 76 if matches.contains(["-h", "--help"]) {
90 print_subcommands(); 77 print_subcommands();
91 return Ok(Err(HelpPrinted)); 78 return help;
92 } 79 }
93 matches.finish().or_else(handle_extra_flags)?; 80 matches.finish().or_else(handle_extra_flags)?;
94 return Ok(Ok(Args { verbosity, command: Command::RunServer })); 81 return Ok(Args { verbosity, command: Command::RunServer });
95 } 82 }
96 }; 83 };
97 let command = match subcommand.as_str() { 84 let command = match subcommand.as_str() {
@@ -108,7 +95,7 @@ FLAGS:
108 -h, --help Prints help information 95 -h, --help Prints help information
109 --no-dump" 96 --no-dump"
110 ); 97 );
111 return Ok(Err(HelpPrinted)); 98 return help;
112 } 99 }
113 100
114 let no_dump = matches.contains("--no-dump"); 101 let no_dump = matches.contains("--no-dump");
@@ -127,7 +114,7 @@ USAGE:
127FLAGS: 114FLAGS:
128 -h, --help Prints help inforamtion" 115 -h, --help Prints help inforamtion"
129 ); 116 );
130 return Ok(Err(HelpPrinted)); 117 return help;
131 } 118 }
132 119
133 matches.finish().or_else(handle_extra_flags)?; 120 matches.finish().or_else(handle_extra_flags)?;
@@ -147,7 +134,7 @@ FLAGS:
147 -h, --help Prints help information 134 -h, --help Prints help information
148 -r, --rainbow" 135 -r, --rainbow"
149 ); 136 );
150 return Ok(Err(HelpPrinted)); 137 return help;
151 } 138 }
152 139
153 let rainbow = matches.contains(["-r", "--rainbow"]); 140 let rainbow = matches.contains(["-r", "--rainbow"]);
@@ -181,7 +168,7 @@ OPTIONS:
181ARGS: 168ARGS:
182 <PATH>" 169 <PATH>"
183 ); 170 );
184 return Ok(Err(HelpPrinted)); 171 return help;
185 } 172 }
186 173
187 let randomize = matches.contains("--randomize"); 174 let randomize = matches.contains("--randomize");
@@ -199,7 +186,7 @@ ARGS:
199 trailing.pop().unwrap().into() 186 trailing.pop().unwrap().into()
200 }; 187 };
201 188
202 Command::Stats { 189 Command::AnalysisStats(AnalysisStatsCmd {
203 randomize, 190 randomize,
204 parallel, 191 parallel,
205 memory_usage, 192 memory_usage,
@@ -208,7 +195,7 @@ ARGS:
208 path, 195 path,
209 load_output_dirs, 196 load_output_dirs,
210 with_proc_macro, 197 with_proc_macro,
211 } 198 })
212 } 199 }
213 "analysis-bench" => { 200 "analysis-bench" => {
214 if matches.contains(["-h", "--help"]) { 201 if matches.contains(["-h", "--help"]) {
@@ -235,7 +222,7 @@ OPTIONS:
235ARGS: 222ARGS:
236 <PATH> Project to analyse" 223 <PATH> Project to analyse"
237 ); 224 );
238 return Ok(Err(HelpPrinted)); 225 return help;
239 } 226 }
240 227
241 let path: PathBuf = matches.opt_value_from_str("--project")?.unwrap_or_default(); 228 let path: PathBuf = matches.opt_value_from_str("--project")?.unwrap_or_default();
@@ -256,7 +243,13 @@ ARGS:
256 let memory_usage = matches.contains("--memory-usage"); 243 let memory_usage = matches.contains("--memory-usage");
257 let load_output_dirs = matches.contains("--load-output-dirs"); 244 let load_output_dirs = matches.contains("--load-output-dirs");
258 let with_proc_macro = matches.contains("--with-proc-macro"); 245 let with_proc_macro = matches.contains("--with-proc-macro");
259 Command::Bench { memory_usage, path, what, load_output_dirs, with_proc_macro } 246 Command::Bench(BenchCmd {
247 memory_usage,
248 path,
249 what,
250 load_output_dirs,
251 with_proc_macro,
252 })
260 } 253 }
261 "diagnostics" => { 254 "diagnostics" => {
262 if matches.contains(["-h", "--help"]) { 255 if matches.contains(["-h", "--help"]) {
@@ -275,7 +268,7 @@ FLAGS:
275ARGS: 268ARGS:
276 <PATH>" 269 <PATH>"
277 ); 270 );
278 return Ok(Err(HelpPrinted)); 271 return help;
279 } 272 }
280 273
281 let load_output_dirs = matches.contains("--load-output-dirs"); 274 let load_output_dirs = matches.contains("--load-output-dirs");
@@ -311,7 +304,7 @@ FLAGS:
311ARGS: 304ARGS:
312 <RULE> A structured search replace rule" 305 <RULE> A structured search replace rule"
313 ); 306 );
314 return Ok(Err(HelpPrinted)); 307 return help;
315 } 308 }
316 let mut rules = Vec::new(); 309 let mut rules = Vec::new();
317 while let Some(rule) = matches.free_from_str()? { 310 while let Some(rule) = matches.free_from_str()? {
@@ -338,7 +331,7 @@ FLAGS:
338ARGS: 331ARGS:
339 <PATTERN> A structured search pattern" 332 <PATTERN> A structured search pattern"
340 ); 333 );
341 return Ok(Err(HelpPrinted)); 334 return help;
342 } 335 }
343 let debug_snippet = matches.opt_value_from_str("--debug")?; 336 let debug_snippet = matches.opt_value_from_str("--debug")?;
344 let mut patterns = Vec::new(); 337 let mut patterns = Vec::new();
@@ -349,10 +342,10 @@ ARGS:
349 } 342 }
350 _ => { 343 _ => {
351 print_subcommands(); 344 print_subcommands();
352 return Ok(Err(HelpPrinted)); 345 return help;
353 } 346 }
354 }; 347 };
355 Ok(Ok(Args { verbosity, command })) 348 Ok(Args { verbosity, command })
356 } 349 }
357} 350}
358 351
@@ -380,8 +373,6 @@ SUBCOMMANDS:
380 ) 373 )
381} 374}
382 375
383pub(crate) struct HelpPrinted;
384
385fn handle_extra_flags(e: pico_args::Error) -> Result<()> { 376fn handle_extra_flags(e: pico_args::Error) -> Result<()> {
386 if let pico_args::Error::UnusedArgsLeft(flags) = e { 377 if let pico_args::Error::UnusedArgsLeft(flags) = e {
387 let mut invalid_flags = String::new(); 378 let mut invalid_flags = String::new();
diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs
index a473c9165..fc7f8b01d 100644
--- a/crates/rust-analyzer/src/bin/main.rs
+++ b/crates/rust-analyzer/src/bin/main.rs
@@ -3,7 +3,7 @@
3//! Based on cli flags, either spawns an LSP server, or runs a batch analysis 3//! Based on cli flags, either spawns an LSP server, or runs a batch analysis
4mod args; 4mod args;
5 5
6use std::convert::TryFrom; 6use std::{convert::TryFrom, process};
7 7
8use lsp_server::Connection; 8use lsp_server::Connection;
9use ra_project_model::ProjectManifest; 9use ra_project_model::ProjectManifest;
@@ -14,18 +14,20 @@ use rust_analyzer::{
14}; 14};
15use vfs::AbsPathBuf; 15use vfs::AbsPathBuf;
16 16
17use crate::args::HelpPrinted;
18
19#[cfg(all(feature = "mimalloc"))] 17#[cfg(all(feature = "mimalloc"))]
20#[global_allocator] 18#[global_allocator]
21static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; 19static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
22 20
23fn main() -> Result<()> { 21fn main() {
22 if let Err(err) = try_main() {
23 eprintln!("{}", err);
24 process::exit(101);
25 }
26}
27
28fn try_main() -> Result<()> {
24 setup_logging()?; 29 setup_logging()?;
25 let args = match args::Args::parse()? { 30 let args = args::Args::parse()?;
26 Ok(it) => it,
27 Err(HelpPrinted) => return Ok(()),
28 };
29 match args.command { 31 match args.command {
30 args::Command::RunServer => run_server()?, 32 args::Command::RunServer => run_server()?,
31 args::Command::ProcMacro => ra_proc_macro_srv::cli::run()?, 33 args::Command::ProcMacro => ra_proc_macro_srv::cli::run()?,
@@ -33,36 +35,8 @@ fn main() -> Result<()> {
33 args::Command::Parse { no_dump } => cli::parse(no_dump)?, 35 args::Command::Parse { no_dump } => cli::parse(no_dump)?,
34 args::Command::Symbols => cli::symbols()?, 36 args::Command::Symbols => cli::symbols()?,
35 args::Command::Highlight { rainbow } => cli::highlight(rainbow)?, 37 args::Command::Highlight { rainbow } => cli::highlight(rainbow)?,
36 args::Command::Stats { 38 args::Command::AnalysisStats(cmd) => cmd.run(args.verbosity)?,
37 randomize, 39 args::Command::Bench(cmd) => cmd.run(args.verbosity)?,
38 parallel,
39 memory_usage,
40 only,
41 with_deps,
42 path,
43 load_output_dirs,
44 with_proc_macro,
45 } => cli::analysis_stats(
46 args.verbosity,
47 memory_usage,
48 path.as_ref(),
49 only.as_ref().map(String::as_ref),
50 with_deps,
51 randomize,
52 parallel,
53 load_output_dirs,
54 with_proc_macro,
55 )?,
56 args::Command::Bench { memory_usage, path, what, load_output_dirs, with_proc_macro } => {
57 cli::analysis_bench(
58 args.verbosity,
59 path.as_ref(),
60 what,
61 memory_usage,
62 load_output_dirs,
63 with_proc_macro,
64 )?
65 }
66 args::Command::Diagnostics { path, load_output_dirs, with_proc_macro, all } => { 40 args::Command::Diagnostics { path, load_output_dirs, with_proc_macro, all } => {
67 cli::diagnostics(path.as_ref(), load_output_dirs, with_proc_macro, all)? 41 cli::diagnostics(path.as_ref(), load_output_dirs, with_proc_macro, all)?
68 } 42 }
@@ -73,6 +47,7 @@ fn main() -> Result<()> {
73 cli::search_for_patterns(patterns, debug_snippet)?; 47 cli::search_for_patterns(patterns, debug_snippet)?;
74 } 48 }
75 args::Command::Version => println!("rust-analyzer {}", env!("REV")), 49 args::Command::Version => println!("rust-analyzer {}", env!("REV")),
50 args::Command::Help => {}
76 } 51 }
77 Ok(()) 52 Ok(())
78} 53}
diff --git a/crates/rust-analyzer/src/caps.rs b/crates/rust-analyzer/src/caps.rs
index 37d695448..92a743fd8 100644
--- a/crates/rust-analyzer/src/caps.rs
+++ b/crates/rust-analyzer/src/caps.rs
@@ -76,7 +76,9 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti
76 token_modifiers: semantic_tokens::SUPPORTED_MODIFIERS.to_vec(), 76 token_modifiers: semantic_tokens::SUPPORTED_MODIFIERS.to_vec(),
77 }, 77 },
78 78
79 document_provider: Some(SemanticTokensDocumentProvider::Bool(true)), 79 document_provider: Some(SemanticTokensDocumentProvider::Edits {
80 edits: Some(true),
81 }),
80 range_provider: Some(true), 82 range_provider: Some(true),
81 work_done_progress_options: Default::default(), 83 work_done_progress_options: Default::default(),
82 } 84 }
diff --git a/crates/rust-analyzer/src/cli.rs b/crates/rust-analyzer/src/cli.rs
index a9b9c8923..1034d11bd 100644
--- a/crates/rust-analyzer/src/cli.rs
+++ b/crates/rust-analyzer/src/cli.rs
@@ -14,8 +14,8 @@ use ra_ide::Analysis;
14use ra_prof::profile; 14use ra_prof::profile;
15use ra_syntax::{AstNode, SourceFile}; 15use ra_syntax::{AstNode, SourceFile};
16 16
17pub use analysis_bench::{analysis_bench, BenchWhat, Position}; 17pub use analysis_bench::{BenchCmd, BenchWhat, Position};
18pub use analysis_stats::analysis_stats; 18pub use analysis_stats::AnalysisStatsCmd;
19pub use diagnostics::diagnostics; 19pub use diagnostics::diagnostics;
20pub use load_cargo::load_cargo; 20pub use load_cargo::load_cargo;
21pub use ssr::{apply_ssr_rules, search_for_patterns}; 21pub use ssr::{apply_ssr_rules, search_for_patterns};
diff --git a/crates/rust-analyzer/src/cli/analysis_bench.rs b/crates/rust-analyzer/src/cli/analysis_bench.rs
index 076184ad6..c54ee5f4d 100644
--- a/crates/rust-analyzer/src/cli/analysis_bench.rs
+++ b/crates/rust-analyzer/src/cli/analysis_bench.rs
@@ -1,8 +1,8 @@
1//! Benchmark operations like highlighting or goto definition. 1//! Benchmark operations like highlighting or goto definition.
2 2
3use std::{env, path::Path, str::FromStr, sync::Arc, time::Instant}; 3use std::{env, path::PathBuf, str::FromStr, sync::Arc, time::Instant};
4 4
5use anyhow::{format_err, Result}; 5use anyhow::{bail, format_err, Result};
6use ra_db::{ 6use ra_db::{
7 salsa::{Database, Durability}, 7 salsa::{Database, Durability},
8 FileId, 8 FileId,
@@ -15,6 +15,14 @@ use crate::{
15 print_memory_usage, 15 print_memory_usage,
16}; 16};
17 17
18pub struct BenchCmd {
19 pub path: PathBuf,
20 pub what: BenchWhat,
21 pub memory_usage: bool,
22 pub load_output_dirs: bool,
23 pub with_proc_macro: bool,
24}
25
18pub enum BenchWhat { 26pub enum BenchWhat {
19 Highlight { path: AbsPathBuf }, 27 Highlight { path: AbsPathBuf },
20 Complete(Position), 28 Complete(Position),
@@ -30,85 +38,80 @@ pub struct Position {
30impl FromStr for Position { 38impl FromStr for Position {
31 type Err = anyhow::Error; 39 type Err = anyhow::Error;
32 fn from_str(s: &str) -> Result<Self> { 40 fn from_str(s: &str) -> Result<Self> {
33 let (path_line, column) = rsplit_at_char(s, ':')?; 41 let mut split = s.rsplitn(3, ':');
34 let (path, line) = rsplit_at_char(path_line, ':')?; 42 match (split.next(), split.next(), split.next()) {
35 let path = env::current_dir().unwrap().join(path); 43 (Some(column), Some(line), Some(path)) => {
36 let path = AbsPathBuf::assert(path); 44 let path = env::current_dir().unwrap().join(path);
37 Ok(Position { path, line: line.parse()?, column: column.parse()? }) 45 let path = AbsPathBuf::assert(path);
46 Ok(Position { path, line: line.parse()?, column: column.parse()? })
47 }
48 _ => bail!("position should be in file:line:column format: {:?}", s),
49 }
38 } 50 }
39} 51}
40 52
41fn rsplit_at_char(s: &str, c: char) -> Result<(&str, &str)> { 53impl BenchCmd {
42 let idx = s.rfind(c).ok_or_else(|| format_err!("no `{}` in {}", c, s))?; 54 pub fn run(self, verbosity: Verbosity) -> Result<()> {
43 Ok((&s[..idx], &s[idx + 1..])) 55 ra_prof::init();
44}
45 56
46pub fn analysis_bench( 57 let start = Instant::now();
47 verbosity: Verbosity, 58 eprint!("loading: ");
48 path: &Path, 59 let (mut host, vfs) = load_cargo(&self.path, self.load_output_dirs, self.with_proc_macro)?;
49 what: BenchWhat, 60 eprintln!("{:?}\n", start.elapsed());
50 memory_usage: bool, 61
51 load_output_dirs: bool, 62 let file_id = {
52 with_proc_macro: bool, 63 let path = match &self.what {
53) -> Result<()> { 64 BenchWhat::Highlight { path } => path,
54 ra_prof::init(); 65 BenchWhat::Complete(pos) | BenchWhat::GotoDef(pos) => &pos.path,
55 66 };
56 let start = Instant::now(); 67 let path = path.clone().into();
57 eprint!("loading: "); 68 vfs.file_id(&path).ok_or_else(|| format_err!("Can't find {}", path))?
58 let (mut host, vfs) = load_cargo(path, load_output_dirs, with_proc_macro)?;
59 eprintln!("{:?}\n", start.elapsed());
60
61 let file_id = {
62 let path = match &what {
63 BenchWhat::Highlight { path } => path,
64 BenchWhat::Complete(pos) | BenchWhat::GotoDef(pos) => &pos.path,
65 }; 69 };
66 let path = path.clone().into();
67 vfs.file_id(&path).ok_or_else(|| format_err!("Can't find {}", path))?
68 };
69
70 match &what {
71 BenchWhat::Highlight { .. } => {
72 let res = do_work(&mut host, file_id, |analysis| {
73 analysis.diagnostics(file_id, true).unwrap();
74 analysis.highlight_as_html(file_id, false).unwrap()
75 });
76 if verbosity.is_verbose() {
77 println!("\n{}", res);
78 }
79 }
80 BenchWhat::Complete(pos) | BenchWhat::GotoDef(pos) => {
81 let is_completion = matches!(what, BenchWhat::Complete(..));
82 70
83 let offset = host 71 match &self.what {
84 .analysis() 72 BenchWhat::Highlight { .. } => {
85 .file_line_index(file_id)?
86 .offset(LineCol { line: pos.line - 1, col_utf16: pos.column });
87 let file_position = FilePosition { file_id, offset };
88
89 if is_completion {
90 let options = CompletionConfig::default();
91 let res = do_work(&mut host, file_id, |analysis| { 73 let res = do_work(&mut host, file_id, |analysis| {
92 analysis.completions(&options, file_position) 74 analysis.diagnostics(file_id, true).unwrap();
75 analysis.highlight_as_html(file_id, false).unwrap()
93 }); 76 });
94 if verbosity.is_verbose() { 77 if verbosity.is_verbose() {
95 println!("\n{:#?}", res); 78 println!("\n{}", res);
96 } 79 }
97 } else { 80 }
98 let res = 81 BenchWhat::Complete(pos) | BenchWhat::GotoDef(pos) => {
99 do_work(&mut host, file_id, |analysis| analysis.goto_definition(file_position)); 82 let is_completion = matches!(self.what, BenchWhat::Complete(..));
100 if verbosity.is_verbose() { 83
101 println!("\n{:#?}", res); 84 let offset = host
85 .analysis()
86 .file_line_index(file_id)?
87 .offset(LineCol { line: pos.line - 1, col_utf16: pos.column });
88 let file_position = FilePosition { file_id, offset };
89
90 if is_completion {
91 let options = CompletionConfig::default();
92 let res = do_work(&mut host, file_id, |analysis| {
93 analysis.completions(&options, file_position)
94 });
95 if verbosity.is_verbose() {
96 println!("\n{:#?}", res);
97 }
98 } else {
99 let res = do_work(&mut host, file_id, |analysis| {
100 analysis.goto_definition(file_position)
101 });
102 if verbosity.is_verbose() {
103 println!("\n{:#?}", res);
104 }
102 } 105 }
103 } 106 }
104 } 107 }
105 }
106 108
107 if memory_usage { 109 if self.memory_usage {
108 print_memory_usage(host, vfs); 110 print_memory_usage(host, vfs);
109 } 111 }
110 112
111 Ok(()) 113 Ok(())
114 }
112} 115}
113 116
114fn do_work<F: Fn(&Analysis) -> T, T>(host: &mut AnalysisHost, file_id: FileId, work: F) -> T { 117fn do_work<F: Fn(&Analysis) -> T, T>(host: &mut AnalysisHost, file_id: FileId, work: F) -> T {
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs
index ccc058682..721d41a58 100644
--- a/crates/rust-analyzer/src/cli/analysis_stats.rs
+++ b/crates/rust-analyzer/src/cli/analysis_stats.rs
@@ -1,7 +1,10 @@
1//! Fully type-check project and print various stats, like the number of type 1//! Fully type-check project and print various stats, like the number of type
2//! errors. 2//! errors.
3 3
4use std::{path::Path, time::Instant}; 4use std::{
5 path::PathBuf,
6 time::{SystemTime, UNIX_EPOCH},
7};
5 8
6use hir::{ 9use hir::{
7 db::{AstDatabase, DefDatabase, HirDatabase}, 10 db::{AstDatabase, DefDatabase, HirDatabase},
@@ -10,12 +13,12 @@ use hir::{
10use hir_def::FunctionId; 13use hir_def::FunctionId;
11use hir_ty::{Ty, TypeWalk}; 14use hir_ty::{Ty, TypeWalk};
12use itertools::Itertools; 15use itertools::Itertools;
16use oorandom::Rand32;
13use ra_db::{ 17use ra_db::{
14 salsa::{self, ParallelDatabase}, 18 salsa::{self, ParallelDatabase},
15 SourceDatabaseExt, 19 SourceDatabaseExt,
16}; 20};
17use ra_syntax::AstNode; 21use ra_syntax::AstNode;
18use rand::{seq::SliceRandom, thread_rng};
19use rayon::prelude::*; 22use rayon::prelude::*;
20use rustc_hash::FxHashSet; 23use rustc_hash::FxHashSet;
21use stdx::format_to; 24use stdx::format_to;
@@ -26,6 +29,7 @@ use crate::{
26 }, 29 },
27 print_memory_usage, 30 print_memory_usage,
28}; 31};
32use ra_prof::StopWatch;
29 33
30/// Need to wrap Snapshot to provide `Clone` impl for `map_with` 34/// Need to wrap Snapshot to provide `Clone` impl for `map_with`
31struct Snap<DB>(DB); 35struct Snap<DB>(DB);
@@ -35,274 +39,290 @@ impl<DB: ParallelDatabase> Clone for Snap<salsa::Snapshot<DB>> {
35 } 39 }
36} 40}
37 41
38pub fn analysis_stats( 42pub struct AnalysisStatsCmd {
39 verbosity: Verbosity, 43 pub randomize: bool,
40 memory_usage: bool, 44 pub parallel: bool,
41 path: &Path, 45 pub memory_usage: bool,
42 only: Option<&str>, 46 pub only: Option<String>,
43 with_deps: bool, 47 pub with_deps: bool,
44 randomize: bool, 48 pub path: PathBuf,
45 parallel: bool, 49 pub load_output_dirs: bool,
46 load_output_dirs: bool, 50 pub with_proc_macro: bool,
47 with_proc_macro: bool, 51}
48) -> Result<()> {
49 let db_load_time = Instant::now();
50 let (host, vfs) = load_cargo(path, load_output_dirs, with_proc_macro)?;
51 let db = host.raw_database();
52 eprintln!("Database loaded {:?}", db_load_time.elapsed());
53 let analysis_time = Instant::now();
54 let mut num_crates = 0;
55 let mut visited_modules = FxHashSet::default();
56 let mut visit_queue = Vec::new();
57 52
58 let mut krates = Crate::all(db); 53impl AnalysisStatsCmd {
59 if randomize { 54 pub fn run(self, verbosity: Verbosity) -> Result<()> {
60 krates.shuffle(&mut thread_rng()); 55 let mut rng = {
61 } 56 let seed = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis() as u64;
62 for krate in krates { 57 Rand32::new(seed)
63 let module = krate.root_module(db).expect("crate without root module"); 58 };
64 let file_id = module.definition_source(db).file_id;
65 let file_id = file_id.original_file(db);
66 let source_root = db.file_source_root(file_id);
67 let source_root = db.source_root(source_root);
68 if !source_root.is_library || with_deps {
69 num_crates += 1;
70 visit_queue.push(module);
71 }
72 }
73 59
74 if randomize { 60 let mut db_load_sw = self.stop_watch();
75 visit_queue.shuffle(&mut thread_rng()); 61 let (host, vfs) = load_cargo(&self.path, self.load_output_dirs, self.with_proc_macro)?;
76 } 62 let db = host.raw_database();
63 eprintln!("Database loaded {}", db_load_sw.elapsed());
77 64
78 eprintln!("Crates in this dir: {}", num_crates); 65 let mut analysis_sw = self.stop_watch();
79 let mut num_decls = 0; 66 let mut num_crates = 0;
80 let mut funcs = Vec::new(); 67 let mut visited_modules = FxHashSet::default();
81 while let Some(module) = visit_queue.pop() { 68 let mut visit_queue = Vec::new();
82 if visited_modules.insert(module) {
83 visit_queue.extend(module.children(db));
84 69
85 for decl in module.declarations(db) { 70 let mut krates = Crate::all(db);
86 num_decls += 1; 71 if self.randomize {
87 if let ModuleDef::Function(f) = decl { 72 shuffle(&mut rng, &mut krates);
88 funcs.push(f); 73 }
89 } 74 for krate in krates {
75 let module = krate.root_module(db).expect("crate without root module");
76 let file_id = module.definition_source(db).file_id;
77 let file_id = file_id.original_file(db);
78 let source_root = db.file_source_root(file_id);
79 let source_root = db.source_root(source_root);
80 if !source_root.is_library || self.with_deps {
81 num_crates += 1;
82 visit_queue.push(module);
90 } 83 }
84 }
85
86 if self.randomize {
87 shuffle(&mut rng, &mut visit_queue);
88 }
89
90 eprintln!("Crates in this dir: {}", num_crates);
91 let mut num_decls = 0;
92 let mut funcs = Vec::new();
93 while let Some(module) = visit_queue.pop() {
94 if visited_modules.insert(module) {
95 visit_queue.extend(module.children(db));
91 96
92 for impl_def in module.impl_defs(db) { 97 for decl in module.declarations(db) {
93 for item in impl_def.items(db) {
94 num_decls += 1; 98 num_decls += 1;
95 if let AssocItem::Function(f) = item { 99 if let ModuleDef::Function(f) = decl {
96 funcs.push(f); 100 funcs.push(f);
97 } 101 }
98 } 102 }
103
104 for impl_def in module.impl_defs(db) {
105 for item in impl_def.items(db) {
106 num_decls += 1;
107 if let AssocItem::Function(f) = item {
108 funcs.push(f);
109 }
110 }
111 }
99 } 112 }
100 } 113 }
101 } 114 eprintln!("Total modules found: {}", visited_modules.len());
102 eprintln!("Total modules found: {}", visited_modules.len()); 115 eprintln!("Total declarations: {}", num_decls);
103 eprintln!("Total declarations: {}", num_decls); 116 eprintln!("Total functions: {}", funcs.len());
104 eprintln!("Total functions: {}", funcs.len()); 117 eprintln!("Item Collection: {}", analysis_sw.elapsed());
105 let item_collection_memory = ra_prof::memory_usage();
106 eprintln!(
107 "Item Collection: {:?}, {}",
108 analysis_time.elapsed(),
109 item_collection_memory.allocated
110 );
111 118
112 if randomize { 119 if self.randomize {
113 funcs.shuffle(&mut thread_rng()); 120 shuffle(&mut rng, &mut funcs);
114 } 121 }
115 122
116 let mut bar = match verbosity { 123 let mut bar = match verbosity {
117 Verbosity::Quiet | Verbosity::Spammy => ProgressReport::hidden(), 124 Verbosity::Quiet | Verbosity::Spammy => ProgressReport::hidden(),
118 _ => ProgressReport::new(funcs.len() as u64), 125 _ if self.parallel => ProgressReport::hidden(),
119 }; 126 _ => ProgressReport::new(funcs.len() as u64),
127 };
120 128
121 if parallel { 129 if self.parallel {
122 let inference_time = Instant::now(); 130 let mut inference_sw = self.stop_watch();
123 let snap = Snap(db.snapshot()); 131 let snap = Snap(db.snapshot());
124 funcs 132 funcs
125 .par_iter() 133 .par_iter()
126 .map_with(snap, |snap, &f| { 134 .map_with(snap, |snap, &f| {
127 let f_id = FunctionId::from(f); 135 let f_id = FunctionId::from(f);
128 snap.0.body(f_id.into()); 136 snap.0.body(f_id.into());
129 snap.0.infer(f_id.into()); 137 snap.0.infer(f_id.into());
130 }) 138 })
131 .count(); 139 .count();
132 eprintln!( 140 eprintln!("Parallel Inference: {}", inference_sw.elapsed());
133 "Parallel Inference: {:?}, {}",
134 inference_time.elapsed(),
135 ra_prof::memory_usage().allocated
136 );
137 }
138
139 let inference_time = Instant::now();
140 bar.tick();
141 let mut num_exprs = 0;
142 let mut num_exprs_unknown = 0;
143 let mut num_exprs_partially_unknown = 0;
144 let mut num_type_mismatches = 0;
145 for f in funcs {
146 let name = f.name(db);
147 let full_name = f
148 .module(db)
149 .path_to_root(db)
150 .into_iter()
151 .rev()
152 .filter_map(|it| it.name(db))
153 .chain(Some(f.name(db)))
154 .join("::");
155 if let Some(only_name) = only {
156 if name.to_string() != only_name && full_name != only_name {
157 continue;
158 }
159 } 141 }
160 let mut msg = format!("processing: {}", full_name); 142
161 if verbosity.is_verbose() { 143 let mut inference_sw = self.stop_watch();
162 let src = f.source(db); 144 bar.tick();
163 let original_file = src.file_id.original_file(db); 145 let mut num_exprs = 0;
164 let path = vfs.file_path(original_file); 146 let mut num_exprs_unknown = 0;
165 let syntax_range = src.value.syntax().text_range(); 147 let mut num_exprs_partially_unknown = 0;
166 format_to!(msg, " ({} {:?})", path, syntax_range); 148 let mut num_type_mismatches = 0;
167 } 149 for f in funcs {
168 if verbosity.is_spammy() { 150 let name = f.name(db);
169 bar.println(msg.to_string()); 151 let full_name = f
170 } 152 .module(db)
171 bar.set_message(&msg); 153 .path_to_root(db)
172 let f_id = FunctionId::from(f); 154 .into_iter()
173 let body = db.body(f_id.into()); 155 .rev()
174 let inference_result = db.infer(f_id.into()); 156 .filter_map(|it| it.name(db))
175 let (previous_exprs, previous_unknown, previous_partially_unknown) = 157 .chain(Some(f.name(db)))
176 (num_exprs, num_exprs_unknown, num_exprs_partially_unknown); 158 .join("::");
177 for (expr_id, _) in body.exprs.iter() { 159 if let Some(only_name) = self.only.as_deref() {
178 let ty = &inference_result[expr_id]; 160 if name.to_string() != only_name && full_name != only_name {
179 num_exprs += 1; 161 continue;
180 if let Ty::Unknown = ty {
181 num_exprs_unknown += 1;
182 } else {
183 let mut is_partially_unknown = false;
184 ty.walk(&mut |ty| {
185 if let Ty::Unknown = ty {
186 is_partially_unknown = true;
187 }
188 });
189 if is_partially_unknown {
190 num_exprs_partially_unknown += 1;
191 } 162 }
192 } 163 }
193 if only.is_some() && verbosity.is_spammy() { 164 let mut msg = format!("processing: {}", full_name);
194 // in super-verbose mode for just one function, we print every single expression 165 if verbosity.is_verbose() {
195 let (_, sm) = db.body_with_source_map(f_id.into()); 166 let src = f.source(db);
196 let src = sm.expr_syntax(expr_id); 167 let original_file = src.file_id.original_file(db);
197 if let Ok(src) = src { 168 let path = vfs.file_path(original_file);
198 let node = { 169 let syntax_range = src.value.syntax().text_range();
199 let root = db.parse_or_expand(src.file_id).unwrap(); 170 format_to!(msg, " ({} {:?})", path, syntax_range);
200 src.value.to_node(&root) 171 }
201 }; 172 if verbosity.is_spammy() {
202 let original_file = src.file_id.original_file(db); 173 bar.println(msg.to_string());
203 let line_index = host.analysis().file_line_index(original_file).unwrap(); 174 }
204 let text_range = node.syntax().text_range(); 175 bar.set_message(&msg);
205 let (start, end) = ( 176 let f_id = FunctionId::from(f);
206 line_index.line_col(text_range.start()), 177 let body = db.body(f_id.into());
207 line_index.line_col(text_range.end()), 178 let inference_result = db.infer(f_id.into());
208 ); 179 let (previous_exprs, previous_unknown, previous_partially_unknown) =
209 bar.println(format!( 180 (num_exprs, num_exprs_unknown, num_exprs_partially_unknown);
210 "{}:{}-{}:{}: {}", 181 for (expr_id, _) in body.exprs.iter() {
211 start.line + 1, 182 let ty = &inference_result[expr_id];
212 start.col_utf16, 183 num_exprs += 1;
213 end.line + 1, 184 if let Ty::Unknown = ty {
214 end.col_utf16, 185 num_exprs_unknown += 1;
215 ty.display(db)
216 ));
217 } else { 186 } else {
218 bar.println(format!("unknown location: {}", ty.display(db))); 187 let mut is_partially_unknown = false;
188 ty.walk(&mut |ty| {
189 if let Ty::Unknown = ty {
190 is_partially_unknown = true;
191 }
192 });
193 if is_partially_unknown {
194 num_exprs_partially_unknown += 1;
195 }
219 } 196 }
220 } 197 if self.only.is_some() && verbosity.is_spammy() {
221 if let Some(mismatch) = inference_result.type_mismatch_for_expr(expr_id) { 198 // in super-verbose mode for just one function, we print every single expression
222 num_type_mismatches += 1;
223 if verbosity.is_verbose() {
224 let (_, sm) = db.body_with_source_map(f_id.into()); 199 let (_, sm) = db.body_with_source_map(f_id.into());
225 let src = sm.expr_syntax(expr_id); 200 let src = sm.expr_syntax(expr_id);
226 if let Ok(src) = src { 201 if let Ok(src) = src {
227 // FIXME: it might be nice to have a function (on Analysis?) that goes from Source<T> -> (LineCol, LineCol) directly 202 let node = {
228 // But also, we should just turn the type mismatches into diagnostics and provide these 203 let root = db.parse_or_expand(src.file_id).unwrap();
229 let root = db.parse_or_expand(src.file_id).unwrap(); 204 src.value.to_node(&root)
230 let node = src.map(|e| e.to_node(&root).syntax().clone()); 205 };
231 let original_range = original_range(db, node.as_ref()); 206 let original_file = src.file_id.original_file(db);
232 let path = vfs.file_path(original_range.file_id); 207 let line_index = host.analysis().file_line_index(original_file).unwrap();
233 let line_index = 208 let text_range = node.syntax().text_range();
234 host.analysis().file_line_index(original_range.file_id).unwrap();
235 let text_range = original_range.range;
236 let (start, end) = ( 209 let (start, end) = (
237 line_index.line_col(text_range.start()), 210 line_index.line_col(text_range.start()),
238 line_index.line_col(text_range.end()), 211 line_index.line_col(text_range.end()),
239 ); 212 );
240 bar.println(format!( 213 bar.println(format!(
241 "{} {}:{}-{}:{}: Expected {}, got {}", 214 "{}:{}-{}:{}: {}",
242 path,
243 start.line + 1, 215 start.line + 1,
244 start.col_utf16, 216 start.col_utf16,
245 end.line + 1, 217 end.line + 1,
246 end.col_utf16, 218 end.col_utf16,
247 mismatch.expected.display(db), 219 ty.display(db)
248 mismatch.actual.display(db)
249 )); 220 ));
250 } else { 221 } else {
251 bar.println(format!( 222 bar.println(format!("unknown location: {}", ty.display(db)));
252 "{}: Expected {}, got {}", 223 }
253 name, 224 }
254 mismatch.expected.display(db), 225 if let Some(mismatch) = inference_result.type_mismatch_for_expr(expr_id) {
255 mismatch.actual.display(db) 226 num_type_mismatches += 1;
256 )); 227 if verbosity.is_verbose() {
228 let (_, sm) = db.body_with_source_map(f_id.into());
229 let src = sm.expr_syntax(expr_id);
230 if let Ok(src) = src {
231 // FIXME: it might be nice to have a function (on Analysis?) that goes from Source<T> -> (LineCol, LineCol) directly
232 // But also, we should just turn the type mismatches into diagnostics and provide these
233 let root = db.parse_or_expand(src.file_id).unwrap();
234 let node = src.map(|e| e.to_node(&root).syntax().clone());
235 let original_range = original_range(db, node.as_ref());
236 let path = vfs.file_path(original_range.file_id);
237 let line_index =
238 host.analysis().file_line_index(original_range.file_id).unwrap();
239 let text_range = original_range.range;
240 let (start, end) = (
241 line_index.line_col(text_range.start()),
242 line_index.line_col(text_range.end()),
243 );
244 bar.println(format!(
245 "{} {}:{}-{}:{}: Expected {}, got {}",
246 path,
247 start.line + 1,
248 start.col_utf16,
249 end.line + 1,
250 end.col_utf16,
251 mismatch.expected.display(db),
252 mismatch.actual.display(db)
253 ));
254 } else {
255 bar.println(format!(
256 "{}: Expected {}, got {}",
257 name,
258 mismatch.expected.display(db),
259 mismatch.actual.display(db)
260 ));
261 }
257 } 262 }
258 } 263 }
259 } 264 }
265 if verbosity.is_spammy() {
266 bar.println(format!(
267 "In {}: {} exprs, {} unknown, {} partial",
268 full_name,
269 num_exprs - previous_exprs,
270 num_exprs_unknown - previous_unknown,
271 num_exprs_partially_unknown - previous_partially_unknown
272 ));
273 }
274 bar.inc(1);
260 } 275 }
261 if verbosity.is_spammy() { 276 bar.finish_and_clear();
262 bar.println(format!( 277 eprintln!("Total expressions: {}", num_exprs);
263 "In {}: {} exprs, {} unknown, {} partial", 278 eprintln!(
264 full_name, 279 "Expressions of unknown type: {} ({}%)",
265 num_exprs - previous_exprs, 280 num_exprs_unknown,
266 num_exprs_unknown - previous_unknown, 281 if num_exprs > 0 { num_exprs_unknown * 100 / num_exprs } else { 100 }
267 num_exprs_partially_unknown - previous_partially_unknown 282 );
268 )); 283 report_metric("unknown type", num_exprs_unknown, "#");
269 }
270 bar.inc(1);
271 }
272 bar.finish_and_clear();
273 eprintln!("Total expressions: {}", num_exprs);
274 eprintln!(
275 "Expressions of unknown type: {} ({}%)",
276 num_exprs_unknown,
277 if num_exprs > 0 { num_exprs_unknown * 100 / num_exprs } else { 100 }
278 );
279 report_metric("unknown type", num_exprs_unknown, "#");
280 284
281 eprintln!( 285 eprintln!(
282 "Expressions of partially unknown type: {} ({}%)", 286 "Expressions of partially unknown type: {} ({}%)",
283 num_exprs_partially_unknown, 287 num_exprs_partially_unknown,
284 if num_exprs > 0 { num_exprs_partially_unknown * 100 / num_exprs } else { 100 } 288 if num_exprs > 0 { num_exprs_partially_unknown * 100 / num_exprs } else { 100 }
285 ); 289 );
286 290
287 eprintln!("Type mismatches: {}", num_type_mismatches); 291 eprintln!("Type mismatches: {}", num_type_mismatches);
288 report_metric("type mismatches", num_type_mismatches, "#"); 292 report_metric("type mismatches", num_type_mismatches, "#");
289 293
290 let inference_time = inference_time.elapsed(); 294 eprintln!("Inference: {}", inference_sw.elapsed());
291 let total_memory = ra_prof::memory_usage();
292 eprintln!(
293 "Inference: {:?}, {}",
294 inference_time,
295 total_memory.allocated - item_collection_memory.allocated
296 );
297 295
298 let analysis_time = analysis_time.elapsed(); 296 let total_span = analysis_sw.elapsed();
299 eprintln!("Total: {:?}, {}", analysis_time, total_memory); 297 eprintln!("Total: {}", total_span);
300 report_metric("total time", analysis_time.as_millis() as u64, "ms"); 298 report_metric("total time", total_span.time.as_millis() as u64, "ms");
301 report_metric("total memory", total_memory.allocated.megabytes() as u64, "MB"); 299 if let Some(instructions) = total_span.instructions {
300 report_metric("total instructions", instructions, "#instr");
301 }
302 if let Some(memory) = total_span.memory {
303 report_metric("total memory", memory.allocated.megabytes() as u64, "MB");
304 }
305
306 if self.memory_usage {
307 print_memory_usage(host, vfs);
308 }
302 309
303 if memory_usage { 310 Ok(())
304 print_memory_usage(host, vfs);
305 } 311 }
306 312
307 Ok(()) 313 fn stop_watch(&self) -> StopWatch {
314 StopWatch::start().memory(self.memory_usage)
315 }
316}
317
318fn shuffle<T>(rng: &mut Rand32, slice: &mut [T]) {
319 for i in 0..slice.len() {
320 randomize_first(rng, &mut slice[i..]);
321 }
322
323 fn randomize_first<T>(rng: &mut Rand32, slice: &mut [T]) {
324 assert!(!slice.is_empty());
325 let idx = rng.rand_range(0..slice.len() as u32) as usize;
326 slice.swap(0, idx);
327 }
308} 328}
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index e11c8b909..70b4512d0 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -151,6 +151,7 @@ impl Config {
151 flycheck: Some(FlycheckConfig::CargoCommand { 151 flycheck: Some(FlycheckConfig::CargoCommand {
152 command: "check".to_string(), 152 command: "check".to_string(),
153 target_triple: None, 153 target_triple: None,
154 no_default_features: false,
154 all_targets: true, 155 all_targets: true,
155 all_features: false, 156 all_features: false,
156 extra_args: Vec::new(), 157 extra_args: Vec::new(),
@@ -234,6 +235,9 @@ impl Config {
234 command: data.checkOnSave_command, 235 command: data.checkOnSave_command,
235 target_triple: data.checkOnSave_target.or(data.cargo_target), 236 target_triple: data.checkOnSave_target.or(data.cargo_target),
236 all_targets: data.checkOnSave_allTargets, 237 all_targets: data.checkOnSave_allTargets,
238 no_default_features: data
239 .checkOnSave_noDefaultFeatures
240 .unwrap_or(data.cargo_noDefaultFeatures),
237 all_features: data.checkOnSave_allFeatures.unwrap_or(data.cargo_allFeatures), 241 all_features: data.checkOnSave_allFeatures.unwrap_or(data.cargo_allFeatures),
238 features: data.checkOnSave_features.unwrap_or(data.cargo_features), 242 features: data.checkOnSave_features.unwrap_or(data.cargo_features),
239 extra_args: data.checkOnSave_extraArgs, 243 extra_args: data.checkOnSave_extraArgs,
@@ -398,6 +402,7 @@ config_data! {
398 checkOnSave_allFeatures: Option<bool> = None, 402 checkOnSave_allFeatures: Option<bool> = None,
399 checkOnSave_allTargets: bool = true, 403 checkOnSave_allTargets: bool = true,
400 checkOnSave_command: String = "check".into(), 404 checkOnSave_command: String = "check".into(),
405 checkOnSave_noDefaultFeatures: Option<bool> = None,
401 checkOnSave_target: Option<String> = None, 406 checkOnSave_target: Option<String> = None,
402 checkOnSave_extraArgs: Vec<String> = Vec::new(), 407 checkOnSave_extraArgs: Vec<String> = Vec::new(),
403 checkOnSave_features: Option<Vec<String>> = None, 408 checkOnSave_features: Option<Vec<String>> = None,
diff --git a/crates/rust-analyzer/src/document.rs b/crates/rust-analyzer/src/document.rs
index 43219e633..e882c9865 100644
--- a/crates/rust-analyzer/src/document.rs
+++ b/crates/rust-analyzer/src/document.rs
@@ -1,9 +1,9 @@
1//! In-memory document information. 1//! In-memory document information.
2 2
3/// Information about a document that the Language Client 3/// Information about a document that the Language Client
4// knows about. 4/// knows about.
5// Its lifetime is driven by the textDocument/didOpen and textDocument/didClose 5/// Its lifetime is driven by the textDocument/didOpen and textDocument/didClose
6// client notifications. 6/// client notifications.
7#[derive(Debug, Clone)] 7#[derive(Debug, Clone)]
8pub(crate) struct DocumentData { 8pub(crate) struct DocumentData {
9 pub version: Option<i64>, 9 pub version: Option<i64>,
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index b2d65a6d1..0e592ac1b 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -7,8 +7,8 @@ use std::{sync::Arc, time::Instant};
7 7
8use crossbeam_channel::{unbounded, Receiver, Sender}; 8use crossbeam_channel::{unbounded, Receiver, Sender};
9use flycheck::FlycheckHandle; 9use flycheck::FlycheckHandle;
10use lsp_types::Url; 10use lsp_types::{SemanticTokens, Url};
11use parking_lot::RwLock; 11use parking_lot::{Mutex, RwLock};
12use ra_db::{CrateId, VfsPath}; 12use ra_db::{CrateId, VfsPath};
13use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FileId}; 13use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FileId};
14use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target}; 14use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target};
@@ -71,6 +71,7 @@ pub(crate) struct GlobalState {
71 pub(crate) analysis_host: AnalysisHost, 71 pub(crate) analysis_host: AnalysisHost,
72 pub(crate) diagnostics: DiagnosticCollection, 72 pub(crate) diagnostics: DiagnosticCollection,
73 pub(crate) mem_docs: FxHashMap<VfsPath, DocumentData>, 73 pub(crate) mem_docs: FxHashMap<VfsPath, DocumentData>,
74 pub(crate) semantic_tokens_cache: Arc<Mutex<FxHashMap<Url, SemanticTokens>>>,
74 pub(crate) vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>, 75 pub(crate) vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>,
75 pub(crate) status: Status, 76 pub(crate) status: Status,
76 pub(crate) source_root_config: SourceRootConfig, 77 pub(crate) source_root_config: SourceRootConfig,
@@ -86,6 +87,7 @@ pub(crate) struct GlobalStateSnapshot {
86 pub(crate) check_fixes: CheckFixes, 87 pub(crate) check_fixes: CheckFixes,
87 pub(crate) latest_requests: Arc<RwLock<LatestRequests>>, 88 pub(crate) latest_requests: Arc<RwLock<LatestRequests>>,
88 mem_docs: FxHashMap<VfsPath, DocumentData>, 89 mem_docs: FxHashMap<VfsPath, DocumentData>,
90 pub semantic_tokens_cache: Arc<Mutex<FxHashMap<Url, SemanticTokens>>>,
89 vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>, 91 vfs: Arc<RwLock<(vfs::Vfs, FxHashMap<FileId, LineEndings>)>>,
90 pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>, 92 pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
91} 93}
@@ -120,6 +122,7 @@ impl GlobalState {
120 analysis_host, 122 analysis_host,
121 diagnostics: Default::default(), 123 diagnostics: Default::default(),
122 mem_docs: FxHashMap::default(), 124 mem_docs: FxHashMap::default(),
125 semantic_tokens_cache: Arc::new(Default::default()),
123 vfs: Arc::new(RwLock::new((vfs::Vfs::default(), FxHashMap::default()))), 126 vfs: Arc::new(RwLock::new((vfs::Vfs::default(), FxHashMap::default()))),
124 status: Status::default(), 127 status: Status::default(),
125 source_root_config: SourceRootConfig::default(), 128 source_root_config: SourceRootConfig::default(),
@@ -186,6 +189,7 @@ impl GlobalState {
186 latest_requests: Arc::clone(&self.latest_requests), 189 latest_requests: Arc::clone(&self.latest_requests),
187 check_fixes: Arc::clone(&self.diagnostics.check_fixes), 190 check_fixes: Arc::clone(&self.diagnostics.check_fixes),
188 mem_docs: self.mem_docs.clone(), 191 mem_docs: self.mem_docs.clone(),
192 semantic_tokens_cache: Arc::clone(&self.semantic_tokens_cache),
189 } 193 }
190 } 194 }
191 195
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index cd309ed74..067259e24 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -13,9 +13,10 @@ use lsp_types::{
13 CallHierarchyOutgoingCall, CallHierarchyOutgoingCallsParams, CallHierarchyPrepareParams, 13 CallHierarchyOutgoingCall, CallHierarchyOutgoingCallsParams, CallHierarchyPrepareParams,
14 CodeActionKind, CodeLens, Command, CompletionItem, Diagnostic, DocumentFormattingParams, 14 CodeActionKind, CodeLens, Command, CompletionItem, Diagnostic, DocumentFormattingParams,
15 DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location, 15 DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location,
16 Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensParams, 16 Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensEditResult,
17 SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, 17 SemanticTokensEditsParams, SemanticTokensParams, SemanticTokensRangeParams,
18 SymbolTag, TextDocumentIdentifier, Url, WorkspaceEdit, 18 SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, SymbolTag,
19 TextDocumentIdentifier, Url, WorkspaceEdit,
19}; 20};
20use ra_ide::{ 21use ra_ide::{
21 FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, 22 FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query,
@@ -26,7 +27,7 @@ use ra_project_model::TargetKind;
26use ra_syntax::{algo, ast, AstNode, SyntaxKind, TextRange, TextSize}; 27use ra_syntax::{algo, ast, AstNode, SyntaxKind, TextRange, TextSize};
27use serde::{Deserialize, Serialize}; 28use serde::{Deserialize, Serialize};
28use serde_json::to_value; 29use serde_json::to_value;
29use stdx::{format_to, split_delim}; 30use stdx::{format_to, split_once};
30 31
31use crate::{ 32use crate::{
32 cargo_target_spec::CargoTargetSpec, 33 cargo_target_spec::CargoTargetSpec,
@@ -469,12 +470,12 @@ pub(crate) fn handle_runnables(
469 res.push(runnable); 470 res.push(runnable);
470 } 471 }
471 472
472 // Add `cargo check` and `cargo test` for the whole package 473 // Add `cargo check` and `cargo test` for all targets of the whole package
473 match cargo_spec { 474 match cargo_spec {
474 Some(spec) => { 475 Some(spec) => {
475 for &cmd in ["check", "test"].iter() { 476 for &cmd in ["check", "test"].iter() {
476 res.push(lsp_ext::Runnable { 477 res.push(lsp_ext::Runnable {
477 label: format!("cargo {} -p {}", cmd, spec.package), 478 label: format!("cargo {} -p {} --all-targets", cmd, spec.package),
478 location: None, 479 location: None,
479 kind: lsp_ext::RunnableKind::Cargo, 480 kind: lsp_ext::RunnableKind::Cargo,
480 args: lsp_ext::CargoRunnable { 481 args: lsp_ext::CargoRunnable {
@@ -483,6 +484,7 @@ pub(crate) fn handle_runnables(
483 cmd.to_string(), 484 cmd.to_string(),
484 "--package".to_string(), 485 "--package".to_string(),
485 spec.package.clone(), 486 spec.package.clone(),
487 "--all-targets".to_string(),
486 ], 488 ],
487 executable_args: Vec::new(), 489 executable_args: Vec::new(),
488 expect_test: None, 490 expect_test: None,
@@ -708,11 +710,6 @@ pub(crate) fn handle_formatting(
708 } 710 }
709 }; 711 };
710 712
711 if let Ok(path) = params.text_document.uri.to_file_path() {
712 if let Some(parent) = path.parent() {
713 rustfmt.current_dir(parent);
714 }
715 }
716 let mut rustfmt = rustfmt.stdin(Stdio::piped()).stdout(Stdio::piped()).spawn()?; 713 let mut rustfmt = rustfmt.stdin(Stdio::piped()).stdout(Stdio::piped()).spawn()?;
717 714
718 rustfmt.stdin.as_mut().unwrap().write_all(file.as_bytes())?; 715 rustfmt.stdin.as_mut().unwrap().write_all(file.as_bytes())?;
@@ -864,7 +861,7 @@ pub(crate) fn handle_resolve_code_action(
864 .map(|it| it.into_iter().filter_map(from_proto::assist_kind).collect()); 861 .map(|it| it.into_iter().filter_map(from_proto::assist_kind).collect());
865 862
866 let assists = snap.analysis.resolved_assists(&snap.config.assist, frange)?; 863 let assists = snap.analysis.resolved_assists(&snap.config.assist, frange)?;
867 let (id_string, index) = split_delim(&params.id, ':').unwrap(); 864 let (id_string, index) = split_once(&params.id, ':').unwrap();
868 let index = index.parse::<usize>().unwrap(); 865 let index = index.parse::<usize>().unwrap();
869 let assist = &assists[index]; 866 let assist = &assists[index];
870 assert!(assist.assist.id.0 == id_string); 867 assert!(assist.assist.id.0 == id_string);
@@ -923,10 +920,10 @@ pub(crate) fn handle_code_lens(
923 .filter(|it| { 920 .filter(|it| {
924 matches!( 921 matches!(
925 it.kind, 922 it.kind,
926 SyntaxKind::TRAIT_DEF 923 SyntaxKind::TRAIT
927 | SyntaxKind::STRUCT_DEF 924 | SyntaxKind::STRUCT
928 | SyntaxKind::ENUM_DEF 925 | SyntaxKind::ENUM
929 | SyntaxKind::UNION_DEF 926 | SyntaxKind::UNION
930 ) 927 )
931 }) 928 })
932 .map(|it| { 929 .map(|it| {
@@ -1026,9 +1023,18 @@ pub(crate) fn handle_ssr(
1026 params: lsp_ext::SsrParams, 1023 params: lsp_ext::SsrParams,
1027) -> Result<lsp_types::WorkspaceEdit> { 1024) -> Result<lsp_types::WorkspaceEdit> {
1028 let _p = profile("handle_ssr"); 1025 let _p = profile("handle_ssr");
1026 let selections = params
1027 .selections
1028 .iter()
1029 .map(|range| from_proto::file_range(&snap, params.position.text_document.clone(), *range))
1030 .collect::<Result<Vec<_>, _>>()?;
1029 let position = from_proto::file_position(&snap, params.position)?; 1031 let position = from_proto::file_position(&snap, params.position)?;
1030 let source_change = 1032 let source_change = snap.analysis.structural_search_replace(
1031 snap.analysis.structural_search_replace(&params.query, params.parse_only, position)??; 1033 &params.query,
1034 params.parse_only,
1035 position,
1036 selections,
1037 )??;
1032 to_proto::workspace_edit(&snap, source_change) 1038 to_proto::workspace_edit(&snap, source_change)
1033} 1039}
1034 1040
@@ -1085,7 +1091,7 @@ pub(crate) fn handle_call_hierarchy_prepare(
1085 let RangeInfo { range: _, info: navs } = nav_info; 1091 let RangeInfo { range: _, info: navs } = nav_info;
1086 let res = navs 1092 let res = navs
1087 .into_iter() 1093 .into_iter()
1088 .filter(|it| it.kind == SyntaxKind::FN_DEF) 1094 .filter(|it| it.kind == SyntaxKind::FN)
1089 .map(|it| to_proto::call_hierarchy_item(&snap, it)) 1095 .map(|it| to_proto::call_hierarchy_item(&snap, it))
1090 .collect::<Result<Vec<_>>>()?; 1096 .collect::<Result<Vec<_>>>()?;
1091 1097
@@ -1174,6 +1180,40 @@ pub(crate) fn handle_semantic_tokens(
1174 1180
1175 let highlights = snap.analysis.highlight(file_id)?; 1181 let highlights = snap.analysis.highlight(file_id)?;
1176 let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights); 1182 let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
1183
1184 // Unconditionally cache the tokens
1185 snap.semantic_tokens_cache.lock().insert(params.text_document.uri, semantic_tokens.clone());
1186
1187 Ok(Some(semantic_tokens.into()))
1188}
1189
1190pub(crate) fn handle_semantic_tokens_edits(
1191 snap: GlobalStateSnapshot,
1192 params: SemanticTokensEditsParams,
1193) -> Result<Option<SemanticTokensEditResult>> {
1194 let _p = profile("handle_semantic_tokens_edits");
1195
1196 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
1197 let text = snap.analysis.file_text(file_id)?;
1198 let line_index = snap.analysis.file_line_index(file_id)?;
1199
1200 let highlights = snap.analysis.highlight(file_id)?;
1201
1202 let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
1203
1204 let mut cache = snap.semantic_tokens_cache.lock();
1205 let cached_tokens = cache.entry(params.text_document.uri).or_default();
1206
1207 if let Some(prev_id) = &cached_tokens.result_id {
1208 if *prev_id == params.previous_result_id {
1209 let edits = to_proto::semantic_token_edits(&cached_tokens, &semantic_tokens);
1210 *cached_tokens = semantic_tokens;
1211 return Ok(Some(edits.into()));
1212 }
1213 }
1214
1215 *cached_tokens = semantic_tokens.clone();
1216
1177 Ok(Some(semantic_tokens.into())) 1217 Ok(Some(semantic_tokens.into()))
1178} 1218}
1179 1219
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs
index 113e0e070..3976b6529 100644
--- a/crates/rust-analyzer/src/lsp_ext.rs
+++ b/crates/rust-analyzer/src/lsp_ext.rs
@@ -221,6 +221,9 @@ pub struct SsrParams {
221 /// position. 221 /// position.
222 #[serde(flatten)] 222 #[serde(flatten)]
223 pub position: lsp_types::TextDocumentPositionParams, 223 pub position: lsp_types::TextDocumentPositionParams,
224
225 /// Current selections. Search/replace will be restricted to these if non-empty.
226 pub selections: Vec<lsp_types::Range>,
224} 227}
225 228
226pub enum StatusNotification {} 229pub enum StatusNotification {}
diff --git a/crates/rust-analyzer/src/lsp_utils.rs b/crates/rust-analyzer/src/lsp_utils.rs
index d4cc9dd04..0bc3ff115 100644
--- a/crates/rust-analyzer/src/lsp_utils.rs
+++ b/crates/rust-analyzer/src/lsp_utils.rs
@@ -1,5 +1,5 @@
1//! Utilities for LSP-related boilerplate code. 1//! Utilities for LSP-related boilerplate code.
2use std::{borrow::Cow, error::Error, ops::Range}; 2use std::{error::Error, ops::Range};
3 3
4use lsp_server::Notification; 4use lsp_server::Notification;
5use ra_db::Canceled; 5use ra_db::Canceled;
@@ -84,8 +84,8 @@ impl GlobalState {
84pub(crate) fn apply_document_changes( 84pub(crate) fn apply_document_changes(
85 old_text: &mut String, 85 old_text: &mut String,
86 content_changes: Vec<lsp_types::TextDocumentContentChangeEvent>, 86 content_changes: Vec<lsp_types::TextDocumentContentChangeEvent>,
87 mut line_index: Cow<'_, LineIndex>,
88) { 87) {
88 let mut line_index = LineIndex::new(old_text);
89 // The changes we got must be applied sequentially, but can cross lines so we 89 // The changes we got must be applied sequentially, but can cross lines so we
90 // have to keep our line index updated. 90 // have to keep our line index updated.
91 // Some clients (e.g. Code) sort the ranges in reverse. As an optimization, we 91 // Some clients (e.g. Code) sort the ranges in reverse. As an optimization, we
@@ -110,7 +110,7 @@ pub(crate) fn apply_document_changes(
110 match change.range { 110 match change.range {
111 Some(range) => { 111 Some(range) => {
112 if !index_valid.covers(range.end.line) { 112 if !index_valid.covers(range.end.line) {
113 line_index = Cow::Owned(LineIndex::new(old_text)); 113 line_index = LineIndex::new(&old_text);
114 } 114 }
115 index_valid = IndexValid::UpToLineExclusive(range.start.line); 115 index_valid = IndexValid::UpToLineExclusive(range.start.line);
116 let range = from_proto::text_range(&line_index, range); 116 let range = from_proto::text_range(&line_index, range);
@@ -145,15 +145,10 @@ mod tests {
145 }; 145 };
146 } 146 }
147 147
148 fn run(text: &mut String, changes: Vec<TextDocumentContentChangeEvent>) {
149 let line_index = Cow::Owned(LineIndex::new(&text));
150 super::apply_document_changes(text, changes, line_index);
151 }
152
153 let mut text = String::new(); 148 let mut text = String::new();
154 run(&mut text, vec![]); 149 apply_document_changes(&mut text, vec![]);
155 assert_eq!(text, ""); 150 assert_eq!(text, "");
156 run( 151 apply_document_changes(
157 &mut text, 152 &mut text,
158 vec![TextDocumentContentChangeEvent { 153 vec![TextDocumentContentChangeEvent {
159 range: None, 154 range: None,
@@ -162,36 +157,39 @@ mod tests {
162 }], 157 }],
163 ); 158 );
164 assert_eq!(text, "the"); 159 assert_eq!(text, "the");
165 run(&mut text, c![0, 3; 0, 3 => " quick"]); 160 apply_document_changes(&mut text, c![0, 3; 0, 3 => " quick"]);
166 assert_eq!(text, "the quick"); 161 assert_eq!(text, "the quick");
167 run(&mut text, c![0, 0; 0, 4 => "", 0, 5; 0, 5 => " foxes"]); 162 apply_document_changes(&mut text, c![0, 0; 0, 4 => "", 0, 5; 0, 5 => " foxes"]);
168 assert_eq!(text, "quick foxes"); 163 assert_eq!(text, "quick foxes");
169 run(&mut text, c![0, 11; 0, 11 => "\ndream"]); 164 apply_document_changes(&mut text, c![0, 11; 0, 11 => "\ndream"]);
170 assert_eq!(text, "quick foxes\ndream"); 165 assert_eq!(text, "quick foxes\ndream");
171 run(&mut text, c![1, 0; 1, 0 => "have "]); 166 apply_document_changes(&mut text, c![1, 0; 1, 0 => "have "]);
172 assert_eq!(text, "quick foxes\nhave dream"); 167 assert_eq!(text, "quick foxes\nhave dream");
173 run(&mut text, c![0, 0; 0, 0 => "the ", 1, 4; 1, 4 => " quiet", 1, 16; 1, 16 => "s\n"]); 168 apply_document_changes(
169 &mut text,
170 c![0, 0; 0, 0 => "the ", 1, 4; 1, 4 => " quiet", 1, 16; 1, 16 => "s\n"],
171 );
174 assert_eq!(text, "the quick foxes\nhave quiet dreams\n"); 172 assert_eq!(text, "the quick foxes\nhave quiet dreams\n");
175 run(&mut text, c![0, 15; 0, 15 => "\n", 2, 17; 2, 17 => "\n"]); 173 apply_document_changes(&mut text, c![0, 15; 0, 15 => "\n", 2, 17; 2, 17 => "\n"]);
176 assert_eq!(text, "the quick foxes\n\nhave quiet dreams\n\n"); 174 assert_eq!(text, "the quick foxes\n\nhave quiet dreams\n\n");
177 run( 175 apply_document_changes(
178 &mut text, 176 &mut text,
179 c![1, 0; 1, 0 => "DREAM", 2, 0; 2, 0 => "they ", 3, 0; 3, 0 => "DON'T THEY?"], 177 c![1, 0; 1, 0 => "DREAM", 2, 0; 2, 0 => "they ", 3, 0; 3, 0 => "DON'T THEY?"],
180 ); 178 );
181 assert_eq!(text, "the quick foxes\nDREAM\nthey have quiet dreams\nDON'T THEY?\n"); 179 assert_eq!(text, "the quick foxes\nDREAM\nthey have quiet dreams\nDON'T THEY?\n");
182 run(&mut text, c![0, 10; 1, 5 => "", 2, 0; 2, 12 => ""]); 180 apply_document_changes(&mut text, c![0, 10; 1, 5 => "", 2, 0; 2, 12 => ""]);
183 assert_eq!(text, "the quick \nthey have quiet dreams\n"); 181 assert_eq!(text, "the quick \nthey have quiet dreams\n");
184 182
185 text = String::from("❤️"); 183 text = String::from("❤️");
186 run(&mut text, c![0, 0; 0, 0 => "a"]); 184 apply_document_changes(&mut text, c![0, 0; 0, 0 => "a"]);
187 assert_eq!(text, "a❤️"); 185 assert_eq!(text, "a❤️");
188 186
189 text = String::from("a\nb"); 187 text = String::from("a\nb");
190 run(&mut text, c![0, 1; 1, 0 => "\nțc", 0, 1; 1, 1 => "d"]); 188 apply_document_changes(&mut text, c![0, 1; 1, 0 => "\nțc", 0, 1; 1, 1 => "d"]);
191 assert_eq!(text, "adcb"); 189 assert_eq!(text, "adcb");
192 190
193 text = String::from("a\nb"); 191 text = String::from("a\nb");
194 run(&mut text, c![0, 1; 1, 0 => "ț\nc", 0, 2; 0, 2 => "c"]); 192 apply_document_changes(&mut text, c![0, 1; 1, 0 => "ț\nc", 0, 2; 0, 2 => "c"]);
195 assert_eq!(text, "ațc\ncb"); 193 assert_eq!(text, "ațc\ncb");
196 } 194 }
197} 195}
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 0ace4cb45..438e965e0 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -1,14 +1,13 @@
1//! The main loop of `rust-analyzer` responsible for dispatching LSP 1//! The main loop of `rust-analyzer` responsible for dispatching LSP
2//! requests/replies and notifications back to the client. 2//! requests/replies and notifications back to the client.
3use std::{ 3use std::{
4 borrow::Cow,
5 env, fmt, panic, 4 env, fmt, panic,
6 time::{Duration, Instant}, 5 time::{Duration, Instant},
7}; 6};
8 7
9use crossbeam_channel::{select, Receiver}; 8use crossbeam_channel::{select, Receiver};
10use lsp_server::{Connection, Notification, Request, Response}; 9use lsp_server::{Connection, Notification, Request, Response};
11use lsp_types::{notification::Notification as _, DidChangeTextDocumentParams}; 10use lsp_types::notification::Notification as _;
12use ra_db::VfsPath; 11use ra_db::VfsPath;
13use ra_ide::{Canceled, FileId}; 12use ra_ide::{Canceled, FileId};
14use ra_prof::profile; 13use ra_prof::profile;
@@ -48,7 +47,7 @@ pub fn main_loop(config: Config, connection: Connection) -> Result<()> {
48 SetThreadPriority(thread, thread_priority_above_normal); 47 SetThreadPriority(thread, thread_priority_above_normal);
49 } 48 }
50 49
51 GlobalState::new(connection.sender.clone(), config).run(connection.receiver) 50 GlobalState::new(connection.sender, config).run(connection.receiver)
52} 51}
53 52
54enum Event { 53enum Event {
@@ -387,6 +386,9 @@ impl GlobalState {
387 handlers::handle_call_hierarchy_outgoing, 386 handlers::handle_call_hierarchy_outgoing,
388 )? 387 )?
389 .on::<lsp_types::request::SemanticTokensRequest>(handlers::handle_semantic_tokens)? 388 .on::<lsp_types::request::SemanticTokensRequest>(handlers::handle_semantic_tokens)?
389 .on::<lsp_types::request::SemanticTokensEditsRequest>(
390 handlers::handle_semantic_tokens_edits,
391 )?
390 .on::<lsp_types::request::SemanticTokensRangeRequest>( 392 .on::<lsp_types::request::SemanticTokensRangeRequest>(
391 handlers::handle_semantic_tokens_range, 393 handlers::handle_semantic_tokens_range,
392 )? 394 )?
@@ -422,20 +424,15 @@ impl GlobalState {
422 })? 424 })?
423 .on::<lsp_types::notification::DidChangeTextDocument>(|this, params| { 425 .on::<lsp_types::notification::DidChangeTextDocument>(|this, params| {
424 if let Ok(path) = from_proto::vfs_path(&params.text_document.uri) { 426 if let Ok(path) = from_proto::vfs_path(&params.text_document.uri) {
425 let DidChangeTextDocumentParams { text_document, content_changes } = params; 427 let doc = this.mem_docs.get_mut(&path).unwrap();
426 let vfs = &mut this.vfs.write().0; 428 let vfs = &mut this.vfs.write().0;
427 let world = this.snapshot();
428 let file_id = vfs.file_id(&path).unwrap(); 429 let file_id = vfs.file_id(&path).unwrap();
429
430 // let file_id = vfs.file_id(&path).unwrap();
431 let mut text = String::from_utf8(vfs.file_contents(file_id).to_vec()).unwrap(); 430 let mut text = String::from_utf8(vfs.file_contents(file_id).to_vec()).unwrap();
432 let line_index = world.analysis.file_line_index(file_id)?; 431 apply_document_changes(&mut text, params.content_changes);
433 apply_document_changes(&mut text, content_changes, Cow::Borrowed(&line_index));
434 432
435 // The version passed in DidChangeTextDocument is the version after all edits are applied 433 // The version passed in DidChangeTextDocument is the version after all edits are applied
436 // so we should apply it before the vfs is notified. 434 // so we should apply it before the vfs is notified.
437 let doc = this.mem_docs.get_mut(&path).unwrap(); 435 doc.version = params.text_document.version;
438 doc.version = text_document.version;
439 436
440 vfs.set_file_contents(path.clone(), Some(text.into_bytes())); 437 vfs.set_file_contents(path.clone(), Some(text.into_bytes()));
441 } 438 }
@@ -449,6 +446,8 @@ impl GlobalState {
449 None => log::error!("orphan DidCloseTextDocument: {}", path), 446 None => log::error!("orphan DidCloseTextDocument: {}", path),
450 } 447 }
451 448
449 this.semantic_tokens_cache.lock().remove(&params.text_document.uri);
450
452 if let Some(path) = path.as_path() { 451 if let Some(path) = path.as_path() {
453 this.loader.handle.invalidate(path.to_path_buf()); 452 this.loader.handle.invalidate(path.to_path_buf());
454 } 453 }
diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/semantic_tokens.rs
index 576bd8adc..afc38fb4e 100644
--- a/crates/rust-analyzer/src/semantic_tokens.rs
+++ b/crates/rust-analyzer/src/semantic_tokens.rs
@@ -2,7 +2,10 @@
2 2
3use std::ops; 3use std::ops;
4 4
5use lsp_types::{Range, SemanticToken, SemanticTokenModifier, SemanticTokenType, SemanticTokens}; 5use lsp_types::{
6 Range, SemanticToken, SemanticTokenModifier, SemanticTokenType, SemanticTokens,
7 SemanticTokensEdit,
8};
6 9
7macro_rules! define_semantic_token_types { 10macro_rules! define_semantic_token_types {
8 ($(($ident:ident, $string:literal)),*$(,)?) => { 11 ($(($ident:ident, $string:literal)),*$(,)?) => {
@@ -89,14 +92,18 @@ impl ops::BitOrAssign<SemanticTokenModifier> for ModifierSet {
89/// Tokens are encoded relative to each other. 92/// Tokens are encoded relative to each other.
90/// 93///
91/// This is a direct port of https://github.com/microsoft/vscode-languageserver-node/blob/f425af9de46a0187adb78ec8a46b9b2ce80c5412/server/src/sematicTokens.proposed.ts#L45 94/// This is a direct port of https://github.com/microsoft/vscode-languageserver-node/blob/f425af9de46a0187adb78ec8a46b9b2ce80c5412/server/src/sematicTokens.proposed.ts#L45
92#[derive(Default)]
93pub(crate) struct SemanticTokensBuilder { 95pub(crate) struct SemanticTokensBuilder {
96 id: String,
94 prev_line: u32, 97 prev_line: u32,
95 prev_char: u32, 98 prev_char: u32,
96 data: Vec<SemanticToken>, 99 data: Vec<SemanticToken>,
97} 100}
98 101
99impl SemanticTokensBuilder { 102impl SemanticTokensBuilder {
103 pub fn new(id: String) -> Self {
104 SemanticTokensBuilder { id, prev_line: 0, prev_char: 0, data: Default::default() }
105 }
106
100 /// Push a new token onto the builder 107 /// Push a new token onto the builder
101 pub fn push(&mut self, range: Range, token_index: u32, modifier_bitset: u32) { 108 pub fn push(&mut self, range: Range, token_index: u32, modifier_bitset: u32) {
102 let mut push_line = range.start.line as u32; 109 let mut push_line = range.start.line as u32;
@@ -127,10 +134,136 @@ impl SemanticTokensBuilder {
127 } 134 }
128 135
129 pub fn build(self) -> SemanticTokens { 136 pub fn build(self) -> SemanticTokens {
130 SemanticTokens { result_id: None, data: self.data } 137 SemanticTokens { result_id: Some(self.id), data: self.data }
138 }
139}
140
141pub fn diff_tokens(old: &[SemanticToken], new: &[SemanticToken]) -> Vec<SemanticTokensEdit> {
142 let offset = new.iter().zip(old.iter()).take_while(|&(n, p)| n == p).count();
143
144 let (_, old) = old.split_at(offset);
145 let (_, new) = new.split_at(offset);
146
147 let offset_from_end =
148 new.iter().rev().zip(old.iter().rev()).take_while(|&(n, p)| n == p).count();
149
150 let (old, _) = old.split_at(old.len() - offset_from_end);
151 let (new, _) = new.split_at(new.len() - offset_from_end);
152
153 if old.is_empty() && new.is_empty() {
154 vec![]
155 } else {
156 // The lsp data field is actually a byte-diff but we
157 // travel in tokens so `start` and `delete_count` are in multiples of the
158 // serialized size of `SemanticToken`.
159 vec![SemanticTokensEdit {
160 start: 5 * offset as u32,
161 delete_count: 5 * old.len() as u32,
162 data: Some(new.into()),
163 }]
131 } 164 }
132} 165}
133 166
134pub fn type_index(type_: SemanticTokenType) -> u32 { 167pub fn type_index(type_: SemanticTokenType) -> u32 {
135 SUPPORTED_TYPES.iter().position(|it| *it == type_).unwrap() as u32 168 SUPPORTED_TYPES.iter().position(|it| *it == type_).unwrap() as u32
136} 169}
170
171#[cfg(test)]
172mod tests {
173 use super::*;
174
175 fn from(t: (u32, u32, u32, u32, u32)) -> SemanticToken {
176 SemanticToken {
177 delta_line: t.0,
178 delta_start: t.1,
179 length: t.2,
180 token_type: t.3,
181 token_modifiers_bitset: t.4,
182 }
183 }
184
185 #[test]
186 fn test_diff_insert_at_end() {
187 let before = [from((1, 2, 3, 4, 5)), from((6, 7, 8, 9, 10))];
188 let after = [from((1, 2, 3, 4, 5)), from((6, 7, 8, 9, 10)), from((11, 12, 13, 14, 15))];
189
190 let edits = diff_tokens(&before, &after);
191 assert_eq!(
192 edits[0],
193 SemanticTokensEdit {
194 start: 10,
195 delete_count: 0,
196 data: Some(vec![from((11, 12, 13, 14, 15))])
197 }
198 );
199 }
200
201 #[test]
202 fn test_diff_insert_at_beginning() {
203 let before = [from((1, 2, 3, 4, 5)), from((6, 7, 8, 9, 10))];
204 let after = [from((11, 12, 13, 14, 15)), from((1, 2, 3, 4, 5)), from((6, 7, 8, 9, 10))];
205
206 let edits = diff_tokens(&before, &after);
207 assert_eq!(
208 edits[0],
209 SemanticTokensEdit {
210 start: 0,
211 delete_count: 0,
212 data: Some(vec![from((11, 12, 13, 14, 15))])
213 }
214 );
215 }
216
217 #[test]
218 fn test_diff_insert_in_middle() {
219 let before = [from((1, 2, 3, 4, 5)), from((6, 7, 8, 9, 10))];
220 let after = [
221 from((1, 2, 3, 4, 5)),
222 from((10, 20, 30, 40, 50)),
223 from((60, 70, 80, 90, 100)),
224 from((6, 7, 8, 9, 10)),
225 ];
226
227 let edits = diff_tokens(&before, &after);
228 assert_eq!(
229 edits[0],
230 SemanticTokensEdit {
231 start: 5,
232 delete_count: 0,
233 data: Some(vec![from((10, 20, 30, 40, 50)), from((60, 70, 80, 90, 100))])
234 }
235 );
236 }
237
238 #[test]
239 fn test_diff_remove_from_end() {
240 let before = [from((1, 2, 3, 4, 5)), from((6, 7, 8, 9, 10)), from((11, 12, 13, 14, 15))];
241 let after = [from((1, 2, 3, 4, 5)), from((6, 7, 8, 9, 10))];
242
243 let edits = diff_tokens(&before, &after);
244 assert_eq!(edits[0], SemanticTokensEdit { start: 10, delete_count: 5, data: Some(vec![]) });
245 }
246
247 #[test]
248 fn test_diff_remove_from_beginning() {
249 let before = [from((11, 12, 13, 14, 15)), from((1, 2, 3, 4, 5)), from((6, 7, 8, 9, 10))];
250 let after = [from((1, 2, 3, 4, 5)), from((6, 7, 8, 9, 10))];
251
252 let edits = diff_tokens(&before, &after);
253 assert_eq!(edits[0], SemanticTokensEdit { start: 0, delete_count: 5, data: Some(vec![]) });
254 }
255
256 #[test]
257 fn test_diff_remove_from_middle() {
258 let before = [
259 from((1, 2, 3, 4, 5)),
260 from((10, 20, 30, 40, 50)),
261 from((60, 70, 80, 90, 100)),
262 from((6, 7, 8, 9, 10)),
263 ];
264 let after = [from((1, 2, 3, 4, 5)), from((6, 7, 8, 9, 10))];
265
266 let edits = diff_tokens(&before, &after);
267 assert_eq!(edits[0], SemanticTokensEdit { start: 5, delete_count: 10, data: Some(vec![]) });
268 }
269}
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index c6935c029..5eba1f155 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -1,5 +1,8 @@
1//! Conversion of rust-analyzer specific types to lsp_types equivalents. 1//! Conversion of rust-analyzer specific types to lsp_types equivalents.
2use std::path::{self, Path}; 2use std::{
3 path::{self, Path},
4 sync::atomic::{AtomicU32, Ordering},
5};
3 6
4use itertools::Itertools; 7use itertools::Itertools;
5use ra_db::{FileId, FileRange}; 8use ra_db::{FileId, FileRange};
@@ -31,18 +34,18 @@ pub(crate) fn range(line_index: &LineIndex, range: TextRange) -> lsp_types::Rang
31 34
32pub(crate) fn symbol_kind(syntax_kind: SyntaxKind) -> lsp_types::SymbolKind { 35pub(crate) fn symbol_kind(syntax_kind: SyntaxKind) -> lsp_types::SymbolKind {
33 match syntax_kind { 36 match syntax_kind {
34 SyntaxKind::FN_DEF => lsp_types::SymbolKind::Function, 37 SyntaxKind::FN => lsp_types::SymbolKind::Function,
35 SyntaxKind::STRUCT_DEF => lsp_types::SymbolKind::Struct, 38 SyntaxKind::STRUCT => lsp_types::SymbolKind::Struct,
36 SyntaxKind::ENUM_DEF => lsp_types::SymbolKind::Enum, 39 SyntaxKind::ENUM => lsp_types::SymbolKind::Enum,
37 SyntaxKind::ENUM_VARIANT => lsp_types::SymbolKind::EnumMember, 40 SyntaxKind::VARIANT => lsp_types::SymbolKind::EnumMember,
38 SyntaxKind::TRAIT_DEF => lsp_types::SymbolKind::Interface, 41 SyntaxKind::TRAIT => lsp_types::SymbolKind::Interface,
39 SyntaxKind::MACRO_CALL => lsp_types::SymbolKind::Function, 42 SyntaxKind::MACRO_CALL => lsp_types::SymbolKind::Function,
40 SyntaxKind::MODULE => lsp_types::SymbolKind::Module, 43 SyntaxKind::MODULE => lsp_types::SymbolKind::Module,
41 SyntaxKind::TYPE_ALIAS_DEF => lsp_types::SymbolKind::TypeParameter, 44 SyntaxKind::TYPE_ALIAS => lsp_types::SymbolKind::TypeParameter,
42 SyntaxKind::RECORD_FIELD_DEF => lsp_types::SymbolKind::Field, 45 SyntaxKind::RECORD_FIELD => lsp_types::SymbolKind::Field,
43 SyntaxKind::STATIC_DEF => lsp_types::SymbolKind::Constant, 46 SyntaxKind::STATIC => lsp_types::SymbolKind::Constant,
44 SyntaxKind::CONST_DEF => lsp_types::SymbolKind::Constant, 47 SyntaxKind::CONST => lsp_types::SymbolKind::Constant,
45 SyntaxKind::IMPL_DEF => lsp_types::SymbolKind::Object, 48 SyntaxKind::IMPL => lsp_types::SymbolKind::Object,
46 _ => lsp_types::SymbolKind::Variable, 49 _ => lsp_types::SymbolKind::Variable,
47 } 50 }
48} 51}
@@ -303,12 +306,15 @@ pub(crate) fn inlay_int(line_index: &LineIndex, inlay_hint: InlayHint) -> lsp_ex
303 } 306 }
304} 307}
305 308
309static TOKEN_RESULT_COUNTER: AtomicU32 = AtomicU32::new(1);
310
306pub(crate) fn semantic_tokens( 311pub(crate) fn semantic_tokens(
307 text: &str, 312 text: &str,
308 line_index: &LineIndex, 313 line_index: &LineIndex,
309 highlights: Vec<HighlightedRange>, 314 highlights: Vec<HighlightedRange>,
310) -> lsp_types::SemanticTokens { 315) -> lsp_types::SemanticTokens {
311 let mut builder = semantic_tokens::SemanticTokensBuilder::default(); 316 let id = TOKEN_RESULT_COUNTER.fetch_add(1, Ordering::SeqCst).to_string();
317 let mut builder = semantic_tokens::SemanticTokensBuilder::new(id);
312 318
313 for highlight_range in highlights { 319 for highlight_range in highlights {
314 let (type_, mods) = semantic_token_type_and_modifiers(highlight_range.highlight); 320 let (type_, mods) = semantic_token_type_and_modifiers(highlight_range.highlight);
@@ -328,6 +334,15 @@ pub(crate) fn semantic_tokens(
328 builder.build() 334 builder.build()
329} 335}
330 336
337pub(crate) fn semantic_token_edits(
338 previous: &lsp_types::SemanticTokens,
339 current: &lsp_types::SemanticTokens,
340) -> lsp_types::SemanticTokensEdits {
341 let result_id = current.result_id.clone();
342 let edits = semantic_tokens::diff_tokens(&previous.data, &current.data);
343 lsp_types::SemanticTokensEdits { result_id, edits }
344}
345
331fn semantic_token_type_and_modifiers( 346fn semantic_token_type_and_modifiers(
332 highlight: Highlight, 347 highlight: Highlight,
333) -> (lsp_types::SemanticTokenType, semantic_tokens::ModifierSet) { 348) -> (lsp_types::SemanticTokenType, semantic_tokens::ModifierSet) {
diff --git a/crates/rust-analyzer/tests/heavy_tests/main.rs b/crates/rust-analyzer/tests/heavy_tests/main.rs
index 28e896648..7370505f8 100644
--- a/crates/rust-analyzer/tests/heavy_tests/main.rs
+++ b/crates/rust-analyzer/tests/heavy_tests/main.rs
@@ -115,21 +115,21 @@ fn main() {}
115 }, 115 },
116 { 116 {
117 "args": { 117 "args": {
118 "cargoArgs": ["check", "--package", "foo"], 118 "cargoArgs": ["check", "--package", "foo", "--all-targets"],
119 "executableArgs": [], 119 "executableArgs": [],
120 "workspaceRoot": server.path().join("foo") 120 "workspaceRoot": server.path().join("foo")
121 }, 121 },
122 "kind": "cargo", 122 "kind": "cargo",
123 "label": "cargo check -p foo" 123 "label": "cargo check -p foo --all-targets"
124 }, 124 },
125 { 125 {
126 "args": { 126 "args": {
127 "cargoArgs": ["test", "--package", "foo"], 127 "cargoArgs": ["test", "--package", "foo", "--all-targets"],
128 "executableArgs": [], 128 "executableArgs": [],
129 "workspaceRoot": server.path().join("foo") 129 "workspaceRoot": server.path().join("foo")
130 }, 130 },
131 "kind": "cargo", 131 "kind": "cargo",
132 "label": "cargo test -p foo" 132 "label": "cargo test -p foo --all-targets"
133 } 133 }
134 ]), 134 ]),
135 ); 135 );
diff --git a/crates/rust-analyzer/tests/heavy_tests/support.rs b/crates/rust-analyzer/tests/heavy_tests/support.rs
index e152264d3..f242c8165 100644
--- a/crates/rust-analyzer/tests/heavy_tests/support.rs
+++ b/crates/rust-analyzer/tests/heavy_tests/support.rs
@@ -253,7 +253,8 @@ impl Drop for Server {
253} 253}
254 254
255fn recv_timeout(receiver: &Receiver<Message>) -> Option<Message> { 255fn recv_timeout(receiver: &Receiver<Message>) -> Option<Message> {
256 let timeout = Duration::from_secs(120); 256 let timeout =
257 if cfg!(target_os = "macos") { Duration::from_secs(300) } else { Duration::from_secs(120) };
257 select! { 258 select! {
258 recv(receiver) -> msg => msg.ok(), 259 recv(receiver) -> msg => msg.ok(),
259 recv(after(timeout)) -> _ => panic!("timed out"), 260 recv(after(timeout)) -> _ => panic!("timed out"),
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs
index ea0e6b949..b65875c96 100644
--- a/crates/stdx/src/lib.rs
+++ b/crates/stdx/src/lib.rs
@@ -109,9 +109,18 @@ pub fn replace(buf: &mut String, from: char, to: &str) {
109 *buf = buf.replace(from, to) 109 *buf = buf.replace(from, to)
110} 110}
111 111
112pub fn split_delim(haystack: &str, delim: char) -> Option<(&str, &str)> { 112// https://github.com/rust-lang/rust/issues/74773
113 let idx = haystack.find(delim)?; 113pub fn split_once(haystack: &str, delim: char) -> Option<(&str, &str)> {
114 Some((&haystack[..idx], &haystack[idx + delim.len_utf8()..])) 114 let mut split = haystack.splitn(2, delim);
115 let prefix = split.next()?;
116 let suffix = split.next()?;
117 Some((prefix, suffix))
118}
119pub fn rsplit_once(haystack: &str, delim: char) -> Option<(&str, &str)> {
120 let mut split = haystack.rsplitn(2, delim);
121 let suffix = split.next()?;
122 let prefix = split.next()?;
123 Some((prefix, suffix))
115} 124}
116 125
117pub fn trim_indent(mut text: &str) -> String { 126pub fn trim_indent(mut text: &str) -> String {
diff --git a/crates/test_utils/src/fixture.rs b/crates/test_utils/src/fixture.rs
index ed764046b..e40b61a94 100644
--- a/crates/test_utils/src/fixture.rs
+++ b/crates/test_utils/src/fixture.rs
@@ -2,7 +2,7 @@
2//! rust-analyzer database from a single string. 2//! rust-analyzer database from a single string.
3 3
4use rustc_hash::FxHashMap; 4use rustc_hash::FxHashMap;
5use stdx::{lines_with_ends, split_delim, trim_indent}; 5use stdx::{lines_with_ends, split_once, trim_indent};
6 6
7#[derive(Debug, Eq, PartialEq)] 7#[derive(Debug, Eq, PartialEq)]
8pub struct Fixture { 8pub struct Fixture {
@@ -71,14 +71,14 @@ impl Fixture {
71 let mut cfg_key_values = Vec::new(); 71 let mut cfg_key_values = Vec::new();
72 let mut env = FxHashMap::default(); 72 let mut env = FxHashMap::default();
73 for component in components[1..].iter() { 73 for component in components[1..].iter() {
74 let (key, value) = split_delim(component, ':').unwrap(); 74 let (key, value) = split_once(component, ':').unwrap();
75 match key { 75 match key {
76 "crate" => krate = Some(value.to_string()), 76 "crate" => krate = Some(value.to_string()),
77 "deps" => deps = value.split(',').map(|it| it.to_string()).collect(), 77 "deps" => deps = value.split(',').map(|it| it.to_string()).collect(),
78 "edition" => edition = Some(value.to_string()), 78 "edition" => edition = Some(value.to_string()),
79 "cfg" => { 79 "cfg" => {
80 for entry in value.split(',') { 80 for entry in value.split(',') {
81 match split_delim(entry, '=') { 81 match split_once(entry, '=') {
82 Some((k, v)) => cfg_key_values.push((k.to_string(), v.to_string())), 82 Some((k, v)) => cfg_key_values.push((k.to_string(), v.to_string())),
83 None => cfg_atoms.push(entry.to_string()), 83 None => cfg_atoms.push(entry.to_string()),
84 } 84 }
@@ -86,7 +86,7 @@ impl Fixture {
86 } 86 }
87 "env" => { 87 "env" => {
88 for key in value.split(',') { 88 for key in value.split(',') {
89 if let Some((k, v)) = split_delim(key, '=') { 89 if let Some((k, v)) = split_once(key, '=') {
90 env.insert(k.into(), v.into()); 90 env.insert(k.into(), v.into());
91 } 91 }
92 } 92 }
diff --git a/docs/dev/README.md b/docs/dev/README.md
index 417352c9d..67813a9c0 100644
--- a/docs/dev/README.md
+++ b/docs/dev/README.md
@@ -50,271 +50,85 @@ We use bors-ng to enforce the [not rocket science](https://graydon2.dreamwidth.o
50 50
51You can run `cargo xtask install-pre-commit-hook` to install git-hook to run rustfmt on commit. 51You can run `cargo xtask install-pre-commit-hook` to install git-hook to run rustfmt on commit.
52 52
53# Code organization
54
55All Rust code lives in the `crates` top-level directory, and is organized as a
56single Cargo workspace. The `editors` top-level directory contains code for
57integrating with editors. Currently, it contains the plugin for VS Code (in
58TypeScript). The `docs` top-level directory contains both developer and user
59documentation.
60
61We have some automation infra in Rust in the `xtask` package. It contains
62stuff like formatting checking, code generation and powers `cargo xtask install`.
63The latter syntax is achieved with the help of cargo aliases (see `.cargo`
64directory).
65
66# Launching rust-analyzer 53# Launching rust-analyzer
67 54
68Debugging the language server can be tricky: LSP is rather chatty, so driving it 55Debugging the language server can be tricky.
69from the command line is not really feasible, driving it via VS Code requires 56LSP is rather chatty, so driving it from the command line is not really feasible, driving it via VS Code requires interacting with two processes.
70interacting with two processes.
71 57
72For this reason, the best way to see how rust-analyzer works is to find a 58For this reason, the best way to see how rust-analyzer works is to find a relevant test and execute it.
73relevant test and execute it (VS Code includes an action for running a single 59VS Code & Emacs include an action for running a single test.
74test).
75 60
76However, launching a VS Code instance with a locally built language server is 61Launching a VS Code instance with a locally built language server is also possible.
77possible. There's **"Run Extension (Debug Build)"** launch configuration for this. 62There's **"Run Extension (Debug Build)"** launch configuration for this in VS Code.
78 63
79In general, I use one of the following workflows for fixing bugs and 64In general, I use one of the following workflows for fixing bugs and implementing features:
80implementing features.
81 65
82If the problem concerns only internal parts of rust-analyzer (i.e. I don't need 66If the problem concerns only internal parts of rust-analyzer (i.e. I don't need to touch the `rust-analyzer` crate or TypeScript code), there is a unit-test for it.
83to touch the `rust-analyzer` crate or TypeScript code), there is a unit-test for it. 67So, I use **Rust Analyzer: Run** action in VS Code to run this single test, and then just do printf-driven development/debugging.
84So, I use **Rust Analyzer: Run** action in VS Code to run this single test, and 68As a sanity check after I'm done, I use `cargo xtask install --server` and **Reload Window** action in VS Code to verify that the thing works as I expect.
85then just do printf-driven development/debugging. As a sanity check after I'm
86done, I use `cargo xtask install --server` and **Reload Window** action in VS
87Code to sanity check that the thing works as I expect.
88 69
89If the problem concerns only the VS Code extension, I use **Run Installed Extension** 70If the problem concerns only the VS Code extension, I use **Run Installed Extension** launch configuration from `launch.json`.
90launch configuration from `launch.json`. Notably, this uses the usual 71Notably, this uses the usual `rust-analyzer` binary from `PATH`.
91`rust-analyzer` binary from `PATH`. For this, it is important to have the following 72For this, it is important to have the following in your `settings.json` file:
92in your `settings.json` file:
93```json 73```json
94{ 74{
95 "rust-analyzer.serverPath": "rust-analyzer" 75 "rust-analyzer.serverPath": "rust-analyzer"
96} 76}
97``` 77```
98After I am done with the fix, I use `cargo 78After I am done with the fix, I use `cargo xtask install --client-code` to try the new extension for real.
99xtask install --client-code` to try the new extension for real.
100
101If I need to fix something in the `rust-analyzer` crate, I feel sad because it's
102on the boundary between the two processes, and working there is slow. I usually
103just `cargo xtask install --server` and poke changes from my live environment.
104Note that this uses `--release`, which is usually faster overall, because
105loading stdlib into debug version of rust-analyzer takes a lot of time. To speed
106things up, sometimes I open a temporary hello-world project which has
107`"rust-analyzer.withSysroot": false` in `.code/settings.json`. This flag causes
108rust-analyzer to skip loading the sysroot, which greatly reduces the amount of
109things rust-analyzer needs to do, and makes printf's more useful. Note that you
110should only use the `eprint!` family of macros for debugging: stdout is used for LSP
111communication, and `print!` would break it.
112
113If I need to fix something simultaneously in the server and in the client, I
114feel even more sad. I don't have a specific workflow for this case.
115
116Additionally, I use `cargo run --release -p rust-analyzer -- analysis-stats
117path/to/some/rust/crate` to run a batch analysis. This is primarily useful for
118performance optimizations, or for bug minimization.
119
120# Code Style & Review Process
121
122Our approach to "clean code" is two-fold:
123
124* We generally don't block PRs on style changes.
125* At the same time, all code in rust-analyzer is constantly refactored.
126
127It is explicitly OK for a reviewer to flag only some nits in the PR, and then send a follow-up cleanup PR for things which are easier to explain by example, cc-ing the original author.
128Sending small cleanup PRs (like renaming a single local variable) is encouraged.
129
130## Scale of Changes
131
132Everyone knows that it's better to send small & focused pull requests.
133The problem is, sometimes you *have* to, eg, rewrite the whole compiler, and that just doesn't fit into a set of isolated PRs.
134
135The main things to keep an eye on are the boundaries between various components.
136There are three kinds of changes:
137
1381. Internals of a single component are changed.
139 Specifically, you don't change any `pub` items.
140 A good example here would be an addition of a new assist.
141
1422. API of a component is expanded.
143 Specifically, you add a new `pub` function which wasn't there before.
144 A good example here would be expansion of assist API, for example, to implement lazy assists or assists groups.
145
1463. A new dependency between components is introduced.
147 Specifically, you add a `pub use` reexport from another crate or you add a new line to the `[dependencies]` section of `Cargo.toml`.
148 A good example here would be adding reference search capability to the assists crates.
149 79
150For the first group, the change is generally merged as long as: 80If I need to fix something in the `rust-analyzer` crate, I feel sad because it's on the boundary between the two processes, and working there is slow.
81I usually just `cargo xtask install --server` and poke changes from my live environment.
82Note that this uses `--release`, which is usually faster overall, because loading stdlib into debug version of rust-analyzer takes a lot of time.
83To speed things up, sometimes I open a temporary hello-world project which has `"rust-analyzer.withSysroot": false` in `.code/settings.json`.
84This flag causes rust-analyzer to skip loading the sysroot, which greatly reduces the amount of things rust-analyzer needs to do, and makes printf's more useful.
85Note that you should only use the `eprint!` family of macros for debugging: stdout is used for LSP communication, and `print!` would break it.
151 86
152* it works for the happy case, 87If I need to fix something simultaneously in the server and in the client, I feel even more sad.
153* it has tests, 88I don't have a specific workflow for this case.
154* it doesn't panic for the unhappy case.
155 89
156For the second group, the change would be subjected to quite a bit of scrutiny and iteration. 90Additionally, I use `cargo run --release -p rust-analyzer -- analysis-stats path/to/some/rust/crate` to run a batch analysis.
157The new API needs to be right (or at least easy to change later). 91This is primarily useful for performance optimizations, or for bug minimization.
158The actual implementation doesn't matter that much.
159It's very important to minimize the amount of changed lines of code for changes of the second kind.
160Often, you start doing a change of the first kind, only to realise that you need to elevate to a change of the second kind.
161In this case, we'll probably ask you to split API changes into a separate PR.
162
163Changes of the third group should be pretty rare, so we don't specify any specific process for them.
164That said, adding an innocent-looking `pub use` is a very simple way to break encapsulation, keep an eye on it!
165
166Note: if you enjoyed this abstract hand-waving about boundaries, you might appreciate
167https://www.tedinski.com/2018/02/06/system-boundaries.html
168
169## Minimal Tests
170
171Most tests in rust-analyzer start with a snippet of Rust code.
172This snippets should be minimal -- if you copy-paste a snippet of real code into the tests, make sure to remove everything which could be removed.
173There are many benefits to this:
174
175* less to read or to scroll past
176* easier to understand what exactly is tested
177* less stuff printed during printf-debugging
178* less time to run test
179
180It also makes sense to format snippets more compactly (for example, by placing enum defitions like `enum E { Foo, Bar }` on a single line),
181as long as they are still readable.
182
183## Order of Imports
184
185We separate import groups with blank lines
186
187```rust
188mod x;
189mod y;
190
191use std::{ ... }
192
193use crate_foo::{ ... }
194use crate_bar::{ ... }
195
196use crate::{}
197
198use super::{} // but prefer `use crate::`
199```
200 92
201## Import Style 93## Parser Tests
202
203Items from `hir` and `ast` should be used qualified:
204
205```rust
206// Good
207use ra_syntax::ast;
208
209fn frobnicate(func: hir::Function, strukt: ast::StructDef) {}
210
211// Not as good
212use hir::Function;
213use ra_syntax::ast::StructDef;
214
215fn frobnicate(func: Function, strukt: StructDef) {}
216```
217
218Avoid local `use MyEnum::*` imports.
219
220Prefer `use crate::foo::bar` to `use super::bar`.
221
222## Order of Items
223
224Optimize for the reader who sees the file for the first time, and wants to get the general idea about what's going on.
225People read things from top to bottom, so place most important things first.
226
227Specifically, if all items except one are private, always put the non-private item on top.
228
229Put `struct`s and `enum`s first, functions and impls last.
230
231Do
232
233```rust
234// Good
235struct Foo {
236 bars: Vec<Bar>
237}
238
239struct Bar;
240```
241
242rather than
243
244```rust
245// Not as good
246struct Bar;
247
248struct Foo {
249 bars: Vec<Bar>
250}
251```
252
253## Variable Naming
254
255We generally use boring and long names for local variables ([yay code completion](https://github.com/rust-analyzer/rust-analyzer/pull/4162#discussion_r417130973)).
256The default name is a lowercased name of the type: `global_state: GlobalState`.
257Avoid ad-hoc acronyms and contractions, but use the ones that exist consistently (`db`, `ctx`, `acc`).
258The default name for "result of the function" local variable is `res`.
259
260## Collection types
261 94
262We prefer `rustc_hash::FxHashMap` and `rustc_hash::FxHashSet` instead of the ones in `std::collections`. 95Tests for the parser (`ra_parser`) live in the `ra_syntax` crate (see `test_data` directory).
263They use a hasher that's slightly faster and using them consistently will reduce code size by some small amount. 96There are two kinds of tests:
264 97
265## Preconditions 98* Manually written test cases in `parser/ok` and `parser/err`
99* "Inline" tests in `parser/inline` (these are generated) from comments in `ra_parser` crate.
266 100
267Function preconditions should generally be expressed in types and provided by the caller (rather than checked by callee): 101The purpose of inline tests is not to achieve full coverage by test cases, but to explain to the reader of the code what each particular `if` and `match` is responsible for.
102If you are tempted to add a large inline test, it might be a good idea to leave only the simplest example in place, and move the test to a manual `parser/ok` test.
268 103
269```rust 104To update test data, run with `UPDATE_EXPECT` variable:
270// Good
271fn frbonicate(walrus: Walrus) {
272 ...
273}
274 105
275// Not as good 106```bash
276fn frobnicate(walrus: Option<Walrus>) { 107env UPDATE_EXPECT=1 cargo qt
277 let walrus = match walrus {
278 Some(it) => it,
279 None => return,
280 };
281 ...
282}
283``` 108```
284 109
285## Premature Pessimization 110After adding a new inline test you need to run `cargo xtest codegen` and also update the test data as described above.
286
287While we don't specifically optimize code yet, avoid writing code which is slower than it needs to be.
288Don't allocate a `Vec` where an iterator would do, don't allocate strings needlessly.
289 111
290```rust 112## TypeScript Tests
291// Good
292use itertools::Itertools;
293 113
294let (first_word, second_word) = match text.split_ascii_whitespace().collect_tuple() { 114If you change files under `editors/code` and would like to run the tests and linter, install npm and run:
295 Some(it) => it,
296 None => return,
297}
298 115
299// Not as good 116```bash
300let words = text.split_ascii_whitespace().collect::<Vec<_>>(); 117cd editors/code
301if words.len() != 2 { 118npm ci
302 return 119npm run lint
303}
304``` 120```
305 121
306## Documentation 122# Code organization
307
308For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines.
309If the line is too long, you want to split the sentence in two :-)
310
311## Commit Style
312 123
313We don't have specific rules around git history hygiene. 124All Rust code lives in the `crates` top-level directory, and is organized as a single Cargo workspace.
314Maintaining clean git history is encouraged, but not enforced. 125The `editors` top-level directory contains code for integrating with editors.
315We use rebase workflow, it's OK to rewrite history during PR review process. 126Currently, it contains the plugin for VS Code (in TypeScript).
127The `docs` top-level directory contains both developer and user documentation.
316 128
317Avoid @mentioning people in commit messages and pull request descriptions (they are added to commit message by bors), as such messages create a lot of duplicate notification traffic during rebases. 129We have some automation infra in Rust in the `xtask` package.
130It contains stuff like formatting checking, code generation and powers `cargo xtask install`.
131The latter syntax is achieved with the help of cargo aliases (see `.cargo` directory).
318 132
319# Architecture Invariants 133# Architecture Invariants
320 134
@@ -349,35 +163,11 @@ The main IDE crate (`ra_ide`) uses "Plain Old Data" for the API.
349Rather than talking in definitions and references, it talks in Strings and textual offsets. 163Rather than talking in definitions and references, it talks in Strings and textual offsets.
350In general, API is centered around UI concerns -- the result of the call is what the user sees in the editor, and not what the compiler sees underneath. 164In general, API is centered around UI concerns -- the result of the call is what the user sees in the editor, and not what the compiler sees underneath.
351The results are 100% Rust specific though. 165The results are 100% Rust specific though.
166Shout outs to LSP developers for popularizing the idea that "UI" is a good place to draw a boundary at.
352 167
353## Parser Tests 168# Code Style & Review Process
354
355Tests for the parser (`ra_parser`) live in the `ra_syntax` crate (see `test_data` directory).
356There are two kinds of tests:
357
358* Manually written test cases in `parser/ok` and `parser/err`
359* "Inline" tests in `parser/inline` (these are generated) from comments in `ra_parser` crate.
360
361The purpose of inline tests is not to achieve full coverage by test cases, but to explain to the reader of the code what each particular `if` and `match` is responsible for.
362If you are tempted to add a large inline test, it might be a good idea to leave only the simplest example in place, and move the test to a manual `parser/ok` test.
363
364To update test data, run with `UPDATE_EXPECT` variable:
365
366```bash
367env UPDATE_EXPECT=1 cargo qt
368```
369
370After adding a new inline test you need to run `cargo xtest codegen` and also update the test data as described above.
371
372## TypeScript Tests
373
374If you change files under `editors/code` and would like to run the tests and linter, install npm and run:
375 169
376```bash 170Do see [./style.md](./style.md).
377cd editors/code
378npm ci
379npm run lint
380```
381 171
382# Logging 172# Logging
383 173
@@ -445,3 +235,34 @@ For measuring time of incremental analysis, use either of these:
445$ cargo run --release -p rust-analyzer -- analysis-bench ../chalk/ --highlight ../chalk/chalk-engine/src/logic.rs 235$ cargo run --release -p rust-analyzer -- analysis-bench ../chalk/ --highlight ../chalk/chalk-engine/src/logic.rs
446$ cargo run --release -p rust-analyzer -- analysis-bench ../chalk/ --complete ../chalk/chalk-engine/src/logic.rs:94:0 236$ cargo run --release -p rust-analyzer -- analysis-bench ../chalk/ --complete ../chalk/chalk-engine/src/logic.rs:94:0
447``` 237```
238
239# Release Process
240
241Release process is handled by `release`, `dist` and `promote` xtasks, `release` being the main one.
242
243`release` assumes that you have checkouts of `rust-analyzer`, `rust-analyzer.github.io`, and `rust-lang/rust` in the same directory:
244
245```
246./rust-analyzer
247./rust-analyzer.github.io
248./rust-rust-analyzer # Note the name!
249```
250
251Additionally, it assumes that remote for `rust-analyzer` is called `upstream` (I use `origin` to point to my fork).
252
253Release steps:
254
2551. Inside rust-analyzer, run `cargo xtask release`. This will:
256 * checkout the `release` branch
257 * reset it to `upstream/nightly`
258 * push it to `upstream`. This triggers GitHub Actions which:
259 ** runs `cargo xtask dist` to package binaries and VS Code extension
260 ** makes a GitHub release
261 ** pushes VS Code extension to the marketplace
262 * create new changelog in `rust-analyzer.github.io`
263 * create `rust-analyzer.github.io/git.log` file with the log of merge commits since last release
2642. While the release is in progress, fill-in the changelog using `git.log`
2653. Commit & push the changelog
2664. Tweet
2675. Inside `rust-analyzer`, run `cargo xtask promote` -- this will create a PR to rust-lang/rust updating rust-analyzer's submodule.
268 Self-approve the PR.
diff --git a/docs/dev/style.md b/docs/dev/style.md
new file mode 100644
index 000000000..1c68f5702
--- /dev/null
+++ b/docs/dev/style.md
@@ -0,0 +1,212 @@
1Our approach to "clean code" is two-fold:
2
3* We generally don't block PRs on style changes.
4* At the same time, all code in rust-analyzer is constantly refactored.
5
6It is explicitly OK for a reviewer to flag only some nits in the PR, and then send a follow-up cleanup PR for things which are easier to explain by example, cc-ing the original author.
7Sending small cleanup PRs (like renaming a single local variable) is encouraged.
8
9# Scale of Changes
10
11Everyone knows that it's better to send small & focused pull requests.
12The problem is, sometimes you *have* to, eg, rewrite the whole compiler, and that just doesn't fit into a set of isolated PRs.
13
14The main things to keep an eye on are the boundaries between various components.
15There are three kinds of changes:
16
171. Internals of a single component are changed.
18 Specifically, you don't change any `pub` items.
19 A good example here would be an addition of a new assist.
20
212. API of a component is expanded.
22 Specifically, you add a new `pub` function which wasn't there before.
23 A good example here would be expansion of assist API, for example, to implement lazy assists or assists groups.
24
253. A new dependency between components is introduced.
26 Specifically, you add a `pub use` reexport from another crate or you add a new line to the `[dependencies]` section of `Cargo.toml`.
27 A good example here would be adding reference search capability to the assists crates.
28
29For the first group, the change is generally merged as long as:
30
31* it works for the happy case,
32* it has tests,
33* it doesn't panic for the unhappy case.
34
35For the second group, the change would be subjected to quite a bit of scrutiny and iteration.
36The new API needs to be right (or at least easy to change later).
37The actual implementation doesn't matter that much.
38It's very important to minimize the amount of changed lines of code for changes of the second kind.
39Often, you start doing a change of the first kind, only to realise that you need to elevate to a change of the second kind.
40In this case, we'll probably ask you to split API changes into a separate PR.
41
42Changes of the third group should be pretty rare, so we don't specify any specific process for them.
43That said, adding an innocent-looking `pub use` is a very simple way to break encapsulation, keep an eye on it!
44
45Note: if you enjoyed this abstract hand-waving about boundaries, you might appreciate
46https://www.tedinski.com/2018/02/06/system-boundaries.html
47
48# Crates.io Dependencies
49
50We try to be very conservative with usage of crates.io dependencies.
51Don't use small "helper" crates (exception: `itertools` is allowed).
52If there's some general reusable bit of code you need, consider adding it to the `stdx` crate.
53
54# Minimal Tests
55
56Most tests in rust-analyzer start with a snippet of Rust code.
57This snippets should be minimal -- if you copy-paste a snippet of real code into the tests, make sure to remove everything which could be removed.
58There are many benefits to this:
59
60* less to read or to scroll past
61* easier to understand what exactly is tested
62* less stuff printed during printf-debugging
63* less time to run test
64
65It also makes sense to format snippets more compactly (for example, by placing enum definitions like `enum E { Foo, Bar }` on a single line),
66as long as they are still readable.
67
68## Order of Imports
69
70Separate import groups with blank lines.
71Use one `use` per crate.
72
73```rust
74mod x;
75mod y;
76
77// First std.
78use std::{ ... }
79
80// Second, external crates (both crates.io crates and other rust-analyzer crates).
81use crate_foo::{ ... }
82use crate_bar::{ ... }
83
84// Then current crate.
85use crate::{}
86
87// Finally, parent and child modules, but prefer `use crate::`.
88use super::{}
89```
90
91Module declarations come before the imports.
92Order them in "suggested reading order" for a person new to the code base.
93
94## Import Style
95
96Qualify items from `hir` and `ast`.
97
98```rust
99// Good
100use ra_syntax::ast;
101
102fn frobnicate(func: hir::Function, strukt: ast::StructDef) {}
103
104// Not as good
105use hir::Function;
106use ra_syntax::ast::StructDef;
107
108fn frobnicate(func: Function, strukt: StructDef) {}
109```
110
111Avoid local `use MyEnum::*` imports.
112
113Prefer `use crate::foo::bar` to `use super::bar`.
114
115## Order of Items
116
117Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on.
118People read things from top to bottom, so place most important things first.
119
120Specifically, if all items except one are private, always put the non-private item on top.
121
122Put `struct`s and `enum`s first, functions and impls last.
123
124Do
125
126```rust
127// Good
128struct Foo {
129 bars: Vec<Bar>
130}
131
132struct Bar;
133```
134
135rather than
136
137```rust
138// Not as good
139struct Bar;
140
141struct Foo {
142 bars: Vec<Bar>
143}
144```
145
146## Variable Naming
147
148Use boring and long names for local variables ([yay code completion](https://github.com/rust-analyzer/rust-analyzer/pull/4162#discussion_r417130973)).
149The default name is a lowercased name of the type: `global_state: GlobalState`.
150Avoid ad-hoc acronyms and contractions, but use the ones that exist consistently (`db`, `ctx`, `acc`).
151The default name for "result of the function" local variable is `res`.
152The default name for "I don't really care about the name" variable is `it`.
153
154## Collection types
155
156Prefer `rustc_hash::FxHashMap` and `rustc_hash::FxHashSet` instead of the ones in `std::collections`.
157They use a hasher that's slightly faster and using them consistently will reduce code size by some small amount.
158
159## Preconditions
160
161Express function preconditions in types and force the caller to provide them (rather than checking in callee):
162
163```rust
164// Good
165fn frbonicate(walrus: Walrus) {
166 ...
167}
168
169// Not as good
170fn frobnicate(walrus: Option<Walrus>) {
171 let walrus = match walrus {
172 Some(it) => it,
173 None => return,
174 };
175 ...
176}
177```
178
179## Premature Pessimization
180
181Avoid writing code which is slower than it needs to be.
182Don't allocate a `Vec` where an iterator would do, don't allocate strings needlessly.
183
184```rust
185// Good
186use itertools::Itertools;
187
188let (first_word, second_word) = match text.split_ascii_whitespace().collect_tuple() {
189 Some(it) => it,
190 None => return,
191}
192
193// Not as good
194let words = text.split_ascii_whitespace().collect::<Vec<_>>();
195if words.len() != 2 {
196 return
197}
198```
199
200## Documentation
201
202For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines.
203If the line is too long, you want to split the sentence in two :-)
204
205## Commit Style
206
207We don't have specific rules around git history hygiene.
208Maintaining clean git history is encouraged, but not enforced.
209Use rebase workflow, it's OK to rewrite history during PR review process.
210
211Avoid @mentioning people in commit messages and pull request descriptions(they are added to commit message by bors).
212Such messages create a lot of duplicate notification traffic during rebases.
diff --git a/docs/dev/syntax.md b/docs/dev/syntax.md
index c2864bbbc..d4bc4b07c 100644
--- a/docs/dev/syntax.md
+++ b/docs/dev/syntax.md
@@ -82,7 +82,7 @@ Points of note:
82An input like `fn f() { 90 + 2 }` might be parsed as 82An input like `fn f() { 90 + 2 }` might be parsed as
83 83
84``` 84```
85FN_DEF@0..17 85[email protected]
86 [email protected] "fn" 86 [email protected] "fn"
87 [email protected] " " 87 [email protected] " "
88 [email protected] 88 [email protected]
@@ -342,7 +342,7 @@ pub struct FnDef {
342impl AstNode for FnDef { 342impl AstNode for FnDef {
343 fn cast(syntax: SyntaxNode) -> Option<Self> { 343 fn cast(syntax: SyntaxNode) -> Option<Self> {
344 match kind { 344 match kind {
345 FN_DEF => Some(FnDef { syntax }), 345 FN => Some(FnDef { syntax }),
346 _ => None, 346 _ => None,
347 } 347 }
348 } 348 }
diff --git a/editors/code/package.json b/editors/code/package.json
index 658c913fd..ee5f96bf3 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -323,6 +323,14 @@
323 "default": true, 323 "default": true,
324 "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)" 324 "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)"
325 }, 325 },
326 "rust-analyzer.checkOnSave.noDefaultFeatures": {
327 "type": [
328 "null",
329 "boolean"
330 ],
331 "default": null,
332 "markdownDescription": "Do not activate the `default` feature"
333 },
326 "rust-analyzer.checkOnSave.allFeatures": { 334 "rust-analyzer.checkOnSave.allFeatures": {
327 "type": [ 335 "type": [
328 "null", 336 "null",
@@ -599,7 +607,7 @@
599 "items": { 607 "items": {
600 "type": "string" 608 "type": "string"
601 }, 609 },
602 "description": "List of warnings warnings that should be displayed with hint severity.\nThe warnings will be indicated by faded text or three dots in code and will not show up in the problems panel.", 610 "description": "List of warnings that should be displayed with hint severity.\nThe warnings will be indicated by faded text or three dots in code and will not show up in the problems panel.",
603 "default": [] 611 "default": []
604 } 612 }
605 } 613 }
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index c21e5597c..d0faf4745 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -190,6 +190,7 @@ export function ssr(ctx: Ctx): Cmd {
190 if (!editor || !client) return; 190 if (!editor || !client) return;
191 191
192 const position = editor.selection.active; 192 const position = editor.selection.active;
193 const selections = editor.selections;
193 const textDocument = { uri: editor.document.uri.toString() }; 194 const textDocument = { uri: editor.document.uri.toString() };
194 195
195 const options: vscode.InputBoxOptions = { 196 const options: vscode.InputBoxOptions = {
@@ -198,7 +199,7 @@ export function ssr(ctx: Ctx): Cmd {
198 validateInput: async (x: string) => { 199 validateInput: async (x: string) => {
199 try { 200 try {
200 await client.sendRequest(ra.ssr, { 201 await client.sendRequest(ra.ssr, {
201 query: x, parseOnly: true, textDocument, position, 202 query: x, parseOnly: true, textDocument, position, selections,
202 }); 203 });
203 } catch (e) { 204 } catch (e) {
204 return e.toString(); 205 return e.toString();
@@ -215,7 +216,7 @@ export function ssr(ctx: Ctx): Cmd {
215 cancellable: false, 216 cancellable: false,
216 }, async (_progress, _token) => { 217 }, async (_progress, _token) => {
217 const edit = await client.sendRequest(ra.ssr, { 218 const edit = await client.sendRequest(ra.ssr, {
218 query: request, parseOnly: false, textDocument, position 219 query: request, parseOnly: false, textDocument, position, selections,
219 }); 220 });
220 221
221 await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit)); 222 await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit));
diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts
index bd92c5b6d..925126a16 100644
--- a/editors/code/src/debug.ts
+++ b/editors/code/src/debug.ts
@@ -87,9 +87,17 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v
87 debugOutput.show(true); 87 debugOutput.show(true);
88 } 88 }
89 89
90 const wsFolder = path.normalize(vscode.workspace.workspaceFolders![0].uri.fsPath); // folder exists or RA is not active. 90 const isMultiFolderWorkspace = vscode.workspace.workspaceFolders!.length > 1;
91 const firstWorkspace = vscode.workspace.workspaceFolders![0]; // folder exists or RA is not active.
92 const workspace = !isMultiFolderWorkspace || !runnable.args.workspaceRoot ?
93 firstWorkspace :
94 vscode.workspace.workspaceFolders!.find(w => runnable.args.workspaceRoot?.includes(w.uri.fsPath)) || firstWorkspace;
95
96 const wsFolder = path.normalize(workspace.uri.fsPath);
97 const workspaceQualifier = isMultiFolderWorkspace ? `:${workspace.name}` : '';
91 function simplifyPath(p: string): string { 98 function simplifyPath(p: string): string {
92 return path.normalize(p).replace(wsFolder, '${workspaceRoot}'); 99 // see https://github.com/rust-analyzer/rust-analyzer/pull/5513#issuecomment-663458818 for why this is needed
100 return path.normalize(p).replace(wsFolder, '${workspaceFolder' + workspaceQualifier + '}');
93 } 101 }
94 102
95 const executable = await getDebugExecutable(runnable); 103 const executable = await getDebugExecutable(runnable);
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts
index 149f9a0d6..494d51c83 100644
--- a/editors/code/src/lsp_ext.ts
+++ b/editors/code/src/lsp_ext.ts
@@ -95,6 +95,7 @@ export interface SsrParams {
95 parseOnly: boolean; 95 parseOnly: boolean;
96 textDocument: lc.TextDocumentIdentifier; 96 textDocument: lc.TextDocumentIdentifier;
97 position: lc.Position; 97 position: lc.Position;
98 selections: lc.Range[];
98} 99}
99export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr'); 100export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr');
100 101
diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml
index d1cfb5909..1a1140b04 100644
--- a/xtask/Cargo.toml
+++ b/xtask/Cargo.toml
@@ -10,9 +10,11 @@ license = "MIT OR Apache-2.0"
10doctest = false 10doctest = false
11 11
12[dependencies] 12[dependencies]
13walkdir = "2.3.1"
14pico-args = "0.3.1"
15quote = "1.0.2"
16proc-macro2 = "1.0.8"
17anyhow = "1.0.26" 13anyhow = "1.0.26"
18flate2 = "1.0" 14flate2 = "1.0"
15pico-args = "0.3.1"
16proc-macro2 = "1.0.8"
17quote = "1.0.2"
18ungrammar = "1.1.1"
19walkdir = "2.3.1"
20write-json = "0.1.0"
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs
index 392648d71..adc191254 100644
--- a/xtask/src/ast_src.rs
+++ b/xtask/src/ast_src.rs
@@ -93,19 +93,19 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
93 ], 93 ],
94 nodes: &[ 94 nodes: &[
95 "SOURCE_FILE", 95 "SOURCE_FILE",
96 "STRUCT_DEF", 96 "STRUCT",
97 "UNION_DEF", 97 "UNION",
98 "ENUM_DEF", 98 "ENUM",
99 "FN_DEF", 99 "FN",
100 "RET_TYPE", 100 "RET_TYPE",
101 "EXTERN_CRATE_ITEM", 101 "EXTERN_CRATE",
102 "MODULE", 102 "MODULE",
103 "USE_ITEM", 103 "USE",
104 "STATIC_DEF", 104 "STATIC",
105 "CONST_DEF", 105 "CONST",
106 "TRAIT_DEF", 106 "TRAIT",
107 "IMPL_DEF", 107 "IMPL",
108 "TYPE_ALIAS_DEF", 108 "TYPE_ALIAS",
109 "MACRO_CALL", 109 "MACRO_CALL",
110 "TOKEN_TREE", 110 "TOKEN_TREE",
111 "MACRO_DEF", 111 "MACRO_DEF",
@@ -113,12 +113,12 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
113 "TUPLE_TYPE", 113 "TUPLE_TYPE",
114 "NEVER_TYPE", 114 "NEVER_TYPE",
115 "PATH_TYPE", 115 "PATH_TYPE",
116 "POINTER_TYPE", 116 "PTR_TYPE",
117 "ARRAY_TYPE", 117 "ARRAY_TYPE",
118 "SLICE_TYPE", 118 "SLICE_TYPE",
119 "REFERENCE_TYPE", 119 "REF_TYPE",
120 "PLACEHOLDER_TYPE", 120 "INFER_TYPE",
121 "FN_POINTER_TYPE", 121 "FN_PTR_TYPE",
122 "FOR_TYPE", 122 "FOR_TYPE",
123 "IMPL_TRAIT_TYPE", 123 "IMPL_TRAIT_TYPE",
124 "DYN_TRAIT_TYPE", 124 "DYN_TRAIT_TYPE",
@@ -126,13 +126,13 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
126 "PAREN_PAT", 126 "PAREN_PAT",
127 "REF_PAT", 127 "REF_PAT",
128 "BOX_PAT", 128 "BOX_PAT",
129 "BIND_PAT", 129 "IDENT_PAT",
130 "PLACEHOLDER_PAT", 130 "WILDCARD_PAT",
131 "DOT_DOT_PAT", 131 "REST_PAT",
132 "PATH_PAT", 132 "PATH_PAT",
133 "RECORD_PAT", 133 "RECORD_PAT",
134 "RECORD_FIELD_PAT_LIST", 134 "RECORD_PAT_FIELD_LIST",
135 "RECORD_FIELD_PAT", 135 "RECORD_PAT_FIELD",
136 "TUPLE_STRUCT_PAT", 136 "TUPLE_STRUCT_PAT",
137 "TUPLE_PAT", 137 "TUPLE_PAT",
138 "SLICE_PAT", 138 "SLICE_PAT",
@@ -144,7 +144,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
144 "ARRAY_EXPR", 144 "ARRAY_EXPR",
145 "PAREN_EXPR", 145 "PAREN_EXPR",
146 "PATH_EXPR", 146 "PATH_EXPR",
147 "LAMBDA_EXPR", 147 "CLOSURE_EXPR",
148 "IF_EXPR", 148 "IF_EXPR",
149 "WHILE_EXPR", 149 "WHILE_EXPR",
150 "CONDITION", 150 "CONDITION",
@@ -159,9 +159,9 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
159 "MATCH_ARM_LIST", 159 "MATCH_ARM_LIST",
160 "MATCH_ARM", 160 "MATCH_ARM",
161 "MATCH_GUARD", 161 "MATCH_GUARD",
162 "RECORD_LIT", 162 "RECORD_EXPR",
163 "RECORD_FIELD_LIST", 163 "RECORD_EXPR_FIELD_LIST",
164 "RECORD_FIELD", 164 "RECORD_EXPR_FIELD",
165 "EFFECT_EXPR", 165 "EFFECT_EXPR",
166 "BOX_EXPR", 166 "BOX_EXPR",
167 // postfix 167 // postfix
@@ -179,13 +179,14 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
179 "BIN_EXPR", 179 "BIN_EXPR",
180 "EXTERN_BLOCK", 180 "EXTERN_BLOCK",
181 "EXTERN_ITEM_LIST", 181 "EXTERN_ITEM_LIST",
182 "ENUM_VARIANT", 182 "VARIANT",
183 "RECORD_FIELD_DEF_LIST", 183 "RECORD_FIELD_LIST",
184 "RECORD_FIELD_DEF", 184 "RECORD_FIELD",
185 "TUPLE_FIELD_DEF_LIST", 185 "TUPLE_FIELD_LIST",
186 "TUPLE_FIELD_DEF", 186 "TUPLE_FIELD",
187 "ENUM_VARIANT_LIST", 187 "VARIANT_LIST",
188 "ITEM_LIST", 188 "ITEM_LIST",
189 "ASSOC_ITEM_LIST",
189 "ATTR", 190 "ATTR",
190 "META_ITEM", // not an item actually 191 "META_ITEM", // not an item actually
191 "USE_TREE", 192 "USE_TREE",
@@ -193,7 +194,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
193 "PATH", 194 "PATH",
194 "PATH_SEGMENT", 195 "PATH_SEGMENT",
195 "LITERAL", 196 "LITERAL",
196 "ALIAS", 197 "RENAME",
197 "VISIBILITY", 198 "VISIBILITY",
198 "WHERE_CLAUSE", 199 "WHERE_CLAUSE",
199 "WHERE_PRED", 200 "WHERE_PRED",
@@ -202,11 +203,12 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
202 "NAME_REF", 203 "NAME_REF",
203 "LET_STMT", 204 "LET_STMT",
204 "EXPR_STMT", 205 "EXPR_STMT",
205 "TYPE_PARAM_LIST", 206 "GENERIC_PARAM_LIST",
207 "GENERIC_PARAM",
206 "LIFETIME_PARAM", 208 "LIFETIME_PARAM",
207 "TYPE_PARAM", 209 "TYPE_PARAM",
208 "CONST_PARAM", 210 "CONST_PARAM",
209 "TYPE_ARG_LIST", 211 "GENERIC_ARG_LIST",
210 "LIFETIME_ARG", 212 "LIFETIME_ARG",
211 "TYPE_ARG", 213 "TYPE_ARG",
212 "ASSOC_TYPE_ARG", 214 "ASSOC_TYPE_ARG",
@@ -223,2021 +225,37 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
223 ], 225 ],
224}; 226};
225 227
226pub(crate) struct AstSrc<'a> { 228#[derive(Default, Debug)]
227 pub(crate) tokens: &'a [&'a str], 229pub(crate) struct AstSrc {
228 pub(crate) nodes: &'a [AstNodeSrc<'a>], 230 pub(crate) tokens: Vec<String>,
229 pub(crate) enums: &'a [AstEnumSrc<'a>], 231 pub(crate) nodes: Vec<AstNodeSrc>,
230} 232 pub(crate) enums: Vec<AstEnumSrc>,
231
232pub(crate) struct AstNodeSrc<'a> {
233 pub(crate) doc: &'a [&'a str],
234 pub(crate) name: &'a str,
235 pub(crate) traits: &'a [&'a str],
236 pub(crate) fields: &'a [Field<'a>],
237}
238
239pub(crate) enum Field<'a> {
240 Token(&'a str),
241 Node { name: &'a str, src: FieldSrc<'a> },
242}
243
244pub(crate) enum FieldSrc<'a> {
245 Shorthand,
246 Optional(&'a str),
247 Many(&'a str),
248} 233}
249 234
250pub(crate) struct AstEnumSrc<'a> { 235#[derive(Debug)]
251 pub(crate) doc: &'a [&'a str], 236pub(crate) struct AstNodeSrc {
252 pub(crate) name: &'a str, 237 pub(crate) doc: Vec<String>,
253 pub(crate) traits: &'a [&'a str], 238 pub(crate) name: String,
254 pub(crate) variants: &'a [&'a str], 239 pub(crate) traits: Vec<String>,
240 pub(crate) fields: Vec<Field>,
255} 241}
256 242
257macro_rules! ast_nodes { 243#[derive(Debug, Eq, PartialEq)]
258 ($( 244pub(crate) enum Field {
259 $(#[doc = $doc:expr])+ 245 Token(String),
260 struct $name:ident$(: $($trait:ident),*)? { 246 Node { name: String, ty: String, cardinality: Cardinality },
261 $($field_name:ident $(![$token:tt])? $(: $ty:tt)?),*$(,)?
262 }
263 )*) => {
264 [$(
265 AstNodeSrc {
266 doc: &[$($doc),*],
267 name: stringify!($name),
268 traits: &[$($(stringify!($trait)),*)?],
269 fields: &[
270 $(field!($(T![$token])? $field_name $($ty)?)),*
271 ],
272
273 }
274 ),*]
275 };
276} 247}
277 248
278macro_rules! field { 249#[derive(Debug, Eq, PartialEq)]
279 (T![$token:tt] T) => { 250pub(crate) enum Cardinality {
280 Field::Token(stringify!($token)) 251 Optional,
281 }; 252 Many,
282 ($field_name:ident) => {
283 Field::Node { name: stringify!($field_name), src: FieldSrc::Shorthand }
284 };
285 ($field_name:ident [$ty:ident]) => {
286 Field::Node { name: stringify!($field_name), src: FieldSrc::Many(stringify!($ty)) }
287 };
288 ($field_name:ident $ty:ident) => {
289 Field::Node { name: stringify!($field_name), src: FieldSrc::Optional(stringify!($ty)) }
290 };
291} 253}
292 254
293macro_rules! ast_enums { 255#[derive(Debug)]
294 ($( 256pub(crate) struct AstEnumSrc {
295 $(#[doc = $doc:expr])+ 257 pub(crate) doc: Vec<String>,
296 enum $name:ident $(: $($trait:ident),*)? { 258 pub(crate) name: String,
297 $($variant:ident),*$(,)? 259 pub(crate) traits: Vec<String>,
298 } 260 pub(crate) variants: Vec<String>,
299 )*) => {
300 [$(
301 AstEnumSrc {
302 doc: &[$($doc),*],
303 name: stringify!($name),
304 traits: &[$($(stringify!($trait)),*)?],
305 variants: &[$(stringify!($variant)),*],
306 }
307 ),*]
308 };
309} 261}
310
311pub(crate) const AST_SRC: AstSrc = AstSrc {
312 tokens: &["Whitespace", "Comment", "String", "RawString"],
313 nodes: &ast_nodes! {
314 /// The entire Rust source file. Includes all top-level inner attributes and module items.
315 ///
316 /// [Reference](https://doc.rust-lang.org/reference/crates-and-source-files.html)
317 struct SourceFile: ModuleItemOwner, AttrsOwner, DocCommentsOwner {
318 modules: [Module],
319 }
320
321 /// Function definition either with body or not.
322 /// Includes all of its attributes and doc comments.
323 ///
324 /// ```
325 /// ❰
326 /// /// Docs
327 /// #[attr]
328 /// pub extern "C" fn foo<T>(#[attr] Patern {p}: Pattern) -> u32
329 /// where
330 /// T: Debug
331 /// {
332 /// 42
333 /// }
334 /// ❱
335 ///
336 /// extern "C" {
337 /// ❰ fn fn_decl(also_variadic_ffi: u32, ...) -> u32; ❱
338 /// }
339 /// ```
340 ///
341 /// - [Reference](https://doc.rust-lang.org/reference/items/functions.html)
342 /// - [Nomicon](https://doc.rust-lang.org/nomicon/ffi.html#variadic-functions)
343 struct FnDef: VisibilityOwner, NameOwner, TypeParamsOwner, DocCommentsOwner, AttrsOwner {
344 Abi,
345 T![const],
346 T![default],
347 T![async],
348 T![unsafe],
349 T![fn],
350 ParamList,
351 RetType,
352 body: BlockExpr,
353 T![;]
354 }
355
356 /// Return type annotation.
357 ///
358 /// ```
359 /// fn foo(a: u32) ❰ -> Option<u32> ❱ { Some(a) }
360 /// ```
361 ///
362 /// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
363 struct RetType { T![->], TypeRef }
364
365 /// Struct definition.
366 /// Includes all of its attributes and doc comments.
367 ///
368 /// ```
369 /// ❰
370 /// /// Docs
371 /// #[attr]
372 /// struct Foo<T> where T: Debug {
373 /// /// Docs
374 /// #[attr]
375 /// pub a: u32,
376 /// b: T,
377 /// }
378 /// ❱
379 ///
380 /// ❰ struct Foo; ❱
381 /// ❰ struct Foo<T>(#[attr] T) where T: Debug; ❱
382 /// ```
383 ///
384 /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
385 struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner {
386 T![struct],
387 FieldDefList,
388 T![;]
389 }
390
391 /// Union definition.
392 /// Includes all of its attributes and doc comments.
393 ///
394 /// ```
395 /// ❰
396 /// /// Docs
397 /// #[attr]
398 /// pub union Foo<T> where T: Debug {
399 /// /// Docs
400 /// #[attr]
401 /// a: T,
402 /// b: u32,
403 /// }
404 /// ❱
405 /// ```
406 ///
407 /// [Reference](https://doc.rust-lang.org/reference/items/unions.html)
408 struct UnionDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner {
409 T![union],
410 RecordFieldDefList,
411 }
412
413 /// Record field definition list including enclosing curly braces.
414 ///
415 /// ```
416 /// struct Foo // same for union
417 /// ❰
418 /// {
419 /// a: u32,
420 /// b: bool,
421 /// }
422 /// ❱
423 /// ```
424 ///
425 /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
426 struct RecordFieldDefList { T!['{'], fields: [RecordFieldDef], T!['}'] }
427
428 /// Record field definition including its attributes and doc comments.
429 ///
430 /// ` ``
431 /// same for union
432 /// struct Foo {
433 /// ❰
434 /// /// Docs
435 /// #[attr]
436 /// pub a: u32
437 /// ❱
438 ///
439 /// ❰ b: bool ❱
440 /// }
441 /// ```
442 ///
443 /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
444 struct RecordFieldDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { }
445
446 /// Tuple field definition list including enclosing parens.
447 ///
448 /// ```
449 /// struct Foo ❰ (u32, String, Vec<u32>) ❱;
450 /// ```
451 ///
452 /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
453 struct TupleFieldDefList { T!['('], fields: [TupleFieldDef], T![')'] }
454
455 /// Tuple field definition including its attributes.
456 ///
457 /// ```
458 /// struct Foo(❰ #[attr] u32 ❱);
459 /// ```
460 ///
461 /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
462 struct TupleFieldDef: VisibilityOwner, AttrsOwner {
463 TypeRef,
464 }
465
466 /// Enum definition.
467 /// Includes all of its attributes and doc comments.
468 ///
469 /// ```
470 /// ❰
471 /// /// Docs
472 /// #[attr]
473 /// pub enum Foo<T> where T: Debug {
474 /// /// Docs
475 /// #[attr]
476 /// Bar,
477 /// Baz(#[attr] u32),
478 /// Bruh {
479 /// a: u32,
480 /// /// Docs
481 /// #[attr]
482 /// b: T,
483 /// }
484 /// }
485 /// ❱
486 /// ```
487 ///
488 /// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
489 struct EnumDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner {
490 T![enum],
491 variant_list: EnumVariantList,
492 }
493
494 /// Enum variant definition list including enclosing curly braces.
495 ///
496 /// ```
497 /// enum Foo
498 /// ❰
499 /// {
500 /// Bar,
501 /// Baz(u32),
502 /// Bruh {
503 /// a: u32
504 /// }
505 /// }
506 /// ❱
507 /// ```
508 ///
509 /// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
510 struct EnumVariantList {
511 T!['{'],
512 variants: [EnumVariant],
513 T!['}']
514 }
515
516 /// Enum variant definition including its attributes and discriminant value definition.
517 ///
518 /// ```
519 /// enum Foo {
520 /// ❰
521 /// /// Docs
522 /// #[attr]
523 /// Bar
524 /// ❱
525 ///
526 /// // same for tuple and record variants
527 /// }
528 /// ```
529 ///
530 /// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
531 struct EnumVariant: VisibilityOwner, NameOwner, DocCommentsOwner, AttrsOwner {
532 FieldDefList,
533 T![=],
534 Expr
535 }
536
537 /// Trait definition.
538 /// Includes all of its attributes and doc comments.
539 ///
540 /// ```
541 /// ❰
542 /// /// Docs
543 /// #[attr]
544 /// pub unsafe trait Foo<T>: Debug where T: Debug {
545 /// // ...
546 /// }
547 /// ❱
548 /// ```
549 ///
550 /// [Reference](https://doc.rust-lang.org/reference/items/traits.html)
551 struct TraitDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeParamsOwner, TypeBoundsOwner {
552 T![unsafe],
553 T![auto],
554 T![trait],
555 ItemList,
556 }
557
558 /// Module definition either with body or not.
559 /// Includes all of its inner and outer attributes, module items, doc comments.
560 ///
561 /// ```
562 /// ❰
563 /// /// Docs
564 /// #[attr]
565 /// pub mod foo;
566 /// ❱
567 ///
568 /// ❰
569 /// /// Docs
570 /// #[attr]
571 /// pub mod bar {
572 /// //! Inner docs
573 /// #![inner_attr]
574 /// }
575 /// ❱
576 /// ```
577 ///
578 /// [Reference](https://doc.rust-lang.org/reference/items/modules.html)
579 struct Module: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner {
580 T![mod],
581 ItemList,
582 T![;]
583 }
584
585 /// Item defintion list.
586 /// This is used for both top-level items and impl block items.
587 ///
588 /// ```
589 /// ❰
590 /// fn foo {}
591 /// struct Bar;
592 /// enum Baz;
593 /// trait Bruh;
594 /// const BRUUH: u32 = 42;
595 /// ❱
596 ///
597 /// impl Foo
598 /// ❰
599 /// {
600 /// fn bar() {}
601 /// const BAZ: u32 = 42;
602 /// }
603 /// ❱
604 /// ```
605 ///
606 /// [Reference](https://doc.rust-lang.org/reference/items.html)
607 struct ItemList: ModuleItemOwner {
608 T!['{'],
609 assoc_items: [AssocItem],
610 T!['}']
611 }
612
613 /// Constant variable definition.
614 /// Includes all of its attributes and doc comments.
615 ///
616 /// ```
617 /// ❰
618 /// /// Docs
619 /// #[attr]
620 /// pub const FOO: u32 = 42;
621 /// ❱
622 /// ```
623 ///
624 /// [Reference](https://doc.rust-lang.org/reference/items/constant-items.html)
625 struct ConstDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner {
626 T![default],
627 T![const],
628 T![=],
629 body: Expr,
630 T![;]
631 }
632
633
634 /// Static variable definition.
635 /// Includes all of its attributes and doc comments.
636 ///
637 /// ```
638 /// ❰
639 /// /// Docs
640 /// #[attr]
641 /// pub static mut FOO: u32 = 42;
642 /// ❱
643 /// ```
644 ///
645 /// [Reference](https://doc.rust-lang.org/reference/items/static-items.html)
646 struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner {
647 T![static],
648 T![mut],
649 T![=],
650 body: Expr,
651 T![;]
652 }
653
654 /// Type alias definition.
655 /// Includes associated type clauses with type bounds.
656 ///
657 /// ```
658 /// ❰
659 /// /// Docs
660 /// #[attr]
661 /// pub type Foo<T> where T: Debug = T;
662 /// ❱
663 ///
664 /// trait Bar {
665 /// ❰ type Baz: Debug; ❱
666 /// ❰ type Bruh = String; ❱
667 /// ❰ type Bruuh: Debug = u32; ❱
668 /// }
669 /// ```
670 ///
671 /// [Reference](https://doc.rust-lang.org/reference/items/type-aliases.html)
672 struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner {
673 T![default],
674 T![type],
675 T![=],
676 TypeRef,
677 T![;]
678 }
679
680 /// Inherent and trait impl definition.
681 /// Includes all of its inner and outer attributes.
682 ///
683 /// ```
684 /// ❰
685 /// #[attr]
686 /// unsafe impl<T> const !Foo for Bar where T: Debug {
687 /// #![inner_attr]
688 /// // ...
689 /// }
690 /// ❱
691 /// ```
692 ///
693 /// [Reference](https://doc.rust-lang.org/reference/items/implementations.html)
694 struct ImplDef: TypeParamsOwner, AttrsOwner, DocCommentsOwner {
695 T![default],
696 T![const],
697 T![unsafe],
698 T![impl],
699 T![!],
700 T![for],
701 ItemList,
702 }
703
704
705 /// Parenthesized type reference.
706 /// Note: parens are only used for grouping, this is not a tuple type.
707 ///
708 /// ```
709 /// // This is effectively just `u32`.
710 /// // Single-item tuple must be defined with a trailing comma: `(u32,)`
711 /// type Foo = ❰ (u32) ❱;
712 ///
713 /// let bar: &'static ❰ (dyn Debug) ❱ = "bruh";
714 /// ```
715 struct ParenType { T!['('], TypeRef, T![')'] }
716
717 /// Unnamed tuple type.
718 ///
719 /// ```
720 /// let foo: ❰ (u32, bool) ❱ = (42, true);
721 /// ```
722 ///
723 /// [Reference](https://doc.rust-lang.org/reference/types/tuple.html)
724 struct TupleType { T!['('], fields: [TypeRef], T![')'] }
725
726 /// The never type (i.e. the exclamation point).
727 ///
728 /// ```
729 /// type T = ❰ ! ❱;
730 ///
731 /// fn no_return() -> ❰ ! ❱ {
732 /// loop {}
733 /// }
734 /// ```
735 ///
736 /// [Reference](https://doc.rust-lang.org/reference/types/never.html)
737 struct NeverType { T![!] }
738
739 /// Path to a type.
740 /// Includes single identifier type names and elaborate paths with
741 /// generic parameters.
742 ///
743 /// ```
744 /// type Foo = ❰ String ❱;
745 /// type Bar = ❰ std::vec::Vec<T> ❱;
746 /// type Baz = ❰ ::bruh::<Bruuh as Iterator>::Item ❱;
747 /// ```
748 ///
749 /// [Reference](https://doc.rust-lang.org/reference/paths.html)
750 struct PathType { Path }
751
752 /// Raw pointer type.
753 ///
754 /// ```
755 /// type Foo = ❰ *const u32 ❱;
756 /// type Bar = ❰ *mut u32 ❱;
757 /// ```
758 ///
759 /// [Reference](https://doc.rust-lang.org/reference/types/pointer.html#raw-pointers-const-and-mut)
760 struct PointerType { T![*], T![const], T![mut], TypeRef }
761
762 /// Array type.
763 ///
764 /// ```
765 /// type Foo = ❰ [u32; 24 - 3] ❱;
766 /// ```
767 ///
768 /// [Reference](https://doc.rust-lang.org/reference/types/array.html)
769 struct ArrayType { T!['['], TypeRef, T![;], Expr, T![']'] }
770
771 /// Slice type.
772 ///
773 /// ```
774 /// type Foo = ❰ [u8] ❱;
775 /// ```
776 ///
777 /// [Reference](https://doc.rust-lang.org/reference/types/slice.html)
778 struct SliceType { T!['['], TypeRef, T![']'] }
779
780 /// Reference type.
781 ///
782 /// ```
783 /// type Foo = ❰ &'static str ❱;
784 /// ```
785 ///
786 /// [Reference](https://doc.rust-lang.org/reference/types/pointer.html)
787 struct ReferenceType { T![&], T![lifetime], T![mut], TypeRef }
788
789 /// Placeholder type (i.e. the underscore).
790 ///
791 /// ```
792 /// let foo: ❰ _ ❱ = 42_u32;
793 /// ```
794 ///
795 /// [Reference](https://doc.rust-lang.org/reference/types/inferred.html)
796 struct PlaceholderType { T![_] }
797
798 /// Function pointer type (not to be confused with `Fn*` family of traits).
799 ///
800 /// ```
801 /// type Foo = ❰ async fn(#[attr] u32, named: bool) -> u32 ❱;
802 ///
803 /// type Bar = ❰ extern "C" fn(variadic: u32, #[attr] ...) ❱;
804 /// ```
805 ///
806 /// [Reference](https://doc.rust-lang.org/reference/types/function-pointer.html)
807 struct FnPointerType { Abi, T![unsafe], T![fn], ParamList, RetType }
808
809 /// Higher order type.
810 ///
811 /// ```
812 /// type Foo = ❰ for<'a> fn(&'a str) ❱;
813 /// ```
814 ///
815 /// [Reference](https://doc.rust-lang.org/nomicon/hrtb.html)
816 struct ForType { T![for], TypeParamList, TypeRef }
817
818 /// Opaque `impl Trait` type.
819 ///
820 /// ```
821 /// fn foo(bar: ❰ impl Debug + Eq ❱) {}
822 /// ```
823 ///
824 /// [Reference](https://doc.rust-lang.org/reference/types/impl-trait.html)
825 struct ImplTraitType: TypeBoundsOwner { T![impl] }
826
827 /// Trait object type.
828 ///
829 /// ```
830 /// type Foo = ❰ dyn Debug ❱;
831 /// ```
832 ///
833 /// [Reference](https://doc.rust-lang.org/reference/types/trait-object.html)
834 struct DynTraitType: TypeBoundsOwner { T![dyn] }
835
836 /// Tuple literal.
837 ///
838 /// ```
839 /// ❰ (42, true) ❱;
840 /// ```
841 ///
842 /// [Reference](https://doc.rust-lang.org/reference/expressions/tuple-expr.html)
843 struct TupleExpr: AttrsOwner { T!['('], exprs: [Expr], T![')'] }
844
845 /// Array literal.
846 ///
847 /// ```
848 /// ❰ [#![inner_attr] true, false, true] ❱;
849 ///
850 /// ❰ ["baz"; 24] ❱;
851 /// ```
852 ///
853 /// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html)
854 struct ArrayExpr: AttrsOwner { T!['['], exprs: [Expr], T![;], T![']'] }
855
856 /// Parenthesized expression.
857 /// Note: parens are only used for grouping, this is not a tuple literal.
858 ///
859 /// ```
860 /// ❰ (#![inner_attr] 2 + 2) ❱ * 2;
861 /// ```
862 ///
863 /// [Reference](https://doc.rust-lang.org/reference/expressions/grouped-expr.html)
864 struct ParenExpr: AttrsOwner { T!['('], Expr, T![')'] }
865
866 /// Path to a symbol in expression context.
867 /// Includes single identifier variable names and elaborate paths with
868 /// generic parameters.
869 ///
870 /// ```
871 /// ❰ Some::<i32> ❱;
872 /// ❰ foo ❱ + 42;
873 /// ❰ Vec::<i32>::push ❱;
874 /// ❰ <[i32]>::reverse ❱;
875 /// ❰ <String as std::borrow::Borrow<str>>::borrow ❱;
876 /// ```
877 ///
878 /// [Reference](https://doc.rust-lang.org/reference/expressions/path-expr.html)
879 struct PathExpr { Path }
880
881 /// Anonymous callable object literal a.k.a. closure, lambda or functor.
882 ///
883 /// ```
884 /// ❰ || 42 ❱;
885 /// ❰ |a: u32| val + 1 ❱;
886 /// ❰ async |#[attr] Pattern(_): Pattern| { bar } ❱;
887 /// ❰ move || baz ❱;
888 /// ❰ || -> u32 { closure_with_ret_type_annotation_requires_block_expr } ❱
889 /// ```
890 ///
891 /// [Reference](https://doc.rust-lang.org/reference/expressions/closure-expr.html)
892 struct LambdaExpr: AttrsOwner {
893 T![static], // Note(@matklad): I belive this is (used to be?) syntax for generators
894 T![async],
895 T![move],
896 ParamList,
897 RetType,
898 body: Expr,
899 }
900
901 /// If expression. Includes both regular `if` and `if let` forms.
902 /// Beware that `else if` is a special case syntax sugar, because in general
903 /// there has to be block expression after `else`.
904 ///
905 /// ```
906 /// ❰ if bool_cond { 42 } ❱
907 /// ❰ if bool_cond { 42 } else { 24 } ❱
908 /// ❰ if bool_cond { 42 } else if bool_cond2 { 42 } ❱
909 ///
910 /// ❰
911 /// if let Pattern(foo) = bar {
912 /// foo
913 /// } else {
914 /// panic!();
915 /// }
916 /// ❱
917 /// ```
918 ///
919 /// [Reference](https://doc.rust-lang.org/reference/expressions/if-expr.html)
920 struct IfExpr: AttrsOwner { T![if], Condition }
921
922 /// Unconditional loop expression.
923 ///
924 /// ```
925 /// ❰
926 /// loop {
927 /// // yeah, it's that simple...
928 /// }
929 /// ❱
930 /// ```
931 ///
932 /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html)
933 struct LoopExpr: AttrsOwner, LoopBodyOwner { T![loop] }
934
935 /// Block expression with an optional prefix (label, try ketword,
936 /// unsafe keyword, async keyword...).
937 ///
938 /// ```
939 /// ❰
940 /// 'label: try {
941 /// None?
942 /// }
943 /// ❱
944 /// ```
945 ///
946 /// - [try block](https://doc.rust-lang.org/unstable-book/language-features/try-blocks.html)
947 /// - [unsafe block](https://doc.rust-lang.org/reference/expressions/block-expr.html#unsafe-blocks)
948 /// - [async block](https://doc.rust-lang.org/reference/expressions/block-expr.html#async-blocks)
949 struct EffectExpr: AttrsOwner { Label, T![try], T![unsafe], T![async], BlockExpr }
950
951
952 /// For loop expression.
953 /// Note: record struct literals are not valid as iterable expression
954 /// due to ambiguity.
955 ///
956 /// ```
957 /// ❰
958 /// for i in (0..4) {
959 /// dbg!(i);
960 /// }
961 /// ❱
962 /// ```
963 ///
964 /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#iterator-loops)
965 struct ForExpr: AttrsOwner, LoopBodyOwner {
966 T![for],
967 Pat,
968 T![in],
969 iterable: Expr,
970 }
971
972 /// While loop expression. Includes both regular `while` and `while let` forms.
973 ///
974 /// ```
975 /// ❰
976 /// while bool_cond {
977 /// 42;
978 /// }
979 /// ❱
980 /// ❰
981 /// while let Pattern(foo) = bar {
982 /// bar += 1;
983 /// }
984 /// ❱
985 /// ```
986 ///
987 /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops)
988 struct WhileExpr: AttrsOwner, LoopBodyOwner { T![while], Condition }
989
990 /// Continue expression.
991 ///
992 /// ```
993 /// while bool_cond {
994 /// ❰ continue ❱;
995 /// }
996 ///
997 /// 'outer: loop {
998 /// loop {
999 /// ❰ continue 'outer ❱;
1000 /// }
1001 /// }
1002 ///
1003 /// ```
1004 ///
1005 /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#continue-expressions)
1006 struct ContinueExpr: AttrsOwner { T![continue], T![lifetime] }
1007
1008 /// Break expression.
1009 ///
1010 /// ```
1011 /// while bool_cond {
1012 /// ❰ break ❱;
1013 /// }
1014 /// 'outer: loop {
1015 /// for foo in bar {
1016 /// ❰ break 'outer ❱;
1017 /// }
1018 /// }
1019 /// 'outer: loop {
1020 /// loop {
1021 /// ❰ break 'outer 42 ❱;
1022 /// }
1023 /// }
1024 /// ```
1025 ///
1026 /// [Refernce](https://doc.rust-lang.org/reference/expressions/loop-expr.html#break-expressions)
1027 struct BreakExpr: AttrsOwner { T![break], T![lifetime], Expr }
1028
1029 /// Label.
1030 ///
1031 /// ```
1032 /// ❰ 'outer: ❱ loop {}
1033 ///
1034 /// let foo = ❰ 'bar: ❱ loop {}
1035 ///
1036 /// ❰ 'baz: ❱ {
1037 /// break 'baz;
1038 /// }
1039 /// ```
1040 ///
1041 /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html?highlight=label#loop-labels)
1042 /// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md)
1043 struct Label { T![lifetime] }
1044
1045 /// Block expression. Includes unsafe blocks and block labels.
1046 ///
1047 /// ```
1048 /// let foo = ❰
1049 /// {
1050 /// #![inner_attr]
1051 /// ❰ { } ❱
1052 ///
1053 /// ❰ 'label: { break 'label } ❱
1054 /// }
1055 /// ❱;
1056 /// ```
1057 ///
1058 /// [Reference](https://doc.rust-lang.org/reference/expressions/block-expr.html)
1059 /// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md)
1060 struct BlockExpr: AttrsOwner, ModuleItemOwner {
1061 Label, T!['{'], statements: [Stmt], Expr, T!['}'],
1062 }
1063
1064 /// Return expression.
1065 ///
1066 /// ```
1067 /// || ❰ return 42 ❱;
1068 ///
1069 /// fn bar() {
1070 /// ❰ return ❱;
1071 /// }
1072 /// ```
1073 ///
1074 /// [Reference](https://doc.rust-lang.org/reference/expressions/return-expr.html)
1075 struct ReturnExpr: AttrsOwner { Expr }
1076
1077 /// Call expression (not to be confused with method call expression, it is
1078 /// a separate ast node).
1079 ///
1080 /// ```
1081 /// ❰ foo() ❱;
1082 /// ❰ &str::len("bar") ❱;
1083 /// ❰ <&str as PartialEq<&str>>::eq(&"", &"") ❱;
1084 /// ```
1085 ///
1086 /// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html)
1087 struct CallExpr: ArgListOwner { Expr }
1088
1089 /// Method call expression.
1090 ///
1091 /// ```
1092 /// ❰ receiver_expr.method() ❱;
1093 /// ❰ receiver_expr.method::<T>(42, true) ❱;
1094 ///
1095 /// ❰ ❰ ❰ foo.bar() ❱ .baz() ❱ .bruh() ❱;
1096 /// ```
1097 ///
1098 /// [Reference](https://doc.rust-lang.org/reference/expressions/method-call-expr.html)
1099 struct MethodCallExpr: AttrsOwner, ArgListOwner {
1100 Expr, T![.], NameRef, TypeArgList,
1101 }
1102
1103 /// Index expression a.k.a. subscript operator call.
1104 ///
1105 /// ```
1106 /// ❰ foo[42] ❱;
1107 /// ```
1108 ///
1109 /// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html)
1110 struct IndexExpr: AttrsOwner { T!['['], T![']'] }
1111
1112 /// Field access expression.
1113 ///
1114 /// ```
1115 /// ❰ expr.bar ❱;
1116 ///
1117 /// ❰ ❰ ❰ foo.bar ❱ .baz ❱ .bruh ❱;
1118 /// ```
1119 ///
1120 /// [Reference](https://doc.rust-lang.org/reference/expressions/field-expr.html)
1121 struct FieldExpr: AttrsOwner { Expr, T![.], NameRef }
1122
1123 /// Await operator call expression.
1124 ///
1125 /// ```
1126 /// ❰ expr.await ❱;
1127 /// ```
1128 ///
1129 /// [Reference](https://doc.rust-lang.org/reference/expressions/await-expr.html)
1130 struct AwaitExpr: AttrsOwner { Expr, T![.], T![await] }
1131
1132 /// The question mark operator call.
1133 ///
1134 /// ```
1135 /// ❰ expr? ❱;
1136 /// ```
1137 ///
1138 /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#the-question-mark-operator)
1139 struct TryExpr: AttrsOwner { Expr, T![?] }
1140
1141 /// Type cast expression.
1142 ///
1143 /// ```
1144 /// ❰ expr as T ❱;
1145 /// ```
1146 ///
1147 /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions)
1148 struct CastExpr: AttrsOwner { Expr, T![as], TypeRef }
1149
1150
1151 /// Borrow operator call.
1152 ///
1153 /// ```
1154 /// ❰ &foo ❱;
1155 /// ❰ &mut bar ❱;
1156 /// ❰ &raw const bar ❱;
1157 /// ❰ &raw mut bar ❱;
1158 /// ```
1159 ///
1160 /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#borrow-operators)
1161 struct RefExpr: AttrsOwner { T![&], T![raw], T![mut], T![const], Expr }
1162
1163 /// Prefix operator call. This is either `!` or `*` or `-`.
1164 ///
1165 /// ```
1166 /// ❰ !foo ❱;
1167 /// ❰ *bar ❱;
1168 /// ❰ -42 ❱;
1169 /// ```
1170 ///
1171 /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html)
1172 struct PrefixExpr: AttrsOwner { /*PrefixOp,*/ Expr }
1173
1174 /// Box operator call.
1175 ///
1176 /// ```
1177 /// ❰ box 42 ❱;
1178 /// ```
1179 ///
1180 /// [RFC](https://github.com/rust-lang/rfcs/blob/0806be4f282144cfcd55b1d20284b43f87cbe1c6/text/0809-box-and-in-for-stdlib.md)
1181 struct BoxExpr: AttrsOwner { T![box], Expr }
1182
1183 /// Range operator call.
1184 ///
1185 /// ```
1186 /// ❰ 0..42 ❱;
1187 /// ❰ ..42 ❱;
1188 /// ❰ 0.. ❱;
1189 /// ❰ .. ❱;
1190 /// ❰ 0..=42 ❱;
1191 /// ❰ ..=42 ❱;
1192 /// ```
1193 ///
1194 /// [Reference](https://doc.rust-lang.org/reference/expressions/range-expr.html)
1195 struct RangeExpr: AttrsOwner { /*RangeOp*/ }
1196
1197
1198 /// Binary operator call.
1199 /// Includes all arithmetic, logic, bitwise and assignment operators.
1200 ///
1201 /// ```
1202 /// ❰ 2 + ❰ 2 * 2 ❱ ❱;
1203 /// ❰ ❰ true && false ❱ || true ❱;
1204 /// ```
1205 ///
1206 /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators)
1207 struct BinExpr: AttrsOwner { /*BinOp*/ }
1208
1209
1210 /// [Raw] string, [raw] byte string, char, byte, integer, float or bool literal.
1211 ///
1212 /// ```
1213 /// ❰ "str" ❱;
1214 /// ❰ br##"raw byte str"## ❱;
1215 /// ❰ 'c' ❱;
1216 /// ❰ b'c' ❱;
1217 /// ❰ 42 ❱;
1218 /// ❰ 1e9 ❱;
1219 /// ❰ true ❱;
1220 /// ```
1221 ///
1222 /// [Reference](https://doc.rust-lang.org/reference/expressions/literal-expr.html)
1223 struct Literal { /*LiteralToken*/ }
1224
1225 /// Match expression.
1226 ///
1227 /// ```
1228 /// ❰
1229 /// match expr {
1230 /// Pat1 => {}
1231 /// Pat2(_) => 42,
1232 /// }
1233 /// ❱
1234 /// ```
1235 ///
1236 /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1237 struct MatchExpr: AttrsOwner { T![match], Expr, MatchArmList }
1238
1239 /// Match arm list part of match expression. Includes its inner attributes.
1240 ///
1241 /// ```
1242 /// match expr
1243 /// ❰
1244 /// {
1245 /// #![inner_attr]
1246 /// Pat1 => {}
1247 /// Pat2(_) => 42,
1248 /// }
1249 /// ❱
1250 /// ```
1251 ///
1252 /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1253 struct MatchArmList: AttrsOwner { T!['{'], arms: [MatchArm], T!['}'] }
1254
1255
1256 /// Match arm.
1257 /// Note: record struct literals are not valid as target match expression
1258 /// due to ambiguity.
1259 /// ```
1260 /// match expr {
1261 /// ❰ #[attr] Pattern(it) if bool_cond => it ❱,
1262 /// }
1263 /// ```
1264 ///
1265 /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1266 struct MatchArm: AttrsOwner {
1267 pat: Pat,
1268 guard: MatchGuard,
1269 T![=>],
1270 Expr,
1271 }
1272
1273 /// Match guard.
1274 ///
1275 /// ```
1276 /// match expr {
1277 /// Pattern(it) ❰ if bool_cond ❱ => it,
1278 /// }
1279 /// ```
1280 ///
1281 /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html#match-guards)
1282 struct MatchGuard { T![if], Expr }
1283
1284 /// Record literal expression. The same syntax is used for structs,
1285 /// unions and record enum variants.
1286 ///
1287 /// ```
1288 /// ❰
1289 /// foo::Bar {
1290 /// #![inner_attr]
1291 /// baz: 42,
1292 /// bruh: true,
1293 /// ..spread
1294 /// }
1295 /// ❱
1296 /// ```
1297 ///
1298 /// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1299 struct RecordLit { Path, RecordFieldList}
1300
1301 /// Record field list including enclosing curly braces.
1302 ///
1303 /// foo::Bar ❰
1304 /// {
1305 /// baz: 42,
1306 /// ..spread
1307 /// }
1308 /// ❱
1309 ///
1310 /// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1311 struct RecordFieldList {
1312 T!['{'],
1313 fields: [RecordField],
1314 T![..],
1315 spread: Expr,
1316 T!['}']
1317 }
1318
1319 /// Record field.
1320 ///
1321 /// ```
1322 /// foo::Bar {
1323 /// ❰ #[attr] baz: 42 ❱
1324 /// }
1325 /// ```
1326 ///
1327 /// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1328 struct RecordField: AttrsOwner { NameRef, T![:], Expr }
1329
1330 /// Disjunction of patterns.
1331 ///
1332 /// ```
1333 /// let ❰ Foo(it) | Bar(it) | Baz(it) ❱ = bruh;
1334 /// ```
1335 ///
1336 /// [Reference](https://doc.rust-lang.org/reference/patterns.html)
1337 struct OrPat { pats: [Pat] }
1338
1339 /// Parenthesized pattern.
1340 /// Note: parens are only used for grouping, this is not a tuple pattern.
1341 ///
1342 /// ```
1343 /// if let ❰ &(0..=42) ❱ = foo {}
1344 /// ```
1345 ///
1346 /// https://doc.rust-lang.org/reference/patterns.html#grouped-patterns
1347 struct ParenPat { T!['('], Pat, T![')'] }
1348
1349 /// Reference pattern.
1350 /// Note: this has nothing to do with `ref` keyword, the latter is used in bind patterns.
1351 ///
1352 /// ```
1353 /// let ❰ &mut foo ❱ = bar;
1354 ///
1355 /// let ❰ & ❰ &mut ❰ &_ ❱ ❱ ❱ = baz;
1356 /// ```
1357 ///
1358 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#reference-patterns)
1359 struct RefPat { T![&], T![mut], Pat }
1360
1361 /// Box pattern.
1362 ///
1363 /// ```
1364 /// let ❰ box foo ❱ = box 42;
1365 /// ```
1366 ///
1367 /// [Unstable book](https://doc.rust-lang.org/unstable-book/language-features/box-patterns.html)
1368 struct BoxPat { T![box], Pat }
1369
1370 /// Bind pattern.
1371 ///
1372 /// ```
1373 /// match foo {
1374 /// Some(❰ ref mut bar ❱) => {}
1375 /// ❰ baz @ None ❱ => {}
1376 /// }
1377 /// ```
1378 ///
1379 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#identifier-patterns)
1380 struct BindPat: AttrsOwner, NameOwner { T![ref], T![mut], T![@], Pat }
1381
1382 /// Placeholder pattern a.k.a. the wildcard pattern or the underscore.
1383 ///
1384 /// ```
1385 /// let ❰ _ ❱ = foo;
1386 /// ```
1387 ///
1388 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#wildcard-pattern)
1389 struct PlaceholderPat { T![_] }
1390
1391 /// Rest-of-the record/tuple pattern.
1392 /// Note: this is not the unbonded range pattern (even more: it doesn't exist).
1393 ///
1394 /// ```
1395 /// let Foo { bar, ❰ .. ❱ } = baz;
1396 /// let (❰ .. ❱, bruh) = (42, 24, 42);
1397 /// let Bruuh(❰ .. ❱) = bruuuh;
1398 /// ```
1399 ///
1400 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1401 struct DotDotPat { T![..] }
1402
1403 /// Path pattern.
1404 /// Doesn't include the underscore pattern (it is a special case, namely `PlaceholderPat`).
1405 ///
1406 /// ```
1407 /// let ❰ foo::bar::Baz ❱ { .. } = bruh;
1408 /// if let ❰ CONST ❱ = 42 {}
1409 /// ```
1410 ///
1411 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#path-patterns)
1412 struct PathPat { Path }
1413
1414 /// Slice pattern.
1415 ///
1416 /// ```
1417 /// let ❰ [foo, bar, baz] ❱ = [1, 2, 3];
1418 /// ```
1419 ///
1420 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#slice-patterns)
1421 struct SlicePat { T!['['], args: [Pat], T![']'] }
1422
1423 /// Range pattern.
1424 ///
1425 /// ```
1426 /// match foo {
1427 /// ❰ 0..42 ❱ => {}
1428 /// ❰ 0..=42 ❱ => {}
1429 /// }
1430 /// ```
1431 ///
1432 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#range-patterns)
1433 struct RangePat { } // FIXME(@matklad): here should be T![..], T![..=] I think, if we don't already have an accessor in expresions_ext
1434
1435 /// Literal pattern.
1436 /// Includes only bool, number, char, and string literals.
1437 ///
1438 /// ```
1439 /// match foo {
1440 /// Number(❰ 42 ❱) => {}
1441 /// String(❰ "42" ❱) => {}
1442 /// Bool(❰ true ❱) => {}
1443 /// }
1444 /// ```
1445 ///
1446 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#literal-patterns)
1447 struct LiteralPat { Literal }
1448
1449 /// Macro invocation in pattern position.
1450 ///
1451 /// ```
1452 /// let ❰ foo!(my custom syntax) ❱ = baz;
1453 ///
1454 /// ```
1455 /// [Reference](https://doc.rust-lang.org/reference/macros.html#macro-invocation)
1456 struct MacroPat { MacroCall }
1457
1458 /// Record literal pattern.
1459 ///
1460 /// ```
1461 /// let ❰ foo::Bar { baz, .. } ❱ = bruh;
1462 /// ```
1463 ///
1464 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1465 struct RecordPat { RecordFieldPatList, Path }
1466
1467 /// Record literal's field patterns list including enclosing curly braces.
1468 ///
1469 /// ```
1470 /// let foo::Bar ❰ { baz, bind @ bruh, .. } ❱ = bruuh;
1471 /// ``
1472 ///
1473 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1474 struct RecordFieldPatList {
1475 T!['{'],
1476 pats: [RecordInnerPat],
1477 record_field_pats: [RecordFieldPat],
1478 bind_pats: [BindPat],
1479 T![..],
1480 T!['}']
1481 }
1482
1483 /// Record literal's field pattern.
1484 /// Note: record literal can also match tuple structs.
1485 ///
1486 /// ```
1487 /// let Foo { ❰ bar: _ ❱ } = baz;
1488 /// let TupleStruct { ❰ 0: _ ❱ } = bruh;
1489 /// ```
1490 ///
1491 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1492 struct RecordFieldPat: AttrsOwner { NameRef, T![:], Pat }
1493
1494 /// Tuple struct literal pattern.
1495 ///
1496 /// ```
1497 /// let ❰ foo::Bar(baz, bruh) ❱ = bruuh;
1498 /// ```
1499 ///
1500 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-struct-patterns)
1501 struct TupleStructPat { Path, T!['('], args: [Pat], T![')'] }
1502
1503 /// Tuple pattern.
1504 /// Note: this doesn't include tuple structs (see `TupleStructPat`)
1505 ///
1506 /// ```
1507 /// let ❰ (foo, bar, .., baz) ❱ = bruh;
1508 /// ```
1509 ///
1510 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-patterns)
1511 struct TuplePat { T!['('], args: [Pat], T![')'] }
1512
1513 /// Visibility.
1514 ///
1515 /// ```
1516 /// ❰ pub mod ❱ foo;
1517 /// ❰ pub(crate) ❱ struct Bar;
1518 /// ❰ pub(self) ❱ enum Baz {}
1519 /// ❰ pub(super) ❱ fn bruh() {}
1520 /// ❰ pub(in bruuh::bruuuh) ❱ type T = u64;
1521 /// ```
1522 ///
1523 /// [Reference](https://doc.rust-lang.org/reference/visibility-and-privacy.html)
1524 struct Visibility { T![pub], T![super], T![self], T![crate] }
1525
1526 /// Single identifier.
1527 /// Note(@matklad): `Name` is for things that install a new name into the scope,
1528 /// `NameRef` is a usage of a name. Most of the time, this definition/reference
1529 /// distinction can be determined purely syntactically, ie in
1530 /// ```
1531 /// fn foo() { foo() }
1532 /// ```
1533 /// the first foo is `Name`, the second one is `NameRef`.
1534 /// The notable exception are patterns, where in
1535 /// ``
1536 /// let x = 92
1537 /// ```
1538 /// `x` can be semantically either a name or a name ref, depeding on
1539 /// wether there's an `x` constant in scope.
1540 /// We use `Name` for patterns, and disambiguate semantically (see `NameClass` in ide_db).
1541 ///
1542 /// ```
1543 /// let ❰ foo ❱ = bar;
1544 /// struct ❰ Baz ❱;
1545 /// fn ❰ bruh ❱() {}
1546 /// ```
1547 ///
1548 /// [Reference](https://doc.rust-lang.org/reference/identifiers.html)
1549 struct Name { T![ident] }
1550
1551 /// Reference to a name.
1552 /// See the explanation on the difference between `Name` and `NameRef`
1553 /// in `Name` ast node docs.
1554 ///
1555 /// ```
1556 /// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱;
1557 /// ```
1558 ///
1559 /// [Reference](https://doc.rust-lang.org/reference/identifiers.html)
1560 struct NameRef { }
1561
1562 /// Macro call.
1563 /// Includes all of its attributes and doc comments.
1564 ///
1565 /// ```
1566 /// ❰
1567 /// /// Docs
1568 /// #[attr]
1569 /// macro_rules! foo { // macro rules is also a macro call
1570 /// ($bar: tt) => {}
1571 /// }
1572 /// ❱
1573 ///
1574 /// // semicolon is a part of `MacroCall` when it is used in item positions
1575 /// ❰ foo!(); ❱
1576 ///
1577 /// fn main() {
1578 /// ❰ foo!() ❱; // macro call in expression positions doesn't include the semi
1579 /// }
1580 /// ```
1581 ///
1582 /// [Reference](https://doc.rust-lang.org/reference/macros.html)
1583 struct MacroCall: NameOwner, AttrsOwner, DocCommentsOwner {
1584 Path, T![!], TokenTree, T![;]
1585 }
1586
1587 /// Attribute.
1588 ///
1589 /// ```
1590 /// ❰ #![inner_attr] ❱
1591 ///
1592 /// ❰ #[attr] ❱
1593 /// ❰ #[foo = "bar"] ❱
1594 /// ❰ #[baz(bruh::bruuh = "42")] ❱
1595 /// struct Foo;
1596 /// ```
1597 ///
1598 /// [Reference](https://doc.rust-lang.org/reference/attributes.html)
1599 struct Attr { T![#], T![!], T!['['], Path, T![=], input: AttrInput, T![']'] }
1600
1601 /// Stores a list of lexer tokens and other `TokenTree`s.
1602 /// It appears in attributes, macro_rules and macro call (foo!)
1603 ///
1604 /// ```
1605 /// macro_call! ❰ { my syntax here } ❱;
1606 /// ```
1607 ///
1608 /// [Reference](https://doc.rust-lang.org/reference/macros.html)
1609 struct TokenTree {}
1610
1611 /// Generic lifetime, type and constants parameters list **declaration**.
1612 ///
1613 /// ```
1614 /// fn foo❰ <'a, 'b, T, U, const BAR: u64> ❱() {}
1615 ///
1616 /// struct Baz❰ <T> ❱(T);
1617 ///
1618 /// impl❰ <T> ❱ Bruh<T> {}
1619 ///
1620 /// type Bruuh = for❰ <'a> ❱ fn(&'a str) -> &'a str;
1621 /// ```
1622 ///
1623 /// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1624 struct TypeParamList {
1625 T![<],
1626 generic_params: [GenericParam],
1627 type_params: [TypeParam],
1628 lifetime_params: [LifetimeParam],
1629 const_params: [ConstParam],
1630 T![>]
1631 }
1632
1633 /// Single type parameter **declaration**.
1634 ///
1635 /// ```
1636 /// fn foo<❰ K ❱, ❰ I ❱, ❰ E: Debug ❱, ❰ V = DefaultType ❱>() {}
1637 /// ```
1638 ///
1639 /// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1640 struct TypeParam: NameOwner, AttrsOwner, TypeBoundsOwner {
1641 T![=],
1642 default_type: TypeRef,
1643 }
1644
1645 /// Const generic parameter **declaration**.
1646 /// ```
1647 /// fn foo<T, U, ❰ const BAR: usize ❱, ❰ const BAZ: bool ❱>() {}
1648 /// ```
1649 ///
1650 /// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter)
1651 struct ConstParam: NameOwner, AttrsOwner, TypeAscriptionOwner {
1652 T![=],
1653 default_val: Expr,
1654 }
1655
1656 /// Lifetime parameter **declaration**.
1657 ///
1658 /// ```
1659 /// fn foo<❰ 'a ❱, ❰ 'b ❱, V, G, D>(bar: &'a str, baz: &'b mut str) {}
1660 /// ```
1661 ///
1662 /// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1663 struct LifetimeParam: AttrsOwner { T![lifetime] }
1664
1665 /// Type bound declaration clause.
1666 ///
1667 /// ```
1668 /// fn foo<T: ❰ ?Sized ❱ + ❰ Debug ❱>() {}
1669 ///
1670 /// trait Bar<T>
1671 /// where
1672 /// T: ❰ Send ❱ + ❰ Sync ❱
1673 /// {
1674 /// type Baz: ❰ !Sync ❱ + ❰ Debug ❱ + ❰ ?const Add ❱;
1675 /// }
1676 /// ```
1677 ///
1678 /// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
1679 struct TypeBound { T![lifetime], /* Question, */ T![const], /* Question, */ TypeRef }
1680
1681 /// Type bounds list.
1682 ///
1683 /// ```
1684 ///
1685 /// fn foo<T: ❰ ?Sized + Debug ❱>() {}
1686 ///
1687 /// trait Bar<T>
1688 /// where
1689 /// T: ❰ Send + Sync ❱
1690 /// {
1691 /// type Baz: ❰ !Sync + Debug ❱;
1692 /// }
1693 /// ```
1694 ///
1695 /// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
1696 struct TypeBoundList { bounds: [TypeBound] }
1697
1698 /// Single where predicate.
1699 ///
1700 /// ```
1701 /// trait Foo<'a, 'b, T>
1702 /// where
1703 /// ❰ 'a: 'b ❱,
1704 /// ❰ T: IntoIterator ❱,
1705 /// ❰ for<'c> <T as IntoIterator>::Item: Bar<'c> ❱
1706 /// {}
1707 /// ```
1708 ///
1709 /// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
1710 struct WherePred: TypeBoundsOwner { T![for], TypeParamList, T![lifetime], TypeRef }
1711
1712 /// Where clause.
1713 ///
1714 /// ```
1715 /// trait Foo<'a, T> ❰ where 'a: 'static, T: Debug ❱ {}
1716 ///
1717 /// ```
1718 ///
1719 /// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
1720 struct WhereClause { T![where], predicates: [WherePred] }
1721
1722 /// Abi declaration.
1723 /// Note: the abi string is optional.
1724 ///
1725 /// ```
1726 /// ❰ extern "C" ❱ {
1727 /// fn foo() {}
1728 /// }
1729 ///
1730 /// type Bar = ❰ extern ❱ fn() -> u32;
1731 ///
1732 /// type Baz = ❰ extern r#"stdcall"# ❱ fn() -> bool;
1733 /// ```
1734 ///
1735 /// - [Extern blocks reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
1736 /// - [FFI function pointers reference](https://doc.rust-lang.org/reference/items/functions.html#functions)
1737 struct Abi { /*String*/ }
1738
1739 /// Expression statement.
1740 ///
1741 /// ```
1742 /// ❰ 42; ❱
1743 /// ❰ foo(); ❱
1744 /// ❰ (); ❱
1745 /// ❰ {}; ❱
1746 ///
1747 /// // constructions with trailing curly brace can omit the semicolon
1748 /// // but only when there are satements immediately after them (this is important!)
1749 /// ❰ if bool_cond { } ❱
1750 /// ❰ loop {} ❱
1751 /// ❰ somestatment; ❱
1752 /// ```
1753 ///
1754 /// [Reference](https://doc.rust-lang.org/reference/statements.html)
1755 struct ExprStmt: AttrsOwner { Expr, T![;] }
1756
1757 /// Let statement.
1758 ///
1759 /// ```
1760 /// ❰ #[attr] let foo; ❱
1761 /// ❰ let bar: u64; ❱
1762 /// ❰ let baz = 42; ❱
1763 /// ❰ let bruh: bool = true; ❱
1764 /// ```
1765 ///
1766 /// [Reference](https://doc.rust-lang.org/reference/statements.html#let-statements)
1767 struct LetStmt: AttrsOwner, TypeAscriptionOwner {
1768 T![let],
1769 Pat,
1770 T![=],
1771 initializer: Expr,
1772 T![;],
1773 }
1774
1775 /// Condition of `if` or `while` expression.
1776 ///
1777 /// ```
1778 /// if ❰ true ❱ {}
1779 /// if ❰ let Pat(foo) = bar ❱ {}
1780 ///
1781 /// while ❰ true ❱ {}
1782 /// while ❰ let Pat(baz) = bruh ❱ {}
1783 /// ```
1784 ///
1785 /// [If expression reference](https://doc.rust-lang.org/reference/expressions/if-expr.html)
1786 /// [While expression reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops)
1787 struct Condition { T![let], Pat, T![=], Expr }
1788
1789 /// Parameter list **declaration**.
1790 ///
1791 /// ```
1792 /// fn foo❰ (a: u32, b: bool) ❱ -> u32 {}
1793 /// let bar = ❰ |a, b| ❱ {};
1794 ///
1795 /// impl Baz {
1796 /// fn bruh❰ (&self, a: u32) ❱ {}
1797 /// }
1798 /// ```
1799 ///
1800 /// [Reference](https://doc.rust-lang.org/reference/items/functions.html)ocs to codegen script
1801 struct ParamList { // FIXME: this node is used by closure expressions too, but hey use pipes instead of parens...
1802 T!['('],
1803 SelfParam,
1804 params: [Param],
1805 T![')']
1806 }
1807
1808 /// Self parameter **declaration**.
1809 ///
1810 /// ```
1811 /// impl Bruh {
1812 /// fn foo(❰ self ❱) {}
1813 /// fn bar(❰ &self ❱) {}
1814 /// fn baz(❰ &mut self ❱) {}
1815 /// fn blah<'a>(❰ &'a self ❱) {}
1816 /// fn blin(❰ self: Box<Self> ❱) {}
1817 /// }
1818 /// ```
1819 ///
1820 /// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
1821 struct SelfParam: TypeAscriptionOwner, AttrsOwner { T![&], T![mut], T![lifetime], T![self] }
1822
1823 /// Parameter **declaration**.
1824 ///
1825 /// ```
1826 /// fn foo(❰ #[attr] Pat(bar): Pat(u32) ❱, ❰ #[attr] _: bool ❱) {}
1827 ///
1828 /// extern "C" {
1829 /// fn bar(❰ baz: u32 ❱, ❰ ... ❱) -> u32;
1830 /// }
1831 /// ```
1832 ///
1833 /// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
1834 struct Param: TypeAscriptionOwner, AttrsOwner {
1835 Pat,
1836 T![...]
1837 }
1838
1839 /// Use declaration.
1840 ///
1841 /// ```
1842 /// ❰ #[attr] pub use foo; ❱
1843 /// ❰ use bar as baz; ❱
1844 /// ❰ use bruh::{self, bruuh}; ❱
1845 /// ❰ use { blin::blen, blah::* };
1846 /// ```
1847 ///
1848 /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
1849 struct UseItem: AttrsOwner, VisibilityOwner {
1850 T![use],
1851 UseTree,
1852 }
1853
1854 /// Use tree.
1855 ///
1856 /// ```
1857 /// pub use ❰ foo::❰ * ❱ ❱;
1858 /// use ❰ bar as baz ❱;
1859 /// use ❰ bruh::bruuh::{ ❰ self ❱, ❰ blin ❱ } ❱;
1860 /// use ❰ { ❰ blin::blen ❱ } ❱
1861 /// ```
1862 ///
1863 /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
1864 struct UseTree {
1865 Path, T![*], UseTreeList, Alias
1866 }
1867
1868 /// Item alias.
1869 /// Note: this is not the type alias.
1870 ///
1871 /// ```
1872 /// use foo ❰ as bar ❱;
1873 /// use baz::{bruh ❰ as _ ❱};
1874 /// extern crate bruuh ❰ as blin ❱;
1875 /// ```
1876 ///
1877 /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
1878 struct Alias: NameOwner { T![as] }
1879
1880 /// Sublist of use trees.
1881 ///
1882 /// ```
1883 /// use bruh::bruuh::❰ { ❰ self ❱, ❰ blin ❱ } ❱;
1884 /// use ❰ { blin::blen::❰ {} ❱ } ❱
1885 /// ```
1886 ///
1887 /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
1888 struct UseTreeList { T!['{'], use_trees: [UseTree], T!['}'] }
1889
1890 /// Extern crate item.
1891 ///
1892 /// ```
1893 /// ❰ #[attr] pub extern crate foo; ❱
1894 /// ❰ extern crate self as bar; ❱
1895 /// ```
1896 ///
1897 /// [Reference](https://doc.rust-lang.org/reference/items/extern-crates.html)
1898 struct ExternCrateItem: AttrsOwner, VisibilityOwner {
1899 T![extern], T![crate], NameRef, Alias,
1900 }
1901
1902 /// Call site arguments list.
1903 ///
1904 /// ```
1905 /// foo::<T, U>❰ (42, true) ❱;
1906 /// ```
1907 ///
1908 /// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html)
1909 struct ArgList {
1910 T!['('],
1911 args: [Expr],
1912 T![')']
1913 }
1914
1915 /// Path to a symbol. Includes single identifier names and elaborate paths with
1916 /// generic parameters.
1917 ///
1918 /// ```
1919 /// (0..10).❰ ❰ collect ❱ ::<Vec<_>> ❱();
1920 /// ❰ ❰ ❰ Vec ❱ ::<u8> ❱ ::with_capacity ❱(1024);
1921 /// ❰ ❰ <❰ Foo ❱ as ❰ ❰ bar ❱ ::Bar ❱> ❱ ::baz ❱();
1922 /// ❰ ❰ <❰ bruh ❱> ❱ ::bruuh ❱();
1923 /// ```
1924 ///
1925 /// [Reference](https://doc.rust-lang.org/reference/paths.html)
1926 struct Path {
1927 segment: PathSegment,
1928 T![::],
1929 qualifier: Path,
1930 }
1931
1932 /// Segment of the path to a symbol.
1933 /// Only path segment of an absolute path holds the `::` token,
1934 /// all other `::` tokens that connect path segments reside under `Path` itself.`
1935 ///
1936 /// ```
1937 /// (0..10).❰ collect ❱ :: ❰ <Vec<_>> ❱();
1938 /// ❰ Vec ❱ :: ❰ <u8> ❱ :: ❰ with_capacity ❱(1024);
1939 /// ❰ <❰ Foo ❱ as ❰ bar ❱ :: ❰ Bar ❱> ❱ :: ❰ baz ❱();
1940 /// ❰ <❰ bruh ❱> ❱ :: ❰ bruuh ❱();
1941 ///
1942 /// // Note that only in this case `::` token is inlcuded:
1943 /// ❰ ::foo ❱;
1944 /// ```
1945 ///
1946 /// [Reference](https://doc.rust-lang.org/reference/paths.html)
1947 struct PathSegment {
1948 T![::], T![crate], T![self], T![super], T![<], NameRef, TypeArgList, ParamList, RetType, PathType, T![>]
1949 }
1950
1951 /// List of type arguments that are passed at generic instantiation site.
1952 ///
1953 /// ```
1954 /// type _ = Foo ❰ ::<'a, u64, Item = Bar, 42, {true}> ❱::Bar;
1955 ///
1956 /// Vec❰ ::<bool> ❱::();
1957 /// ```
1958 ///
1959 /// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
1960 struct TypeArgList {
1961 T![::],
1962 T![<],
1963 generic_args: [GenericArg],
1964 type_args: [TypeArg],
1965 lifetime_args: [LifetimeArg],
1966 assoc_type_args: [AssocTypeArg],
1967 const_args: [ConstArg],
1968 T![>]
1969 }
1970
1971 /// Type argument that is passed at generic instantiation site.
1972 ///
1973 /// ```
1974 /// type _ = Foo::<'a, ❰ u64 ❱, ❰ bool ❱, Item = Bar, 42>::Baz;
1975 /// ```
1976 ///
1977 /// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
1978 struct TypeArg { TypeRef }
1979
1980 /// Associated type argument that is passed at generic instantiation site.
1981 /// ```
1982 /// type Foo = Bar::<'a, u64, bool, ❰ Item = Baz ❱, 42>::Bruh;
1983 ///
1984 /// trait Bruh<T>: Iterator<❰ Item: Debug ❱> {}
1985 /// ```
1986 ///
1987 struct AssocTypeArg : TypeBoundsOwner { NameRef, T![=], TypeRef }
1988
1989 /// Lifetime argument that is passed at generic instantiation site.
1990 ///
1991 /// ```
1992 /// fn foo<'a>(s: &'a str) {
1993 /// bar::<❰ 'a ❱>(s);
1994 /// }
1995 /// ```
1996 ///
1997 /// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
1998 struct LifetimeArg { T![lifetime] }
1999
2000 /// Constant value argument that is passed at generic instantiation site.
2001 ///
2002 /// ```
2003 /// foo::<u32, ❰ { true } ❱>();
2004 ///
2005 /// bar::<❰ { 2 + 2} ❱>();
2006 /// ```
2007 ///
2008 /// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter)
2009 struct ConstArg { Literal, BlockExpr }
2010
2011
2012 /// FIXME: (@edwin0cheng) Remove it to use ItemList instead
2013 /// https://github.com/rust-analyzer/rust-analyzer/pull/4083#discussion_r422666243
2014 ///
2015 /// [Reference](https://doc.rust-lang.org/reference/macros.html)
2016 struct MacroItems: ModuleItemOwner { }
2017
2018 /// FIXME: (@edwin0cheng) add some documentation here. As per the writing
2019 /// of this comment this ast node is not used.
2020 ///
2021 /// ```
2022 /// // FIXME: example here
2023 /// ```
2024 ///
2025 /// [Reference](https://doc.rust-lang.org/reference/macros.html)
2026 struct MacroStmts {
2027 statements: [Stmt],
2028 Expr,
2029 }
2030
2031 /// List of items in an extern block.
2032 ///
2033 /// ```
2034 /// extern "C" ❰
2035 /// {
2036 /// fn foo();
2037 /// static var: u32;
2038 /// }
2039 /// ❱
2040 /// ```
2041 ///
2042 /// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2043 struct ExternItemList: ModuleItemOwner {
2044 T!['{'],
2045 extern_items: [ExternItem],
2046 T!['}']
2047 }
2048
2049 /// Extern block.
2050 ///
2051 /// ```
2052 /// ❰
2053 /// extern "C" {
2054 /// fn foo();
2055 /// }
2056 /// ❱
2057 ///
2058 /// ```
2059 ///
2060 /// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2061 struct ExternBlock {
2062 Abi,
2063 ExternItemList
2064 }
2065
2066 /// Meta item in an attribute.
2067 ///
2068 /// ```
2069 /// #[❰ bar::baz = "42" ❱]
2070 /// #[❰ bruh(bruuh("true")) ❱]
2071 /// struct Foo;
2072 /// ```
2073 ///
2074 /// [Reference](https://doc.rust-lang.org/reference/attributes.html?highlight=meta,item#meta-item-attribute-syntax)
2075 struct MetaItem {
2076 Path, T![=], AttrInput, nested_meta_items: [MetaItem]
2077 }
2078
2079 /// Macro 2.0 definition.
2080 /// Their syntax is still WIP by rustc team...
2081 /// ```
2082 /// ❰
2083 /// macro foo { }
2084 /// ❱
2085 /// ```
2086 ///
2087 /// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/1584-macros.md)
2088 struct MacroDef {
2089 Name, TokenTree
2090 }
2091 },
2092 enums: &ast_enums! {
2093 /// Any kind of nominal type definition.
2094 enum NominalDef: NameOwner, TypeParamsOwner, AttrsOwner {
2095 StructDef, EnumDef, UnionDef,
2096 }
2097
2098 /// Any kind of **declared** generic parameter
2099 enum GenericParam {
2100 LifetimeParam,
2101 TypeParam,
2102 ConstParam
2103 }
2104
2105 /// Any kind of generic argument passed at instantiation site
2106 enum GenericArg {
2107 LifetimeArg,
2108 TypeArg,
2109 ConstArg,
2110 AssocTypeArg
2111 }
2112
2113 /// Any kind of construct valid in type context
2114 enum TypeRef {
2115 ParenType,
2116 TupleType,
2117 NeverType,
2118 PathType,
2119 PointerType,
2120 ArrayType,
2121 SliceType,
2122 ReferenceType,
2123 PlaceholderType,
2124 FnPointerType,
2125 ForType,
2126 ImplTraitType,
2127 DynTraitType,
2128 }
2129
2130 /// Any kind of top-level item that may appear in a module
2131 enum ModuleItem: NameOwner, AttrsOwner, VisibilityOwner {
2132 StructDef,
2133 UnionDef,
2134 EnumDef,
2135 FnDef,
2136 TraitDef,
2137 TypeAliasDef,
2138 ImplDef,
2139 UseItem,
2140 ExternCrateItem,
2141 ConstDef,
2142 StaticDef,
2143 Module,
2144 MacroCall,
2145 ExternBlock
2146 }
2147
2148
2149
2150 /// Any kind of item that may appear in an impl block
2151 ///
2152 /// // FIXME: impl blocks can also contain MacroCall
2153 enum AssocItem: NameOwner, AttrsOwner {
2154 FnDef, TypeAliasDef, ConstDef
2155 }
2156
2157 /// Any kind of item that may appear in an extern block
2158 ///
2159 /// // FIXME: extern blocks can also contain MacroCall
2160 enum ExternItem: NameOwner, AttrsOwner, VisibilityOwner {
2161 FnDef, StaticDef
2162 }
2163
2164 /// Any kind of expression
2165 enum Expr: AttrsOwner {
2166 TupleExpr,
2167 ArrayExpr,
2168 ParenExpr,
2169 PathExpr,
2170 LambdaExpr,
2171 IfExpr,
2172 LoopExpr,
2173 ForExpr,
2174 WhileExpr,
2175 ContinueExpr,
2176 BreakExpr,
2177 Label,
2178 BlockExpr,
2179 ReturnExpr,
2180 MatchExpr,
2181 RecordLit,
2182 CallExpr,
2183 IndexExpr,
2184 MethodCallExpr,
2185 FieldExpr,
2186 AwaitExpr,
2187 TryExpr,
2188 EffectExpr,
2189 CastExpr,
2190 RefExpr,
2191 PrefixExpr,
2192 RangeExpr,
2193 BinExpr,
2194 Literal,
2195 MacroCall,
2196 BoxExpr,
2197 }
2198
2199 /// Any kind of pattern
2200 enum Pat {
2201 OrPat,
2202 ParenPat,
2203 RefPat,
2204 BoxPat,
2205 BindPat,
2206 PlaceholderPat,
2207 DotDotPat,
2208 PathPat,
2209 RecordPat,
2210 TupleStructPat,
2211 TuplePat,
2212 SlicePat,
2213 RangePat,
2214 LiteralPat,
2215 MacroPat,
2216 }
2217
2218 /// Any kind of pattern that appears directly inside of the curly
2219 /// braces of a record pattern
2220 enum RecordInnerPat {
2221 RecordFieldPat,
2222 BindPat
2223 }
2224
2225 /// Any kind of input to an attribute
2226 enum AttrInput { Literal, TokenTree }
2227
2228 /// Any kind of statement
2229 /// Note: there are no empty statements, these are just represented as
2230 /// bare semicolons without a dedicated statement ast node.
2231 enum Stmt {
2232 LetStmt,
2233 ExprStmt,
2234 // macro calls are parsed as expression statements
2235 }
2236
2237 /// Any kind of fields list (record or tuple field lists)
2238 enum FieldDefList {
2239 RecordFieldDefList,
2240 TupleFieldDefList,
2241 }
2242 },
2243};
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs
index 745a25862..cafad8070 100644
--- a/xtask/src/codegen/gen_syntax.rs
+++ b/xtask/src/codegen/gen_syntax.rs
@@ -3,34 +3,41 @@
3//! Specifically, it generates the `SyntaxKind` enum and a number of newtype 3//! Specifically, it generates the `SyntaxKind` enum and a number of newtype
4//! wrappers around `SyntaxNode` which implement `ra_syntax::AstNode`. 4//! wrappers around `SyntaxNode` which implement `ra_syntax::AstNode`.
5 5
6use std::{collections::HashSet, fmt::Write}; 6use std::{
7 collections::{BTreeSet, HashSet},
8 fmt::Write,
9};
7 10
8use proc_macro2::{Punct, Spacing}; 11use proc_macro2::{Punct, Spacing};
9use quote::{format_ident, quote}; 12use quote::{format_ident, quote};
13use ungrammar::{rust_grammar, Grammar, Rule};
10 14
11use crate::{ 15use crate::{
12 ast_src::{AstSrc, Field, FieldSrc, KindsSrc, AST_SRC, KINDS_SRC}, 16 ast_src::{AstEnumSrc, AstNodeSrc, AstSrc, Cardinality, Field, KindsSrc, KINDS_SRC},
13 codegen::{self, update, Mode}, 17 codegen::{self, update, Mode},
14 project_root, Result, 18 project_root, Result,
15}; 19};
16 20
17pub fn generate_syntax(mode: Mode) -> Result<()> { 21pub fn generate_syntax(mode: Mode) -> Result<()> {
22 let grammar = rust_grammar();
23 let ast = lower(&grammar);
24
18 let syntax_kinds_file = project_root().join(codegen::SYNTAX_KINDS); 25 let syntax_kinds_file = project_root().join(codegen::SYNTAX_KINDS);
19 let syntax_kinds = generate_syntax_kinds(KINDS_SRC)?; 26 let syntax_kinds = generate_syntax_kinds(KINDS_SRC)?;
20 update(syntax_kinds_file.as_path(), &syntax_kinds, mode)?; 27 update(syntax_kinds_file.as_path(), &syntax_kinds, mode)?;
21 28
22 let ast_tokens_file = project_root().join(codegen::AST_TOKENS); 29 let ast_tokens_file = project_root().join(codegen::AST_TOKENS);
23 let contents = generate_tokens(AST_SRC)?; 30 let contents = generate_tokens(&ast)?;
24 update(ast_tokens_file.as_path(), &contents, mode)?; 31 update(ast_tokens_file.as_path(), &contents, mode)?;
25 32
26 let ast_nodes_file = project_root().join(codegen::AST_NODES); 33 let ast_nodes_file = project_root().join(codegen::AST_NODES);
27 let contents = generate_nodes(KINDS_SRC, AST_SRC)?; 34 let contents = generate_nodes(KINDS_SRC, &ast)?;
28 update(ast_nodes_file.as_path(), &contents, mode)?; 35 update(ast_nodes_file.as_path(), &contents, mode)?;
29 36
30 Ok(()) 37 Ok(())
31} 38}
32 39
33fn generate_tokens(grammar: AstSrc<'_>) -> Result<String> { 40fn generate_tokens(grammar: &AstSrc) -> Result<String> {
34 let tokens = grammar.tokens.iter().map(|token| { 41 let tokens = grammar.tokens.iter().map(|token| {
35 let name = format_ident!("{}", token); 42 let name = format_ident!("{}", token);
36 let kind = format_ident!("{}", to_upper_snake_case(token)); 43 let kind = format_ident!("{}", to_upper_snake_case(token));
@@ -62,13 +69,13 @@ fn generate_tokens(grammar: AstSrc<'_>) -> Result<String> {
62 Ok(pretty) 69 Ok(pretty)
63} 70}
64 71
65fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> { 72fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> Result<String> {
66 let (node_defs, node_boilerplate_impls): (Vec<_>, Vec<_>) = grammar 73 let (node_defs, node_boilerplate_impls): (Vec<_>, Vec<_>) = grammar
67 .nodes 74 .nodes
68 .iter() 75 .iter()
69 .map(|node| { 76 .map(|node| {
70 let name = format_ident!("{}", node.name); 77 let name = format_ident!("{}", node.name);
71 let kind = format_ident!("{}", to_upper_snake_case(node.name)); 78 let kind = format_ident!("{}", to_upper_snake_case(&node.name));
72 let traits = node.traits.iter().map(|trait_name| { 79 let traits = node.traits.iter().map(|trait_name| {
73 let trait_name = format_ident!("{}", trait_name); 80 let trait_name = format_ident!("{}", trait_name);
74 quote!(impl ast::#trait_name for #name {}) 81 quote!(impl ast::#trait_name for #name {})
@@ -144,25 +151,10 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
144 quote!(impl ast::#trait_name for #name {}) 151 quote!(impl ast::#trait_name for #name {})
145 }); 152 });
146 153
147 ( 154 let ast_node = if en.name == "Stmt" {
148 quote! { 155 quote! {}
149 #[pretty_doc_comment_placeholder_workaround] 156 } else {
150 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
151 pub enum #name {
152 #(#variants(#variants),)*
153 }
154
155 #(#traits)*
156 },
157 quote! { 157 quote! {
158 #(
159 impl From<#variants> for #name {
160 fn from(node: #variants) -> #name {
161 #name::#variants(node)
162 }
163 }
164 )*
165
166 impl AstNode for #name { 158 impl AstNode for #name {
167 fn can_cast(kind: SyntaxKind) -> bool { 159 fn can_cast(kind: SyntaxKind) -> bool {
168 match kind { 160 match kind {
@@ -187,13 +179,35 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
187 } 179 }
188 } 180 }
189 } 181 }
182 }
183 };
184
185 (
186 quote! {
187 #[pretty_doc_comment_placeholder_workaround]
188 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
189 pub enum #name {
190 #(#variants(#variants),)*
191 }
192
193 #(#traits)*
194 },
195 quote! {
196 #(
197 impl From<#variants> for #name {
198 fn from(node: #variants) -> #name {
199 #name::#variants(node)
200 }
201 }
202 )*
203 #ast_node
190 }, 204 },
191 ) 205 )
192 }) 206 })
193 .unzip(); 207 .unzip();
194 208
195 let enum_names = grammar.enums.iter().map(|it| it.name); 209 let enum_names = grammar.enums.iter().map(|it| &it.name);
196 let node_names = grammar.nodes.iter().map(|it| it.name); 210 let node_names = grammar.nodes.iter().map(|it| &it.name);
197 211
198 let display_impls = 212 let display_impls =
199 enum_names.chain(node_names.clone()).map(|it| format_ident!("{}", it)).map(|name| { 213 enum_names.chain(node_names.clone()).map(|it| format_ident!("{}", it)).map(|name| {
@@ -212,9 +226,11 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
212 .nodes 226 .nodes
213 .iter() 227 .iter()
214 .map(|kind| to_pascal_case(kind)) 228 .map(|kind| to_pascal_case(kind))
215 .filter(|name| !defined_nodes.contains(name.as_str())) 229 .filter(|name| !defined_nodes.iter().any(|&it| it == name))
216 { 230 {
217 eprintln!("Warning: node {} not defined in ast source", node); 231 drop(node)
232 // TODO: restore this
233 // eprintln!("Warning: node {} not defined in ast source", node);
218 } 234 }
219 235
220 let ast = quote! { 236 let ast = quote! {
@@ -236,12 +252,12 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
236 let mut res = String::with_capacity(ast.len() * 2); 252 let mut res = String::with_capacity(ast.len() * 2);
237 253
238 let mut docs = 254 let mut docs =
239 grammar.nodes.iter().map(|it| it.doc).chain(grammar.enums.iter().map(|it| it.doc)); 255 grammar.nodes.iter().map(|it| &it.doc).chain(grammar.enums.iter().map(|it| &it.doc));
240 256
241 for chunk in ast.split("# [ pretty_doc_comment_placeholder_workaround ]") { 257 for chunk in ast.split("# [ pretty_doc_comment_placeholder_workaround ]") {
242 res.push_str(chunk); 258 res.push_str(chunk);
243 if let Some(doc) = docs.next() { 259 if let Some(doc) = docs.next() {
244 write_doc_comment(doc, &mut res); 260 write_doc_comment(&doc, &mut res);
245 } 261 }
246 } 262 }
247 263
@@ -249,7 +265,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
249 Ok(pretty) 265 Ok(pretty)
250} 266}
251 267
252fn write_doc_comment(contents: &[&str], dest: &mut String) { 268fn write_doc_comment(contents: &[String], dest: &mut String) {
253 for line in contents { 269 for line in contents {
254 writeln!(dest, "///{}", line).unwrap(); 270 writeln!(dest, "///{}", line).unwrap();
255 } 271 }
@@ -296,7 +312,7 @@ fn generate_syntax_kinds(grammar: KindsSrc<'_>) -> Result<String> {
296 312
297 let ast = quote! { 313 let ast = quote! {
298 #![allow(bad_style, missing_docs, unreachable_pub)] 314 #![allow(bad_style, missing_docs, unreachable_pub)]
299 /// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. 315 /// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT`.
300 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] 316 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
301 #[repr(u16)] 317 #[repr(u16)]
302 pub enum SyntaxKind { 318 pub enum SyntaxKind {
@@ -363,6 +379,7 @@ fn generate_syntax_kinds(grammar: KindsSrc<'_>) -> Result<String> {
363 #([#all_keywords_idents] => { $crate::SyntaxKind::#all_keywords };)* 379 #([#all_keywords_idents] => { $crate::SyntaxKind::#all_keywords };)*
364 [lifetime] => { $crate::SyntaxKind::LIFETIME }; 380 [lifetime] => { $crate::SyntaxKind::LIFETIME };
365 [ident] => { $crate::SyntaxKind::IDENT }; 381 [ident] => { $crate::SyntaxKind::IDENT };
382 [shebang] => { $crate::SyntaxKind::SHEBANG };
366 } 383 }
367 }; 384 };
368 385
@@ -413,9 +430,13 @@ fn to_pascal_case(s: &str) -> String {
413 buf 430 buf
414} 431}
415 432
416impl Field<'_> { 433fn pluralize(s: &str) -> String {
434 format!("{}s", s)
435}
436
437impl Field {
417 fn is_many(&self) -> bool { 438 fn is_many(&self) -> bool {
418 matches!(self, Field::Node { src: FieldSrc::Many(_), .. }) 439 matches!(self, Field::Node { cardinality: Cardinality::Many, .. })
419 } 440 }
420 fn token_kind(&self) -> Option<proc_macro2::TokenStream> { 441 fn token_kind(&self) -> Option<proc_macro2::TokenStream> {
421 match self { 442 match self {
@@ -429,7 +450,7 @@ impl Field<'_> {
429 fn method_name(&self) -> proc_macro2::Ident { 450 fn method_name(&self) -> proc_macro2::Ident {
430 match self { 451 match self {
431 Field::Token(name) => { 452 Field::Token(name) => {
432 let name = match *name { 453 let name = match name.as_str() {
433 ";" => "semicolon", 454 ";" => "semicolon",
434 "->" => "thin_arrow", 455 "->" => "thin_arrow",
435 "'{'" => "l_curly", 456 "'{'" => "l_curly",
@@ -448,29 +469,273 @@ impl Field<'_> {
448 "." => "dot", 469 "." => "dot",
449 ".." => "dotdot", 470 ".." => "dotdot",
450 "..." => "dotdotdot", 471 "..." => "dotdotdot",
472 "..=" => "dotdoteq",
451 "=>" => "fat_arrow", 473 "=>" => "fat_arrow",
452 "@" => "at", 474 "@" => "at",
453 ":" => "colon", 475 ":" => "colon",
454 "::" => "coloncolon", 476 "::" => "coloncolon",
455 "#" => "pound", 477 "#" => "pound",
456 "?" => "question_mark", 478 "?" => "question_mark",
479 "," => "comma",
457 _ => name, 480 _ => name,
458 }; 481 };
459 format_ident!("{}_token", name) 482 format_ident!("{}_token", name)
460 } 483 }
461 Field::Node { name, src } => match src { 484 Field::Node { name, .. } => {
462 FieldSrc::Shorthand => format_ident!("{}", to_lower_snake_case(name)), 485 if name == "type" {
463 _ => format_ident!("{}", name), 486 format_ident!("ty")
464 }, 487 } else {
488 format_ident!("{}", name)
489 }
490 }
465 } 491 }
466 } 492 }
467 fn ty(&self) -> proc_macro2::Ident { 493 fn ty(&self) -> proc_macro2::Ident {
468 match self { 494 match self {
469 Field::Token(_) => format_ident!("SyntaxToken"), 495 Field::Token(_) => format_ident!("SyntaxToken"),
470 Field::Node { name, src } => match src { 496 Field::Node { ty, .. } => format_ident!("{}", ty),
471 FieldSrc::Optional(ty) | FieldSrc::Many(ty) => format_ident!("{}", ty),
472 FieldSrc::Shorthand => format_ident!("{}", name),
473 },
474 } 497 }
475 } 498 }
476} 499}
500
501fn lower(grammar: &Grammar) -> AstSrc {
502 let mut res = AstSrc::default();
503 res.tokens = vec!["Whitespace".into(), "Comment".into(), "String".into(), "RawString".into()];
504
505 let nodes = grammar.iter().collect::<Vec<_>>();
506
507 for &node in &nodes {
508 let name = grammar[node].name.clone();
509 let rule = &grammar[node].rule;
510 match lower_enum(grammar, rule) {
511 Some(variants) => {
512 let enum_src = AstEnumSrc { doc: Vec::new(), name, traits: Vec::new(), variants };
513 res.enums.push(enum_src);
514 }
515 None => {
516 let mut fields = Vec::new();
517 lower_rule(&mut fields, grammar, None, rule);
518 res.nodes.push(AstNodeSrc { doc: Vec::new(), name, traits: Vec::new(), fields });
519 }
520 }
521 }
522
523 deduplicate_fields(&mut res);
524 extract_enums(&mut res);
525 extract_struct_traits(&mut res);
526 extract_enum_traits(&mut res);
527 res
528}
529
530fn lower_enum(grammar: &Grammar, rule: &Rule) -> Option<Vec<String>> {
531 let alternatives = match rule {
532 Rule::Alt(it) => it,
533 _ => return None,
534 };
535 let mut variants = Vec::new();
536 for alternative in alternatives {
537 match alternative {
538 Rule::Node(it) => variants.push(grammar[*it].name.clone()),
539 Rule::Token(it) if grammar[*it].name == ";" => (),
540 _ => return None,
541 }
542 }
543 Some(variants)
544}
545
546fn lower_rule(acc: &mut Vec<Field>, grammar: &Grammar, label: Option<&String>, rule: &Rule) {
547 if lower_comma_list(acc, grammar, label, rule) {
548 return;
549 }
550
551 match rule {
552 Rule::Node(node) => {
553 let ty = grammar[*node].name.clone();
554 let name = label.cloned().unwrap_or_else(|| to_lower_snake_case(&ty));
555 let field = Field::Node { name, ty, cardinality: Cardinality::Optional };
556 acc.push(field);
557 }
558 Rule::Token(token) => {
559 assert!(label.is_none());
560 let mut name = grammar[*token].name.clone();
561 if name != "int_number" && name != "string" {
562 if "[]{}()".contains(&name) {
563 name = format!("'{}'", name);
564 }
565 let field = Field::Token(name);
566 acc.push(field);
567 }
568 }
569 Rule::Rep(inner) => {
570 if let Rule::Node(node) = &**inner {
571 let ty = grammar[*node].name.clone();
572 let name = label.cloned().unwrap_or_else(|| pluralize(&to_lower_snake_case(&ty)));
573 let field = Field::Node { name, ty, cardinality: Cardinality::Many };
574 acc.push(field);
575 return;
576 }
577 todo!("{:?}", rule)
578 }
579 Rule::Labeled { label: l, rule } => {
580 assert!(label.is_none());
581 let manually_implemented = matches!(
582 l.as_str(),
583 "lhs"
584 | "rhs"
585 | "then_branch"
586 | "else_branch"
587 | "start"
588 | "end"
589 | "op"
590 | "index"
591 | "base"
592 | "value"
593 | "trait"
594 | "self_ty"
595 );
596 if manually_implemented {
597 return;
598 }
599 lower_rule(acc, grammar, Some(l), rule);
600 }
601 Rule::Seq(rules) | Rule::Alt(rules) => {
602 for rule in rules {
603 lower_rule(acc, grammar, label, rule)
604 }
605 }
606 Rule::Opt(rule) => lower_rule(acc, grammar, label, rule),
607 }
608}
609
610// (T (',' T)* ','?)
611fn lower_comma_list(
612 acc: &mut Vec<Field>,
613 grammar: &Grammar,
614 label: Option<&String>,
615 rule: &Rule,
616) -> bool {
617 let rule = match rule {
618 Rule::Seq(it) => it,
619 _ => return false,
620 };
621 let (node, repeat, trailing_comma) = match rule.as_slice() {
622 [Rule::Node(node), Rule::Rep(repeat), Rule::Opt(trailing_comma)] => {
623 (node, repeat, trailing_comma)
624 }
625 _ => return false,
626 };
627 let repeat = match &**repeat {
628 Rule::Seq(it) => it,
629 _ => return false,
630 };
631 match repeat.as_slice() {
632 [comma, Rule::Node(n)] if comma == &**trailing_comma && n == node => (),
633 _ => return false,
634 }
635 let ty = grammar[*node].name.clone();
636 let name = label.cloned().unwrap_or_else(|| pluralize(&to_lower_snake_case(&ty)));
637 let field = Field::Node { name, ty, cardinality: Cardinality::Many };
638 acc.push(field);
639 true
640}
641
642fn deduplicate_fields(ast: &mut AstSrc) {
643 for node in &mut ast.nodes {
644 let mut i = 0;
645 'outer: while i < node.fields.len() {
646 for j in 0..i {
647 let f1 = &node.fields[i];
648 let f2 = &node.fields[j];
649 if f1 == f2 {
650 node.fields.remove(i);
651 continue 'outer;
652 }
653 }
654 i += 1;
655 }
656 }
657}
658
659fn extract_enums(ast: &mut AstSrc) {
660 for node in &mut ast.nodes {
661 for enm in &ast.enums {
662 let mut to_remove = Vec::new();
663 for (i, field) in node.fields.iter().enumerate() {
664 let ty = field.ty().to_string();
665 if enm.variants.iter().any(|it| it == &ty) {
666 to_remove.push(i);
667 }
668 }
669 if to_remove.len() == enm.variants.len() {
670 node.remove_field(to_remove);
671 let ty = enm.name.clone();
672 let name = to_lower_snake_case(&ty);
673 node.fields.push(Field::Node { name, ty, cardinality: Cardinality::Optional });
674 }
675 }
676 }
677}
678
679fn extract_struct_traits(ast: &mut AstSrc) {
680 let traits: &[(&str, &[&str])] = &[
681 ("AttrsOwner", &["attrs"]),
682 ("NameOwner", &["name"]),
683 ("VisibilityOwner", &["visibility"]),
684 ("GenericParamsOwner", &["generic_param_list", "where_clause"]),
685 ("TypeBoundsOwner", &["type_bound_list", "colon_token"]),
686 ("ModuleItemOwner", &["items"]),
687 ("LoopBodyOwner", &["label", "loop_body"]),
688 ("ArgListOwner", &["arg_list"]),
689 ];
690
691 for node in &mut ast.nodes {
692 for (name, methods) in traits {
693 extract_struct_trait(node, name, methods);
694 }
695 }
696}
697
698fn extract_struct_trait(node: &mut AstNodeSrc, trait_name: &str, methods: &[&str]) {
699 let mut to_remove = Vec::new();
700 for (i, field) in node.fields.iter().enumerate() {
701 let method_name = field.method_name().to_string();
702 if methods.iter().any(|&it| it == &method_name) {
703 to_remove.push(i);
704 }
705 }
706 if to_remove.len() == methods.len() {
707 node.traits.push(trait_name.to_string());
708 node.remove_field(to_remove);
709 }
710}
711
712fn extract_enum_traits(ast: &mut AstSrc) {
713 for enm in &mut ast.enums {
714 if enm.name == "Stmt" {
715 continue;
716 }
717 let nodes = &ast.nodes;
718 let mut variant_traits = enm
719 .variants
720 .iter()
721 .map(|var| nodes.iter().find(|it| &it.name == var).unwrap())
722 .map(|node| node.traits.iter().cloned().collect::<BTreeSet<_>>());
723
724 let mut enum_traits = match variant_traits.next() {
725 Some(it) => it,
726 None => continue,
727 };
728 for traits in variant_traits {
729 enum_traits = enum_traits.intersection(&traits).cloned().collect();
730 }
731 enm.traits = enum_traits.into_iter().collect();
732 }
733}
734
735impl AstNodeSrc {
736 fn remove_field(&mut self, to_remove: Vec<usize>) {
737 to_remove.into_iter().rev().for_each(|idx| {
738 self.fields.remove(idx);
739 });
740 }
741}
diff --git a/xtask/src/codegen/gen_unstable_future_descriptor.rs b/xtask/src/codegen/gen_unstable_future_descriptor.rs
index 09c4f61f2..298696fbb 100644
--- a/xtask/src/codegen/gen_unstable_future_descriptor.rs
+++ b/xtask/src/codegen/gen_unstable_future_descriptor.rs
@@ -42,7 +42,7 @@ pub fn generate_unstable_future_descriptor(mode: Mode) -> Result<()> {
42 let ts = quote! { 42 let ts = quote! {
43 use crate::completion::LintCompletion; 43 use crate::completion::LintCompletion;
44 44
45 const UNSTABLE_FEATURE_DESCRIPTOR: &[LintCompletion] = &[ 45 pub const UNSTABLE_FEATURE_DESCRIPTOR: &[LintCompletion] = &[
46 #(#definitions),* 46 #(#definitions),*
47 ]; 47 ];
48 }; 48 };
diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram
new file mode 100644
index 000000000..aca23890c
--- /dev/null
+++ b/xtask/src/codegen/rust.ungram
@@ -0,0 +1,587 @@
1//*************************//
2// Names, Paths and Macros //
3//*************************//
4
5Name =
6 'ident'
7
8NameRef =
9 'ident' | 'int_number'
10
11Path =
12 (qualifier:Path '::')? segment:PathSegment
13
14PathSegment =
15 'crate' | 'self' | 'super'
16| '::' NameRef
17| NameRef GenericArgList?
18| NameRef ParamList RetType?
19| '<' PathType ('as' PathType)? '>'
20
21GenericArgList =
22 '::'? '<' (GenericArg (',' GenericArg)* ','?)? '>'
23
24GenericArg =
25 TypeArg
26| AssocTypeArg
27| LifetimeArg
28| ConstArg
29
30TypeArg =
31 Type
32
33AssocTypeArg =
34 NameRef (':' TypeBoundList | '=' Type)
35
36LifetimeArg =
37 'lifetime'
38
39ConstArg =
40 Expr
41
42MacroCall =
43 Attr* Path '!' Name? TokenTree ';'?
44
45TokenTree =
46 '(' ')'
47| '{' '}'
48| '[' ']'
49
50MacroItems =
51 Item*
52
53MacroStmts =
54 statements:Stmt*
55 Expr?
56
57//*************************//
58// Items //
59//*************************//
60
61SourceFile =
62 'shebang'?
63 Attr*
64 Item*
65
66Item =
67 Const
68| Enum
69| ExternBlock
70| ExternCrate
71| Fn
72| Impl
73| MacroCall
74| Module
75| Static
76| Struct
77| Trait
78| TypeAlias
79| Union
80| Use
81
82Module =
83 Attr* Visibility? 'mod' Name
84 (ItemList | ';')
85
86ItemList =
87 '{' Attr* Item* '}'
88
89ExternCrate =
90 Attr* Visibility? 'extern' 'crate' (NameRef | 'self') Rename? ';'
91
92Rename =
93 'as' (Name | '_')
94
95Use =
96 Attr* Visibility? 'use' UseTree ';'
97
98UseTree =
99 (Path? '::')? ('*' | UseTreeList )
100| Path Rename?
101
102UseTreeList =
103 '{' (UseTree (',' UseTree)* ','?)? '}'
104
105Fn =
106 Attr* Visibility?
107 'default'? ('async' | 'const')? 'unsafe'? Abi?
108 'fn' Name GenericParamList? ParamList RetType?
109 WhereClause?
110 (body:BlockExpr | ';')
111
112Abi =
113 'extern' 'string'?
114
115ParamList =
116 '('(
117 SelfParam
118 | (SelfParam ',')? (Param (',' Param)* ','?)?
119 )')'
120
121SelfParam =
122 Attr* (
123 ('&' 'lifetime'?)? 'mut'? 'self'
124 | 'mut'? 'self' ':' Type
125 )
126
127Param =
128 Attr* (
129 Pat (':' Type)
130 | Type
131 | '...'
132 )
133
134RetType =
135 '->' Type
136
137TypeAlias =
138 Attr* Visibility? 'default'? 'type' Name GenericParamList? (':' TypeBoundList?)? WhereClause?
139 '=' Type ';'
140
141Struct =
142 Attr* Visibility? 'struct' Name GenericParamList? (
143 WhereClause? (RecordFieldList | ';')
144 | TupleFieldList WhereClause? ';'
145 )
146
147RecordFieldList =
148 '{' fields:(RecordField (',' RecordField)* ','?)? '}'
149
150RecordField =
151 Attr* Visibility? Name ':' Type
152
153TupleFieldList =
154 '(' fields:(TupleField (',' TupleField)* ','?)? ')'
155
156TupleField =
157 Attr* Visibility? Type
158
159FieldList =
160 RecordFieldList
161| TupleFieldList
162
163Enum =
164 Attr* Visibility? 'enum' Name GenericParamList? WhereClause?
165 VariantList
166
167VariantList =
168 '{' (Variant (',' Variant)* ','?)? '}'
169
170Variant =
171 Attr* Visibility? Name FieldList ('=' Expr)?
172
173Union =
174 Attr* Visibility? 'union' Name GenericParamList? WhereClause?
175 RecordFieldList
176
177AdtDef =
178 Enum
179| Struct
180| Union
181
182Const =
183 Attr* Visibility? 'default'? 'const' (Name | '_') ':' Type
184 '=' body:Expr ';'
185
186Static =
187 Attr* Visibility? 'static'? 'mut'? Name ':' Type
188 '=' body:Expr ';'
189
190Trait =
191 Attr* Visibility? 'unsafe'? 'auto'? 'trait' Name GenericParamList
192 (':' TypeBoundList?)? WhereClause
193 AssocItemList
194
195AssocItemList =
196 '{' Attr* AssocItem* '}'
197
198AssocItem =
199 Const
200| Fn
201| MacroCall
202| TypeAlias
203
204Impl =
205 Attr* Visibility?
206 'default'? 'unsafe'? 'impl' 'const'? GenericParamList?
207 ('!'? target_trait:Type 'for')? target_type:Type
208 WhereClause?
209 AssocItemList
210
211ExternBlock =
212 Attr* Abi ExternItemList
213
214ExternItemList =
215 '{' Attr* ExternItem* '}'
216
217ExternItem =
218 Fn | Static | MacroCall
219
220GenericParamList =
221 '<' (GenericParam (',' GenericParam)* ','?)? '>'
222
223GenericParam =
224 ConstParam
225| LifetimeParam
226| TypeParam
227
228TypeParam =
229 Attr* Name (':' TypeBoundList?)?
230 ('=' default_type:Type)?
231
232ConstParam =
233 Attr* 'const' Name ':' Type
234 ('=' default_val:Expr)?
235
236LifetimeParam =
237 Attr* 'lifetime' (':' TypeBoundList?)?
238
239WhereClause =
240 'where' predicates:(WherePred (',' WherePred)* ','?)
241
242WherePred =
243 ('for' GenericParamList)? ('lifetime' | Type) ':' TypeBoundList
244
245Visibility =
246 'pub' ('('
247 'super'
248 | 'self'
249 | 'crate'
250 | 'in' Path
251 ')')?
252
253Attr =
254 '#' '!'? '[' Path ('=' Literal | TokenTree)? ']'
255
256//****************************//
257// Statements and Expressions //
258//****************************//
259
260Stmt =
261 ExprStmt
262| Item
263| LetStmt
264
265LetStmt =
266 Attr* 'let' Pat (':' Type)?
267 '=' initializer:Expr ';'
268
269ExprStmt =
270 Attr* Expr ';'?
271
272Expr =
273 ArrayExpr
274| AwaitExpr
275| BinExpr
276| BlockExpr
277| BoxExpr
278| BreakExpr
279| CallExpr
280| CastExpr
281| ClosureExpr
282| ContinueExpr
283| EffectExpr
284| FieldExpr
285| ForExpr
286| IfExpr
287| IndexExpr
288| Literal
289| LoopExpr
290| MacroCall
291| MatchExpr
292| MethodCallExpr
293| ParenExpr
294| PathExpr
295| PrefixExpr
296| RangeExpr
297| RecordExpr
298| RefExpr
299| ReturnExpr
300| TryExpr
301| TupleExpr
302| WhileExpr
303
304Literal =
305 Attr* value:(
306 'int_number' | 'float_number'
307 | 'string' | 'raw_string'
308 | 'byte_string' | 'raw_byte_string'
309 | 'true' | 'false'
310 | 'char' | 'byte'
311 )
312
313PathExpr =
314 Attr* Path
315
316BlockExpr =
317 '{'
318 Attr*
319 statements:Stmt*
320 Expr?
321 '}'
322
323RefExpr =
324 Attr* '&' ('raw' |'mut' | 'const') Expr
325
326TryExpr =
327 Attr* Expr '?'
328
329EffectExpr =
330 Attr* Label? ('try' | 'unsafe' | 'async') BlockExpr
331
332PrefixExpr =
333 Attr* op:('-' | '!' | '*') Expr
334
335BinExpr =
336 Attr*
337 lhs:Expr
338 op:(
339 '||' | '&&'
340 | '==' | '!=' | '<=' | '>=' | '<' | '>'
341 | '+' | '*' | '-' | '/' | '%' | '<<' | '>>' | '^' | '|' | '&'
342 | '=' | '+=' | '/=' | '*=' | '%=' | '>>=' | '<<=' | '-=' | '|=' | '&=' | '^='
343 )
344 rhs:Expr
345
346CastExpr =
347 Attr* Expr 'as' Type
348
349ParenExpr =
350 Attr* '(' Attr* Expr ')'
351
352ArrayExpr =
353 Attr* '[' Attr* (
354 (Expr (',' Expr)* ','?)?
355 | Expr ';' Expr
356 ) ']'
357
358IndexExpr =
359 Attr* base:Expr '[' index:Expr ']'
360
361TupleExpr =
362 Attr* '(' Attr* fields:(Expr (',' Expr)* ','?)? ')'
363
364RecordExpr =
365 Path RecordExprFieldList
366
367RecordExprFieldList =
368 '{'
369 Attr*
370 fields:(RecordExprField (',' RecordExprField)* ','?)
371 ('..' spread:Expr)?
372 '}'
373
374RecordExprField =
375 Attr* NameRef (':' Expr)?
376
377CallExpr =
378 Attr* Expr ArgList
379
380ArgList =
381 '(' args:(Expr (',' Expr)* ','?)? ')'
382
383MethodCallExpr =
384 Attr* Expr '.' NameRef GenericArgList? ArgList
385
386FieldExpr =
387 Attr* Expr '.' NameRef
388
389ClosureExpr =
390 Attr* 'static'? 'async'? 'move'? ParamList RetType?
391 body:Expr
392
393IfExpr =
394 Attr* 'if' Condition then_branch:BlockExpr
395 ('else' else_branch:(IfExpr | BlockExpr))?
396
397Condition =
398 'let' Pat '=' Expr
399| Expr
400
401LoopExpr =
402 Attr* Label? 'loop'
403 loop_body:BlockExpr
404
405ForExpr =
406 Attr* Label? 'for' Pat 'in' iterable:Expr
407 loop_body:BlockExpr
408
409WhileExpr =
410 Attr* Label? 'while' Condition
411 loop_body:BlockExpr
412
413Label =
414 'lifetime'
415
416BreakExpr =
417 Attr* 'break' 'lifetime'? Expr?
418
419ContinueExpr =
420 Attr* 'continue' 'lifetime'?
421
422RangeExpr =
423 Attr* start:Expr? op:('..' | '..=') end:Expr?
424
425MatchExpr =
426 Attr* 'match' Expr MatchArmList
427
428MatchArmList =
429 '{'
430 Attr*
431 arms:MatchArm*
432 '}'
433
434MatchArm =
435 Attr* Pat guard:MatchGuard? '=>' Expr ','?
436
437MatchGuard =
438 'if' Expr
439
440ReturnExpr =
441 Attr* 'return' Expr?
442
443AwaitExpr =
444 Attr* Expr '.' 'await'
445
446BoxExpr =
447 Attr* 'box' Expr
448
449//*************************//
450// Types //
451//*************************//
452
453Type =
454 ArrayType
455| DynTraitType
456| FnPointerType
457| ForType
458| ImplTraitType
459| InferType
460| NeverType
461| ParenType
462| PathType
463| PointerType
464| ReferenceType
465| SliceType
466| TupleType
467
468ParenType =
469 '(' Type ')'
470
471NeverType =
472 '!'
473
474PathType =
475 Path
476
477TupleType =
478 '(' fields:(Type (',' Type)* ','?)? ')'
479
480PointerType =
481 '*' ('const' | 'mut') Type
482
483ReferenceType =
484 '&' 'lifetime'? 'mut'? Type
485
486ArrayType =
487 '[' Type ';' Expr ']'
488
489SliceType =
490 '[' Type ']'
491
492InferType =
493 '_'
494
495FnPointerType =
496 'const'? 'async'? 'unsafe'? Abi? 'fn' ParamList RetType?
497
498ForType =
499 'for' GenericParamList Type
500
501ImplTraitType =
502 'impl' TypeBoundList
503
504DynTraitType =
505 'dyn' TypeBoundList
506
507TypeBoundList =
508 bounds:(TypeBound ('+' TypeBound)* '+'?)
509
510TypeBound =
511 'lifetime'
512| '?'? Type
513
514//************************//
515// Patterns //
516//************************//
517
518Pat =
519 IdentPat
520| BoxPat
521| RestPat
522| LiteralPat
523| MacroPat
524| OrPat
525| ParenPat
526| PathPat
527| WildcardPat
528| RangePat
529| RecordPat
530| RefPat
531| SlicePat
532| TuplePat
533| TupleStructPat
534
535LiteralPat =
536 Literal
537
538IdentPat =
539 Attr* 'ref'? 'mut'? Name ('@' Pat)?
540
541WildcardPat =
542 '_'
543
544RangePat =
545 start:Pat op:('..' | '..=') end:Pat
546
547RefPat =
548 '&' 'mut'? Pat
549
550RecordPat =
551 Path RecordPatFieldList
552
553RecordPatFieldList =
554 '{'
555 fields:(RecordPatField (',' RecordPatField)* ','?)
556 '..'?
557 '}'
558
559RecordPatField =
560 Attr* (NameRef ':')? Pat
561
562TupleStructPat =
563 Path '(' fields:(Pat (',' Pat)* ','?)? ')'
564
565TuplePat =
566 '(' fields:(Pat (',' Pat)* ','?)? ')'
567
568ParenPat =
569 '(' Pat ')'
570
571SlicePat =
572 '[' (Pat (',' Pat)* ','?)? ']'
573
574PathPat =
575 Path
576
577OrPat =
578 (Pat ('|' Pat)* '|'?)
579
580BoxPat =
581 'box' Pat
582
583RestPat =
584 '..'
585
586MacroPat =
587 MacroCall
diff --git a/xtask/src/metrics.rs b/xtask/src/metrics.rs
index 9ac3fa51d..4bade2c7e 100644
--- a/xtask/src/metrics.rs
+++ b/xtask/src/metrics.rs
@@ -1,7 +1,6 @@
1use std::{ 1use std::{
2 collections::BTreeMap, 2 collections::BTreeMap,
3 env, 3 env,
4 fmt::{self, Write as _},
5 io::Write as _, 4 io::Write as _,
6 path::Path, 5 path::Path,
7 time::{Instant, SystemTime, UNIX_EPOCH}, 6 time::{Instant, SystemTime, UNIX_EPOCH},
@@ -127,40 +126,21 @@ impl Metrics {
127 self.metrics.insert(name.into(), (value, unit)); 126 self.metrics.insert(name.into(), (value, unit));
128 } 127 }
129 128
130 fn json(&self) -> Json { 129 fn json(&self) -> String {
131 let mut json = Json::default(); 130 let mut buf = String::new();
132 self.to_json(&mut json); 131 self.to_json(write_json::object(&mut buf));
133 json 132 buf
134 } 133 }
135 fn to_json(&self, json: &mut Json) {
136 json.begin_object();
137 {
138 json.field("host");
139 self.host.to_json(json);
140
141 json.field("timestamp");
142 let timestamp = self.timestamp.duration_since(UNIX_EPOCH).unwrap();
143 json.number(timestamp.as_secs() as f64);
144 134
145 json.field("revision"); 135 fn to_json(&self, mut obj: write_json::Object<'_>) {
146 json.string(&self.revision); 136 self.host.to_json(obj.object("host"));
147 137 let timestamp = self.timestamp.duration_since(UNIX_EPOCH).unwrap();
148 json.field("metrics"); 138 obj.number("timestamp", timestamp.as_secs() as f64);
149 json.begin_object(); 139 obj.string("revision", &self.revision);
150 { 140 let mut metrics = obj.object("metrics");
151 for (k, (value, unit)) in &self.metrics { 141 for (k, (value, unit)) in &self.metrics {
152 json.field(k); 142 metrics.array(k).number(*value as f64).string(unit);
153 json.begin_array();
154 {
155 json.number(*value as f64);
156 json.string(unit);
157 }
158 json.end_array();
159 }
160 }
161 json.end_object()
162 } 143 }
163 json.end_object();
164 } 144 }
165} 145}
166 146
@@ -189,91 +169,7 @@ impl Host {
189 Ok(line[field.len()..].trim().to_string()) 169 Ok(line[field.len()..].trim().to_string())
190 } 170 }
191 } 171 }
192 fn to_json(&self, json: &mut Json) { 172 fn to_json(&self, mut obj: write_json::Object<'_>) {
193 json.begin_object(); 173 obj.string("os", &self.os).string("cpu", &self.cpu).string("mem", &self.mem);
194 {
195 json.field("os");
196 json.string(&self.os);
197
198 json.field("cpu");
199 json.string(&self.cpu);
200
201 json.field("mem");
202 json.string(&self.mem);
203 }
204 json.end_object();
205 }
206}
207
208struct State {
209 obj: bool,
210 first: bool,
211}
212
213#[derive(Default)]
214struct Json {
215 stack: Vec<State>,
216 buf: String,
217}
218
219impl Json {
220 fn begin_object(&mut self) {
221 self.stack.push(State { obj: true, first: true });
222 self.buf.push('{');
223 }
224 fn end_object(&mut self) {
225 self.stack.pop();
226 self.buf.push('}')
227 }
228 fn begin_array(&mut self) {
229 self.stack.push(State { obj: false, first: true });
230 self.buf.push('[');
231 }
232 fn end_array(&mut self) {
233 self.stack.pop();
234 self.buf.push(']')
235 }
236 fn field(&mut self, name: &str) {
237 self.object_comma();
238 self.string_token(name);
239 self.buf.push(':');
240 }
241 fn string(&mut self, value: &str) {
242 self.array_comma();
243 self.string_token(value);
244 }
245 fn string_token(&mut self, value: &str) {
246 self.buf.push('"');
247 self.buf.extend(value.escape_default());
248 self.buf.push('"');
249 }
250 fn number(&mut self, value: f64) {
251 self.array_comma();
252 write!(self.buf, "{}", value).unwrap();
253 }
254
255 fn array_comma(&mut self) {
256 let state = self.stack.last_mut().unwrap();
257 if state.obj {
258 return;
259 }
260 if !state.first {
261 self.buf.push(',');
262 }
263 state.first = false;
264 }
265
266 fn object_comma(&mut self) {
267 let state = self.stack.last_mut().unwrap();
268 if !state.first {
269 self.buf.push(',');
270 }
271 state.first = false;
272 }
273}
274
275impl fmt::Display for Json {
276 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
277 write!(f, "{}", self.buf)
278 } 174 }
279} 175}
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index adadffc53..d65a2acbc 100644
--- a/xtask/tests/tidy.rs
+++ b/xtask/tests/tidy.rs
@@ -55,7 +55,6 @@ fn check_licenses() {
550BSD OR MIT OR Apache-2.0 550BSD OR MIT OR Apache-2.0
56Apache-2.0 OR BSL-1.0 56Apache-2.0 OR BSL-1.0
57Apache-2.0 OR MIT 57Apache-2.0 OR MIT
58Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
59Apache-2.0/MIT 58Apache-2.0/MIT
60BSD-2-Clause 59BSD-2-Clause
61BSD-3-Clause 60BSD-3-Clause