Commit graph

16470 commits

Author SHA1 Message Date
Jonas Schievink
31594bcd01 decl_check: follow test style guide 2021-04-13 14:13:35 +02:00
bors[bot]
9beed98f2a
Merge #8432
8432: decl_check: consider outer scopes' allows r=jonas-schievink a=lf-

Fix #8417. Also makes it less noisy about no_mangle annotated stuff the
user can do nothing about.

Note: this still is broken with bitfield! macros. A repro in an ignore
test is included here. I believe this bug is elsewhere, and I don't
think I can work around it here.

I would like help filing the remaining bug, as it does actually affect
users, but I don't know how to describe the behaviour (or even if it
is unintended).

Co-authored-by: Jade <software@lfcode.ca>
2021-04-13 12:02:26 +00:00
bors[bot]
03e0bf7f55
Merge #8354
8354: Distinguishing between different operators in semantic highlighting r=matklad a=chetankhilosiya



Co-authored-by: Chetan Khilosiya <chetan.khilosiya@gmail.com>
2021-04-13 11:46:23 +00:00
bors[bot]
e6728a8cd3
Merge #8415
8415: Fix faulty assertion when extracting function with macro call r=matklad a=brandondong

**Reproduction:**
```rust
fn main() {
    let n = 1;
    let k = n * n;
    dbg!(n);
}
```
1. Select the second and third lines of the main function. Use the "Extract into function" code assist.
2. Panic occurs in debug, error is logged in release: "[ERROR ide_assists::handlers::extract_function] assertion failed: matches!(path, ast :: Expr :: PathExpr(_))".
3. Function generates successfully on release where the panic was bypassed.
```rust
fn fun_name(n: i32) {
    let k = n * n;
    dbg!(n);
}
```

**Cause:**
- The generated function will take `n` as a parameter. The extraction logic needs to search the usages of `n` to determine whether it is used mutably or not. The helper `path_element_of_reference` is called for each usage but the second usage is a macro call and fails the `Expr::PathExpr(_)` match assertion.
- The caller of `path_element_of_reference` does implicitly assume it to be a `Expr::PathExpr(_)` in how it looks at its parent node for determining whether it is used mutably. This logic will not work for macros.
- I'm not sure if there are any other cases besides macros where it could be something other than a `Expr::PathExpr(_)`. I tried various examples and could not find any.

**Fix:**
- Update assertion to include the macro case.
- Add a FIXME to properly handle checking if a macro usage requires mutable access. For now, return false instead of running the existing logic that is tailored for `Expr::PathExpr(_)`'s.

Co-authored-by: Brandon <brandondong604@hotmail.com>
2021-04-13 11:39:03 +00:00
bors[bot]
0c02208fd8
Merge #8489
8489: Indent block expressions on enter r=matklad a=jonas-schievink

This improves on https://github.com/rust-analyzer/rust-analyzer/pull/8388 by also indenting the created block expression on enter.

