Commit graph

25486 commits

Author SHA1 Message Date
Andreas Backx
942b392150
Exclude Markdown injection grammar from .vscodeignore.
Enables Markdown injection introduced in #14866 but wasn't included in release due to it being ignored.
2023-06-11 22:53:58 -07:00
hkalbasi
a4695788ca Add a bunch of fixme comments 2023-06-12 00:37:11 +03:30
bors
d567091f47 Auto merge of #15028 - Veykril:rustfmt-thread, r=Veykril
internal: Give rustfmt jobs a separate thread

Some light testing suggests that this fixes the waiting on formatting popup in vscode when the project is still building (which is usually the way for me to encounter it, as r-a is either waiting or getting little resources causing the tasks to block formatting)
2023-06-11 18:14:54 +00:00
Lukas Wirth
179b8d7efc
Formatting
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2023-06-11 20:11:26 +02:00
Lukas Wirth
52bb94d697 internal: Give rustfmt jobs a separate thread 2023-06-11 19:56:24 +02:00
Ryo Yoshida
42eab5e100
Deduplicate field names for completion 2023-06-11 19:34:27 +09:00
Ryo Yoshida
b4795507e3
autoderef: completely resolve and deduplicate types 2023-06-11 19:34:22 +09:00
bors
b7497fcdfa Auto merge of #15025 - lowr:fix/nested-macro-in-assoc-item-panic, r=lnicola
minor: remove commented out conflicts

Follow-up to #14989 🤦‍♂️
2023-06-11 09:00:00 +00:00
Ryo Yoshida
ed8c58a3b1
Remove commented out conflicts 2023-06-11 17:14:36 +09:00
bors
c3bab96b80 Auto merge of #14989 - lowr:fix/nested-macro-in-assoc-item-panic, r=Veykril
fix: derive source scope from syntax node to be transformed

Fixes #14534

When we use `PathTransform` for associated items of a trait, we have been feeding `SemanticsScope` for the trait definition to it as source scope. `PathTransform` uses the source scope to resolve paths in associated items to find which path to transform. In the course of path resolution, the scope is responsible for lowering `ast::MacroType`s (because they can be written within a path) using `AstIdMap` for the scope's `HirFileId`.

The problem here is that when an associated item is generated by a macro, the scope for the trait is different from the scope for that associated item. The former can only resolve the top-level macros within the trait definition but not the macro calls generated by those top-level macros. We need the latter to resolve such nested macros.

This PR makes sure that we pass `SemanticsScope` for each associated item we're applying path transformation to.
2023-06-11 07:10:27 +00:00
Ryo Yoshida
d091991491
fix(completion): derive source scope from syntax node to be transformed 2023-06-11 15:25:43 +09:00
Ryo Yoshida
008f5065d1
fix(assist): derive source scope from syntax node to be transformed 2023-06-11 15:25:36 +09:00
hkalbasi
e83b56739f Flatten the TypeOwnerId 2023-06-11 01:36:32 +03:30
hkalbasi
f8594f78bb Use ConstArg instead of Expr for AstId of InTypeConstId 2023-06-11 00:39:28 +03:30
hkalbasi
d9136df9e5 Handle return types for in type const bodies 2023-06-11 00:39:28 +03:30
hkalbasi
a481e004b0 Lower const params with a bad id 2023-06-11 00:39:28 +03:30
bors
68bdf609f3 Auto merge of #14974 - max-heller:issue-14958, r=lowr
Properly format documentation for `SignatureHelpRequest`s

Properly formats function documentation instead of returning it raw when responding to `SignatureHelpRequest`s.

I added a test in `crates/rust-analyzer/tests/slow-tests/main.rs` -- not sure if this is the best location given the relevant code is in `crates/rust-analyzer` or if it's possible to test in a less heavyweight manner.

Closes #14958
2023-06-10 14:15:37 +00:00
max-heller
78fab7d5d5 format documentation for SignatureHelpRequests 2023-06-10 09:54:34 -04:00
bors
95228d23bb Auto merge of #14875 - ponyii:fix/implement-missing-members-do-not-transform-lifetimes, r=Veykril
fix: implemeted lifetime transformation fot assits

A part of https://github.com/rust-lang/rust-analyzer/issues/13363
I expect to implement transformation of const params in a separate PR

