Commit graph

239 commits

Author SHA1 Message Date
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
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
bors[bot]
0fbfab3b45
Merge #8059
8059: Move doc-comment highlight injection from AST to HIR r=matklad,jonas-schievink a=Veykril

Fixes #5016

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-17 11:13:54 +00:00
Matthias Krüger
966c23f529 avoid converting types into themselves via .into() (clippy::useless-conversion)
example: let x: String = String::from("hello world").into();
2021-03-17 01:27:56 +01:00
Aleksey Kladov
186a430853 pit-of-successify tree editor 2021-03-16 22:59:57 +03:00
Aleksey Kladov
34555593ca Auto-magical whitespace 2021-03-16 22:51:37 +03:00
Aleksey Kladov
d733c9bdad Move more bounds
changelog: skip
2021-03-16 22:28:04 +03:00
Lukas Wirth
acc6458390 Replace trait object boxing with extra AttrsOwnerNode 2021-03-16 19:06:58 +01:00
Aleksey Kladov
f5a81ec468 Upgrade rowan
Notably, new rowan comes with support for mutable syntax trees.
2021-03-16 16:10:49 +03:00
Edwin Cheng
8e07b23b84 Fix macro expansion for statements w/o semicolon 2021-03-16 13:44:50 +08:00
Laurențiu Nicola
88cee24c6c Enable thread-local coverage marks 2021-03-15 16:02:50 +02:00
Lukas Wirth
6e6d75bbdc Attach trivia to ast::Union nodes 2021-03-14 11:11:01 +01:00
bors[bot]
c0459c5357
Merge #7956
7956: Add assist to convert for_each into for loops r=Veykril a=SaiintBrisson

This PR resolves #7821.
Adds an assist to that converts an `Iterator::for_each` into a for loop: 

```rust
fn main() {
    let vec = vec![(1, 2), (2, 3), (3, 4)];
    x.iter().for_each(|(x, y)| {
        println!("x: {}, y: {}", x, y);
    })
}
```
becomes
```rust
fn main() {
    let vec = vec![(1, 2), (2, 3), (3, 4)];
    for (x, y) in x.iter() {
        println!("x: {}, y: {}", x, y);
    });
}
```

Co-authored-by: Luiz Carlos Mourão Paes de Carvalho <luizcarlosmpc@gmail.com>
Co-authored-by: Luiz Carlos <luizcarlosmpc@gmail.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-12 14:45:04 +00:00
kjeremy
08e0e9976d cargo update and lexer 2021-03-10 13:47:12 -05:00
Luiz Carlos Mourão Paes de Carvalho
61fb16577b feat: add expr_for_loop to make in syntax 2021-03-09 23:54:35 -03:00
bors[bot]
21913d0fdb
Merge #7873 #7933
7873: Consider unresolved qualifiers during flyimport r=matklad a=SomeoneToIgnore

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

Takes unresolved qualifiers into account, providing better completions (or none, if the path is resolved or do not match).

Does not handle cases when both path qualifier and some trait has to be imported: there are many extra issues with those (such as overlapping imports, for instance) that will require large diffs to address.

Also does not do a fuzzy search on qualifier, that requires some adjustments in `import_map` for better queries and changes to the default replace range which also seems relatively big to include here.

