Commit graph

2892 commits

Author SHA1 Message Date
Ekaterina Babshukova 46c453d0d3 show macros in file structure 2019-06-29 00:08:02 +03:00
bors[bot] 5d829841cd Merge #1440
1440: fixed #1384 r=matklad a=zbelial

This PR fixed #1384 .

Co-authored-by: zjy <zhaojiyang1@xiaomi.com>
2019-06-28 12:14:19 +00:00
zjy de930237ff fixed #1384 2019-06-28 15:22:17 +08:00
Ryan Cumming e052ca9d61 Swallow expected rustfmt errors
My workflow in Visual Studio Code + Rust Analyzer has become:

1. Make a change to Rust source code using all the analysis magic

2. Save the file to trigger `cargo watch`. I have format on save enabled
   for all file types so this also runs `rustfmt`

3. Fix any diagnostics that `cargo watch` finds

Unfortunately if the Rust source has any syntax errors the act of saving
will pop up a scary "command has failed" message and will switch to the
"Output" tab to show the `rustfmt` error and exit code.

I did a quick survey of what other Language Servers do in this case.
Both the JSON and TypeScript servers will swallow the error and return
success. This is consistent with how I remember my workflow in those
languages. The syntax error will show up as a diagnostic so it should
be clear why the file isn't formatting.

I checked the `rustfmt` source code and while it does distinguish "parse
errors" from "operational errors" internally they both result in exit
status of 1. However, more catastrophic errors (missing `rustfmt`,
SIGSEGV, etc) will return 127+ error codes which we can distinguish from
a normal failure.

This changes our handler to log an info message and feign success if
`rustfmt` exits with status 1.

Another option I considered was only swallowing the error if the
formatting request came from format-on-save. However, the Language
Server Protocol doesn't seem to distinguish those cases.
2019-06-27 08:08:26 +10:00
Aleksey Kladov 6e2369938a make sure that CrateDefMap is independent from syntax 2019-06-26 21:50:42 +03:00
bors[bot] 203d5dd0d0 Merge #1443
1443: cache chalk queries r=flodiebold a=matklad

This gives a significant speedup, because chalk will call these
functions several times even withing a single revision. The only
significant one here is `impl_data`, but I figured it might be good to
cache others just for consistency.

The results I get are:

Before:

from scratch:   16.081457952s
no change:      15.846493ms
trivial change: 352.95592ms
comment change: 361.998408ms
const change:   457.629212ms

After:

from scratch:   14.910610278s
no change:      14.934647ms
trivial change: 85.633023ms
comment change: 96.433023ms
const change:   171.543296ms

Seems like a nice win!

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-06-26 16:35:22 +00:00
Aleksey Kladov fa55b72c54 move ra_prof dep where it belongs 2019-06-26 13:07:26 +03:00
Aleksey Kladov a198d78bd1 cache chalk queries
This gives a significant speedup, because chalk will call these
functions several times even withing a single revision. The only
significant one here is `impl_data`, but I figured it might be good to
cache others just for consistency.

The results I get are:

Before:

from scratch:   16.081457952s
no change:      15.846493ms
trivial change: 352.95592ms
comment change: 361.998408ms
const change:   457.629212ms

After:

from scratch:   14.910610278s
no change:      14.934647ms
trivial change: 85.633023ms
comment change: 96.433023ms
const change:   171.543296ms

Seems like a nice win!
2019-06-26 12:54:13 +03:00
Aleksey Kladov d621533f15 add cpuprofile to ra_prof
Now, one can use `let _p = ra_prof::cpu_profiler()` to capture profile
of a block of code.

This is not an out of the box experience, as that relies on gperfools

See the docs on https://github.com/AtheMathmo/cpuprofiler for more!
2019-06-26 11:11:28 +03:00
bors[bot] 0129790a8f Merge #1432
1432: Make fill_match_arm work with trivial arm r=matklad a=ironyman

Addresses this issue https://github.com/rust-analyzer/rust-analyzer/issues/1399

One minor issue I noticed is that complete_postfix creates an arm like this

```
                match E::X {
                    <|>_ => {},
                }
```

but fill_match_arms creates arms like this
```
                     E::X => (), 
```

