Commit graph

7897 commits

Author SHA1 Message Date
bors[bot]
ba48c6548c
Merge #5311
5311: Fix goto definition for type alias type parameters r=matklad a=matklad

closes https://github.com/rust-analyzer/rust-analyzer/issues/5042



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-11 10:46:25 +00:00
Aleksey Kladov
8c4919c9fd Fix goto definition for type alias type parameters
closes https://github.com/rust-analyzer/rust-analyzer/issues/5042
2020-07-11 12:45:30 +02:00
bors[bot]
45be08c708
Merge #5310
5310: Reduce visibility r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-11 10:34:14 +00:00
Aleksey Kladov
3fc4916b53 Reduce visibility 2020-07-11 12:31:50 +02:00
bors[bot]
33ebfa8dcc
Merge #5309
5309: Make sure there are no commands in code actions r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-11 09:58:56 +00:00
Aleksey Kladov
0f0c5081c0 Make sure there are no commands in code actions 2020-07-11 11:53:24 +02:00
bors[bot]
6c1546c3a4
Merge #4996
4996: Correctly generate new struct field in file containing struct def r=matklad a=TimoFreiberg

WIP because the test doesn't pass.
Testing the fix by hand looked good, although quickfixes seem to not support setting the editor cursor yet, which i think we want for "generate missing defs from usage" fixes.


Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-07-11 09:51:31 +00:00
Aleksey Kladov
7f6e5de37c disable profiling 2020-07-11 03:41:52 +02:00
Aleksey Kladov
5e25000763 Profiling example 2020-07-11 03:41:01 +02:00
Aleksey Kladov
e7ba7f47a7 Profiling tweaks 2020-07-11 03:04:37 +02:00
Aleksey Kladov
e6ea395fb0 Don't show error when speculatively reloading workspace 2020-07-11 01:39:06 +02:00
Aleksey Kladov
a36ff4a100 Speed up completion 2020-07-11 01:26:24 +02:00
Aleksey Kladov
a425d7d871 Simplify 2020-07-10 23:57:10 +02:00
Aleksey Kladov
dac9a4cebd Don't spawn notify unnecessary 2020-07-10 23:45:07 +02:00
Aleksey Kladov
a1ef6cc553 Optimize VFS processing 2020-07-10 22:30:24 +02:00
Aleksey Kladov
676d2e040d Sort cargo metadata
See https://github.com/rust-lang/cargo/issues/8477

We need this to prevent spurious workspace reloads
2020-07-10 22:30:24 +02:00
Aleksey Kladov
be679a02ab Add profiling calls 2020-07-10 22:30:24 +02:00
Aleksey Kladov
86bc4d20b3 Also reload when adding new examples, tests, etc 2020-07-10 22:30:24 +02:00
Timo Freiberg
43079ba80d Correctly generate new struct field in file containing struct def 2020-07-10 19:16:41 +02:00
Aleksey Kladov
a482eb0cd8 Better caret placement when filling match arms 2020-07-10 18:22:04 +02:00
Aleksey Kladov
3558736582 Better name 2020-07-10 17:56:55 +02:00
Aleksey Kladov
2d20c8f218 Don't add braces after struct
Unit structs are a thing
2020-07-10 17:42:18 +02:00
Aleksey Kladov
e4983daa5e Better complete expression keywords 2020-07-10 17:41:43 +02:00
Aleksey Kladov
51dd06566e Complete params in nested fns 2020-07-10 16:29:14 +02:00
Aleksey Kladov
d02aabe633 Complete parameters more aggressively 2020-07-10 16:07:12 +02:00
Aleksey Kladov
74d376763c Refresh tests 2020-07-10 16:05:01 +02:00
bors[bot]
9ab59e2162
Merge #5293
5293: Automatically reload project info on Cargo.toml changes r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-10 13:35:46 +00:00
Aleksey Kladov
d0a8f6a3eb Automatically reload project info on Cargo.toml changes 2020-07-10 15:35:15 +02:00
Aleksey Kladov
075380dd56 Look through Arc for goto type definition 2020-07-10 14:42:26 +02:00
Aleksey Kladov
cd4502fd47 Simplify tests 2020-07-10 14:39:05 +02:00
Aleksey Kladov
f4147f6a34 Dont expose ID 2020-07-10 14:11:31 +02:00
Aleksey Kladov
9c54537ecf Rename 2020-07-10 14:09:31 +02:00
Aleksey Kladov
b85042601d Goto type definition works for self 2020-07-10 14:08:35 +02:00
bors[bot]
5fa8f8e376
Merge #5286
5286: Only take first 500 syntax errors r=jonas-schievink a=yihuang

Too many syntax errors make some editor/ide slow, fix #3434.

Co-authored-by: yihuang <yi.codeplayer@gmail.com>
2020-07-10 09:33:29 +00:00
yihuang
17ff67dd7e
Only take first 500 syntax errors
Too many syntax errors make some editor/ide slow, fix #3434.
2020-07-10 17:30:57 +08:00
Aleksey Kladov
17edf50e2c Avoid accidently stumping over config values 2020-07-10 10:07:08 +02:00
Aleksey Kladov
68706b59c9 Don't mess with cursor position when adding hashes 2020-07-09 19:21:41 +02:00
bors[bot]
1fb92d791e
Merge #5284
5284: Fold struct literals r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-09 16:49:44 +00:00
Aleksey Kladov
ca8969a104 Fold struct literals 2020-07-09 18:49:17 +02:00
Jonas Schievink
74aa0ab9f7 arg count mismatch: handle tuple ctors 2020-07-09 18:24:02 +02:00
bors[bot]
89c7c55995
Merge #5270
5270: Add argument count mismatch diagnostic r=matklad a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/issues/4025.

This currently has one false positive on this line, where `max` is resolved to `Iterator::max` instead of `Ord::max`:

8aa10c00a4/crates/expect/src/lib.rs (L263)

(I have no idea why it thinks that `usize` is an `Iterator`)

TODO:
* [x] Tests
* [x] Improve diagnostic text for method calls

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-07-09 15:34:43 +00:00
Jonas Schievink
f4a9d9a00f Address review comments 2020-07-09 17:33:49 +02:00
Aleksey Kladov
65d9966a4f Always put config first 2020-07-09 16:12:53 +02:00
Aleksey Kladov
e075e6eef2 Move diagnostics tests to expect 2020-07-09 16:04:29 +02:00
Jonas Schievink
984b6889eb Add tests 2020-07-09 15:52:10 +02:00
Jonas Schievink
3ce4407dcb Fix diagnostic for method calls 2020-07-09 15:51:32 +02:00
Jonas Schievink
d04f3604d5 Correctly pluralize message 2020-07-09 15:50:53 +02:00
Jonas Schievink
73327c647d Remove unnecessary DiagnosticSink handlers 2020-07-09 15:50:35 +02:00
Aleksey Kladov
d70f4f5da5 Add fixmes 2020-07-09 15:41:13 +02:00
Aleksey Kladov
9d0196a491 Simplify 2020-07-09 15:35:52 +02:00
Aleksey Kladov
b398519011 Cleanup diagnostic conversion code 2020-07-09 15:34:37 +02:00
Aleksey Kladov
117392e879 Remove insta from ra_ide 2020-07-09 14:33:57 +02:00
Aleksey Kladov
fb0bc941a5 Cleanup diagnostics tests 2020-07-09 14:33:03 +02:00
Aleksey Kladov
ea68a1d0c9 Reduce code duplication 2020-07-09 13:59:49 +02:00
Jonas Schievink
47d0cf201c Don't emit diagnostic if there are type errors 2020-07-09 12:41:35 +02:00
Jonas Schievink
63ce2c7b5f Add argument count mismatch diagnostic 2020-07-09 12:16:29 +02:00
Aleksey Kladov
4399eff2d0 Re-enable IDE features for incomplete impl blocs 2020-07-09 12:14:26 +02:00
Aleksey Kladov
8e1ebbcc13 Simplify 2020-07-09 11:47:27 +02:00
Aleksey Kladov
2aa27d612e expect should be a dev dep 2020-07-09 10:59:41 +02:00
Aleksey Kladov
b660681a6b Unify tests 2020-07-09 10:58:56 +02:00
Aleksey Kladov
b9aab22d56 No blank indent 2020-07-09 10:33:32 +02:00
Aleksey Kladov
c66812193e Prettier rendering 2020-07-09 10:31:12 +02:00
Aleksey Kladov
e7c47eb7f5 Streamline 2020-07-09 10:19:37 +02:00
Aleksey Kladov
3a26752c66 Reduce API 2020-07-09 10:03:28 +02:00
Aleksey Kladov
22269c67b8 Cleanup 2020-07-09 09:56:15 +02:00
Aleksey Kladov
3ef9ef34c6 Reduce API 2020-07-09 09:42:01 +02:00
Aleksey Kladov
ed12bd2791 Rename 2020-07-09 09:39:53 +02:00
Aleksey Kladov
abbb539f97 Refactor hover tests 2020-07-09 00:10:49 +02:00
Aleksey Kladov
9ce9a4ae0d Simplify tests 2020-07-08 23:06:15 +02:00
Aleksey Kladov
e4b4600752 better language 2020-07-08 22:47:50 +02:00
Aleksey Kladov
e8bb153b19 Add Markup type 2020-07-08 22:37:35 +02:00
Aleksey Kladov
16dcf020c4 simplify 2020-07-08 20:35:54 +02:00
Aleksey Kladov
d74a77efb1 Minimize API 2020-07-08 20:35:54 +02:00
Aleksey Kladov
7238acab78 Dead code 2020-07-08 20:35:54 +02:00
Aleksey Kladov
86aac4303f Reduce visibility 2020-07-08 19:41:57 +02:00
Aleksey Kladov
dab7f3d2c6 Remove relative_path dependency 2020-07-08 19:32:36 +02:00
Aleksey Kladov
7ae696ba76 Remove unwanted dependency 2020-07-08 18:26:31 +02:00
Aleksey Kladov
35e4bb3506 Document failed refactor 2020-07-08 18:17:45 +02:00
kjeremy
4b7f473223 Clippy perf warnings 2020-07-08 09:45:29 -04:00
Aleksey Kladov
69b79e3a73 Replace ad hocery with science 2020-07-07 23:28:48 +02:00
Aleksey Kladov
5d2225f4bc Fix symbol search in salsa
Previous solution for binning paths into disjoint directories was
simple and fast -- just a single binary search.

Unfortunatelly, it wasn't coorrect: if the ditr are

  /d
  /d/a
  /d/c

then partitioning the file /d/b/lib.rs won't pick /d as a correct
directory.

