rust-analyzer/crates/stdx/src
Johannes Altmanninger 30b992e95a Deduplicate references to macro argument
Commit 6a06f6f72 (Deduplicate reference search results, 2022-11-07) deduplicates references
within each definition.

There is an edge case when requesting references of a macro argument.  Apparently, our
descend_into_macros() stanza in references.rs produces a cartesian product of
- references inside the macro times
- times references outside the macro.

Since the above deduplication only applies to the references within a single definition, we
return them all, leading to many redundant references.

Work around this by deduplicating definitions as well.  Perhaps there is a better fix to not
produce this cartesian product in the first place; but I think at least for definitions the
problem would remain; a macro can contain multiple definitions of the same name, but since the
navigation target will be the unresolved location, it's the same for all of them.

We can't use unique() because we don't want to drop references that don't have a declaration
(though I dont' have an example for this case).

I discovered this working with the "bitflags" macro from the crate of the same name.

Fixes #16357
2024-02-19 12:23:59 +01:00
..
thread Merge commit 'aa9bc8612514d216f84eec218dfd19ab83f3598a' into sync-from-ra 2023-06-05 12:04:23 +03:00
anymap.rs Lint debug prints and disallowed types with clippy 2024-02-01 17:57:27 +01:00
lib.rs Deduplicate references to macro argument 2024-02-19 12:23:59 +01:00
macros.rs Auto merge of #16451 - Urhengulas:satisfy-clippy, r=Veykril 2024-02-01 14:23:18 +00:00
non_empty_vec.rs minor: replace panics with types 2022-01-02 19:05:37 +03:00
panic_context.rs Lint debug prints and disallowed types with clippy 2024-02-01 17:57:27 +01:00
process.rs Merge commit '3b7c7f97e4a7bb253a8d398ee4f8346f6cf2817b' into sync-from-ra 2023-11-08 08:15:03 +02:00
rand.rs Lint debug prints and disallowed types with clippy 2024-02-01 17:57:27 +01:00
thread.rs Merge commit 'aa9bc8612514d216f84eec218dfd19ab83f3598a' into sync-from-ra 2023-06-05 12:04:23 +03:00