Commit Graph

2962 Commits

Author SHA1 Message Date
bors[bot]
b81caed43f Merge #1408
1408: Associated type basics & Deref support r=matklad a=flodiebold

This adds the necessary Chalk integration to handle associated types and uses it to implement support for `Deref` in the `*` operator and autoderef; so e.g. dot completions through an `Arc` work now.

It doesn't yet implement resolution of associated types in paths, though. Also, there's a big FIXME about handling variables in the solution we get from Chalk correctly.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-06-16 12:00:41 +00:00
Florian Diebold
ad3673d8d8 Add test for autoderef infinite recursion 2019-06-16 12:25:04 +02:00
Florian Diebold
96c2b9c41d Simplifications / cleanup from review 2019-06-16 12:25:04 +02:00
bors[bot]
e6fbff3246 Merge #1406
1406: reuse AnalysisHost in batch analysis r=matklad a=matklad

We do some custom setup in `AnalysisHost`, like setting up LRU size. I figure it's a good idea to not duplicate this work in batch analysis, *if* we want to keep batch and non-batch close.

Long-term, I see a value in keeping batch a separate, lighter weight thing. However, because now we use batch to measure performance, keeping them closer makes more sense.

I'd also like to add ability to get completions by using batch analysis, and that will require ra_ide_api as well.

@flodiebold were there some reason why we haven't started with this approach from the start?

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-06-16 08:08:10 +00:00
Muhammad Mominul Huque
91510db6d8
Fall down of failures 2019-06-16 00:48:50 +06:00
Shotaro Yamada
774537fb01 Fix formatting 2019-06-16 01:45:38 +09:00
Florian Diebold
30647cd195 Some more cleanup 2019-06-15 18:36:58 +02:00
Florian Diebold
94a6aff9f8 Check that Deref has the right number of parameters 2019-06-15 18:33:30 +02:00
Florian Diebold
3e78a6e3e0 Somewhat handle variables in the derefed type, and add another test 2019-06-15 18:21:23 +02:00
Florian Diebold
ca5ed2307c Implement * operation using Deref trait 2019-06-15 18:21:23 +02:00
Florian Diebold
9c5e7dd849 Implement autoderef using the Deref trait
- add support for other lang item targets, since we need the Deref lang item
2019-06-15 18:21:23 +02:00
Florian Diebold
49489dc20c Add basic infrastructure for assoc type projection 2019-06-15 18:21:23 +02:00
Florian Diebold
6f946f9656 Add test for Deref 2019-06-15 18:21:23 +02:00
Shotaro Yamada
474a04615c Skip attrs in Literal::token 2019-06-15 23:36:12 +09:00
Aleksey Kladov
b0be4207d0 reuse AnalysisHost in batch analysis 2019-06-15 16:29:23 +03:00
Aleksey Kladov
24703acf26 re-enable backtraces on panic 2019-06-15 12:58:17 +03:00
bors[bot]
257a15b939 Merge #1404
1404: Fight down failures! r=matklad a=mominul

issue #1400 

Now only `ra_tools` crate depends on `failure`, should I also fight those? 😁

Co-authored-by: Muhammad Mominul Huque <mominul2082@gmail.com>
2019-06-15 09:45:55 +00:00
Muhammad Mominul Huque
408e173bb9
Cleanup 2019-06-15 14:04:26 +06:00
Muhammad Mominul Huque
125d6e74f7
Fix a doc test 2019-06-15 13:53:37 +06:00
Muhammad Mominul Huque
ebb40c7f87
cargo format 2019-06-15 13:37:15 +06:00
Muhammad Mominul Huque
f032eeb05f
Get rid of failure: ra_batch ra_cli 2019-06-15 13:24:02 +06:00
Muhammad Mominul Huque
9709bd39ca
Get rid of failure: ra_lsp_server & ra_project_model 2019-06-15 02:42:56 +06:00
bors[bot]
9dbf985df5 Merge #1403
1403: Add alloc -> core dependency r=matklad a=flodiebold

Also a small fix for the ra-emacs-lsp company fix.

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-06-14 19:34:51 +00:00
Muhammad Mominul Huque
a931fb1ef6
Get rid of failure: gen_lsp_server 2019-06-15 01:03:17 +06:00
Florian Diebold
dafa177088 Add alloc -> core dependency 2019-06-13 21:59:50 +02:00
Aleksey Kladov
d32e15cae6 Temp fix for slow onEnter issue
The issue was windows specific -- cancellation caused collection of
bracktraces at some point, and that was slow on windows.

