summary refs log tree commit diff
path: root/src/tools/rust-analyzer/crates/ide-db
AgeCommit message (Collapse)AuthorLines
2024-12-16fix: Fix path qualified auto-importing completions not working with re-exportsLukas Wirth-120/+152
Prior to this commit we used to generate import paths, then zipped them with the existing qualifier to check if they agree on the path to import. This is brittle when re-exports come into play causing items to have multiple applicable paths that refer to them. This commit instead rewrites this logic by generating the import path for the qualifier, verifying that the rest of the qualifier resolves and then doing a final lookup on that resolution result for the final segment instead.
2024-12-13feat: improve name generation in destructure_tuple_bindingroife-0/+2
2024-12-13Bump typosLaurențiu Nicola-1/+1
2024-12-11Properly handle different defaults for severity of lintsChayim Refael Friedman-1267/+6155
Previously all lints were assumed to be `#[warn]`, and we had a hand-coded list of `#[allow]` exceptions. Now the severity is autogenerated from rustdoc output. Also support lints that change status between editions, and the `warnings` lint group.
2024-12-11Merge from rust-lang/rustLaurențiu Nicola-11/+2
2024-12-10minor: enhance name suggestion for `Arc<T>` and `Rc<T>`roife-1/+27
2024-12-05fix: Resolve generic parameters within use capturesLukas Wirth-0/+7
2024-12-05Parse lifetime bounds in lifetime param into TypeBoundListLukas Wirth-10/+0
This mainly aids in error recovery but also makes it a bit easier to handle lifetime resolution. While doing so it also came apparent that we were not actually lowering lifetime outlives relationships within lifetime parameter declaration bounds, so this fixes that.
2024-12-04Rename `core_pattern_type` and `core_pattern_types` lib feature gates to ↵Oli Scherer-11/+2
`pattern_type_macro` That's what the gates are actually gating, and the single char difference in naming was not helpful either
2024-12-04Fix parsing of parenthesized type args and RTNLukas Wirth-1/+2
2024-10-28Move text-edit into ide-dbLukas Wirth-9/+882
2024-10-28Merge pull request #18074 from ChayimFriedman2/typeref-source-mapLukas Wirth-0/+20
internal: Build source map for `hir_def::TypeRef`s
2024-10-27Invert token iteration order in macro mappingLukas Wirth-2/+4
2024-10-25Factor out token rankingLukas Wirth-0/+30
2024-10-25Fix memory usage calculation's queries listChayim Refael Friedman-0/+20
2024-10-22Auto merge of #18370 - duncpro:goto-def-ranges, r=Veykrilbors-2/+10
feat: resolve range patterns to their structs Closes #18367
2024-10-22Auto merge of #18349 - dqkqd:issue-18344, r=Veykrilbors-1/+13
feat: render docs from aliased type when type has no docs Trying to close #18344 - [x] ~Find the docs by traversing upwards if the type itself has none but aliasing for another type that might have.~ - [x] Show docs from aliased type. - [x] Showing description that we are displaying documentation for different definition in hover box. ![image](https://github.com/user-attachments/assets/820d6f97-aa2c-4dc4-8a25-75746e32d950)
2024-10-22feat: render docs from aliased type when docs are missingKhanh Duong Quoc-1/+13
2024-10-22resolve range patterns to the their struct typesDuncan Proctor-2/+10
2024-10-21Move explicit range handling out of goto_definition, use OperatorClass insteadduncanproctor-22/+18
2024-10-21GotoDefinition on a Range or InclusiveRange operator will link to the struct ↵duncanproctor-1/+16
definition
2024-10-14chore: rename salsa to ra_salsaDavid Barsky-20/+22
2024-10-04Auto merge of #18234 - Veykril:veykril/push-vzynqtlxmrnl, r=Veykrilbors-3/+7
internal: Filter out opaque tokens in some IDE feature macro descensions
2024-10-04internal: Filter out opaque tokens in some of IDE feature macro descensionsLukas Wirth-3/+7
2024-09-30Auto merge of #18207 - mbwilding:master, r=Veykrilbors-1/+1
fix: Ambiguity with CamelCase diagnostic messages, align with rustc warnings Fixed diagnostic messages so they say UpperCamelCase rather than CamelCase, as it is ambiguous. Usually I'd call it PascalCase, but in the code base it is called UpperCamelCase so I left it with that naming choice. `rustc` says `upper camel case` also when the case is wrong ``` warning: trait `testThing` should have an upper camel case name --> src/main.rs:5:7 | 5 | trait testThing { | ^^^^^^^^^ help: convert the identifier to upper camel case: `TestThing` | = note: `#[warn(non_camel_case_types)]` on by default ``` This is in line with the UPPER_SNAKE_CASE diagnostic messages. https://github.com/rust-lang/rust-analyzer/blob/546339a7be357b3e95fc4b79a8816dce540d477b/crates/hir-ty/src/diagnostics/decl_check.rs#L60 https://github.com/rust-lang/rust-analyzer/blob/546339a7be357b3e95fc4b79a8816dce540d477b/crates/ide-diagnostics/src/handlers/incorrect_case.rs#L535
2024-09-29Rename object_safety to dyn_compatibilityNoah Bright-2/+2
Up to a trait implemented by another package, linking to $CARGO_HOME/registry/cache/index.crates.io-6f17d22bba15001f/
2024-09-29Fix ambiguity with CamelCase diagnostic messagesMatthew Wilding-1/+1
2024-09-25Prime caches for symbol search too.Kevin Reid-0/+16
2024-09-24fix: Temporary fix for `remove_unused_imports` not handling import aliases ↵Shoyu Vanilla-3/+20
correctly
2024-09-18Auto merge of #18131 - ChayimFriedman2:macro-expand-dollar-crate, r=Veykrilbors-1/+1
fix: Get rid of `$crate` in expansions shown to the user Be it "Expand Macro Recursively", "Inline macro" or few other things. We replace it with the crate name, as should've always been. Probably fixes some issues, but I don't know what they are.
2024-09-18Get rid of `$crate` in expansions shown to the userChayim Refael Friedman-1/+1
Be it "Expand Macro Recursively", "Inline macro" or few other things. We replace it with the crate name, as should've always been.
2024-09-17internal: Extend `SourceChangeBuilder` to make make working with ↵DropDemBits-1/+95
`SyntaxEditor`s easier
2024-09-10refactor: introduce NameGenerator in suggest_nameroife-62/+150
2024-09-09Auto merge of #18041 - roife:fix-issue-17631, r=Veykrilbors-1/+95
feat: better name suggestions for fn fix #17631. Better name suggestions for fn-calls / method-calls in the form of `from()`, `from_xxx()`, `into()`, etc.
2024-09-09feat: better name suggestions for fnroife-1/+95
2024-09-05Support more IDE features for asm operandsLukas Wirth-6/+22
2024-09-05Give InlineAsmOperand a HIR representationLukas Wirth-26/+37
2024-09-05Add Definition kind for asm register operandLukas Wirth-4/+15
2024-09-05Add Definition kind for asm register classesLukas Wirth-3/+12
2024-09-03feat: suggest name in let_stmt and fn_paramroife-2/+16
2024-09-03refactor: move ide_assist::utils::suggest_name to ide-dbroife-0/+821
2024-09-01internal: Lay basic ground work for standalone mbe testsLukas Wirth-137/+1
2024-08-26Auto merge of #17941 - ChayimFriedman2:pre-closure-to-fn, r=Veykrilbors-4/+6
Preliminary work for #17940 I split the PR as requested, and made small commits.
2024-08-25Auto merge of #17958 - Veykril:deref-chain-method-completions, r=Veykrilbors-30/+51
fix: Fix trait method completions not acknowledging Deref impls
2024-08-25fix: Fix trait method completions not acknowledging Deref implsLukas Wirth-30/+51
2024-08-25Don't enable the search fast path for short associated functions when a ↵Chayim Refael Friedman-0/+4
search scope is set In most places where we set a search scope it is a single file, and so the fast path will actually harm performance, since it has to search for aliases in the whole project. The only exception that qualifies for the fast path is SSR (there is an exception that don't qualify for the fast path as it search for `use` items). It sets the search scope to avoid dependencies. We could make it use the fast path, but I didn't bother.
2024-08-24Modify `hacks::parse_expr_from_str()` to take an edition tooChayim Refael Friedman-4/+6
This will be needed as we parse unknown identifiers and want to insert them into source code.
2024-08-22Add cov_marks to test #17927Chayim Refael Friedman-0/+9
2024-08-22Speed up search for short associated functions, especially very common ↵Chayim Refael Friedman-80/+427
identifiers such as `new` The search is used by IDE features such as rename and find all references. The search is slow because we need to verify each candidate, and that requires analyzing it; the key to speeding it up is to avoid the analysis where possible. I did that with a bunch of tricks that exploits knowledge about the language and its possibilities. The first key insight is that associated methods may only be referenced in the form `ContainerName::func_name` (parentheses are not necessary!) (Rust doesn't include a way to `use Container::func_name`, and even if it will in the future most usages are likely to stay in that form. Searching for `::` will help only a bit, but searching for `Container` can help considerably, since it is very rare that there will be two identical instances of both a container and a method of it. However, things are not as simple as they sound. In Rust a container can be aliased in multiple ways, and even aliased from different files/modules. If we will try to resolve the alias, we will lose any gain from the textual search (although very common method names such as `new` will still benefit, most will suffer because there are more instances of a container name than its associated item). This is where the key trick enters the picture. The key insight is that there is still a textual property: a container namer cannot be aliased, unless its name is mentioned in the alias declaration, or a name of alias of it is mentioned in the alias declaration. This becomes a fixpoint algorithm: we expand our list of aliases as we collect more and more (possible) aliases, until we eventually reach a fixpoint. A fixpoint is not guaranteed (and we do have guards for the rare cases where it does not happen), but it is almost so: most types have very few aliases, if at all. We do use some semantic information while analyzing aliases. It's a balance: too much semantic analysis, and the search will become slow. But too few of it, and we will bring many incorrect aliases to our list, and risk it expands and expands and never reach a fixpoint. At the end, based on benchmarks, it seems worth to do a lot to avoid adding an alias (but not too much), while it is worth to do a lot to avoid the need to semantically analyze func_name matches (but again, not too much). After we collected our list of aliases, we filter matches based on this list. Only if a match can be real, we do semantic analysis for it. The results are promising: searching for all references on `new()` in `base-db` in the rust-analyzer repository, which previously took around 60 seconds, now takes as least as two seconds and a half (roughly), while searching for `Vec::new()`, almost an upper bound to how much a symbol can be used, that used to take 7-9 minutes(!) now completes in 100-120 seconds, and with less than half of non-verified results (aka. false positives). This is the less strictly correct (but faster) of this patch; it can miss some (rare) cases (there is a test for that - `goto_ref_on_short_associated_function_complicated_type_magic_can_confuse_our_logic()`). There is another branch that have no false negatives but is slower to search (`Vec::new()` never reaches a fixpoint in aliases collection there). I believe it is possible to create a strategy that will have the best of both worlds, but it will involve significant complexity and I didn't bother, especially considering that in the vast majority of the searches the other branch will be more than enough. But all in all, I decided to bring this branch (of course if the maintainers will agree), since our search is already not 100% accurate (it misses macros), and I believe there is value in the additional perf.
2024-08-22Fully remove old macro descension APILukas Wirth-7/+6