Commit Graph

26170 Commits

Author SHA1 Message Date
Ryan Mehri
60f7473c99 fix parens when inlining closure local variables 2023-09-21 21:31:15 -07: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
bors
4778255b3d Auto merge of #15637 - Wilfred:update_chalk, r=lnicola
Update chalk version

This only pulls in one commit in Chalk, which is an improvement to inference for rust-analyzer: https://github.com/rust-lang/chalk/pull/800
2023-09-20 04:58:09 +00:00
Wilfred Hughes
3a63255d2a Update chalk version 2023-09-19 16:56:59 -07:00
bors
0427a239eb Auto merge of #15635 - SomeoneToIgnore:fix-vscode-edits, r=Veykril
Do not resolve inlayHint.textEdit for VSCode client

Closes https://github.com/rust-lang/rust-analyzer/issues/15604

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 20:36:09 +00: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
bors
cdaadb6138 Auto merge of #15632 - emilio:scip-build-rs, r=lnicola
scip: Use load_workspace_at.

This honors the build script config, and is also simpler.
2023-09-19 11:54:17 +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
bors
258b15c506 Auto merge of #15628 - lnicola:sync-from-rust, r=lnicola
minor: Sync from downstream
2023-09-18 09:05:50 +00:00
Laurențiu Nicola
d39b45a58d Merge branch 'master' into sync-from-rust 2023-09-18 12:04:59 +03:00
bors
05666441ba Auto merge of #15625 - jDomantas:domantas/fix-15623, r=HKalbasi
fix: Don't skip closure captures after let-else

As I understand that `return` was left there by accident. It caused capture analysis to skip the rest of the block after a let-else, and then missed captures caused incorrect results in borrowck, closure hints, layout calculation, etc.

Fixes #15623

I didn't understand why I using the example from #15623 as-is doesn't work - I don't get the warnings unless I remove the `call_me()` call, even on the same commit as my own RA version which does show those warnings.
2023-09-17 17:53:15 +00: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
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
bors
47c51b70dd Auto merge of #15609 - WaffleLapkin:undup_sema, r=Veykril
Remove most of the duplication from `Semantics{,Impl}` via deref

See https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Semantics.20vs.20SemanticsImpl/near/390795952
2023-09-14 06:23:54 +00: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
Ryan Mehri
cd0a89ac4f fix: field shorthand overwritten in promote local to const assist 2023-09-11 10:59:23 -07: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
bors
0e251ff768 Auto merge of #15232 - alibektas:14850, r=Veykril
ide : Disallow renaming of non-local items

fixes #14850 . This makes me wonder , why stop at structs and not do the same for other ADTs? Would be happy to add them too if nothing speaks against it.
2023-09-11 08:21:51 +00: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
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
bors
326f37ef1f Auto merge of #15592 - Veykril:shrink, r=Veykril
Shrink some stuff
2023-09-10 06:55:01 +00:00
Lukas Wirth
ccff704c25 Shrink some stuff 2023-09-10 08:24:26 +02:00
bors
994df3d6a3 Auto merge of #15586 - Veykril:shrink, r=Veykril
shrink_to_fit body source map
2023-09-09 12:53:39 +00:00
Lukas Wirth
cfcef69072 shrink_to_fit body source map 2023-09-09 14:40:56 +02:00
bors
a3cfb457ca Auto merge of #15584 - Veykril:diag-private-field-constructor, r=Veykril
Diagnose private fields in record constructor
2023-09-09 09:02:50 +00:00
Lukas Wirth
8f5fee4a5a Diagnose incorrect and private fields in record structs 2023-09-09 10:45:29 +02: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