The proper fix here is to make sure that we don't collect bracktraces
unnecessary (which we currently do due to failure), but, as a
temporary fix, let's just not force their collection in the first
place!
2019-06-13 21:29:44 +03:00
Aleksey Kladov
b8cae2cf8f check for cancellation when executing queries
Note that we can't just remove CheckCanceled trait altogether:
sometimes it's useful to check for cancellation while the query is
running! We do this, for example, in the name resolution fixed-point
loop.
2019-06-12 18:47:55 +03:00
bors[bot]
c452d2842c Merge #1393
1393: fix: support existential type r=matklad a=csmoe

Closes https://github.com/rust-analyzer/rust-analyzer/issues/1387
r? @matklad 

Co-authored-by: csmoe <csmoe@msn.com>
2019-06-12 14:46:05 +00:00
csmoe
2ca9f71897 fix: support existential type 2019-06-12 14:32:39 +00:00
bors[bot]
03645c5576 Merge #1382
1382: use salsa's LRU for syntax trees r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-06-12 10:36:47 +00:00
Aleksey Kladov
fed52706de make LRU cache configurable 2019-06-12 13:36:24 +03:00
Aleksey Kladov
15668119de make LRU_CAP configurable for batch db 2019-06-12 13:25:30 +03:00
Aleksey Kladov
fc2658b074 use salsa's LRU for syntax trees 2019-06-12 13:25:30 +03:00
bors[bot]
98020ef2f3 Merge #1394
1394: Fix hover for pat that shadows items r=matklad a=sinkuu

```rust
fn x() {}

fn y() {
    let x = 0i32;
    x; // hover on `x` is expected to be `i32`, but the actual result was `fn x()`
}
```

This was because: if [`res.is_empty()`](656a0fa9f9/crates/ra_ide_api/src/hover.rs (L205)), it fallbacks to "index based approach" and adds `fn x()` to `res`, which makes [`res.extend(type_of)` below](656a0fa9f9/crates/ra_ide_api/src/hover.rs (L260-L266)) not happen.

Co-authored-by: Shotaro Yamada <sinkuu@sinkuu.xyz>
2019-06-11 17:24:28 +00:00
Aleksey Kladov
ff6f6b3a52 move docs under code model 2019-06-11 18:28:51 +03:00
Aleksey Kladov
f6c227babd fix compilation 2019-06-11 18:28:51 +03:00
Aleksey Kladov
14b1f87634 minor formatting 2019-06-11 18:28:51 +03:00
Aleksey Kladov
26753f0e49 remove unneded From(..) impl 2019-06-11 18:28:51 +03:00
Aleksey Kladov
0dcaded439 move source to a seaparate file 2019-06-11 18:28:51 +03:00
Aleksey Kladov
c4512fadb1 remove inherent source impls 2019-06-11 18:28:51 +03:00
Aleksey Kladov
dd63f17027 use Source for module, part 2 2019-06-11 18:28:51 +03:00
Aleksey Kladov
0145d06515 use Source for module, part 1 2019-06-11 18:28:51 +03:00
Aleksey Kladov
178d8e96b5 use Source for StructField 2019-06-11 18:28:51 +03:00
Aleksey Kladov
8b94b429e5 use Source for MacroDef 2019-06-11 18:28:51 +03:00
Aleksey Kladov
a6e339e822 use Source for impl block 2019-06-11 18:28:51 +03:00
Aleksey Kladov
f411c2988d use Source for Trait 2019-06-11 18:28:51 +03:00
Aleksey Kladov
5e6213b516 simplify 2019-06-11 18:28:51 +03:00
Aleksey Kladov
f2ccc54468 use Source for TypeAlias 2019-06-11 18:28:51 +03:00
Aleksey Kladov
647c8f3df8 reduce duplication in hover 2019-06-11 18:28:51 +03:00
Aleksey Kladov
46bc8675ed use Source for statics and consts 2019-06-11 18:28:51 +03:00
Aleksey Kladov
4f94af3c4a use Source for Function 2019-06-11 18:28:51 +03:00
Aleksey Kladov
36865adcb9 Introduce HasSource trait 2019-06-11 18:28:51 +03:00
Aleksey Kladov
2a1fe26b6d use Source more 2019-06-11 18:28:51 +03:00
Aleksey Kladov
91c120ccea introduce Source struct 2019-06-11 18:28:51 +03:00
Shotaro Yamada
acafbd66f8 Fix hover for pat that shadows items 2019-06-11 23:46:33 +09:00
bors[bot]
3f5f9f0560 Merge #1391
1391: rename tools -> ra_tools r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-06-10 22:49:51 +00:00
Aleksey Kladov
10d34532e3 rename tools -> ra_tools
This should help with caching on CI I hope (see .travis.yml
before_cache)
2019-06-11 01:47:37 +03:00
Aleksey Kladov
156b7ee842 use single version of either in hir 2019-06-11 01:26:20 +03:00
Edwin Cheng
656a0fa9f9 Simpliy hover on ast::name 2019-06-11 01:18:32 +08:00
Edwin Cheng
34322ea9a3 Use classify_name_ref in hover 2019-06-11 00:34:43 +08:00
bors[bot]
cbafae6fa8 Merge #1388
1388: Remove NavigationTarget::node and fill docs and description in during construction r=matklad a=edwin0cheng