Other assists and a completion affected:
- `generate_function` currently just ignores lifetimes and, consequently, is not affected
- `inline_call` and `replace_derive_with...` don't seem to need lifetime transformation
- `trait_impl` (a completion) is fixed and tested
2023-06-10 13:22:50 +00:00
bors
cee7a72d81 Auto merge of #14827 - davidlattimore:autopublish-offset, r=Veykril
autopublish: Offset version number

The workflow is currently failing because it's trying to publish 0.0.16, while the last version published was 0.0.149.
2023-06-10 11:33:06 +00:00
bors
489eeab978 Auto merge of #14960 - jneem:group-delim-span, r=Veykril
Add span to group.

This appears to fix #14959, but I've never contributed to rust-analyzer before and there were some things that confused me:

- I had to add the `fn byte_range` method to get it to build. This was added to rust in [April](https://github.com/rust-lang/rust/pull/109002), so I don't understand why it wasn't needed until now
- When testing, I ran into the fact that rust recently updated its `METADATA_VERSION`, so I had to test this with nightly-2023-05-20. But then I noticed that rust has its own copy of `rust-analyzer`, and the metadata version bump has already been [handled there](60e95e76d0). So I guess I don't really understand the relationship between the code there and the code here.
2023-06-10 11:15:16 +00:00
bors
49b4f15973 Auto merge of #15022 - HKalbasi:nightly-mir-eval-panic, r=HKalbasi
Fix panic in displaying unsized structs
2023-06-10 08:06:56 +00:00
hkalbasi
1dd76e8a9d Fix panic in displaying unsized structs 2023-06-10 11:32:37 +03:30
bors
5f8a6f67b9 Auto merge of #15020 - Veykril:perf2, r=Veykril
Count query entries in memory usage command
2023-06-09 23:50:34 +00:00
Lukas Wirth
ccce893577 Count query entries in memory usage command 2023-06-10 01:49:32 +02:00
Lukas Wirth
b6fb35f20c Shrink hir_expand::attr::AttrInput by boxing a variant 2023-06-10 01:21:52 +02:00
bors
993299ee3f Auto merge of #15019 - HKalbasi:nightly-mir-eval-panic, r=HKalbasi
Fix panic in displaying const trait objects

I hope this fixes the panic on recent nightly stdlib, but I didn't test it locally.
2023-06-09 22:43:58 +00:00
hkalbasi
6fbf6ef514 Fix panic in displaying const trait objects 2023-06-10 02:10:52 +03:30
bors
60d952e902 Auto merge of #14979 - DropDemBits:structure-snippets-migrate-1, r=Veykril
internal: Migrate some assists to use the structured snippet API

Migrates the following assists:

- `add_missing_impl_members`
- `extract_type_alias`

As an additional requirement, these assists are also migrated to use the mutable AST API, since otherwise there would be overlapping `Indel` spans
2023-06-09 19:26:01 +00:00
bors
425619dd28 Auto merge of #15014 - Wilfred:document_sysroot, r=Veykril
Document the sysroot field in JsonProject

rust-analyzer supports both `sysroot` and `sysroot_src` in `rust-project.json`. Document `sysroot` and show example values for both fields.
2023-06-09 18:37:25 +00:00
bors
2796851961 Auto merge of #14998 - Veykril:eager-mapping, r=Veykril
internal: Lazy eager macros

This PR makes eager macros less eager. We now only eagerly expand the input of them, while the actual expansion of the macro itself now happens like other lazy macros.
This change allows unifying a lot of macro handling between the two now, most of the special casing now happens for `include!` specifically as it is a very unique macro (by having two inputs that come from differing files).
Fixes https://github.com/rust-lang/rust-analyzer/issues/14841
Fixes https://github.com/rust-lang/rust-analyzer/issues/14996
2023-06-09 11:15:12 +00:00
Lukas Wirth
a02b9b279e internal: Lazy eager macros 2023-06-09 13:02:13 +02:00
bors
9973b11218 Auto merge of #15012 - lowr:patch/generate-fn-async-ret-ty, r=HKalbasi
Infer return type for async function in `generate_function`

Part of #10122

In `generate_function` assist, when we infer the return type of async function we're generating, we should retrieve the type of parent await expression rather than the call expression itself.
2023-06-09 09:00:45 +00:00
Wilfred Hughes
5da14237eb Document the sysroot field in JsonProject
rust-analyzer supports both `sysroot` and `sysroot_src` in
`rust-project.json`. Document `sysroot` and show example values for
both fields.
2023-06-08 14:56:37 -07:00
bors
9c03aa1ac2 Auto merge of #14997 - lnicola:fix-warning, r=Veykril
internal: Fix dependency warning

Hope this doesn't break #14984 again.
2023-06-08 15:48:58 +00:00
Ryo Yoshida
32768fe310
Infer return type for async function in generate_function 2023-06-09 00:32:52 +09:00
bors
9157927772 Auto merge of #15006 - HKalbasi:format-panic, r=HKalbasi
Fix unwrap on None in expanding format args

fix #15002
2023-06-07 20:48:09 +00:00
hkalbasi
30e16e20d0 Fix unwrap on None in expanding format args 2023-06-08 00:17:22 +03:30
bors
dcab226210 Auto merge of #15005 - beyarkay:rebuild-to-rebuilt-typo, r=lnicola
Fix typo in reload.rs

Thanks for the amazing LSP! I found a small typo and fixed it.
2023-06-07 19:01:35 +00:00
beyarkay
dac660dc1d Fix typo in reload.rs 2023-06-07 20:57:27 +02:00
Joe Neeman
ad2a0d1093 Add configurable proc-macro-srv path for diagnostics 2023-06-07 08:48:19 -05:00
Joe Neeman
cdab3507eb Add span to group. 2023-06-07 08:48:19 -05:00
bors
085a3112ae Auto merge of #15000 - lowr:fix/builtin-derive-bound-for-assoc, r=HKalbasi
fix: only generate trait bound for associated types in field types

Given the following definitions:

```rust
trait Trait {
    type A;
    type B;
    type C;
}

#[derive(Clone)]
struct S<T: Trait>
where
    T::A: Send,
{
    qualified: <T as Trait>::B,
    shorthand: T::C,
}
```

we currently expand the derive macro to:

```rust
impl<T> Clone for S<T>
where
    T: Trait + Clone,
    T::A: Clone,
    T::B: Clone,
    T::C: Clone,
{ /* ... */ }
```

This does not match how rustc expands it. Specifically, `Clone` bounds for `T::A` and `T::B` should not be generated.

The criteria for associated types to get bound seem to be 1) the associated type appears as part of field types AND 2) it's written in the shorthand form. I have no idea why rustc doesn't consider qualified associated types (there's even a comment that suggests they should be considered; see rust-lang/rust#50730), but it's important to follow rustc.
2023-06-07 13:00:24 +00:00
Ryo Yoshida
4f0c6fac17
fix: only generate trait bound for associated types in field types 2023-06-07 20:52:49 +09:00
Laurențiu Nicola
08ef169435 Fix dependency warning 2023-06-07 12:34:38 +03:00
bors
1c25885bd2 Auto merge of #14995 - Veykril:proc-macro-slow-test, r=lnicola
fix: Fix proc-macro slow test
2023-06-07 05:04:33 +00:00
Lukas Wirth
a6bef7808f fix: Fix proc-macro slow test 2023-06-07 07:03:27 +02:00
bors
058e2d2bdd Auto merge of #14925 - viktorlott:inline-const-expr-as-static-str, r=HKalbasi
feat: inline const as literal

Assist: inline_const_as_literal

Evaluate and inline const variable as literal.

```rust
const STRING: &str = "Hello, World!";

fn something() -> &'static str {
    STR$0ING
}
```
->
```rust
const STRING: &str = "Hello, World!";

fn something() -> &'static str {
    "Hello, World!"
}
```
2023-06-06 21:30:30 +00:00
bors
f3145dc1f1 Auto merge of #14994 - Veykril:ci-fix, r=Veykril
fix: Fix ci never running on nightly when proc-macro things change

Was wondering why this wasn't running on the subtree sync ...
2023-06-06 21:03:56 +00:00
Lukas Wirth
ef09558575 fix: Fix ci never running on nightly when proc-macro things change 2023-06-06 23:02:58 +02:00