Commit Graph

491 Commits

Author SHA1 Message Date
Aleksey Kladov
4176c03d12 Remove SyntaxPtr::range from more places 2020-04-23 16:33:01 +02:00
Jeremy Kolb
d7f3d858ad Some clippy fixes 2020-04-19 15:15:49 -04:00
Aleksey Kladov
b79fd82559 Correctly infer types in guard expressions
The root cause was that we forgot to add bindings from the arm to the
guard expression

closes #3980
2020-04-18 22:16:04 +02:00
Florian Diebold
b49ecafd40 find_path: Builtins are always in scope
Fixes #3977.
2020-04-18 12:06:22 +02:00
bors[bot]
179d983535
Merge #4012
4012: fix panic on ellipsis in pattern r=flodiebold a=JoshMcguigan

fixes #3999

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-04-17 12:39:20 +00:00
Josh Mcguigan
408f914bf4 fix panic on ellipsis in pattern 2020-04-17 05:36:44 -07:00
Aleksey Kladov
146f6f5a45 Simplify Diagnostic structure
It's not entirely clear what subnode ranges should mean in the
presence of macros, so let's leave them out for now. We are not using
them heavily anyway.
2020-04-17 13:56:42 +02:00
Aleksey Kladov
a8196ffe84 Correctly highlight ranges of diagnostics from macros
closes #2799
2020-04-17 13:56:38 +02:00
Aleksey Kladov
302bf97bbf Don't expose impl details of SyntaxPtr 2020-04-17 12:25:41 +02:00
bors[bot]
1e0ba04033
Merge #3966 #3968
3966: Add support for bounds on associated types in trait definitions r=matklad a=flodiebold

E.g.
```rust
trait Trait {
    type Item: SomeOtherTrait;
}
```
Note that these don't simply desugar to where clauses; as I understand it, where clauses have to be proved by the *user* of the trait, but these bounds are proved by the *implementor*. (Also, where clauses on associated types are unstable.)

(Another one from my recursive solver branch...)

3968: Remove format from syntax_bridge hot path r=matklad a=edwin0cheng

Although only around 1% speed up by running:

```
Measure-Command {start-process .\target\release\rust-analyzer "analysis-stats -q ." -NoNewWindow -wait}
```

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-15 09:29:36 +00:00
bors[bot]
d61909f904
Merge #3964 #3965 #3967
3964: Nicer Chalk debug logs r=matklad a=flodiebold

I'm looking at a lot of Chalk debug logs at the moment, so here's a few changes to make them slightly nicer...

3965: Implement inline associated type bounds r=matklad a=flodiebold

Like `Iterator<Item: SomeTrait>`.

This is an unstable feature, but it's used in the standard library e.g. in the definition of Flatten, so we can't get away with not implementing it :)

(This is cherry-picked from my recursive solver branch, where it works better, but I did manage to write a test that works with the current Chalk solver as well...)

3967: Handle `Self::Type` in trait definitions when referring to own associated type r=matklad a=flodiebold

It was implemented for other generic parameters for the trait, but not for `Self`.

(Last one off my recursive solver branch 😄 )

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-04-15 09:19:46 +00:00
kjeremy
eedab116ab insta 0.16 2020-04-14 13:57:02 -04:00
Josh Mcguigan
ee822d19b7 handle tuple patterns with ellipsis 2020-04-13 08:19:19 -07:00
Florian Diebold
c8b2ec8c20 Add support for bounds on associated types in trait definitions
E.g.
```
trait Trait {
    type Item: SomeOtherTrait;
}
```
Note that these don't simply desugar to where clauses; as I understand it, where
clauses have to be proved by the *user* of the trait, but these bounds are proved
by the *implementor*. (Also, where clauses on associated types are unstable.)
2020-04-13 15:57:28 +02:00
Florian Diebold
db32a2e421 Implement inline associated type bounds
Like `Iterator<Item: SomeTrait>`.

This is an unstable feature, but it's used in the standard library e.g. in the
definition of Flatten, so we can't get away with not implementing it :)
2020-04-13 15:07:39 +02:00
Aleksey Kladov
5e5eb6a108 Align grammar for record patterns and literals
The grammar now looks like this

   [name_ref :] pat