![qualifier_completion](https://user-images.githubusercontent.com/2690773/110040808-0af8dc00-7d4c-11eb-83db-65af94e843bb.gif)


7933: Improve compilation speed r=matklad a=matklad

bors r+
🤖

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-09 11:58:48 +00:00
Aleksey Kladov
867fdf8f03 Improve compilation speed 2021-03-09 14:54:50 +03:00
Kirill Bulatov
778deb38fe Better strip turbofishes 2021-03-08 23:59:39 +02:00
Laurențiu Nicola
fc9eed4836 Use upstream cov-mark 2021-03-08 22:19:44 +02:00
Aleksey Kladov
abb6b8f14c Use the same name in xtask and test utils 2021-03-08 21:45:06 +03:00
kjeremy
41d1b4cd26 Update lexer 2021-03-02 15:33:22 -05:00
bors[bot]
2183d65c97
Merge #7777
7777: Implement line<->block comment assist r=Veykril a=djrenren

Fixes: https://github.com/rust-analyzer/rust-analyzer/issues/6515

Co-authored-by: John Renner <john@jrenner.net>
2021-03-02 08:04:38 +00:00
kjeremy
d42730b76e bump crates 2021-02-25 10:34:48 -05:00
John Renner
9eecba4dbf Implement line<->block comment assist 2021-02-24 17:13:00 -08:00
Lukas Wirth
694f7a7e9f Add tests for apply_demorgan 2021-02-24 11:58:37 +01:00
Laurențiu Nicola
48ae948b22 Bump deps 2021-02-21 19:13:11 +02:00
Laurențiu Nicola
af4148970a Fix incorrect missing field diagnostic with box patterns 2021-02-20 12:36:17 +02:00
Lukas Wirth
2887426da0 Revert "Replace usage of ast::NameOrNameRef with ast::NameLike"
This reverts commit e1dbf43cf8.
2021-02-17 15:00:44 +01:00
Lukas Wirth
e1dbf43cf8 Replace usage of ast::NameOrNameRef with ast::NameLike 2021-02-17 14:02:34 +01:00
Lukas Wirth
e52bdc55ef Implement ast::AstNode for NameLike and move it to node_ext 2021-02-16 19:27:08 +01:00
bors[bot]
b7a6d830be
Merge #7687
7687: Specialization for async traits r=matklad a=arnaudgolfouse

Fixes #7669.

Adapting the parser seemed to be all that was needed, but I am not very experienced with the codebase. Is this enough ?

Co-authored-by: Arnaud <arnaud.golfouse@laposte.net>
2021-02-16 14:16:47 +00:00
bors[bot]
88e8b0a5fa
Merge #7620
7620: Support control flow in `extract_function` assist r=matklad a=cpud36

Support `return`ing from outer function, `break`ing and `continue`ing outer loops when extracting function.

# Example
Transforms
```rust
fn foo() -> i32 {
  let items = [1,2,3];
  let mut sum = 0;
  for &item in items {
    <|>if item == 42 {
      break;
    }<|>
    sum += item;
  }
  sum
}
```
Into 
```rust
fn foo() -> i32 {
  let items = [1,2,3];
  let mut sum = 0;
  for &item in items {
    if fun_name(item) {
      break;
    }
    sum += item;
  }
  sum
}

fn fun_name(item: i32) -> bool {
  if item == 42 {
    return true;
  }
  false
}
```

![add_explicit_type_infer_type](https://user-images.githubusercontent.com/4218373/107544222-0fadf280-6bdb-11eb-9625-ed6194ba92c0.gif)

# Features

Supported variants
- break and function does not return => uses `bool` and plain if
- break and function does return => uses `Option<T>` and matches on it
- break with value and function does not return => uses `Option<T>` and if let
- break with value and function does return => uses `Result<T, U>` and matches on t
- same for `return` and `continue`(but we can't continue with value)

Assist does handle nested loops and nested items(like functions, modules, impls)

Try `expr?` operator is allowed together with `return Err(_)` and `return None`.
`return expr` is not allowed.

# Not supported
## Mixing `return` with `break` or `continue`
If we have e.g. a `return` and a `break` in the selected code, it is unclear what the produced code should look like.
We can try `Result<T, Option<U>>` or something like that, but it isn't idiomatic, nor it is established. Otherwise, implementation
is relatively simple.

## `break` with label
Not sure how to handle different labels for multiple `break`s.

[edit] implemented try `expr?`

Co-authored-by: Vladyslav Katasonov <cpud47@gmail.com>
2021-02-16 14:01:09 +00:00