Commit Graph

27650 Commits

Author SHA1 Message Date
Michel Lind
fafb16b052
lsp-server: add license files
The `lsp-server` crate is currently published without license files, which is
needed when packaging in Linux distributions.

Symlink the files from the repository root so they are kept in sync.

Test showing the files get picked up by `cargo package`:
```
michel in rust-analyzer/lib/lsp-server on  add-lsp-server-license [+] is 📦 v0.7.6 via 🐍 v3.12.1 (.venv311) via 🦀 v1.76.0
⬢ [fedora:39] ❯ cargo package --allow-dirty --no-verify
    Updating crates.io index
   Packaging lsp-server v0.7.6 (/home/michel/src/github/rust-lang/rust-analyzer/lib/lsp-server)
    Updating crates.io index
    Packaged 12 files, 59.6KiB (16.3KiB compressed)

michel in rust-analyzer/lib/lsp-server on  add-lsp-server-license [+] is 📦 v0.7.6 via 🐍 v3.12.1 (.venv311) via 🦀 v1.76.0
⬢ [fedora:39] ❯ tar tf ../../target/package/lsp-server-0.7.6.crate | grep LICENSE
lsp-server-0.7.6/LICENSE-APACHE
lsp-server-0.7.6/LICENSE-MIT
```

Signed-off-by: Michel Lind <salimma@fedoraproject.org>
2024-02-15 18:01:36 -06:00
DropDemBits
bcf14e27ce
Work around snippet edits doubling up extra indentation
We can't tell vscode to not add in the extra indentation, so we instead opt to remove it from the edits themselves, and then let vscode add it back in.
2024-02-15 18:39:17 -05:00
DropDemBits
d846586bc9
fix: Support multiple tab stops in completions in VSCode
Uses the native VSCode support for `SnippetTextEdit`s, but in a semi-hacky way as it's not fully supported yet.
2024-02-15 18:13:04 -05:00
bors
b9b0d29b8e Auto merge of #16574 - davidsemakula:needless-return-fix, r=Veykril
fix: Fix "needless return" diagnostic for trailing item declarations

Fixes #16566
2024-02-15 17:36:17 +00:00
davidsemakula
9ae0f924dd fix "needless return" for trailing item declarations 2024-02-15 20:07:58 +03:00
bors
b30b77d373 Auto merge of #16573 - Veykril:salsa-doc-tests, r=Veykril
internal: Remove salsa doc compile tests

These don't play well with the github CI error annotations
2024-02-15 16:29:39 +00:00
Lukas Wirth
1443d49b72 Remove salsa doc compile tests 2024-02-15 17:28:24 +01:00
bors
db277c7bb3 Auto merge of #16569 - DropDemBits:structured-snippet-fix-adjust-snippet-ranges, r=Veykril
fix: Place snippets correctly in multi-edit assists

Fixes #16539
2024-02-15 15:54:23 +00:00
bors
8443305015 Auto merge of #16559 - Wilfred:scip_documentation_field, r=lnicola
Set documentation field in SCIP from doc comment

Previously, the documentation field was the same as the text shown to users when they hover over that symbol. The documentation should really just be the doc comment, and as of #16179 the signature is already stored in the signatureDocumentation field.
2024-02-15 09:07:29 +00:00
Nicholas Nethercote
d33d8675d0 Add ErrorGuaranteed to ast::LitKind::Err, token::LitKind::Err.
This mostly works well, and eliminates a couple of delayed bugs.

One annoying thing is that we should really also add an
`ErrorGuaranteed` to `proc_macro::bridge::LitKind::Err`. But that's
difficult because `proc_macro` doesn't have access to `ErrorGuaranteed`,
so we have to fake it.
2024-02-15 14:46:08 +11:00
DropDemBits
7cf4a8a3bf
fix: Place snippets correctly in multi-edit assists 2024-02-14 21:35:17 -05:00
DropDemBits
0d6024c021
Add tests for snippet range adjustment
Uses actual source for tests to easily confirm the results.
2024-02-14 21:33:05 -05:00
Wilfred Hughes
dda641c62c Set documentation field in SCIP from doc comment
Previously, the documentation field was the same as the text shown to
users when they hover over that symbol. The documentation should
really just be the doc comment, and as of #16179 the signature is
already stored in the signatureDocumentation field.
2024-02-14 14:46:32 -08:00
bors
dba59970bc Auto merge of #15003 - WaffleLapkin:become_unuwuable, r=Veykril
feature: Add basic support for `become` expr/tail calls

This follows https://github.com/rust-lang/rfcs/pull/3407 and my WIP implementation in the compiler.

Notice that I haven't even *opened* a compiler PR (although I plan to soon), so this feature doesn't really exist outside of my WIP branches. I've used this to help me test my implementation; opening a PR before I forget.