2020-04-12 00:00:15 +02:00
bors[bot]
fd06fe7b13
Merge #3925
3925: Implement assist "Reorder field names" r=matklad a=geoffreycopin

This PR implements the "Reorder record fields" assist as discussed in issue #3821 .

Adding a `RecordFieldPat` variant to the `Pat` enum seemed like the easiest way to handle the `RecordPat` children as a single sequence of elements, maybe there is a better way ?

Co-authored-by: Geoffrey Copin <copin.geoffrey@gmail.com>
2020-04-11 18:40:46 +00:00
Aleksey Kladov
0aece75cdd Remove dead code 2020-04-11 19:36:31 +02:00
Geoffrey Copin
270bcfdfc2 Avoid adding a RecordFieldPat variant to the Pat enum 2020-04-11 19:30:41 +02:00
Aleksey Kladov
7a39bc3ba2 Make records grammar more orthogonal
We used

  name [: expr]

grammar before, now it is

  [name :] expr

which makes things simpler
2020-04-11 19:20:41 +02:00
Aleksey Kladov
f980b07529 Make incremental nameres test harder 2020-04-11 17:54:46 +02:00
Aleksey Kladov
38c67e5c0d Avoid cyclic queries in name resolution when processing enums 2020-04-11 17:52:26 +02:00
Aleksey Kladov
deb40d52aa Align naming 2020-04-11 17:20:26 +02:00
Aleksey Kladov
55356332bf Remove code duplication 2020-04-11 17:18:42 +02:00
Aleksey Kladov
b8eb1597c9 Use Expander for cfg handling in structs 2020-04-11 17:17:12 +02:00
Aleksey Kladov
ac21100f32 Use Expander for cfg handling in impls 2020-04-11 17:12:17 +02:00
Aleksey Kladov
e9519e1035 Pull Expander up 2020-04-11 17:09:50 +02:00
Aleksey Kladov
6b0870d12e Simplify 2020-04-11 17:00:31 +02:00
Aleksey Kladov
c1244c853c Forward compat 2020-04-11 00:27:00 +02:00
Aleksey Kladov
7995c916fe profile queries 2020-04-10 20:26:47 +02:00
Aleksey Kladov
c8b4c36f81 Semicolon token 2020-04-10 16:10:28 +02:00
Josh Mcguigan
e63315b8f1 add record pat missing field diagnostic 2020-04-10 06:35:52 -07:00
Geoffrey Copin
730a927c5e Implement assist "Reorder field names" 2020-04-10 00:57:03 +02:00
Aleksey Kladov
30084a56a5 Simpler acessors for keywords 2020-04-09 23:42:01 +02:00
Aleksey Kladov
00ec0c1066 use uniform accessor 2020-04-09 23:19:51 +02:00
bors[bot]
33df20868d
Merge #3918
3918: Add support for feature attributes in struct literal r=matklad a=bnjjj

