Commit graph

31798 commits

Author SHA1 Message Date
bors
4717b2bb14 Auto merge of #18152 - CryZe:highlight-async-block-exit-points, r=Veykril
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-14 11:09:33 +00:00
bors
b5187ab853 Auto merge of #18226 - SabrinaJewson:fix-impl-use, r=Veykril
Correctly parse `use` in generic parameters

Fixes: #18225
2024-10-14 10:40:37 +00:00
bors
d7628c0a8b Auto merge of #18281 - darichey:async-subprocess, r=lnicola
Run subprocesses async in vscode extension

Extensions should not block the vscode extension host. Replace uses of `spawnSync` with `spawnAsync`, a convenience wrapper around `spawn`.

These `spawnSync`s are unlikely to cause a real issue in practice, because they spawn very short-lived processes, so we aren't blocking for very long. That said, blocking the extension host is poor practice, and if they _do_ block for too long for whatever reason, vscode becomes useless.
2024-10-12 07:45:15 +00:00
bors
b551482c41 Auto merge of #18289 - darichey:fix-relative-buildfiles, r=lnicola
Fix panic when json project has relative buildfile paths

The `build_file` path may be relative to the workspace root.
2024-10-12 07:30:26 +00:00
David Richey
eded3a8e29 Fix panic when json project has relative buildfile paths 2024-10-12 02:25:40 -05:00
David Richey
0260e41283 Run subprocesses async in vscode extension 2024-10-10 20:44:13 -05:00
bors
0fb804acb3 Auto merge of #18245 - boattime:master, r=davidbarsky
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-09 20:23:52 +00:00
bors
7692c82e0b Auto merge of #18247 - jhgg:lsp/fix-something-to-resolve, r=Veykril
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-09 15:35:33 +00:00
bors
e33e819b12 Auto merge of #18246 - ChayimFriedman2:fix-18238, r=Veykril
fix: Fix `prettify_macro_expansion()` when the node isn't the whole file

Fixes #18238.
2024-10-09 15:20:47 +00:00
bors
9aa4293594 Auto merge of #18269 - jhgg:hir-ty/change-struct-constructor-formatting, r=flodiebold
hir-ty: change struct + enum variant constructor formatting.

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

likewise the second commit, also makes this uniform for enum variants as well.

fixes #18259
2024-10-09 07:09:06 +00:00
Christopher Serr
68c263bdf6 Only Highlight Exit Points on async Token
This ensures that when being on an `await` token, it still only
highlights the yield points and not the exit points.
2024-10-08 23:30:05 +02:00
Jake
9434ceba40
include fn prefix for all callable defs 2024-10-08 11:37:08 -07:00
Jake
5cba3e72bc
hir-ty: change struct constructor formatting.
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-08 11:05:03 -07:00
bors
efaf8bd5de Auto merge of #18267 - lnicola:sync-from-rust, r=lnicola
minor: Sync from downstream
2024-10-08 11:27:18 +00:00
Laurențiu Nicola
b9e58a2379 Merge from rust-lang/rust 2024-10-08 14:25:39 +03:00
Laurențiu Nicola
a9ed9c51fd Preparing for merge from rust-lang/rust 2024-10-08 14:25:24 +03:00
bors
9806060d55 Auto merge of #18266 - lnicola:macos-13, r=lnicola
internal: Use macos-13 runners and bump MACOSX_DEPLOYMENT_TARGET to 13.0

As Monterey seems to be EOL.
2024-10-08 10:39:04 +00:00
Laurențiu Nicola
525c1ceaf0 Use macos-13 runners and bump MACOSX_DEPLOYMENT_TARGET 2024-10-08 13:00:58 +03:00
bors
2b750da1a1 Auto merge of #18255 - ChayimFriedman2:stack-overflow, r=HKalbasi
Use external stack in borrowck DFS