(feel free to ignore this for now, given all of the above)
2024-02-14 15:44:26 +00:00
Maybe Waffle
e146139957 Add support for become expr/tail calls 2024-02-14 14:57:18 +00:00
bors
3bb8d3a32f Auto merge of #16247 - Veykril:opqueues, r=Veykril
fix: Fix build scripts not being rebuilt in some occasions

Also makes proc-macro changed flag setting async, we don't wanna block `process_changes` on the database as that is on the main thread!
2024-02-14 14:33:16 +00:00
bors
004190bb5c Auto merge of #16563 - Veykril:fix-rustup-toolchain-bins, r=Veykril
fix: Set `RUSTUP_TOOLCHAIN` and invoke the proxies instead of directly invoking sysroot binaries

cc https://github.com/rust-lang/rust-analyzer/pull/16537 should fix https://github.com/rust-lang/rust-analyzer/issues/16561
2024-02-14 14:20:47 +00:00
Lukas Wirth
1e6cef94df fix: Fix build scripts not being rebuilt in some occasions 2024-02-14 15:20:45 +01:00
Lukas Wirth
465ddef7cc fix: Set RUSTUP_TOOLCHAIN and invoke the proxies instead of directly invoking sysroot binaries 2024-02-14 15:13:45 +01:00
bors
000ce5d29c Auto merge of #16562 - Veykril:problem-matcher, r=Veykril
internal: Add a clippy and rustfmt problem matcher to CI
2024-02-14 11:40:38 +00:00
Lukas Wirth
f481181a14 Run rustfmt directly on CI 2024-02-14 11:36:25 +01:00
Lukas Wirth
c125e8ca89 Add github ci problem matcher for clippy 2024-02-14 11:26:30 +01:00
bors
efe68e3f78 Auto merge of #16560 - lnicola:sysroot-metadata, r=Veykril
internal: Set channel override when querying the sysroot metadata

This is pretty hard to discover, and makes the setting useless, we should probably enable it for now.

CC #16486
2024-02-14 08:04:34 +00:00
Laurențiu Nicola
c738655188 Set channel override when querying the sysroot metadata 2024-02-14 08:45:11 +02:00
bors
113f054274 Auto merge of #16558 - Wilfred:json_project_ts, r=lnicola
Update JsonProject to include optional fields

These were documented in #15014 in the manual, but this definition wasn't updated to match.
2024-02-14 06:24:56 +00:00
Wilfred Hughes
931f563a89 Update JsonProject to include optional fields
These were documented in #15014 in the manual, but this definition
wasn't updated to match.
2024-02-13 14:29:20 -08:00
bors
a02a219773 Auto merge of #16554 - Veykril:proc-macro-cargo-config-env, r=Veykril
fix: Pass .cargo/config.toml env vars to proc-macro server

Fixes https://github.com/rust-lang/rust-analyzer/issues/13976
2024-02-13 18:43:37 +00:00
Lukas Wirth
a981db53fa fix: Pass .cargo/config.toml env vars to proc-macro server 2024-02-13 19:42:03 +01:00
bors
2c05da15a9 Auto merge of #16553 - Veykril:field-lit-recovery, r=Veykril
fix: Imrpove recover on `=` for record field initializer and pattern
2024-02-13 17:28:36 +00:00
Lukas Wirth
bf115a6064 fix: Recover from = in record pattern field 2024-02-13 18:25:40 +01:00
Lukas Wirth
ccccc299c8 fix: Recover from = in record constructor field assignment 2024-02-13 18:23:33 +01:00
bors
fc1ee6136c Auto merge of #16544 - dfireBird:impl_trait_completion, r=Veykril
Add completions to show only traits in trait `impl` statement

This is prerequisite PR for adding the assist mentioned in #12500

P.S: If wanted, I will add the implementation of the assist in this PR as well.
2024-02-13 16:38:35 +00:00
Lukas Wirth
7f661782cd
Simplify 2024-02-13 17:26:14 +01:00
bors
22ca3fd89d Auto merge of #16550 - DavisVaughan:feature/activate-on-top-level-cargo-toml, r=Veykril
Activate on top level `Cargo.toml` and `rust-project.json` files

I believe there is an issue with how rust-analyzer is activated from within a VS Code project.

IIUC, the intent is that when you open a rust project with a top level `Cargo.toml`, then rust-analyzer should just start right up due to a VS Code activation event. This is not currently the case. i.e. run something like `cargo new ~/Desktop/hithere`, then open that folder in VS Code:

https://github.com/rust-lang/rust-analyzer/assets/19150088/1608b985-fd88-4174-a22a-5b3dd0fad84b

It is not until you actually open a Rust file that the extension starts up.

It looks like this was introduced in https://github.com/rust-lang/rust-analyzer/pull/10442. I do agree that recursive searching with `**/` is likely overkill, but I'm not sure `*/Cargo.toml` is working as expected in this comment (https://github.com/rust-lang/rust-analyzer/pull/10442#issuecomment-932967421):

> For some reason, */Cargo.toml works for both Cargo.toml in the project root and in a subdirectory (but not two levels deep).

