summary refs log tree commit diff
path: root/src/tools/rust-analyzer/crates/ide
AgeCommit message (Collapse)AuthorLines
2024-11-25Revert "Prepare for omittiong parts of completion data that need to be resolved"Kirill Bulatov-2/+2
This reverts commit 008d5130b7dce96693cd9c39cd5e71d9dc73bd5b.
2024-10-04Auto merge of #18234 - Veykril:veykril/push-vzynqtlxmrnl, r=Veykrilbors-4/+5
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-4/+5
2024-10-01Fix: Handle block exprs as modules when finding their parentsShoyu Vanilla-2/+36
2024-09-30Auto merge of #18210 - ChayimFriedman2:label-macro, r=Veykrilbors-0/+18
fix: Fix resolution of label inside macro When working on Something Else (TM) (I left a hint in the commits :P), I noticed to my surprise that labels inside macros are not resolved. This led to a discovery of *two* unrelated bugs, which are hereby fixed in two commits.
2024-09-30When resolving labels in `break` and `continue` for the IDE, do not resolve ↵Chayim Refael Friedman-0/+18
them textually, instead reuse the results of HIR lowering This fixes a bug where labels inside macros were not resolved, but more importantly this prepares us to a future where we have hygiene, and textual equivalence isn't enough to resolve identifiers.
2024-09-30Auto merge of #18167 - SomeoneToIgnore:fat-completions, r=Veykrilbors-2/+2
internal: Send less data during `textDocument/completion` if possible Similar to https://github.com/rust-lang/rust-analyzer/pull/15522, stops sending extra data during `textDocument/completion` if that data was set in the client completions resolve capabilities, and sends those only during `completionItem/resolve` requests. Currently, rust-analyzer sends back all fields (including potentially huge docs) for every completion item which might get large. Same as the other one, this PR aims to keep the changes minimal and does not remove extra computations for such fields — instead, it just filters them out before sending to the client. The PR omits primitive, boolean and integer, types such as `deprecated`, `preselect`, `insertTextFormat`, `insertTextMode`, etc. AND `additionalTextEdits` — this one looks very dangerous to compute for each completion item (as the spec says we ought to if there's no corresponding resolve capabilities provided) due to the diff computations and the fact that this code had been in the resolution for some time. It would be good to resolve this lazily too, please let me know if it's ok to do. When tested with Zed which only defines `documentation` and `additionalTextEdits` in its client completion resolve capabilities, rust-analyzer starts to send almost 3 times less characters: Request: ```json {"jsonrpc":"2.0","id":104,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/ide/src/inlay_hints.rs"},"position":{"line":90,"character":14},"context":{"triggerKind":1}}} ``` <img width="1338" alt="image" src="https://github.com/user-attachments/assets/104f19b5-7095-4fc1-b008-5d829623b2e2"> Before: 381944 characters [before.json](https://github.com/user-attachments/files/17092385/before.json) After: 140503 characters [after.json](https://github.com/user-attachments/files/17092386/after.json) After Zed's [patch](https://github.com/zed-industries/zed/pull/18212) to enable all resolving possible: 84452 characters [after-after.json](https://github.com/user-attachments/files/17092755/after-after.json)
2024-09-29Rename object_safety to dyn_compatibilityNoah Bright-25/+25
Up to a trait implemented by another package, linking to $CARGO_HOME/registry/cache/index.crates.io-6f17d22bba15001f/
2024-09-24Auto merge of #18166 - ChayimFriedman2:dollar-crate-root, r=Veykrilbors-3/+9
fix: Fix a bug in span map merge, and add explanations of how span maps are stored Because it took me hours to figure out that contrary to common sense, the offset stored is the *end* of the node, and we search by the *start*. Which is why we need a convoluted `partition_point()` instead of a simple `binary_search()`. And this was not documented at all. Which made me make mistakes with my implementation of `SpanMap::merge()`. The other bug fixed about span map merging is correctly keeping track of the current offset in presence of multiple sibling macro invocations. Unrelated, but because of the previous issue it took me hours to debug, so I figured out I'll put them together for posterity. Fixes #18163.
2024-09-24Auto merge of #18160 - ChayimFriedman2:fix-18138, r=Veykrilbors-0/+32
fix: Fix name resolution when an import is resolved to some namespace and then later in the algorithm another namespace is added The import is flagged as "indeterminate", and previously it was re-resolved, but only at the end of name resolution, when it's already too late for anything that depends on it. This issue was tried to fix in https://github.com/rust-lang/rust-analyzer/pull/2466, but it was not fixed fully. That PR is also why IDE features did work: the import at the end was resolved correctly, so IDE features that re-resolved the macro path resolved it correctly. I was concerned about the performance of this, but this doesn't seem to regress `analysis-stats .`, so I guess it's fine to land this. I have no idea about the incremental perf however and I don't know how to measure that, although when typing in `zbus` (including creating a new function, which should recompute the def map) completion was fast enough. I didn't check what rustc does, so maybe it does something more performant, like keeping track of only possibly problematic imports. Fixes #18138. Probably fixes #17630.
2024-09-23Support expect in attribute completion and hoverLaurențiu Nicola-3/+27
2024-09-23Prepare for omittiong parts of completion data that need to be resolvedKirill Bulatov-2/+2
2024-09-23Fix a bug in span map merge, and add explanations of how span maps are storedChayim Refael Friedman-3/+9
Because it took me hours to figure out that contrary to common sense, the offset stored is the *end* of the node, and we search by the *start*. Which is why we need a convoluted `partition_point()` instead of a simple `binary_search()`. And this was not documented at all. Which made me make mistakes with my implementation of `SpanMap::merge()`. The other bug fixed about span map merging is correctly keeping track of the current offset in presence of multiple sibling macro invocations. Unrelated, but because of the previous issue it took me hours to debug, so I figured out I'll put them together for posterity.
2024-09-22Fix name resolution when an import is resolved to some namespace and then ↵Chayim Refael Friedman-0/+32
later in the algorithm another namespace is added The import is flagged as "indeterminate", and previously it was re-resolved, but only at the end of name resolution, when it's already too late for anything that depends on it. This issue was tried to fix in https://github.com/rust-lang/rust-analyzer/pull/2466, but it was not fixed fully.
2024-09-18Auto merge of #18131 - ChayimFriedman2:macro-expand-dollar-crate, r=Veykrilbors-27/+117
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-27/+117
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-17Always cache macro expansions' root node in SemanticsChayim Refael Friedman-0/+70
Previously some expansions were not cached, but were cached in the expansion cache, which caused panics when later queries tried to lookup the node from the expansion cache.
2024-09-16Fix printing of constants greater than `i128::MAX`Chayim Refael Friedman-0/+18
2024-09-12Auto merge of #18107 - Veykril:push-oopkquknxqxs, r=Veykrilbors-38/+24
fix: Don't emit empty inlay hint parts
2024-09-12fix: Don't emit empty inlay hint partsLukas Wirth-38/+24
2024-09-11Auto merge of #18075 - roife:fix-issue-17858, r=Veykrilbors-0/+178
feat: render patterns in params for hovering Fix #17858 This PR introduces an option to [hir-def/src/body/pretty.rs](https://github.com/rust-lang/rust-analyzer/blob/08c7bbc2dbe4dcc8968484f1a0e1e6fe7a1d4f6d/crates/hir-def/src/body/pretty.rs) to render the result as a single line, which is then reused for rendering patterns in parameters for hovering.
2024-09-11Lift out workspace related data into a separate query to preserve crategraph ↵Lukas Wirth-5/+13
deduplication
2024-09-09feat: use shorthand when pretty-print record patroife-2/+50
2024-09-09fix: add parenthesis for or-patternroife-1/+16
2024-09-09fix: use `pretty_print_pat` for params in fnroife-0/+115
2024-09-05asm! parsing and lowering fixesLukas Wirth-3/+77
2024-09-05Fix name fetching being incorrect for asm operandsLukas Wirth-2/+10
2024-09-05Support more IDE features for asm operandsLukas Wirth-21/+93
2024-09-05Give InlineAsmOperand a HIR representationLukas Wirth-39/+39
2024-09-05Add Definition kind for asm register operandLukas Wirth-13/+18
2024-09-05Add Definition kind for asm register classesLukas Wirth-5/+175
2024-09-05Lower asm expressionsLukas Wirth-4/+4
2024-09-04Add edition dependent keyword highlighting testsLukas Wirth-7/+320
2024-09-03feat: Implement cast typechecksShoyu Vanilla-0/+4
2024-09-02fix: lifetime hint panic in non generic defsLukas Wirth-1/+19
2024-09-01internal: Lay basic ground work for standalone mbe testsLukas Wirth-5/+0
2024-09-01minor: Reduce friction for updating minicoreLukas Wirth-27/+58
2024-08-31fix: Fix lifetime elision inlay hints breaking for ranged requestsLukas Wirth-57/+59
2024-08-30Support fn-ptr and fn-path types for lifetime elision hintsLukas Wirth-358/+597
2024-08-30Improve inlay hint resolution reliabilityLukas Wirth-205/+266
2024-08-29Do not report missing unsafe on `addr_of[_mut]!(EXTERN_OR_MUT_STATIC)`Chayim Refael Friedman-6/+6
The compiler no longer does as well; see https://github.com/rust-lang/rust/pull/125834.
2024-08-29Auto merge of #17814 - ShoyuVanilla:object-safety, r=Veykrilbors-8/+94
feat: Implement object safety and its hovering hint Resolves #17779 - [x] Fill missing implementations - [x] Hover rendering - [x] Implement object safety's own test suite, like layout - [x] Add test cases (from rustc maybe) - [x] Clean up ugly codes - [x] Add doc string
2024-08-29feat: Implement object safetyShoyu Vanilla-8/+94
2024-08-28Fix name resolution of shadowed builtin macroChayim Refael Friedman-0/+19
2024-08-27Revert "feat: Implement `module_path` macro"Lukas Wirth-71/+3
2024-08-26Auto merge of #17963 - avrong:avrong/error-lifetimes, r=Veykrilbors-1/+1
Always show error lifetime arguments as `'_` Fixes #17947 Changed error lifetime argument presentation in non-test environment to `'_` and now showing them even if all of args are error lifetimes. This also influenced some of the other tests like `extract_function.rs`, `predicate.rs` and `type_pos.rs`. Not sure whether I need to refrain from adding lifetimes args there. Happy to fix if needed
2024-08-26Show and render error lifetime args as `'_`Aleksei Trifonov-1/+1
2024-08-26Auto merge of #17941 - ChayimFriedman2:pre-closure-to-fn, r=Veykrilbors-3/+3
Preliminary work for #17940 I split the PR as requested, and made small commits.
2024-08-24Provide `Future::Output` and `Iterator` lang itemsChayim Refael Friedman-3/+3
2024-08-23Auto merge of #17936 - Veykril:module_path, r=Veykrilbors-3/+71
feat: Implement `module_path` macro Turns out this is a pain to implement because of our hir-def hir-expand split :)