aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/release.yaml37
-rw-r--r--Cargo.lock100
-rw-r--r--Cargo.toml2
-rw-r--r--crates/arena/Cargo.toml10
-rw-r--r--crates/arena/src/map.rs62
-rw-r--r--crates/assists/src/assist_config.rs8
-rw-r--r--crates/assists/src/assist_context.rs41
-rw-r--r--crates/assists/src/handlers/add_explicit_type.rs32
-rw-r--r--crates/assists/src/handlers/add_missing_impl_members.rs56
-rw-r--r--crates/assists/src/handlers/add_turbo_fish.rs12
-rw-r--r--crates/assists/src/handlers/apply_demorgan.rs12
-rw-r--r--crates/assists/src/handlers/auto_import.rs73
-rw-r--r--crates/assists/src/handlers/change_visibility.rs42
-rw-r--r--crates/assists/src/handlers/convert_integer_literal.rs32
-rw-r--r--crates/assists/src/handlers/early_return.rs30
-rw-r--r--crates/assists/src/handlers/expand_glob_import.rs34
-rw-r--r--crates/assists/src/handlers/extract_struct_from_enum_variant.rs91
-rw-r--r--crates/assists/src/handlers/extract_variable.rs50
-rw-r--r--crates/assists/src/handlers/fill_match_arms.rs44
-rw-r--r--crates/assists/src/handlers/fix_visibility.rs78
-rw-r--r--crates/assists/src/handlers/flip_binexpr.rs24
-rw-r--r--crates/assists/src/handlers/flip_comma.rs12
-rw-r--r--crates/assists/src/handlers/flip_trait_bound.rs20
-rw-r--r--crates/assists/src/handlers/generate_default_from_enum_variant.rs10
-rw-r--r--crates/assists/src/handlers/generate_derive.rs12
-rw-r--r--crates/assists/src/handlers/generate_from_impl_for_enum.rs16
-rw-r--r--crates/assists/src/handlers/generate_function.rs60
-rw-r--r--crates/assists/src/handlers/generate_impl.rs14
-rw-r--r--crates/assists/src/handlers/generate_new.rs32
-rw-r--r--crates/assists/src/handlers/infer_function_return_type.rs32
-rw-r--r--crates/assists/src/handlers/inline_function.rs12
-rw-r--r--crates/assists/src/handlers/inline_local_variable.rs156
-rw-r--r--crates/assists/src/handlers/introduce_named_lifetime.rs44
-rw-r--r--crates/assists/src/handlers/invert_if.rs20
-rw-r--r--crates/assists/src/handlers/merge_imports.rs42
-rw-r--r--crates/assists/src/handlers/merge_match_arms.rs12
-rw-r--r--crates/assists/src/handlers/move_bounds.rs10
-rw-r--r--crates/assists/src/handlers/move_guard.rs22
-rw-r--r--crates/assists/src/handlers/move_module_to_file.rs10
-rw-r--r--crates/assists/src/handlers/pull_assignment_up.rs20
-rw-r--r--crates/assists/src/handlers/qualify_path.rs116
-rw-r--r--crates/assists/src/handlers/raw_string.rs54
-rw-r--r--crates/assists/src/handlers/remove_dbg.rs80
-rw-r--r--crates/assists/src/handlers/remove_mut.rs2
-rw-r--r--crates/assists/src/handlers/remove_unused_param.rs61
-rw-r--r--crates/assists/src/handlers/reorder_fields.rs12
-rw-r--r--crates/assists/src/handlers/reorder_impl.rs201
-rw-r--r--crates/assists/src/handlers/replace_derive_with_manual_impl.rs20
-rw-r--r--crates/assists/src/handlers/replace_if_let_with_match.rs30
-rw-r--r--crates/assists/src/handlers/replace_impl_trait_with_generic.rs18
-rw-r--r--crates/assists/src/handlers/replace_let_with_if_let.rs4
-rw-r--r--crates/assists/src/handlers/replace_qualified_name_with_use.rs58
-rw-r--r--crates/assists/src/handlers/replace_string_with_char.rs14
-rw-r--r--crates/assists/src/handlers/replace_unwrap_with_match.rs10
-rw-r--r--crates/assists/src/handlers/split_import.rs12
-rw-r--r--crates/assists/src/handlers/toggle_ignore.rs6
-rw-r--r--crates/assists/src/handlers/unmerge_use.rs231
-rw-r--r--crates/assists/src/handlers/unwrap_block.rs34
-rw-r--r--crates/assists/src/handlers/wrap_return_type_in_result.rs70
-rw-r--r--crates/assists/src/lib.rs6
-rw-r--r--crates/assists/src/tests.rs55
-rw-r--r--crates/assists/src/tests/generated.rs161
-rw-r--r--crates/assists/src/utils.rs1
-rw-r--r--crates/base_db/src/fixture.rs16
-rw-r--r--crates/completion/src/completions.rs1
-rw-r--r--crates/completion/src/completions/attribute.rs49
-rw-r--r--crates/completion/src/completions/dot.rs48
-rw-r--r--crates/completion/src/completions/flyimport.rs291
-rw-r--r--crates/completion/src/completions/fn_param.rs8
-rw-r--r--crates/completion/src/completions/keyword.rs164
-rw-r--r--crates/completion/src/completions/macro_in_item_position.rs2
-rw-r--r--crates/completion/src/completions/mod_.rs87
-rw-r--r--crates/completion/src/completions/pattern.rs20
-rw-r--r--crates/completion/src/completions/postfix.rs74
-rw-r--r--crates/completion/src/completions/qualified_path.rs73
-rw-r--r--crates/completion/src/completions/record.rs28
-rw-r--r--crates/completion/src/completions/snippet.rs8
-rw-r--r--crates/completion/src/completions/trait_impl.rs76
-rw-r--r--crates/completion/src/completions/unqualified_path.rs356
-rw-r--r--crates/completion/src/config.rs4
-rw-r--r--crates/completion/src/context.rs34
-rw-r--r--crates/completion/src/item.rs8
-rw-r--r--crates/completion/src/lib.rs19
-rw-r--r--crates/completion/src/patterns.rs56
-rw-r--r--crates/completion/src/render.rs61
-rw-r--r--crates/completion/src/render/enum_variant.rs2
-rw-r--r--crates/completion/src/render/function.rs22
-rw-r--r--crates/completion/src/render/macro_.rs8
-rw-r--r--crates/completion/src/test_utils.rs18
-rw-r--r--crates/flycheck/Cargo.toml3
-rw-r--r--crates/flycheck/src/lib.rs23
-rw-r--r--crates/hir/src/code_model.rs18
-rw-r--r--crates/hir/src/db.rs4
-rw-r--r--crates/hir/src/diagnostics.rs2
-rw-r--r--crates/hir/src/from_id.rs2
-rw-r--r--crates/hir/src/semantics.rs1
-rw-r--r--crates/hir/src/semantics/source_to_def.rs9
-rw-r--r--crates/hir_def/Cargo.toml2
-rw-r--r--crates/hir_def/src/adt.rs2
-rw-r--r--crates/hir_def/src/attr.rs2
-rw-r--r--crates/hir_def/src/body.rs2
-rw-r--r--crates/hir_def/src/body/lower.rs10
-rw-r--r--crates/hir_def/src/body/scope.rs32
-rw-r--r--crates/hir_def/src/db.rs2
-rw-r--r--crates/hir_def/src/expr.rs11
-rw-r--r--crates/hir_def/src/find_path.rs48
-rw-r--r--crates/hir_def/src/generics.rs2
-rw-r--r--crates/hir_def/src/item_tree.rs12
-rw-r--r--crates/hir_def/src/item_tree/lower.rs4
-rw-r--r--crates/hir_def/src/lib.rs2
-rw-r--r--crates/hir_def/src/nameres.rs2
-rw-r--r--crates/hir_def/src/nameres/collector.rs10
-rw-r--r--crates/hir_def/src/nameres/tests/incremental.rs4
-rw-r--r--crates/hir_def/src/path.rs1
-rw-r--r--crates/hir_def/src/path/lower.rs2
-rw-r--r--crates/hir_def/src/per_ns.rs2
-rw-r--r--crates/hir_def/src/resolver.rs14
-rw-r--r--crates/hir_def/src/src.rs2
-rw-r--r--crates/hir_def/src/trace.rs4
-rw-r--r--crates/hir_def/src/type_ref.rs2
-rw-r--r--crates/hir_def/src/visibility.rs2
-rw-r--r--crates/hir_expand/Cargo.toml2
-rw-r--r--crates/hir_expand/src/ast_id_map.rs32
-rw-r--r--crates/hir_expand/src/builtin_derive.rs2
-rw-r--r--crates/hir_expand/src/db.rs16
-rw-r--r--crates/hir_expand/src/hygiene.rs210
-rw-r--r--crates/hir_expand/src/lib.rs8
-rw-r--r--crates/hir_expand/src/name.rs2
-rw-r--r--crates/hir_expand/src/proc_macro.rs4
-rw-r--r--crates/hir_ty/Cargo.toml2
-rw-r--r--crates/hir_ty/src/db.rs2
-rw-r--r--crates/hir_ty/src/diagnostics.rs15
-rw-r--r--crates/hir_ty/src/diagnostics/expr.rs31
-rw-r--r--crates/hir_ty/src/diagnostics/match_check.rs6
-rw-r--r--crates/hir_ty/src/display.rs100
-rw-r--r--crates/hir_ty/src/infer.rs2
-rw-r--r--crates/hir_ty/src/infer/expr.rs7
-rw-r--r--crates/hir_ty/src/lower.rs8
-rw-r--r--crates/hir_ty/src/tests.rs6
-rw-r--r--crates/hir_ty/src/tests/display_source_code.rs15
-rw-r--r--crates/hir_ty/src/tests/macros.rs31
-rw-r--r--crates/hir_ty/src/tests/traits.rs8
-rw-r--r--crates/ide/src/call_hierarchy.rs73
-rw-r--r--crates/ide/src/diagnostics.rs118
-rw-r--r--crates/ide/src/diagnostics/field_shorthand.rs15
-rw-r--r--crates/ide/src/diagnostics/fixes.rs36
-rw-r--r--crates/ide/src/display/navigation_target.rs35
-rw-r--r--crates/ide/src/doc_links.rs50
-rw-r--r--crates/ide/src/expand_macro.rs12
-rw-r--r--crates/ide/src/extend_selection.rs114
-rw-r--r--crates/ide/src/fixture.rs12
-rw-r--r--crates/ide/src/fn_references.rs6
-rw-r--r--crates/ide/src/goto_definition.rs267
-rw-r--r--crates/ide/src/goto_implementation.rs16
-rw-r--r--crates/ide/src/goto_type_definition.rs12
-rw-r--r--crates/ide/src/hover.rs313
-rw-r--r--crates/ide/src/inlay_hints.rs62
-rw-r--r--crates/ide/src/join_lines.rs140
-rw-r--r--crates/ide/src/lib.rs27
-rw-r--r--crates/ide/src/matching_brace.rs10
-rw-r--r--crates/ide/src/parent_module.rs8
-rw-r--r--crates/ide/src/references.rs288
-rw-r--r--crates/ide/src/references/rename.rs688
-rw-r--r--crates/ide/src/runnables.rs128
-rw-r--r--crates/ide/src/syntax_highlighting.rs821
-rw-r--r--crates/ide/src/syntax_highlighting/format.rs94
-rw-r--r--crates/ide/src/syntax_highlighting/highlight.rs509
-rw-r--r--crates/ide/src/syntax_highlighting/highlights.rs92
-rw-r--r--crates/ide/src/syntax_highlighting/html.rs28
-rw-r--r--crates/ide/src/syntax_highlighting/inject.rs158
-rw-r--r--crates/ide/src/syntax_highlighting/injection.rs192
-rw-r--r--crates/ide/src/syntax_highlighting/injector.rs78
-rw-r--r--crates/ide/src/syntax_highlighting/macro_rules.rs10
-rw-r--r--crates/ide/src/syntax_highlighting/tags.rs173
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/highlight_assoc_functions.html28
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html71
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/highlight_extern_crate.html4
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/highlight_injection.html20
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/highlight_strings.html106
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html88
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/highlighting.html260
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/injection.html48
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/rainbow_highlighting.html20
-rw-r--r--crates/ide/src/syntax_highlighting/tests.rs24
-rw-r--r--crates/ide/src/syntax_tree.rs52
-rw-r--r--crates/ide/src/typing.rs38
-rw-r--r--crates/ide/src/typing/on_enter.rs18
-rw-r--r--crates/ide_db/src/apply_change.rs1
-rw-r--r--crates/ide_db/src/call_info/tests.rs54
-rw-r--r--crates/ide_db/src/defs.rs80
-rw-r--r--crates/ide_db/src/helpers.rs90
-rw-r--r--crates/ide_db/src/helpers/famous_defs_fixture.rs120
-rw-r--r--crates/ide_db/src/helpers/import_assets.rs (renamed from crates/assists/src/utils/import_assets.rs)50
-rw-r--r--crates/ide_db/src/helpers/insert_use.rs18
-rw-r--r--crates/ide_db/src/helpers/insert_use/tests.rs2
-rw-r--r--crates/ide_db/src/imports_locator.rs8
-rw-r--r--crates/ide_db/src/search.rs114
-rw-r--r--crates/ide_db/src/source_change.rs56
-rw-r--r--crates/ide_db/src/traits/tests.rs18
-rw-r--r--crates/mbe/src/lib.rs4
-rw-r--r--crates/mbe/src/mbe_expander/matcher.rs4
-rw-r--r--crates/mbe/src/mbe_expander/transcriber.rs35
-rw-r--r--crates/mbe/src/parser.rs15
-rw-r--r--crates/mbe/src/syntax_bridge.rs12
-rw-r--r--crates/mbe/src/tests.rs48
-rw-r--r--crates/parser/src/grammar.rs12
-rw-r--r--crates/parser/src/grammar/expressions/atom.rs28
-rw-r--r--crates/parser/src/grammar/items.rs28
-rw-r--r--crates/parser/src/grammar/items/traits.rs2
-rw-r--r--crates/parser/src/grammar/items/use_item.rs2
-rw-r--r--crates/parser/src/grammar/params.rs31
-rw-r--r--crates/parser/src/grammar/paths.rs6
-rw-r--r--crates/parser/src/grammar/patterns.rs2
-rw-r--r--crates/parser/src/grammar/type_args.rs6
-rw-r--r--crates/parser/src/grammar/type_params.rs4
-rw-r--r--crates/parser/src/parser.rs16
-rw-r--r--crates/parser/src/syntax_kind.rs3
-rw-r--r--crates/parser/src/syntax_kind/generated.rs9
-rw-r--r--crates/proc_macro_api/Cargo.toml2
-rw-r--r--crates/proc_macro_api/src/msg.rs2
-rw-r--r--crates/proc_macro_srv/Cargo.toml2
-rw-r--r--crates/proc_macro_srv/src/proc_macro/bridge/rpc.rs2
-rw-r--r--crates/proc_macro_srv/src/rustc_server.rs2
-rw-r--r--crates/proc_macro_srv/src/tests/mod.rs8
-rw-r--r--crates/proc_macro_srv/src/tests/utils.rs2
-rw-r--r--crates/profile/Cargo.toml5
-rw-r--r--crates/profile/src/lib.rs15
-rw-r--r--crates/profile/src/tree.rs4
-rw-r--r--crates/project_model/Cargo.toml5
-rw-r--r--crates/project_model/src/cargo_workspace.rs30
-rw-r--r--crates/project_model/src/lib.rs1
-rw-r--r--crates/project_model/src/rustc_cfg.rs34
-rw-r--r--crates/project_model/src/sysroot.rs2
-rw-r--r--crates/project_model/src/workspace.rs143
-rw-r--r--crates/rust-analyzer/src/bin/main.rs5
-rw-r--r--crates/rust-analyzer/src/caps.rs24
-rw-r--r--crates/rust-analyzer/src/cli/analysis_bench.rs5
-rw-r--r--crates/rust-analyzer/src/cli/analysis_stats.rs39
-rw-r--r--crates/rust-analyzer/src/cli/load_cargo.rs3
-rw-r--r--crates/rust-analyzer/src/cli/ssr.rs8
-rw-r--r--crates/rust-analyzer/src/config.rs74
-rw-r--r--crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt47
-rw-r--r--crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt47
-rw-r--r--crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt47
-rw-r--r--crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt120
-rw-r--r--crates/rust-analyzer/src/diagnostics/to_proto.rs53
-rw-r--r--crates/rust-analyzer/src/global_state.rs3
-rw-r--r--crates/rust-analyzer/src/handlers.rs83
-rw-r--r--crates/rust-analyzer/src/lib.rs1
-rw-r--r--crates/rust-analyzer/src/lsp_utils.rs10
-rw-r--r--crates/rust-analyzer/src/main_loop.rs92
-rw-r--r--crates/rust-analyzer/src/markdown.rs2
-rw-r--r--crates/rust-analyzer/src/op_queue.rs25
-rw-r--r--crates/rust-analyzer/src/reload.rs113
-rw-r--r--crates/rust-analyzer/src/semantic_tokens.rs8
-rw-r--r--crates/rust-analyzer/src/to_proto.rs107
-rw-r--r--crates/rust-analyzer/tests/rust-analyzer/main.rs144
-rw-r--r--crates/ssr/src/lib.rs24
-rw-r--r--crates/ssr/src/matching.rs4
-rw-r--r--crates/ssr/src/search.rs20
-rw-r--r--crates/ssr/src/tests.rs25
-rw-r--r--crates/stdx/Cargo.toml5
-rw-r--r--crates/stdx/src/lib.rs70
-rw-r--r--crates/stdx/src/macros.rs52
-rw-r--r--crates/syntax/Cargo.toml2
-rw-r--r--crates/syntax/src/algo.rs14
-rw-r--r--crates/syntax/src/ast/generated/nodes.rs80
-rw-r--r--crates/syntax/src/ast/make.rs10
-rw-r--r--crates/syntax/src/ast/node_ext.rs57
-rw-r--r--crates/syntax/src/display.rs2
-rw-r--r--crates/syntax/src/parsing/lexer.rs8
-rw-r--r--crates/syntax/src/parsing/reparsing.rs61
-rw-r--r--crates/syntax/src/validation.rs8
-rw-r--r--crates/syntax/test_data/parser/err/0018_incomplete_fn.rast6
-rw-r--r--crates/syntax/test_data/parser/err/0035_use_recover.rast3
-rw-r--r--crates/syntax/test_data/parser/err/0037_visibility_in_traits.rast10
-rw-r--r--crates/syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast15
-rw-r--r--crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast15
-rw-r--r--crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast6
-rw-r--r--crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0002_use_tree_list.rast101
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0002_use_tree_list.rs2
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0006_self_param.rast15
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0018_arb_self_types.rast6
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0021_impl_item_list.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rast50
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rs3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0039_type_arg.rast28
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0039_type_arg.rs2
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0052_path_type.rast6
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0062_mod_contents.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0067_crate_path.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast6
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0117_macro_call_type.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0153_pub_parens_typepath.rast6
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0159_yield_expr.rast28
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0159_yield_expr.rs4
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0160_crate_visibility_in.rast42
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0160_crate_visibility_in.rs2
-rw-r--r--crates/syntax/test_data/parser/ok/0007_extern_crate.rast3
-rw-r--r--crates/syntax/test_data/parser/ok/0012_visibility.rast10
-rw-r--r--crates/syntax/test_data/parser/ok/0013_use_path_self_super.rast9
-rw-r--r--crates/syntax/test_data/parser/ok/0020_type_param_bounds.rast3
-rw-r--r--crates/syntax/test_data/parser/ok/0034_crate_path_in_call.rast3
-rw-r--r--crates/syntax/test_data/parser/ok/0045_block_inner_attrs.rast3
-rw-r--r--crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast24
-rw-r--r--crates/test_utils/src/lib.rs17
-rw-r--r--crates/vfs/src/anchored_path.rs10
-rw-r--r--crates/vfs/src/file_set.rs57
-rw-r--r--crates/vfs/src/lib.rs121
-rw-r--r--crates/vfs/src/loader.rs80
-rw-r--r--crates/vfs/src/path_interner.rs14
-rw-r--r--crates/vfs/src/vfs_path.rs94
-rw-r--r--docs/dev/README.md2
-rw-r--r--docs/dev/style.md216
-rw-r--r--docs/user/generated_config.adoc2
-rw-r--r--docs/user/manual.adoc4
-rw-r--r--editors/code/package.json2
-rw-r--r--editors/code/src/main.ts8
-rw-r--r--lib/README.md2
-rw-r--r--lib/arena/Cargo.toml10
-rw-r--r--lib/arena/src/lib.rs (renamed from crates/arena/src/lib.rs)111
-rw-r--r--lib/arena/src/map.rs69
-rw-r--r--xtask/Cargo.toml2
-rw-r--r--xtask/src/ast_src.rs4
-rw-r--r--xtask/src/codegen/gen_assists_docs.rs4
-rw-r--r--xtask/src/main.rs12
-rw-r--r--xtask/tests/tidy.rs38
330 files changed, 8362 insertions, 5912 deletions
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index ece1fd364..a97ed24ba 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -118,6 +118,37 @@ jobs:
118 name: dist-x86_64-unknown-linux-gnu 118 name: dist-x86_64-unknown-linux-gnu
119 path: ./dist 119 path: ./dist
120 120
121 dist-aarch64-unknown-linux-gnu:
122 name: dist (aarch64-unknown-linux-gnu)
123 runs-on: ubuntu-16.04
124 env:
125 RA_TARGET: aarch64-unknown-linux-gnu
126 CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
127
128 steps:
129 - name: Checkout repository
130 uses: actions/checkout@v2
131
132 - name: Install Rust toolchain
133 uses: actions-rs/toolchain@v1
134 with:
135 toolchain: stable
136 target: aarch64-unknown-linux-gnu
137 profile: minimal
138 override: true
139
140 - name: Install target toolchain
141 run: sudo apt-get install gcc-aarch64-linux-gnu
142
143 - name: Dist
144 run: cargo xtask dist
145
146 - name: Upload artifacts
147 uses: actions/upload-artifact@v1
148 with:
149 name: dist-aarch64-unknown-linux-gnu
150 path: ./dist
151
121 dist-x86_64-apple-darwin: 152 dist-x86_64-apple-darwin:
122 name: dist (x86_64-apple-darwin) 153 name: dist (x86_64-apple-darwin)
123 runs-on: macos-latest 154 runs-on: macos-latest
@@ -174,7 +205,7 @@ jobs:
174 publish: 205 publish:
175 name: publish 206 name: publish
176 runs-on: ubuntu-16.04 207 runs-on: ubuntu-16.04
177 needs: ['dist-x86_64-pc-windows-msvc', 'dist-aarch64-pc-windows-msvc', 'dist-x86_64-unknown-linux-gnu', 'dist-x86_64-apple-darwin', 'dist-aarch64-apple-darwin'] 208 needs: ['dist-x86_64-pc-windows-msvc', 'dist-aarch64-pc-windows-msvc', 'dist-x86_64-unknown-linux-gnu', 'dist-aarch64-unknown-linux-gnu', 'dist-x86_64-apple-darwin', 'dist-aarch64-apple-darwin']
178 steps: 209 steps:
179 - name: Install Nodejs 210 - name: Install Nodejs
180 uses: actions/setup-node@v1 211 uses: actions/setup-node@v1
@@ -207,6 +238,10 @@ jobs:
207 path: dist 238 path: dist
208 - uses: actions/download-artifact@v1 239 - uses: actions/download-artifact@v1
209 with: 240 with:
241 name: dist-aarch64-unknown-linux-gnu
242 path: dist
243 - uses: actions/download-artifact@v1
244 with:
210 name: dist-x86_64-pc-windows-msvc 245 name: dist-x86_64-pc-windows-msvc
211 path: dist 246 path: dist
212 - uses: actions/download-artifact@v1 247 - uses: actions/download-artifact@v1
diff --git a/Cargo.lock b/Cargo.lock
index 6b9020424..aac473191 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -37,10 +37,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
37checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344" 37checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344"
38 38
39[[package]] 39[[package]]
40name = "arena"
41version = "0.0.0"
42
43[[package]]
44name = "arrayvec" 40name = "arrayvec"
45version = "0.5.2" 41version = "0.5.2"
46source = "registry+https://github.com/rust-lang/crates.io-index" 42source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -127,12 +123,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
127checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" 123checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
128 124
129[[package]] 125[[package]]
126name = "cargo-platform"
127version = "0.1.1"
128source = "registry+https://github.com/rust-lang/crates.io-index"
129checksum = "0226944a63d1bf35a3b5f948dd7c59e263db83695c9e8bffc4037de02e30f1d7"
130dependencies = [
131 "serde",
132]
133
134[[package]]
130name = "cargo_metadata" 135name = "cargo_metadata"
131version = "0.12.0" 136version = "0.12.2"
132source = "registry+https://github.com/rust-lang/crates.io-index" 137source = "registry+https://github.com/rust-lang/crates.io-index"
133checksum = "d5a5f7b42f606b7f23674f6f4d877628350682bc40687d3fae65679a58d55345" 138checksum = "11a47b6286279a9998588ef7050d1ebc2500c69892a557c90fe5d071c64415dc"
134dependencies = [ 139dependencies = [
140 "cargo-platform",
135 "semver", 141 "semver",
142 "semver-parser",
136 "serde", 143 "serde",
137 "serde_json", 144 "serde_json",
138] 145]
@@ -316,7 +323,7 @@ dependencies = [
316 "const_fn", 323 "const_fn",
317 "crossbeam-utils 0.8.1", 324 "crossbeam-utils 0.8.1",
318 "lazy_static", 325 "lazy_static",
319 "memoffset", 326 "memoffset 0.6.1",
320 "scopeguard", 327 "scopeguard",
321] 328]
322 329
@@ -427,6 +434,7 @@ dependencies = [
427 "jod-thread", 434 "jod-thread",
428 "log", 435 "log",
429 "serde_json", 436 "serde_json",
437 "stdx",
430 "toolchain", 438 "toolchain",
431] 439]
432 440
@@ -494,6 +502,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
494checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" 502checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
495 503
496[[package]] 504[[package]]
505name = "hashbrown"
506version = "0.10.0"
507source = "registry+https://github.com/rust-lang/crates.io-index"
508checksum = "2140e9c963869f01789fa4fef4805211081ec794af5fc77c0d5b377906118853"
509
510[[package]]
497name = "heck" 511name = "heck"
498version = "0.3.2" 512version = "0.3.2"
499source = "registry+https://github.com/rust-lang/crates.io-index" 513source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -535,7 +549,6 @@ name = "hir_def"
535version = "0.0.0" 549version = "0.0.0"
536dependencies = [ 550dependencies = [
537 "anymap", 551 "anymap",
538 "arena",
539 "base_db", 552 "base_db",
540 "cfg", 553 "cfg",
541 "drop_bomb", 554 "drop_bomb",
@@ -545,6 +558,7 @@ dependencies = [
545 "hir_expand", 558 "hir_expand",
546 "indexmap", 559 "indexmap",
547 "itertools 0.10.0", 560 "itertools 0.10.0",
561 "la-arena",
548 "log", 562 "log",
549 "mbe", 563 "mbe",
550 "once_cell", 564 "once_cell",
@@ -561,9 +575,9 @@ dependencies = [
561name = "hir_expand" 575name = "hir_expand"
562version = "0.0.0" 576version = "0.0.0"
563dependencies = [ 577dependencies = [
564 "arena",
565 "base_db", 578 "base_db",
566 "either", 579 "either",
580 "la-arena",
567 "log", 581 "log",
568 "mbe", 582 "mbe",
569 "parser", 583 "parser",
@@ -578,7 +592,6 @@ dependencies = [
578name = "hir_ty" 592name = "hir_ty"
579version = "0.0.0" 593version = "0.0.0"
580dependencies = [ 594dependencies = [
581 "arena",
582 "arrayvec", 595 "arrayvec",
583 "base_db", 596 "base_db",
584 "chalk-ir", 597 "chalk-ir",
@@ -589,6 +602,7 @@ dependencies = [
589 "hir_def", 602 "hir_def",
590 "hir_expand", 603 "hir_expand",
591 "itertools 0.10.0", 604 "itertools 0.10.0",
605 "la-arena",
592 "log", 606 "log",
593 "once_cell", 607 "once_cell",
594 "profile", 608 "profile",
@@ -678,7 +692,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
678checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" 692checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b"
679dependencies = [ 693dependencies = [
680 "autocfg", 694 "autocfg",
681 "hashbrown", 695 "hashbrown 0.9.1",
682] 696]
683 697
684[[package]] 698[[package]]
@@ -760,6 +774,10 @@ dependencies = [
760] 774]
761 775
762[[package]] 776[[package]]
777name = "la-arena"
778version = "0.2.0"
779
780[[package]]
763name = "lazy_static" 781name = "lazy_static"
764version = "1.4.0" 782version = "1.4.0"
765source = "registry+https://github.com/rust-lang/crates.io-index" 783source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -892,6 +910,15 @@ dependencies = [
892 910
893[[package]] 911[[package]]
894name = "memoffset" 912name = "memoffset"
913version = "0.5.6"
914source = "registry+https://github.com/rust-lang/crates.io-index"
915checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa"
916dependencies = [
917 "autocfg",
918]
919
920[[package]]
921name = "memoffset"
895version = "0.6.1" 922version = "0.6.1"
896source = "registry+https://github.com/rust-lang/crates.io-index" 923source = "registry+https://github.com/rust-lang/crates.io-index"
897checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" 924checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87"
@@ -1184,9 +1211,8 @@ version = "0.0.0"
1184name = "profile" 1211name = "profile"
1185version = "0.0.0" 1212version = "0.0.0"
1186dependencies = [ 1213dependencies = [
1187 "arena",
1188 "backtrace",
1189 "cfg-if 1.0.0", 1214 "cfg-if 1.0.0",
1215 "la-arena",
1190 "libc", 1216 "libc",
1191 "once_cell", 1217 "once_cell",
1192 "perf-event", 1218 "perf-event",
@@ -1197,14 +1223,15 @@ name = "project_model"
1197version = "0.0.0" 1223version = "0.0.0"
1198dependencies = [ 1224dependencies = [
1199 "anyhow", 1225 "anyhow",
1200 "arena",
1201 "base_db", 1226 "base_db",
1202 "cargo_metadata", 1227 "cargo_metadata",
1203 "cfg", 1228 "cfg",
1204 "itertools 0.10.0", 1229 "itertools 0.10.0",
1230 "la-arena",
1205 "log", 1231 "log",
1206 "paths", 1232 "paths",
1207 "proc_macro_api", 1233 "proc_macro_api",
1234 "profile",
1208 "rustc-hash", 1235 "rustc-hash",
1209 "serde", 1236 "serde",
1210 "serde_json", 1237 "serde_json",
@@ -1299,14 +1326,15 @@ checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
1299 1326
1300[[package]] 1327[[package]]
1301name = "rowan" 1328name = "rowan"
1302version = "0.10.0" 1329version = "0.10.5"
1303source = "registry+https://github.com/rust-lang/crates.io-index" 1330source = "registry+https://github.com/rust-lang/crates.io-index"
1304checksum = "1e081ed6eacce09e243b619ab90f069c27b0cff8a6d0eb8ad2ec935b65853798" 1331checksum = "e1898adeafc7d3c69913b33ee1acbbb39c726a9dbe05ff77c08b52957643e8db"
1305dependencies = [ 1332dependencies = [
1333 "hashbrown 0.10.0",
1306 "rustc-hash", 1334 "rustc-hash",
1307 "smol_str", 1335 "smol_str",
1308 "text-size", 1336 "text-size",
1309 "thin-dst", 1337 "triomphe",
1310] 1338]
1311 1339
1312[[package]] 1340[[package]]
@@ -1448,9 +1476,9 @@ dependencies = [
1448 1476
1449[[package]] 1477[[package]]
1450name = "semver-parser" 1478name = "semver-parser"
1451version = "0.10.1" 1479version = "0.10.2"
1452source = "registry+https://github.com/rust-lang/crates.io-index" 1480source = "registry+https://github.com/rust-lang/crates.io-index"
1453checksum = "42ef146c2ad5e5f4b037cd6ce2ebb775401729b19a82040c1beac9d36c7d1428" 1481checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7"
1454dependencies = [ 1482dependencies = [
1455 "pest", 1483 "pest",
1456] 1484]
@@ -1552,8 +1580,17 @@ dependencies = [
1552] 1580]
1553 1581
1554[[package]] 1582[[package]]
1583name = "stable_deref_trait"
1584version = "1.2.0"
1585source = "registry+https://github.com/rust-lang/crates.io-index"
1586checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
1587
1588[[package]]
1555name = "stdx" 1589name = "stdx"
1556version = "0.0.0" 1590version = "0.0.0"
1591dependencies = [
1592 "backtrace",
1593]
1557 1594
1558[[package]] 1595[[package]]
1559name = "syn" 1596name = "syn"
@@ -1623,9 +1660,9 @@ dependencies = [
1623 1660
1624[[package]] 1661[[package]]
1625name = "text-size" 1662name = "text-size"
1626version = "1.0.0" 1663version = "1.1.0"
1627source = "registry+https://github.com/rust-lang/crates.io-index" 1664source = "registry+https://github.com/rust-lang/crates.io-index"
1628checksum = "f03e7efdedc3bc78cb2337f1e2785c39e45f5ef762d9e4ebb137fff7380a6d8a" 1665checksum = "288cb548dbe72b652243ea797201f3d481a0609a967980fcc5b2315ea811560a"
1629 1666
1630[[package]] 1667[[package]]
1631name = "text_edit" 1668name = "text_edit"
@@ -1635,12 +1672,6 @@ dependencies = [
1635] 1672]
1636 1673
1637[[package]] 1674[[package]]
1638name = "thin-dst"
1639version = "1.1.0"
1640source = "registry+https://github.com/rust-lang/crates.io-index"
1641checksum = "db3c46be180f1af9673ebb27bc1235396f61ef6965b3fe0dbb2e624deb604f0e"
1642
1643[[package]]
1644name = "thread_local" 1675name = "thread_local"
1645version = "1.0.1" 1676version = "1.0.1"
1646source = "registry+https://github.com/rust-lang/crates.io-index" 1677source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1782,6 +1813,17 @@ dependencies = [
1782] 1813]
1783 1814
1784[[package]] 1815[[package]]
1816name = "triomphe"
1817version = "0.1.2"
1818source = "registry+https://github.com/rust-lang/crates.io-index"
1819checksum = "6e9d872053cf9e5a833d8c1dd772cdc38ab66a908129d6f73c049c986161d07c"
1820dependencies = [
1821 "memoffset 0.5.6",
1822 "serde",
1823 "stable_deref_trait",
1824]
1825
1826[[package]]
1785name = "tt" 1827name = "tt"
1786version = "0.0.0" 1828version = "0.0.0"
1787dependencies = [ 1829dependencies = [
@@ -1797,9 +1839,9 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
1797 1839
1798[[package]] 1840[[package]]
1799name = "ungrammar" 1841name = "ungrammar"
1800version = "1.6.0" 1842version = "1.9.2"
1801source = "registry+https://github.com/rust-lang/crates.io-index" 1843source = "registry+https://github.com/rust-lang/crates.io-index"
1802checksum = "f96cc1b6938f7c548fbcc630bac5c896ae77a130909829ab18b8eab78c51b7ee" 1844checksum = "58a02e2041a872d56354e843e8e86e6b946fc8e7dc32982fcdc335e29eb4cc8b"
1803 1845
1804[[package]] 1846[[package]]
1805name = "unicase" 1847name = "unicase"
diff --git a/Cargo.toml b/Cargo.toml
index 59d36fbc1..46c64d35c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,5 @@
1[workspace] 1[workspace]
2members = [ "crates/*", "xtask/" ] 2members = ["xtask/", "lib/*", "crates/*"]
3 3
4[profile.dev] 4[profile.dev]
5# Disabling debug info speeds up builds a bunch, 5# Disabling debug info speeds up builds a bunch,
diff --git a/crates/arena/Cargo.toml b/crates/arena/Cargo.toml
deleted file mode 100644
index 863eedf76..000000000
--- a/crates/arena/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
1[package]
2name = "arena"
3version = "0.0.0"
4description = "TBD"
5license = "MIT OR Apache-2.0"
6authors = ["rust-analyzer developers"]
7edition = "2018"
8
9[lib]
10doctest = false
diff --git a/crates/arena/src/map.rs b/crates/arena/src/map.rs
deleted file mode 100644
index 0f33907c0..000000000
--- a/crates/arena/src/map.rs
+++ /dev/null
@@ -1,62 +0,0 @@
1//! A map from arena IDs to some other type. Space requirement is O(highest ID).
2
3use std::marker::PhantomData;
4
5use crate::Idx;
6
7/// A map from arena IDs to some other type. Space requirement is O(highest ID).
8#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
9pub struct ArenaMap<ID, V> {
10 v: Vec<Option<V>>,
11 _ty: PhantomData<ID>,
12}
13
14impl<T, V> ArenaMap<Idx<T>, V> {
15 pub fn insert(&mut self, id: Idx<T>, t: V) {
16 let idx = Self::to_idx(id);
17
18 self.v.resize_with((idx + 1).max(self.v.len()), || None);
19 self.v[idx] = Some(t);
20 }
21
22 pub fn get(&self, id: Idx<T>) -> Option<&V> {
23 self.v.get(Self::to_idx(id)).and_then(|it| it.as_ref())
24 }
25
26 pub fn get_mut(&mut self, id: Idx<T>) -> Option<&mut V> {
27 self.v.get_mut(Self::to_idx(id)).and_then(|it| it.as_mut())
28 }
29
30 pub fn values(&self) -> impl Iterator<Item = &V> {
31 self.v.iter().filter_map(|o| o.as_ref())
32 }
33
34 pub fn values_mut(&mut self) -> impl Iterator<Item = &mut V> {
35 self.v.iter_mut().filter_map(|o| o.as_mut())
36 }
37
38 pub fn iter(&self) -> impl Iterator<Item = (Idx<T>, &V)> {
39 self.v.iter().enumerate().filter_map(|(idx, o)| Some((Self::from_idx(idx), o.as_ref()?)))
40 }
41
42 fn to_idx(id: Idx<T>) -> usize {
43 u32::from(id.into_raw()) as usize
44 }
45
46 fn from_idx(idx: usize) -> Idx<T> {
47 Idx::from_raw((idx as u32).into())
48 }
49}
50
51impl<T, V> std::ops::Index<Idx<V>> for ArenaMap<Idx<V>, T> {
52 type Output = T;
53 fn index(&self, id: Idx<V>) -> &T {
54 self.v[Self::to_idx(id)].as_ref().unwrap()
55 }
56}
57
58impl<T, V> Default for ArenaMap<Idx<V>, T> {
59 fn default() -> Self {
60 ArenaMap { v: Vec::new(), _ty: PhantomData }
61 }
62}
diff --git a/crates/assists/src/assist_config.rs b/crates/assists/src/assist_config.rs
index 4fe8ea761..9cabf037c 100644
--- a/crates/assists/src/assist_config.rs
+++ b/crates/assists/src/assist_config.rs
@@ -4,7 +4,7 @@
4//! module, and we use to statically check that we only produce snippet 4//! module, and we use to statically check that we only produce snippet
5//! assists if we are allowed to. 5//! assists if we are allowed to.
6 6
7use ide_db::helpers::{insert_use::MergeBehavior, SnippetCap}; 7use ide_db::helpers::{insert_use::InsertUseConfig, SnippetCap};
8 8
9use crate::AssistKind; 9use crate::AssistKind;
10 10
@@ -14,9 +14,3 @@ pub struct AssistConfig {
14 pub allowed: Option<Vec<AssistKind>>, 14 pub allowed: Option<Vec<AssistKind>>,
15 pub insert_use: InsertUseConfig, 15 pub insert_use: InsertUseConfig,
16} 16}
17
18#[derive(Clone, Copy, Debug, PartialEq, Eq)]
19pub struct InsertUseConfig {
20 pub merge: Option<MergeBehavior>,
21 pub prefix_kind: hir::PrefixKind,
22}
diff --git a/crates/assists/src/assist_context.rs b/crates/assists/src/assist_context.rs
index 91cc63427..8d93edba2 100644
--- a/crates/assists/src/assist_context.rs
+++ b/crates/assists/src/assist_context.rs
@@ -2,7 +2,6 @@
2 2
3use std::mem; 3use std::mem;
4 4
5use algo::find_covering_element;
6use hir::Semantics; 5use hir::Semantics;
7use ide_db::{ 6use ide_db::{
8 base_db::{AnchoredPathBuf, FileId, FileRange}, 7 base_db::{AnchoredPathBuf, FileId, FileRange},
@@ -10,7 +9,7 @@ use ide_db::{
10}; 9};
11use ide_db::{ 10use ide_db::{
12 label::Label, 11 label::Label,
13 source_change::{FileSystemEdit, SourceChange, SourceFileEdit}, 12 source_change::{FileSystemEdit, SourceChange},
14 RootDatabase, 13 RootDatabase,
15}; 14};
16use syntax::{ 15use syntax::{
@@ -94,11 +93,11 @@ impl<'a> AssistContext<'a> {
94 self.sema.find_node_at_offset_with_descend(self.source_file.syntax(), self.offset()) 93 self.sema.find_node_at_offset_with_descend(self.source_file.syntax(), self.offset())
95 } 94 }
96 pub(crate) fn covering_element(&self) -> SyntaxElement { 95 pub(crate) fn covering_element(&self) -> SyntaxElement {
97 find_covering_element(self.source_file.syntax(), self.frange.range) 96 self.source_file.syntax().covering_element(self.frange.range)
98 } 97 }
99 // FIXME: remove 98 // FIXME: remove
100 pub(crate) fn covering_node_for_range(&self, range: TextRange) -> SyntaxElement { 99 pub(crate) fn covering_node_for_range(&self, range: TextRange) -> SyntaxElement {
101 find_covering_element(self.source_file.syntax(), range) 100 self.source_file.syntax().covering_element(range)
102 } 101 }
103} 102}
104 103
@@ -180,20 +179,12 @@ impl Assists {
180pub(crate) struct AssistBuilder { 179pub(crate) struct AssistBuilder {
181 edit: TextEditBuilder, 180 edit: TextEditBuilder,
182 file_id: FileId, 181 file_id: FileId,
183 is_snippet: bool, 182 source_change: SourceChange,
184 source_file_edits: Vec<SourceFileEdit>,
185 file_system_edits: Vec<FileSystemEdit>,
186} 183}
187 184
188impl AssistBuilder { 185impl AssistBuilder {
189 pub(crate) fn new(file_id: FileId) -> AssistBuilder { 186 pub(crate) fn new(file_id: FileId) -> AssistBuilder {
190 AssistBuilder { 187 AssistBuilder { edit: TextEdit::builder(), file_id, source_change: SourceChange::default() }
191 edit: TextEdit::builder(),
192 file_id,
193 is_snippet: false,
194 source_file_edits: Vec::default(),
195 file_system_edits: Vec::default(),
196 }
197 } 188 }
198 189
199 pub(crate) fn edit_file(&mut self, file_id: FileId) { 190 pub(crate) fn edit_file(&mut self, file_id: FileId) {
@@ -204,15 +195,7 @@ impl AssistBuilder {
204 fn commit(&mut self) { 195 fn commit(&mut self) {
205 let edit = mem::take(&mut self.edit).finish(); 196 let edit = mem::take(&mut self.edit).finish();
206 if !edit.is_empty() { 197 if !edit.is_empty() {
207 match self.source_file_edits.binary_search_by_key(&self.file_id, |edit| edit.file_id) { 198 self.source_change.insert_source_edit(self.file_id, edit);
208 Ok(idx) => self.source_file_edits[idx]
209 .edit
210 .union(edit)
211 .expect("overlapping edits for same file"),
212 Err(idx) => self
213 .source_file_edits
214 .insert(idx, SourceFileEdit { file_id: self.file_id, edit }),
215 }
216 } 199 }
217 } 200 }
218 201
@@ -231,7 +214,7 @@ impl AssistBuilder {
231 offset: TextSize, 214 offset: TextSize,
232 snippet: impl Into<String>, 215 snippet: impl Into<String>,
233 ) { 216 ) {
234 self.is_snippet = true; 217 self.source_change.is_snippet = true;
235 self.insert(offset, snippet); 218 self.insert(offset, snippet);
236 } 219 }
237 /// Replaces specified `range` of text with a given string. 220 /// Replaces specified `range` of text with a given string.
@@ -245,7 +228,7 @@ impl AssistBuilder {
245 range: TextRange, 228 range: TextRange,
246 snippet: impl Into<String>, 229 snippet: impl Into<String>,
247 ) { 230 ) {
248 self.is_snippet = true; 231 self.source_change.is_snippet = true;
249 self.replace(range, snippet); 232 self.replace(range, snippet);
250 } 233 }
251 pub(crate) fn replace_ast<N: AstNode>(&mut self, old: N, new: N) { 234 pub(crate) fn replace_ast<N: AstNode>(&mut self, old: N, new: N) {
@@ -260,15 +243,11 @@ impl AssistBuilder {
260 pub(crate) fn create_file(&mut self, dst: AnchoredPathBuf, content: impl Into<String>) { 243 pub(crate) fn create_file(&mut self, dst: AnchoredPathBuf, content: impl Into<String>) {
261 let file_system_edit = 244 let file_system_edit =
262 FileSystemEdit::CreateFile { dst: dst.clone(), initial_contents: content.into() }; 245 FileSystemEdit::CreateFile { dst: dst.clone(), initial_contents: content.into() };
263 self.file_system_edits.push(file_system_edit); 246 self.source_change.push_file_system_edit(file_system_edit);
264 } 247 }
265 248
266 fn finish(mut self) -> SourceChange { 249 fn finish(mut self) -> SourceChange {
267 self.commit(); 250 self.commit();
268 SourceChange { 251 mem::take(&mut self.source_change)
269 source_file_edits: mem::take(&mut self.source_file_edits),
270 file_system_edits: mem::take(&mut self.file_system_edits),
271 is_snippet: self.is_snippet,
272 }
273 } 252 }
274} 253}
diff --git a/crates/assists/src/handlers/add_explicit_type.rs b/crates/assists/src/handlers/add_explicit_type.rs
index 563cbf505..cb1548cef 100644
--- a/crates/assists/src/handlers/add_explicit_type.rs
+++ b/crates/assists/src/handlers/add_explicit_type.rs
@@ -12,7 +12,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
12// 12//
13// ``` 13// ```
14// fn main() { 14// fn main() {
15// let x<|> = 92; 15// let x$0 = 92;
16// } 16// }
17// ``` 17// ```
18// -> 18// ->
@@ -81,21 +81,17 @@ mod tests {
81 81
82 #[test] 82 #[test]
83 fn add_explicit_type_target() { 83 fn add_explicit_type_target() {
84 check_assist_target(add_explicit_type, "fn f() { let a<|> = 1; }", "a"); 84 check_assist_target(add_explicit_type, "fn f() { let a$0 = 1; }", "a");
85 } 85 }
86 86
87 #[test] 87 #[test]
88 fn add_explicit_type_works_for_simple_expr() { 88 fn add_explicit_type_works_for_simple_expr() {
89 check_assist(add_explicit_type, "fn f() { let a<|> = 1; }", "fn f() { let a: i32 = 1; }"); 89 check_assist(add_explicit_type, "fn f() { let a$0 = 1; }", "fn f() { let a: i32 = 1; }");
90 } 90 }
91 91
92 #[test] 92 #[test]
93 fn add_explicit_type_works_for_underscore() { 93 fn add_explicit_type_works_for_underscore() {
94 check_assist( 94 check_assist(add_explicit_type, "fn f() { let a$0: _ = 1; }", "fn f() { let a: i32 = 1; }");
95 add_explicit_type,
96 "fn f() { let a<|>: _ = 1; }",
97 "fn f() { let a: i32 = 1; }",
98 );
99 } 95 }
100 96
101 #[test] 97 #[test]
@@ -109,7 +105,7 @@ mod tests {
109 } 105 }
110 106
111 fn f() { 107 fn f() {
112 let a<|>: Option<_> = Option::Some(1); 108 let a$0: Option<_> = Option::Some(1);
113 }"#, 109 }"#,
114 r#" 110 r#"
115 enum Option<T> { 111 enum Option<T> {
@@ -127,7 +123,7 @@ mod tests {
127 fn add_explicit_type_works_for_macro_call() { 123 fn add_explicit_type_works_for_macro_call() {
128 check_assist( 124 check_assist(
129 add_explicit_type, 125 add_explicit_type,
130 r"macro_rules! v { () => {0u64} } fn f() { let a<|> = v!(); }", 126 r"macro_rules! v { () => {0u64} } fn f() { let a$0 = v!(); }",
131 r"macro_rules! v { () => {0u64} } fn f() { let a: u64 = v!(); }", 127 r"macro_rules! v { () => {0u64} } fn f() { let a: u64 = v!(); }",
132 ); 128 );
133 } 129 }
@@ -136,31 +132,31 @@ mod tests {
136 fn add_explicit_type_works_for_macro_call_recursive() { 132 fn add_explicit_type_works_for_macro_call_recursive() {
137 check_assist( 133 check_assist(
138 add_explicit_type, 134 add_explicit_type,
139 r#"macro_rules! u { () => {0u64} } macro_rules! v { () => {u!()} } fn f() { let a<|> = v!(); }"#, 135 r#"macro_rules! u { () => {0u64} } macro_rules! v { () => {u!()} } fn f() { let a$0 = v!(); }"#,
140 r#"macro_rules! u { () => {0u64} } macro_rules! v { () => {u!()} } fn f() { let a: u64 = v!(); }"#, 136 r#"macro_rules! u { () => {0u64} } macro_rules! v { () => {u!()} } fn f() { let a: u64 = v!(); }"#,
141 ); 137 );
142 } 138 }
143 139
144 #[test] 140 #[test]
145 fn add_explicit_type_not_applicable_if_ty_not_inferred() { 141 fn add_explicit_type_not_applicable_if_ty_not_inferred() {
146 check_assist_not_applicable(add_explicit_type, "fn f() { let a<|> = None; }"); 142 check_assist_not_applicable(add_explicit_type, "fn f() { let a$0 = None; }");
147 } 143 }
148 144
149 #[test] 145 #[test]
150 fn add_explicit_type_not_applicable_if_ty_already_specified() { 146 fn add_explicit_type_not_applicable_if_ty_already_specified() {
151 check_assist_not_applicable(add_explicit_type, "fn f() { let a<|>: i32 = 1; }"); 147 check_assist_not_applicable(add_explicit_type, "fn f() { let a$0: i32 = 1; }");
152 } 148 }
153 149
154 #[test] 150 #[test]
155 fn add_explicit_type_not_applicable_if_specified_ty_is_tuple() { 151 fn add_explicit_type_not_applicable_if_specified_ty_is_tuple() {
156 check_assist_not_applicable(add_explicit_type, "fn f() { let a<|>: (i32, i32) = (3, 4); }"); 152 check_assist_not_applicable(add_explicit_type, "fn f() { let a$0: (i32, i32) = (3, 4); }");
157 } 153 }
158 154
159 #[test] 155 #[test]
160 fn add_explicit_type_not_applicable_if_cursor_after_equals() { 156 fn add_explicit_type_not_applicable_if_cursor_after_equals() {
161 check_assist_not_applicable( 157 check_assist_not_applicable(
162 add_explicit_type, 158 add_explicit_type,
163 "fn f() {let a =<|> match 1 {2 => 3, 3 => 5};}", 159 "fn f() {let a =$0 match 1 {2 => 3, 3 => 5};}",
164 ) 160 )
165 } 161 }
166 162
@@ -168,7 +164,7 @@ mod tests {
168 fn add_explicit_type_not_applicable_if_cursor_before_let() { 164 fn add_explicit_type_not_applicable_if_cursor_before_let() {
169 check_assist_not_applicable( 165 check_assist_not_applicable(
170 add_explicit_type, 166 add_explicit_type,
171 "fn f() <|>{let a = match 1 {2 => 3, 3 => 5};}", 167 "fn f() $0{let a = match 1 {2 => 3, 3 => 5};}",
172 ) 168 )
173 } 169 }
174 170
@@ -178,7 +174,7 @@ mod tests {
178 add_explicit_type, 174 add_explicit_type,
179 r#" 175 r#"
180fn main() { 176fn main() {
181 let multiply_by_two<|> = |i| i * 3; 177 let multiply_by_two$0 = |i| i * 3;
182 let six = multiply_by_two(2); 178 let six = multiply_by_two(2);
183}"#, 179}"#,
184 ) 180 )
@@ -195,7 +191,7 @@ struct Test<K, T = u8> {
195} 191}
196 192
197fn main() { 193fn main() {
198 let test<|> = Test { t: 23u8, k: 33 }; 194 let test$0 = Test { t: 23u8, k: 33 };
199}"#, 195}"#,
200 r#" 196 r#"
201struct Test<K, T = u8> { 197struct Test<K, T = u8> {
diff --git a/crates/assists/src/handlers/add_missing_impl_members.rs b/crates/assists/src/handlers/add_missing_impl_members.rs
index 7df05b841..63cea754d 100644
--- a/crates/assists/src/handlers/add_missing_impl_members.rs
+++ b/crates/assists/src/handlers/add_missing_impl_members.rs
@@ -20,7 +20,7 @@ use crate::{
20// fn bar(&self) {} 20// fn bar(&self) {}
21// } 21// }
22// 22//
23// impl Trait<u32> for () {<|> 23// impl Trait<u32> for () {$0
24// 24//
25// } 25// }
26// ``` 26// ```
@@ -63,7 +63,7 @@ pub(crate) fn add_missing_impl_members(acc: &mut Assists, ctx: &AssistContext) -
63// 63//
64// impl Trait for () { 64// impl Trait for () {
65// type X = (); 65// type X = ();
66// fn foo(&self) {}<|> 66// fn foo(&self) {}$0
67// 67//
68// } 68// }
69// ``` 69// ```
@@ -166,7 +166,7 @@ struct S;
166 166
167impl Foo for S { 167impl Foo for S {
168 fn bar(&self) {} 168 fn bar(&self) {}
169<|> 169$0
170}"#, 170}"#,
171 r#" 171 r#"
172trait Foo { 172trait Foo {
@@ -214,7 +214,7 @@ struct S;
214 214
215impl Foo for S { 215impl Foo for S {
216 fn bar(&self) {} 216 fn bar(&self) {}
217<|> 217$0
218}"#, 218}"#,
219 r#" 219 r#"
220trait Foo { 220trait Foo {
@@ -242,7 +242,7 @@ impl Foo for S {
242 r#" 242 r#"
243trait Foo { fn foo(&self); } 243trait Foo { fn foo(&self); }
244struct S; 244struct S;
245impl Foo for S { <|> }"#, 245impl Foo for S { $0 }"#,
246 r#" 246 r#"
247trait Foo { fn foo(&self); } 247trait Foo { fn foo(&self); }
248struct S; 248struct S;
@@ -261,7 +261,7 @@ impl Foo for S {
261 r#" 261 r#"
262trait Foo { fn foo(&self); } 262trait Foo { fn foo(&self); }
263struct S; 263struct S;
264impl Foo for S<|>"#, 264impl Foo for S$0"#,
265 r#" 265 r#"
266trait Foo { fn foo(&self); } 266trait Foo { fn foo(&self); }
267struct S; 267struct S;
@@ -280,7 +280,7 @@ impl Foo for S {
280 r#" 280 r#"
281trait Foo<T> { fn foo(&self, t: T) -> &T; } 281trait Foo<T> { fn foo(&self, t: T) -> &T; }
282struct S; 282struct S;
283impl Foo<u32> for S { <|> }"#, 283impl Foo<u32> for S { $0 }"#,
284 r#" 284 r#"
285trait Foo<T> { fn foo(&self, t: T) -> &T; } 285trait Foo<T> { fn foo(&self, t: T) -> &T; }
286struct S; 286struct S;
@@ -299,7 +299,7 @@ impl Foo<u32> for S {
299 r#" 299 r#"
300trait Foo<T> { fn foo(&self, t: T) -> &T; } 300trait Foo<T> { fn foo(&self, t: T) -> &T; }
301struct S; 301struct S;
302impl<U> Foo<U> for S { <|> }"#, 302impl<U> Foo<U> for S { $0 }"#,
303 r#" 303 r#"
304trait Foo<T> { fn foo(&self, t: T) -> &T; } 304trait Foo<T> { fn foo(&self, t: T) -> &T; }
305struct S; 305struct S;
@@ -318,7 +318,7 @@ impl<U> Foo<U> for S {
318 r#" 318 r#"
319trait Foo { fn foo(&self); } 319trait Foo { fn foo(&self); }
320struct S; 320struct S;
321impl Foo for S {}<|>"#, 321impl Foo for S {}$0"#,
322 r#" 322 r#"
323trait Foo { fn foo(&self); } 323trait Foo { fn foo(&self); }
324struct S; 324struct S;
@@ -340,7 +340,7 @@ mod foo {
340 trait Foo { fn foo(&self, bar: Bar); } 340 trait Foo { fn foo(&self, bar: Bar); }
341} 341}
342struct S; 342struct S;
343impl foo::Foo for S { <|> }"#, 343impl foo::Foo for S { $0 }"#,
344 r#" 344 r#"
345mod foo { 345mod foo {
346 pub struct Bar; 346 pub struct Bar;
@@ -370,7 +370,7 @@ mod foo {
370use foo::bar; 370use foo::bar;
371 371
372struct S; 372struct S;
373impl bar::Foo for S { <|> }"#, 373impl bar::Foo for S { $0 }"#,
374 r#" 374 r#"
375mod foo { 375mod foo {
376 pub mod bar { 376 pub mod bar {
@@ -400,7 +400,7 @@ mod foo {
400 trait Foo { fn foo(&self, bar: Bar<u32>); } 400 trait Foo { fn foo(&self, bar: Bar<u32>); }
401} 401}
402struct S; 402struct S;
403impl foo::Foo for S { <|> }"#, 403impl foo::Foo for S { $0 }"#,
404 r#" 404 r#"
405mod foo { 405mod foo {
406 pub struct Bar<T>; 406 pub struct Bar<T>;
@@ -425,7 +425,7 @@ mod foo {
425 trait Foo<T> { fn foo(&self, bar: Bar<T>); } 425 trait Foo<T> { fn foo(&self, bar: Bar<T>); }
426} 426}
427struct S; 427struct S;
428impl foo::Foo<u32> for S { <|> }"#, 428impl foo::Foo<u32> for S { $0 }"#,
429 r#" 429 r#"
430mod foo { 430mod foo {
431 pub struct Bar<T>; 431 pub struct Bar<T>;
@@ -452,7 +452,7 @@ mod foo {
452} 452}
453struct Param; 453struct Param;
454struct S; 454struct S;
455impl foo::Foo<Param> for S { <|> }"#, 455impl foo::Foo<Param> for S { $0 }"#,
456 r#" 456 r#"
457mod foo { 457mod foo {
458 trait Foo<T> { fn foo(&self, bar: T); } 458 trait Foo<T> { fn foo(&self, bar: T); }
@@ -479,7 +479,7 @@ mod foo {
479 trait Foo { fn foo(&self, bar: Bar<u32>::Assoc); } 479 trait Foo { fn foo(&self, bar: Bar<u32>::Assoc); }
480} 480}
481struct S; 481struct S;
482impl foo::Foo for S { <|> }"#, 482impl foo::Foo for S { $0 }"#,
483 r#" 483 r#"
484mod foo { 484mod foo {
485 pub struct Bar<T>; 485 pub struct Bar<T>;
@@ -506,7 +506,7 @@ mod foo {
506 trait Foo { fn foo(&self, bar: Bar<Baz>); } 506 trait Foo { fn foo(&self, bar: Bar<Baz>); }
507} 507}
508struct S; 508struct S;
509impl foo::Foo for S { <|> }"#, 509impl foo::Foo for S { $0 }"#,
510 r#" 510 r#"
511mod foo { 511mod foo {
512 pub struct Bar<T>; 512 pub struct Bar<T>;
@@ -532,7 +532,7 @@ mod foo {
532 trait Foo { fn foo(&self, bar: dyn Fn(u32) -> i32); } 532 trait Foo { fn foo(&self, bar: dyn Fn(u32) -> i32); }
533} 533}
534struct S; 534struct S;
535impl foo::Foo for S { <|> }"#, 535impl foo::Foo for S { $0 }"#,
536 r#" 536 r#"
537mod foo { 537mod foo {
538 pub trait Fn<Args> { type Output; } 538 pub trait Fn<Args> { type Output; }
@@ -554,7 +554,7 @@ impl foo::Foo for S {
554 r#" 554 r#"
555trait Foo; 555trait Foo;
556struct S; 556struct S;
557impl Foo for S { <|> }"#, 557impl Foo for S { $0 }"#,
558 ) 558 )
559 } 559 }
560 560
@@ -568,7 +568,7 @@ trait Foo {
568 fn valid(some: u32) -> bool { false } 568 fn valid(some: u32) -> bool { false }
569} 569}
570struct S; 570struct S;
571impl Foo for S { <|> }"#, 571impl Foo for S { $0 }"#,
572 ) 572 )
573 } 573 }
574 574
@@ -586,7 +586,7 @@ trait Foo {
586 fn foo(&self); 586 fn foo(&self);
587} 587}
588struct S; 588struct S;
589impl Foo for S {}<|>"#, 589impl Foo for S {}$0"#,
590 r#" 590 r#"
591#[doc(alias = "test alias")] 591#[doc(alias = "test alias")]
592trait Foo { 592trait Foo {
@@ -621,7 +621,7 @@ trait Foo {
621 fn foo(some: u32) -> bool; 621 fn foo(some: u32) -> bool;
622} 622}
623struct S; 623struct S;
624impl Foo for S { <|> }"#, 624impl Foo for S { $0 }"#,
625 r#" 625 r#"
626trait Foo { 626trait Foo {
627 type Output; 627 type Output;
@@ -648,7 +648,7 @@ trait Foo<T = Self> {
648} 648}
649 649
650struct S; 650struct S;
651impl Foo for S { <|> }"#, 651impl Foo for S { $0 }"#,
652 r#" 652 r#"
653trait Foo<T = Self> { 653trait Foo<T = Self> {
654 fn bar(&self, other: &T); 654 fn bar(&self, other: &T);
@@ -673,7 +673,7 @@ trait Foo<T1, T2 = Self> {
673} 673}
674 674
675struct S<T>; 675struct S<T>;
676impl Foo<T> for S<T> { <|> }"#, 676impl Foo<T> for S<T> { $0 }"#,
677 r#" 677 r#"
678trait Foo<T1, T2 = Self> { 678trait Foo<T1, T2 = Self> {
679 fn bar(&self, this: &T1, that: &T2); 679 fn bar(&self, this: &T1, that: &T2);
@@ -697,7 +697,7 @@ trait Tr {
697 type Ty: Copy + 'static; 697 type Ty: Copy + 'static;
698} 698}
699 699
700impl Tr for ()<|> { 700impl Tr for ()$0 {
701}"#, 701}"#,
702 r#" 702 r#"
703trait Tr { 703trait Tr {
@@ -719,7 +719,7 @@ trait Tr {
719 fn foo(); 719 fn foo();
720} 720}
721 721
722impl Tr for ()<|> { 722impl Tr for ()$0 {
723 +++ 723 +++
724}"#, 724}"#,
725 r#" 725 r#"
@@ -745,7 +745,7 @@ trait Tr {
745 fn foo(); 745 fn foo();
746} 746}
747 747
748impl Tr for ()<|> { 748impl Tr for ()$0 {
749 // very important 749 // very important
750}"#, 750}"#,
751 r#" 751 r#"
@@ -771,7 +771,7 @@ trait Test {
771 fn foo(&self, x: crate) 771 fn foo(&self, x: crate)
772} 772}
773impl Test for () { 773impl Test for () {
774 <|> 774 $0
775} 775}
776"#, 776"#,
777 r#" 777 r#"
@@ -796,7 +796,7 @@ trait Foo<BAR> {
796 fn foo(&self, bar: BAR); 796 fn foo(&self, bar: BAR);
797} 797}
798impl Foo for () { 798impl Foo for () {
799 <|> 799 $0
800} 800}
801"#, 801"#,
802 r#" 802 r#"
diff --git a/crates/assists/src/handlers/add_turbo_fish.rs b/crates/assists/src/handlers/add_turbo_fish.rs
index 1f486c013..8e9ea4fad 100644
--- a/crates/assists/src/handlers/add_turbo_fish.rs
+++ b/crates/assists/src/handlers/add_turbo_fish.rs
@@ -14,7 +14,7 @@ use crate::{
14// ``` 14// ```
15// fn make<T>() -> T { todo!() } 15// fn make<T>() -> T { todo!() }
16// fn main() { 16// fn main() {
17// let x = make<|>(); 17// let x = make$0();
18// } 18// }
19// ``` 19// ```
20// -> 20// ->
@@ -77,7 +77,7 @@ mod tests {
77 r#" 77 r#"
78fn make<T>() -> T {} 78fn make<T>() -> T {}
79fn main() { 79fn main() {
80 make<|>(); 80 make$0();
81} 81}
82"#, 82"#,
83 r#" 83 r#"
@@ -97,7 +97,7 @@ fn main() {
97 r#" 97 r#"
98fn make<T>() -> T {} 98fn make<T>() -> T {}
99fn main() { 99fn main() {
100 make()<|>; 100 make()$0;
101} 101}
102"#, 102"#,
103 r#" 103 r#"
@@ -119,7 +119,7 @@ impl S {
119 fn make<T>(&self) -> T {} 119 fn make<T>(&self) -> T {}
120} 120}
121fn main() { 121fn main() {
122 S.make<|>(); 122 S.make$0();
123} 123}
124"#, 124"#,
125 r#" 125 r#"
@@ -142,7 +142,7 @@ fn main() {
142 r#" 142 r#"
143fn make<T>() -> T {} 143fn make<T>() -> T {}
144fn main() { 144fn main() {
145 make<|>::<()>(); 145 make$0::<()>();
146} 146}
147"#, 147"#,
148 ); 148 );
@@ -156,7 +156,7 @@ fn main() {
156 r#" 156 r#"
157fn make() -> () {} 157fn make() -> () {}
158fn main() { 158fn main() {
159 make<|>(); 159 make$0();
160} 160}
161"#, 161"#,
162 ); 162 );
diff --git a/crates/assists/src/handlers/apply_demorgan.rs b/crates/assists/src/handlers/apply_demorgan.rs
index 1a6fdafda..ed4d11455 100644
--- a/crates/assists/src/handlers/apply_demorgan.rs
+++ b/crates/assists/src/handlers/apply_demorgan.rs
@@ -12,7 +12,7 @@ use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKin
12// 12//
13// ``` 13// ```
14// fn main() { 14// fn main() {
15// if x != 4 ||<|> !y {} 15// if x != 4 ||$0 !y {}
16// } 16// }
17// ``` 17// ```
18// -> 18// ->
@@ -68,26 +68,26 @@ mod tests {
68 68
69 #[test] 69 #[test]
70 fn demorgan_turns_and_into_or() { 70 fn demorgan_turns_and_into_or() {
71 check_assist(apply_demorgan, "fn f() { !x &&<|> !x }", "fn f() { !(x || x) }") 71 check_assist(apply_demorgan, "fn f() { !x &&$0 !x }", "fn f() { !(x || x) }")
72 } 72 }
73 73
74 #[test] 74 #[test]
75 fn demorgan_turns_or_into_and() { 75 fn demorgan_turns_or_into_and() {
76 check_assist(apply_demorgan, "fn f() { !x ||<|> !x }", "fn f() { !(x && x) }") 76 check_assist(apply_demorgan, "fn f() { !x ||$0 !x }", "fn f() { !(x && x) }")
77 } 77 }
78 78
79 #[test] 79 #[test]
80 fn demorgan_removes_inequality() { 80 fn demorgan_removes_inequality() {
81 check_assist(apply_demorgan, "fn f() { x != x ||<|> !x }", "fn f() { !(x == x && x) }") 81 check_assist(apply_demorgan, "fn f() { x != x ||$0 !x }", "fn f() { !(x == x && x) }")
82 } 82 }
83 83
84 #[test] 84 #[test]
85 fn demorgan_general_case() { 85 fn demorgan_general_case() {
86 check_assist(apply_demorgan, "fn f() { x ||<|> x }", "fn f() { !(!x && !x) }") 86 check_assist(apply_demorgan, "fn f() { x ||$0 x }", "fn f() { !(!x && !x) }")
87 } 87 }
88 88
89 #[test] 89 #[test]
90 fn demorgan_doesnt_apply_with_cursor_not_on_op() { 90 fn demorgan_doesnt_apply_with_cursor_not_on_op() {
91 check_assist_not_applicable(apply_demorgan, "fn f() { <|> !x || !x }") 91 check_assist_not_applicable(apply_demorgan, "fn f() { $0 !x || !x }")
92 } 92 }
93} 93}
diff --git a/crates/assists/src/handlers/auto_import.rs b/crates/assists/src/handlers/auto_import.rs
index bd5bba646..4e2a4fcd9 100644
--- a/crates/assists/src/handlers/auto_import.rs
+++ b/crates/assists/src/handlers/auto_import.rs
@@ -1,13 +1,11 @@
1use ide_db::helpers::{ 1use ide_db::helpers::{
2 import_assets::{ImportAssets, ImportCandidate},
2 insert_use::{insert_use, ImportScope}, 3 insert_use::{insert_use, ImportScope},
3 mod_path_to_ast, 4 mod_path_to_ast,
4}; 5};
5use syntax::ast; 6use syntax::ast;
6 7
7use crate::{ 8use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
8 utils::import_assets::{ImportAssets, ImportCandidate},
9 AssistContext, AssistId, AssistKind, Assists, GroupLabel,
10};
11 9
12// Feature: Auto Import 10// Feature: Auto Import
13// 11//
@@ -70,7 +68,7 @@ use crate::{
70// 68//
71// ``` 69// ```
72// fn main() { 70// fn main() {
73// let map = HashMap<|>::new(); 71// let map = HashMap$0::new();
74// } 72// }
75// # pub mod std { pub mod collections { pub struct HashMap { } } } 73// # pub mod std { pub mod collections { pub struct HashMap { } } }
76// ``` 74// ```
@@ -121,8 +119,7 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
121 119
122fn import_group_message(import_candidate: &ImportCandidate) -> GroupLabel { 120fn import_group_message(import_candidate: &ImportCandidate) -> GroupLabel {
123 let name = match import_candidate { 121 let name = match import_candidate {
124 ImportCandidate::UnqualifiedName(candidate) 122 ImportCandidate::Path(candidate) => format!("Import {}", &candidate.name),
125 | ImportCandidate::QualifierStart(candidate) => format!("Import {}", &candidate.name),
126 ImportCandidate::TraitAssocItem(candidate) => { 123 ImportCandidate::TraitAssocItem(candidate) => {
127 format!("Import a trait for item {}", &candidate.name) 124 format!("Import a trait for item {}", &candidate.name)
128 } 125 }
@@ -151,7 +148,7 @@ mod tests {
151 148
152 use std::fmt; 149 use std::fmt;
153 150
154 <|>Formatter 151 $0Formatter
155 ", 152 ",
156 r" 153 r"
157 mod std { 154 mod std {
@@ -172,7 +169,7 @@ mod tests {
172 check_assist( 169 check_assist(
173 auto_import, 170 auto_import,
174 r" 171 r"
175 <|>PubStruct 172 $0PubStruct
176 173
177 pub mod PubMod { 174 pub mod PubMod {
178 pub struct PubStruct; 175 pub struct PubStruct;
@@ -198,7 +195,7 @@ mod tests {
198 macro_rules! foo { 195 macro_rules! foo {
199 ($i:ident) => { fn foo(a: $i) {} } 196 ($i:ident) => { fn foo(a: $i) {} }
200 } 197 }
201 foo!(Pub<|>Struct); 198 foo!(Pub$0Struct);
202 199
203 pub mod PubMod { 200 pub mod PubMod {
204 pub struct PubStruct; 201 pub struct PubStruct;
@@ -227,7 +224,7 @@ mod tests {
227 use PubMod::PubStruct1; 224 use PubMod::PubStruct1;
228 225
229 struct Test { 226 struct Test {
230 test: Pub<|>Struct2<u8>, 227 test: Pub$0Struct2<u8>,
231 } 228 }
232 229
233 pub mod PubMod { 230 pub mod PubMod {
@@ -259,7 +256,7 @@ mod tests {
259 check_assist( 256 check_assist(
260 auto_import, 257 auto_import,
261 r" 258 r"
262 PubSt<|>ruct 259 PubSt$0ruct
263 260
264 pub mod PubMod1 { 261 pub mod PubMod1 {
265 pub struct PubStruct; 262 pub struct PubStruct;
@@ -296,7 +293,7 @@ mod tests {
296 r" 293 r"
297 use PubMod::PubStruct; 294 use PubMod::PubStruct;
298 295
299 PubStruct<|> 296 PubStruct$0
300 297
301 pub mod PubMod { 298 pub mod PubMod {
302 pub struct PubStruct; 299 pub struct PubStruct;
@@ -310,7 +307,7 @@ mod tests {
310 check_assist_not_applicable( 307 check_assist_not_applicable(
311 auto_import, 308 auto_import,
312 r" 309 r"
313 PrivateStruct<|> 310 PrivateStruct$0
314 311
315 pub mod PubMod { 312 pub mod PubMod {
316 struct PrivateStruct; 313 struct PrivateStruct;
@@ -324,7 +321,7 @@ mod tests {
324 check_assist_not_applicable( 321 check_assist_not_applicable(
325 auto_import, 322 auto_import,
326 " 323 "
327 PubStruct<|>", 324 PubStruct$0",
328 ); 325 );
329 } 326 }
330 327
@@ -333,7 +330,7 @@ mod tests {
333 check_assist_not_applicable( 330 check_assist_not_applicable(
334 auto_import, 331 auto_import,
335 r" 332 r"
336 use PubStruct<|>; 333 use PubStruct$0;
337 334
338 pub mod PubMod { 335 pub mod PubMod {
339 pub struct PubStruct; 336 pub struct PubStruct;
@@ -346,7 +343,7 @@ mod tests {
346 check_assist( 343 check_assist(
347 auto_import, 344 auto_import,
348 r" 345 r"
349 test_function<|> 346 test_function$0
350 347
351 pub mod PubMod { 348 pub mod PubMod {
352 pub fn test_function() {}; 349 pub fn test_function() {};
@@ -377,7 +374,7 @@ macro_rules! foo {
377 374
378//- /main.rs crate:main deps:crate_with_macro 375//- /main.rs crate:main deps:crate_with_macro
379fn main() { 376fn main() {
380 foo<|> 377 foo$0
381} 378}
382", 379",
383 r"use crate_with_macro::foo; 380 r"use crate_with_macro::foo;
@@ -395,7 +392,7 @@ fn main() {
395 auto_import, 392 auto_import,
396 r" 393 r"
397 struct AssistInfo { 394 struct AssistInfo {
398 group_label: Option<<|>GroupLabel>, 395 group_label: Option<$0GroupLabel>,
399 } 396 }
400 397
401 mod m { pub struct GroupLabel; } 398 mod m { pub struct GroupLabel; }
@@ -419,7 +416,7 @@ fn main() {
419 416
420 use mod1::mod2; 417 use mod1::mod2;
421 fn main() { 418 fn main() {
422 mod2::mod3::TestStruct<|> 419 mod2::mod3::TestStruct$0
423 } 420 }
424 ", 421 ",
425 ); 422 );
@@ -436,7 +433,7 @@ fn main() {
436 433
437 use test_mod::test_function; 434 use test_mod::test_function;
438 fn main() { 435 fn main() {
439 test_function<|> 436 test_function$0
440 } 437 }
441 ", 438 ",
442 ); 439 );
@@ -455,7 +452,7 @@ fn main() {
455 } 452 }
456 453
457 fn main() { 454 fn main() {
458 TestStruct::test_function<|> 455 TestStruct::test_function$0
459 } 456 }
460 ", 457 ",
461 r" 458 r"
@@ -488,7 +485,7 @@ fn main() {
488 } 485 }
489 486
490 fn main() { 487 fn main() {
491 TestStruct::TEST_CONST<|> 488 TestStruct::TEST_CONST$0
492 } 489 }
493 ", 490 ",
494 r" 491 r"
@@ -524,7 +521,7 @@ fn main() {
524 } 521 }
525 522
526 fn main() { 523 fn main() {
527 test_mod::TestStruct::test_function<|> 524 test_mod::TestStruct::test_function$0
528 } 525 }
529 ", 526 ",
530 r" 527 r"
@@ -573,7 +570,7 @@ fn main() {
573 570
574 use test_mod::TestTrait2; 571 use test_mod::TestTrait2;
575 fn main() { 572 fn main() {
576 test_mod::TestEnum::test_function<|>; 573 test_mod::TestEnum::test_function$0;
577 } 574 }
578 ", 575 ",
579 ) 576 )
@@ -595,7 +592,7 @@ fn main() {
595 } 592 }
596 593
597 fn main() { 594 fn main() {
598 test_mod::TestStruct::TEST_CONST<|> 595 test_mod::TestStruct::TEST_CONST$0
599 } 596 }
600 ", 597 ",
601 r" 598 r"
@@ -644,7 +641,7 @@ fn main() {
644 641
645 use test_mod::TestTrait2; 642 use test_mod::TestTrait2;
646 fn main() { 643 fn main() {
647 test_mod::TestEnum::TEST_CONST<|>; 644 test_mod::TestEnum::TEST_CONST$0;
648 } 645 }
649 ", 646 ",
650 ) 647 )
@@ -667,7 +664,7 @@ fn main() {
667 664
668 fn main() { 665 fn main() {
669 let test_struct = test_mod::TestStruct {}; 666 let test_struct = test_mod::TestStruct {};
670 test_struct.test_meth<|>od() 667 test_struct.test_meth$0od()
671 } 668 }
672 ", 669 ",
673 r" 670 r"
@@ -699,7 +696,7 @@ fn main() {
699 //- /main.rs crate:main deps:dep 696 //- /main.rs crate:main deps:dep
700 fn main() { 697 fn main() {
701 let test_struct = dep::test_mod::TestStruct {}; 698 let test_struct = dep::test_mod::TestStruct {};
702 test_struct.test_meth<|>od() 699 test_struct.test_meth$0od()
703 } 700 }
704 //- /dep.rs crate:dep 701 //- /dep.rs crate:dep
705 pub mod test_mod { 702 pub mod test_mod {
@@ -730,7 +727,7 @@ fn main() {
730 r" 727 r"
731 //- /main.rs crate:main deps:dep 728 //- /main.rs crate:main deps:dep
732 fn main() { 729 fn main() {
733 dep::test_mod::TestStruct::test_func<|>tion 730 dep::test_mod::TestStruct::test_func$0tion
734 } 731 }
735 //- /dep.rs crate:dep 732 //- /dep.rs crate:dep
736 pub mod test_mod { 733 pub mod test_mod {
@@ -760,7 +757,7 @@ fn main() {
760 r" 757 r"
761 //- /main.rs crate:main deps:dep 758 //- /main.rs crate:main deps:dep
762 fn main() { 759 fn main() {
763 dep::test_mod::TestStruct::CONST<|> 760 dep::test_mod::TestStruct::CONST$0
764 } 761 }
765 //- /dep.rs crate:dep 762 //- /dep.rs crate:dep
766 pub mod test_mod { 763 pub mod test_mod {
@@ -791,7 +788,7 @@ fn main() {
791 //- /main.rs crate:main deps:dep 788 //- /main.rs crate:main deps:dep
792 fn main() { 789 fn main() {
793 let test_struct = dep::test_mod::TestStruct {}; 790 let test_struct = dep::test_mod::TestStruct {};
794 test_struct.test_func<|>tion() 791 test_struct.test_func$0tion()
795 } 792 }
796 //- /dep.rs crate:dep 793 //- /dep.rs crate:dep
797 pub mod test_mod { 794 pub mod test_mod {
@@ -815,7 +812,7 @@ fn main() {
815 //- /main.rs crate:main deps:dep 812 //- /main.rs crate:main deps:dep
816 fn main() { 813 fn main() {
817 let test_struct = dep::test_mod::TestStruct {}; 814 let test_struct = dep::test_mod::TestStruct {};
818 test_struct.test_meth<|>od() 815 test_struct.test_meth$0od()
819 } 816 }
820 //- /dep.rs crate:dep 817 //- /dep.rs crate:dep
821 pub mod test_mod { 818 pub mod test_mod {
@@ -858,7 +855,7 @@ fn main() {
858 use test_mod::TestTrait2; 855 use test_mod::TestTrait2;
859 fn main() { 856 fn main() {
860 let one = test_mod::TestEnum::One; 857 let one = test_mod::TestEnum::One;
861 one.test<|>_method(); 858 one.test$0_method();
862 } 859 }
863 ", 860 ",
864 ) 861 )
@@ -874,7 +871,7 @@ pub struct Struct;
874 871
875//- /main.rs crate:main deps:dep 872//- /main.rs crate:main deps:dep
876fn main() { 873fn main() {
877 Struct<|> 874 Struct$0
878} 875}
879", 876",
880 r"use dep::Struct; 877 r"use dep::Struct;
@@ -902,7 +899,7 @@ pub fn panic_fmt() {}
902//- /main.rs crate:main deps:dep 899//- /main.rs crate:main deps:dep
903struct S; 900struct S;
904 901
905impl f<|>mt::Display for S {} 902impl f$0mt::Display for S {}
906", 903",
907 r"use dep::fmt; 904 r"use dep::fmt;
908 905
@@ -930,7 +927,7 @@ mac!();
930 927
931//- /main.rs crate:main deps:dep 928//- /main.rs crate:main deps:dep
932fn main() { 929fn main() {
933 Cheese<|>; 930 Cheese$0;
934} 931}
935", 932",
936 r"use dep::Cheese; 933 r"use dep::Cheese;
@@ -954,7 +951,7 @@ pub struct fmt;
954 951
955//- /main.rs crate:main deps:dep 952//- /main.rs crate:main deps:dep
956fn main() { 953fn main() {
957 FMT<|>; 954 FMT$0;
958} 955}
959", 956",
960 r"use dep::FMT; 957 r"use dep::FMT;
diff --git a/crates/assists/src/handlers/change_visibility.rs b/crates/assists/src/handlers/change_visibility.rs
index 22d7c95d9..ac8c44124 100644
--- a/crates/assists/src/handlers/change_visibility.rs
+++ b/crates/assists/src/handlers/change_visibility.rs
@@ -13,7 +13,7 @@ use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists};
13// Adds or changes existing visibility specifier. 13// Adds or changes existing visibility specifier.
14// 14//
15// ``` 15// ```
16// <|>fn frobnicate() {} 16// $0fn frobnicate() {}
17// ``` 17// ```
18// -> 18// ->
19// ``` 19// ```
@@ -118,23 +118,23 @@ mod tests {
118 118
119 #[test] 119 #[test]
120 fn change_visibility_adds_pub_crate_to_items() { 120 fn change_visibility_adds_pub_crate_to_items() {
121 check_assist(change_visibility, "<|>fn foo() {}", "pub(crate) fn foo() {}"); 121 check_assist(change_visibility, "$0fn foo() {}", "pub(crate) fn foo() {}");
122 check_assist(change_visibility, "f<|>n foo() {}", "pub(crate) fn foo() {}"); 122 check_assist(change_visibility, "f$0n foo() {}", "pub(crate) fn foo() {}");
123 check_assist(change_visibility, "<|>struct Foo {}", "pub(crate) struct Foo {}"); 123 check_assist(change_visibility, "$0struct Foo {}", "pub(crate) struct Foo {}");
124 check_assist(change_visibility, "<|>mod foo {}", "pub(crate) mod foo {}"); 124 check_assist(change_visibility, "$0mod foo {}", "pub(crate) mod foo {}");
125 check_assist(change_visibility, "<|>trait Foo {}", "pub(crate) trait Foo {}"); 125 check_assist(change_visibility, "$0trait Foo {}", "pub(crate) trait Foo {}");
126 check_assist(change_visibility, "m<|>od {}", "pub(crate) mod {}"); 126 check_assist(change_visibility, "m$0od {}", "pub(crate) mod {}");
127 check_assist(change_visibility, "unsafe f<|>n foo() {}", "pub(crate) unsafe fn foo() {}"); 127 check_assist(change_visibility, "unsafe f$0n foo() {}", "pub(crate) unsafe fn foo() {}");
128 } 128 }
129 129
130 #[test] 130 #[test]
131 fn change_visibility_works_with_struct_fields() { 131 fn change_visibility_works_with_struct_fields() {
132 check_assist( 132 check_assist(
133 change_visibility, 133 change_visibility,
134 r"struct S { <|>field: u32 }", 134 r"struct S { $0field: u32 }",
135 r"struct S { pub(crate) field: u32 }", 135 r"struct S { pub(crate) field: u32 }",
136 ); 136 );
137 check_assist(change_visibility, r"struct S ( <|>u32 )", r"struct S ( pub(crate) u32 )"); 137 check_assist(change_visibility, r"struct S ( $0u32 )", r"struct S ( pub(crate) u32 )");
138 } 138 }
139 139
140 #[test] 140 #[test]
@@ -142,33 +142,33 @@ mod tests {
142 mark::check!(change_visibility_field_false_positive); 142 mark::check!(change_visibility_field_false_positive);
143 check_assist_not_applicable( 143 check_assist_not_applicable(
144 change_visibility, 144 change_visibility,
145 r"struct S { field: [(); { let <|>x = ();}] }", 145 r"struct S { field: [(); { let $0x = ();}] }",
146 ) 146 )
147 } 147 }
148 148
149 #[test] 149 #[test]
150 fn change_visibility_pub_to_pub_crate() { 150 fn change_visibility_pub_to_pub_crate() {
151 check_assist(change_visibility, "<|>pub fn foo() {}", "pub(crate) fn foo() {}") 151 check_assist(change_visibility, "$0pub fn foo() {}", "pub(crate) fn foo() {}")
152 } 152 }
153 153
154 #[test] 154 #[test]
155 fn change_visibility_pub_crate_to_pub() { 155 fn change_visibility_pub_crate_to_pub() {
156 check_assist(change_visibility, "<|>pub(crate) fn foo() {}", "pub fn foo() {}") 156 check_assist(change_visibility, "$0pub(crate) fn foo() {}", "pub fn foo() {}")
157 } 157 }
158 158
159 #[test] 159 #[test]
160 fn change_visibility_const() { 160 fn change_visibility_const() {
161 check_assist(change_visibility, "<|>const FOO = 3u8;", "pub(crate) const FOO = 3u8;"); 161 check_assist(change_visibility, "$0const FOO = 3u8;", "pub(crate) const FOO = 3u8;");
162 } 162 }
163 163
164 #[test] 164 #[test]
165 fn change_visibility_static() { 165 fn change_visibility_static() {
166 check_assist(change_visibility, "<|>static FOO = 3u8;", "pub(crate) static FOO = 3u8;"); 166 check_assist(change_visibility, "$0static FOO = 3u8;", "pub(crate) static FOO = 3u8;");
167 } 167 }
168 168
169 #[test] 169 #[test]
170 fn change_visibility_type_alias() { 170 fn change_visibility_type_alias() {
171 check_assist(change_visibility, "<|>type T = ();", "pub(crate) type T = ();"); 171 check_assist(change_visibility, "$0type T = ();", "pub(crate) type T = ();");
172 } 172 }
173 173
174 #[test] 174 #[test]
@@ -181,7 +181,7 @@ mod tests {
181 // comments 181 // comments
182 182
183 #[derive(Debug)] 183 #[derive(Debug)]
184 <|>struct Foo; 184 $0struct Foo;
185 ", 185 ",
186 r" 186 r"
187 /// docs 187 /// docs
@@ -199,14 +199,14 @@ mod tests {
199 check_assist_not_applicable( 199 check_assist_not_applicable(
200 change_visibility, 200 change_visibility,
201 r"mod foo { pub enum Foo {Foo1} } 201 r"mod foo { pub enum Foo {Foo1} }
202 fn main() { foo::Foo::Foo1<|> } ", 202 fn main() { foo::Foo::Foo1$0 } ",
203 ); 203 );
204 } 204 }
205 205
206 #[test] 206 #[test]
207 fn change_visibility_target() { 207 fn change_visibility_target() {
208 check_assist_target(change_visibility, "<|>fn foo() {}", "fn"); 208 check_assist_target(change_visibility, "$0fn foo() {}", "fn");
209 check_assist_target(change_visibility, "pub(crate)<|> fn foo() {}", "pub(crate)"); 209 check_assist_target(change_visibility, "pub(crate)$0 fn foo() {}", "pub(crate)");
210 check_assist_target(change_visibility, "struct S { <|>field: u32 }", "field"); 210 check_assist_target(change_visibility, "struct S { $0field: u32 }", "field");
211 } 211 }
212} 212}
diff --git a/crates/assists/src/handlers/convert_integer_literal.rs b/crates/assists/src/handlers/convert_integer_literal.rs
index 667115382..a8a819cfc 100644
--- a/crates/assists/src/handlers/convert_integer_literal.rs
+++ b/crates/assists/src/handlers/convert_integer_literal.rs
@@ -7,7 +7,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
7// Converts the base of integer literals to other bases. 7// Converts the base of integer literals to other bases.
8// 8//
9// ``` 9// ```
10// const _: i32 = 10<|>; 10// const _: i32 = 10$0;
11// ``` 11// ```
12// -> 12// ->
13// ``` 13// ```
@@ -65,47 +65,47 @@ mod tests {
65 65
66 #[test] 66 #[test]
67 fn binary_target() { 67 fn binary_target() {
68 check_assist_target(convert_integer_literal, "const _: i32 = 0b1010<|>;", "0b1010"); 68 check_assist_target(convert_integer_literal, "const _: i32 = 0b1010$0;", "0b1010");
69 } 69 }
70 70
71 #[test] 71 #[test]
72 fn octal_target() { 72 fn octal_target() {
73 check_assist_target(convert_integer_literal, "const _: i32 = 0o12<|>;", "0o12"); 73 check_assist_target(convert_integer_literal, "const _: i32 = 0o12$0;", "0o12");
74 } 74 }
75 75
76 #[test] 76 #[test]
77 fn decimal_target() { 77 fn decimal_target() {
78 check_assist_target(convert_integer_literal, "const _: i32 = 10<|>;", "10"); 78 check_assist_target(convert_integer_literal, "const _: i32 = 10$0;", "10");
79 } 79 }
80 80
81 #[test] 81 #[test]
82 fn hexadecimal_target() { 82 fn hexadecimal_target() {
83 check_assist_target(convert_integer_literal, "const _: i32 = 0xA<|>;", "0xA"); 83 check_assist_target(convert_integer_literal, "const _: i32 = 0xA$0;", "0xA");
84 } 84 }
85 85
86 #[test] 86 #[test]
87 fn binary_target_with_underscores() { 87 fn binary_target_with_underscores() {
88 check_assist_target(convert_integer_literal, "const _: i32 = 0b10_10<|>;", "0b10_10"); 88 check_assist_target(convert_integer_literal, "const _: i32 = 0b10_10$0;", "0b10_10");
89 } 89 }
90 90
91 #[test] 91 #[test]
92 fn octal_target_with_underscores() { 92 fn octal_target_with_underscores() {
93 check_assist_target(convert_integer_literal, "const _: i32 = 0o1_2<|>;", "0o1_2"); 93 check_assist_target(convert_integer_literal, "const _: i32 = 0o1_2$0;", "0o1_2");
94 } 94 }
95 95
96 #[test] 96 #[test]
97 fn decimal_target_with_underscores() { 97 fn decimal_target_with_underscores() {
98 check_assist_target(convert_integer_literal, "const _: i32 = 1_0<|>;", "1_0"); 98 check_assist_target(convert_integer_literal, "const _: i32 = 1_0$0;", "1_0");
99 } 99 }
100 100
101 #[test] 101 #[test]
102 fn hexadecimal_target_with_underscores() { 102 fn hexadecimal_target_with_underscores() {
103 check_assist_target(convert_integer_literal, "const _: i32 = 0x_A<|>;", "0x_A"); 103 check_assist_target(convert_integer_literal, "const _: i32 = 0x_A$0;", "0x_A");
104 } 104 }
105 105
106 #[test] 106 #[test]
107 fn convert_decimal_integer() { 107 fn convert_decimal_integer() {
108 let before = "const _: i32 = 1000<|>;"; 108 let before = "const _: i32 = 1000$0;";
109 109
110 check_assist_by_label( 110 check_assist_by_label(
111 convert_integer_literal, 111 convert_integer_literal,
@@ -131,7 +131,7 @@ mod tests {
131 131
132 #[test] 132 #[test]
133 fn convert_hexadecimal_integer() { 133 fn convert_hexadecimal_integer() {
134 let before = "const _: i32 = 0xFF<|>;"; 134 let before = "const _: i32 = 0xFF$0;";
135 135
136 check_assist_by_label( 136 check_assist_by_label(
137 convert_integer_literal, 137 convert_integer_literal,
@@ -157,7 +157,7 @@ mod tests {
157 157
158 #[test] 158 #[test]
159 fn convert_binary_integer() { 159 fn convert_binary_integer() {
160 let before = "const _: i32 = 0b11111111<|>;"; 160 let before = "const _: i32 = 0b11111111$0;";
161 161
162 check_assist_by_label( 162 check_assist_by_label(
163 convert_integer_literal, 163 convert_integer_literal,
@@ -183,7 +183,7 @@ mod tests {
183 183
184 #[test] 184 #[test]
185 fn convert_octal_integer() { 185 fn convert_octal_integer() {
186 let before = "const _: i32 = 0o377<|>;"; 186 let before = "const _: i32 = 0o377$0;";
187 187
188 check_assist_by_label( 188 check_assist_by_label(
189 convert_integer_literal, 189 convert_integer_literal,
@@ -209,7 +209,7 @@ mod tests {
209 209
210 #[test] 210 #[test]
211 fn convert_integer_with_underscores() { 211 fn convert_integer_with_underscores() {
212 let before = "const _: i32 = 1_00_0<|>;"; 212 let before = "const _: i32 = 1_00_0$0;";
213 213
214 check_assist_by_label( 214 check_assist_by_label(
215 convert_integer_literal, 215 convert_integer_literal,
@@ -235,7 +235,7 @@ mod tests {
235 235
236 #[test] 236 #[test]
237 fn convert_integer_with_suffix() { 237 fn convert_integer_with_suffix() {
238 let before = "const _: i32 = 1000i32<|>;"; 238 let before = "const _: i32 = 1000i32$0;";
239 239
240 check_assist_by_label( 240 check_assist_by_label(
241 convert_integer_literal, 241 convert_integer_literal,
@@ -262,7 +262,7 @@ mod tests {
262 #[test] 262 #[test]
263 fn convert_overflowing_literal() { 263 fn convert_overflowing_literal() {
264 let before = "const _: i32 = 264 let before = "const _: i32 =
265 111111111111111111111111111111111111111111111111111111111111111111111111<|>;"; 265 111111111111111111111111111111111111111111111111111111111111111111111111$0;";
266 check_assist_not_applicable(convert_integer_literal, before); 266 check_assist_not_applicable(convert_integer_literal, before);
267 } 267 }
268} 268}
diff --git a/crates/assists/src/handlers/early_return.rs b/crates/assists/src/handlers/early_return.rs
index 2c48f32bf..8bbbb7ed5 100644
--- a/crates/assists/src/handlers/early_return.rs
+++ b/crates/assists/src/handlers/early_return.rs
@@ -24,7 +24,7 @@ use crate::{
24// 24//
25// ``` 25// ```
26// fn main() { 26// fn main() {
27// <|>if cond { 27// $0if cond {
28// foo(); 28// foo();
29// bar(); 29// bar();
30// } 30// }
@@ -200,7 +200,7 @@ mod tests {
200 r#" 200 r#"
201 fn main() { 201 fn main() {
202 bar(); 202 bar();
203 if<|> true { 203 if$0 true {
204 foo(); 204 foo();
205 205
206 //comment 206 //comment
@@ -230,7 +230,7 @@ mod tests {
230 r#" 230 r#"
231 fn main(n: Option<String>) { 231 fn main(n: Option<String>) {
232 bar(); 232 bar();
233 if<|> let Some(n) = n { 233 if$0 let Some(n) = n {
234 foo(n); 234 foo(n);
235 235
236 //comment 236 //comment
@@ -260,7 +260,7 @@ mod tests {
260 convert_to_guarded_return, 260 convert_to_guarded_return,
261 r#" 261 r#"
262 fn main() { 262 fn main() {
263 if<|> let Ok(x) = Err(92) { 263 if$0 let Ok(x) = Err(92) {
264 foo(x); 264 foo(x);
265 } 265 }
266 } 266 }
@@ -284,7 +284,7 @@ mod tests {
284 r#" 284 r#"
285 fn main(n: Option<String>) { 285 fn main(n: Option<String>) {
286 bar(); 286 bar();
287 if<|> let Ok(n) = n { 287 if$0 let Ok(n) = n {
288 foo(n); 288 foo(n);
289 289
290 //comment 290 //comment
@@ -315,7 +315,7 @@ mod tests {
315 r#" 315 r#"
316 fn main() { 316 fn main() {
317 while true { 317 while true {
318 if<|> true { 318 if$0 true {
319 foo(); 319 foo();
320 bar(); 320 bar();
321 } 321 }
@@ -343,7 +343,7 @@ mod tests {
343 r#" 343 r#"
344 fn main() { 344 fn main() {
345 while true { 345 while true {
346 if<|> let Some(n) = n { 346 if$0 let Some(n) = n {
347 foo(n); 347 foo(n);
348 bar(); 348 bar();
349 } 349 }
@@ -372,7 +372,7 @@ mod tests {
372 r#" 372 r#"
373 fn main() { 373 fn main() {
374 loop { 374 loop {
375 if<|> true { 375 if$0 true {
376 foo(); 376 foo();
377 bar(); 377 bar();
378 } 378 }
@@ -400,7 +400,7 @@ mod tests {
400 r#" 400 r#"
401 fn main() { 401 fn main() {
402 loop { 402 loop {
403 if<|> let Some(n) = n { 403 if$0 let Some(n) = n {
404 foo(n); 404 foo(n);
405 bar(); 405 bar();
406 } 406 }
@@ -428,7 +428,7 @@ mod tests {
428 convert_to_guarded_return, 428 convert_to_guarded_return,
429 r#" 429 r#"
430 fn main() { 430 fn main() {
431 if<|> true { 431 if$0 true {
432 return; 432 return;
433 } 433 }
434 } 434 }
@@ -443,7 +443,7 @@ mod tests {
443 r#" 443 r#"
444 fn main() { 444 fn main() {
445 loop { 445 loop {
446 if<|> true { 446 if$0 true {
447 continue; 447 continue;
448 } 448 }
449 } 449 }
@@ -458,7 +458,7 @@ mod tests {
458 convert_to_guarded_return, 458 convert_to_guarded_return,
459 r#" 459 r#"
460 fn main() { 460 fn main() {
461 if<|> true { 461 if$0 true {
462 return 462 return
463 } 463 }
464 } 464 }
@@ -472,7 +472,7 @@ mod tests {
472 convert_to_guarded_return, 472 convert_to_guarded_return,
473 r#" 473 r#"
474 fn main() { 474 fn main() {
475 if<|> true { 475 if$0 true {
476 foo(); 476 foo();
477 } else { 477 } else {
478 bar() 478 bar()
@@ -488,7 +488,7 @@ mod tests {
488 convert_to_guarded_return, 488 convert_to_guarded_return,
489 r#" 489 r#"
490 fn main() { 490 fn main() {
491 if<|> true { 491 if$0 true {
492 foo(); 492 foo();
493 } 493 }
494 bar(); 494 bar();
@@ -504,7 +504,7 @@ mod tests {
504 r#" 504 r#"
505 fn main() { 505 fn main() {
506 if false { 506 if false {
507 if<|> true { 507 if$0 true {
508 foo(); 508 foo();
509 } 509 }
510 } 510 }
diff --git a/crates/assists/src/handlers/expand_glob_import.rs b/crates/assists/src/handlers/expand_glob_import.rs
index f51a9a4ad..5fe617ba4 100644
--- a/crates/assists/src/handlers/expand_glob_import.rs
+++ b/crates/assists/src/handlers/expand_glob_import.rs
@@ -25,7 +25,7 @@ use crate::{
25// pub struct Baz; 25// pub struct Baz;
26// } 26// }
27// 27//
28// use foo::*<|>; 28// use foo::*$0;
29// 29//
30// fn qux(bar: Bar, baz: Baz) {} 30// fn qux(bar: Bar, baz: Baz) {}
31// ``` 31// ```
@@ -201,7 +201,7 @@ fn is_mod_visible_from(ctx: &AssistContext, module: Module, from: Module) -> boo
201// } 201// }
202// 202//
203// ↓ --------------- 203// ↓ ---------------
204// use foo::*<|>; 204// use foo::*$0;
205// use baz::Baz; 205// use baz::Baz;
206// ↑ --------------- 206// ↑ ---------------
207fn find_imported_defs(ctx: &AssistContext, star: SyntaxToken) -> Option<Vec<Def>> { 207fn find_imported_defs(ctx: &AssistContext, star: SyntaxToken) -> Option<Vec<Def>> {
@@ -303,7 +303,7 @@ mod foo {
303 pub fn f() {} 303 pub fn f() {}
304} 304}
305 305
306use foo::*<|>; 306use foo::*$0;
307 307
308fn qux(bar: Bar, baz: Baz) { 308fn qux(bar: Bar, baz: Baz) {
309 f(); 309 f();
@@ -340,7 +340,7 @@ mod foo {
340 pub fn f() {} 340 pub fn f() {}
341} 341}
342 342
343use foo::{*<|>, f}; 343use foo::{*$0, f};
344 344
345fn qux(bar: Bar, baz: Baz) { 345fn qux(bar: Bar, baz: Baz) {
346 f(); 346 f();
@@ -378,7 +378,7 @@ mod foo {
378} 378}
379 379
380use foo::Bar; 380use foo::Bar;
381use foo::{*<|>, f}; 381use foo::{*$0, f};
382 382
383fn qux(bar: Bar, baz: Baz) { 383fn qux(bar: Bar, baz: Baz) {
384 f(); 384 f();
@@ -422,7 +422,7 @@ mod foo {
422 } 422 }
423} 423}
424 424
425use foo::{bar::{*<|>, f}, baz::*}; 425use foo::{bar::{*$0, f}, baz::*};
426 426
427fn qux(bar: Bar, baz: Baz) { 427fn qux(bar: Bar, baz: Baz) {
428 f(); 428 f();
@@ -470,7 +470,7 @@ mod foo {
470 } 470 }
471} 471}
472 472
473use foo::{bar::{Bar, Baz, f}, baz::*<|>}; 473use foo::{bar::{Bar, Baz, f}, baz::*$0};
474 474
475fn qux(bar: Bar, baz: Baz) { 475fn qux(bar: Bar, baz: Baz) {
476 f(); 476 f();
@@ -529,7 +529,7 @@ mod foo {
529 529
530use foo::{ 530use foo::{
531 bar::{*, f}, 531 bar::{*, f},
532 baz::{g, qux::*<|>} 532 baz::{g, qux::*$0}
533}; 533};
534 534
535fn qux(bar: Bar, baz: Baz) { 535fn qux(bar: Bar, baz: Baz) {
@@ -605,7 +605,7 @@ mod foo {
605 605
606use foo::{ 606use foo::{
607 bar::{*, f}, 607 bar::{*, f},
608 baz::{g, qux::{h, q::*<|>}} 608 baz::{g, qux::{h, q::*$0}}
609}; 609};
610 610
611fn qux(bar: Bar, baz: Baz) { 611fn qux(bar: Bar, baz: Baz) {
@@ -681,7 +681,7 @@ mod foo {
681 681
682use foo::{ 682use foo::{
683 bar::{*, f}, 683 bar::{*, f},
684 baz::{g, qux::{q::j, *<|>}} 684 baz::{g, qux::{q::j, *$0}}
685}; 685};
686 686
687fn qux(bar: Bar, baz: Baz) { 687fn qux(bar: Bar, baz: Baz) {
@@ -747,7 +747,7 @@ fn qux(bar: Bar, baz: Baz) {
747 // pub fn baz() {} 747 // pub fn baz() {}
748 748
749 // //- /main.rs crate:main deps:foo 749 // //- /main.rs crate:main deps:foo
750 // use foo::*<|>; 750 // use foo::*$0;
751 751
752 // fn main() { 752 // fn main() {
753 // bar!(); 753 // bar!();
@@ -777,7 +777,7 @@ pub trait Tr {
777impl Tr for () {} 777impl Tr for () {}
778 778
779//- /main.rs crate:main deps:foo 779//- /main.rs crate:main deps:foo
780use foo::*<|>; 780use foo::*$0;
781 781
782fn main() { 782fn main() {
783 ().method(); 783 ().method();
@@ -807,7 +807,7 @@ pub trait Tr2 {
807impl Tr2 for () {} 807impl Tr2 for () {}
808 808
809//- /main.rs crate:main deps:foo 809//- /main.rs crate:main deps:foo
810use foo::*<|>; 810use foo::*$0;
811 811
812fn main() { 812fn main() {
813 ().method(); 813 ().method();
@@ -834,7 +834,7 @@ mod foo {
834 } 834 }
835} 835}
836 836
837use foo::bar::*<|>; 837use foo::bar::*$0;
838 838
839fn baz(bar: Bar) {} 839fn baz(bar: Bar) {}
840", 840",
@@ -851,7 +851,7 @@ mod foo {
851 } 851 }
852} 852}
853 853
854use foo::bar::baz::*<|>; 854use foo::bar::baz::*$0;
855 855
856fn qux(baz: Baz) {} 856fn qux(baz: Baz) {}
857", 857",
@@ -869,7 +869,7 @@ fn qux(baz: Baz) {}
869 pub struct Qux; 869 pub struct Qux;
870 } 870 }
871 871
872 use foo::Bar<|>; 872 use foo::Bar$0;
873 873
874 fn qux(bar: Bar, baz: Baz) {} 874 fn qux(bar: Bar, baz: Baz) {}
875 ", 875 ",
@@ -885,7 +885,7 @@ mod foo {
885 pub struct Bar; 885 pub struct Bar;
886} 886}
887 887
888use foo::{*<|>}; 888use foo::{*$0};
889 889
890struct Baz { 890struct Baz {
891 bar: Bar 891 bar: Bar
diff --git a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs
index 6f35a061c..e3ef04932 100644
--- a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs
+++ b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs
@@ -2,12 +2,16 @@ use std::iter;
2 2
3use either::Either; 3use either::Either;
4use hir::{AsName, Module, ModuleDef, Name, Variant}; 4use hir::{AsName, Module, ModuleDef, Name, Variant};
5use ide_db::helpers::{ 5use ide_db::{
6 insert_use::{insert_use, ImportScope}, 6 defs::Definition,
7 mod_path_to_ast, 7 helpers::{
8 insert_use::{insert_use, ImportScope},
9 mod_path_to_ast,
10 },
11 search::FileReference,
12 RootDatabase,
8}; 13};
9use ide_db::{defs::Definition, search::Reference, RootDatabase}; 14use rustc_hash::FxHashSet;
10use rustc_hash::{FxHashMap, FxHashSet};
11use syntax::{ 15use syntax::{
12 algo::{find_node_at_offset, SyntaxRewriter}, 16 algo::{find_node_at_offset, SyntaxRewriter},
13 ast::{self, edit::IndentLevel, make, AstNode, NameOwner, VisibilityOwner}, 17 ast::{self, edit::IndentLevel, make, AstNode, NameOwner, VisibilityOwner},
@@ -21,7 +25,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
21// Extracts a struct from enum variant. 25// Extracts a struct from enum variant.
22// 26//
23// ``` 27// ```
24// enum A { <|>One(u32, u32) } 28// enum A { $0One(u32, u32) }
25// ``` 29// ```
26// -> 30// ->
27// ``` 31// ```
@@ -58,29 +62,29 @@ pub(crate) fn extract_struct_from_enum_variant(
58 let mut visited_modules_set = FxHashSet::default(); 62 let mut visited_modules_set = FxHashSet::default();
59 let current_module = enum_hir.module(ctx.db()); 63 let current_module = enum_hir.module(ctx.db());
60 visited_modules_set.insert(current_module); 64 visited_modules_set.insert(current_module);
61 let mut rewriters = FxHashMap::default(); 65 let mut def_rewriter = None;
62 for reference in usages { 66 for (file_id, references) in usages {
63 let rewriter = rewriters 67 let mut rewriter = SyntaxRewriter::default();
64 .entry(reference.file_range.file_id) 68 let source_file = ctx.sema.parse(file_id);
65 .or_insert_with(SyntaxRewriter::default); 69 for reference in references {
66 let source_file = ctx.sema.parse(reference.file_range.file_id); 70 update_reference(
67 update_reference( 71 ctx,
68 ctx, 72 &mut rewriter,
69 rewriter, 73 reference,
70 reference, 74 &source_file,
71 &source_file, 75 &enum_module_def,
72 &enum_module_def, 76 &variant_hir_name,
73 &variant_hir_name, 77 &mut visited_modules_set,
74 &mut visited_modules_set, 78 );
75 ); 79 }
76 } 80 if file_id == ctx.frange.file_id {
77 let mut rewriter = 81 def_rewriter = Some(rewriter);
78 rewriters.remove(&ctx.frange.file_id).unwrap_or_else(SyntaxRewriter::default); 82 continue;
79 for (file_id, rewriter) in rewriters { 83 }
80 builder.edit_file(file_id); 84 builder.edit_file(file_id);
81 builder.rewrite(rewriter); 85 builder.rewrite(rewriter);
82 } 86 }
83 builder.edit_file(ctx.frange.file_id); 87 let mut rewriter = def_rewriter.unwrap_or_default();
84 update_variant(&mut rewriter, &variant); 88 update_variant(&mut rewriter, &variant);
85 extract_struct_def( 89 extract_struct_def(
86 &mut rewriter, 90 &mut rewriter,
@@ -90,6 +94,7 @@ pub(crate) fn extract_struct_from_enum_variant(
90 &variant.parent_enum().syntax().clone().into(), 94 &variant.parent_enum().syntax().clone().into(),
91 enum_ast.visibility(), 95 enum_ast.visibility(),
92 ); 96 );
97 builder.edit_file(ctx.frange.file_id);
93 builder.rewrite(rewriter); 98 builder.rewrite(rewriter);
94 }, 99 },
95 ) 100 )
@@ -205,13 +210,13 @@ fn update_variant(rewriter: &mut SyntaxRewriter, variant: &ast::Variant) -> Opti
205fn update_reference( 210fn update_reference(
206 ctx: &AssistContext, 211 ctx: &AssistContext,
207 rewriter: &mut SyntaxRewriter, 212 rewriter: &mut SyntaxRewriter,
208 reference: Reference, 213 reference: FileReference,
209 source_file: &SourceFile, 214 source_file: &SourceFile,
210 enum_module_def: &ModuleDef, 215 enum_module_def: &ModuleDef,
211 variant_hir_name: &Name, 216 variant_hir_name: &Name,
212 visited_modules_set: &mut FxHashSet<Module>, 217 visited_modules_set: &mut FxHashSet<Module>,
213) -> Option<()> { 218) -> Option<()> {
214 let offset = reference.file_range.range.start(); 219 let offset = reference.range.start();
215 let (segment, expr) = if let Some(path_expr) = 220 let (segment, expr) = if let Some(path_expr) =
216 find_node_at_offset::<ast::PathExpr>(source_file.syntax(), offset) 221 find_node_at_offset::<ast::PathExpr>(source_file.syntax(), offset)
217 { 222 {
@@ -251,7 +256,7 @@ mod tests {
251 fn test_extract_struct_several_fields_tuple() { 256 fn test_extract_struct_several_fields_tuple() {
252 check_assist( 257 check_assist(
253 extract_struct_from_enum_variant, 258 extract_struct_from_enum_variant,
254 "enum A { <|>One(u32, u32) }", 259 "enum A { $0One(u32, u32) }",
255 r#"struct One(pub u32, pub u32); 260 r#"struct One(pub u32, pub u32);
256 261
257enum A { One(One) }"#, 262enum A { One(One) }"#,
@@ -262,7 +267,7 @@ enum A { One(One) }"#,
262 fn test_extract_struct_several_fields_named() { 267 fn test_extract_struct_several_fields_named() {
263 check_assist( 268 check_assist(
264 extract_struct_from_enum_variant, 269 extract_struct_from_enum_variant,
265 "enum A { <|>One { foo: u32, bar: u32 } }", 270 "enum A { $0One { foo: u32, bar: u32 } }",
266 r#"struct One{ pub foo: u32, pub bar: u32 } 271 r#"struct One{ pub foo: u32, pub bar: u32 }
267 272
268enum A { One(One) }"#, 273enum A { One(One) }"#,
@@ -273,7 +278,7 @@ enum A { One(One) }"#,
273 fn test_extract_struct_one_field_named() { 278 fn test_extract_struct_one_field_named() {
274 check_assist( 279 check_assist(
275 extract_struct_from_enum_variant, 280 extract_struct_from_enum_variant,
276 "enum A { <|>One { foo: u32 } }", 281 "enum A { $0One { foo: u32 } }",
277 r#"struct One{ pub foo: u32 } 282 r#"struct One{ pub foo: u32 }
278 283
279enum A { One(One) }"#, 284enum A { One(One) }"#,
@@ -285,7 +290,7 @@ enum A { One(One) }"#,
285 check_assist( 290 check_assist(
286 extract_struct_from_enum_variant, 291 extract_struct_from_enum_variant,
287 r#"const One: () = (); 292 r#"const One: () = ();
288enum A { <|>One(u32, u32) }"#, 293enum A { $0One(u32, u32) }"#,
289 r#"const One: () = (); 294 r#"const One: () = ();
290struct One(pub u32, pub u32); 295struct One(pub u32, pub u32);
291 296
@@ -297,7 +302,7 @@ enum A { One(One) }"#,
297 fn test_extract_struct_pub_visibility() { 302 fn test_extract_struct_pub_visibility() {
298 check_assist( 303 check_assist(
299 extract_struct_from_enum_variant, 304 extract_struct_from_enum_variant,
300 "pub enum A { <|>One(u32, u32) }", 305 "pub enum A { $0One(u32, u32) }",
301 r#"pub struct One(pub u32, pub u32); 306 r#"pub struct One(pub u32, pub u32);
302 307
303pub enum A { One(One) }"#, 308pub enum A { One(One) }"#,
@@ -319,7 +324,7 @@ pub enum A { One(One) }"#,
319 } 324 }
320 325
321 pub enum MyEnum { 326 pub enum MyEnum {
322 <|>MyField(u8, u8), 327 $0MyField(u8, u8),
323 } 328 }
324 } 329 }
325} 330}
@@ -361,7 +366,7 @@ fn another_fn() {
361 extract_struct_from_enum_variant, 366 extract_struct_from_enum_variant,
362 r#" 367 r#"
363enum E { 368enum E {
364 <|>V { i: i32, j: i32 } 369 $0V { i: i32, j: i32 }
365} 370}
366 371
367fn f() { 372fn f() {
@@ -389,7 +394,7 @@ fn f() {
389 r#" 394 r#"
390//- /main.rs 395//- /main.rs
391enum E { 396enum E {
392 <|>V(i32, i32) 397 $0V(i32, i32)
393} 398}
394mod foo; 399mod foo;
395 400
@@ -424,7 +429,7 @@ fn f() {
424 r#" 429 r#"
425//- /main.rs 430//- /main.rs
426enum E { 431enum E {
427 <|>V { i: i32, j: i32 } 432 $0V { i: i32, j: i32 }
428} 433}
429mod foo; 434mod foo;
430 435
@@ -457,7 +462,7 @@ fn f() {
457 check_assist( 462 check_assist(
458 extract_struct_from_enum_variant, 463 extract_struct_from_enum_variant,
459 r#" 464 r#"
460enum A { <|>One { a: u32, b: u32 } } 465enum A { $0One { a: u32, b: u32 } }
461 466
462struct B(A); 467struct B(A);
463 468
@@ -487,29 +492,29 @@ fn foo() {
487 492
488 #[test] 493 #[test]
489 fn test_extract_enum_not_applicable_for_element_with_no_fields() { 494 fn test_extract_enum_not_applicable_for_element_with_no_fields() {
490 check_not_applicable("enum A { <|>One }"); 495 check_not_applicable("enum A { $0One }");
491 } 496 }
492 497
493 #[test] 498 #[test]
494 fn test_extract_enum_not_applicable_if_struct_exists() { 499 fn test_extract_enum_not_applicable_if_struct_exists() {
495 check_not_applicable( 500 check_not_applicable(
496 r#"struct One; 501 r#"struct One;
497 enum A { <|>One(u8, u32) }"#, 502 enum A { $0One(u8, u32) }"#,
498 ); 503 );
499 } 504 }
500 505
501 #[test] 506 #[test]
502 fn test_extract_not_applicable_one_field() { 507 fn test_extract_not_applicable_one_field() {
503 check_not_applicable(r"enum A { <|>One(u32) }"); 508 check_not_applicable(r"enum A { $0One(u32) }");
504 } 509 }
505 510
506 #[test] 511 #[test]
507 fn test_extract_not_applicable_no_field_tuple() { 512 fn test_extract_not_applicable_no_field_tuple() {
508 check_not_applicable(r"enum A { <|>None() }"); 513 check_not_applicable(r"enum A { $0None() }");
509 } 514 }
510 515
511 #[test] 516 #[test]
512 fn test_extract_not_applicable_no_field_named() { 517 fn test_extract_not_applicable_no_field_named() {
513 check_not_applicable(r"enum A { <|>None {} }"); 518 check_not_applicable(r"enum A { $0None {} }");
514 } 519 }
515} 520}
diff --git a/crates/assists/src/handlers/extract_variable.rs b/crates/assists/src/handlers/extract_variable.rs
index 291809205..98f3dc6ca 100644
--- a/crates/assists/src/handlers/extract_variable.rs
+++ b/crates/assists/src/handlers/extract_variable.rs
@@ -16,7 +16,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
16// 16//
17// ``` 17// ```
18// fn main() { 18// fn main() {
19// <|>(1 + 2)<|> * 4; 19// $0(1 + 2)$0 * 4;
20// } 20// }
21// ``` 21// ```
22// -> 22// ->
@@ -187,7 +187,7 @@ mod tests {
187 extract_variable, 187 extract_variable,
188 r#" 188 r#"
189fn foo() { 189fn foo() {
190 foo(<|>1 + 1<|>); 190 foo($01 + 1$0);
191}"#, 191}"#,
192 r#" 192 r#"
193fn foo() { 193fn foo() {
@@ -200,7 +200,7 @@ fn foo() {
200 #[test] 200 #[test]
201 fn extract_var_in_comment_is_not_applicable() { 201 fn extract_var_in_comment_is_not_applicable() {
202 mark::check!(extract_var_in_comment_is_not_applicable); 202 mark::check!(extract_var_in_comment_is_not_applicable);
203 check_assist_not_applicable(extract_variable, "fn main() { 1 + /* <|>comment<|> */ 1; }"); 203 check_assist_not_applicable(extract_variable, "fn main() { 1 + /* $0comment$0 */ 1; }");
204 } 204 }
205 205
206 #[test] 206 #[test]
@@ -210,7 +210,7 @@ fn foo() {
210 extract_variable, 210 extract_variable,
211 r#" 211 r#"
212fn foo() { 212fn foo() {
213 <|>1 + 1<|>; 213 $01 + 1$0;
214}"#, 214}"#,
215 r#" 215 r#"
216fn foo() { 216fn foo() {
@@ -221,7 +221,7 @@ fn foo() {
221 extract_variable, 221 extract_variable,
222 " 222 "
223fn foo() { 223fn foo() {
224 <|>{ let x = 0; x }<|> 224 $0{ let x = 0; x }$0
225 something_else(); 225 something_else();
226}", 226}",
227 " 227 "
@@ -238,7 +238,7 @@ fn foo() {
238 extract_variable, 238 extract_variable,
239 " 239 "
240fn foo() { 240fn foo() {
241 <|>1<|> + 1; 241 $01$0 + 1;
242}", 242}",
243 " 243 "
244fn foo() { 244fn foo() {
@@ -255,7 +255,7 @@ fn foo() {
255 extract_variable, 255 extract_variable,
256 r#" 256 r#"
257fn foo() { 257fn foo() {
258 bar(<|>1 + 1<|>) 258 bar($01 + 1$0)
259} 259}
260"#, 260"#,
261 r#" 261 r#"
@@ -269,7 +269,7 @@ fn foo() {
269 extract_variable, 269 extract_variable,
270 r#" 270 r#"
271fn foo() { 271fn foo() {
272 <|>bar(1 + 1)<|> 272 $0bar(1 + 1)$0
273} 273}
274"#, 274"#,
275 r#" 275 r#"
@@ -289,7 +289,7 @@ fn foo() {
289fn main() { 289fn main() {
290 let x = true; 290 let x = true;
291 let tuple = match x { 291 let tuple = match x {
292 true => (<|>2 + 2<|>, true) 292 true => ($02 + 2$0, true)
293 _ => (0, false) 293 _ => (0, false)
294 }; 294 };
295} 295}
@@ -316,7 +316,7 @@ fn main() {
316 let tuple = match x { 316 let tuple = match x {
317 true => { 317 true => {
318 let y = 1; 318 let y = 1;
319 (<|>2 + y<|>, true) 319 ($02 + y$0, true)
320 } 320 }
321 _ => (0, false) 321 _ => (0, false)
322 }; 322 };
@@ -344,7 +344,7 @@ fn main() {
344 extract_variable, 344 extract_variable,
345 " 345 "
346fn main() { 346fn main() {
347 let lambda = |x: u32| <|>x * 2<|>; 347 let lambda = |x: u32| $0x * 2$0;
348} 348}
349", 349",
350 " 350 "
@@ -361,7 +361,7 @@ fn main() {
361 extract_variable, 361 extract_variable,
362 " 362 "
363fn main() { 363fn main() {
364 let lambda = |x: u32| { <|>x * 2<|> }; 364 let lambda = |x: u32| { $0x * 2$0 };
365} 365}
366", 366",
367 " 367 "
@@ -378,7 +378,7 @@ fn main() {
378 extract_variable, 378 extract_variable,
379 " 379 "
380fn main() { 380fn main() {
381 let o = <|>Some(true)<|>; 381 let o = $0Some(true)$0;
382} 382}
383", 383",
384 " 384 "
@@ -396,7 +396,7 @@ fn main() {
396 extract_variable, 396 extract_variable,
397 " 397 "
398fn main() { 398fn main() {
399 let v = <|>bar.foo()<|>; 399 let v = $0bar.foo()$0;
400} 400}
401", 401",
402 " 402 "
@@ -414,7 +414,7 @@ fn main() {
414 extract_variable, 414 extract_variable,
415 " 415 "
416fn foo() -> u32 { 416fn foo() -> u32 {
417 <|>return 2 + 2<|>; 417 $0return 2 + 2$0;
418} 418}
419", 419",
420 " 420 "
@@ -434,7 +434,7 @@ fn foo() -> u32 {
434fn foo() -> u32 { 434fn foo() -> u32 {
435 435
436 436
437 <|>return 2 + 2<|>; 437 $0return 2 + 2$0;
438} 438}
439", 439",
440 " 440 "
@@ -452,7 +452,7 @@ fn foo() -> u32 {
452 " 452 "
453fn foo() -> u32 { 453fn foo() -> u32 {
454 454
455 <|>return 2 + 2<|>; 455 $0return 2 + 2$0;
456} 456}
457", 457",
458 " 458 "
@@ -473,7 +473,7 @@ fn foo() -> u32 {
473 // bar 473 // bar
474 474
475 475
476 <|>return 2 + 2<|>; 476 $0return 2 + 2$0;
477} 477}
478", 478",
479 " 479 "
@@ -497,7 +497,7 @@ fn foo() -> u32 {
497 " 497 "
498fn main() { 498fn main() {
499 let result = loop { 499 let result = loop {
500 <|>break 2 + 2<|>; 500 $0break 2 + 2$0;
501 }; 501 };
502} 502}
503", 503",
@@ -518,7 +518,7 @@ fn main() {
518 extract_variable, 518 extract_variable,
519 " 519 "
520fn main() { 520fn main() {
521 let v = <|>0f32 as u32<|>; 521 let v = $00f32 as u32$0;
522} 522}
523", 523",
524 " 524 "
@@ -540,7 +540,7 @@ struct S {
540} 540}
541 541
542fn main() { 542fn main() {
543 S { foo: <|>1 + 1<|> } 543 S { foo: $01 + 1$0 }
544} 544}
545"#, 545"#,
546 r#" 546 r#"
@@ -558,18 +558,18 @@ fn main() {
558 558
559 #[test] 559 #[test]
560 fn test_extract_var_for_return_not_applicable() { 560 fn test_extract_var_for_return_not_applicable() {
561 check_assist_not_applicable(extract_variable, "fn foo() { <|>return<|>; } "); 561 check_assist_not_applicable(extract_variable, "fn foo() { $0return$0; } ");
562 } 562 }
563 563
564 #[test] 564 #[test]
565 fn test_extract_var_for_break_not_applicable() { 565 fn test_extract_var_for_break_not_applicable() {
566 check_assist_not_applicable(extract_variable, "fn main() { loop { <|>break<|>; }; }"); 566 check_assist_not_applicable(extract_variable, "fn main() { loop { $0break$0; }; }");
567 } 567 }
568 568
569 // FIXME: This is not quite correct, but good enough(tm) for the sorting heuristic 569 // FIXME: This is not quite correct, but good enough(tm) for the sorting heuristic
570 #[test] 570 #[test]
571 fn extract_var_target() { 571 fn extract_var_target() {
572 check_assist_target(extract_variable, "fn foo() -> u32 { <|>return 2 + 2<|>; }", "2 + 2"); 572 check_assist_target(extract_variable, "fn foo() -> u32 { $0return 2 + 2$0; }", "2 + 2");
573 573
574 check_assist_target( 574 check_assist_target(
575 extract_variable, 575 extract_variable,
@@ -577,7 +577,7 @@ fn main() {
577fn main() { 577fn main() {
578 let x = true; 578 let x = true;
579 let tuple = match x { 579 let tuple = match x {
580 true => (<|>2 + 2<|>, true) 580 true => ($02 + 2$0, true)
581 _ => (0, false) 581 _ => (0, false)
582 }; 582 };
583} 583}
diff --git a/crates/assists/src/handlers/fill_match_arms.rs b/crates/assists/src/handlers/fill_match_arms.rs
index f9a62b9fa..da47187e4 100644
--- a/crates/assists/src/handlers/fill_match_arms.rs
+++ b/crates/assists/src/handlers/fill_match_arms.rs
@@ -21,7 +21,7 @@ use crate::{
21// 21//
22// fn handle(action: Action) { 22// fn handle(action: Action) {
23// match action { 23// match action {
24// <|> 24// $0
25// } 25// }
26// } 26// }
27// ``` 27// ```
@@ -231,7 +231,7 @@ mod tests {
231 Cs(i32, Option<i32>), 231 Cs(i32, Option<i32>),
232 } 232 }
233 fn main() { 233 fn main() {
234 match A::As<|> { 234 match A::As$0 {
235 A::As, 235 A::As,
236 A::Bs{x,y:Some(_)} => {} 236 A::Bs{x,y:Some(_)} => {}
237 A::Cs(_, Some(_)) => {} 237 A::Cs(_, Some(_)) => {}
@@ -249,7 +249,7 @@ mod tests {
249 fill_match_arms, 249 fill_match_arms,
250 r#" 250 r#"
251 fn main() { 251 fn main() {
252 match (0, false)<|> { 252 match (0, false)$0 {
253 } 253 }
254 } 254 }
255 "#, 255 "#,
@@ -267,7 +267,7 @@ mod tests {
267 Cs(i32, Option<i32>), 267 Cs(i32, Option<i32>),
268 } 268 }
269 fn main() { 269 fn main() {
270 match A::As<|> { 270 match A::As$0 {
271 A::Bs { x, y: Some(_) } => {} 271 A::Bs { x, y: Some(_) } => {}
272 A::Cs(_, Some(_)) => {} 272 A::Cs(_, Some(_)) => {}
273 } 273 }
@@ -297,7 +297,7 @@ mod tests {
297 r#" 297 r#"
298enum A { As, Bs, Cs(Option<i32>) } 298enum A { As, Bs, Cs(Option<i32>) }
299fn main() { 299fn main() {
300 match A::As<|> { 300 match A::As$0 {
301 A::Cs(_) | A::Bs => {} 301 A::Cs(_) | A::Bs => {}
302 } 302 }
303} 303}
@@ -322,7 +322,7 @@ fn main() {
322enum A { As, Bs, Cs, Ds(String), Es(B) } 322enum A { As, Bs, Cs, Ds(String), Es(B) }
323enum B { Xs, Ys } 323enum B { Xs, Ys }
324fn main() { 324fn main() {
325 match A::As<|> { 325 match A::As$0 {
326 A::Bs if 0 < 1 => {} 326 A::Bs if 0 < 1 => {}
327 A::Ds(_value) => { let x = 1; } 327 A::Ds(_value) => { let x = 1; }
328 A::Es(B::Xs) => (), 328 A::Es(B::Xs) => (),
@@ -352,7 +352,7 @@ fn main() {
352 r#" 352 r#"
353enum A { As, Bs, Cs(Option<i32>) } 353enum A { As, Bs, Cs(Option<i32>) }
354fn main() { 354fn main() {
355 match A::As<|> { 355 match A::As$0 {
356 A::As(_) => {} 356 A::As(_) => {}
357 a @ A::Bs(_) => {} 357 a @ A::Bs(_) => {}
358 } 358 }
@@ -380,7 +380,7 @@ enum A { As, Bs, Cs(String), Ds(String, String), Es { x: usize, y: usize } }
380 380
381fn main() { 381fn main() {
382 let a = A::As; 382 let a = A::As;
383 match a<|> {} 383 match a$0 {}
384} 384}
385"#, 385"#,
386 r#" 386 r#"
@@ -411,7 +411,7 @@ fn main() {
411 fn main() { 411 fn main() {
412 let a = A::One; 412 let a = A::One;
413 let b = B::One; 413 let b = B::One;
414 match (a<|>, b) {} 414 match (a$0, b) {}
415 } 415 }
416 "#, 416 "#,
417 r#" 417 r#"
@@ -443,7 +443,7 @@ fn main() {
443 fn main() { 443 fn main() {
444 let a = A::One; 444 let a = A::One;
445 let b = B::One; 445 let b = B::One;
446 match (&a<|>, &b) {} 446 match (&a$0, &b) {}
447 } 447 }
448 "#, 448 "#,
449 r#" 449 r#"
@@ -475,7 +475,7 @@ fn main() {
475 fn main() { 475 fn main() {
476 let a = A::One; 476 let a = A::One;
477 let b = B::One; 477 let b = B::One;
478 match (a<|>, b) { 478 match (a$0, b) {
479 (A::Two, B::One) => {} 479 (A::Two, B::One) => {}
480 } 480 }
481 } 481 }
@@ -494,7 +494,7 @@ fn main() {
494 fn main() { 494 fn main() {
495 let a = A::One; 495 let a = A::One;
496 let b = B::One; 496 let b = B::One;
497 match (a<|>, b) { 497 match (a$0, b) {
498 (A::Two, B::One) => {} 498 (A::Two, B::One) => {}
499 (A::One, B::One) => {} 499 (A::One, B::One) => {}
500 (A::One, B::Two) => {} 500 (A::One, B::Two) => {}
@@ -517,7 +517,7 @@ fn main() {
517 517
518 fn main() { 518 fn main() {
519 let a = A::One; 519 let a = A::One;
520 match (a<|>, ) { 520 match (a$0, ) {
521 } 521 }
522 } 522 }
523 "#, 523 "#,
@@ -532,7 +532,7 @@ fn main() {
532 enum A { As } 532 enum A { As }
533 533
534 fn foo(a: &A) { 534 fn foo(a: &A) {
535 match a<|> { 535 match a$0 {
536 } 536 }
537 } 537 }
538 "#, 538 "#,
@@ -555,7 +555,7 @@ fn main() {
555 } 555 }
556 556
557 fn foo(a: &mut A) { 557 fn foo(a: &mut A) {
558 match a<|> { 558 match a$0 {
559 } 559 }
560 } 560 }
561 "#, 561 "#,
@@ -581,7 +581,7 @@ fn main() {
581 enum E { X, Y } 581 enum E { X, Y }
582 582
583 fn main() { 583 fn main() {
584 match E::X<|> {} 584 match E::X$0 {}
585 } 585 }
586 "#, 586 "#,
587 "match E::X {}", 587 "match E::X {}",
@@ -597,7 +597,7 @@ fn main() {
597 597
598 fn main() { 598 fn main() {
599 match E::X { 599 match E::X {
600 <|>_ => {} 600 $0_ => {}
601 } 601 }
602 } 602 }
603 "#, 603 "#,
@@ -624,7 +624,7 @@ fn main() {
624 624
625 fn main() { 625 fn main() {
626 match X { 626 match X {
627 <|> 627 $0
628 } 628 }
629 } 629 }
630 "#, 630 "#,
@@ -650,7 +650,7 @@ fn main() {
650 enum A { One, Two } 650 enum A { One, Two }
651 fn foo(a: A) { 651 fn foo(a: A) {
652 match a { 652 match a {
653 // foo bar baz<|> 653 // foo bar baz$0
654 A::One => {} 654 A::One => {}
655 // This is where the rest should be 655 // This is where the rest should be
656 } 656 }
@@ -678,7 +678,7 @@ fn main() {
678 enum A { One, Two } 678 enum A { One, Two }
679 fn foo(a: A) { 679 fn foo(a: A) {
680 match a { 680 match a {
681 // foo bar baz<|> 681 // foo bar baz$0
682 } 682 }
683 } 683 }
684 "#, 684 "#,
@@ -702,7 +702,7 @@ fn main() {
702 r#" 702 r#"
703 enum A { One, Two, } 703 enum A { One, Two, }
704 fn foo(a: A) { 704 fn foo(a: A) {
705 match a<|> { 705 match a$0 {
706 _ => (), 706 _ => (),
707 } 707 }
708 } 708 }
@@ -724,7 +724,7 @@ fn main() {
724 mark::check!(option_order); 724 mark::check!(option_order);
725 let before = r#" 725 let before = r#"
726fn foo(opt: Option<i32>) { 726fn foo(opt: Option<i32>) {
727 match opt<|> { 727 match opt$0 {
728 } 728 }
729} 729}
730"#; 730"#;
diff --git a/crates/assists/src/handlers/fix_visibility.rs b/crates/assists/src/handlers/fix_visibility.rs
index c10b3b8f5..6c7824e55 100644
--- a/crates/assists/src/handlers/fix_visibility.rs
+++ b/crates/assists/src/handlers/fix_visibility.rs
@@ -18,7 +18,7 @@ use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists};
18// fn frobnicate() {} 18// fn frobnicate() {}
19// } 19// }
20// fn main() { 20// fn main() {
21// m::frobnicate<|>() {} 21// m::frobnicate$0() {}
22// } 22// }
23// ``` 23// ```
24// -> 24// ->
@@ -218,14 +218,14 @@ mod tests {
218 check_assist( 218 check_assist(
219 fix_visibility, 219 fix_visibility,
220 r"mod foo { fn foo() {} } 220 r"mod foo { fn foo() {} }
221 fn main() { foo::foo<|>() } ", 221 fn main() { foo::foo$0() } ",
222 r"mod foo { $0pub(crate) fn foo() {} } 222 r"mod foo { $0pub(crate) fn foo() {} }
223 fn main() { foo::foo() } ", 223 fn main() { foo::foo() } ",
224 ); 224 );
225 check_assist_not_applicable( 225 check_assist_not_applicable(
226 fix_visibility, 226 fix_visibility,
227 r"mod foo { pub fn foo() {} } 227 r"mod foo { pub fn foo() {} }
228 fn main() { foo::foo<|>() } ", 228 fn main() { foo::foo$0() } ",
229 ) 229 )
230 } 230 }
231 231
@@ -234,38 +234,38 @@ mod tests {
234 check_assist( 234 check_assist(
235 fix_visibility, 235 fix_visibility,
236 r"mod foo { struct Foo; } 236 r"mod foo { struct Foo; }
237 fn main() { foo::Foo<|> } ", 237 fn main() { foo::Foo$0 } ",
238 r"mod foo { $0pub(crate) struct Foo; } 238 r"mod foo { $0pub(crate) struct Foo; }
239 fn main() { foo::Foo } ", 239 fn main() { foo::Foo } ",
240 ); 240 );
241 check_assist_not_applicable( 241 check_assist_not_applicable(
242 fix_visibility, 242 fix_visibility,
243 r"mod foo { pub struct Foo; } 243 r"mod foo { pub struct Foo; }
244 fn main() { foo::Foo<|> } ", 244 fn main() { foo::Foo$0 } ",
245 ); 245 );
246 check_assist( 246 check_assist(
247 fix_visibility, 247 fix_visibility,
248 r"mod foo { enum Foo; } 248 r"mod foo { enum Foo; }
249 fn main() { foo::Foo<|> } ", 249 fn main() { foo::Foo$0 } ",
250 r"mod foo { $0pub(crate) enum Foo; } 250 r"mod foo { $0pub(crate) enum Foo; }
251 fn main() { foo::Foo } ", 251 fn main() { foo::Foo } ",
252 ); 252 );
253 check_assist_not_applicable( 253 check_assist_not_applicable(
254 fix_visibility, 254 fix_visibility,
255 r"mod foo { pub enum Foo; } 255 r"mod foo { pub enum Foo; }
256 fn main() { foo::Foo<|> } ", 256 fn main() { foo::Foo$0 } ",
257 ); 257 );
258 check_assist( 258 check_assist(
259 fix_visibility, 259 fix_visibility,
260 r"mod foo { union Foo; } 260 r"mod foo { union Foo; }
261 fn main() { foo::Foo<|> } ", 261 fn main() { foo::Foo$0 } ",
262 r"mod foo { $0pub(crate) union Foo; } 262 r"mod foo { $0pub(crate) union Foo; }
263 fn main() { foo::Foo } ", 263 fn main() { foo::Foo } ",
264 ); 264 );
265 check_assist_not_applicable( 265 check_assist_not_applicable(
266 fix_visibility, 266 fix_visibility,
267 r"mod foo { pub union Foo; } 267 r"mod foo { pub union Foo; }
268 fn main() { foo::Foo<|> } ", 268 fn main() { foo::Foo$0 } ",
269 ); 269 );
270 } 270 }
271 271
@@ -276,7 +276,7 @@ mod tests {
276 r" 276 r"
277//- /main.rs 277//- /main.rs
278mod foo; 278mod foo;
279fn main() { foo::Foo<|> } 279fn main() { foo::Foo$0 }
280 280
281//- /foo.rs 281//- /foo.rs
282struct Foo; 282struct Foo;
@@ -291,7 +291,7 @@ struct Foo;
291 check_assist( 291 check_assist(
292 fix_visibility, 292 fix_visibility,
293 r"mod foo { pub struct Foo { bar: (), } } 293 r"mod foo { pub struct Foo { bar: (), } }
294 fn main() { foo::Foo { <|>bar: () }; } ", 294 fn main() { foo::Foo { $0bar: () }; } ",
295 r"mod foo { pub struct Foo { $0pub(crate) bar: (), } } 295 r"mod foo { pub struct Foo { $0pub(crate) bar: (), } }
296 fn main() { foo::Foo { bar: () }; } ", 296 fn main() { foo::Foo { bar: () }; } ",
297 ); 297 );
@@ -300,7 +300,7 @@ struct Foo;
300 r" 300 r"
301//- /lib.rs 301//- /lib.rs
302mod foo; 302mod foo;
303fn main() { foo::Foo { <|>bar: () }; } 303fn main() { foo::Foo { $0bar: () }; }
304//- /foo.rs 304//- /foo.rs
305pub struct Foo { bar: () } 305pub struct Foo { bar: () }
306", 306",
@@ -310,14 +310,14 @@ pub struct Foo { bar: () }
310 check_assist_not_applicable( 310 check_assist_not_applicable(
311 fix_visibility, 311 fix_visibility,
312 r"mod foo { pub struct Foo { pub bar: (), } } 312 r"mod foo { pub struct Foo { pub bar: (), } }
313 fn main() { foo::Foo { <|>bar: () }; } ", 313 fn main() { foo::Foo { $0bar: () }; } ",
314 ); 314 );
315 check_assist_not_applicable( 315 check_assist_not_applicable(
316 fix_visibility, 316 fix_visibility,
317 r" 317 r"
318//- /lib.rs 318//- /lib.rs
319mod foo; 319mod foo;
320fn main() { foo::Foo { <|>bar: () }; } 320fn main() { foo::Foo { $0bar: () }; }
321//- /foo.rs 321//- /foo.rs
322pub struct Foo { pub bar: () } 322pub struct Foo { pub bar: () }
323", 323",
@@ -331,14 +331,14 @@ pub struct Foo { pub bar: () }
331 check_assist_not_applicable( 331 check_assist_not_applicable(
332 fix_visibility, 332 fix_visibility,
333 r"mod foo { pub enum Foo { Bar { bar: () } } } 333 r"mod foo { pub enum Foo { Bar { bar: () } } }
334 fn main() { foo::Foo::Bar { <|>bar: () }; } ", 334 fn main() { foo::Foo::Bar { $0bar: () }; } ",
335 ); 335 );
336 check_assist_not_applicable( 336 check_assist_not_applicable(
337 fix_visibility, 337 fix_visibility,
338 r" 338 r"
339//- /lib.rs 339//- /lib.rs
340mod foo; 340mod foo;
341fn main() { foo::Foo::Bar { <|>bar: () }; } 341fn main() { foo::Foo::Bar { $0bar: () }; }
342//- /foo.rs 342//- /foo.rs
343pub enum Foo { Bar { bar: () } } 343pub enum Foo { Bar { bar: () } }
344", 344",
@@ -346,14 +346,14 @@ pub enum Foo { Bar { bar: () } }
346 check_assist_not_applicable( 346 check_assist_not_applicable(
347 fix_visibility, 347 fix_visibility,
348 r"mod foo { pub struct Foo { pub bar: (), } } 348 r"mod foo { pub struct Foo { pub bar: (), } }
349 fn main() { foo::Foo { <|>bar: () }; } ", 349 fn main() { foo::Foo { $0bar: () }; } ",
350 ); 350 );
351 check_assist_not_applicable( 351 check_assist_not_applicable(
352 fix_visibility, 352 fix_visibility,
353 r" 353 r"
354//- /lib.rs 354//- /lib.rs
355mod foo; 355mod foo;
356fn main() { foo::Foo { <|>bar: () }; } 356fn main() { foo::Foo { $0bar: () }; }
357//- /foo.rs 357//- /foo.rs
358pub struct Foo { pub bar: () } 358pub struct Foo { pub bar: () }
359", 359",
@@ -367,7 +367,7 @@ pub struct Foo { pub bar: () }
367 check_assist( 367 check_assist(
368 fix_visibility, 368 fix_visibility,
369 r"mod foo { pub union Foo { bar: (), } } 369 r"mod foo { pub union Foo { bar: (), } }
370 fn main() { foo::Foo { <|>bar: () }; } ", 370 fn main() { foo::Foo { $0bar: () }; } ",
371 r"mod foo { pub union Foo { $0pub(crate) bar: (), } } 371 r"mod foo { pub union Foo { $0pub(crate) bar: (), } }
372 fn main() { foo::Foo { bar: () }; } ", 372 fn main() { foo::Foo { bar: () }; } ",
373 ); 373 );
@@ -376,7 +376,7 @@ pub struct Foo { pub bar: () }
376 r" 376 r"
377//- /lib.rs 377//- /lib.rs
378mod foo; 378mod foo;
379fn main() { foo::Foo { <|>bar: () }; } 379fn main() { foo::Foo { $0bar: () }; }
380//- /foo.rs 380//- /foo.rs
381pub union Foo { bar: () } 381pub union Foo { bar: () }
382", 382",
@@ -386,14 +386,14 @@ pub union Foo { bar: () }
386 check_assist_not_applicable( 386 check_assist_not_applicable(
387 fix_visibility, 387 fix_visibility,
388 r"mod foo { pub union Foo { pub bar: (), } } 388 r"mod foo { pub union Foo { pub bar: (), } }
389 fn main() { foo::Foo { <|>bar: () }; } ", 389 fn main() { foo::Foo { $0bar: () }; } ",
390 ); 390 );
391 check_assist_not_applicable( 391 check_assist_not_applicable(
392 fix_visibility, 392 fix_visibility,
393 r" 393 r"
394//- /lib.rs 394//- /lib.rs
395mod foo; 395mod foo;
396fn main() { foo::Foo { <|>bar: () }; } 396fn main() { foo::Foo { $0bar: () }; }
397//- /foo.rs 397//- /foo.rs
398pub union Foo { pub bar: () } 398pub union Foo { pub bar: () }
399", 399",
@@ -405,14 +405,14 @@ pub union Foo { pub bar: () }
405 check_assist( 405 check_assist(
406 fix_visibility, 406 fix_visibility,
407 r"mod foo { const FOO: () = (); } 407 r"mod foo { const FOO: () = (); }
408 fn main() { foo::FOO<|> } ", 408 fn main() { foo::FOO$0 } ",
409 r"mod foo { $0pub(crate) const FOO: () = (); } 409 r"mod foo { $0pub(crate) const FOO: () = (); }
410 fn main() { foo::FOO } ", 410 fn main() { foo::FOO } ",
411 ); 411 );
412 check_assist_not_applicable( 412 check_assist_not_applicable(
413 fix_visibility, 413 fix_visibility,
414 r"mod foo { pub const FOO: () = (); } 414 r"mod foo { pub const FOO: () = (); }
415 fn main() { foo::FOO<|> } ", 415 fn main() { foo::FOO$0 } ",
416 ); 416 );
417 } 417 }
418 418
@@ -421,14 +421,14 @@ pub union Foo { pub bar: () }
421 check_assist( 421 check_assist(
422 fix_visibility, 422 fix_visibility,
423 r"mod foo { static FOO: () = (); } 423 r"mod foo { static FOO: () = (); }
424 fn main() { foo::FOO<|> } ", 424 fn main() { foo::FOO$0 } ",
425 r"mod foo { $0pub(crate) static FOO: () = (); } 425 r"mod foo { $0pub(crate) static FOO: () = (); }
426 fn main() { foo::FOO } ", 426 fn main() { foo::FOO } ",
427 ); 427 );
428 check_assist_not_applicable( 428 check_assist_not_applicable(
429 fix_visibility, 429 fix_visibility,
430 r"mod foo { pub static FOO: () = (); } 430 r"mod foo { pub static FOO: () = (); }
431 fn main() { foo::FOO<|> } ", 431 fn main() { foo::FOO$0 } ",
432 ); 432 );
433 } 433 }
434 434
@@ -437,14 +437,14 @@ pub union Foo { pub bar: () }
437 check_assist( 437 check_assist(
438 fix_visibility, 438 fix_visibility,
439 r"mod foo { trait Foo { fn foo(&self) {} } } 439 r"mod foo { trait Foo { fn foo(&self) {} } }
440 fn main() { let x: &dyn foo::<|>Foo; } ", 440 fn main() { let x: &dyn foo::$0Foo; } ",
441 r"mod foo { $0pub(crate) trait Foo { fn foo(&self) {} } } 441 r"mod foo { $0pub(crate) trait Foo { fn foo(&self) {} } }
442 fn main() { let x: &dyn foo::Foo; } ", 442 fn main() { let x: &dyn foo::Foo; } ",
443 ); 443 );
444 check_assist_not_applicable( 444 check_assist_not_applicable(
445 fix_visibility, 445 fix_visibility,
446 r"mod foo { pub trait Foo { fn foo(&self) {} } } 446 r"mod foo { pub trait Foo { fn foo(&self) {} } }
447 fn main() { let x: &dyn foo::Foo<|>; } ", 447 fn main() { let x: &dyn foo::Foo$0; } ",
448 ); 448 );
449 } 449 }
450 450
@@ -453,14 +453,14 @@ pub union Foo { pub bar: () }
453 check_assist( 453 check_assist(
454 fix_visibility, 454 fix_visibility,
455 r"mod foo { type Foo = (); } 455 r"mod foo { type Foo = (); }
456 fn main() { let x: foo::Foo<|>; } ", 456 fn main() { let x: foo::Foo$0; } ",
457 r"mod foo { $0pub(crate) type Foo = (); } 457 r"mod foo { $0pub(crate) type Foo = (); }
458 fn main() { let x: foo::Foo; } ", 458 fn main() { let x: foo::Foo; } ",
459 ); 459 );
460 check_assist_not_applicable( 460 check_assist_not_applicable(
461 fix_visibility, 461 fix_visibility,
462 r"mod foo { pub type Foo = (); } 462 r"mod foo { pub type Foo = (); }
463 fn main() { let x: foo::Foo<|>; } ", 463 fn main() { let x: foo::Foo$0; } ",
464 ); 464 );
465 } 465 }
466 466
@@ -469,7 +469,7 @@ pub union Foo { pub bar: () }
469 check_assist( 469 check_assist(
470 fix_visibility, 470 fix_visibility,
471 r"mod foo { mod bar { fn bar() {} } } 471 r"mod foo { mod bar { fn bar() {} } }
472 fn main() { foo::bar<|>::bar(); } ", 472 fn main() { foo::bar$0::bar(); } ",
473 r"mod foo { $0pub(crate) mod bar { fn bar() {} } } 473 r"mod foo { $0pub(crate) mod bar { fn bar() {} } }
474 fn main() { foo::bar::bar(); } ", 474 fn main() { foo::bar::bar(); } ",
475 ); 475 );
@@ -479,7 +479,7 @@ pub union Foo { pub bar: () }
479 r" 479 r"
480//- /main.rs 480//- /main.rs
481mod foo; 481mod foo;
482fn main() { foo::bar<|>::baz(); } 482fn main() { foo::bar$0::baz(); }
483 483
484//- /foo.rs 484//- /foo.rs
485mod bar { 485mod bar {
@@ -495,7 +495,7 @@ mod bar {
495 check_assist_not_applicable( 495 check_assist_not_applicable(
496 fix_visibility, 496 fix_visibility,
497 r"mod foo { pub mod bar { pub fn bar() {} } } 497 r"mod foo { pub mod bar { pub fn bar() {} } }
498 fn main() { foo::bar<|>::bar(); } ", 498 fn main() { foo::bar$0::bar(); } ",
499 ); 499 );
500 } 500 }
501 501
@@ -506,7 +506,7 @@ mod bar {
506 r" 506 r"
507//- /main.rs 507//- /main.rs
508mod foo; 508mod foo;
509fn main() { foo::bar<|>::baz(); } 509fn main() { foo::bar$0::baz(); }
510 510
511//- /foo.rs 511//- /foo.rs
512mod bar; 512mod bar;
@@ -525,7 +525,7 @@ pub fn baz() {}
525 r" 525 r"
526//- /main.rs 526//- /main.rs
527mod foo; 527mod foo;
528fn main() { foo::bar<|>>::baz(); } 528fn main() { foo::bar$0>::baz(); }
529 529
530//- /foo.rs 530//- /foo.rs
531mod bar { 531mod bar {
@@ -545,7 +545,7 @@ mod bar {
545 fix_visibility, 545 fix_visibility,
546 r" 546 r"
547//- /main.rs crate:a deps:foo 547//- /main.rs crate:a deps:foo
548foo::Bar<|> 548foo::Bar$0
549//- /lib.rs crate:foo 549//- /lib.rs crate:foo
550struct Bar; 550struct Bar;
551", 551",
@@ -560,7 +560,7 @@ struct Bar;
560 fix_visibility, 560 fix_visibility,
561 r" 561 r"
562//- /main.rs crate:a deps:foo 562//- /main.rs crate:a deps:foo
563foo::Bar<|> 563foo::Bar$0
564//- /lib.rs crate:foo 564//- /lib.rs crate:foo
565pub(crate) struct Bar; 565pub(crate) struct Bar;
566", 566",
@@ -572,7 +572,7 @@ pub(crate) struct Bar;
572 r" 572 r"
573//- /main.rs crate:a deps:foo 573//- /main.rs crate:a deps:foo
574fn main() { 574fn main() {
575 foo::Foo { <|>bar: () }; 575 foo::Foo { $0bar: () };
576} 576}
577//- /lib.rs crate:foo 577//- /lib.rs crate:foo
578pub struct Foo { pub(crate) bar: () } 578pub struct Foo { pub(crate) bar: () }
@@ -593,7 +593,7 @@ pub struct Foo { pub(crate) bar: () }
593 use bar::Baz; 593 use bar::Baz;
594 mod bar { pub(super) struct Baz; } 594 mod bar { pub(super) struct Baz; }
595 } 595 }
596 foo::Baz<|> 596 foo::Baz$0
597 ", 597 ",
598 r" 598 r"
599 mod foo { 599 mod foo {
diff --git a/crates/assists/src/handlers/flip_binexpr.rs b/crates/assists/src/handlers/flip_binexpr.rs
index 404f06133..209e5d43c 100644
--- a/crates/assists/src/handlers/flip_binexpr.rs
+++ b/crates/assists/src/handlers/flip_binexpr.rs
@@ -8,7 +8,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
8// 8//
9// ``` 9// ```
10// fn main() { 10// fn main() {
11// let _ = 90 +<|> 2; 11// let _ = 90 +$0 2;
12// } 12// }
13// ``` 13// ```
14// -> 14// ->
@@ -77,42 +77,34 @@ mod tests {
77 77
78 #[test] 78 #[test]
79 fn flip_binexpr_target_is_the_op() { 79 fn flip_binexpr_target_is_the_op() {
80 check_assist_target(flip_binexpr, "fn f() { let res = 1 ==<|> 2; }", "==") 80 check_assist_target(flip_binexpr, "fn f() { let res = 1 ==$0 2; }", "==")
81 } 81 }
82 82
83 #[test] 83 #[test]
84 fn flip_binexpr_not_applicable_for_assignment() { 84 fn flip_binexpr_not_applicable_for_assignment() {
85 check_assist_not_applicable(flip_binexpr, "fn f() { let mut _x = 1; _x +=<|> 2 }") 85 check_assist_not_applicable(flip_binexpr, "fn f() { let mut _x = 1; _x +=$0 2 }")
86 } 86 }
87 87
88 #[test] 88 #[test]
89 fn flip_binexpr_works_for_eq() { 89 fn flip_binexpr_works_for_eq() {
90 check_assist( 90 check_assist(flip_binexpr, "fn f() { let res = 1 ==$0 2; }", "fn f() { let res = 2 == 1; }")
91 flip_binexpr,
92 "fn f() { let res = 1 ==<|> 2; }",
93 "fn f() { let res = 2 == 1; }",
94 )
95 } 91 }
96 92
97 #[test] 93 #[test]
98 fn flip_binexpr_works_for_gt() { 94 fn flip_binexpr_works_for_gt() {
99 check_assist(flip_binexpr, "fn f() { let res = 1 ><|> 2; }", "fn f() { let res = 2 < 1; }") 95 check_assist(flip_binexpr, "fn f() { let res = 1 >$0 2; }", "fn f() { let res = 2 < 1; }")
100 } 96 }
101 97
102 #[test] 98 #[test]
103 fn flip_binexpr_works_for_lteq() { 99 fn flip_binexpr_works_for_lteq() {
104 check_assist( 100 check_assist(flip_binexpr, "fn f() { let res = 1 <=$0 2; }", "fn f() { let res = 2 >= 1; }")
105 flip_binexpr,
106 "fn f() { let res = 1 <=<|> 2; }",
107 "fn f() { let res = 2 >= 1; }",
108 )
109 } 101 }
110 102
111 #[test] 103 #[test]
112 fn flip_binexpr_works_for_complex_expr() { 104 fn flip_binexpr_works_for_complex_expr() {
113 check_assist( 105 check_assist(
114 flip_binexpr, 106 flip_binexpr,
115 "fn f() { let res = (1 + 1) ==<|> (2 + 2); }", 107 "fn f() { let res = (1 + 1) ==$0 (2 + 2); }",
116 "fn f() { let res = (2 + 2) == (1 + 1); }", 108 "fn f() { let res = (2 + 2) == (1 + 1); }",
117 ) 109 )
118 } 110 }
@@ -125,7 +117,7 @@ mod tests {
125 fn dyn_eq(&self, other: &dyn Diagnostic) -> bool { 117 fn dyn_eq(&self, other: &dyn Diagnostic) -> bool {
126 match other.downcast_ref::<Self>() { 118 match other.downcast_ref::<Self>() {
127 None => false, 119 None => false,
128 Some(it) => it ==<|> self, 120 Some(it) => it ==$0 self,
129 } 121 }
130 } 122 }
131 "#, 123 "#,
diff --git a/crates/assists/src/handlers/flip_comma.rs b/crates/assists/src/handlers/flip_comma.rs
index 64b4b1a76..18cf64a34 100644
--- a/crates/assists/src/handlers/flip_comma.rs
+++ b/crates/assists/src/handlers/flip_comma.rs
@@ -8,7 +8,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
8// 8//
9// ``` 9// ```
10// fn main() { 10// fn main() {
11// ((1, 2),<|> (3, 4)); 11// ((1, 2),$0 (3, 4));
12// } 12// }
13// ``` 13// ```
14// -> 14// ->
@@ -49,14 +49,14 @@ mod tests {
49 fn flip_comma_works_for_function_parameters() { 49 fn flip_comma_works_for_function_parameters() {
50 check_assist( 50 check_assist(
51 flip_comma, 51 flip_comma,
52 "fn foo(x: i32,<|> y: Result<(), ()>) {}", 52 r#"fn foo(x: i32,$0 y: Result<(), ()>) {}"#,
53 "fn foo(y: Result<(), ()>, x: i32) {}", 53 r#"fn foo(y: Result<(), ()>, x: i32) {}"#,
54 ) 54 )
55 } 55 }
56 56
57 #[test] 57 #[test]
58 fn flip_comma_target() { 58 fn flip_comma_target() {
59 check_assist_target(flip_comma, "fn foo(x: i32,<|> y: Result<(), ()>) {}", ",") 59 check_assist_target(flip_comma, r#"fn foo(x: i32,$0 y: Result<(), ()>) {}"#, ",")
60 } 60 }
61 61
62 #[test] 62 #[test]
@@ -68,7 +68,7 @@ mod tests {
68 check_assist_target( 68 check_assist_target(
69 flip_comma, 69 flip_comma,
70 "pub enum Test { \ 70 "pub enum Test { \
71 A,<|> \ 71 A,$0 \
72 }", 72 }",
73 ",", 73 ",",
74 ); 74 );
@@ -76,7 +76,7 @@ mod tests {
76 check_assist_target( 76 check_assist_target(
77 flip_comma, 77 flip_comma,
78 "pub struct Test { \ 78 "pub struct Test { \
79 foo: usize,<|> \ 79 foo: usize,$0 \
80 }", 80 }",
81 ",",