about summary refs log tree commit diff
path: root/src/tools/rust-analyzer/crates
AgeCommit message (Collapse)AuthorLines
2024-10-14Auto merge of #18291 - roife:fix-issue-18212, r=Veykrilbors-18/+139
feat: respect references.exclude_tests in call-hierarchy close #18212 ### Changes 1. feat: respect `references.exclude_tests` in call-hierarchy 2. Modified the description of `references.exclude_tests`
2024-10-14Auto merge of #18275 - darichey:fix-test-case-hang, r=Veykrilbors-2/+5
Skip #[test_case] expansion Fixes #18274, although I don't fully understand if this is the best fix (it's not clear to me why this didn't cause issues before https://github.com/rust-lang/rust-analyzer/pull/18085).
2024-10-14Auto merge of #18252 - ShoyuVanilla:issue-15799, r=Veykrilbors-1/+37
fix: Do not consider mutable usage of deref to `*mut T` as deref_mut Fixes #15799 We are doing some heuristics for deciding whether the given deref is deref or deref_mut here; https://github.com/rust-lang/rust-analyzer/blob/5982d9c420d0dc90739171829f0d2e9c80d98979/crates/hir-ty/src/infer/mutability.rs#L182-L200 But this heuristic is erroneous if we are dereferencing to a mut ptr and normally those cases are filtered out here as builtin; https://github.com/rust-lang/rust-analyzer/blob/5982d9c420d0dc90739171829f0d2e9c80d98979/crates/hir-ty/src/mir/lower/as_place.rs#L165-L177 Howerver, this works not so well if the given dereferencing is double dereferencings like the case in the #15799. ```rust struct WrapPtr(*mut u32); impl core::ops::Deref for WrapPtr { type Target = *mut u32; fn deref(&self) -> &Self::Target { &self.0 } } fn main() { let mut x = 0u32; let wrap = WrapPtr(&mut x); unsafe { **wrap = 6; } } ``` Here are two - outer and inner - dereferences here, and the outer dereference is marked as deref_mut because there is an assignment operation. And this deref_mut marking is propagated into the inner dereferencing. In the later MIR lowering, the outer dereference is filtered out as it's expr type is `*mut u32`, but the expr type in the inner dereference is an ADT, so this false-mutablility is not filtered out. This PR cuts propagation of this false mutablilty chain if the expr type is mut ptr. Since this happens before the resolve_all, it may have some limitations when the expr type is determined as mut ptr at the very end of inferencing, but I couldn't find simple fix for it 🤔
2024-10-14Auto merge of #18242 - Veykril:veykril/push-tnynzqsmtnqw, r=Veykrilbors-185/+174
internal: Don't resolve extern crates in import fix point resolution The fix point loop won't progress them given the potential extern crate candidates are set up at build time.
2024-10-14Auto merge of #18229 - mrkajetanp:rustfmt-path, r=Veykrilbors-3/+3
fix: Join rustfmt overrideCommand with project root When providing a custom rustfmt command, join it with the project root instead of the workspace root. This fixes rust-analyzer getting the wrong invocation path in projects containing subprojects. This makes the behaviour consistent with how a custom path provided in rust-analyzer.procMacro.server behaves already. Resolves issue #18222
2024-10-14Auto merge of #18217 - ChayimFriedman2:cast-unknown-ptr, r=Veykrilbors-25/+48
fix: Comment out cast checks for unknown ptr kind Just like we don't check for types containing unknown. Fixes #18214. See also https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Another.20case.20of.20.2318064.3F.
2024-10-14Auto merge of #18152 - CryZe:highlight-async-block-exit-points, r=Veykrilbors-73/+101
feat: Highlight exit points of async blocks Async blocks act similar to async functions in that the await keywords are related, but also act like functions where the exit points are related. Fixes #18147
2024-10-14Auto merge of #18226 - SabrinaJewson:fix-impl-use, r=Veykrilbors-1/+29
Correctly parse `use` in generic parameters Fixes: #18225
2024-10-13Add wrap/unwrap return type in OptionGiga Bowser-0/+2348
2024-10-13feat: respect references.exclude_tests in call-hierarchyroife-18/+139
2024-10-12Fix panic when json project has relative buildfile pathsDavid Richey-1/+1
2024-10-09Skip #[test_case] expansionDavid Richey-2/+5
2024-10-09Auto merge of #18245 - boattime:master, r=davidbarskybors-2/+2
fix: include description in label details when detail field is marked for … Fixes https://github.com/rust-lang/rust-analyzer/issues/18231. When omitting the autocomplete detail field, the autocomplete label details can still be returned. Currently the label details are missing the description field if the detail field is included in resolveSupport since it is being overwritten as None and opted to be sent with `completionItem/resolve`. Example completion capabilities. ``` completion = { completionItem = { commitCharactersSupport = true, deprecatedSupport = true, documentationFormat = { "markdown", "plaintext" }, insertReplaceSupport = true, insertTextModeSupport = { valueSet = { 1, 2 } }, labelDetailsSupport = true, preselectSupport = true, resolveSupport = { properties = { "documentation", "detail", "additionalTextEdits", "sortText", "filterText", "insertText", "textEdit", "insertTextFormat", "insertTextMode" } }, snippetSupport = true, tagSupport = { valueSet = { 1 } } } ```
2024-10-09Auto merge of #18247 - jhgg:lsp/fix-something-to-resolve, r=Veykrilbors-7/+7
lsp: fix completion_item something_to_resolve not being a latch to true while looking at #18245 i noticed that `something_to_resolve` could technically flap between true -> false if some subsequent fields that were requested to be resolved were empty. this fixes that by using `|=` instead of `=` when assigning to `something_to_resolve` which will prevent it from going back to false once set. although some cases it's simply assigning to `true` i opted to continue to use `|=` there for uniformity sake. but happy to change those back to `=`'s. cc `@SomeoneToIgnore`
2024-10-09Auto merge of #18246 - ChayimFriedman2:fix-18238, r=Veykrilbors-1/+34
fix: Fix `prettify_macro_expansion()` when the node isn't the whole file Fixes #18238.
2024-10-08Reserve guarded string literals (RFC 3593)Peter Jaszkowiak-0/+6
2024-10-08Only Highlight Exit Points on `async` TokenChristopher Serr-7/+13
This ensures that when being on an `await` token, it still only highlights the yield points and not the exit points.
2024-10-08include fn prefix for all callable defsJake-36/+29
2024-10-08hir-ty: change struct constructor formatting.Jake-53/+54
before, when formatting struct constructor for `struct S(usize, usize)` it would format as: extern "rust-call" S(usize, usize) -> S but after this change, we'll format as: fn S(usize, usize) -> S
2024-10-08Merge from rust-lang/rustLaurențiu Nicola-0/+7
2024-10-06Use external stack in borrowck DFSChayim Refael Friedman-58/+67
Because damnit, it can crash r-a. Why do people make this stupid DFSes anyway (I get it, it's easier until it blows).
2024-10-07fix: Do not consider mutable usage of deref to `*mut T` as deref_mutShoyu Vanilla-1/+37
2024-10-05lsp: fix completion_item something_to_resolve not being a latch to trueJake-7/+7
2024-10-05Fix `prettify_macro_expansion()` when the node isn't the whole fileChayim Refael Friedman-1/+34
2024-10-05Include description in label details when detail field is marked for resolutionMax-2/+2
2024-10-05Fix IDE layer not correctly resolving opt-in extern cratesLukas Wirth-7/+18
2024-10-05Add excluded extern-prelude IDE resolution testLukas Wirth-3/+9
2024-10-05Turn ImportSource into a structLukas Wirth-46/+54
2024-10-05Remove ImportSource::ExternCrate as the fixed point loop can't affect itLukas Wirth-138/+102
2024-10-04Auto merge of #18227 - davidbarsky:davidbarsky/push-lmntvwvznyyx, r=davidbarskybors-61/+181
internal: add json `tracing` Layer for profiling startup On `buck2/integrations/rust-project`, this results in the following being printed: ```json {"name":"discover_command","elapsed_ms":18703} {"name":"parallel_prime_caches","elapsed_ms":0} {"name":"vfs_load","elapsed_ms":5895} {"name":"vfs_load","elapsed_ms":547} {"name":"parallel_prime_caches","elapsed_ms":23} {"name":"parallel_prime_caches","elapsed_ms":84} {"name":"parallel_prime_caches","elapsed_ms":5819} ```
2024-10-04internal: add JSON formatting for hprofDavid Barsky-61/+181
2024-10-04Auto merge of #18234 - Veykril:veykril/push-vzynqtlxmrnl, r=Veykrilbors-70/+114
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-70/+114
2024-10-02fix: Join rustfmt overrideCommand with project rootKajetan Puchalski-3/+3
When providing a custom rustfmt command, join it with the project root instead of the workspace root. This fixes rust-analyzer getting the wrong invocation path in projects containing subprojects. This makes the behaviour consistent with how a custom path provided in rust-analyzer.procMacro.server behaves already. Resolves issue #18222
2024-10-01fix: correctly parse `use` in generic parametersSabrinaJewson-1/+29
2024-10-01Fix: Handle block exprs as modules when finding their parentsShoyu Vanilla-7/+46
2024-09-30Comment out cast checks for unknown ptr kindChayim Refael Friedman-25/+48
Just like we don't check for types containing unknown.
2024-09-30internal: remove `Default` from OpQueueDavid Barsky-24/+40
2024-09-30Auto merge of #18210 - ChayimFriedman2:label-macro, r=Veykrilbors-27/+71
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-24/+40
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-74/+225
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-30Auto merge of #18207 - mbwilding:master, r=Veykrilbors-21/+21
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-30Auto merge of #18085 - ChayimFriedman2:gate-test, r=Veykrilbors-18/+93
feat: Provide an config option to not set `cfg(test)` Fixes #17957.
2024-09-30Gate `#[test]` expansion under `cfg(test)`.Chayim Refael Friedman-45/+78
This will mean users opting to not activate `cfg(test)` will lose IDE experience on them, which is quite unfortunate, but this is unavoidable if we want to avoid false positives on e.g. diagnostics. The real fix is to provide IDE experience even for cfg'ed out code, but this is out of scope for this PR.
2024-09-30Provide an config option to not set `cfg(test)`Chayim Refael Friedman-15/+57
2024-09-29Auto merge of #18205 - noahmbright:object_safety, r=HKalbasibors-105/+111
Rename object_safety First PR here (yay!), so I read some of the getting started docs. There are a couple references to `handlers.rs`, which as far as I can tell has been refactored into `handlers/*.rs`. I made some tweaks to that in one commit. There is one fixme about a function called `to_lsp_runnable`, which I can't find anywhere at all. I can update that if I get some more info there. Otherwise I changed references to object safety, is object safe, etc., trying to match case/style as I went. There was one case I found where there's a trait from somewhere else called `is_object_safe`, which I found defined in my cargo registry. I didn't touch that for now, just marked it with a fixme
2024-09-29When glueing together tokens from macros, merge their spansChayim Refael Friedman-3/+31
2024-09-29Auto merge of #18208 - davidbarsky:davidbarsky/push-qkwkmttnukqt, r=lnicolabors-3/+12
internal: allow overriding proc macro server in analysis-stats Needed this argument in order to profile the proc macro expansion server (c.f., [this Zulip conversation](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/.60macro_rules!.60-based.20macros.20for.20derives.2Fattributes/near/473466794)). I also took the opportunity to change the phrasing for `--proc-macro-srv`. Ran with `samply record ~/.cargo/bin/rust-analyzer analysis-stats --proc-macro-srv /Users/dbarsky/.cargo/bin/rust-analyzer-proc-macro-srv --parallel .` on rust-analyzer itself.
2024-09-29internal: allow overriding proc macro server in analysis-statsDavid Barsky-3/+12
2024-09-29Rename object_safety to dyn_compatibilityNoah Bright-105/+111
Up to a trait implemented by another package, linking to $CARGO_HOME/registry/cache/index.crates.io-6f17d22bba15001f/