The correct solution here is a trie, but it requires exposing path
components.

So, we use a poor man's substitution -- a *vector* of sorted paths,
such that each bucket is prefix-free

closes #5246
2020-07-07 17:38:02 +02:00
Aleksey Kladov
9effc6116f Upstream salsa 2020-07-07 15:48:55 +02:00
bors[bot]
73e972a173
Merge #5244
5244: Add a command to compute memory usage statistics r=matklad a=jonas-schievink

This allows inspecting memory usage on a live rust-analyzer instance after it has been used interactively.

This will only work with `--features jemalloc`, so maybe it should print something more useful when that's not available? Right now it will just print 0 Bytes for every query.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-07-07 11:00:04 +00:00
bors[bot]
0719f2824c
Merge #5247
5247: Modernize unqualified reference completion tests r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-07 10:52:54 +00:00
Aleksey Kladov
5b8a5bfb15 Modernize unqualified reference completion tests 2020-07-07 12:52:09 +02:00
bors[bot]
687fb031d2
Merge #5245
5245: Refactor AssistBuilder to manage a SourceChange r=matklad a=theduke

`AssistBuilder` now managaes a full `SourceChange` instead of a
`Vec<SourceFileEdit>`.

This prepares AssistBuilder to handle creation of new files.


Co-authored-by: Christoph Herzog <chris@theduke.at>
2020-07-07 10:25:17 +00:00
Christoph Herzog
3360118040 Refactor AssistBuilder to manage a SourceChange
`AssistBuilder`` now managaes a full `SourceChange` instead of a
Vec<SourceFileEdit>.

This prepares AssistBuilder to handle creation of new files.
2020-07-07 12:10:18 +02:00
Jonas Schievink
f44c4b61e1 Add a command to compute memory usage statistics 2020-07-07 12:10:14 +02:00
Aleksey Kladov
9b2847885d cleanup 2020-07-07 11:44:16 +02:00
bors[bot]
0f5d62a3f3
Merge #5235 #5236 #5241
5235: Don't ping people in PRs r=matklad a=lnicola



5236: Disable ES module interop r=matklad a=lnicola



5241: Clippy perf warnings r=matklad a=kjeremy

Removes redundant clones

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-07-07 09:29:52 +00:00
Aleksey Kladov
4bbc385277 Switch to fully dynamically dispatched salsa
This improves compile times quite a bit
2020-07-07 10:14:48 +02:00
kjeremy
ebdee366b0 Clippy perf warnings
Removes redundant clones
2020-07-06 17:13:55 -04:00
Aleksey Kladov
23258d8436 Simplify file watcher 2020-07-06 09:28:17 +02:00
bors[bot]
8b0983e89a
Merge #5228
5228: Fix typo r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-05 09:24:58 +00:00
Aleksey Kladov
569504938e Fix typo 2020-07-05 11:19:16 +02:00
Aleksey Kladov
4be73c2b7f AbsPath 2020-07-05 11:15:35 +02:00
Aleksey Kladov
453167b492 Modernise item completion tests 2020-07-04 23:25:33 +02:00
Paul Daniel Faria
5b96d4103e Fallback to target in cfg if not specified in project json config 2020-07-04 13:50:27 -04:00
Paul Daniel Faria
db99f2dd7e Add optional target to crates in json project, lookup default cfgs per target when generating cfg list 2020-07-04 13:49:44 -04:00
Aleksey Kladov
943fa46395 Alight details in comkplation list 2020-07-04 19:03:58 +02:00
Aleksey Kladov
c14a3b4a20 Modernize qual path completion tests 2020-07-04 18:53:30 +02:00
Aleksey Kladov
824a24c710 Modernize snippet completion tests 2020-07-04 18:03:34 +02:00
Aleksey Kladov
3902e5574c Add Item change to the set of benches 2020-07-04 17:04:33 +02:00
Aleksey Kladov
000d1db351 Fix bench to work with relative paths 2020-07-04 17:03:02 +02:00
Aleksey Kladov
ba9c398144 Modernize postfix completion tests 2020-07-04 15:44:21 +02:00
Aleksey Kladov
7a7fd6d239 Modernize pattern completion tests 2020-07-04 15:10:55 +02:00
Aleksey Kladov
9dacd2338c Fix lookup in tests 2020-07-04 15:05:33 +02:00
Aleksey Kladov
216e093f90 Macro tests 2020-07-04 15:04:57 +02:00
Aleksey Kladov
03ca33406e Modernize tests 2020-07-04 14:53:43 +02:00
Aleksey Kladov
f2f6a46aa4 Cleanup dot completiont tests 2020-07-04 10:41:50 +02:00
Aleksey Kladov
caeddff543 Comments 2020-07-04 10:03:27 +02:00
Aleksey Kladov
5c68dd6b59 Better tests for completion scoring 2020-07-04 09:53:54 +02:00
Aleksey Kladov
aaba2300fb Modernize completion presentation tests 2020-07-04 09:36:53 +02:00
Aleksey Kladov
65768feaff Unify naming 2020-07-04 09:08:51 +02:00
Aleksey Kladov
6518f18f80 Cleanup tests 2020-07-04 09:07:18 +02:00
bors[bot]
212fa29a69
Merge #5197
5197: SSR internal refactorings r=davidlattimore a=davidlattimore

- Extract error code out to a separate module
- Improve error reporting when a test fails
- Refactor matching code
- Update tests so that all paths in search patterns can be resolved

Co-authored-by: David Lattimore <dml@google.com>
2020-07-04 00:13:11 +00:00
David Lattimore
a354e5b5cf SSR: Update tests so that all paths in patterns can be resolved 2020-07-04 08:56:58 +10:00
David Lattimore
69051d2f9d SSR: Refactor matching code.
Mutable state is now stored in the enum Phase.
MatchState, since it now has no mutable state is renamed Matcher.
MatchInputs is merged into Matcher
2020-07-04 08:56:58 +10:00
David Lattimore
4a8679824b SSR: Improve error reporting when a test fails 2020-07-04 08:56:58 +10:00
David Lattimore
a5ef644a16 SSR: Extract error code out to a separate module
This is to make reusing it outside of parsing easier in a subsequent
change.
2020-07-04 08:56:51 +10:00
Aleksey Kladov
cda1a6c638 Cleanup more completion tests 2020-07-04 00:01:45 +02:00
Aleksey Kladov
9f9b38bdb4 Cleanup presentation tests 2020-07-03 23:15:44 +02:00
Aleksey Kladov
d09f692300 Add AssistKind::Generate 2020-07-03 19:32:18 +02:00
Aleksey Kladov
66b6a433c6 Unify naming of generating assists 2020-07-03 19:32:18 +02:00
bors[bot]
a434ecef51
Merge #5212
5212: Fix module renaming r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-03 16:55:01 +00:00
Aleksey Kladov
f4a3bc30b8 Fix module renaming 2020-07-03 18:47:26 +02:00
Aleksey Kladov
4c347a9f65 Compress rename tests 2020-07-03 18:39:36 +02:00
Aleksey Kladov
2656c415c8 Use expect for rename tests 2020-07-03 18:35:43 +02:00
Aleksey Kladov
ee7ab0104d Adhere to code style in rename tests 2020-07-03 18:29:37 +02:00
bors[bot]
7ad7f3ca8c
Merge #5211
5211: Fix inference of indexing argument (partly) r=flodiebold a=flodiebold

We need to add the `T: Index<Arg>` obligation to be resolved later as well, otherwise we can't make inferences about `Arg` later based on the `Index` impls.

This still doesn't fix indexing with integer variables though; there's a further problem with Chalk floundering because of the variable, I think.

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-07-03 16:18:34 +00:00
Florian Diebold
57feb323f7 Fix inference of indexing argument (partly)
We need to add the `T: Index<Arg>` obligation to be resolved later as well,
otherwise we can't make inferences about `Arg` later based on the `Index` impls.

This still doesn't fix indexing with integer variables though; there's a further
problem with Chalk floundering because of the variable, I think.
2020-07-03 18:17:06 +02:00
bors[bot]
0f68fed4a0
Merge #5209
5209: Fixes to memory usage stats r=matklad a=jonas-schievink

This brings the unaccounted memory down from 287mb to 250mb, and displays memory used by VFS and "other" allocations.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-07-03 15:58:46 +00:00
Aleksey Kladov
b8ef8539a6 Fix workspace reloading 2020-07-03 17:19:00 +02:00
Jonas Schievink
f01e7e3601 Track VFS and remaining/unaccounted memory 2020-07-03 17:16:01 +02:00
Jonas Schievink
93d0ac7fa0 Fix memory usage accounting for interned queries 2020-07-03 17:12:29 +02:00
bors[bot]
88a602f305
Merge #5205
5205: Refactor attribut completion tests r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-03 14:06:13 +00:00
Aleksey Kladov
314efae29d Refactor attribut completion tests 2020-07-03 15:59:37 +02:00
Aleksey Kladov
f1671f460b Compress attribute completion tests 2020-07-03 15:38:53 +02:00
bors[bot]
f51b0cfdd6
Merge #5116
5116: Categorize assists r=matklad a=kjeremy

Categorize assists so that editors can use them. Follows the LSP spec pretty close (and some things may need adjustments) but this populates the Refactor menu in vscode and pushes quickfixes through again.

This is a prerequisite to filtering out assists that the client doesn't care about.

Fixes #4147

Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-07-03 12:44:09 +00:00
Aleksey Kladov
503de8e229 Add function to test completion edit 2020-07-03 13:21:48 +02:00
Aleksey Kladov
e2b04621f9 Refactor keyword completion tests 2020-07-03 12:51:18 +02:00
Aleksey Kladov
0e23175a07 Cleanup record completion tests 2020-07-03 11:48:48 +02:00
kjeremy
4c9347ecc3 Don't categorize things we don't care about 2020-07-02 18:01:22 -04:00
kjeremy
36cc81ac71 Move AssistKind into AssistId 2020-07-02 17:48:35 -04:00
kjeremy
1d58e16824 Recategorize a few 2020-07-02 17:14:15 -04:00
Jeremy Kolb
b98c16a034 Categorize assists 2020-07-02 17:13:02 -04:00
bors[bot]
4cb8bf03c5
Merge #5192
5192: Implement rust-analyzer feature configuration to tests. r=matklad a=daxpedda

Fixes #3198.

I'm unsure if it is desired this way, maybe we want to make a seperate configuration?

Co-authored-by: daxpedda <daxpedda@gmail.com>
2020-07-02 15:48:54 +00:00
Aleksey Kladov
6c7578bd7a Move cargo metadata off the main loop 2020-07-02 17:39:51 +02:00
daxpedda
eb75a644a1
Implement rust-analyzer feature configuration to tests. 2020-07-02 16:13:24 +02:00
bors[bot]
83f3cdca4f
Merge #5191
5191: Minor r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-02 14:10:13 +00:00
Aleksey Kladov
6a694ad047 Minor 2020-07-02 16:06:00 +02:00
bors[bot]
1a3a7f4237
Merge #5188
5188: Implement StatusBar r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-02 14:02:52 +00:00
bors[bot]
e75b4fc85e
Merge #5189
5189: Record and suggest assoc. items of traits via ImportMap r=matklad a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/5115

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-07-02 13:55:14 +00:00
Jonas Schievink
6ee73cd334 Use SmolStr 2020-07-02 15:42:37 +02:00
Aleksey Kladov
4f26a3734e Indicate when project needs a reload 2020-07-02 15:34:12 +02:00
Aleksey Kladov
3ef7676076 Implement StatusBar 2020-07-02 15:32:14 +02:00
Jonas Schievink
361b399b6d Fix tests 2020-07-02 13:34:08 +02:00
Jonas Schievink
31f5b48817 Record and suggest trait items via ImportMap 2020-07-02 12:43:52 +02:00
bors[bot]
57ed622ec4
Merge #5089 #5161 #5184 #5185 #5186
5089: Disable auto-complete on comments r=matklad a=BGluth

Resolves #4907 by disabling any auto-completion on comments.

As flodiebold [pointed out](https://github.com/rust-analyzer/rust-analyzer/issues/4907#issuecomment-648439979), in the future we may want to support some form of auto-completion within doc comments, but for now it was suggested to just disable auto-completion on them entirely.

The implementation involves adding a new field `is_comment` to `CompletionContext` and checking if the immediate token we auto-completed on is a comment. I couldn't see a case where we need to check any of the ancestors, but let me know if this is not sufficient. I also wasn't sure if it was necessary to add a new field to this struct, but I decided it's probably the best option if we want to potentially do auto-completion on doc comments in the future.

Finally, the three tests I added should I think ideally not filter results by `CompletionKind::Keyword`, but if I want to get unfiltered results, I need access to a non-public function [get_all_completion_items](9a4d02faf9/crates/ra_ide/src/completion/test_utils.rs (L32-L39)) which I don't know if I should make public just for this.



5161: SSR: Add initial support for placeholder constraints r=matklad a=davidlattimore



5184: Always install required nightly extension if current one is not nightly r=matklad a=Veetaha

This is weird, but having switched back to stable by uninstalling the extension appears that vscode doesn't destroy the `PersistentState` and thus changing to `nightly` channel doesn't work because the last check for nightly extension was less than 1 hour ago. The simple solution is to skip this check if we know that the current extension version is not nightly.

5185: Force showing extension activation error pop-up notification r=matklad a=Veetaha

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/5091

5186: fix: correct pd/ppd/tfn/tmod completion doc r=matklad a=fannheyward

a33eefa3b2/crates/ra_ide/src/completion/complete_snippet.rs (L23-L24)

Co-authored-by: BGluth <gluthb@gmail.com>
Co-authored-by: David Lattimore <dml@google.com>
Co-authored-by: Veetaha <veetaha2@gmail.com>
Co-authored-by: Heyward Fann <fannheyward@gmail.com>
2020-07-02 09:12:46 +00:00
Heyward Fann
f1986be8fd fix: correct pd/ppd/tfn/tmod completion doc
a33eefa3b2/crates/ra_ide/src/completion/complete_snippet.rs (L23)
2020-07-02 11:06:00 +08:00
David Lattimore
83588a1c45 SSR: Use T! instead of SyntaxKind::* where possible 2020-07-02 09:19:58 +10:00
BGluth
cc77bdf59a Auto-completion no longer occurs on comments 2020-07-01 15:20:07 -06:00
BGluth
0bbd6428ad Added tests for no auto-completion on comments 2020-07-01 15:16:47 -06:00
bors[bot]
a33eefa3b2
Merge #5149
5149: Implement Chalk variable kinds r=flodiebold a=flodiebold

This means we need to keep track of the kinds (general/int/float) of variables in `Canonical`, which requires some more ceremony. (It also exposes some places where we're not really dealing with canonicalization correctly -- another thing to be cleaned up when we switch to using Chalk's types directly.)

Should fix the last remaining issue of #2534.

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-07-01 18:41:06 +00:00
Florian Diebold
d5d485ef92 Implement Chalk variable kinds
This means we need to keep track of the kinds (general/int/float) of variables
in `Canonical`, which requires some more ceremony. (It also exposes some places
where we're not really dealing with canonicalization correctly -- another thing
to be cleaned up when we switch to using Chalk's types directly.)

Should fix the last remaining issue of #2534.
2020-07-01 20:40:38 +02:00
bors[bot]
ec1d1a1b70
Merge #5179
5179: ItemTree: Lower fields despite invalid type r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/5147

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-07-01 17:28:12 +00:00
Jonas Schievink
4ef1d533bd ItemTree: Lower fields despite invalid type 2020-07-01 19:24:39 +02:00
bors[bot]
43dfd29d8d
Merge #5174
5174: Colorize more test fixtures r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-07-01 17:20:02 +00:00
bors[bot]
ad1a0e626b
Merge #5175
5175: More memory-efficient impl collection r=matklad a=jonas-schievink

This saves roughly 90 MB in `ImplsFromDepsQuery`, which used to copy the list of all impls from libcore into *every* crate in the graph. It also stops collecting inherent impls from dependencies entirely, as those can only be located within the crate defining the self type.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-07-01 17:12:06 +00:00
bors[bot]
8943c2cb97
Merge #5178
5178: Fold multiline calls r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-01 16:35:16 +00:00
Aleksey Kladov
8295dc42a0 Fold multiline calls 2020-07-01 18:27:58 +02:00
Laurențiu Nicola
dbb940fa7d Colorize more test fixtures 2020-07-01 19:05:34 +03:00
Aleksey Kladov
53e3a7aeb4 Update file structure tests 2020-07-01 17:59:44 +02:00
Aleksey Kladov
bebbbb61a7 Update expand macro tests 2020-07-01 17:52:22 +02:00
Jonas Schievink
6bde542a39 Split CrateImplDefs in inherent and trait impls
This makes the intention of inherent vs. trait impls somewhat more
clear and also fixes (?) an issue where trait impls with an unresolved
trait were added as inherent impls instead (hence the test changes).
2020-07-01 17:15:20 +02:00
bors[bot]
14bf5bb7ee
Merge #5167
5167: Reuse Semantics instances r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-07-01 15:06:13 +00:00
bors[bot]
f565447775
Merge #5173
5173: Automatically reload project on config change r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-01 14:43:11 +00:00
Aleksey Kladov
a03cfa4926 Automatically reload project on config change 2020-07-01 16:42:14 +02:00
bors[bot]
3cf389f88b
Merge #5171
5171: Better account for project reload r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-01 14:01:36 +00:00
Aleksey Kladov
298adb27b9 Better account for project reload 2020-07-01 16:01:03 +02:00
Jonas Schievink
07ba986db7 Don't recursively call impls_from_deps
It creates a big map and duplicates lots of impls that are then left
lying around
2020-07-01 15:19:36 +02:00
Jonas Schievink
63ea8f2af0 Add a transitive deps iterator to CrateGraph 2020-07-01 15:18:51 +02:00
bors[bot]
3f94ad332a
Merge #5169
5169: Add reload workspace command r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-01 13:08:25 +00:00
Aleksey Kladov
c9f878962a Add reload workspace command 2020-07-01 14:57:59 +02:00
Aleksey Kladov
18ec1ed72e Log flycheck command 2020-07-01 14:49:13 +02:00
Laurențiu Nicola
9710ad8c48 Reuse Semantics instances 2020-07-01 15:27:01 +03:00
Jeremy Kolb
20d864807d Use the selection range when resolving call hierarchy items
Add a test in call_hierarchy that already passed

Fixes #5103
2020-07-01 07:56:15 -04:00
bors[bot]
248b656c21
Merge #5162
5162: Try to reduce Semantics monomorphisations r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-07-01 11:40:47 +00:00
Laurențiu Nicola
d89827f9e0 Make less code generic 2020-07-01 14:38:42 +03:00
Laurențiu Nicola
e8505f14d4 Try to reduce Semantics monomorphisations 2020-07-01 14:38:42 +03:00
Aleksey Kladov
44b8737ced Dont show empty progress for empty workspaces 2020-07-01 13:05:34 +02:00
Aleksey Kladov
991850bc3c Unify magic env var name 2020-07-01 12:31:03 +02:00
Aleksey Kladov
7b0113b3d5 Move parser specific tests utils to parser tests 2020-07-01 12:30:17 +02:00
bors[bot]
a9db3d53a0
Merge #5159
5159: Don't fail expect tests in rewrite mode r=matklad a=matklad

bors r+

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-01 09:35:31 +00:00
Aleksey Kladov
05d67a9a0e Move test data to test_data directory 2020-07-01 11:26:09 +02:00
Aleksey Kladov
adf624b433 Add file support to expect 2020-07-01 11:19:40 +02:00
Laurențiu Nicola
c1139a5a44 Use the existing Semantics in auto_import 2020-07-01 11:48:15 +03:00
Aleksey Kladov
82838f5eda Cleanup 2020-07-01 10:44:16 +02:00
Aleksey Kladov
977b688144 Don't fail tests when updating snapshot 2020-07-01 10:44:16 +02:00
David Lattimore
3d9997889b SSR: Add initial support for placeholder constraints 2020-07-01 18:44:11 +10:00
bors[bot]
dd3ad2bd41
Merge #5154 #5157
5154: Structured search debugging r=matklad a=davidlattimore

Adds a "search" mode to the rust-analyzer binary that does structured search (SSR without the replace part). This is intended primarily for debugging why a bit of code isn't matching a pattern.

5157: Use dynamic dispatch in AstDiagnostic r=matklad a=lnicola



Co-authored-by: David Lattimore <dml@google.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-07-01 08:11:23 +00:00
bors[bot]
686e115e73
Merge #5158
5158: Use CrateName correctly r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-01 08:03:47 +00:00
Aleksey Kladov
80386ca5be Use Strings for display names 2020-07-01 10:03:07 +02:00
Aleksey Kladov
307c6fec61 Use CrateName for semantic names 2020-07-01 09:53:53 +02:00
Laurențiu Nicola
1be5e848b0 Use dynamic dispatch in AstDiagnostic 2020-07-01 10:46:27 +03:00
Laurențiu Nicola
331e6d8f16 Remove db from AssistsContext 2020-07-01 10:25:59 +03:00
bors[bot]
98ae447fa7
Merge #5153
5153: Make SemanticsScope non-generic r=matklad a=lnicola

This slightly reduces the build times:

![image](https://user-images.githubusercontent.com/308347/86210975-3a809480-bb7e-11ea-8975-788457f6b353.png)

(compare to https://github.com/rust-analyzer/rust-analyzer/issues/1987#issuecomment-652202248)

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-07-01 07:17:16 +00:00
Aleksey Kladov
e336a96998 FileSetConfig works with empty set of roots
Closes #5139
2020-07-01 09:06:51 +02:00
David Lattimore
95f8310514 Structured search debugging 2020-07-01 16:50:45 +10:00
Laurențiu Nicola
5953cbd7ae Make SemanticsScope non-generic 2020-07-01 09:34:45 +03:00
bors[bot]
b1a2d01645
Merge #5142
5142: analysis-stats: allow parallel type inference r=matklad a=jonas-schievink

This is mostly just for testing/fun, but it looks like type inference can be sped up massively with little to no effort (since it runs after the serial phases are already done).

Without `--parallel`:

```
Item Collection: 16.43597698s, 683mb allocated 720mb resident
Inference: 25.429774879s, 1720mb allocated 1781mb resident
Total: 41.865866352s, 1720mb allocated 1781mb resident
```

With `--parallel`:

```
Item Collection: 16.380369815s, 683mb allocated 735mb resident
Parallel Inference: 7.449166445s, 1721mb allocated 1812mb resident
Inference: 143.437157ms, 1721mb allocated 1812mb resident
Total: 23.973303611s, 1721mb allocated 1812mb resident
```

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-06-30 21:17:54 +00:00
Aleksey Kladov
cec92407f4 Don't crash on empty out_dirs with older cargos
closes #5125
2020-06-30 22:12:27 +02:00
Aleksey Kladov
8b725a2f77 Switch to expect for the rest of inlay tests 2020-06-30 21:55:21 +02:00
Aleksey Kladov
442c13ba17 Simplify most of the inlay hints tests 2020-06-30 18:04:25 +02:00
Jonas Schievink
4602c2eeaa analysis-stats: allow parallel type inference 2020-06-30 17:00:17 +02:00
bors[bot]
0954d31bee
Merge #5138
5138: Refactor runnable tests r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-30 12:18:31 +00:00
Aleksey Kladov
de464f5e4a Refactor runnable tests 2020-06-30 14:12:55 +02:00
bors[bot]
3e70d0f308
Merge #5136
5136: Split namespace maps in `ItemScope` r=jonas-schievink a=jonas-schievink

Reduces memory usage of the CrateDefMap query by ~130 MB (50%) on r-a.

I was also looking into handling glob imports more efficiently (storing scope chains instead of always duplicating everything into the glob-importing module's scope), but it seems that this already gives the most significant wins.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-06-30 12:10:21 +00:00
Jonas Schievink
7c9b3d154c Remove entries_without_primitives 2020-06-30 14:06:23 +02:00
Jonas Schievink
a80e8fea85 Simplify entry API usage 2020-06-30 13:54:40 +02:00
Aleksey Kladov
af7e300041 Remove confusing API 2020-06-30 13:29:53 +02:00
Jonas Schievink
56fb8a401a Reorder imports 2020-06-30 13:25:15 +02:00
Jonas Schievink
0fcbc716fd Split namespace maps in ItemScope
Reduces memory usage of the CrateDefMap query by ~130 MB on r-a.
2020-06-30 13:23:42 +02:00
Aleksey Kladov
34072d53b6 Rewrite goto implementation tests 2020-06-30 13:20:16 +02:00
Aleksey Kladov
4484908a86 Rewrite goto definition tests 2020-06-30 13:03:08 +02:00
Aleksey Kladov
d34e725f09 Better factoring 2020-06-30 12:14:16 +02:00
Aleksey Kladov
d21c84abd4 Generalize annotations 2020-06-30 12:13:08 +02:00
bors[bot]
e87cba85ef
Merge #5132
5132: Fix some typos r=matklad a=davidlattimore



Co-authored-by: David Lattimore <dml@google.com>
2020-06-30 08:45:16 +00:00
bors[bot]
d13ded6cbc
Merge #5101
5101: Add expect -- a light-weight alternative to insta r=matklad a=matklad

This PR implements a small snapshot-testing library. Snapshot updating is done by setting an env var, or by using editor feature (which runs  a test with env-var set). 

Here's workflow for updating a failing test:

![expect](https://user-images.githubusercontent.com/1711539/85926956-28afa080-b8a3-11ea-9260-c6d0d8914d0b.gif)

Here's workflow for adding a new test:

![expect-fresh](https://user-images.githubusercontent.com/1711539/85926961-306f4500-b8a3-11ea-9369-f2373e327a3f.gif)

Note that colorized diffs are not implemented in this PR, but should be easy to add (we already use them in test_utils). 

Main differences from insta (which is essential for rust-analyzer development, thanks @mitsuhiko!):
* self-updating tests, no need for a separate tool
* fewer features (only inline snapshots, no redactions)
* fewer deps (no yaml, no persistence)
* tighter integration with editor
* first-class snapshot object, which can be used to write test functions (as opposed to testing macros)
* trivial to tweak for rust-analyzer needs, by virtue of being a workspace member. 

I think eventually we should converge to a single snapshot testing library, but I am not sure that `expect` is exactly right, so I suggest rolling with both insta and expect for some time (if folks agree that expect might be better in the first place!). 

# Editor Integration Implementation 

The thing I am most excited about is the ability to update a specific snapshot from the editor. I want this to be available to other snapshot-testing libraries (cc @mitsuhiko, @aaronabramov), so I want to document how this works. 

The ideal UI here would be a code action (💡). Unfortunately, it seems like it is impossible to implement without some kind of persistence (if you save test failures into some kind of a database, like insta does, than you can read the database from the editor plugin). Note that it is possible to highlight error by outputing error message in rustc's format. Unfortunately, one can't use the same trick to implement a quick fix. 

For this reason, expect makes use of another rust-analyzer feature -- ability to run a single test at the cursor position. This does need some expect-specific code in rust-analyzer unfortunately. Specifically, if rust-analyzer notices that the cursor is on `expect!` macro, it adds a special flag to runnable's JSON. However, given #5017 it is possible to approximate this well-enough without rust-analyzer integration. Specifically, an extension can register a special runner which checks (using regexes) if rust-anlyzer runnable covers text with specific macro invocation and do special magic in that case. 

closes #3835 


Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-30 08:34:08 +00:00
David Lattimore
ef49bbeec4 Fix some typos 2020-06-30 10:43:37 +10:00
bors[bot]
2bd7171399
Merge #5120
5120: Add a simple SSR subcommand to the rust-analyzer command line binary r=davidlattimore a=davidlattimore

Is adding the dependency on ra_ide_db OK? It's needed for the call to `db.local_roots()`

Co-authored-by: David Lattimore <dml@google.com>
2020-06-29 23:33:34 +00:00
David Lattimore
867f29559f Moved new deps to CLI-only section 2020-06-30 09:31:45 +10:00
bors[bot]
e1a5bd866e
Merge #5096 #5097
5096: Fix handling of whitespace when applying SSR within macro expansions. r=matklad a=davidlattimore

I originally did replacement by passing in the full file text. Then as some point I thought I could do without it. Turns out calling .text() on a node coming from a macro expansion isn't a great idea, especially when you then try and use ranges from the original source to cut that text. The test I added here actually panics without the rest of this change (sorry I didn't notice sooner).

5097: Fix SSR prompt following #4919 r=matklad a=davidlattimore



Co-authored-by: David Lattimore <dml@google.com>
2020-06-29 16:03:10 +00:00
bors[bot]
86f1556f7c
Merge #5122
5122: Fix "Run | Debug" lens for examples r=matklad a=vsrs

Fixes #4974

Co-authored-by: vsrs <vit@conrlab.com>
2020-06-29 15:55:42 +00:00
bors[bot]
4da0a78c4e
Merge #5126
5126: Use more of FxHash* r=matklad a=lnicola

```
-rwxr-xr-x 1 me me 37917528 Jun 29 17:26 /home/me/.cargo/bin/rust-analyzer
-rwxr-xr-x 1 me me 37904056 Jun 29 18:14 /home/me/.cargo/bin/rust-analyzer
```

Saved 13.5 KB there :-).

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-29 15:39:51 +00:00
Aleksey Kladov
bbc4dc9956 Update the rest of the tests 2020-06-29 17:23:01 +02:00
Aleksey Kladov
e805e8c1d5 (T): make typification tests more data driven 2020-06-29 17:23:01 +02:00
Laurențiu Nicola
95d67ec401 Use more of FxHash* 2020-06-29 18:07:52 +03:00
bors[bot]
82ce5792ab
Merge #5124
5124: (Partially) fix handling of type params depending on type params r=matklad a=flodiebold

If the first type parameter gets inferred, that's still not handled correctly; it'll require some more refactoring: E.g. if we have `Thing<T, F=fn() -> T>` and then instantiate `Thing<_>`, that gets turned into `Thing<_, fn() -> _>` before the `_` is instantiated into a type variable -- so afterwards, we have two type variables without any connection to each other.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-06-29 14:13:41 +00:00
Florian Diebold
8e8d2ffecb (Partially) fix handling of type params depending on type params
If the first type parameter gets inferred, that's still not handled correctly;
it'll require some more refactoring: E.g. if we have `Thing<T, F=fn() -> T>` and
then instantiate `Thing<_>`, that gets turned into `Thing<_, fn() -> _>` before
the `_` is instantiated into a type variable -- so afterwards, we have two type
variables without any connection to each other.
2020-06-29 16:10:20 +02:00
vsrs
05e6cbf310 Fix "Run | Debug" lens for examples 2020-06-29 14:05:52 +03:00
David Lattimore
93a91ae9de Add a simple SSR subcommand to the rust-analyzer command line binary 2020-06-29 13:34:45 +10:00
bors[bot]
ca31b1d63a
Merge #5105
5105: Simlify with matches!() r=matklad a=Veetaha



Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-06-28 22:37:25 +00:00
Veetaha
36128c170d Get rid of unused imports 2020-06-29 01:23:39 +03:00
Veetaha
503f9498cd Follow matklad suggestions
- Move vis_offset() to utils.rs
- Shorten explicit ra_syntax::ast -> ast
- Undo refactoring exhaustive pattern to non-exhaustive
2020-06-29 01:18:50 +03:00
bors[bot]
11f31ae4c3
Merge #5114
5114: Cleanup cargo process handling in flycheck r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-28 21:43:18 +00:00
Aleksey Kladov
5cdd8d442e Cleanup cargo process handling in flycheck 2020-06-28 23:42:44 +02:00
Aleksey Kladov
32e85a1a89 More standard pattern for Cargo 2020-06-28 23:01:28 +02:00
Aleksey Kladov
eddb744d90 Naming 2020-06-28 22:35:18 +02:00
Aleksey Kladov
309b21f378 Rename 2020-06-28 22:31:40 +02:00
Florian Diebold
3fe0d73670 Update Chalk to released version 2020-06-28 21:24:20 +02:00
Aleksey Kladov
80ef52f0d5 Make sure to join the child 2020-06-28 20:00:04 +02:00
Aleksey Kladov
7cf1981a2d Don't show ra_fixture param hints 2020-06-28 13:11:41 +02:00
Veetaha
e75e2ae5b6 Simlify with matches!() 2020-06-28 04:03:59 +03:00
Aleksey Kladov
a4f934efa8
Update crates/rust-analyzer/src/handlers.rs
Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-06-28 01:23:32 +02:00
Veetaha
39a58ed19a Simplify 2020-06-28 01:30:45 +03:00
Aleksey Kladov
3c1714d76d Fix potential overflow 2020-06-27 21:35:52 +02:00
Aleksey Kladov
53787c7eba style 2020-06-27 21:33:14 +02:00
Aleksey Kladov
a9b4fb034b Add colors 2020-06-27 21:14:25 +02:00
Aleksey Kladov
175e48e5be Remove fragile test
This test needs to be updated after every change (it contains line
number), which is annoying.

It also fails on windows due to \, so it's easier to remove it.
2020-06-27 20:50:16 +02:00
Aleksey Kladov
18e4e9fb0b Update crates/expect/src/lib.rs
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-06-27 20:50:16 +02:00
Aleksey Kladov
d21dae738b Update crates/expect/src/lib.rs
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-06-27 20:50:16 +02:00
Laurențiu Nicola
f8d37ff0b2 Add support for include_bytes 2020-06-27 21:02:47 +03:00
Aleksey Kladov
be265ece02 Add example expect test for goto definition 2020-06-27 19:22:31 +02:00
Aleksey Kladov
03c5a6690d Add light-weight snapshot testing library with editor integration 2020-06-27 19:22:31 +02:00
bors[bot]
446fd3f515
Merge #5100
5100: Add support for include_str r=edwin0cheng a=lnicola

r? @edwin0cheng 

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-27 16:36:38 +00:00
Laurențiu Nicola
b4420626fb Add support for include_str 2020-06-27 19:34:48 +03:00
Paul Daniel Faria
68a649d547 Simplify unsafe expr collection match 2020-06-27 12:00:46 -04:00
Paul Daniel Faria
b7e25ba854 Improve perf of finding unsafe exprs 2020-06-27 11:55:54 -04:00
Paul Daniel Faria
b1992b469c Remove unneeded code, filename from tests, fix rebasing issues 2020-06-27 11:38:34 -04:00
Paul Daniel Faria
28bb8ed9cb Cleanup changes leftover from previous tracking attempt 2020-06-27 10:16:19 -04:00
Paul Daniel Faria
2ca52bbb32 Revert ide highlighting changes (addressing on another branch) 2020-06-27 10:16:19 -04:00
Paul Daniel Faria
2fc92fa28c Remove track_parent and parent_map, replace with simple walk in missign unsafe validator 2020-06-27 10:13:14 -04:00
Paul Daniel Faria
f78df42f81 Fix issues caused during rebase 2020-06-27 10:13:14 -04:00
Paul Daniel Faria
2608a6fd3a unsafe: Clean up, improve tracking, add debug_assert
Move unsafe_expressions to unsafe_validation.rs, replace vec tracking of
child exprs with inline macro, add debug assert to ensure tracked
children match walked children exactly
2020-06-27 10:13:14 -04:00
Paul Daniel Faria
f678e0d837 Add HighlightTag::Operator, use it for unsafe deref. Move unsafe validation to its own file 2020-06-27 10:13:14 -04:00
Paul Daniel Faria
6c1682396c Account for deref token in syntax highlighting of unsafe, add test for that case 2020-06-27 10:11:10 -04:00
Paul Daniel Faria
7f2219dc76 Track expr parents during lowering, use parent map when checking if unsafe exprs are within unsafe blocks 2020-06-27 10:10:26 -04:00
Paul Daniel Faria
9ce44be2ab Address review comments, have MissingUnsafe diagnostic point to each unsafe use, update tests 2020-06-27 10:10:26 -04:00
Paul Daniel Faria
b9569886a9 Rename Expr::UnsafeBlock to Expr::Unsafe 2020-06-27 10:10:26 -04:00
Paul Daniel Faria
278cbf12cd Track unsafe blocks, don't trigger missing unsafe diagnostic when unsafe exprs within unsafe block 2020-06-27 10:10:26 -04:00
Paul Daniel Faria
3df0f9ce7e Add missing self param to test 2020-06-27 10:09:42 -04:00
Paul Daniel Faria
c622551ec2 Fix typo in test 2020-06-27 10:09:42 -04:00
Paul Daniel Faria
499d4c454d Remove UnnecessaryUnsafe diagnostic, Fix Expr::Call unsafe analysis 2020-06-27 10:09:42 -04:00
Paul Daniel Faria
b358fbfdf8 Add tests covering unsafe blocks, more attempts to get call expr tests passing 2020-06-27 10:09:29 -04:00
Paul Daniel Faria
daf1cac9f8 Move diagnostics back into expr, add tests for diagnostics, fix logic to account for derefs of raw ptrs 2020-06-27 10:09:29 -04:00
Paul Daniel Faria
0b95bed83f Add unsafe diagnostics and unsafe highlighting 2020-06-27 10:08:14 -04:00
bors[bot]
6a067ce947
Merge #5090
5090: Bump deps r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-27 11:00:51 +00:00
Laurențiu Nicola
52a488982f Bump rustc_lexer 2020-06-27 13:56:54 +03:00
Laurențiu Nicola
d036006c95 Bump deps 2020-06-27 13:56:54 +03:00
David Lattimore
64a49589e7 Fix handling of whitespace when applying SSR within macro expansions.
I originally did replacement by passing in the full file text. Then as some point I thought I could do without it. Turns out calling .text() on a node coming from a macro expansion isn't a great idea, especially when you then try and use ranges from the original source to cut that text. The test I added here actually panics without the rest of this change (sorry I didn't notice sooner).
2020-06-27 20:38:31 +10:00
Aleksey Kladov
491d000c27 Add :: to label for crate:: completion 2020-06-27 12:26:25 +02:00
Aleksey Kladov
4e3e8d1ab2 cleanup 2020-06-27 12:07:48 +02:00
bors[bot]
18a6dd4635
Merge #4982
4982: Bump chalk r=matklad a=lnicola

This passes the tests, but fails in a weird way on `analysis-stats`:

```
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-solve-0.14.0/src/clauses/builtin_traits/fn_family.rs:96:20
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1076
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:477
  11: rust_begin_unwind
             at src/libstd/panicking.rs:385
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:86
  13: core::panicking::panic
             at src/libcore/panicking.rs:51
  14: chalk_solve::clauses::builtin_traits::fn_family::add_fn_trait_program_clauses
  15: chalk_solve::clauses::builder::ClauseBuilder<I>::push_binders
  16: chalk_solve::clauses::program_clauses_that_could_match
  17: chalk_solve::clauses::program_clauses_for_goal
  18: chalk_solve::recursive::Solver<I>::solve_new_subgoal
  19: <chalk_solve::recursive::Solver<I> as chalk_solve::recursive::solve::SolveDatabase<I>>::solve_goal
  20: chalk_solve::recursive::Solver<I>::solve_root_goal
  21: chalk_solve::solve::Solver<I>::solve_limited
  22: ra_hir_ty::traits::trait_solve_query
  23: salsa::runtime::Runtime<DB>::execute_query_implementation
  24: salsa::derived::slot::Slot<DB,Q,MP>::read_upgrade
  25: salsa::derived::slot::Slot<DB,Q,MP>::read
  26: <salsa::derived::DerivedStorage<DB,Q,MP> as salsa::plumbing::QueryStorageOps<DB,Q>>::try_fetch
  27: salsa::QueryTable<DB,Q>::get
  28: <T as ra_hir_ty::db::HirDatabase>::trait_solve
  29: ra_hir_ty::infer::InferenceContext::resolve_ty_as_possible
  30: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner
  31: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_coerce
  32: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::check_call_arguments
  33: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_method_call
  34: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner
  35: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr
  36: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_method_call
  37: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner
  38: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_coerce
  39: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner
  40: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner
  41: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_coerce
  42: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner
  43: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_coerce
  44: ra_hir_ty::infer::infer_query
  45: salsa::runtime::Runtime<DB>::execute_query_implementation
  46: salsa::derived::slot::Slot<DB,Q,MP>::read_upgrade
  47: salsa::derived::slot::Slot<DB,Q,MP>::read
  48: <salsa::derived::DerivedStorage<DB,Q,MP> as salsa::plumbing::QueryStorageOps<DB,Q>>::try_fetch
  49: ra_hir_ty::db::infer_wait
  50: rust_analyzer::cli::analysis_stats::analysis_stats
  51: rust_analyzer::main
  52: std::rt::lang_start::{{closure}}
  53: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
  54: std::panicking::try::do_call
             at src/libstd/panicking.rs:297
  55: std::panicking::try
             at src/libstd/panicking.rs:274
  56: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  57: std::rt::lang_start_internal
             at src/libstd/rt.rs:51
  58: main
  59: __libc_start_main
  60: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
