Commit graph

910 commits

Author SHA1 Message Date
Vincent Esche
b5b0f4bc5a Replace "TBD" with more helpful desciptions in published crates' [package.description] fields 2024-08-06 00:25:02 +02:00
Lukas Wirth
fcb88832de Simplify FileDelegate 2024-08-05 13:03:03 +02:00
Lukas Wirth
f053b1aa6a feat: Load sysroot library via cargo metadata 2024-08-05 12:18:19 +02:00
Luuk Wester
64ee4d3b1e flip the naming of the doc comment to comment assist 2024-07-28 00:48:08 +02:00
bors
c29bac1cdf Auto merge of #17647 - joshka:jm/rename-commands, r=Veykril
Rename rust-analyzer commands

The commands `editor.action.triggerParameterHints` and
`editor.action.rename` are now renamed to
`rust-analyzer.triggerParameterHints` and `rust-analyzer.rename`

This change helps make it clear that these commands are specific to
rust-analyzer and not part of the default set of commands provided by
VSCode.

Fixes: https://github.com/rust-lang/rust-analyzer/issues/17644

Note: This seems like it will be a breaking change for any RA client that previously reacted to `editor.action.triggerParameterHints` - naive search: https://github.com/search?q=editor.action.triggerParameterHints+AND+%28NOT+is%3Afork%29+rust-analyzer&type=code
2024-07-22 08:10:03 +00:00
Lukas Wirth
e3f16223c8 Simplify 2024-07-22 09:54:31 +02:00
Josh McKinney
5b1a5a250b
Rename rust-analyzer commands
The commands `editor.action.triggerParameterHints` and
`editor.action.rename` are now renamed to
`rust-analyzer.triggerParameterHints` and `rust-analyzer.rename`

This change helps make it clear that these commands are specific to
rust-analyzer and not part of the default set of commands provided by
VSCode.

Fixes: https://github.com/rust-lang/rust-analyzer/issues/17644
2024-07-20 01:11:14 -07:00
Yuri Astrakhan
cc1aded86c Avoid ref when using format! in compiler
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
2024-07-19 14:41:59 -04:00
bors
aa4768f7be Auto merge of #17622 - roife:fix-issue-17602, r=Veykril
fix: handle synonymous imports with different renaming in 'merge imports'

fix #17602
2024-07-19 15:16:02 +00:00
Lukas Wirth
5264f86242 Encode edition within FileId in the hir layer 2024-07-18 08:49:10 +02:00
roife
87a3ab4658 fix: handle synonymous imports in 'merge imports' 2024-07-18 05:01:58 +08:00
Lukas Wirth
7011094685 Add always disabled gen parse support 2024-07-17 10:49:12 +02:00
Lukas Wirth
2346a80ab4 Remove Name::to_smol_str 2024-07-16 12:43:58 +02:00
Lukas Wirth
df5f1777b8 More symbol usage 2024-07-16 12:05:16 +02:00
bors
e961b1aece Auto merge of #17587 - joshka:jm/edit-name-after-refactor, r=Veykril
Trigger VSCode to rename after extract variable assist is applied

When the user applies the "Extract Variable" assist, the cursor is
positioned at the newly inserted variable. This commit adds a command
to the assist that triggers the rename action in VSCode. This way, the
user can quickly rename the variable after applying the assist.

Fixes part of: #17579

https://github.com/user-attachments/assets/4cf38740-ab22-4b94-b0f1-eddd51c26c29

I haven't yet looked at the module or function extraction assists yet.
2024-07-15 09:53:39 +00:00
Lukas Wirth
cde0f69cae Fix stable iteration ordering for Map<Name, ...> usages 2024-07-15 11:25:46 +02:00
Lukas Wirth
f2d51073d2 Use statics + clone instead of const until const can access statics 2024-07-14 17:52:59 +02:00
Josh McKinney
bfa6a5ca84
Address feedback from @DropDemBits
- move `edit.rename()` to the end of the function
- use a match statement to set `res.command`
2024-07-13 19:33:35 -07:00
bors
8efe8a8528
Trigger VSCode to rename after extract variable assist is applied
When the user applies the "Extract Variable" assist, the cursor is
positioned at the newly inserted variable. This commit adds a command
to the assist that triggers the rename action in VSCode. This way, the
user can quickly rename the variable after applying the assist.

Fixes part of: #17579
2024-07-12 19:06:19 -07:00
Lukas Wirth
3fe815b0f3 Use Symbol in Name 2024-07-12 16:06:44 +02:00
winstxnhdw
c4bcec214a refactor: search for enum semantically 2024-07-10 21:13:13 +01:00
winstxnhdw
120526ad68 style: prefer type inference
- unrelated to the PR but I wanted to change this in #17467
2024-07-09 22:30:00 +01:00
winstxnhdw
2b52bffaef feat: do not add new enum if it already exists 2024-07-09 22:17:07 +01:00
bors
a5b21ea0aa Auto merge of #17555 - Veykril:grammar-inline, r=Veykril
internal: Inline generated syntax methods
2024-07-07 09:21:04 +00:00
Lukas Wirth
c08d419fba HasGenericArgs syntax trait 2024-07-07 11:18:28 +02:00
bors
a494aaba87 Auto merge of #17523 - wada314:master, r=Veykril
Add an option to use "::" for the external crate prefix.

Fixes #11823 .
Hi I'm very new to rust-analyzer and not sure how the review process are. Can somebody take a look at this PR? thanks!
2024-07-07 08:32:46 +00:00
Lukas Wirth
9b3e912d67 Update generated lint definitions 2024-07-07 08:35:18 +02:00
Shohei Wada
3725ab3146 squash. 2024-07-02 01:52:34 +09:00
bors
becf5d31f7 Auto merge of #17494 - harrysarson:harry/keep-braces, r=Veykril
do not normalize `use foo::{self}` to `use foo`

