Commit graph

18462 commits

Author SHA1 Message Date
bohan
d20471334f use visibility to check unused imports and delete some stmts 2023-10-22 21:27:46 +08:00
Laurențiu Nicola
094cecd3bd Fix VS Code detection for Insiders version 2023-10-21 19:08:41 +03:00
bors
954fb1d673 Auto merge of #15727 - DaniPopes:lintgen-unstable-book, r=HKalbasi
feat: generate descriptors for all unstable features

Most unstable features don't have their own chapter in the unstable book, so a rustc helper tool (`src/tools/unstable-book-gen`) generates shims to fill the gaps.
Run this tool to generate the full unstable-book source before parsing it.
2023-10-20 16:42:23 +00:00
bors
bd38871a98 Auto merge of #15736 - rmehri01:15678_module_incorrect_case_diagnostics, r=HKalbasi
fix: add incorrect case diagnostics for module names

Adds diagnostics for checking both inline and file module names are snake case.

Closes #15678
2023-10-20 16:20:40 +00:00
Young-Flash
a7f77d89a9 fix: auto import trait if needed 2023-10-19 17:34:17 +08:00
bors
7f1e6fdfee Auto merge of #15775 - Young-Flash:refactor, r=Veykril
refactor: change generated variable name

change generated variable name in `replace_is_some_with_if_let_some` assist

close https://github.com/rust-lang/rust-analyzer/issues/15765
2023-10-18 06:39:34 +00:00
Young-Flash
1a0fe58d81 refactor: change generated variable name 2023-10-17 17:34:11 +08:00
bors
d6afb4fa23 Auto merge of #15746 - pvalletbo:string-literals-diagnose, r=Veykril
String literals diagnose

Continues the work from #15744 to add diagnosis errors to Str, ByteStr, and CStr literal kinds.

Also replaces `unescape_char` for `unescape_byte` to use the correct method for Byte literals.
2023-10-16 18:23:22 +00:00
Lukas Wirth
40acc5250f Update rustc_abi dependency 2023-10-15 18:57:40 +02:00
bors
65532e417d Auto merge of #15755 - Young-Flash:cursor_selection, r=lnicola
fix: make cursor select at _tmp

