Commit Graph

398 Commits

Author SHA1 Message Date
Jonas Schievink
3dd5e273b6 Shrink diagnostic spans for errors inside macros 2022-01-08 15:40:42 +01:00
Jonas Schievink
67f548d8e9 Allow doc comments on all Items 2022-01-08 15:27:48 +01:00
bors[bot]
c17db9fa53
Merge #11107
11107: Fix generic type substitution in impl trait with assoc type r=pnevyk a=pnevyk

Fixes #11045 

The path transform now detects if a type parameter that is being substituted has an associated type. In that case it is necessary (or safe in general case) to fully qualify the substitution with a trait which the associated type belongs to.

This PR also fixes the previous wrong behavior of the substitution that could create an invalid tree `PATH_TYPE -> PATH_TYPE -> ...`.

Co-authored-by: Petr Nevyhoštěný <petr.nevyhosteny@gmail.com>
2022-01-08 09:05:09 +00:00
bors[bot]
41a0e95d61
Merge #11230
11230: fix: Fix attribute stripping ignoring doc comments r=Veykril a=Veykril

Follow up to https://github.com/rust-analyzer/rust-analyzer/pull/11225#pullrequestreview-846779237


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-07 18:06:33 +00:00
Lukas Wirth
81163b8cd4 fix: Fix attribute stripping ignoring doc comments 2022-01-07 18:51:10 +01:00
bors[bot]
40009e07d0
Merge #11145
11145: feat: add config to use reasonable default expression instead of todo! when filling missing fields r=Veykril a=bnjjj

Use `Default::default()` in struct fields when we ask to fill it instead of putting `todo!()` for every fields

