Commit graph

4654 commits

Author SHA1 Message Date
bors[bot]
7c1af25b22
Merge #2795
2795: Use dummy value for macro file in bulitin macros r=matklad a=edwin0cheng

This PR skip the actual line and column computation for `MacroFile` and return a dummy value instead.

Related to #2794



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-01-11 20:13:48 +00:00
Edwin Cheng
9f65ae20c2 Use dummy value for macro file in bulitin macros 2020-01-11 16:37:42 +08:00
bors[bot]
991b62a4f9
Merge #2790
2790: Add test for macro expansion in various expressions r=edwin0cheng a=flodiebold

cc @edwin0cheng 

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-01-11 03:51:04 +00:00
Emil Lauridsen
d6da18e99d Address nit 2020-01-10 22:41:52 +01:00
Emil Lauridsen
1d1eea217d Slightly more robust cargo watcher root search 2020-01-10 22:10:26 +01:00
Florian Diebold
dd6ec81d65 Add test for macro expansion in various expressions 2020-01-10 22:08:02 +01:00
kjeremy
a633a6275a Fix Write being sent down the wire.
Not sure what the deal is here but it wasn't sending Write.
2020-01-10 15:30:17 -05:00
kjeremy
32540abcb3 Add AccessMode to decls 2020-01-10 15:14:19 -05:00
kjeremy
49fd6a5228 Split Declaration out into it's own type 2020-01-10 15:14:19 -05:00
kjeremy
cc96ddfe69 Simplify and update tests to account for access 2020-01-10 15:14:19 -05:00
Jeremy Kolb
6c89d86ade Tweaks 2020-01-10 15:14:19 -05:00
Jeremy Kolb
d993f329a0 Basic DocumentHighlightKind support for assignments 2020-01-10 15:14:19 -05:00
Edwin Cheng
dca9195f75 Add missing expr cases for expand macro 2020-01-11 03:11:23 +08:00
bors[bot]
029c02982b
Merge #2786
2786: Proper handling local in hover r=flodiebold a=edwin0cheng

This PR implement back the `Local` hover information generation, which is fall back to a general case catch previously :

9a44f627be/crates/ra_ide/src/hover.rs (L173-L182)



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-01-10 17:58:14 +00:00
Edwin Cheng
19094abd41 Proper handling local in hover 2020-01-11 01:51:08 +08:00
bors[bot]
9a44f627be
Merge #2785
2785: Expand PAREN_EXPR as expression r=matklad a=edwin0cheng



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-01-10 16:31:02 +00:00
Edwin Cheng
ca62d98781 Expand PAREN_EXPR as expression 2020-01-11 00:29:00 +08:00
Emil Lauridsen
aa433c67d8 Parse trait aliases 2020-01-09 18:40:01 +01:00
bors[bot]
c2bbfb9a5f
Merge #2778
2778: ⬆️ rowan r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-09 15:33:37 +00:00
Aleksey Kladov
47785b0cd4 ⬆️ rowan 2020-01-09 16:33:02 +01:00
Aleksey Kladov
cf5bdf464c
Merge pull request #2732 from detrumi/cargo-toml-not-found-message-toggle
Flag to hide cargo.toml not found error
2020-01-09 15:16:39 +01:00
bors[bot]
3263c70766
Merge #2772
2772: Actually test references r=kjeremy a=kjeremy

This will be a little more work when `ReferenceSearchResults` change but I think it's easier to maintain in the end. It also follows a similar pattern to navigation targets and call hierarchy.

Co-authored-by: kjeremy <kjeremy@gmail.com>
Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-01-09 12:26:59 +00:00
Jeremy Kolb
6fc80efe77 visibility tweak 2020-01-09 07:26:04 -05:00
bors[bot]
0d6e5a986c
Merge #2771
2771: Remove the Default impl for SourceRoot r=matklad a=michalt

Let's be always explicit whether we create a library (i.e., an immutable
dependency) or a local `SourceRoot`, since it can have a large impact on
the validation performance in salsa. (we found it the hard way recently,
where the `Default` instance made it quite tricky to spot a bug)

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>