Here make cursor select at `_tmp` atuomatically after the assist apply. Refer to [vscode snippet placeholder](https://code.visualstudio.com/docs/editor/userdefinedsnippets#_placeholders).

![cursor_selection](https://github.com/rust-lang/rust-analyzer/assets/71162630/a7866efe-2d54-488b-903e-9df039f34a7e)

following https://github.com/rust-lang/rust-analyzer/pull/15752
2023-10-15 07:41:29 +00:00
Christian Schott
8217ff9c16
make ProjectionStore-impls pub-accessible 2023-10-14 19:20:11 +02:00
bors
16ac6c284c Auto merge of #15756 - harpsword:fix_typo_in_mbe_lib, r=lnicola
fix typo in mbe/lib.rs comment

fix typo in mbe/lib.rs comment
2023-10-14 06:23:12 +00:00
harpsword
3f4368a090 fix: fix typo in mbe/lib.rs comment 2023-10-14 14:13:24 +08:00
Young-Flash
bc34e8f1ad feat: make cursor select at _tmp 2023-10-14 11:05:38 +08:00
bors
862693ff95 Auto merge of #15752 - Young-Flash:replace_is_method_with_if_let_method, r=HKalbasi
feat: add replace_is_ok_with_if_let_ok assist

following https://github.com/rust-lang/rust-analyzer/pull/15743
2023-10-13 07:32:55 +00:00
Young-Flash
5bbca22720 update mod order to adapt alphabetically sorted 2023-10-13 00:09:13 +08:00
Young-Flash
506b1e515b feat: add replace_is_ok_with_if_let_ok assist 2023-10-12 23:26:42 +08:00
bors
84e1d27343 Auto merge of #15743 - Young-Flash:replace_is_some_with_if_let_some, r=HKalbasi
add replace_is_some_with_if_let_some assist

This is a basic impl, if it is ok, `if my_result.is_ok()`-> `if let Ok(_x) = my_result ​`will be add next.

close https://github.com/rust-lang/rust-analyzer/issues/12977
2023-10-12 08:20:08 +00:00
Young-Flash
3605bb38ff fix CI: generate doctest 2023-10-12 11:50:44 +08:00
Pol Valletbó
6845c80a2f fix: format 2023-10-11 15:52:22 +02:00
Pol Valletbó
4b281ffdf2 chore: format imports 2023-10-11 15:52:05 +02:00
Pol Valletbó
b769f34f63 chore: move common code to function 2023-10-11 15:45:45 +02:00
Pol Valletbó
e1aeb7fa79 fix: handle errors for string byte string and c_string 2023-10-11 15:25:52 +02:00
Pol Valletbó
677e6f3439 fix: use unescape_byte function for Byte literals 2023-10-11 13:09:15 +02:00
Pol Valletbó
f58a8250dc fix: cargo fmt 2023-10-11 12:36:53 +02:00
Pol Valletbó
1fe6ac87e9 add diagnosis messages for chars and byte literal errors 2023-10-11 12:19:00 +02:00
Young-Flash
a7fada4650 add replace_is_some_with_if_let_some assist 2023-10-11 17:44:27 +08:00
Ryan Mehri
36eac9abee fix: add incorrect case diagnostics for module names 2023-10-09 13:36:39 -07:00
bors
aaa1e8e1b8 Auto merge of #15618 - shogo-nakano-desu:internal/port-anymap, r=Veykril
internal: port anymap

## Description
- The anymap crate has been ported. During this process, unnecessary features for rust-analyzer have been removed.
- From the tests that were checking the existing licenses, the anymap license (`BlueOak-1.0.0 OR MIT OR Apache-2.0`) has been removed.

## Requests
- While porting the code this time, I have tried to respect the original author's intentions and have kept the comments/codes as much as possible. Please don't hesitate to tell me if you think the comments/codes also need to be appropriately modified.
- If there are any necessary changes regarding the licensing or anything else, please let me know so I can fix them.

## Issue
https://github.com/rust-lang/rust-analyzer/issues/15500
2023-10-09 08:40:54 +00:00
bors
ab62c0186f Auto merge of #15696 - rmehri01:14293_tuple_return_type_to_struct, r=Veykril
feat: implement tuple return type to tuple struct assist

This PR implements the `convert_tuple_return_type_to_struct` assist, for converting the return type of a function or method from a tuple to a tuple struct. Additionally, it moves the `to_camel_case` and `char_has_case` functions from `case_conv` to `stdx` so that they can be used similar to `to_lower_snake_case`.

[tuple_return_type_to_tuple_struct.webm](https://github.com/rust-lang/rust-analyzer/assets/52933714/2803ff58-fde3-4144-9495-7c7c7e139075)

Currently, the assist puts the struct definition above the function, or above the nearest `impl` or `trait` if applicable and only rewrites literal tuples that are returned in the body of the function. Additionally, it only attempts to rewrite simple tuple pattern usages with the corresponding tuple struct pattern but does so across files and modules.

I think that this is sufficient for the majority of use cases but I could be wrong. One thing I'm still not sure how to approach is handling `Self` and generics/lifetimes in the tuple type to be extracted. I was thinking of either manually figuring out what lifetimes and generics are in scope and using them (sort of similar to the `generate_function` assist) or maybe using `ctx.sema.resolve_type` and `generic_params` on `hir::Type` but this seems to not deal with lifetimes.

Closes #14293
2023-10-09 08:14:42 +00:00
bors
dca63d1b21 Auto merge of #15713 - Veykril:flyimport-completions-short, r=Veykril
Do flyimport completions by prefix search for short paths

Fixes https://github.com/rust-lang/rust-analyzer/issues/15711
2023-10-09 07:56:02 +00:00
DaniPopes
0c4be03456
feat: generate descriptors for all unstable features 2023-10-09 09:36:47 +02:00
Victor Song
a39d2076db Addressed PR style comments 2023-10-09 02:15:05 -05:00
Victor Song
9771e1e18f Don't pass any target directory options to custom flycheck 2023-10-09 02:15:05 -05:00
Victor Song
2290cc3cf3 Pass target directory as flag instead of env variable 2023-10-09 02:15:05 -05:00
Victor Song
3682c3791b Set CARGO_TARGET_DIR when using Flycheck custom command 2023-10-09 02:15:05 -05:00
Victor Song
ef0b3bbef1 Clarify documentation on new parameter 2023-10-09 02:15:05 -05:00
Victor Song
53b6700594 Add dedicated target_dir field to CargoConfig and FlycheckConfig
Add dedicated field for `target_dir` in the configurations for Cargo
and Flycheck. Also change the directory to be a `PathBuf` as opposed to
a `String` to be more appropriate to the operating system.
2023-10-09 02:15:05 -05:00
Victor Song
aeef7b644b Add config option to use rust-analyzer specific target dir
Adds a Rust Analyzer configuration option to set a custom
target directory for builds. This is a workaround for Rust Analyzer
blocking debug builds while running `cargo check`. This change
should close #6007
2023-10-09 02:15:05 -05:00
DaniPopes
c5d9bfaa52
internal: fix automatic rustc/rustdoc lint generation 2023-10-07 23:24:55 +02:00
bors
b1f89a84ab Auto merge of #15600 - davidbarsky:davidbarsky/broken-rustfmt-in-ra, r=Veykril
fix: ensure `rustfmt` runs when configured with `./`

(Hopefully) resolves https://github.com/rust-lang/rust-analyzer/issues/15595. This change kinda approaches canonicalization—which I am not a fan of—but only in service of making `./`-configured commands run correctly.

Longer-term, I feel like this code should be removed once `rustfmt` supports recursive searches of configuration files or interpolation of values like `${workspace_folder}` lands in rust-analyzer.

## Testing

I cloned `rustc`, setup rust-analyzer as suggested in the [`rustc` dev guide](https://rustc-dev-guide.rust-lang.org/building/suggested.html#configuring-rust-analyzer-for-rustc), saved and formatted files in `src/tools/miri` and `compiler`, and saw `rustfmt` (seemingly) correctly.
2023-10-06 11:33:52 +00:00
Lukas Wirth
b3ebc9ab6a Check for both path separators on windows 2023-10-06 13:26:36 +02:00
Lukas Wirth
88a00bf49d Shrink PatPtr by swapping its AstPtr and Either wrap order 2023-10-06 12:32:37 +02:00
Tobias Berger
114f8a07e9
Fix typos exec_intrinsic 2023-10-06 09:24:28 +02:00
bors
fd39a30b6c Auto merge of #15712 - cuishuang:master, r=lnicola
minor: Remove repetitive words
2023-10-05 22:29:45 +00:00
cui fliter
58239f2990 Remove repetitive words
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-10-05 19:40:41 +08:00
Lukas Wirth
4af730eb26 Do flyimport completions by prefix search for short paths 2023-10-05 13:21:12 +02:00
bors
695c612489 Auto merge of #15641 - alibektas:15598/fix_into_to_from, r=Veykril
fix: preceding QualifiedPathType for into_to_from assist

fixes #15598
2023-10-05 08:25:58 +00:00
Ryan Mehri
9ba8dbc902 style: clean up magic number for finding pattern usages 2023-10-04 08:04:59 -07:00
bors
7e9da40078 Auto merge of #15700 - rmehri01:15694_iterator_demorgan, r=Veykril
feat: add assist for applying De Morgan's law to `Iterator::all` and `Iterator::any`

This PR adds an assist for transforming expressions of the form `!iter.any(|x| predicate(x))` into `iter.all(|x| !predicate(x))` and vice versa.

[IteratorDeMorgans.webm](https://github.com/rust-lang/rust-analyzer/assets/52933714/aad1a299-6620-432b-9106-aafd2a7fa9f5)

Closes #15694
2023-10-04 11:08:44 +00:00
Lukas Wirth
c266387e13
Replace unwrap with expect 2023-10-04 13:06:23 +02:00
Lukas Wirth
fe398163b6 Recognize custom main function as binary entrypoint for runnables 2023-10-04 12:07:41 +02:00
David Barsky
a8ec77dc7e address PR feedback. 2023-10-03 16:44:09 -04:00
Laurențiu Nicola
7c113ee77c Add mock description to rustc-dependencies 2023-10-03 17:32:57 +03:00
bors
4c9d2c75b5 Auto merge of #15698 - rmehri01:15695_make_guarded_return_more_lenient, r=Veykril
fix: allow more kinds of if let patterns in guarded return assist

Removes the checks that require the pattern to be a tuple struct with exactly 1 field that is unqualified and has an identifier pattern in it. I'm not sure if there should be more checks in place but they seem unnecessary now?

Closes #15695
2023-10-02 09:23:49 +00:00
Laurențiu Nicola
084ee934b8 Strip base prefix in layout_scalar_valid_range 2023-10-02 10:47:18 +03:00
Ryan Mehri
34d3490198 feat: add assist for applying De Morgan's law to iterators 2023-10-01 21:30:10 -07:00
Ryan Mehri
146a7cc490 fix: allow more kinds of if let patterns in guarded return assist 2023-10-01 11:48:10 -07:00
Ryan Mehri
2611fbf623 implement basic version of convert_tuple_return_type_to_struct assist 2023-09-30 17:07:01 -07:00
Ryan Mehri
40f80e29a5 move to_camel_case and char_has_case from case_conv to stdx 2023-09-30 08:04:04 -07:00
hkalbasi
af28458643 Downgrade unused_variables to experimental 2023-09-30 08:38:55 +03:30
bors
4791a5de21 Auto merge of #15692 - Veykril:underscore-completions, r=Veykril
fix: Typing underscore should not trigger completions in types or patterns
2023-09-29 19:08:15 +00:00
Lukas Wirth
ae5d74dffb typing underscore should not trigger completions in types or patterns 2023-09-29 21:06:47 +02:00
bors
547bcf8bbf Auto merge of #15688 - Veykril:rustc_layout_scalar_valid_range, r=Veykril
Make rustc_layout_scalar_valid_range attributes work for non-decimal literals

Closes https://github.com/rust-lang/rust-analyzer/issues/15687
2023-09-29 13:32:09 +00:00
Lukas Wirth
a943b19e08 Make rustc_layout_scalar_valid_range attributes work for non-decimal literals 2023-09-29 15:30:47 +02:00
bors
e478db717e Auto merge of #15680 - DaniPopes:regenerate-lints, r=Veykril
internal: re-generate lints.rs

Looks like this hasn't been run in a while
2023-09-29 12:44:24 +00:00
DaniPopes
53f5c1c13f
internal: re-generate lints.rs 2023-09-29 14:20:17 +02:00
bors
50678e0da0 Auto merge of #15682 - Veykril:param-list-recov, r=Veykril
Recover better on missing parameter in param list

We should do the same for argument lists, but that is more tricky to fix.
2023-09-29 11:14:02 +00:00
Lukas Wirth
a382e649ca Recover better on missing parameter in param list 2023-09-29 12:50:16 +02:00
bors
87e2c310f9 Auto merge of #15667 - rmehri01:bool_to_enum_top_level, r=Veykril
fix: make bool_to_enum assist create enum at top-level

This pr makes the `bool_to_enum` assist create the `enum` at the next closest module block or at top-level, which fixes a few tricky cases such as with an associated `const` in a trait or module:

```rust
trait Foo {
    const $0BOOL: bool;
}

impl Foo for usize {
    const BOOL: bool = true;
}

fn main() {
    if <usize as Foo>::BOOL {
        println!("foo");
    }
}
```

Which now properly produces:

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

trait Foo {
    const BOOL: Bool;
}

impl Foo for usize {
    const BOOL: Bool = Bool::True;
}

fn main() {
    if <usize as Foo>::BOOL == Bool::True {
        println!("foo");
    }
}
```

I also think it's a bit nicer, especially for local variables, but didn't really know to do it in the first PR :)
2023-09-29 10:20:11 +00:00
Ryan Mehri
1b3e5b2105 style: simplify node_to_insert_before 2023-09-28 10:09:13 -07:00
Emilio Cobos Álvarez
791e6c8b1b
scip: Allow customizing cargo config.
Re-use the LSP config json for simplicity.
2023-09-28 17:22:19 +02:00
Lukas Wirth
2b9dde14ab Allocate ast ids for parameters 2023-09-28 13:16:11 +02:00
bors
3b1b58c225 Auto merge of #15662 - rmehri01:fix_panic_with_return_in_match, r=Veykril
fix: panic with wrapping/unwrapping result return type assists

With the `wrap_return_type_in_result` assist, the following code results in a panic (note the lack of a semicolon):

```rust
fn foo(num: i32) -> $0i32 {
    return num
}

=>

thread 'handlers::wrap_return_type_in_result::tests::wrap_return_in_tail_position' panicked at crates/syntax/src/ted.rs:137:41:
called `Option::unwrap()` on a `None` value
```

I think this is because it first walks the body expression to change any `return` expressions and then walks all tail expressions, resulting in the `return num` being changed twice since it is both a `return` and in tail position. This can also happen when a `match` is in tail position and `return` is used in a branch for example. Not really sure how big of an issue this is in practice though since this seems to be the only case that is impacted and can be reduced to just `num` instead of `return num`.

This also occurs with the `unwrap_result_return_type` assist but panics with the following instead:

```
thread 'handlers::unwrap_result_return_type::tests::wrap_return_in_tail_position' panicked at /rustc/3223b0b5e8dadda3f76c3fd1a8d6c5addc09599e/library/alloc/src/string.rs:1766:29:
assertion failed: self.is_char_boundary(n)
```
2023-09-26 14:18:33 +00:00
Lukas Wirth
0dbde71159 Simplify 2023-09-26 12:25:59 +02:00
Ryan Mehri
73150c3f36 fix: wrap method call exprs in parens 2023-09-25 21:44:16 -07:00
Ryan Mehri
bce4be9478 fix: make bool_to_enum assist create enum at top-level 2023-09-25 21:01:54 -07:00
Milo
85ead6ec27 remove other unwraps 2023-09-25 11:48:23 +00:00
Milo
f64eecd2e2 fix one 2023-09-25 11:30:21 +00:00
bors
972a19f4cb Auto merge of #15659 - HKalbasi:unused-var, r=HKalbasi
Add `unused_variables` native diagnostic
2023-09-25 06:38:14 +00:00
Ryan Mehri
7306504b82 fix panic with wrapping/unwrapping result return type assists 2023-09-24 16:00:55 -07:00
DaniPopes
588c7d9182
minor: hover_simple refactor 2023-09-24 22:47:29 +02:00
hkalbasi
ab52ba2de7 Fix unused_variables in tests 2023-09-24 23:45:36 +03:30
hkalbasi
7834b8fadb Add unused_variables native diagnostic 2023-09-24 21:29:15 +03:30
bors
e5e937ae5e Auto merge of #15582 - vxpm:master, r=HKalbasi
add option to show full function signatures in completion docs

implements #15538

with `"rust-analyzer.completion.fullFunctionSignatures.enable": false`:
![image](https://github.com/rust-lang/rust-analyzer/assets/59714841/ff739ad1-9975-461f-a62d-22c7823e7b71)

with `"rust-analyzer.completion.fullFunctionSignatures.enable": true`:
![image](https://github.com/rust-lang/rust-analyzer/assets/59714841/9bc98300-cef6-44ef-a353-dcf35cd36fce)
2023-09-24 07:38:38 +00:00
vxpm
10fae62820 split detail function 2023-09-23 19:43:19 -03:00
vxpm
9f3d627681 add tests for full signatures 2023-09-23 19:39:42 -03:00
Ali Bektas
fc258de5a3 Make QualPathTy case readable 2023-09-22 21:23:03 +02:00
bors
2b580a1f3c Auto merge of #15492 - RalfJung:invocation, r=Veykril
extend check.overrideCommand and buildScripts.overrideCommand docs

Extend check.overrideCommand and buildScripts.overrideCommand docs regarding invocation strategy and location.

However something still seems a bit odd -- the docs for `invocationStrategy`/`invocationLocation` talk about "workspaces", but the setting that controls which workspaces are considered is called `linkedProjects`. Is a project the same as a workspace here or is there some subtle difference?
2023-09-22 16:09:01 +00:00
bors
8139e8e072 Auto merge of #15425 - alibektas:deunwrap/convert_comment_block, r=Veykril
minor : Deunwrap convert_comment_block and desugar_doc_comment

Closes subtask 13 of #15398 . I still don't know a more idiomatic way for the for loops I added, any suggestion would make me happy.
2023-09-22 15:47:55 +00:00
bors
59bcbafc95 Auto merge of #15594 - alibektas:deunwrap/add_missing_match_arms, r=Veykril
Deunwrap add_missing_match_arms

Last subtask of #15398
2023-09-22 15:31:30 +00:00
Ali Bektas
132a6ce8fc Omit QualPathTy when possible 2023-09-22 14:04:17 +02:00
Ali Bektas
622e1a8d88 Add a test case to add_missing_match_arms
Although it doesn't panic now, further changes to how we recover from incomplete syntax
may cause this assist to panic. To mitigate this a test case has been added.
2023-09-22 13:51:19 +02:00
Ali Bektas
0a91a54794 v4 2023-09-22 13:32:20 +02:00
bors
4a8622c8fa Auto merge of #15652 - Veykril:format_to, r=lnicola
minor: Various small fixes
2023-09-22 09:06:06 +00:00
Ali Bektas
695a1349fa Fix doctest 2023-09-22 10:46:21 +02:00
Ali Bektas
8ad536f2d1 Make path start with a QualifiedPathType 2023-09-22 10:46:21 +02:00
Lukas Wirth
556f0c6704 Various small fixes 2023-09-22 10:13:51 +02:00
bors
5855bd8579 Auto merge of #15587 - dfireBird:fix-15128, r=Veykril
Fix autoimport does nothing when importing trait that is as _ imports

Potentially fixes #15128

There are two cases of imports:
1. With simple path
2. With use tree list (or say complex path).

On deeper inspection, the [`recursive_merge`](994df3d6a3/crates/ide-db/src/imports/merge_imports.rs (L87)) function (called by [`try_merge_trees_mut`)](994df3d6a3/crates/ide-db/src/imports/merge_imports.rs (L69)) is meaningful only in the case of complex path (i.e when the UseTree contains a UseTreeList).

The [`recursive_merge`](994df3d6a3/crates/ide-db/src/imports/merge_imports.rs (L87)) function has [match with `Ok` arm](994df3d6a3/crates/ide-db/src/imports/merge_imports.rs (L106)), that is only executed when both LHS and RHS has `PathSegment` with same `NameRef`. The removal of underscore is implemented in this arm in the case of complex path.

For simple paths, the underscore is removed by checking if both LHS and RHS are simple paths and if their `Path` is same (the check is done [here](994df3d6a3/crates/ide-db/src/imports/merge_imports.rs (L74))) and remove the underscore if one is found (I made an assumption here that RHS will always be what rust-analyzer suggests to import, because at this point I'm not sure how to remove underscore with help of `ted::replace`).
2023-09-22 07:39:11 +00:00
bors
df75809a85 Auto merge of #15484 - rmehri01:14779_bool_to_enum_assist, r=Veykril
feat: Bool to enum assist

This adds the `bool_to_enum` assist, which converts the type of boolean local variables, fields, constants and statics to a new `enum` type, making it easier to distinguish the meaning of `true` and `false` by renaming the variants.

Closes #14779
2023-09-22 07:19:12 +00:00
bors
2ededa2f14 Auto merge of #15432 - alibektas:deunwrap/inline_call, r=Veykril
minor : Deunwrap inline call

#15398 subtask 4. There is still one instance of unwrap, which I found pretty hard to change.
2023-09-22 07:03:02 +00:00
Lukas Wirth
93562dd5bd Use parent + and_then instead of ancestors 2023-09-22 08:53:24 +02:00
bors
11ffcc08a3 Auto merge of #15615 - shogo-nakano-desu:refactor/fix-clippy-lints, r=Veykril
Refactor/fix clippy lints

As title says.
2023-09-22 06:46:29 +00:00
bors
fccae08dd3 Auto merge of #15649 - tomalexander:master, r=Veykril
Documentation: Add parenthesis to the list of on-typing assists.
2023-09-22 06:12:52 +00:00
Ryan Mehri
ea11846490 fix parens when inlining closure in body of function 2023-09-21 21:55:10 -07:00
Ryan Mehri
60f7473c99 fix parens when inlining closure local variables 2023-09-21 21:31:15 -07:00
Tom Alexander
91b012f91d
Documentation: Add parenthesis to the list of on-typing assists. 2023-09-21 14:58:24 -04:00
bors
d6fef2c7e3 Auto merge of #15621 - kpreid:import, r=Veykril
Give `unmerge_use` a label explaining what it will affect.

When I'm trying to clean up `use`s, I often feel uncertain about what exactly the effects of choosing an assist will be. This PR makes a small improvement to that by giving “Unmerge use” a label which names the root of the tree that it's going to move, when one exists.

There is no test because I didn't see, among the test helpers, a way to assert on the assist label (as opposed to filtering on it). However, I did test the change manually.

I looked into making a similar change to “Merge imports”, but that is considerably trickier.
2023-09-20 14:38:08 +00:00
shogo-nakano-desu
dd843060f9 refactor: remove boxing 2023-09-20 23:02:52 +09:00
shogo-nakano-desu
2b891ca084 chore: add comments to mention anymap is a port from another repo 2023-09-20 09:07:58 +09:00
shogo-nakano-desu
6212182739 refactor: remove hashbrown deps since we can use std 2023-09-20 09:02:10 +09:00
shogo-nakano-desu
f671b0b864 refactor: move implementation inside anymap crate into stdx crate 2023-09-20 09:02:10 +09:00
shogo-nakano-desu
00e238e99b refactor: remove unnecesary cfg_attr and inline macro 2023-09-20 09:02:10 +09:00
shogo-nakano-desu
4b3257a365 refactor: port anymap 2023-09-20 09:02:05 +09:00
Wilfred Hughes
3a63255d2a Update chalk version 2023-09-19 16:56:59 -07:00
Kirill Bulatov
f9fac02c57 Use proper editor name 2023-09-19 23:34:43 +03:00
Kirill Bulatov
184119258e Do not resolve inlayHint.textEdit for VSCode client
VSCode behaves strangely, allowing to navigate into label location, but
not allowing to apply hint's text edit, after hint is resolved.
See https://github.com/microsoft/vscode/issues/193124 for details.

For now, stub hint resolution for VSCode specifically.
2023-09-19 21:40:22 +03:00
bors
22b18b9f77 Auto merge of #15616 - HKalbasi:rustc-deps, r=HKalbasi
Switch to in-tree rustc dependencies with a cfg flag

We can use this flag to detect and prevent breakages in rustc CI. (see #14846 and #15569)

~The `IN_RUSTC_REPOSITORY` is just a placeholder. Is there any existing cfg flag that rustc CI sets?~
2023-09-19 17:41:12 +00:00
Emilio Cobos Álvarez
c372431123
scip: Use load_workspace_at.
This honors the build script config, and is also simpler.
2023-09-19 13:48:05 +02:00
Laurențiu Nicola
bcfc997eac Merge commit '258b15c506a2d3ad862fd17ae24eaf272443f477' into sync-from-ra 2023-09-18 12:33:49 +03:00
Laurențiu Nicola
d39b45a58d Merge branch 'master' into sync-from-rust 2023-09-18 12:04:59 +03:00
jDomantas
a961068504 add layout test 2023-09-17 17:00:57 +03:00
jDomantas
b3aba94cbd use code from bug report for regression test 2023-09-17 16:52:32 +03:00
jDomantas
a0c31b73d8 don't skip the rest of the block after let-else 2023-09-17 12:46:41 +03:00
jDomantas
a77789e7aa regression test 2023-09-17 11:54:42 +03:00
Kevin Reid
cac796acb3 Give unmerge_use a label explaining what it will affect. 2023-09-16 13:29:03 -07:00
bors
9d0ccf01a1 Auto merge of #15597 - rmehri01:fix_promote_local_field_shorthand, r=HKalbasi
Field shorthand overwritten in promote local to const assist

Currently, running `promote_local_to_const` on the following:

```rust
struct Foo {
    bar: usize,
}

fn main() {
    let $0bar = 0;
    let foo = Foo { bar };
}
```

Results in:

```rust
struct Foo {
    bar: usize,
}

fn main() {
    const BAR: usize = 0;
    let foo = Foo { BAR };
}
```

But instead should be something like:

```rust
struct Foo {
    bar: usize,
}

fn main() {
    const BAR: usize = 0;
    let foo = Foo { bar: BAR };
}
```
2023-09-16 16:48:21 +00:00
hkalbasi
f4704bc8ae Switch to in-tree rustc dependencies with a cfg flag 2023-09-15 18:10:11 +03:30
shogo-nakano-desu
96c333262a refactor: fix clippy lint 2023-09-15 16:47:39 +09:00
shogo-nakano-desu
0bb2298ac6 refactor: remove TODO with no explanation 2023-09-15 16:43:31 +09:00
shogo-nakano-desu
ebbbaaa90f refactor: fix clippy lints 2023-09-15 16:43:21 +09:00
bors
12e28c3575 Auto merge of #15611 - Veykril:stability-import, r=Veykril
Prefer stable paths over unstable ones in import path calculation

Fixes https://github.com/rust-lang/rust-analyzer/issues/15610
2023-09-14 09:11:12 +00:00
Lukas Wirth
e63e323823 Prefer stable paths over unstable ones in import path calculation 2023-09-14 11:03:41 +02:00
Maybe Waffle
a219dbda2b Remove most of the duplication from Semantics{,Impl} via deref 2023-09-13 22:02:28 +00:00
bors
089ae47ebe Auto merge of #15606 - Veykril:annotation-above-item-fi, r=Veykril
fix: Fix lens location "above_whole_item" breaking lenses

Fixes https://github.com/rust-lang/rust-analyzer/issues/15602
2023-09-13 20:02:06 +00:00
Lukas Wirth
712e67cf11 fix: Fix lens location "above_whole_item" breaking lenses 2023-09-13 22:01:04 +02:00
bors
15e1356149 Auto merge of #15601 - Veykril:diag-derive, r=Veykril
fix: Temporarily skip decl check in derive expansions

"Fixes https://github.com/rust-lang/rust-analyzer/issues/15344"
2023-09-12 21:11:28 +00:00
Lukas Wirth
affe5a7315 fix: Temporarily skip decl check in derive expansions 2023-09-12 23:10:03 +02:00
David Barsky
2974416a81 fix: ensure rustfmt runs when configured with ./ 2023-09-12 14:35:24 -04:00
Ryan Mehri
cd0a89ac4f fix: field shorthand overwritten in promote local to const assist 2023-09-11 10:59:23 -07:00
dfireBird
df1239bf92
add tests for insert use with renamed imports
Tested for two cases:
1. Simple Use
2. Complex Use
2023-09-11 17:43:53 +05:30
dfireBird
d79486529e
remove as _ on auto importing on trait that is aliased with _ 2023-09-11 17:43:53 +05:30
Ali Bektas
145a101fe8 Deunwrap add_missing_match_arms 2023-09-11 14:09:19 +02:00
Ali Bektas
893e19137e Make assist lazy again 2023-09-11 13:33:26 +02:00
Ali Bektas
0863024b1a Make assist lazy again 2023-09-11 13:31:42 +02:00
bors
cc6c8209cb Auto merge of #15431 - alibektas:deunwrap/extract_function, r=Veykril
minor : Deunwrap extract_function

#15398 subtask 5.
2023-09-11 08:37:57 +00:00
Ryan Mehri
25b1b3e753 feat: add support for other ADT types and destructuring patterns 2023-09-10 22:21:12 -07:00
Ali Bektas
0118741632 v4 2023-09-10 23:25:36 +02:00
Ali Bektas
a0c8bee35e Add more comments as requested 2023-09-10 23:19:58 +02:00
Ali Bektas
6dc7fa9423 v3 2023-09-10 23:19:58 +02:00
Ali Bektas
43edb51b21 Generalize disallowing of definition renaming 2023-09-10 23:19:58 +02:00
Ali Bektas
7ae70a06ce Disallow renaming of non-local structs 2023-09-10 23:19:58 +02:00
Ali Bektas
2fdf7e4b75 v3 2023-09-10 23:15:37 +02:00
Ali Bektas
a66dbd11ed v2 2023-09-10 23:15:05 +02:00
Ali Bektas
b316bccc97 replace for loops with sth more idiomatic 2023-09-10 23:15:05 +02:00
Ali Bektas
9c6257138d Deunwrap convert_comment_block 2023-09-10 23:15:05 +02:00
Ali Bektas
0f1673c6f1 v3 2023-09-10 23:00:19 +02:00
Ali Bektas
6f7460484a v2 2023-09-10 22:45:09 +02:00
Ali Bektas
35e0d800f0 Deunwrap extract_function 2023-09-10 22:45:09 +02:00
Ali Bektas
38491fcf07 v3 2023-09-10 22:39:07 +02:00
Ali Bektas
68d24b69d4 Deunwrap inline call v2 2023-09-10 22:39:07 +02:00
Ali Bektas
5683df2965 Deunwrap inline call 2023-09-10 22:39:07 +02:00
Ryan Mehri
7ba2e130b9 fix: add checks for overwriting incorrect ancestor 2023-09-10 00:21:11 -07:00
Lukas Wirth
ccff704c25 Shrink some stuff 2023-09-10 08:24:26 +02:00
Ryan Mehri
2e13aed3bc feat: support cross module imports 2023-09-09 11:59:59 -07:00
Ryan Mehri
136a9dbe36 style: rename some locals 2023-09-09 11:59:59 -07:00
Ryan Mehri
455dacfd3b fix: only trigger assist on Name 2023-09-09 11:59:59 -07:00
Ryan Mehri
91ac1d6194 fix: initializing struct multiple times 2023-09-09 11:59:59 -07:00
Ryan Mehri
83196fd4d9 fix: remove trailing whitespace 2023-09-09 11:59:59 -07:00
Ryan Mehri
59738d5fd5 fix: add generated doctest 2023-09-09 11:59:58 -07:00
Ryan Mehri
d7a8e800c9 feat: initial version of bool_to_enum assist 2023-09-09 11:58:19 -07:00
Lukas Wirth
cfcef69072 shrink_to_fit body source map 2023-09-09 14:40:56 +02:00
Lukas Wirth
8f5fee4a5a Diagnose incorrect and private fields in record structs 2023-09-09 10:45:29 +02:00
vxpm
6b487ed4be fix & run tests 2023-09-08 22:03:42 -03:00
vxpm
6afa5b0ba2 better handling of spaces & newlines 2023-09-08 22:03:42 -03:00
vxpm
23ffda1a97 full function signatures option 2023-09-08 22:03:42 -03:00
Lukas Wirth
55c75450fb Diagnose private fields in record constructor 2023-09-08 23:19:30 +02:00
bors
c405509f2e Auto merge of #15560 - davidbarsky:davidbarsky/use-sysroot-rustc-to-determine-cfgs, r=Veykril
project-model: when using `rust-project.json`, prefer the sysroot-defined rustc over discovery in `$PATH`

At the moment, rust-analyzer discovers `rustc` via the `$PATH` even if the `sysroot` field is defined in a `rust-project.json`. However, this does not work for users who do not have rustup installed, resulting in any `cfg`-based inference in rust-analzyer not working correctly. In my (decently naive!) opinion, it makes more sense to rely on the `sysroot` field in the `rust-project.json`.

One might ask "why not add `rustc` to the `$PATH`?" That is a reasonable question, but that doesn't work for my use case:
- The path to the sysroot in my employer's monorepo changes depending on which platform a user is on. For example, if they're on Linux, they'd want to use the sysroot defined at path `a`, whereas if they're on macOS, they'd want to use the sysroot at path `b` (I wrote the sysroot resolution functionality [here](765da4ca1e/integrations/rust-project/src/sysroot.rs (L39)), if you're curious).
- The location of the sysroot can (and does!) change, especially as people figure out how to make Rust run successfully on non-Linux platforms (e.g., iOS, Android, etc.) in a monorepo. Updating people's `$PATH` company-wide is hard while updating a config inside a CLI is pretty easy.

## Testing

I've created a `rust-project.json` using [rust-project](https://github.com/facebook/buck2/tree/main/integrations/rust-project) and was able to successfully load a project with and without the `sysroot`/`sysroot_src` fields—without those fields, rust-analyzer fell back to the `$PATH` based approach, as evidenced by `[DEBUG project_model::rustc_cfg] using rustc from env rustc="rustc"` showing up in the logs.
2023-09-08 18:14:25 +00:00
David Barsky
0bf6ffaf82
Update crates/project-model/src/rustc_cfg.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2023-09-08 14:07:59 -04:00
bors
c31d418a31 Auto merge of #15578 - Veykril:diag-tuple-struct-count, r=Veykril
Diagnose mismatched arg count for tuple struct patterns
2023-09-08 13:08:10 +00:00
Lukas Wirth
8654a098c7 Diagnose mismatched arg count for tuple struct patterns 2023-09-08 14:54:43 +02:00
bors
ea71a49c8e Auto merge of #15577 - Veykril:clear-native-diags, r=Veykril
Clear native diagnostics on file closing

Fixes https://github.com/rust-lang/rust-analyzer/issues/15562
2023-09-08 11:54:59 +00:00
Lukas Wirth
297ed70a23 Clear native diagnostics on file closing 2023-09-08 13:54:44 +02:00
Andy Caldwell
7e786ea4cf Rework no_coverage to coverage(off) 2023-09-08 12:46:06 +01:00
bors
70a6cf0ef7 Auto merge of #15522 - SomeoneToIgnore:resolve-inlay-hints, r=Veykril
Resolve inlay hint data

Part of https://github.com/rust-lang/rust-analyzer/issues/13962

Support https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#inlayHint_resolve better, by omitting all inlay hint fields specified in the client hint resolve capabilities.

Current list of all capabilities possible to resolve later:
```
"textEdits"
"tooltip"
"label.tooltip"
"label.location"
"label.command"
```

and every one specified in the client capabilities is now resolved by r-a, being omitted in the initial response.

--------------

When editing `inlay_hints.rs` file around line `457` with no resolve capabilities, I get
<details>
  <summary>resolved json, 10803 characters</summary>

```json
{"jsonrpc":"2.0","id":55,"result":[{"position":{"line":477,"character":1},"label":[{"value":"fn inlay_hints","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/ide/src/inlay_hints.rs","range":{"start":{"line":445,"character":14},"end":{"line":445,"character":25}}}}],"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":451,"character":10},"label":[{"value":": "},{"value":"ProfileSpan","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/profile/src/hprof.rs","range":{"start":{"line":85,"character":11},"end":{"line":85,"character":22}}}},{"value":""}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":451,"character":27},"label":[{"value":"label:","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/profile/src/hprof.rs","range":{"start":{"line":60,"character":12},"end":{"line":60,"character":17}}}}],"kind":2,"paddingLeft":false,"paddingRight":true,"data":{"file_id":0}},{"position":{"line":452,"character":12},"label":[{"value":": "},{"value":"Semantics","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/hir/src/semantics.rs","range":{"start":{"line":108,"character":11},"end":{"line":108,"character":20}}}},{"value":"<'_, "},{"value":"RootDatabase","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/ide-db/src/lib.rs","range":{"start":{"line":75,"character":11},"end":{"line":75,"character":23}}}},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":453,"character":12},"label":[{"value":": "},{"value":"SourceFile","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/ast/generated/nodes.rs","range":{"start":{"line":223,"character":11},"end":{"line":223,"character":21}}}},{"value":""}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":454,"character":12},"label":[{"value":": &"},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":456,"character":12},"label":": i32","kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":458,"character":15},"label":[{"value":": "},{"value":"Vec","location":{"uri":"file:///Users/someonetoignore/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs","range":{"start":{"line":395,"character":11},"end":{"line":395,"character":14}}}},{"value":"<"},{"value":"InlayHint","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/ide/src/inlay_hints.rs","range":{"start":{"line":149,"character":11},"end":{"line":149,"character":20}}}},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":460,"character":21},"label":[{"value":": "},{"value":"SemanticsScope","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/hir/src/semantics.rs","range":{"start":{"line":1651,"character":11},"end":{"line":1651,"character":25}}}},{"value":"<'_>"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":460,"character":36},"label":[{"value":"node:","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/hir/src/semantics.rs","range":{"start":{"line":482,"character":24},"end":{"line":482,"character":28}}}}],"kind":2,"paddingLeft":false,"paddingRight":true,"data":{"file_id":0}},{"position":{"line":461,"character":23},"label":[{"value":": "},{"value":"FamousDefs","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/ide-db/src/famous_defs.rs","range":{"start":{"line":20,"character":11},"end":{"line":20,"character":21}}}},{"value":"<'_, '_>"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":463,"character":17},"label":[{"value":": impl FnMut("},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">)"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":463,"character":25},"label":[{"value":": "},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":463,"character":33},"label":[{"value":"hints:","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/ide/src/inlay_hints.rs","range":{"start":{"line":480,"character":4},"end":{"line":480,"character":9}}}}],"kind":2,"paddingLeft":false,"paddingRight":true,"data":{"file_id":0}},{"position":{"line":465,"character":22},"label":[{"value":": "},{"value":"TextRange","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/text-size-1.1.0/src/range.rs","range":{"start":{"line":14,"character":11},"end":{"line":14,"character":20}}}},{"value":""}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":467,"character":35},"label":[{"value":": "},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":469,"character":92},"label":[{"value":"impl "},{"value":"Iterator","location":{"uri":"file:///Users/someonetoignore/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs","range":{"start":{"line":72,"character":10},"end":{"line":72,"character":18}}}},{"value":"<"},{"value":"Item","location":{"uri":"file:///Users/someonetoignore/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs","range":{"start":{"line":76,"character":9},"end":{"line":76,"character":13}}}},{"value":" = "},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">>"}],"kind":1,"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":468,"character":34},"label":[{"value":"impl "},{"value":"Iterator","location":{"uri":"file:///Users/someonetoignore/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs","range":{"start":{"line":72,"character":10},"end":{"line":72,"character":18}}}},{"value":"<"},{"value":"Item","location":{"uri":"file:///Users/someonetoignore/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs","range":{"start":{"line":76,"character":9},"end":{"line":76,"character":13}}}},{"value":" = "},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">>"},{"value":""}],"kind":1,"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":467,"character":41},"label":[{"value":""},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">"}],"kind":1,"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":469,"character":40},"label":" -> bool","kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":469,"character":39},"label":[{"value":": &"},{"value":"SyntaxNode","location":{"uri":"file:///Users/someonetoignore/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/api.rs","range":{"start":{"line":15,"character":11},"end":{"line":15,"character":21}}}},{"value":"<"},{"value":"RustLanguage","location":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/syntax/src/syntax_node.rs","range":{"start":{"line":15,"character":9},"end":{"line":15,"character":21}}}},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}}]}
```

</details>

for the visible editor range alone, pretty much repeated on every consequent edit.

With this patch and all inlay hint resolve capabilities enabled, for the same example I observe quite a footprint reduction:

<details>
  <summary>unresolved json, 4142 characters</summary>

```json
{"jsonrpc":"2.0","id":49,"result":[{"position":{"line":477,"character":1},"label":[{"value":"fn inlay_hints"}],"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":451,"character":10},"label":[{"value":": "},{"value":"ProfileSpan"},{"value":""}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":451,"character":27},"label":[{"value":"label:"}],"kind":2,"paddingLeft":false,"paddingRight":true,"data":{"file_id":0}},{"position":{"line":452,"character":12},"label":[{"value":": "},{"value":"Semantics"},{"value":"<'_, "},{"value":"RootDatabase"},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":453,"character":12},"label":[{"value":": "},{"value":"SourceFile"},{"value":""}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":454,"character":12},"label":[{"value":": &"},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":456,"character":12},"label":": i32","kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":458,"character":15},"label":[{"value":": "},{"value":"Vec"},{"value":"<"},{"value":"InlayHint"},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":460,"character":21},"label":[{"value":": "},{"value":"SemanticsScope"},{"value":"<'_>"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":460,"character":36},"label":[{"value":"node:"}],"kind":2,"paddingLeft":false,"paddingRight":true,"data":{"file_id":0}},{"position":{"line":461,"character":23},"label":[{"value":": "},{"value":"FamousDefs"},{"value":"<'_, '_>"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":463,"character":17},"label":[{"value":": impl FnMut("},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">)"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":463,"character":25},"label":[{"value":": "},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":463,"character":33},"label":[{"value":"hints:"}],"kind":2,"paddingLeft":false,"paddingRight":true,"data":{"file_id":0}},{"position":{"line":465,"character":22},"label":[{"value":": "},{"value":"TextRange"},{"value":""}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":467,"character":35},"label":[{"value":": "},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":469,"character":92},"label":[{"value":"impl "},{"value":"Iterator"},{"value":"<"},{"value":"Item"},{"value":" = "},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">>"}],"kind":1,"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":468,"character":34},"label":[{"value":"impl "},{"value":"Iterator"},{"value":"<"},{"value":"Item"},{"value":" = "},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">>"},{"value":""}],"kind":1,"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":467,"character":41},"label":[{"value":""},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">"}],"kind":1,"paddingLeft":true,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":469,"character":40},"label":" -> bool","kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}},{"position":{"line":469,"character":39},"label":[{"value":": &"},{"value":"SyntaxNode"},{"value":"<"},{"value":"RustLanguage"},{"value":">"}],"kind":1,"paddingLeft":false,"paddingRight":false,"data":{"file_id":0}}]}
```

</details>

with all unresolved parts needing only for navigation, hover or applying the hint edit — dynamic parts that are made after mouse hover or similar events, that resolve the hint data.
2023-09-08 11:12:27 +00:00
bors
347695abc8 Auto merge of #15528 - Veykril:r-a-cfg, r=Veykril
Enable `rust_analyzer` for cfgs when code is being analyzed by rust-analyzer

This allows one to have r-a skip analysis/replace macros that work not well with r-a at all by gating them behind this cfg (an example being the `quote` macro which r-a struggles with in terms of performance).
2023-09-08 10:51:17 +00:00
bors
b67606c4e2 Auto merge of #15529 - SomeoneToIgnore:less-inlay-hint-refreshes, r=Veykril
Do not send inlay hint refresh requests on file edits

See https://github.com/rust-lang/rust-analyzer/issues/13369#issuecomment-1695306870

Editor itself is able to invalidate hints after edits, and /refresh was sent after editor reports changes to the language server. This forces the editor to either query & invalidate the hints twice after every edit, or wait for /refresh to come before querying the hints.

Both options are rather useless, so instead, send a request on server startup only: client editors do not know when the server actually starts up, this will help to query the initial hints after editor was open and the server was still starting up.
2023-09-08 10:35:23 +00:00
bors
548d2f08e0 Auto merge of #15575 - HKalbasi:mir, r=HKalbasi
Intern projections in mir place

I hope this reduces mir memory usage.
2023-09-08 09:28:46 +00:00
bors
829e77709e Auto merge of #15524 - vsrs:bind_unused_param, r=Veykril
Bind unused parameter assistant

This PR introduces a new **Bind unused parameter assistant**.

While we do have a QuickFix from `rustc` (prefixing the parameter with an underscore), it's sometimes more convenient to suppress the warning using the following approach:
```rust
 fn some_function(unused: i32) {}
```
->
```rust
fn some_function(unused: i32) {
    let _ = unused;
}
```
2023-09-08 09:12:31 +00:00
hkalbasi
9708a29e57 Intern projections in mir place 2023-09-08 12:39:41 +03:30
Lukas Wirth
fddef42e92 Only set rust-analyzer cfg for workspace members 2023-09-08 11:02:56 +02:00
Lukas Wirth
e9e2c1ae75 Update project-model test outputs 2023-09-08 10:49:15 +02:00
Lukas Wirth
853f8a21f7 Fix cfg completions not working 2023-09-08 10:49:15 +02:00
Lukas Wirth
ca6ddd8ea3 Enable rust_analyzer for cfgs when code is being analyzed by rust-analyzer 2023-09-08 10:49:12 +02:00
bors
3325622230 Auto merge of #15430 - alibektas:deunwrap/wrap_return_type_in_result, r=Veykril
minor : Deunwrap wrap_return_type_in_result

#15398 subtask 7
2023-09-08 08:24:29 +00:00
bors
47e0d07eb0 Auto merge of #15573 - alibektas:15539/into_to_from, r=Veykril
assist : `into_to_qualified_from`

fixes #15539. This assist converts an `.into()` call into an explicit fully qualified `from()` call.
2023-09-08 07:44:24 +00:00
bors
5ddad87b1a Auto merge of #15574 - alibektas:15572/false_crate_name_env, r=Veykril
minor : use crate name for `CARGO_CRATE_NAME`

fixes #15572 . Until now we used the package name as a replacement of crate name. With this PR r-a first sets all the env variables it set before and on top of those it tries to set `CARGO_CRATE_NAME` to crates name, following envvar's naming convention.
2023-09-08 07:25:34 +00:00
Ali Bektas
506a477acf Use cargo name as the CARGO_CRATE_NAME instead of package name 2023-09-08 01:41:00 +02:00
Ali Bektas
9762f764ae Add assist into_to_qualified_from
This assist converts an `.into()` call into an explicit
fully qualified from call.
2023-09-07 23:43:46 +02:00
David Barsky
912b22fa07 add doc comment to rustc_cfg::RustcCfgConfig 2023-09-07 15:30:11 -04:00