Commit Graph

5821 Commits

Author SHA1 Message Date
Edwin Cheng
f7f121d60d Add dylib loading code 2020-04-10 01:18:47 +08:00
bors[bot]
dde9488559
Merge #3919
3919: Refactor tokena accessors r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-09 16:54:14 +00:00
Aleksey Kladov
2bfb65db93 Be consistent about token accesors 2020-04-09 18:48:13 +02:00
bors[bot]
4cea01fdf8
Merge #3917
3917: Improve tt::Subtree debug print r=matklad a=edwin0cheng



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-09 16:39:19 +00:00
Aleksey Kladov
e6d22187a6 Add _token suffix to token accessors
I think this makes is more clear which things are : AstNode and which
are : AstToken
2020-04-09 18:25:36 +02:00
Aleksey Kladov
a95116fbfa Simplify 2020-04-09 18:20:06 +02:00
Edwin Cheng
19d952c603 Improve tt::Subtree debug print 2020-04-10 00:17:32 +08:00
Aleksey Kladov
56c8581b90 Put displays at the end 2020-04-09 18:11:16 +02:00
Aleksey Kladov
9285cbffb6 More compact 2020-04-09 18:08:54 +02:00
Aleksey Kladov
6fd2a12495 More compact generated code 2020-04-09 18:07:16 +02:00
Aleksey Kladov
4a063e651f Move the rest of the tokens to generated/tokens 2020-04-09 17:58:15 +02:00
Aleksey Kladov
c80795e274 Move generated tokens to a separate file 2020-04-09 17:47:46 +02:00
Aleksey Kladov
59b6b2278b Start ast/generated/tokens 2020-04-09 16:25:06 +02:00
Aleksey Kladov
d61932ef7e Prepare for spliting generated into tokens and nodes 2020-04-09 16:17:18 +02:00
Aleksey Kladov
738fc79c92 Remove allocations from LCA
I haven't actually profiled this, but not allocating a hash map (or
anything, really) seems like a good idea
2020-04-09 13:56:45 +02:00
Luca Barbieri
74e3b48806 Parse correctly fn f<T>() where T: Fn() -> u8 + Send {}
We used to parse it as T: Fn() -> (u8 + Send), which is different from
the rustc behavior of T: (Fn() -> u8) + Send
2020-04-09 13:05:41 +02:00
Aleksey Kladov
689661c959 Scale back to only two traits 2020-04-09 13:00:09 +02:00
Luca Barbieri
60f4d7bd8c Provide more complete AST accessors to support usage in rustc 2020-04-09 11:50:37 +02:00
bors[bot]
8595693287
Merge #3909
3909: Generate tokense r=matklad a=matklad

bors r+
🤖

Co-authored-by: Luca Barbieri <luca@luca-barbieri.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-09 09:24:19 +00:00
Aleksey Kladov
8f01e62bb9 Scale back the traits 2020-04-09 11:04:18 +02:00
bors[bot]
412eda7387
Merge #3880
3880: Add support for attributes for struct fields r=matklad a=bnjjj

Hello I try to solve this example:
```rust
struct MyStruct {
    my_val: usize,
    #[cfg(feature = "foo")]
    bar: bool,
}
impl MyStruct {
    #[cfg(feature = "foo")]
    pub(crate) fn new(my_val: usize, bar: bool) -> Self {
        Self { my_val, bar }
    }
    #[cfg(not(feature = "foo"))]
    pub(crate) fn new(my_val: usize, _bar: bool) -> Self {
        Self { my_val }
    }
}
```

Here is a draft PR to try to solve this issue. In fact for now when i have this kind of example, rust-analyzer tells me that my second Self {} miss the bar field. Which is a bug.

I have some difficulties to add this features. Here in my draft I share my work about adding attributes support on struct field data. But I'm stuck when I have to fetch attributes from parent expressions. I don't really know how to do that. For the first iteration I just want to solve my issue without solving on all different expressions. And then after I will try to implement that on different kind of expression. I think I have to fetch my FunctionId and then I will be able to find attributes with myFunction.attrs() But I don't know if it's the right way.

