Commit Graph

291 Commits

Author SHA1 Message Date
Domantas Jadenkus
22e5194396 generate match arms with todo!() as placeholder body 2021-05-24 22:17:16 +03:00
Laurențiu Nicola
b43bc61981 Bump rustc_lexer 2021-05-24 16:39:19 +03:00
Aleksey Kladov
188b0f96f9 Add more docs 2021-05-22 16:53:47 +03:00
Aleksey Kladov
47d7434dde internal: replace AstTransformer with mutable syntax trees 2021-05-22 15:27:32 +03:00
Lukas Tobias Wirth
da7f1eb756 Don't compare ast::Visibility by stringifying 2021-05-20 17:45:59 +02:00
Aleksey Kladov
75a0123614 fix: don't add extra whitespace around fields
closes #8785
2021-05-17 12:45:01 +03:00
Aleksey Kladov
1859df37fd internal: use mutable syntax trees when filling fields 2021-05-16 18:10:56 +03:00
Aleksey Kladov
e4a7b44e55 internal: use mutable trees when filling match arms 2021-05-16 15:10:18 +03:00
bors[bot]
a57bd59f35
Merge #8813
8813: Get some more array lengths! r=lf- a=lf-

This is built on #8799 and thus contains its changes. I'll rebase it onto master when that one gets merged. It adds support for r-a understanding the length of:

* `let a: [u8; 2] = ...`
* `let a = b"aaa"`
* `let a = [0u8; 4]`

I have added support for getting the values of byte strings, which was not previously there. I am least confident in the correctness of this part and it probably needs some more tests, as we currently have only one test that exercised that part (!).

Fixes #2922.

Co-authored-by: Jade <software@lfcode.ca>
2021-05-16 01:53:12 +00:00
Lukas Wirth
4b5b54279a Attach comments to ast::Impl 2021-05-15 17:32:28 +02:00
Aleksey Kladov
883dd1568f internal: use more mutable APIs 2021-05-14 20:00:35 +03:00
Aleksey Kladov
cea589b3b5 internal: rewrite assoc item manipulaion to use mutable trees 2021-05-14 18:47:08 +03:00
Aleksey Kladov
73123a7550 internal: remove SyntaxRewriter 2021-05-14 16:40:11 +03:00
Aleksey Kladov
873717190d internal: remove more of the SyntaxRewriter 2021-05-14 16:28:59 +03:00
Aleksey Kladov
0650f77dd9 internal: remove one more immutable tree 2021-05-14 16:19:27 +03:00
Aleksey Kladov
ad0648dc95 Cleanup imports 2021-05-13 13:44:47 +03:00
Jade
73023c0299 Support length for ByteStrings
I am not confident that my added byte string parsing is right.
2021-05-12 21:22:46 -07:00
Aleksey Kladov
bf26e13cd2 simplify 2021-05-10 15:25:56 +03:00
Aleksey Kladov
4f3c0adc5a internal: introduce ast::make::ext module with common shortcuts
There's a tension between keeping a well-architectured minimal
orthogonal set of constructs, and providing convenience functions.
Relieve this pressure by introducing an dedicated module for
non-orthogonal shortcuts.

This is inspired by the django.shortcuts module which serves a similar
purpose architecturally.
2021-05-09 19:55:43 +03:00
Aleksey Kladov
680a0d54e4 internal: fix make API 2021-05-09 19:22:33 +03:00
Aleksey Kladov
5342800147 internal: rewrite **Repalce impl Trait** assist to mutable syntax trees 2021-05-09 18:20:37 +03:00
Aleksey Kladov
d9c9f6dc2c cleanups 2021-05-09 17:58:03 +03:00
Aleksey Kladov
8a7904127d minor: remove dead code 2021-05-08 23:28:36 +03:00
Aleksey Kladov
1755b57e1a internal: pull_assignment_up uses mutable trees 2021-05-08 23:11:42 +03:00
Aleksey Kladov
880ddddfe6 dead code 2021-05-08 20:02:48 +03:00
Aleksey Kladov
1fdc9d8e9e internal: remove one more syntax rewriter 2021-05-08 14:47:14 +03:00
Jonas Schievink
e2b664e9fd fix: use raw idents in make::name{_ref} with keywords 2021-05-07 17:22:54 +02:00
Dawer
0a156c80af Hide implementation details of TokenText 2021-05-06 10:07:06 +05:00
Dawer
d9b4ac8128 Clean up 2021-05-06 10:07:06 +05:00
Dawer
d7e169fe55 Borrow text from nodes of immutable syntax trees 2021-05-06 10:07:06 +05:00
Dawer
dc4fa504ea Adapt to a new rowan borrowing node API. 2021-05-06 10:06:52 +05:00
Dawer
52143f389f Update to rowan 0.13.0-pre.5 2021-05-06 10:04:39 +05:00
Jonas Schievink
cb8632d87c Parse const param defaults 2021-04-29 03:07:53 +02:00
Jonas Schievink
caee3a2eeb Correctly parse negated literals as const args 2021-04-29 02:27:55 +02:00
Lukas Wirth
050c69c19d Split out merge_imports module from helpers::insert_use 2021-04-24 13:31:43 +02:00
bors[bot]
5cbde9f531
Merge #8591 #8638
8591: Remove SyntaxRewriter usage in insert_use in favor of mutable syntax trees r=matklad a=Veykril