Related dissused:

 https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/MBE.20discussion/near/167105559

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-06-09 19:45:35 +00:00
Edwin Cheng
60938ff73e Remove incorrect FIXME 2019-06-10 03:41:21 +08:00
Edwin Cheng
9ded8d2eab Formating 2019-06-10 03:39:42 +08:00
Edwin Cheng
e91bf0bba4 Use &str instread of Option<String> 2019-06-10 03:37:34 +08:00
Edwin Cheng
fc70275fed Rename "string" to "buf" 2019-06-10 03:30:03 +08:00
Edwin Cheng
41cb3fd758 Rename Description to ShortLabel 2019-06-10 03:28:53 +08:00
Edwin Cheng
358ad0efca Make description_from_symbol depends on symbol 2019-06-10 00:20:49 +08:00
Edwin Cheng
4db0f0ccaf Rename description funcs 2019-06-10 00:09:19 +08:00
Edwin Cheng
e9848b2e6c Change docs and description to getter method 2019-06-10 00:04:03 +08:00
Edwin Cheng
aacc894134 Add display::Description 2019-06-09 23:59:59 +08:00
Edwin Cheng
2acf1e16fc Construct doc individually 2019-06-09 03:27:01 +08:00
Aleksey Kladov
caefa6982b remove some hacks from nameresolution for macros 2019-06-08 20:42:02 +03:00
Aleksey Kladov
780e1a365b somewhat better name 2019-06-08 18:38:14 +03:00
Edwin Cheng
d46278d320 Remove node function in NavTarget 2019-06-08 22:27:11 +08:00
Aleksey Kladov
ac64967872 add a fixme 2019-06-08 14:55:25 +03:00
Aleksey Kladov
1b783e33e9 one macro def should be enough 2019-06-08 14:48:56 +03:00
Aleksey Kladov
2c28f5245d make documenation a query 2019-06-08 14:36:39 +03:00
Aleksey Kladov
33026c654e make Docs handing more ideomatic 2019-06-08 14:16:05 +03:00
Aleksey Kladov
5dc2789895 Move docs to dedicated module 2019-06-08 13:53:14 +03:00
csmoe
205a8278a9 fix: never type with binding
Change-Id: I14e1bc628b9d2dfdb1f40de3d3707f4e872767f2
2019-06-07 19:49:49 +08:00
bors[bot]
8ba5617613 Merge #1377
1377: Use inline snapshots in complete_keyword r=matklad a=sbihel

Relates to #1127