before:

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {<|>};
}
``` 

after: 

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {
        text: String::new(),
        num: 0,
        other: todo!(),
    };
}
``` 



Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Coenen Benjamin <benjamin.coenen@hotmail.com>
2022-01-07 14:10:11 +00:00
Lukas Wirth
08adce61a1 Better interface for doc comment and attribute processing 2022-01-07 14:14:33 +01:00
Benjamin Coenen
b60a29ca94 feat(diagnostics): use default expression instead of todo! when missing fields
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-07 14:13:34 +01:00
Lukas Wirth
69dbfc7754 Generate AnyHasDocComments node 2022-01-07 12:38:18 +01:00
Jonas Schievink
9dd42cd1e1 Useconst _ instead of mod __ 2022-01-06 12:55:33 +01:00
Jonas Schievink
3ff68f25b8 Expand attribute macros on impl and trait items 2022-01-06 12:30:16 +01:00
Benjamin Coenen
336c899a07 add better default behavior on fill struct fields diagnostic
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-04 15:59:00 +01:00
Benjamin Coenen
0435463439 feat(diagnostics): use Default::default() expression instead of todo! when missing fields
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2021-12-30 15:49:31 +01:00
Ariel Davis
d4262f4af8 Migrate to SyntaxNodePtr in new rowan 2021-12-29 23:48:53 -08:00
Aleksey Kladov
660cf34d8c dead code 2021-12-28 19:13:30 +03:00
Aleksey Kladov
bfc263f1f9 introduce hacks module 2021-12-28 18:57:13 +03:00
Aleksey Kladov
45bba40079 dead code 2021-12-28 17:00:55 +03:00
Aleksey Kladov
55f1564101 remove fragments from syntax 2021-12-28 17:00:55 +03:00
Aleksey Kladov
7e9c74d20b drop dead code 2021-12-28 17:00:55 +03:00
Aleksey Kladov
f0fefde401 remove Item::parse 2021-12-28 17:00:55 +03:00
Aleksey Kladov
b468bd6645 internal: start isolating ssr-related parsing APIs to SSR 2021-12-28 17:00:55 +03:00
Aleksey Kladov
b360ea91f2 internal: move inline parser tests to parser crate 2021-12-26 18:19:09 +03:00
Aleksey Kladov
0f74758fea internal: move outlined parser tests 2021-12-26 17:58:33 +03:00
Aleksey Kladov
f4cb0ff9be internal: move ws attachment logic to the parser crate
This has to re-introduce the `sink` pattern, because doing this purely
with iterators is awkward :( Maaaybe the event vector was a false start?

But, anyway, I like the current factoring more -- it sort-of obvious
that we do want to keep ws-attachment business in the parser, and that
we also don't want that to depend on the particular tree structure. I
think `shortcuts` module achieves that.
2021-12-26 16:47:10 +03:00
Aleksey Kladov
f692fafee8 rename 2021-12-25 22:03:57 +03:00
Aleksey Kladov
74de79b1da internal: rename 2021-12-25 22:02:26 +03:00
Aleksey Kladov
d0d05075ed internal: replace TreeSink with a data structure
The general theme of this is to make parser a better independent
library.

The specific thing we do here is replacing callback based TreeSink with
a data structure. That is, rather than calling user-provided tree
construction methods, the parser now spits out a very bare-bones tree,
effectively a log of a DFS traversal.

This makes the parser usable without any *specifc* tree sink, and allows
us to, eg, move tests into this crate.

Now, it's also true that this is a distinction without a difference, as
the old and the new interface are equivalent in expressiveness. Still,
this new thing seems somewhat simpler. But yeah, I admit I don't have a
suuper strong motivation here, just a hunch that this is better.
2021-12-25 22:02:26 +03:00
Petr Nevyhoštěný
d9b3242bcd Fix generic type substitution in impl trait with assoc type 2021-12-23 10:16:24 +01:00
Lukas Wirth
7f7a3644b3 Fully render type alias completions from hir 2021-12-21 16:36:23 +01:00
Lukas Wirth
40d5c58a80 Fully render const item completions from hir 2021-12-21 16:35:51 +01:00
Aleksey Kladov
a022ad68c9 internal: move all the lexing to the parser crate 2021-12-18 17:20:38 +03:00
Aleksey Kladov
958f20ff84 minor: dead code 2021-12-18 14:55:20 +03:00
Lukas Wirth
901c7c7277 match_ast! takes a pattern to allow underscore usage 2021-12-14 12:44:31 +01:00
bors[bot]
791722b70a
Merge #10998
10998: Add number representation assists r=Veykril a=errx

Reimplemented assists from this PR https://github.com/rust-analyzer/rust-analyzer/pull/3683 with current APIs.
![image](https://user-images.githubusercontent.com/462486/145726792-47700215-26f2-4fdc-9520-63d1487901e5.png)
![image](https://user-images.githubusercontent.com/462486/145726802-f528a2f7-9159-41d3-b459-fc3fae033e60.png)


I've decided not to add options about size of the groups so behaviour is similar to clippy's. 
Minimal number length is also taken from clippy.


Co-authored-by: Oleg Matrokhin <matrokhin@gmail.com>
2021-12-13 18:49:06 +00:00
Oleg Matrokhin
60605a24d4 Reuse results from split_into_parts() 2021-12-13 21:16:04 +03:00
Oleg Matrokhin
8b03b41b7a Add number representation assists 2021-12-13 19:35:38 +03:00
Aleksey Kladov
57e6ef0bfb tighten up invariants 2021-12-12 19:22:37 +03:00
Aleksey Kladov
965585748e more orthogonal interface 2021-12-12 18:38:49 +03:00
Aleksey Kladov
6ce587ba5a parser tests work 2021-12-12 18:31:05 +03:00
Lukas Wirth
0c98a01b3e Remove possible multiline details in completions 2021-11-24 16:08:11 +01:00
iDawer
601413df8f Use mutable syntax trees in merge_imports, split_imports 2021-11-19 20:02:27 +05:00
Laurențiu Nicola
b23bebebc0 Remove validation of super in use paths 2021-11-16 20:02:42 +02:00
TheDoctor314
58a24de7d8 Fix impl_def_from_trait
Revert "Fix `impl_trait` function to emit correct ast"

This reverts commit 55a4813151.

Fix `impl_def_from_trait`

It now generates the correct `ast::Impl` using
`generate_trait_impl_text` and parses it to form the right node (copied
from the private fn 'make::ast_from_text').
2021-11-15 22:28:22 +05:30
TheDoctor314
55a4813151 Fix impl_trait function to emit correct ast
`impl_trait` code copied from `generate_impl_text_inner` to properly
handle the bounds for the generic parameters.
2021-11-11 14:16:59 +05:30
TheDoctor314
05b368f065 Add generic parameters for manual impl assist
The `impl_trait` function takes an optional `GenericParamList` to create
the trait impl.
2021-11-10 12:53:48 +05:30
Lukas Wirth
c93983e76f Fix for-loop expressions breaking with BlockExpr iterable 2021-10-30 16:37:32 +02:00
Lukas Wirth
3018ffd85e Refactor ide handling for paths in derive inputs 2021-10-28 16:47:19 +02:00
Aleksey Kladov
485c5e6717 internal: remove unused dollars 2021-10-23 20:44:35 +03:00
bors[bot]
a75353e8ac
Merge #9939
9939: feat: Adding extract_module assist r=Veykril a=feniljain

Should solve https://github.com/rust-analyzer/rust-analyzer/issues/9591

Co-authored-by: vi_mi <fenil.jain2018@vitstudent.ac.in>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-10-22 09:29:16 +00:00
Lukas Wirth
1294bfce86 Migrate to edition 2021 2021-10-21 20:10:40 +02:00