It changes behaviour and can cause collisions. E.g. for the following snippet

```rs
mod foo {

    pub mod bar {}

    pub const bar: i32 = 8;
}

// transforming the below to `use foo::bar;` causes the error:
//
//   the name `bar` is defined multiple times
use foo::bar::{self};

const bar: u32 = 99;

fn main() {
    let local_bar = bar;
}
```

we still normalize

```rs
use foo::bar;
use foo::bar::{self};
```

to `use foo::bar;` because this cannot cause collisions.

See: https://github.com/rust-lang/rust-analyzer/pull/17140#issuecomment-2079189725
2024-07-01 10:20:01 +00:00
bors
ea7fdada6a Auto merge of #17520 - Veykril:slim-proc-macro-api, r=Veykril
internal: Cleanup proc-macro-srv some more
2024-06-30 15:12:50 +00:00
Lukas Wirth
21a3d01875 Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
bors
56ef2404b3 Auto merge of #17516 - kilpkonn:master, r=kilpkonn
Quality of life improvements to term search

Basically two things:
- Allow optionally disabling "borrow checking" restrictions on term search code assists. Sometimes it is better to get invalid suggestions and fix borrow checking issues later...
- Remove explicit generics in generated expressions. I find it quite rare that one writes `None::<T>` instead of `None`.
2024-06-30 12:41:22 +00:00
bors
7e8f9c82e1 Auto merge of #17467 - winstxnhdw:bool-to-enum, r=Veykril
feat: add bool_to_enum assist for parameters

## Summary

This PR adds parameter support for `bool_to_enum` assists. Essentially, the assist can now transform this:

```rs
fn function($0foo: bool) {
    if foo {
        println!("foo");
    }
}
```

To this,

```rs
#[derive(PartialEq, Eq)]
enum Bool { True, False }

fn function(foo: Bool) {
    if foo == Bool::True {
        println!("foo");
    }
}
```

Thanks to `@/davidbarsky`  for the test skeleton (:

Closes #17400
2024-06-30 12:26:07 +00:00
Tavo Annus
c19458270d Do not explicit generics to generated expressions 2024-06-30 15:19:19 +03:00
Lukas Wirth
bfb187aacd Fix expression scope calculation when within macro expansions 2024-06-30 13:26:17 +02:00
Tavo Annus
1389312871 Make borrow checking configurable for term search 2024-06-29 12:24:08 +03:00
Harry Sarson
23965e4512 do not normalize use foo::{self} to use foo
It changes behaviour and can cause collisions. E.g. for the following snippet

```rs
mod foo {

    pub mod bar {}

    pub const bar: i32 = 8;
}

// tranforming the below to `use foo::bar;` causes the error:
//
//   the name `bar` is defined multiple times
use foo::bar::{self};

const bar: u32 = 99;

fn main() {
    let local_bar = bar;
}
```

we still normalize

```rs
use foo::bar;
use foo::bar::{self};
```

to `use foo::bar;` because this cannot cause collisions.

See: https://github.com/rust-lang/rust-analyzer/pull/17140#issuecomment-2079189725
2024-06-26 08:58:13 +01:00
winstxnhdw
d468746075
feat: add bool_to_enum assist for parameters 2024-06-25 01:39:16 +08:00
winstxnhdw
21c63abec7
tests: add test for param transformation 2024-06-25 01:39:11 +08:00
bors
0cb22db658 Auto merge of #17487 - Veykril:ty-perf-stuff, r=Veykril
internal: Some more small memory optimizations

Not a big impact on metrics, though there are some more savings in queries mainly used by the IDE layer from this
2024-06-24 09:50:35 +00:00
Lukas Wirth
db056b4a69 Fix term_search filtering enum variant generics incorrectly 2024-06-24 10:31:21 +02:00
bors
e0a400edd4 Auto merge of #17471 - davidsemakula:fix-remove-parenthesis, r=Veykril
fix: don't remove parentheses for calls of function-like pointers that are members of a struct or union

Fixes #17111
2024-06-24 08:25:49 +00:00
Tavo Annus
957325a5fe Run data_constructor tactic only backwards 2024-06-21 22:01:06 +03:00
davidsemakula
d6d45a23d3 fix: don't remove parentheses for calls of function-like pointers that are members of a struct or union 2024-06-21 17:57:53 +03:00
Tavo Annus
c87609fef1 Add tactic for associated item constants 2024-06-18 22:08:44 +03:00
Lukas Wirth
8520a0c585 Thread more HasSource::source calls through Semantics for caching 2024-06-10 10:33:07 +02:00
Lukas Wirth
d4dc3ca83b Register virtual workspace Cargo.toml files in the VFS 2024-06-09 12:54:50 +02:00
bors
26c1638bfb Auto merge of #17308 - mathew-horner:prefer-workspace, r=Veykril
Add preference modifier for workspace-local crates when using auto import.

`@joshka` pointed out some odd behavior of auto import ordering. It doesn't seem that the current heuristics were applying any sort of precedence to imports from the workspace. I've went ahead and added that.

I hope to get some feedback on the modifier numbers here. I just went with something that felt like it balanced giving more power to workspace crates without completely ignoring relative path distance.

closes https://github.com/rust-lang/rust-analyzer/issues/17303
2024-06-07 10:35:49 +00:00
Wilfred Hughes
27182bb96b chore: Prefer tracing span shorthand macros 2024-06-06 16:52:25 -07:00
bors
cb6b808185 Auto merge of #17315 - hamirmahal:style/simplify-string-interpolation, r=Veykril
style: simplify string interpolation
2024-06-03 12:29:27 +00:00