As promised here is the next PR to solve 2 different scenarios with feature flag on struct literal.
close #3870 

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-09 19:27:06 +00:00
Benjamin Coenen
c1317d6923 feat: add support for feature attributes in struct literal
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-09 19:12:50 +02:00
Aleksey Kladov
2bfb65db93 Be consistent about token accesors 2020-04-09 18:48:13 +02:00
Benjamin Coenen
fc70cf9458 feat: add support for feature attributes in struct literal
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-09 18:32:02 +02: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
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
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
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
Aleksey Kladov
bf569f8b29 Check for eprintln on CI 2020-04-06 17:00:18 +02:00
Laurențiu Nicola
b58a7f41f1 Fix inference of function pointer return types 2020-04-05 18:18:40 +03:00
Aleksey Kladov
da8eb29a2f Macro patterns are not confused with expressions.
We treat macro calls as expressions (there's appropriate Into impl),
which causes problem if there's expresison and non-expression macro in
the same node (like in the match arm).

We fix this problem by nesting macor patterns into another node (the
same way we nest path into PathExpr or PathPat). Ideally, we probably
should add a similar nesting for macro expressions, but that needs
some careful thinking about macros in blocks: `{ am_i_expression!() }`.
2020-04-03 16:12:38 +02:00
Josh Mcguigan
d0b6b2ee2f lower bool literal with the value from source code rather than default bool value 2020-04-01 04:47:41 -07:00
Josh Mcguigan
a9d0c9b2a4 lower literal patterns 2020-04-01 04:18:46 -07:00
Aleksey Kladov
6596e7cddf Nice string formatting 2020-03-28 12:27:54 +01:00
bors[bot]
b1594f1080
Merge #3727
3727: Introduce ra_proc_macro r=matklad a=edwin0cheng

This PR implemented:

1.  Reading dylib path of proc-macro crate from cargo check , similar to how `OUTDIR` is obtained.
2.  Added a new crate `ra_proc_macro` and implement the foot-work for reading result from external proc-macro expander. 
3. Added a struct `ProcMacroClient` , which will be responsible to the client side communication to the External process.



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-26 17:09:32 +00:00
Edwin Cheng
db162df264 Remove deps on tt_mbe 2020-03-27 00:46:40 +08:00
Aleksey Kladov
db34abeb85 Get rid of ItemOrMacro 2020-03-26 16:10:01 +01:00
Aleksey Kladov
b7aaefb5a4 Minor incremental tests cleanup 2020-03-26 15:44:31 +01:00
Edwin Cheng
d0b6ed4441 Add ProcMacroClient 2020-03-26 03:29:45 +08:00
Aleksey Kladov
9f53cec1da Cleanup memory usage stats 2020-03-25 19:35:46 +01:00
Edwin Cheng
07ec31813c fix typo of visibility_of 2020-03-26 00:11:38 +08:00
Edwin Cheng
2adc9a8d5f Remove collect proc_macro definitions 2020-03-25 20:14:22 +08:00
Edwin Cheng
8afb445357 Rename to CustomDerive 2020-03-25 19:50:12 +08:00
Edwin Cheng
7667aa6033 Refactoring a bit 2020-03-25 19:50:12 +08:00
Edwin Cheng
34dc8d25c1 Add basic custom derive lowering 2020-03-25 19:50:12 +08:00
Edwin Cheng
bcfb3700ce Add ItemScope::visibility_of 2020-03-25 04:45:42 +08:00
bors[bot]
baa11d52f4
Merge #3684
3684: ra_hir_def: fix typo r=edwin0cheng a=Veetaha



Co-authored-by: veetaha <veetaha2@gmail.com>
2020-03-22 19:59:05 +00:00
veetaha
dc1fbef985 ra_hir_def: fix typo 2020-03-22 19:38:55 +02:00
Edwin Cheng
bb22a4e386 Add support for macro in symbo_index 2020-03-22 15:00:44 +08:00
Edwin Cheng
92cc6c9816 Add recursive limit in expression macro expansion 2020-03-21 23:58:47 +08:00
Aleksey Kladov
f840fcb2f5 Simplify Arena to use a generic index 2020-03-19 18:46:30 +01:00
veetaha
4d83961acb ra_hir_def: remove dat fixme 2020-03-18 02:35:49 +02:00
Aleksey Kladov
de7662c852 Check that no file contains trailing ws
rustfmt allows trailing spaces in string literals unfortunately.
2020-03-17 11:42:54 +01:00
Aleksey Kladov
9faea2364d Use dyn Trait for working with databse
It improves compile time in `--release` mode quite a bit, it doesn't
really slow things down and, conceptually, it seems closer to what we
want the physical architecture to look like (we don't want to
monomorphise EVERYTHING in a single leaf crate).
2020-03-16 17:42:30 +01:00
Kirill Bulatov
92fd430dab Use Display instead of a custom method 2020-03-16 12:03:43 +02:00
Kirill Bulatov
059ed25a3e Fix crate display name dashes 2020-03-16 11:47:52 +02:00
bors[bot]
efa72c899d
Merge #3591
3591: Support local macro_rules r=matklad a=edwin0cheng

This PR implement local `macro_rules` in function body, by adding following things:

1. While lowering, add a `MacroDefId` in body's `ItemScope` as a textual legacy macro. 
2. Make `Expander::enter_expand` search with given `ItemScope`.
3. Make `Resolver::resolve_path_as_macro` search with `LocalItemScope`.

Fix #2181

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-15 12:15:09 +00:00
Florian Diebold
0a9ea782eb Fix completion of trait items
Trait items should be public by default.
2020-03-14 20:48:36 +01:00
Edwin Cheng
fe78a14bbb Support local macro_rules 2020-03-14 14:25:51 +08:00
Florian Diebold
89eb9e8002 Protect against infinite macro expansion in def collector
There was a test for this, but it wasn't actually working because the first
recursive expansion failed. (The comma...)

Even with this limit, that test (when fixed) still takes some time to pass
because of the exponential growth of the expansions, so I disabled it and added
a different one without growth.
2020-03-13 14:50:03 +01:00
Josh Mcguigan
7208498d54 fix issue 3444 2020-03-12 17:16:28 -07:00
Edwin Cheng
22f064cca7 Add resolve_extern_path in DB 2020-03-11 01:06:01 +08:00
kjeremy
d1e9f0af04 Updates insta to 0.15.0 and bumps console to 0.10.0 2020-03-09 10:28:30 -04:00
Aleksey Kladov
34b0409298 Print crate name in profil 2020-03-09 11:55:43 +01:00
Aleksey Kladov
254ef1860b Minimize API 2020-03-09 11:16:06 +01:00
Aleksey Kladov
0320ebdd10 Use Index for CrateGraph 2020-03-09 11:11:59 +01:00
bors[bot]
57c27f9139
Merge #3519
3519: Show mod path on hover r=matklad a=SomeoneToIgnore

Closes #1064

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-03-09 09:33:46 +00:00
Kirill Bulatov
e1aa96f2c5 Less abstract CrateData api 2020-03-09 11:26:46 +02:00
Florian Diebold
05e1c7b197 Handle visibility for assoc item path completion as well 2020-03-08 15:15:46 +01:00
Florian Diebold
734e68da4c Handle visibility in method call completion 2020-03-07 23:03:56 +01:00
Aleksey Kladov
9abf0d9659 Normalize waiting queries names 2020-03-07 00:18:04 +01:00
Aleksey Kladov
59f91f2f9b Less confusing profile names 2020-03-06 16:40:38 +01:00
Aleksey Kladov
57da3df99a Explicitly remember desugard pats 2020-03-06 15:17:48 +01:00
Aleksey Kladov
5ffddc4b92 Explicitly remember desugard exprs 2020-03-06 15:11:05 +01:00
Aleksey Kladov
fb5891c433 Source map returns a result
cc #2236
2020-03-06 14:44:44 +01:00
Aleksey Kladov
b96da48809 Add profiling calls 2020-03-05 14:22:31 +01:00
Edwin Cheng
1465cc0c4f Implement concat macro 2020-03-04 01:21:14 +08:00
Aleksey Kladov
62e62d1c23 Reformat? 2020-03-02 14:28:34 +01:00
bors[bot]
ea67e2346e
Merge #3384
3384: fix #2377 super::super::* r=flodiebold a=JoshMcguigan

Thanks @matklad for the detailed explanation on #2377. I believe this fixes it.

One thing I'm not sure about is you said the fix would involve changing `crates/ra_hir_def/src/path/lower/lower.rs`, but I only changed `crates/ra_hir_def/src/path/lower/lower_use.rs`. I'm not sure what kind of test code I'd have to write to expose the issue in `lower.rs`, but I'd be happy to add it if you are able to provide additional guidance. 

closes #2377

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-03-01 13:36:44 +00:00
Josh Mcguigan
0057d1e10d fix completion for super::super:: 2020-02-29 21:04:21 -08:00
Josh Mcguigan
69faf81e0d fix #2377 super::super::* 2020-02-29 19:48:55 -08:00
Aleksey Kladov
a1e1869554 Rename ast::ImplBlock -> ast::ImplDef 2020-02-29 21:33:15 +01:00
Shotaro Yamada
33de107ed9 Remove unused dependencies 2020-02-27 14:04:13 +09:00