Co-authored-by: ironyman <ironyman@users.noreply.github.com>
Co-authored-by: Changyu Li <changyl@microsoft.com>
2019-06-25 21:06:17 +00:00
Changyu Li 3a2a13756f Review 1 2019-06-25 13:26:12 -07:00
Shotaro Yamada 9668737d05 Add comment 2019-06-25 20:57:42 +09:00
Shotaro Yamada 9e7a6bd66e Method resolution for slices 2019-06-25 02:17:44 +09:00
bors[bot] f6340022c1 Merge #1429
1429: Add box postfix completion r=matklad a=kanru



Co-authored-by: Kan-Ru Chen <kanru@kanru.info>
2019-06-24 10:21:36 +00:00
bors[bot] 67ecc88f66 Merge #1415
1415: fix: specialization r=matklad a=csmoe

Closes #1402 
r? @matklad 

Co-authored-by: csmoe <csmoe@msn.com>
2019-06-24 10:10:05 +00:00
Aleksey Kladov 8109ebb101 Add SourceRoot::is_library, in preparation for salsa's durability 2019-06-24 12:35:07 +03:00
ironyman 888157b52e fill_match_arm works with trivial arm 2019-06-23 21:05:50 -07:00
Kan-Ru Chen bf7a35294d Add box postfix completion 2019-06-23 22:18:25 +09:00
kjeremy f8f136e990 Bump cargo_metadata, ena, flexi_logger 2019-06-20 15:09:39 -04:00
Aleksey Kladov 9ff872329a don' collect macros 2019-06-20 16:48:10 +03:00
bors[bot] cd1ff2e2a1 Merge #1419
1419: Add firewall query to lang items r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-06-19 22:14:12 +00:00
Aleksey Kladov bcff61257a Add firewall query to lang items
With an intermediate query, changing one module won't cause reparsing
of all modules
2019-06-19 23:46:50 +03:00
csmoe d04473accb fix: specialization(with blindly parsing)
Change-Id: Ic5d2767e8781568d76d4d0013cd6081e95ae8a95
2019-06-19 18:37:38 +08:00
bors[bot] 363f2f394e Merge #1414
1414: fix: box_syntax/pattern r=matklad a=csmoe

Closes #1412 
r? @matklad 

Co-authored-by: csmoe <csmoe@msn.com>
2019-06-19 10:07:37 +00:00
csmoe d6533994e4 fix: box_pattern
Change-Id: I45a856d74fb616d3bce33050f9e69d327186bd59
2019-06-19 14:28:50 +08:00
Aleksey Kladov 0caec7d250 rename XSignature -> XData 2019-06-18 20:20:08 +03:00
csmoe 5999733ca6 fix: box_syntax(#1412)
Change-Id: I6e20e0163fa545de37226c1561b3b7103615626c
2019-06-18 21:46:47 +08:00
bors[bot] 1541b2d689 Merge #1409
1409: The Fall down of failures r=matklad a=mominul

😁
Replaced all the uses of `failure` crate with `std::error::Error`.

Closes #1400 
Depends on rust-analyzer/teraron#1

Co-authored-by: Muhammad Mominul Huque <mominul2082@gmail.com>
2019-06-16 19:58:33 +00:00
Muhammad Mominul Huque d3e74bfd2c
Update teraron version 2019-06-17 00:07:31 +06:00
Aleksey Kladov 6314e62cfb add analysis-bench to benchmark incremental analysis
Can be used like this:

```
$ cargo run --release -p ra_cli -- \
  analysis-bench ../chalk/ \
  --complete ../chalk/chalk-engine/src/logic.rs:94:0

loading: 225.970093ms

from scratch:   8.492373325s
no change:      445.265µs
trivial change: 95.631242ms
```

Or like this:

```
$ cargo run --release -p ra_cli -- \
  analysis-bench ../chalk/ \
  --highlight ../chalk/chalk-engine/src/logic.rs

loading: 209.873484ms

from scratch:   9.504916942s
no change:      7.731119ms
trivial change: 124.984039ms
```

"from scratch" includes initial analysis of the relevant bits of the
project

"no change" just asks the same question for the second time. It
measures overhead on assembling the answer outside of salsa.

"trivial change" doesn't do an actual salsa change, it just advances
the revision. This test how fast is salsa at validating things.
2019-06-16 19:45:05 +03:00
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