```

It's as if we're returning `None` for a well-known trait that `chalk` asks about. That seems to happen for `Deref`, `CoerceUnsized` and `Try`.

r? @flodiebold

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-27 09:50:08 +00:00
bors[bot]
dd3f9eaceb
Merge #5007
5007: SSR: Allow matching within macro calls r=matklad a=davidlattimore

#3186 

Co-authored-by: David Lattimore <dml@google.com>
2020-06-27 09:43:08 +00:00
bors[bot]
656cbc68a1
Merge #5033
5033: Order of glob imports should not affect import shadowing r=Nashenas88 a=Nashenas88

Fixes #5032

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-06-27 02:51:54 +00:00
Paul Daniel Faria
1f5d30ff16 Replace simple is_named with matches macro 2020-06-26 22:51:13 -04:00
David Lattimore
fc46c12e36 Fix test following change to fixture parsing (d016cb4867) 2020-06-27 11:33:00 +10:00
David Lattimore
f4dc549582 SSR: Allow matching within macro calls 2020-06-27 11:33:00 +10:00
Aleksey Kladov
f89722f357 Better exe probing 2020-06-27 02:04:33 +02:00
Aleksey Kladov
9617bb4f07 Try to find rustfmt in more places 2020-06-27 01:28:06 +02:00
Aleksey Kladov
f5584668db introduce_variable -> extract_variable 2020-06-27 01:21:43 +02:00
bors[bot]
7488cd6a1b
Merge #5083
5083: Micro-optimize lookahead in composite tokens r=matklad a=lnicola

I'm not sure that this is measurable, but can't hurt, I guess.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-26 19:25:46 +00:00
Laurențiu Nicola
2c72d2f438 Micro-optimize lookahead in composite tokens 2020-06-26 21:47:17 +03:00
bors[bot]
e628c66359
Merge #4945
4945: do not suggest assist for return type to result in bad case  r=matklad a=bnjjj

close #4826

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-26 16:59:59 +00:00
bors[bot]
89277e7a42
Merge #5081
5081: Fix a panic with malformed inner items r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-06-26 16:12:22 +00:00
Jonas Schievink
efe378d2b4 Make find_inner_item fallible
The ItemTree does not collect incomplete items, such as traits with no
name, so the (malformed) AST node might have no corresponding item.
2020-06-26 18:07:31 +02:00
Jonas Schievink
7f6694b12e find_inner_item: more detailed panic message 2020-06-26 18:02:41 +02:00
Aleksey Kladov
91453e796b Set corret request method 2020-06-26 17:55:20 +02:00
Jonas Schievink
5d7172f17e Simplify inner item lowering 2020-06-26 17:30:27 +02:00
Aleksey Kladov
5a18734338 Fix config switching 2020-06-26 17:28:04 +02:00
bors[bot]
a0a475546b
Merge #5078
5078: Minor r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-26 15:18:04 +00:00
Aleksey Kladov
de7b248227 Minor 2020-06-26 17:17:38 +02:00
Paul Daniel Faria
b700443e78 Remove comment that's no longer valid 2020-06-26 11:13:58 -04:00
Paul Daniel Faria
76755ce176 Split glob import map to per-ns, switch ExprCollector to use a simpler push_res 2020-06-26 11:11:51 -04:00
bors[bot]
d86a2426a2
Merge #5077
5077: Type safer requests r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-26 15:08:58 +00:00
Aleksey Kladov
9d15e8fc4f Type safer requests 2020-06-26 17:07:14 +02:00
bors[bot]
fa70882418
Merge #5075
5075: Be more precise about flycheck status r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-26 15:02:00 +00:00
bors[bot]
4f60b4f2a3
Merge #5076
5076: Make VFS join methods fallible r=matklad a=jonas-schievink



Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-06-26 14:37:15 +00:00
Aleksey Kladov
1893289e5c Move progress reporting to utils 2020-06-26 16:33:57 +02:00
Jonas Schievink
72fe70f2f8 Make VFS join methods fallible 2020-06-26 16:30:50 +02:00
Aleksey Kladov
bd903bf132 Be more precise about flycheck status 2020-06-26 16:20:46 +02:00
bors[bot]
ce06f8d041
Merge #5072 #5073
5072: Cleanup r=matklad a=matklad



bors r+
🤖

5073: `iterate_method_candidates`: Address review comments r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-06-26 10:06:34 +00:00
Aleksey Kladov
12831b74af Cleanup 2020-06-26 12:06:08 +02:00
Jonas Schievink
c441306427 Address review comments 2020-06-26 12:04:11 +02:00
Laurențiu Nicola
7e104ea4a8 Bump chalk 2020-06-26 13:00:55 +03:00
Aleksey Kladov
b039f0d1ba Simplify 2020-06-26 11:44:46 +02:00
Aleksey Kladov
751b8792a2 Simplify 2020-06-26 11:43:07 +02:00
Aleksey Kladov
34118779ec Workaround use Trait as _ bug in rust-analyzer 2020-06-26 11:39:27 +02:00
Aleksey Kladov
2fd25e2d98 reduce visibility 2020-06-26 11:29:27 +02:00
Aleksey Kladov
1272e6cb88 minor 2020-06-26 11:21:21 +02:00
bors[bot]
3f2a596b9b
Merge #5066
5066: Infer type for slice wildcard patterns r=flodiebold a=adamrk

Resolves https://github.com/rust-analyzer/rust-analyzer/issues/4830

The issue is just that we were never inferring the type for the wildcard `..` in slice patterns.

Co-authored-by: adamrk <ark.email@gmail.com>
2020-06-26 08:52:22 +00:00
Aleksey Kladov
5f6f994256 Simplify 2020-06-26 00:54:41 +02:00
Aleksey Kladov
dd5841556c Smarter introduce variable
Use field init shorthand
2020-06-26 00:51:34 +02:00
Aleksey Kladov
e70f7dc10c Minor 2020-06-26 00:27:57 +02:00
Aleksey Kladov
72fb712dff Add new module for project loading stuff 2020-06-26 00:27:57 +02:00
Aleksey Kladov
3d0f782138 Prep dynamic workspace loading 2020-06-26 00:27:57 +02:00
Aleksey Kladov
73d73077fe Separate creation and initialization of global state 2020-06-26 00:27:57 +02:00
adamrk
0ebc24043b Infer type for slice wildcard patterns 2020-06-25 23:16:58 +02:00
Aleksey Kladov
df769e5bb4 Simplify diagnostics handling 2020-06-25 22:45:35 +02:00
Aleksey Kladov
86a4d4cb9c Simplify 2020-06-25 19:23:52 +02:00
Aleksey Kladov
dba11cb060 -mMake it harder to accidently early-exit the loop 2020-06-25 19:01:16 +02:00
Paul Daniel Faria
de9e964e4a Track import type outside of , use enum rather than bool to improve readability 2020-06-25 12:42:12 -04:00
bors[bot]
b5aa92bab9
Merge #5064
5064: Add NotificationDispatcher r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-25 16:29:23 +00:00
Aleksey Kladov
f5ea35a271 Add NotificationDispatcher 2020-06-25 18:28:58 +02:00
Aleksey Kladov
22098127c4 Move request dispatcher to a separate file 2020-06-25 17:22:18 +02:00
bors[bot]
ba72863452
Merge #5063
5063: Store field/variant attrs in ItemTree and use it for adt.rs queries r=jonas-schievink a=jonas-schievink



Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-06-25 15:18:35 +00:00
Aleksey Kladov
379a096de9 Refactor main_loop 2020-06-25 17:14:11 +02:00
Jonas Schievink
dad2f75b91 Use ItemTree to answer enum_data query 2020-06-25 16:52:47 +02:00
Jonas Schievink
563d585594 Use IdRange for variants 2020-06-25 16:52:15 +02:00
Jonas Schievink
b06214d164 Generalize FieldIds -> IdRange<T> 2020-06-25 16:42:59 +02:00
Jonas Schievink
2a8fc9e682 adt.rs: fetch struct/union data from item tree 2020-06-25 16:41:08 +02:00
Aleksey Kladov
dd20c2ec5b Move TaskPool into GlobalState 2020-06-25 15:35:42 +02:00
Paul Daniel Faria
0b657ddbfe Revert resolution of all glob imports first, replace with tracking of glob imports and shadowing when more specific 2020-06-25 09:27:00 -04:00
Paul Daniel Faria
70d4829560 Order of glob imports should not affect import shadowing 2020-06-25 09:23:34 -04:00
Jonas Schievink
d84b3ff6a1 Collect field/variant attrs in ItemTree 2020-06-25 14:39:27 +02:00
Aleksey Kladov
9cdeb1291e Better event naming 2020-06-25 14:13:17 +02:00
Jonas Schievink
9ba7726579 Allow iterating fields in the ItemTree 2020-06-25 13:50:27 +02:00
bors[bot]
4ec0a2c454
Merge #5056
5056: Canonicalize actor API r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-25 11:48:53 +00:00
Aleksey Kladov
331addcf61 Canonicalize actor API 2020-06-25 13:47:22 +02:00
Aleksey Kladov
394a3dbcb5 Fix matchig brace for pipes 2020-06-25 10:16:06 +02:00
Aleksey Kladov
1ccf33d88f Minor, move code 2020-06-25 09:51:30 +02:00
bors[bot]
0d2e695ffc
Merge #5050
5050: Simplify r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-25 07:28:27 +00:00
Aleksey Kladov
941d4bfa53 Simplify 2020-06-25 09:27:59 +02:00
Aleksey Kladov
5d401092f0 Minor rename 2020-06-25 09:19:01 +02:00
bors[bot]
edf8f419b5
Merge #5049
5049: Rename ra_flycheck -> flycheck r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-25 07:15:30 +00:00
Aleksey Kladov
0ec5d4f55c Rename ra_flycheck -> flycheck 2020-06-25 09:13:46 +02:00
bors[bot]
44d525d4e0
Merge #5048
5048: Unify code style for worker threads r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-25 07:01:14 +00:00
Aleksey Kladov
5a184fe855 Unify style 2020-06-25 09:00:33 +02:00
Aleksey Kladov
db58b3e063 matching brace works for | in lambdas 2020-06-25 08:49:26 +02:00
Aleksey Kladov
dab8808e82 Abstract over channel 2020-06-25 08:39:33 +02:00
Aleksey Kladov
69e6924dd5 Use Handle/Actor terminology for flycheck 2020-06-25 08:24:27 +02:00
Aleksey Kladov
874a5f80c7 Scale progress down
There are two reasons why we don't want a generic ra_progress crate
just yet:

*First*, it introduces a common interface between separate components,
and that is usually undesirable (b/c components start to fit the
interface, rather than doing what makes most sense for each particular
component).

*Second*, it introduces a separate async channel for progress, which
makes it harder to correlate progress reports with the work done. Ie,
when we see 100% progress, it's not blindly obvious that the work has
actually finished, we might have some pending messages still.
2020-06-25 08:01:03 +02:00
Aleksey Kladov
76a530242a Merge branch 'Veetaha-feat/sync-branch' 2020-06-25 07:56:47 +02:00
Aleksey Kladov
10ee6eb733 Tweak visibility 2020-06-25 01:02:08 +02:00
Aleksey Kladov
012a7e57b9 Reduce visibility 2020-06-25 01:02:08 +02:00
Aleksey Kladov
19b063e055 Merge LoopState into GlobalState 2020-06-25 01:02:04 +02:00
Aleksey Kladov
693489e5ee Flatten module hierarchy 2020-06-24 18:57:30 +02:00
Aleksey Kladov
d6c204c750 Cleanup visibility 2020-06-24 18:54:05 +02:00
bors[bot]
946b2c28a7
Merge #5038
5038: Make `iterate_method_candidates` non-generic r=jonas-schievink a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/issues/4975

bors r+ 🤖 ;)

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-06-24 15:45:39 +00:00
Jonas Schievink
cefb2204cb Make iterate_method_candidates non-generic 2020-06-24 17:45:38 +02:00
bors[bot]
7e61f4c59e
Merge #5035 #5037
5035: Less error-prone naming r=matklad a=matklad



bors r+
🤖

5037: Don't watch dirs if not asked to r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-24 15:18:13 +00:00
Aleksey Kladov
089ea36b2e Don't watch dirs if not asked to 2020-06-24 17:11:07 +02:00
Aleksey Kladov
6937bcb67d Less error-prone naming 2020-06-24 16:59:15 +02:00
Aleksey Kladov
ddc5a3e567 Fix infinite cargo check bug 2020-06-24 16:59:15 +02:00
Jonas Schievink
2928600374 Reorder items 2020-06-24 16:54:21 +02:00
Jonas Schievink
d6fd7809b0 Clean up and fix inner item collection a bit 2020-06-24 16:54:21 +02:00
Jonas Schievink
3b50b0b2b6 Use a HashMap instead of Vec
This is no longer enforcing stack discipline, so a Vec isn't necessary
or helpful
2020-06-24 16:54:21 +02:00
Jonas Schievink
59d4640b64 Remove unneeded HirFileId argument 2020-06-24 16:54:21 +02:00
Jonas Schievink
d4ddec2bdf Shrink arenas after building ItemTree 2020-06-24 16:54:21 +02:00
Jonas Schievink
94169ee504 ItemTree: Use more boxed slices 2020-06-24 16:54:21 +02:00
Jonas Schievink
abdba92334 Don't allocate empty generics 2020-06-24 16:54:21 +02:00
Jonas Schievink
43cad21623 Don't allocate common visibilities 2020-06-24 16:54:20 +02:00
Jonas Schievink
16fd4dabb7 Remove file id from item tree
It's not needed, and `source` is only used by tests anyways
2020-06-24 16:53:56 +02:00
Jonas Schievink
c019002d17 Slightly reduce ItemTree memory footprint 2020-06-24 16:53:56 +02:00
Jonas Schievink
f9a1a9cd3c Merge item tree traits
The Source trait isn't needed anymore since we no longer merge
extern crate items with use items.
2020-06-24 16:53:56 +02:00
Jonas Schievink
b5fd02d93c Generate ModItem via macro 2020-06-24 16:53:56 +02:00
Jonas Schievink
20ff1cdcfb Address more comments 2020-06-24 16:53:56 +02:00
Jonas Schievink
a0ad457575 if let else -> match 2020-06-24 16:53:56 +02:00
Jonas Schievink
ae7a296c85 Unify and test attribute handling 2020-06-24 16:53:56 +02:00
Jonas Schievink
689e147c9d Collect inner items in expression macros 2020-06-24 16:53:54 +02:00
Jonas Schievink
5a81427304 Measure ItemTree query memory usage 2020-06-24 16:53:16 +02:00
Jonas Schievink
ffa0435050 Make generics and attr queries use ItemTree
Now it's fast
2020-06-24 16:53:16 +02:00
Jonas Schievink
19586bc5c6 Record HirFileId's in profiler 2020-06-24 16:53:16 +02:00
Jonas Schievink
1fbe21a545 Make remaining item data queries use item tree 2020-06-24 16:53:16 +02:00
Jonas Schievink
4b03b39d5b draw the rest of the owl 2020-06-24 16:53:16 +02:00
Jonas Schievink
b94caeb88b ItemTree: Make clonable and add AST access 2020-06-24 16:53:16 +02:00
Jonas Schievink
c12f7b610b Lower generics 2020-06-24 16:53:16 +02:00
Jonas Schievink
864b650f92 ItemTree: use a newtyped ID 2020-06-24 16:53:16 +02:00
Jonas Schievink
278556f9fe Move ItemTree lowering into its own module 2020-06-24 16:53:16 +02:00
Jonas Schievink
f9e5ba7d40 Remove now-broken incremental test
The ItemTree tracks impl and trait items, so the CrateDefMap now needs
recomputing when those change
2020-06-24 16:53:16 +02:00
Jonas Schievink
0e2602f75e Remove raw item query 2020-06-24 16:53:16 +02:00
Jonas Schievink
7054e89d18 Fix test 2020-06-24 16:53:16 +02:00
Jonas Schievink
9d24412929 Move collector 2020-06-24 16:53:14 +02:00
Jonas Schievink
f9417bcf49 Draw the rest of the owl 2020-06-24 16:52:37 +02:00
Jonas Schievink
e24de2007f collector changes WIP 2020-06-24 16:52:37 +02:00
Jonas Schievink
696a7a5a41 lower traits 2020-06-24 16:52:37 +02:00
Jonas Schievink
34bc80650b Hook up query, add impls, lower moar 2020-06-24 16:52:37 +02:00
Aleksey Kladov
1d75d11d6c Start item tree 2020-06-24 16:52:37 +02:00
Aleksey Kladov
e6c61d5072 Cleanup project.json deserialization 2020-06-24 16:16:52 +02:00
Aleksey Kladov
a07cad16ab Rename json_project -> project_json 2020-06-24 16:03:24 +02:00
bors[bot]
97c4d06258
Merge #5015 #5027 #5028
5015: Account for updated module ids when determining whether a resolution is changed r=matklad a=Nashenas88

Fixes #4943

5027: Make Debug less verbose for VfsPath and use Display in analysis-stats r=matklad a=lnicola



5028: Remove namedExports config r=matklad a=lnicola

Fixes a warning:

```
(!) Plugin commonjs: The namedExports option from "@rollup/plugin-commonjs" is deprecated. Named exports are now handled automatically.
```

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-24 13:02:37 +00:00
Paul Daniel Faria
43c6f6c039 Fix formatting issue with glob shadow test 2020-06-24 08:50:59 -04:00
Aleksey Kladov
154cb8243b Be more explicit about absolute paths at various places 2020-06-24 14:39:34 +02:00
Paul Daniel Faria
dfd79907b8 Use a macro in push_res to simplify code, simplify glob_shadowed_def assertion 2020-06-24 08:20:41 -04:00
Laurențiu Nicola
c15c22139f Make Debug less verbose for VfsPath and use Display in analysis-stats 2020-06-24 14:07:03 +03:00
bors[bot]
dff62def2e
Merge #5023
5023: Fix string literal inference in match r=flodiebold a=lnicola

Fixes #5020 

r? @flodiebold 

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-24 10:40:47 +00:00
bors[bot]
414b731e7d
Merge #5024 #5026
5024: Simplify r=matklad a=matklad



bors r+
🤖

5026: Disable file watching when running slow tests r=matklad a=matklad

This should rid us of the intermittent test failure

https://github.com/rust-analyzer/rust-analyzer/pull/5017#issuecomment-648717983



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-24 10:31:20 +00:00
Aleksey Kladov
0a2b6087ec Simplify 2020-06-24 12:30:54 +02:00
Aleksey Kladov
a0b76161ab Disable file watching when running slow tests
This should rid us of the intermittent test failure

https://github.com/rust-analyzer/rust-analyzer/pull/5017#issuecomment-648717983
2020-06-24 12:27:13 +02:00
Laurențiu Nicola
2bd9f0f020 Fix string literal inference in match 2020-06-24 13:20:06 +03:00
Aleksey Kladov
5e7a1a1203 Simplify 2020-06-24 12:01:17 +02:00
Aleksey Kladov
04fe512f0d Simplify 2020-06-24 11:51:45 +02:00
Aleksey Kladov
9d64525daa Simplify 2020-06-24 11:50:53 +02:00
Aleksey Kladov
d4a493078a Simplify 2020-06-24 11:48:44 +02:00
Aleksey Kladov
c749fe223b Remove duplication 2020-06-24 11:31:30 +02:00
Aleksey Kladov
c6795fb83a More consistent usage of fixtures 2020-06-24 11:29:43 +02:00
Aleksey Kladov
e9cb818c26 Use fixtures more 2020-06-24 11:05:47 +02:00
Aleksey Kladov
08e2149eab Simplify 2020-06-24 10:28:28 +02:00
bors[bot]
c544f9a137
Merge #4940
4940: Add support for marking doctest items as distinct from normal code r=ltentrup a=Nashenas88

This adds `HighlightTag::Generic | HighlightModifier::Injected` as the default highlight for all elements within a doctest. Please feel free to suggest that a new tag be created or a different one used.

![Screenshot from 2020-06-23 09-18-13](https://user-images.githubusercontent.com/1673130/85408493-9752ce00-b532-11ea-94fe-197353ccc778.png)

Fixes #4929 
Fixes #4939

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
Co-authored-by: Paul Daniel Faria <nashenas88@users.noreply.github.com>
2020-06-24 05:22:23 +00:00
Paul Daniel Faria
38af81f183 Account for updated module ids when determining whether a resolution is "changed" 2020-06-23 22:10:01 -04:00
Paul Daniel Faria
0d87eee3a9 Improve readability be replacing hard-to-read if-else branches with a match 2020-06-23 19:35:09 -04:00
Aleksey Kladov
d016cb4867 Use only one code-path for parsing fixtures
This removes leading newlines everywhere, shifting all ranges in tests
by one
2020-06-24 00:48:38 +02:00
Aleksey Kladov
e5101ae150 Centralize fixture parsing for assists 2020-06-24 00:30:34 +02:00
Aleksey Kladov
7ce122b1df Remove useless test code 2020-06-23 23:45:40 +02:00
Aleksey Kladov
aa69757a01 More principled indentation trimming in fixtures 2020-06-23 23:33:41 +02:00
Aleksey Kladov
f2f69e75c8 Minor, rename 2020-06-23 22:51:33 +02:00
Aleksey Kladov
ff687453a8 Slightly better name 2020-06-23 21:29:50 +02:00
Aleksey Kladov
295c8d4f7f Complicate
Fixing test fallout unfortunately requires more work, we need to do
it, but let's merge something at least!
2020-06-23 20:38:36 +02:00
Aleksey Kladov
a34f9b7fb3 Docs for Fixture 2020-06-23 18:58:45 +02:00
Aleksey Kladov
84cd28fddc Cut problematic dependency 2020-06-23 18:56:26 +02:00
Aleksey Kladov
fdf86aee18 Nicer API 2020-06-23 18:46:56 +02:00
Aleksey Kladov
3486b47e5c Simplify 2020-06-23 18:43:55 +02:00
Paul Daniel Faria
a8a606cdc4 Remove unrelated change 2020-06-23 12:40:55 -04:00
Aleksey Kladov
21f751a0e5 Simplify 2020-06-23 18:37:26 +02:00
Aleksey Kladov
30748161f0 Simplify 2020-06-23 18:37:26 +02:00
Aleksey Kladov
6996ec860b Drop rarely used fixture functionality 2020-06-23 18:37:26 +02:00
Aleksey Kladov
f304874c8c Move fixtures to a separate file 2020-06-23 18:37:26 +02:00
Paul Daniel Faria
1e9095ae8c
Update comment for pop_and_inject
Co-authored-by: Leander Tentrup <ltentrup@users.noreply.github.com>
2020-06-23 12:15:45 -04:00
Paul Daniel Faria
2a56323537 Update injection mechanism and stop injecting through highlight element, switch to more general new highlight tag, generic 2020-06-23 12:13:50 -04:00
Paul Daniel Faria
d8230acd84 Add punctuation highlighting for highlighting punctuation in doctests, fix highlighting in doctests 2020-06-23 12:11:33 -04:00
Paul Daniel Faria
e137d9accb Add default color and opacity for documentation and injected, respectively, in the html generator 2020-06-23 12:08:04 -04:00
Paul Daniel Faria
351bba9bee Add support for marking doctest items as distinct from normal code, add default tag to all doctest elements 2020-06-23 12:08:04 -04:00
Aleksey Kladov
dad1333b48 New VFS 2020-06-23 17:51:06 +02:00
bors[bot]
7aa66371ee
Merge #5010
5010: Remove relative-path dependency r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-23 15:04:42 +00:00
Aleksey Kladov
676e82bb83 Remove relative-path dependency 2020-06-23 17:04:10 +02:00
bors[bot]
c0b9ae5503
Merge #5004
5004: Fix panic in split/merge import assists r=matklad a=lnicola

Fixes #4368 #4905

Not sure if this is the best solution here. Maybe the `make` functions should be fallible? We generally seem to be playing whack-a-mole with panics in assists, although most of them are `unwrap`s in the assist code.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-23 14:55:03 +00:00
Laurențiu Nicola
76ddface08 Fix panic in split and merge import assists 2020-06-23 16:51:07 +03:00
bors[bot]
3e09dbba94
Merge #5002
5002: Fix underflow panic when doctests are at top of file r=Nashenas88 a=Nashenas88

While debugging a comment at the top of a test string, I discovered that the offset calculations could underflow and panic. This only seemed to occur in tests, I assume because it's running a debug mode. The wrapping is quickly fixed later on in release mode, which is why this seems to have gone unnoticed. The new checks ensure the value is always positive or zero.

Co-authored-by: Paul Daniel Faria <nashenas88@users.noreply.github.com>
2020-06-23 13:25:43 +00:00
bors[bot]
338b229b79
Merge #4999
4999: SSR: Allow matching of whole macro calls r=matklad a=davidlattimore

Matching within macro calls is to come later and matching of macro calls within macro calls later still.

Co-authored-by: David Lattimore <dml@google.com>
2020-06-23 10:02:59 +00:00
Paul Daniel Faria
0b971625c3 Fix underflow panic when doctests are at top of file 2020-06-22 22:29:08 -04:00
bors[bot]
98c3e4e887
Merge #5000
5000: Remove RelativePathBuf from fixture r=matklad a=matklad

The paths in fixture are not really relative (the default one is
`/main.rs`), so it doesn't make sense to use `RelativePathBuf` here.



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-22 22:15:22 +00:00
Aleksey Kladov
6a6098d4c3 Remove RelativePathBuf from fixture
The paths in fixture are not really relative (the default one is
`/main.rs`), so it doesn't make sense to use `RelativePathBuf` here.
2020-06-23 00:14:44 +02:00
David Lattimore
467af611fb SSR: Allow matching of whole macro calls
Matching within macro calls is to come later and matching of macro calls within macro calls later still.
2020-06-23 07:42:34 +10:00
bors[bot]
eabbeec14c
Merge #4988
4988: Don't offer to add missing fields of unknown types r=flodiebold a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-22 15:47:22 +00:00
Laurențiu Nicola
acc2819c10 Don't offer to add missing fields of unknown types 2020-06-22 18:16:00 +03:00
bors[bot]
87615166af
Merge #4900
4900: Self variant enum res fix r=BGluth a=BGluth

Fixes #4789.

This is my first PR for this project, so it's probably worth giving it an extra close look.

A few things that I wasn't sure about:
- Is `resolve_path` really the best place to perform this check? It seemed like a natural place, but perhaps there's a better place?
- When handling the new variant `PathResolution::VariantDef`, I couldn't see an obvious variant of `TypeNs` to return in `in_type_ns` for Unions and Structs.

Co-authored-by: BGluth <gluthb@gmail.com>
2020-06-22 14:37:45 +00:00
BGluth
bdf7e70820 Enum variants with Self::[variant] now resolve (#4879) 2020-06-22 08:28:53 -06:00
Aleksey Kladov
7c9f97ecb8 Add paths::RelPath[Buf] 2020-06-22 15:03:37 +02:00
bors[bot]
d8842e89e9
Merge #4899
4899: don't complete top level attrs inside nested attrs and add better labels r=matklad a=bnjjj

close #4890

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-22 12:13:18 +00:00
bors[bot]
d144d69d2e
Merge #4921
4921: Allow SSR to match type references, items, paths and patterns r=davidlattimore a=davidlattimore

Part of #3186

Co-authored-by: David Lattimore <dml@google.com>
2020-06-22 11:50:34 +00:00
David Lattimore
662ab2ecc8 Allow SSR to match type references, items, paths and patterns
Part of #3186
2020-06-22 21:42:55 +10:00
Benjamin Coenen
5aad6c9fa6 don't complete top level attrs inside nested attrs and add better labels #4899
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-22 13:39:05 +02:00
bors[bot]
19701b39ac
Merge #4928
4928: Fix renaming mod in use tree r=matklad a=unexge

Fixes #4825

Co-authored-by: unexge <unexge@gmail.com>
2020-06-22 11:19:09 +00:00
BGluth
3a3b40a554 Created goto Self enum variant test 2020-06-21 13:27:16 -06:00
Benjamin Coenen
3df879f139 don't complete top level attrs inside nested attrs and add better labels #4899
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-21 19:14:08 +02:00
Benjamin Coenen
9342574097 do not suggest assist for return type to result in bad case #4826
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-21 18:47:27 +02:00
Jeremy Kolb
a120ceed19 Update test for new serde 2020-06-21 12:10:50 -04:00
Jonas Schievink
500d8b2f60 Handle bindings after @ in patterns 2020-06-21 15:19:38 +02:00
bors[bot]
6d0a765d34
Merge #4962
4962: Implement APIs for parsing expressions, types, paths, patterns and items r=davidlattimore a=davidlattimore



Co-authored-by: David Lattimore <dml@google.com>
2020-06-21 12:37:29 +00:00
David Lattimore
bc99e95d7d Implement APIs for parsing expressions, types, paths, patterns and items 2020-06-21 22:28:17 +10:00
bors[bot]
50dad50188
Merge #4959
4959: Syntax highlighting for documentation comments on macro definitions r=matklad a=ltentrup

Two minor changes with regards to syntax highlighting of comments attached to macro definitions.

Before
<img width="290" alt="Bildschirmfoto 2020-06-20 um 00 05 19" src="https://user-images.githubusercontent.com/201808/85182705-c561b500-b289-11ea-944e-0bdf6508a44f.png">

After
<img width="288" alt="Bildschirmfoto 2020-06-20 um 00 03 36" src="https://user-images.githubusercontent.com/201808/85182727-d90d1b80-b289-11ea-9d2d-234731f19302.png">
Fixes #4949

Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
2020-06-21 12:05:16 +00:00
bors[bot]
04d64267de
Merge #4947
4947: Replace `impls_in_trait` query with smarter use of `CrateImplDefs` r=matklad a=jonas-schievink

`impls_in_trait` was allocating a whopping ~400 MB of RAM when running analysis-stats on r-a itself.

Remove it, instead adding a query that computes a summary `CrateImplDefs` map for all transitive dependencies. This can probably still be made more efficient, but this already reduces the peak memory usage by 25% without much performance impact on analysis-stats.

**Before**:

```
Total: 34.962107188s, 2083mb allocated 2141mb resident
   422mb ImplsForTraitQuery (deps)
   250mb CrateDefMapQueryQuery
   147mb MacroArgQuery
   140mb TraitSolveQuery (deps)
    68mb InferQueryQuery (deps)
    62mb ImplDatumQuery (deps)