Co-authored-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-09 10:35:17 +00:00
bors[bot]
5ced6f4be3
Merge #2777
2777: Better error message r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-09 10:26:22 +00:00
Aleksey Kladov
4223760a7b Better error message
closes #2775
2020-01-09 11:25:44 +01:00
kjeremy
9791b9c36a Actually test references 2020-01-08 16:35:58 -05:00
Michal Terepeta
d761435ba0 Remove the Default impl for SourceRoot
Let's be always explicit whether we create a library (i.e., an immutable
dependency) or a local `SourceRoot`, since it can have a large impact on
the validation performance in salsa. (we found it the hard way recently,
where the `Default` instance made it quite tricky to spot a bug)

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-08 19:42:27 +01:00
kjeremy
c7b2bc1363 Move private API down 2020-01-08 11:33:04 -05:00
Wilco Kusee
11caebe6ce
Remove unneeded Box::new
Co-Authored-By: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-08 17:22:08 +01:00
Wilco Kusee
738d5a7ec2
Derive debug 2020-01-08 17:21:19 +01:00
Jeremy Kolb
1b19a8aa5e Implement proposed CallHierarchy feature
See: https://github.com/microsoft/vscode-languageserver-node/blob/master/protocol/src/protocol.callHierarchy.proposed.ts
2020-01-08 10:15:49 -05:00
Mikhail Modin
fb25c91979 Adds a way to limits reference search by StructLiteral 2020-01-08 15:21:54 +01:00
Wilco Kusee
003620f0d6
Use downcasting for CargoTomlNotFoundError 2020-01-08 14:06:08 +01:00
Aleksey Kladov
5d8f2bd822
Merge pull request #2762 from edwin0cheng/fix-2759
Reject tuple index for missing fields assist
2020-01-08 12:49:54 +01:00
Edwin Cheng
a4c9babedb Proper emit diagnostic without fix 2020-01-08 02:18:43 +08:00
Edwin Cheng
e55e6da13a Reject tuple index for missing fields assist 2020-01-08 02:08:17 +08:00
Aleksey Kladov
8317efa191
Merge pull request #2760 from edwin0cheng/fix-descend-into-macros
Use src node for analyze source in `descend_into_macros`
2020-01-07 18:08:43 +01:00
Edwin Cheng
1fdee24608 Use src node for analyze source 2020-01-08 00:23:53 +08:00
Aleksey Kladov
b8ca479a2e
Merge pull request #2756 from matklad/retasks
⬆️ crates
2020-01-07 17:17:31 +01:00
Aleksey Kladov
072f0d323b Fix back compat 2020-01-07 16:45:57 +01:00
Aleksey Kladov
4d66f5d7d2 Fix panic in tuple fields 2020-01-07 14:49:42 +01:00
Michael Chesser
ce1b34fd59 Improve const generics parsing
- Handle const generics type args
- Fix issue with const generic as first parameter in trait impl
2020-01-07 09:29:03 +10:30
Michal Terepeta
be967b94e1 Fix a problem with Durability of libraries
When processing a change with added libraries, we used
`Default::default` for `SourceRoot` which sets `is_library` to false.
Since we use `is_library` to decide whether to use low or high
durability, I believe that this caused us to mark many library
dependencies as having low durability and thus increased the size of the
graph that salsa needed to verify on every change.

Based on my initial tests this speeds up the `CrateDefMapQuery` on
rust-analyzer from about ~64ms to ~14ms and reduces the number of
validations for the query from over 60k to about 7k.

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-06 22:21:56 +01:00
bors[bot]
010d902021
Merge #2726
2726: Improve profiling output when duration filter is specified r=matklad a=michalt

In particular:

  - Use strict inequality for comparisons, since that's what the filter
    syntax supports.

  - Convert to millis for comparisons, since that's the unit used both
    for the filter and when printing.

Now something like `RA_PROFILE='*>0'` will only print things that took
at least 1ms (when rounded to millis).

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>

Co-authored-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-06 09:41:14 +00:00
Jeremy Kolb
5afb22e2b3 BinOp helper to detect assignment 2020-01-04 15:54:31 -05:00
bors[bot]
c15293e019
Merge #2745
2745: remove unused file r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-04 09:58:37 +00:00
Aleksey Kladov
b5e7186265 remove unused file 2020-01-04 10:58:10 +01:00
bors[bot]
823c15215e
Merge #2743
2743: Switch ast declaration from ron to a macro r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-03 20:54:42 +00:00
Aleksey Kladov
084bd304f3 Switch ast declaration from ron to a macro 2020-01-03 21:54:10 +01:00
bors[bot]
cb160f2a34
Merge #2742
2742: Split `infer` query into two for better profiling r=flodiebold a=michalt