Unfortunately changing `insert_use` to not use `SyntaxRewriter` creates a lot of changes since so much relies on that. But on the other hand this should be the biggest usage of `SyntaxRewriter` I believe.

8638: Remove SyntaxRewriter::from_fn r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-23 16:49:08 +00:00
Lukas Wirth
e6e4417bbb Remove SyntaxRewriter::from_fn 2021-04-23 18:36:43 +02:00
bors[bot]
85bab7539a
Merge #8317
8317: Convert tuple struct to named struct assist r=Veykril a=unexge

Closes https://github.com/rust-analyzer/rust-analyzer/issues/8192

Co-authored-by: unexge <unexge@gmail.com>
2021-04-23 13:37:48 +00:00
Laurențiu Nicola
e50ca6b067 Bump rustc_lexer 2021-04-21 19:19:27 +03:00
Comonad
09147c3303 Add support for fill match arms of boolean values
- Add support for boolean inside tuple
2021-04-21 19:33:45 +08:00
Lukas Wirth
3f7a086b4f Parse outer atttributes for RecordPatField 2021-04-21 11:08:15 +02:00
Lukas Wirth
fa20a5064b Remove SyntaxRewriter usage in insert_use in favor of ted 2021-04-20 02:09:12 +02:00
bors[bot]
6877e6e4da
Merge #8578
8578: fix: false positive about inner attrs in docs r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-19 14:37:54 +00:00
Aleksey Kladov
5f89a60f1a fix: false positive about inner attrs in docs
closes #8541
2021-04-19 17:11:49 +03:00
bors[bot]
e7a8977358
Merge #8524 #8527
8524: Fix extract function with partial block selection r=matklad a=brandondong

**Reproduction:**
```rust
fn foo() {
    let n = 1;
    let mut v = $0n * n;$0
    v += 1;
}
```
1. Select the snippet ($0) and use the "Extract into function" assist.
2. Extracted function is incorrect and does not compile:
```rust
fn foo() {
    let n = 1;
    let mut v = fun_name(n);
    v += 1;
}

fn fun_name(n: i32) {}
```
3. Omitting the ending semicolon from the selection fixes the extracted function:
```rust
fn fun_name(n: i32) -> i32 {
    n * n
}
```

**Cause:**
- When `extraction_target` uses a block extraction (semicolon case) instead of an expression extraction (no semicolon case), the user selection is directly used as the TextRange.
- However, the existing function extraction logic for blocks requires that the TextRange spans from start to end of complete statements to work correctly.
- For example:
```rust
fn foo() {
    let m = 2;
    let n = 1;
    let mut v = m $0* n;
    let mut w = 3;$0
    v += 1;
    w += 1;
}
```
produces
```rust
fn foo() {
    let m = 2;
    let n = 1;
    let mut v = m let mut w = fun_name(n);
    v += 1;
    w += 1;
}

fn fun_name(n: i32) -> i32 {
    let mut w = 3;
    w
}
```
- The user selected TextRange is directly replaced by the function call which is now in the middle of another statement. The extracted function body only contains statements that were fully covered by the TextRange and so the `* n` code is deleted. The logic for calculating variable usage and outlived variables for the function parameters and return type respectively search within the TextRange and so do not include `m` or `v`.

**Fix:**
- Only extract full statements when using block extraction. If a user selected part of a statement, extract that full statement.

8527: Switch introduce_named_lifetime assist to use mutable syntax tree  r=matklad a=iDawer

This extends `GenericParamsOwnerEdit` trait with `get_or_create_generic_param_list` method

Co-authored-by: Brandon <brandondong604@hotmail.com>
Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-04-19 13:09:18 +00:00
cynecx
cf3b4f1e20 hir_ty: Expand macros at type position 2021-04-17 16:24:56 +02:00
Bernhard Schuster
3b7753d257
nail rowan version down
The different pre versions include breaking changes, which cause build failures for the users.
2021-04-17 09:31:54 +02:00
Dawer
8965be3d0e Fill match arms for a tuple of a single enum. 2021-04-16 17:22:11 +05:00
Dawer
cedbf2e1c5 Finish GenericParamsOwnerEdit impls 2021-04-15 15:57:45 +05:00
Dawer
144afa55a6 Switch introduce_named_lifetime assist to use mutable syntax tree 2021-04-15 01:56:19 +05:00