```

**After**:

```
Total: 35.261100358s, 1520mb allocated 1569mb resident
   250mb CrateDefMapQueryQuery
   147mb MacroArgQuery
   144mb TraitSolveQuery (deps)
    68mb InferQueryQuery (deps)
    61mb ImplDatumQuery (deps)
    45mb BodyQuery
    45mb ImplDatumQuery
```

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-06-20 22:14:21 +00:00
Aleksey Kladov
f3cf85ab48 Move ReqQueue to lsp-server 2020-06-20 23:24:16 +02:00
bors[bot]
b575b02449
Merge #4961
4961: Centralize handing of in-flight requests r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-20 19:39:41 +00:00
bors[bot]
c8557b91a3
Merge #4958
4958: Infer FnSig via Fn traits r=flodiebold a=adamrk

Addresses https://github.com/rust-analyzer/rust-analyzer/issues/4481.
When inferring types check if the callee implements one of the builtin `Fn` traits. Also autoderef the callee before trying to figure out it's `FnSig`. 

Co-authored-by: adamrk <ark.email@gmail.com>
2020-06-20 15:10:35 +00:00
adamrk
1629fb770e Push obligation instead of matching on solution 2020-06-20 17:00:57 +02:00
Aleksey Kladov
93605c49ba Centralize handing of in-flight requests 2020-06-20 13:06:11 +02:00
adamrk
d8f5192d99 Get Output assoc type by name 2020-06-20 11:53:55 +02:00
adamrk
f07338bae2 Add test for dyn Fn Output 2020-06-20 11:43:40 +02:00