Co-authored-by: Simon Bihel <simon.bihel@ens-rennes.fr>
2019-06-06 13:10:46 +00:00
Andrey Tkachenko
505b8d873f [#1083] Try block syntax: fix tests 2019-06-06 16:26:54 +04:00
Andrey Tkachenko
281c9eeaff [#1083] Try block syntax 2019-06-06 15:43:26 +04:00
csmoe
44363cd5d2 fix: clean up warnings
Change-Id: I91a468f6e846ac28574825b8ee7aa02fbff68f63
2019-06-06 10:06:46 +08:00
bors[bot]
5deb907b43 Merge #1374
1374: Implement `cargo lint` and fix some clippy errors r=alanhdu a=alanhdu

This creates a `cargo lint` command that runs clippy with certain lints disabled. I've also gone ahead and fixed some of the lint errors, although there are many more still to go.

cc #848 

Co-authored-by: Alan Du <alanhdu@gmail.com>
2019-06-04 22:14:46 +00:00
Alan Du
aa30c4909e Allow clippy::redundant_pattern_matching 2019-06-04 18:05:38 -04:00
Alan Du
02b6f871f1 Fix clippy::iter_cloned_collect 2019-06-04 18:05:07 -04:00
Alan Du
9b54b06ee3 Fix clippy::option_map_or_none 2019-06-04 18:05:07 -04:00
Alan Du
964edd9943 Fix clippy::while_let_loop 2019-06-04 18:05:07 -04:00
Alan Du
b28ca32db2 Fix clippy::or_fun_call 2019-06-04 18:05:07 -04:00
Alan Du
40424d4222 Fix clippy::identity_conversion 2019-06-04 18:05:07 -04:00
Alan Du
ed3d93b875 Fix clippy::single_char_pattern 2019-06-04 18:05:07 -04:00
Alan Du
682bf04bf4 Fix clippy::new_without_default 2019-06-04 18:05:07 -04:00
Alan Du
6939011b27 Fix clippy::assign_op_pattern 2019-06-04 18:05:07 -04:00
Alan Du
21d7964bc3 Fix clippy::useless_format 2019-06-04 18:05:07 -04:00
Alan Du
fb592d76aa Fix clippy::into_iter_on_ref 2019-06-04 18:05:07 -04:00
Alan Du
619a615298 Fix clippy::len_zero 2019-06-04 18:05:07 -04:00
Alan Du
7bcd8d6290 Fix clippy::unused_mut 2019-06-04 18:05:07 -04:00
Alan Du
6095e3fe19 Fix clippy::unnecessary_mut_passed 2019-06-04 18:05:07 -04:00
Alan Du
fafca4cb11 Fix clippy::ptr_arg 2019-06-04 18:05:07 -04:00
Alan Du
4e449fb0b0 Fix clippy::if_same_then_else 2019-06-04 18:05:07 -04:00
Alan Du
63e37f9536 Fix clippy::expect_fun_call 2019-06-04 18:05:07 -04:00
Alan Du
b9af1d7c42 Fix clippy::match_ref_pats 2019-06-04 18:05:07 -04:00
Alan Du
dddcb0ad94 Fix clippy::needless_return 2019-06-04 18:05:07 -04:00
Alan Du
ecd420636e Fix clippy::single_match 2019-06-04 18:05:07 -04:00
Simon Bihel
ec31f475ca
Use inline snapshots in complete_keyword 2019-06-04 21:26:12 +01:00
Aleksey Kladov
d2b23599b6 fix debug scopes 2019-06-04 14:46:22 +03:00
Alan Du
354db651da Fix clippy::clone_double_ref 2019-06-04 03:00:58 -04:00
Alan Du
573a6bb5c9 Fix clippy::match_bool 2019-06-04 03:00:58 -04:00
Alan Du
07ebf5528e Allow clippy::map_clone
We should turn it on after Iterator::copied stabilizes
2019-06-04 03:00:58 -04:00
Alan Du
557e90c6ca Allow clippy::needless_pass_by_value 2019-06-04 03:00:58 -04:00
Alan Du
a181fd318b Implement cargo lint to run clippy 2019-06-03 20:34:00 -04:00
Aleksey Kladov
5264711b5d add couple of debug utils 2019-06-04 00:27:49 +03:00
bors[bot]
6aa8d8b99d Merge #1369
1369: don't cache parses twice r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-06-02 17:21:42 +00:00
Aleksey Kladov
8b7f58976b don't cache parses twice
Before this commit, `Parse`s for original file ended up two times in
salsa's db: first, when we parse original file, and second, when we
parse macro or a file.

Given that parse trees are the worst ofenders in terms of memory, it
makes sense to make sure we store them only once.
2019-06-02 20:15:10 +03:00
bors[bot]
ae8fd982c0 Merge #1368
1368: Store referece instead of full token tree in tokenbuffer r=matklad a=edwin0cheng

This PR try to minimize the memory allocation in converting `SyntaxNode` to `TokenTree` by using reference isnteead of full token tree in `TokenBuffer`. 

Note that the final goal is replace `TokenTree` with TokenBuffer such that there is no conversion between them.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-06-02 17:09:49 +00:00
Edwin Cheng
824f413d75 unnecessary paranthesis 2019-06-03 01:05:58 +08:00
Edwin Cheng
54ea251bd4 Store referece in tokenbuffer 2019-06-03 00:54:33 +08:00
Aleksey Kladov
2f02e1a8ba collect macro queries 2019-06-02 18:58:49 +03:00
Aleksey Kladov
5af9e475f4 add AstDatabase 2019-06-02 12:27:36 +03:00
Aleksey Kladov
011599df27 collect types and bodies 2019-06-01 22:47:20 +03:00
Aleksey Kladov
f7d3a87305 collect impl source maps 2019-06-01 22:31:22 +03:00
Aleksey Kladov
d7a2a9171e don't cache ast_id_to_node 2019-06-01 22:14:42 +03:00
Aleksey Kladov
37e80c5297 show macro expanded trees in the stats as well 2019-06-01 22:13:24 +03:00
bors[bot]
ccec71165b Merge #1360
1360: Improve goto definition for MBE r=matklad a=edwin0cheng

This PR improve the macro resolution for goto definition and expression macro invocation by using proper path resolution for external macros. 



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-06-01 17:48:06 +00:00
Edwin Cheng
371961be0e Improve goto definition for MBE 2019-06-01 19:34:19 +08:00
bors[bot]
1e6b45b05a Merge #1359
1359: don't poison mutex around chalk r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-06-01 08:00:00 +00:00
Aleksey Kladov
f89d34be6a don't poison mutex around chalk
We use panics for cancellation, so we could trigger panic while
holding the solver. std::sync::Mutex will be poisoned as a result,
which and all further attempts to use solver (from other threads) will
panic as well.

This commit switches to parking_lot::Mutex which just unlocks on panic.
2019-06-01 10:57:44 +03:00
Aleksey Kladov
4dd7faed34 apply profile filter to top-level entries only 2019-06-01 10:41:47 +03:00
Aleksey Kladov
bf801953a3 rename 2019-06-01 10:31:40 +03:00
Aleksey Kladov
678a458543 move subs inside 2019-06-01 10:24:43 +03:00
Aleksey Kladov
78e17f65cf use sync queries for join lines and friends 2019-05-31 20:53:00 +03:00
Aleksey Kladov
c6537c3280 add sync requests 2019-05-31 20:50:16 +03:00
Aleksey Kladov
9697d8afad cleanup 2019-05-31 20:42:53 +03:00
Aleksey Kladov
15efd58274 cleanup 2019-05-31 20:30:14 +03:00
Aleksey Kladov
2d773a46c9 simplify 2019-05-31 20:23:56 +03:00
Aleksey Kladov
e1bda6aeda move completed requests to a separate file 2019-05-31 20:14:54 +03:00
Aleksey Kladov
838915c9a2 simplify 2019-05-31 19:24:33 +03:00
Aleksey Kladov
8bb02859e8 introduce constant 2019-05-31 19:20:22 +03:00
Aleksey Kladov
0e542936be minor 2019-05-31 19:17:46 +03:00
Laurențiu Nicola
be15541b03 Sort hover results in tests 2019-05-30 21:20:17 +03:00
Aleksey Kladov
b6a854e161 update ra_ide_api to use builtins 2019-05-30 16:10:07 +03:00
Aleksey Kladov
c6ee9d681c add tests for primitive types 2019-05-30 15:14:11 +03:00
Aleksey Kladov
97158f5c8a add built-in types to scopes 2019-05-30 15:03:58 +03:00
Aleksey Kladov
4e5b02966b add list of builtin types 2019-05-30 14:26:27 +03:00
Aleksey Kladov
e6545cc647 add ModuleDef::BuiltInType 2019-05-30 14:06:28 +03:00
Aleksey Kladov
54f77ad68d switch to upstream salsa 2019-05-30 13:05:09 +03:00
Aleksey Kladov
18ed351747 ⬆️ parking_lot 2019-05-30 12:02:30 +03:00
Aleksey Kladov
0ee5bd16c9 cancel salsa's validation
This small fix should improve rust-analyzer resopnsivness for
real-time operations like onEnter handling.

Turns out, salsa's validation can take hundreds of milliseconds, and,
in case no changes were made, it won't be triggering any queries.

Because we check for cancellation in queries, that means that
validation is not cancellable!

What this PR does is injecting check_canceled checks into validation,
by using salsa's event API, which wasn't meant to be used like this,
but, hey, it works!

Here's the onEnter handling before and after this change:

https://youtu.be/7-ffPzgvH7o
2019-05-30 10:06:02 +03:00
bors[bot]
8c3cd8f121 Merge #1346
1346: bump timeout for CI r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-29 19:18:57 +00:00