@matklad (or anyone else) if you can help me it would be great :D 

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-09 08:08:55 +00:00
Aleksey Kladov
dd2e8e86a9 Fix add missing items assist order
closes #3904
2020-04-09 10:00:27 +02:00
Benjamin Coenen
585bb83e2a feat: add attributes support on struct fields and method #3870
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-09 09:53:53 +02:00
Edwin Cheng
836384393b Remove unused func 2020-04-09 13:04:01 +08:00
Edwin Cheng
6af1015f74 Add rustc_server (ra_tt rustc bridge) 2020-04-09 12:22:45 +08:00
Josh Mcguigan
36c110ee09 match checking add additional test for match checking tuple with missing pattern 2020-04-08 10:47:05 -07:00
Josh Mcguigan
941615748d fix panic in match checking when tuple enum missing pattern 2020-04-08 10:47:05 -07:00
Benjamin Coenen
8f1dba6f9a feat: add attributes support on struct fields and method #3870
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-08 18:12:15 +02:00
Luca Barbieri
68196ccc10 Add AstElement trait, generate tokens, support tokens in enums
- Adds a new AstElement trait that is implemented by all generated
  node, token and enum structs

- Overhauls the code generators to code-generate all tokens, and
  also enhances enums to support including tokens, node, and nested
  enums
2020-04-08 17:15:12 +02:00
Luca Barbieri
35a69d09ee Fix warnings emitted when compiling as part of rustc 2020-04-08 14:49:19 +02:00
bors[bot]
8ea7c9cb62
Merge #3826
3826: Flatten nested highlight ranges during DFS traversal r=matklad a=ltentrup

Implements the flattening of nested highlights from #3447.


There is a caveat: I needed to add `Clone` to `HighlightedRange` to split highlight ranges  ~and the nesting does not appear in the syntax highlighting test (it does appear in the accidental-quadratic test but there it is not checked against a ground-truth)~.

I have added a test case for the example mentioned in #3447.

Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
2020-04-08 12:00:08 +00:00
bors[bot]
9aa3bca536
Merge #3892
3892: Add L_DOLLAR for TYPE_RECOVERY_SET r=matklad a=edwin0cheng

This PR is a hot fix for issue #3861 that just prevent it make the parser being stuck.

The actual problem described in https://github.com/rust-analyzer/rust-analyzer/pull/3873#issuecomment-610208693 is a very deep rabbit hole I don't want to dig right now :(

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-08 10:51:46 +00:00
Edwin Cheng
53d05448c1 Add L_DOLLAR for TYPE_RECOVERY_SET 2020-04-08 18:34:20 +08:00
Aleksey Kladov
9e3c843847 fmt 2020-04-08 12:19:41 +02:00
Aleksey Kladov
4c29214bba Move computation of missing fields into hir 2020-04-07 18:34:17 +02:00
Aleksey Kladov
7819d99d6b Add functional update test 2020-04-07 18:25:47 +02:00
Aleksey Kladov
d8f6013404 Fix names of test modules 2020-04-07 18:23:18 +02:00
Benjamin Coenen
18a5e16483 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-04-07 17:59:09 +02:00
Benjamin Coenen
ab864ed259 feat: add attributes support on struct fields #3870
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-07 17:58:05 +02:00
bors[bot]
33c364b545
Merge #3878
3878: A more precise panic macro r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-07 14:41:07 +00:00
Aleksey Kladov
3bde2b7423 A more precise panic macro 2020-04-07 16:40:39 +02:00
Aleksey Kladov
5540193fc8 Don't insert !() if there's already some 2020-04-07 16:37:33 +02:00
Aleksey Kladov
73ccf7f495 Reorder imports 2020-04-07 15:07:18 +02:00
Josh Mcguigan
9fc1f51b7a add fixme to use type checker rather than manually comparing types 2020-04-07 05:17:59 -07:00
Josh Mcguigan
a208de15b7 PR feedback implementation 2020-04-07 05:12:08 -07:00
Josh Mcguigan
da6752d5f9 missing match arms diagnostic change source to match expression 2020-04-07 05:12:08 -07:00
Josh Mcguigan
5fe608fb31 handle match auto-deref 2020-04-07 05:12:08 -07:00
Josh Mcguigan
5b4316377b improving documentation 2020-04-07 05:12:08 -07:00
Josh Mcguigan
43dfd89493 handle non matching enum pattern types 2020-04-07 05:12:08 -07:00
Josh Mcguigan
b87b7a088f remove panics 2020-04-07 05:12:08 -07:00