![on enter](https://user-images.githubusercontent.com/1786438/114444123-cb38d600-9bce-11eb-8af2-8e8d1c0f9908.gif)


Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-13 10:06:36 +00:00
bors[bot]
d8120ed1a0
Merge #8500
8500: internal: fix flakiness of accidentally quadratic test r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-13 09:56:45 +00:00
Aleksey Kladov
327323ad25 internal: fix flakiness of accidentally quadratic test 2021-04-13 12:56:24 +03:00
bors[bot]
11e7371df7
Merge #8499
8499: internal: don't use `#[should_panic]` for tests r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-13 09:23:24 +00:00
Aleksey Kladov
db2a989565 internal: don't use #[should_panic] for tests 2021-04-13 12:21:59 +03:00
bors[bot]
6081b437cc
Merge #8498
8498: feat: improve performance by delaying computation of fixes for diagnostics r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-13 09:09:24 +00:00
Aleksey Kladov
06a633ff42 feat: improve performance by delaying computation of fixes for diagnostics 2021-04-13 12:09:04 +03:00
Aleksey Kladov
04b5fcfdb2 Ensure that listing&resolving code actions use the same set of actions 2021-04-13 11:27:00 +03:00
Jade
26d2653dd6 address review feedback 2021-04-13 01:21:03 -07:00
bors[bot]
fe29a9e837
Merge #8494
8494: internal: unfork code paths for unresolved and resolved assist r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-13 07:59:36 +00:00
Aleksey Kladov
460f0ef669 internal: unfork code paths for unresolved and resolved assist 2021-04-13 10:59:15 +03:00
bors[bot]
15d3b6c577
Merge #8496
8496: Exclude nightly tag from git describe to fix version string r=lnicola a=lnicola

Otherwise if we run `git describe` on the release day we pick up the `nightly` tag from the previous release.

changelog fix

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-04-13 06:22:09 +00:00
Laurențiu Nicola
3b964c0c81 Exclude nightly tag from git describe to fix version string 2021-04-13 09:20:17 +03:00
Jonas Schievink
a8ca4666f1 Add a cov_mark 2021-04-13 00:51:10 +02:00
Jonas Schievink
89f015ead9 Simplify multiline check 2021-04-12 21:41:44 +02:00
Jonas Schievink
dd1832c016 Indent block expressions on enter 2021-04-12 20:35:38 +02:00
bors[bot]
27e80e9438
Merge #8488
8488: Fix typo: liner -> linear r=SomeoneToIgnore a=NieDzejkob

🙈

Co-authored-by: Jakub Kądziołka <kuba@kadziolka.net>
2021-04-12 18:26:23 +00:00
Jakub Kądziołka
2f60cec3ac
Fix typo: liner -> linear
🙈
2021-04-12 20:20:25 +02:00
bors[bot]
9f25676f0c
Merge #8483
8483: internal: clarify who a rls-2.0 wg r=edwin0cheng a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-12 16:29:56 +00:00
Aleksey Kladov
c8f48f50b3 internal: clarify who a rls-2.0 wg 2021-04-12 19:19:16 +03:00
bors[bot]
563d2d15b3
Merge #8481
8481: internal: prepare for lazy diagnostics r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-12 14:58:44 +00:00
Aleksey Kladov
426d098bd6 internal: prepare for lazy diagnostics 2021-04-12 17:58:01 +03:00
bors[bot]
cae920a1bb
Merge #8478
8478: fix: don't spam repeated error messages when `cargo check` fails r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-12 13:20:01 +00:00
Aleksey Kladov
29d5f29932 fix: don't spam repeated error messages when cargo check fails
Conceptually, using a *message* here is wrong, because this is a
"status", rather than "point in time" thing. But statuses are an LSP
extension, while messages are stable. As a compromise, send message only
for more critical `metadata` failures, and only once per state change.
2021-04-12 16:19:36 +03:00
bors[bot]
a526d0a4b7
Merge #8476
8476: feat: avoid checking the whole project during initial loading r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-12 12:32:55 +00:00
Aleksey Kladov
186c5c47cb feat: avoid checking the whole project during initial loading 2021-04-12 15:29:31 +03:00
Brandon
09a78caca4 Add macro test 2021-04-11 11:12:02 -07:00
bors[bot]
7be06139b6
Merge #8469
8469: Remove assertion in impl collection r=flodiebold a=flodiebold

This condition should always be true for *valid* code, but of course
there might be invalid code or things that we can't currently resolve.

Fixes #8464.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-04-11 10:08:30 +00:00
Florian Diebold
97d6e36dbe Remove assertion in impl collection
This condition should always be true for *valid* code, but of course
there might be invalid code or things that we can't currently resolve.

Fixes #8464.
2021-04-11 12:07:58 +02:00
bors[bot]
5b40342d2d
Merge #8465
8465: Include more info in assert r=jonas-schievink a=jonas-schievink

This helped find https://github.com/rust-analyzer/rust-analyzer/issues/8464

changelog skip

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-10 23:42:26 +00:00
Jonas Schievink
5f2efae3ba Include more info in assert 2021-04-11 01:41:40 +02:00
bors[bot]
eccd0efedb
Merge #8463
8463: Support macros in pattern position r=jonas-schievink a=jonas-schievink

This was fairly easy, because patterns are limited to bodies, so almost all changes were inside body lowering.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-10 23:33:18 +00:00
Jonas Schievink
e2c1da36f5 Support macros in pattern position 2021-04-11 01:25:50 +02:00
bors[bot]
a8a25863f6
Merge #8436
8436: Fix extract function's mutability of variables outliving the body r=matklad a=brandondong

**Reproduction:**
```rust
fn main() {
    let mut k = 1;
    let mut j = 2;
    j += 1;
    k += j;
}
```
1. Select the first to third lines of the main function. Use the "Extract into function" code assist.
2. The output is the following which does not compile because the outlived variable `k` is declared as immutable:
```rust
fn main() {
    let (k, j) = fun_name();
    k += j;
}

fn fun_name() -> (i32, i32) {
    let mut k = 1;
    let mut j = 2;
    j += 1;
    (k, j)
}
```
3. We would instead expect the output to be:
```rust
fn main() {
    let (mut k, j) = fun_name();
    k += j;
}
```

**Fix:**
- Instead of declaring outlived variables as immutable unconditionally, check for any mutable usages outside of the extracted function.

Co-authored-by: Brandon <brandondong604@hotmail.com>
2021-04-10 21:35:05 +00:00
bors[bot]
bd675c8a8b
Merge #8460
8460: Revert "Rewrite `#[derive]` removal code to be based on AST" r=jonas-schievink a=jonas-schievink

It breaks some function-like proc macros: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Proc.20macro.20expansion/near/233971916

It also uses attribute indices incorrectly, which causes insufficient attributes to be removed.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-10 18:34:59 +00:00
Jonas Schievink
44b04ebe43 Revert "Rewrite #[derive] removal to be based on AST"
This reverts commit 7e78aebc8f.
2021-04-10 20:30:28 +02:00
Jonas Schievink
050dc93e00 Revert "Use pub(crate)"
This reverts commit c51213c2e7.
2021-04-10 20:30:24 +02:00
Jonas Schievink
526dc4b5f5 Revert "Use name![derive]"
This reverts commit d6187de4cd.
2021-04-10 20:30:19 +02:00
bors[bot]
dea3ff609e
Merge #8458
8458: Respect test style guidelines in tests::traits r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-10 16:06:01 +00:00
Lukas Wirth
8113c3a914 Respect test style guidelines in tests::traits 2021-04-10 18:03:27 +02:00
bors[bot]
4bf32eea21
Merge #8457
8457: Implement more precise binary op return type heuristic r=flodiebold a=Veykril

Should fix #7150

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-10 15:53:06 +00:00
Lukas Wirth
a15b8136ee Add test for binary op return ty with adt 2021-04-10 17:52:24 +02:00
Lukas Wirth
d9554c258b Add manual ops::Add impls to test::traits::closure_2 2021-04-10 17:16:35 +02:00
Lukas Wirth
252eb78dc3 Implement more precise binary op return type prediction 2021-04-10 16:56:32 +02:00
bors[bot]
0fac165052
Merge #8410
8410: Use CompletionTextEdit::InsertAndReplace if supported by the client r=Veykril a=Veykril

Fixes #8404, Fixes #3130

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-10 13:07:46 +00:00
bors[bot]
e357b6bb36
Merge #8384
8384: add is quadratic test r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-10 10:01:03 +00:00