This is the same change as we did with `crate_def_map` and it does seem
that we mostly spend time in salsa, without recomputing much on
rust-analyzer side.

Example output:

```
 233ms - handle_inlay_hints
      163ms - get_inlay_hints
          163ms - SourceAnalyzer::new
               67ms - def_with_body_from_child_node
                   67ms - analyze_container
                       67ms - analyze_container
                           67ms - Module::from_definition
                               67ms - Module::from_file
                                   67ms - crate_def_map
                                        0ms - parse_macro_query (6 calls)
                                        0ms - raw_items_query (1 calls)
                                       66ms - ???
                            0ms - crate_def_map (1 calls)
                        0ms - crate_def_map (1 calls)
               96ms - infer
                    2ms - trait_solve_query (2 calls)
                   94ms - ???
                0ms - body_with_source_map_query (1 calls)
                0ms - crate_def_map (1 calls)
      [...]
```

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>

Co-authored-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-03 19:08:32 +00:00
Michal Terepeta
d6c2a59538 Split infer query into two for better profiling
This is the same change as we did with `crate_def_map` and it does seem
that we mostly spend time in salsa, without recomputing much on
rust-analyzer side.

Example output:

```
 233ms - handle_inlay_hints
      163ms - get_inlay_hints
          163ms - SourceAnalyzer::new
               67ms - def_with_body_from_child_node
                   67ms - analyze_container
                       67ms - analyze_container
                           67ms - Module::from_definition
                               67ms - Module::from_file
                                   67ms - crate_def_map
                                        0ms - parse_macro_query (6 calls)
                                        0ms - raw_items_query (1 calls)
                                       66ms - ???
                            0ms - crate_def_map (1 calls)
                        0ms - crate_def_map (1 calls)
               96ms - infer
                    2ms - trait_solve_query (2 calls)
                   94ms - ???
                0ms - body_with_source_map_query (1 calls)
                0ms - crate_def_map (1 calls)
      [...]
```

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-03 19:58:11 +01:00
Edwin Cheng
ff5883637c Fix unused import for windows in cargo_watch test 2020-01-04 01:18:46 +08:00
Wilco Kusee
e7bb82c3a4
Allow disabling Cargo.toml not found error 2020-01-03 15:04:54 +01:00
Florian Diebold
67240c8d91 Fix #2705
The `-` turned into a `+` during a refactoring.

The original issue was caused by `Read` resolving wrongly to a trait without
type parameters instead of a struct with one parameter; this only fixes the
crash, not the wrong resolution.
2020-01-03 14:57:11 +01:00
Wilco Kusee
6c321d7318
Move error to new file 2020-01-03 14:34:16 +01:00
Michal Terepeta
2e2e443560 Add _query suffix to compute_crate_def_map for consistency
Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-03 14:20:24 +01:00
Wilco Kusee
2202891221
Split errors into WorkspaceError enum 2020-01-03 14:04:46 +01:00
Michal Terepeta
7cd6f12926 Split crate_def_map into two methods
This change:

  - introduces `compute_crate_def_map` query and renames
    `CrateDefMap::crate_def_map_query` for consistency,

  - annotates `crate_def_map` as `salsa::transparent` and adds a
    top-level `crate_def_map` wrapper function around that starts the
    profiler and immediately calls into `compute_crate_def_map` query.

This allows us to better understand where we spent the time, in
particular, how much is spent in the recomputaiton and how much in
salsa.

Example output (where we don't actually re-compute anything, but the
query still takes a non-trivial amount of time):

```
  211ms - handle_inlay_hints
      150ms - get_inlay_hints
          150ms - SourceAnalyzer::new
               65ms - def_with_body_from_child_node
                   65ms - analyze_container
                       65ms - analyze_container
                           65ms - Module::from_definition
                               65ms - Module::from_file
                                   65ms - crate_def_map
                                        1ms - parse_macro_query (6 calls)
                                        0ms - raw_items_query (1 calls)
                                       64ms - ???
```

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-03 13:59:46 +01:00
bors[bot]
e423cfe383
Merge #2730
2730: Add `profile` calls to {Module,Function}::diagnostics r=matklad a=michalt

With this change the output `ra_prof` gives a better indication where
the time is spent. Example output:

