rust-analyzer/crates/ide-db/src
bors 5855bd8579 Auto merge of #15587 - dfireBird:fix-15128, r=Veykril
Fix autoimport does nothing when importing trait that is as _ imports

Potentially fixes #15128

There are two cases of imports:
1. With simple path
2. With use tree list (or say complex path).

On deeper inspection, the [`recursive_merge`](994df3d6a3/crates/ide-db/src/imports/merge_imports.rs (L87)) function (called by [`try_merge_trees_mut`)](994df3d6a3/crates/ide-db/src/imports/merge_imports.rs (L69)) is meaningful only in the case of complex path (i.e when the UseTree contains a UseTreeList).

The [`recursive_merge`](994df3d6a3/crates/ide-db/src/imports/merge_imports.rs (L87)) function has [match with `Ok` arm](994df3d6a3/crates/ide-db/src/imports/merge_imports.rs (L106)), that is only executed when both LHS and RHS has `PathSegment` with same `NameRef`. The removal of underscore is implemented in this arm in the case of complex path.

For simple paths, the underscore is removed by checking if both LHS and RHS are simple paths and if their `Path` is same (the check is done [here](994df3d6a3/crates/ide-db/src/imports/merge_imports.rs (L74))) and remove the underscore if one is found (I made an assumption here that RHS will always be what rust-analyzer suggests to import, because at this point I'm not sure how to remove underscore with help of `ted::replace`).
2023-09-22 07:39:11 +00:00
..
generated Rework no_coverage to coverage(off) 2023-09-08 12:46:06 +01:00
imports add tests for insert use with renamed imports 2023-09-11 17:43:53 +05:30
syntax_helpers Emit builtin#format_args in builtin format_args expander 2023-09-06 18:08:20 +02:00
test_data Merge commit '9b3d03408c' into sync-from-ra 2023-08-21 12:44:09 +03:00
tests Merge commit 'aa9bc86125' into sync-from-ra 2023-06-05 12:04:23 +03:00
active_parameter.rs ⬆️ rust-analyzer 2023-03-13 10:42:24 +02:00
apply_change.rs Merge commit '37f84c101b' into sync-from-ra 2023-07-17 16:49:15 +03:00
assists.rs Merge commit 'aa9bc86125' into sync-from-ra 2023-06-05 12:04:23 +03:00
defs.rs Merge commit '9b3d03408c' into sync-from-ra 2023-08-21 12:44:09 +03:00
documentation.rs Remove markdown module from rust-analyzer crate 2023-09-02 17:27:52 +02:00
famous_defs.rs Merge commit 'baee6b338b' into sync-from-ra 2023-08-07 12:03:15 +03:00
helpers.rs Merge commit '9b3d03408c' into sync-from-ra 2023-08-21 12:44:09 +03:00
items_locator.rs Merge commit '37f84c101b' into sync-from-ra 2023-07-17 16:49:15 +03:00
label.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
lib.rs Move doc comment handling into ide-db 2023-09-02 16:27:26 +02:00
path_transform.rs Merge commit '9b3d03408c' into sync-from-ra 2023-08-21 12:44:09 +03:00
rename.rs v4 2023-09-10 23:25:36 +02:00
rust_doc.rs Remove markdown module from rust-analyzer crate 2023-09-02 17:27:52 +02:00
search.rs fix: Fix lens location "above_whole_item" breaking lenses 2023-09-13 22:01:04 +02:00
source_change.rs Merge commit 'baee6b338b' into sync-from-ra 2023-08-07 12:03:15 +03:00
symbol_index.rs Merge commit '9b3d03408c' into sync-from-ra 2023-08-21 12:44:09 +03:00
traits.rs Merge commit 'aa9bc86125' into sync-from-ra 2023-06-05 12:04:23 +03:00
ty_filter.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
use_trivial_constructor.rs Merge commit '9b3d03408c' into sync-from-ra 2023-08-21 12:44:09 +03:00