Because damnit, it can crash r-a. Why do people make this stupid DFSes anyway (I get it, it's easier until it blows).

Fixes #18223 (who thought DFS will be the problem).
2024-10-06 21:23:00 +00:00
Chayim Refael Friedman
13f853464c Use external stack in borrowck DFS
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-06 23:48:16 +03:00
bors
b1cc7b0746 Auto merge of #130540 - veera-sivarajan:fix-87525, r=estebank
Add a Lint for Pointer to Integer Transmutes in Consts

Fixes #87525

This PR adds a MirLint for pointer to integer transmutes in const functions and associated consts. The implementation closely follows this comment: https://github.com/rust-lang/rust/pull/85769#issuecomment-880969112. More details about the implementation can be found in the comments.

Note: This could break some sound code as mentioned by RalfJung in https://github.com/rust-lang/rust/pull/85769#issuecomment-886491680:

> ... technically const-code could transmute/cast an int to a ptr and then transmute it back and that would be correct -- so the lint will deny some sound code. Does not seem terribly likely though.

References:
1. https://doc.rust-lang.org/std/mem/fn.transmute.html
2. https://doc.rust-lang.org/reference/items/associated-items.html#associated-constants
2024-10-06 02:39:23 +00:00
Jake
bab2a6ec94
lsp: fix completion_item something_to_resolve not being a latch to true 2024-10-05 15:51:23 -07:00
Chayim Refael Friedman
c8540e7079 Fix prettify_macro_expansion() when the node isn't the whole file 2024-10-05 22:39:33 +03:00
Max
b857a0b488 Include description in label details when detail field is marked for resolution 2024-10-05 13:27:03 -04:00
bors
d03c7511be Auto merge of #130157 - eduardosm:stabilize-const_float_classify, r=RalfJung
Stabilize `const_float_classify`

Tracking issue: https://github.com/rust-lang/rust/issues/72505

Also reverts https://github.com/rust-lang/rust/pull/114486

Closes https://github.com/rust-lang/rust/issues/72505

Stabilized const API:

```rust
impl f32 {
    pub const fn is_nan(self) -> bool;
    pub const fn is_infinite(self) -> bool;
    pub const fn is_finite(self) -> bool;
    pub const fn is_subnormal(self) -> bool;
    pub const fn is_normal(self) -> bool;
    pub const fn classify(self) -> FpCategory;
    pub const fn is_sign_positive(self) -> bool;
    pub const fn is_sign_negative(self) -> bool;
}

impl f64 {
    pub const fn is_nan(self) -> bool;
    pub const fn is_infinite(self) -> bool;
    pub const fn is_finite(self) -> bool;
    pub const fn is_subnormal(self) -> bool;
    pub const fn is_normal(self) -> bool;
    pub const fn classify(self) -> FpCategory;
    pub const fn is_sign_positive(self) -> bool;
    pub const fn is_sign_negative(self) -> bool;
}
```

cc `@rust-lang/wg-const-eval` `@rust-lang/libs-api`
2024-10-04 18:03:16 +00:00
bors
5982d9c420 Auto merge of #18227 - davidbarsky:davidbarsky/push-lmntvwvznyyx, r=davidbarsky
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-04 17:59:02 +00:00
David Barsky
56c10ca981 internal: add JSON formatting for hprof 2024-10-04 11:26:15 -04:00
bors
510f72e12c Auto merge of #18234 - Veykril:veykril/push-vzynqtlxmrnl, r=Veykril
internal: Filter out opaque tokens in some IDE feature macro descensions
2024-10-04 10:26:04 +00:00
Lukas Wirth
24d65bb7cf internal: Filter out opaque tokens in some of IDE feature macro descensions 2024-10-04 11:53:12 +02:00
bors
e5be94eff6 Auto merge of #131228 - jdonszelmann:remove-blank-issue, r=m-ou-se
remove blank issue template

r? `@Noratrieb`

So there are currently two blank issue templates. One called "Blank Issue" and one called "Blank issue". Wildly different, of course. It seems that one is auto generated by GitHub, while the other one has an explicit template for it. This removes the explicit one so there's only one "Blank [iI]ssue" in the list. Unfortunately, the only way to test if it works is merging this and finding out, but it seems obvious that it would work.

![image](https://github.com/user-attachments/assets/f802ca88-a80f-48e8-9aff-4008ec030dfa)
2024-10-04 08:07:11 +00:00
bors
a8d74b67f2 Auto merge of #131191 - nnethercote:lattice_op, r=lcnr
Merge `glb` and `lub` modules

Tons of code is duplicated across them, and it's easy to factor that out.

r? `@lcnr`
2024-10-04 01:20:08 +00:00
bors
fea22fb0a3 Auto merge of #130821 - lcnr:nalgebra-hang-2, r=compiler-errors
add caching to most type folders, rm region uniquification

Fixes the new minimization of the hang in nalgebra and nalgebra itself :3

this is a bit iffy, especially the cache in `TypeRelating`. I believe all the caches are correct, but it definitely adds some non-local complexity in places. The first commit removes region uniquification, reintroducing the ICE from https://github.com/rust-lang/trait-system-refactor-initiative/issues/27. This does not affect coherence and I would like to fix this by introducing OR-region constraints

r? `@compiler-errors`
2024-10-02 19:21:44 +00:00
bors
0e5fce7242 Auto merge of #130829 - Urgau:option_array_transpose, r=ibraheemdev
Add `[Option<T>; N]::transpose`

This PR as a new unstable libs API, `[Option<T>; N]::transpose`, which permits going from `[Option<T>; N]` to `Option<[T; N]>`.

This new API doesn't have an ACP as it was directly asked by T-libs-api in https://github.com/rust-lang/rust/issues/97601#issuecomment-2372109119:

> [..] but it'd be trivial to provide a helper method `.transpose()` that turns array-of-Option into Option-of-array (**and we think that method should exist**; it already does for array-of-MaybeUninit).

r? libs
2024-10-02 04:31:15 +00:00
SabrinaJewson
e735906839
fix: correctly parse use in generic parameters 2024-10-01 22:10:47 +01:00
bors
e1a76671af Auto merge of #18219 - Veykril:veykril/push-ytnzuvtoswqz, r=Veykril
fix: Fix bootstrap error message being incorrect

precedence ...
2024-10-01 10:36:27 +00:00
Lukas Wirth
ac4edbf9dc fix: Fix bootstrap error message being incorrect 2024-10-01 12:33:53 +02:00
bors
417ee6f04a Auto merge of #18206 - ShoyuVanilla:issue-18187, r=Veykril
Fix: Handle block exprs as modules when finding their parents

Fixes #18187
2024-10-01 05:32:31 +00:00
Shoyu Vanilla
e09c2a08d7 Fix: Handle block exprs as modules when finding their parents 2024-10-01 14:05:15 +09:00
bors
f0b6f4adb0 Auto merge of #130587 - coolreader18:field-variant-doclink-disambig, r=notriddle,jyn514
Add `field@` and `variant@` doc-link disambiguators

I'm not sure if this is big enough to need an fcp or not, but this is something I found missing when trying to refer to a field in macro-generated docs, not knowing if a method might be defined as well. Obviously, there are definitely other uses.

In the case where it's not disambiguated, methods (and I suppose other associated items in the value namespace) still take priority, which `@jyn514` said was an oversight but I think is probably the desired behavior 99% of the time anyway - shadowing a field with an accessor method is a very common pattern. If fields and methods with the same name started conflicting, it would be a breaking change. Though, to quote them:

> jyn: maybe you can break this only if both [the method and the field] are public
> jyn: rustc has some future-incompat warning level
> jyn: that gets through -A warnings and --cap-lints from cargo

That'd be out of scope of this PR, though.

Fixes #80283
2024-10-01 01:45:35 +00:00
bors
28830ff2f1 Auto merge of #18195 - davidbarsky:davidbarsky/push-xkqnsyksmzqv, r=Veykril
internal: remove `Default` from OpQueue

`@Wilfred` and I were talking about `OpQueue` and we identified one symptom of its (relative) weirdness is that `last_op_result` returns a `T::default()`; not `Option<&T>`, which means it's not possible to distinguish between "the `OpQueue` hasn't run yet" and "the OpQueue ran, but didn't produce a result". This branch fixes that.
2024-09-30 14:20:11 +00:00
David Barsky
fc6eb66450 internal: remove Default from OpQueue 2024-09-30 10:12:52 -04:00
bors
ac8509a74b Auto merge of #18210 - ChayimFriedman2:label-macro, r=Veykril
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-30 13:09:54 +00:00
Chayim Refael Friedman
cd7cbddaf6 When resolving labels in break and continue for the IDE, do not resolve 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-30 15:13:45 +03:00
bors
dfe6d503b8 Auto merge of #18167 - SomeoneToIgnore:fat-completions, r=Veykril
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-30 08:36:54 +00:00
bors
7b60339273 Auto merge of #18207 - mbwilding:master, r=Veykril
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.
546339a7be/crates/hir-ty/src/diagnostics/decl_check.rs (L60)
546339a7be/crates/ide-diagnostics/src/handlers/incorrect_case.rs (L535)
2024-09-30 08:22:29 +00:00
bors
ceee056af6 Auto merge of #18085 - ChayimFriedman2:gate-test, r=Veykril
feat: Provide an config option to not set `cfg(test)`

Fixes #17957.
2024-09-30 06:32:20 +00:00
Chayim Refael Friedman
4a06675e9c Gate #[test] expansion under cfg(test).
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-30 00:12:45 +03:00
Chayim Refael Friedman
4ea09dd9f6 Provide an config option to not set cfg(test) 2024-09-30 00:12:45 +03:00
bors
822644d97d Auto merge of #18205 - noahmbright:object_safety, r=HKalbasi
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-29 20:20:26 +00:00
Chayim Refael Friedman
9798cf81de When glueing together tokens from macros, merge their spans 2024-09-29 22:58:15 +03:00