```
  213ms - publish_diagnostics
      213ms - diagnostics
           70ms - Module::from_definition
               70ms - Module::from_file
          132ms - Module::diagnostics
               78ms - Function::diagnostics
                    0ms - body_with_source_map_query (1 calls)
                    2ms - trait_solve_query (1 calls)
                   76ms - ???
               15ms - Function::diagnostics
                    0ms - body_with_source_map_query (1 calls)
                   15ms - trait_solve_query (5 calls)
               38ms - Function::diagnostics (51 calls)
            8ms - parse_query (1 calls)
 ```

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>

Co-authored-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-03 11:57:11 +00:00
Michal Terepeta
100c2d0127 Add profile calls to {Module,Function}::diagnostics
With this change the output `ra_prof` gives a better indication where
the time is spent. Example output:

```
  213ms - publish_diagnostics
      213ms - diagnostics
           70ms - Module::from_definition
               70ms - Module::from_file
          132ms - Module::diagnostics
               78ms - Function::diagnostics
                    0ms - body_with_source_map_query (1 calls)
                    2ms - trait_solve_query (1 calls)
                   76ms - ???
               15ms - Function::diagnostics
                    0ms - body_with_source_map_query (1 calls)
                   15ms - trait_solve_query (5 calls)
               38ms - Function::diagnostics (51 calls)
            8ms - parse_query (1 calls)
 ```

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-03 12:50:35 +01:00
Michal Terepeta
84e2e173ee Remove a duplicate line in collect_defs
Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-03 12:40:50 +01:00
Michal Terepeta
bc91120b7c Improve profiling output when duration filter is specified
In particular:

  - Use strict inequality for comparisons, since that's what the filter
    syntax supports.

  - Convert to millis for comparisons, since that's the unit used both
    for the filter and when printing.

Now something like `RA_PROFILE='*>0'` will only print things that took
at least 1ms (when rounded to millis).

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-02 17:26:02 +01:00
Jeremy Kolb
35d72e40e2 Update dependencies 2020-01-01 17:51:48 -05:00
Emil Lauridsen
167cbb7c4d Disable cargo_watch snapshot tests on windows 2020-01-01 23:21:35 +01:00
Aleksey Kladov
c3a86325da
Merge pull request #2672 from Speedy37/master
fix #2520: change expand_repeat loop stop condition
2019-12-31 20:57:26 +01:00
Aleksey Kladov
26bd7a896b Drop support for legacy colorization 2019-12-31 14:11:25 +01:00
Aleksey Kladov
23bac12062 Retry inlay hints on content modified error 2019-12-30 22:20:04 +01:00
Vincent Rouillé
dc98930965
Add details about test_repeat_bad_var current state 2019-12-30 17:12:20 +01:00
Vincent Rouillé
c670a15345
Details about macro NestingState hit and at_end fields 2019-12-30 17:09:07 +01:00
bors[bot]
be37c3369b
Merge #2681
2681: cargo-watcher: Resolve macro call site in more cases r=matklad a=kiljacken

