Commit graph

269 commits

Author SHA1 Message Date
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
kjeremy
761a81822a Update crates 2021-04-07 11:39:33 -04:00
kjeremy
b246f57fad Use arrayvec 0.7 to avoid perf regression in 0.6.1
See: https://github.com/bluss/arrayvec/issues/182
2021-04-05 12:58:35 -04:00
unexge
8d4be829e0 Add convert tuple struct to named struct assist 2021-04-04 20:52:43 +03:00
Edwin Cheng
eedadd7024 Add support for doc on hover for macro 2.0 2021-03-27 14:57:11 +08:00
Edwin Cheng
a193666361 Basic Support Macro 2.0 2021-03-27 13:44:54 +08:00
Aleksey Kladov
1bbac9053d Add TokenText 2021-03-26 21:33:45 +03:00
cynecx
5ff3299dd6 syntax: return owned string instead of leaking string 2021-03-26 18:30:59 +01:00
Laurențiu Nicola
bc5c86543b Use more std::array::IntoIter 2021-03-25 21:06:48 +02:00
Laurențiu Nicola
9787bddac5 Use arrayvec 0.6 2021-03-25 21:03:20 +02:00
Aleksey Kladov
e33959a888 Simplify code
changelog: skip
2021-03-23 19:41:15 +03:00
Aleksey Kladov
9cbf09ec4f rewrite merge use trees assist to use muatable syntax trees
changelog internal
2021-03-22 20:47:46 +03:00
Aleksey Kladov
48b534ceb8 ⬆️ rowan 2021-03-22 20:26:59 +03:00
Matthias Krüger
202b51bc7b a lot of clippy::style fixes 2021-03-21 16:15:41 +01:00
Matthias Krüger
ae7e55c1dd clippy::complexity simplifications related to Iterators 2021-03-21 13:13:34 +01:00
Matthias Krüger
8a67116857 use strip_prefix() instead of starts_with and slicing (clippy::manual_strip) 2021-03-21 12:38:21 +01:00
Matthias Krüger
3d9b3a8575 remove more redundant clones (clippy::redundant_clone()) 2021-03-21 12:10:39 +01:00
Lukas Wirth
38048c35d8 Don't use an untyped String for ActiveParam tracking 2021-03-20 23:22:09 +01:00
Jonas Schievink
fc5f73de45 Move AttrsOwnerNode to syntax and make it public 2021-03-19 20:05:17 +01:00
Aleksey Kladov
a61691026a Make ast editing more ergonomic
changelog internal
2021-03-19 20:53:23 +03:00
Lukas Wirth
4771a56791 Parse extended_key_value_attributes 2021-03-19 02:13:46 +01:00
Jonas Schievink
022a0f061e Correctly parse attributes on fn parameters 2021-03-17 18:28:27 +01:00
Lukas Wirth
ec824a92d0 Better handling of block doc comments 2021-03-17 14:48:57 +01:00