That does not seem to be the case for me. I even went into VS Code itself and added some fake tests for `glob.match()` (which is eventually what gets used for this) and `*/Cargo.toml` doesn't seem to match a top level `Cargo.toml` (and I think that makes sense).

<img width="1087" alt="Screenshot 2024-02-12 at 6 07 08 PM" src="https://github.com/rust-lang/rust-analyzer/assets/19150088/510b0aaa-ac66-48b1-a9e2-a3bdfc237c48">

Lastly, the VS Code search filtering uses the same glob patterns, and it also doesn't match with `*/Cargo.toml`:

https://github.com/rust-lang/rust-analyzer/assets/19150088/4973f5e7-270d-489a-8db4-37469ffe12df

---

If you want both top level `Cargo.toml`s and 1-level-deep `Cargo.toml`s to be detected by VS Code's activation events, then I think we need to lay both of those conditions out explicitly, which I've done in this PR. That does fix the problem for me.

https://github.com/rust-lang/rust-analyzer/assets/19150088/bfcb1223-c45c-479a-9ea4-4be3f36e6838
2024-02-13 16:26:01 +00:00
dfireBird
0e47befaf3
fix flyimport showing other types in impl trait statement 2024-02-13 19:31:04 +05:30
dfireBird
9897662bf7
add completions to show only traits with qualified path prefix 2024-02-13 18:41:24 +05:30
bors
3c4d642d8b Auto merge of #16117 - mustakimali:mo-order, r=Veykril
feat: completion list suggests constructor like & builder methods first

When typing `MyType::` the completion items' order could be re-ordered based on how likely we want to select those:
* Constructors: `new` like functions to be able to create the type,
* Constructors that take args: Any other function that creates `Self`,
* Builder Methods: any builder methods available,
* Regular methods & associated functions (no change there)

![image](https://github.com/rust-lang/rust-analyzer/assets/1546896/54593b91-07b3-455a-8a71-8d203d4eaf4a)

In this photo, the order is:
* `new` constructor is first
* `new_builder` second is a builder method
* `aaaanew` is a constructor that takes arguments, is third  and is irrespective of its alphabetical order among names.

---

Another Example using actix `HttpServer` shows preferring constructor without `self` arg first (the `new` method)

![image](https://github.com/rust-lang/rust-analyzer/assets/1546896/938d3fb0-3d7a-4427-ae2f-ec02a834ccbe)

![image](https://github.com/rust-lang/rust-analyzer/assets/1546896/2c13860c-efd1-459d-b25e-df8adb61bbd0)

I've dropped my previous idea of highlighting these functions in the rustdoc (https://github.com/rust-lang/rust/pull/107926)
2024-02-13 12:06:25 +00:00
bors
e944a273ee Auto merge of #16547 - Veykril:proc-macro-literals, r=Veykril
fix: Validate literals in proc-macro-srv FreeFunctions::literal_from_str

cc https://github.com/rust-lang/rust-analyzer/pull/16446

meant to only get rid of some string allocs but then I noticed we can just implement this with the bare lexer.
2024-02-13 11:35:44 +00:00
Lukas Wirth
ed57008510 fix: Validate literals in proc-macro-srv FreeFunctions::literal_from_str 2024-02-13 12:33:51 +01:00
bors
925705e0c9 Auto merge of #16446 - Tyrubias:literal_from_str, r=Veykril
Implement `literal_from_str` for proc macro server

Closes #16233

Todos and unanswered questions:

- [x] Is this the correct approach? Can both the legacy and `rust_analyzer_span` servers depend on the `syntax` crate?
- [ ] How should we handle suffixes for string literals? It doesn't seem like `rust-analyzer` preservers suffix information after parsing.
- [x] Why are the `expect` tests failing? Specifically `test_fn_like_macro_clone_literals`
2024-02-13 10:41:36 +00:00
Mohammad Mustakim Ali
2c761048d4
fix: clippy 2024-02-13 10:11:17 +00:00
Victor Song
4923b8a74b Return Option<Parse<ast::Literal>> from ast::Literal::parse 2024-02-13 00:00:02 -06:00
Victor Song
1918f9b9e0 Address PR comments 2024-02-13 00:00:02 -06:00
Victor Song
cdb8a88ea3 Fix more compilation errors 2024-02-13 00:00:02 -06:00
Victor Song
965b14d17a Fix compilation errors 2024-02-13 00:00:02 -06:00
Victor Song
027f263ef5 Note FIXME for suffixes 2024-02-13 00:00:02 -06:00
Victor Song
6cd458f3d0 Move raw_delimiter_count to syntax crate 2024-02-13 00:00:02 -06:00
Victor Song
e8c9ca2a2f Refactor shared literal_from_str code 2024-02-13 00:00:02 -06:00
Victor Song
adf7adf3e8 Add syntax crate as proc-macro-srv dep 2024-02-13 00:00:02 -06:00
Victor Song
68365513f3 Implement literal_from_str for proc macro srv 2024-02-13 00:00:02 -06:00