This resolves the actual macro call site in a few more cases, f.x. when a macro invokes `compile_error!` (I'm looking at you `ra_hir_def::path::__path`).

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2019-12-29 21:40:42 +00:00
Emil Lauridsen
bca8524fa2 Add related information with original error site 2019-12-29 20:10:20 +01:00
Emil Lauridsen
96156b95b5 Resolve macro call site in more cases 2019-12-29 19:14:18 +01:00
bors[bot]
fc77921acc
Merge #2680
2680: Fix cargo-watcher file urls on windows r=matklad a=kiljacken

Fixes #2676 

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2019-12-29 17:53:13 +00:00
Emil Lauridsen
0d69d23d2f Lowercase drive letters when getting paths from cargo check 2019-12-29 18:27:14 +01:00
Emil Lauridsen
8280795a85 Remove unused hard-coded paths 2019-12-29 17:39:44 +01:00
Emil Lauridsen
8fad8e897a Resolve traits in infer using lang item infrastructure 2019-12-29 17:39:31 +01:00
Emil Lauridsen
fc3ab03af7 Add helpers for unpacking lang items 2019-12-29 17:38:37 +01:00
bors[bot]
523b4cbc60
Merge #2650
2650: Add macro call support for SourceAnalyzer::type_of r=matklad a=edwin0cheng



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-12-29 15:02:27 +00:00
bors[bot]
ada9e16537
Merge #2674
2674: Reduce visibility r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-12-29 14:08:37 +00:00
Aleksey Kladov
e1d040a6a4 Reduce visibility 2019-12-29 15:07:53 +01:00
Aleksey Kladov
8f36f768e1 Don't add non-impl/trait containers to scope 2019-12-29 14:47:47 +01:00
bors[bot]
dc48f89581
Merge #2668
2668: In-server cargo check watching r=matklad a=kiljacken

Opening a draft now so people can follow the progress, and comment if they spot something stupid.

Things that need doing:
- [x] Running cargo check on save
- [x] Pipe through configuration options from client
- [x] Tests for parsing behavior
- [x] Remove existing cargo watch support from VSCode extension
- [x] Progress notification in VSCode extension using LSP 3.15 `$/progress` notification
- [ ] ~~Rework ra-ide diagnostics to support secondary messages~~
- [ ] ~~Make cargo-check watcher use ra-ide diagnostics~~

~~I'd love some input on whether to try to keep the status bar progress thingy for VSCode? It will require some plumbing, and maintaining yet another rust-analyzer specific LSP notification, which I'm not sure we want to.~~

Fixes #1894 

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2019-12-29 12:57:24 +00:00
bors[bot]
cdcb3d3833
Merge #2667
2667: Visibility r=matklad a=flodiebold

This adds the infrastructure for handling visibility (for fields and methods, not in name resolution) in the HIR and code model, and as a first application hides struct fields from completions if they're not visible from the current module. (We might want to relax this again later, but I think it's ok for now?)

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-12-29 12:24:19 +00:00
Vincent Rouillé
6d84dee4e7
fix #2520: change expand_repeat loop stop condition 2019-12-28 22:48:49 +01:00
Emil Lauridsen
899dbebd02 Fix busy-waiting issue in main cargo watch thread 2019-12-27 17:29:02 +01:00
Emil Lauridsen
c732f215cb Don't finish main cargo watch thread when subprocess finishes. 2019-12-27 12:43:14 +01:00
Emil Lauridsen
ed84c85aef Fix shutdown behavoir of main cargo-watch thread.
Even though this didn't error, it became clear to me that it was closing
the wrong channel, resulting in the child thread never finishing.
2019-12-27 12:42:18 +01:00
Emil Lauridsen
59837c75f4 Add doc comment to module 2019-12-27 11:57:00 +01:00
Emil Lauridsen
4d33835a34 Cargo fmt run 2019-12-27 11:47:09 +01:00
Emil Lauridsen
02ce5bbf6b Shutdown/cancelation story for main cargo watch thread 2019-12-27 11:43:05 +01:00
Emil Lauridsen
a2d10694cc Consistent, hopefully robust, shutdown/cancelation story for cargo check subprocess 2019-12-27 11:32:05 +01:00
Florian Diebold
9fd2c813ca visible_from -> is_visible_from 2019-12-27 11:25:04 +01:00
bors[bot]
823e9193fe
Merge #2657
2657: Omit closure parameters in closure type display strings r=flodiebold a=SomeoneToIgnore

Part of https://github.com/rust-analyzer/rust-analyzer/issues/1946

I wonder, should we display the the closure trait (Fn/FnMut/FnOnce) in inlay hints instead of `|...|` at all?

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2019-12-27 10:10:07 +00:00
Emil Lauridsen
428a6ff5b8 Move cargo watch functionality to separate crate 2019-12-27 11:10:07 +01:00
Florian Diebold
dfe95d735b Remove Arc from RawVisibility
Now that it's not used as a direct query return value anymore, it doesn't need
to be cheaply cloneable anymore.
2019-12-26 16:42:57 +01:00
Florian Diebold
04cf98f8a6 Fix cross-crate glob privacy handling 2019-12-26 16:31:38 +01:00
Florian Diebold
78111620a3 Remove visibility query, instead add struct field visibility to data
Methods should be handled the same, and for items the visibility will be in the
def map.
2019-12-26 16:23:40 +01:00
Florian Diebold
50ebff257d Rename ResolvedVisibility -> Visibility 2019-12-26 16:23:40 +01:00
Florian Diebold
e1a2961273 Rename Visibility -> RawVisibility 2019-12-26 16:23:40 +01:00