Commit graph

7952 commits

Author SHA1 Message Date
Aleksey Kladov
91781c7ce8 Rename TypeArgList -> GenericArgList 2020-07-31 18:29:29 +02:00
Aleksey Kladov
54fd09a9ca Finalize Path grammar 2020-07-31 18:27:23 +02:00
Aleksey Kladov
7980a7e19a Minor 2020-07-31 18:10:46 +02:00
Aleksey Kladov
633aace411 Rename LambdaExpr -> ClosureExpr 2020-07-31 17:08:58 +02:00
Aleksey Kladov
bfcee63e75 Work on expressions grammar 2020-07-31 16:52:08 +02:00
Aleksey Kladov
d4d986c7f8 Item is a Stmt 2020-07-31 15:51:01 +02:00
Aleksey Kladov
a7ca6583fb Handwrite Stmt 2020-07-31 15:40:48 +02:00
Aleksey Kladov
4d38b0dce1 Move Stmt Grammar 2020-07-31 15:27:40 +02:00
Aleksey Kladov
b250ae6c55 Finalize TypeBound grammar 2020-07-31 15:01:18 +02:00
Aleksey Kladov
a6527ed92c "Finalize" Types grammar
Note that `for` type is rust-analyzer's own invention.
Both the reference and syn allow `for` only for fnptr types, and we
allow them everywhere. This needs to be checked with respect to type
bounds grammar...
2020-07-31 14:40:28 +02:00
Aleksey Kladov
a6e45c6c69 Reame PlaceholderType -> InferType 2020-07-31 14:12:51 +02:00
Aleksey Kladov
08ea2271e8 Rename TypeRef -> Type
The TypeRef name comes from IntelliJ days, where you often have both
type *syntax* as well as *semantical* representation of types in
scope. And naming both Type is confusing.

In rust-analyzer however, we use ast types as `ast::Type`, and have
many more semantic counterparts to ast types, so avoiding name clash
here is just confusing.
2020-07-31 12:14:37 +02:00
bors[bot]
6b7cb8b5ab
Merge #5596
5596: Add checkOnSave.noDefaultFeatures and correct, how we handle some cargo flags. r=clemenswasser a=clemenswasser

This PR adds the `rust-analyzer.checkOnSave.noDefaultFeatures` option
and fixes the handling of `cargo.allFeatures`, `cargo.noDefaultFeatures` and `cargo.features`.
Fixes: #5550 

Co-authored-by: Clemens Wasser <clemens.wasser@gmail.com>
2020-07-30 21:23:41 +00:00
bors[bot]
7d18109af4
Merge #5615
5615: simplify r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 20:58:20 +00:00
Aleksey Kladov
848f446a5a simplify 2020-07-30 22:56:43 +02:00
bors[bot]
43d8142214
Merge #5614
5614: Use split_once polyfill r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 20:38:58 +00:00
Aleksey Kladov
cd9f863b01 Use CmdArgs pattern for bench & analysis stats 2020-07-30 22:38:24 +02:00
Aleksey Kladov
be49547b44 Use split_once polyfill 2020-07-30 22:23:12 +02:00
bors[bot]
08d18e0edd
Merge #5610
5610: Bump deps r=flodiebold a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-07-30 20:10:07 +00:00
Laurențiu Nicola
797cdb00d9 Bump chalk 2020-07-30 23:09:07 +03:00
Aleksey Kladov
f95f425ae4 Use ty to access most TypeRefs 2020-07-30 21:02:55 +02:00
Aleksey Kladov
2e2642efcc Remove TypeAscriptionOwner 2020-07-30 20:51:43 +02:00
Aleksey Kladov
fbe60a2e28 simplify 2020-07-30 20:38:15 +02:00
Aleksey Kladov
fcce07d2d1 Finalize attribute grammar 2020-07-30 20:21:32 +02:00
Laurențiu Nicola
fa64817eab Bump perf-event and rustc_lexer 2020-07-30 20:36:03 +03:00
Laurențiu Nicola
a94c564ad0 Fix typo 2020-07-30 20:19:37 +03:00
bors[bot]
e28ea81b2b
Merge #5609
5609: Attrs & Vis r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 17:11:26 +00:00
Aleksey Kladov
01d6c3836b Dead code 2020-07-30 19:10:46 +02:00
bors[bot]
bc8610e2b5
Merge #5608
5608: Introduce GenericParam r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 16:52:59 +00:00
Aleksey Kladov
3dce34aaf8 Introduce GenericParam 2020-07-30 18:52:02 +02:00
bors[bot]
af8132e610
Merge #5607
5607: Finaize item grammar r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 16:39:40 +00:00
Aleksey Kladov
917c89c103 Finaize item grammar 2020-07-30 18:37:46 +02:00
bors[bot]
0f5805541b
Merge #5606
5606: Finalize impl Grammar r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 16:29:24 +00:00
Aleksey Kladov
c5798c4d75 Finalize impl Grammar 2020-07-30 18:28:28 +02:00
Aleksey Kladov
c83467796b Finalize Trait grammar 2020-07-30 18:17:28 +02:00
bors[bot]
c8e2d67dd4
Merge #5594 #5604 #5605
5594: Update sysroot crates r=jonas-schievink a=lnicola



5604: Rename EnumVariant -> Variant r=matklad a=matklad



bors r+
🤖

5605: fmt r=matklad a=matklad



bors r+
🤖

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 16:13:58 +00:00
Aleksey Kladov
ba71f05438 fmt 2020-07-30 18:10:07 +02:00
Aleksey Kladov
3cd4112bdc Finalize const&static grammar 2020-07-30 18:02:20 +02:00
Aleksey Kladov
1766aae145 Rename EnumVariant -> Variant 2020-07-30 17:56:53 +02:00
Aleksey Kladov
609680ef97 Rename EnumDef -> Enum 2020-07-30 17:52:53 +02:00
Aleksey Kladov
216a5344c8 Rename StructDef -> Struct 2020-07-30 17:50:40 +02:00
Aleksey Kladov
1ae4721c9c Finalize union grammar 2020-07-30 17:38:52 +02:00
Aleksey Kladov
8ddbf06e39 Finalize structs grammar 2020-07-30 17:24:07 +02:00
bors[bot]
a257fd06b3
Merge #5597
5597: Rename FieldDef -> Field r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 14:49:39 +00:00
Aleksey Kladov
0a9e3ccc26 Rename FieldDef -> Field 2020-07-30 16:49:13 +02:00
Clemens Wasser
2e562c158f ra_project_model: Fix configuration of features
This commit fixes the handling of user-defined configuration
of some cargo options. Previously you could either specify
`--all-features`, `--no-default-features` or `--features`.
Now you can specify either `--all-features` or `--no-default-features`
and `--features`. This commit also corrects the `--features`
command-line argument creation inside of `load_extern_resources`.
2020-07-30 16:28:29 +02:00
bors[bot]
282702c287
Merge #5595
5595: Rename RecordLit -> RecordExpr r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 14:24:20 +00:00
Aleksey Kladov
6f8aa75329 Rename RecordLit -> RecordExpr 2020-07-30 16:21:30 +02:00
Laurențiu Nicola
afd02461bc Update sysroot crates 2020-07-30 17:17:59 +03:00
Clemens Wasser
8d9f8ac273 flycheck: Added checkOnSave.noDefaultFeatures
This commit adds the option
`rust-analyzer.checkOnSave.noDefaultFeatures`
and fixes #5550.
2020-07-30 16:04:01 +02:00
bors[bot]
323fd64abd
Merge #5593
5593: Code shuffle resiliently r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 13:49:02 +00:00
Aleksey Kladov
d061ab6c8e Code shuffle resiliently 2020-07-30 15:48:35 +02:00
bors[bot]
97fb5daf72
Merge #5592
5592: Rename TypeParamList -> GenericParamList r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 13:39:55 +00:00
Aleksey Kladov
28ef4c375a Rename TypeParamList -> GenericParamList 2020-07-30 15:36:21 +02:00
bors[bot]
ee00679331
Merge #5591
5591: Rename TypeAliasDef -> TypeAlias r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 13:26:15 +00:00
Aleksey Kladov
eb2f806344 Rename TypeAliasDef -> TypeAlias 2020-07-30 15:25:46 +02:00
Aleksey Kladov
1142112c70 Rename FnDef -> Fn 2020-07-30 15:16:05 +02:00
bors[bot]
96c3ff1c57
Merge #5588
5588: Print errors when failing to create a perf counter r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 12:34:38 +00:00
Aleksey Kladov
3e1e6227ca Print errors when failing to create a perf counter 2020-07-30 14:34:11 +02:00
bors[bot]
5844dd0bb4
Merge #5586
5586: Add workaround for changing sysroot paths r=jonas-schievink a=lnicola

Fixes #5577

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-07-30 12:26:04 +00:00
Aleksey Kladov
b6b77d1396 Update tests 2020-07-30 14:20:33 +02:00
Aleksey Kladov
b1332670c7 Rename UseItem -> Use 2020-07-30 14:20:33 +02:00
Aleksey Kladov
e381c02ef3 Add comma list to use tree 2020-07-30 14:20:33 +02:00
bors[bot]
51b18ee2f1
Merge #5587
5587: Finish use grammar r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 12:18:41 +00:00
Aleksey Kladov
02cac962e1 Update tests 2020-07-30 14:18:12 +02:00
Aleksey Kladov
9697d23cbe Rename UseItem -> Use 2020-07-30 14:12:04 +02:00
Aleksey Kladov
35e7966ebe Add comma list to use tree 2020-07-30 14:06:39 +02:00
Laurențiu Nicola
a538e0fbe8 Add workaround for changing sysroot paths 2020-07-30 15:04:41 +03:00
bors[bot]
9042009b7f
Merge #5567
5567: SSR: Wrap placeholder expansions in parenthesis when necessary r=matklad a=davidlattimore

e.g. `foo($a) ==> $a.to_string()` should produce `(1 + 2).to_string()` not `1 + 2.to_string()`

We don't yet try to determine if the whole replacement needs to be wrapped in parenthesis. That's harder and I think perhaps less often an issue.

Co-authored-by: David Lattimore <dml@google.com>
2020-07-30 11:36:50 +00:00
Aleksey Kladov
96313283cd Update tests 2020-07-30 12:33:05 +02:00
David Lattimore
fa1e411322 SSR: Wrap placeholder expansions in parenthesis when necessary
e.g. `foo($a) ==> $a.to_string()` should produce `(1 + 2).to_string()`
not `1 + 2.to_string()`

We don't yet try to determine if the whole replacement needs to be
wrapped in parenthesis. That's harder and I think perhaps less often an
issue.
2020-07-30 20:32:01 +10:00
Aleksey Kladov
d032f872b6 Finish extern crates grammar 2020-07-30 12:31:07 +02:00
bors[bot]
570fdf26c9
Merge #5584
5584: Rename metric r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-30 10:12:58 +00:00
Aleksey Kladov
5cb3d527b0 Rename metric 2020-07-30 12:04:01 +02:00
Aleksey Kladov
026e4e6af1 Update tests 2020-07-30 12:01:14 +02:00
Aleksey Kladov
6cd2131caf Rename Rename 2020-07-30 11:58:41 +02:00
Aleksey Kladov
7d09e5ed61 Finish Module grammar 2020-07-30 11:50:56 +02:00
Aleksey Kladov
081f35fe1b Update tests 2020-07-30 11:50:56 +02:00
Aleksey Kladov
2984da672e Split ItemList & AssocItemList 2020-07-30 11:50:56 +02:00
Aleksey Kladov
f22af66c37 Fixes 2020-07-30 10:43:47 +02:00
Aleksey Kladov
5e498546e8 Fix non-linux compilation 2020-07-30 10:40:55 +02:00
Aleksey Kladov
e9983f98a9 Do not show progress with parallel analysis 2020-07-30 10:30:01 +02:00
Aleksey Kladov
7204374719 Report instructions in addition to time
They hopefully will be more stable on CI
2020-07-30 10:23:32 +02:00
Aleksey Kladov
4bab553029 fix cast 2020-07-30 10:14:35 +02:00
Aleksey Kladov
afab67e69c Allow negative bytes
Gotta be optimistic about those memory usage optimizations
2020-07-30 09:57:36 +02:00
Aleksey Kladov
dae99b6661 Drop resident from memory usage 2020-07-30 09:45:20 +02:00
bors[bot]
9da454bcc2
Merge #5578
5578: Rename ModuleItem -> Item r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-29 22:48:04 +00:00
Aleksey Kladov
ede5d17b04 Finish SourceFile grammar 2020-07-30 00:46:39 +02:00
Aleksey Kladov
6636f56e79 Rename ModuleItem -> Item 2020-07-30 00:23:03 +02:00
bors[bot]
4567ae575e
Merge #5554
5554: Fix remove_dbg r=matklad a=petr-tik

Closes #5129 

Addresses two issues:
- keep the parens from dbg!() in case the call is chained or there is
semantic difference if parens are excluded
- Exclude the semicolon after the dbg!(); by checking if it was
accidentally included in the macro_call

investigated, but decided against:
fix ast::MacroCall extraction to never include semicolons at the end -
this logic lives in rowan.

Defensively shorten the macro_range if there is a semicolon token.
Deleted unneccessary temp variable macro_args

Renamed macro_content to "paste_instead_of_dbg", because it isn't a
simple extraction of text inside dbg!() anymore

Co-authored-by: petr-tik <petr-tik@users.noreply.github.com>
2020-07-29 21:59:03 +00:00
bors[bot]
bd5d236724
Merge #5563
5563: Check all targets for package-level tasks r=matklad a=SomeoneToIgnore

When invoking "Select Runnable" with the caret on a runnable with a specific target (test, bench, binary), append the corresponding argument for the `cargo check -p` module runnable.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-07-29 21:51:49 +00:00
petr-tik
6ea393a8d1 Addressed code review
replaced match with let-if variable assignment
removed the unnecessary semicolon_on_end variable
converted all code and expected test variables to raw strings
and inlined them in asserts
2020-07-29 22:12:53 +01:00
kjeremy
e51d1ddf5b cargo_metadata 0.11.1 and cargo update 2020-07-29 17:06:56 -04:00
Aleksey Kladov
63de7bbb5b
Update crates/rust-analyzer/src/cli/analysis_stats.rs
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-07-29 19:56:54 +02:00
Aleksey Kladov
ba585309ec Replace rand with oorandom 2020-07-29 19:49:10 +02:00
Aleksey Kladov
76202a2c73 Rename NomialDef -> AdtDef 2020-07-29 19:22:15 +02:00
Aleksey Kladov
3d28292157 Switch to ungrammar from ast_src
The primary advantage of ungrammar is that it (eventually) allows one
to describe concrete syntax tree structure -- with alternatives and
specific sequence of tokens & nodes.

That should be re-usable for:

* generate `make` calls
* Rust reference
* Hypothetical parser's evented API

We loose doc comments for the time being unfortunately. I don't think
we should add support for doc comments to ungrammar -- they'll make
grammar file hard to read. We might supply docs as out-of band info,
or maybe just via a reference, but we'll think about that once things
are no longer in flux
2020-07-29 19:18:25 +02:00
Aleksey Kladov
0d1357be05 Dead code 2020-07-29 17:35:12 +02:00
Aleksey Kladov
9fb1624c5e Remove dead code 2020-07-29 15:46:47 +02:00
Aleksey Kladov
dc18ff51c3 Remove dead code 2020-07-29 15:12:19 +02:00
Kirill Bulatov
85d71f4dff Run package-specific cargo check and test for all targets 2020-07-29 15:35:27 +03:00
bors[bot]
9a9ddcc297
Merge #5564
5564: SSR: Restrict to current selection if any r=davidlattimore a=davidlattimore

The selection is also used to avoid unnecessary work, but only to the file level. Further restricting unnecessary work is left for later.

Co-authored-by: David Lattimore <dml@google.com>
2020-07-29 09:23:33 +00:00
David Lattimore
fcb6b166fb SSR: Rename position and lookup_context to resolve_context 2020-07-29 19:20:40 +10:00
bors[bot]
04d2b7b256
Merge #5565
5565: SSR: Don't mix non-path-based rules with path-based r=matklad a=davidlattimore

If any rules contain paths, then we reject any rules that don't contain paths. Allowing a mix leads to strange semantics, since the path-based rules only match things where the path refers to semantically the same thing, whereas the non-path-based rules could match anything. Specifically, if we have a rule like `foo ==>> bar` we only want to match the `foo` that is in the current scope, not any `foo`. However "foo" can be parsed as a pattern (BIND_PAT -> NAME -> IDENT). Allowing such a rule through would result in renaming everything called `foo` to `bar`. It'd also be slow, since without a path, we'd have to use the slow-scan search mechanism.

Co-authored-by: David Lattimore <dml@google.com>
2020-07-29 08:55:34 +00:00
David Lattimore
3600c43f49 SSR: Don't mix non-path-based rules with path-based
If any rules contain paths, then we reject any rules that don't contain paths. Allowing a mix leads to strange semantics, since the path-based rules only match things where the path refers to semantically the same thing, whereas the non-path-based rules could match anything. Specifically, if we have a rule like `foo ==>> bar` we only want to match the `foo` that is in the current scope, not any `foo`. However "foo" can be parsed as a pattern (BIND_PAT -> NAME -> IDENT). Allowing such a rule through would result in renaming everything called `foo` to `bar`. It'd also be slow, since without a path, we'd have to use the slow-scan search mechanism.
2020-07-29 16:01:00 +10:00
David Lattimore
cf55806257 SSR: Restrict to current selection if any
The selection is also used to avoid unnecessary work, but only to the
file level. Further restricting unnecessary work is left for later.
2020-07-29 15:06:58 +10:00
Kirill Bulatov
bb1ae85ed0 Allow running more tests at once 2020-07-29 01:03:19 +03:00
Aleksey Kladov
b10e437039 Fix nameref parsing 2020-07-28 20:59:48 +02:00
Aleksey Kladov
97d309ea4b Bump test timeout for macs 2020-07-28 10:31:08 +02:00
petr-tik
6ea28c3779 Fixed #5129
Addresses two issues:
- keep the parens from dbg!() in case the call is chained or there is
semantic difference if parens are excluded
- Exclude the semicolon after the dbg!(); by checking if it was
accidentally included in the macro_call

investigated, but decided against:
fix ast::MacroCall extraction to never include semicolons at the end -
this logic lives in rowan.

Defensively shorten the macro_range if there is a semicolon token.
Deleted unneccessary temp variable macro_args

Renamed macro_content to "paste_instead_of_dbg", because it isn't a
simple extraction of text inside dbg!() anymore
2020-07-27 22:17:15 +01:00
petr-tik
01bdeaad71 Make all test fn names consistent in remove_dbg 2020-07-27 21:28:41 +01:00
petr-tik
63751d1c6b Added failing tests 2020-07-27 21:28:07 +01:00
bors[bot]
020a40335b
Merge #5547
5547: Fold multiline fn parameters r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-27 11:48:10 +00:00
Aleksey Kladov
aa09aa36e2 Fold multiline fn parameters 2020-07-27 13:42:36 +02:00
bors[bot]
bc9fab1565
Merge #5532
5532: Restore line index optimization for edits r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-07-27 09:49:45 +00:00
bors[bot]
91b2f0baaf
Merge #5539
5539: SSR: Fix path resolution of locals in current scope r=matklad a=davidlattimore



Co-authored-by: David Lattimore <dml@google.com>
2020-07-27 08:06:18 +00:00
Emil Gardström
2b8dcc15ac add completion for rustc lints 2020-07-27 02:23:21 +02:00
David Lattimore
b3ca36b2d9 SSR: Fix for path resolution of locals
It seems that Semantics::scope, if given a statement node, won't resolve
locals that were defined in the current scope, only in parent scopes.
Not sure if this is intended / expected behavior, but we work around it
for now by finding another nearby node to use as the scope (e.g. the
expression inside the EXPR_STMT).
2020-07-26 21:58:35 +10:00
David Lattimore
bb587fae1d SSR: Move more resolution-related code into the resolving module 2020-07-26 21:58:35 +10:00
Aleksey Kladov
524c2e9a7c Report type errors in metrics 2020-07-26 12:43:53 +02:00
Aleksey Kladov
da65cff18b Add one more test 2020-07-26 11:05:28 +02:00
Laurențiu Nicola
83a87fcd11 Restore line index micro-optimization 2020-07-25 12:56:39 +03:00
Aleksey Kladov
451edcc098 Add rustc-perf to metrics 2020-07-25 10:35:45 +02:00
bors[bot]
a09a00a560
Merge #5520
5520: Add DocumentData to represent in-memory document with LSP info r=matklad a=kjeremy

At the moment this only holds document version information but in the near-future it will hold other things like semantic token delta info.

Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-07-24 20:31:44 +00:00
bors[bot]
d7f1a53c6c
Merge #5524
5524: Allow opting out of experimental diagnostics like MismatchedArgCount r=matklad a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/issues/5448
Closes https://github.com/rust-analyzer/rust-analyzer/issues/5419

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-07-24 20:18:01 +00:00
Jonas Schievink
92a4ec80a0 Only display experimental diagnostics when enabled 2020-07-24 17:39:44 +02:00
Jonas Schievink
f6f49735e8 Add toggle for experimental diagnostics 2020-07-24 17:39:16 +02:00
Jonas Schievink
bec5123b0a Mark MismatchedArgCount as experimental 2020-07-24 17:38:33 +02:00
Jonas Schievink
76509b3d2d Allow filtering diagnostics 2020-07-24 17:38:18 +02:00
Jonas Schievink
6f02befee4 Add a builder for DiagnosticSink 2020-07-24 16:30:12 +02:00
Aleksey Kladov
14a3a713c7 Revert "Merge #5516"
This reverts commit 5b13c2411f, reversing
changes made to c3defe2532.
2020-07-24 16:28:19 +02:00
bors[bot]
f4f106dcea
Merge #5522
5522: Increace tracing-tree version from 0.1.3 to 0.1.4 r=kjeremy a=vandenheuvel



Co-authored-by: Bram van den Heuvel <b.vandenheuvel@student.tudelft.nl>
2020-07-24 14:01:47 +00:00
bors[bot]
5b13c2411f
Merge #5516
5516: Better LSP conformance r=matklad a=vsrs

At the moment rust-analyzer does not fully conform to the LSP. This PR fixes two LSP related issues:

1) rust-analyzer sends predefined server capabilities and does not take supplied client capabilities in mind.
2) rust-analyzer uses dynamic `textDocument/didSave` registration even if the client does not support it.


Co-authored-by: vsrs <vit@conrlab.com>
2020-07-24 13:53:41 +00:00
Bram van den Heuvel
090f02bc18 Increace tracing-tree version from 0.1.3 to 0.1.4 2020-07-24 15:41:52 +02:00
vsrs
a84dc4425a Always send experimental & semantic server caps. 2020-07-24 16:29:35 +03:00
kjeremy
48da2d4c16 Add DocumentData to represent in-memory document with LSP info 2020-07-24 09:02:57 -04:00
bors[bot]
c3defe2532
Merge #5518
5518: Use resolved paths in SSR rules r=matklad a=davidlattimore

The main user-visible changes are:
* SSR now matches paths based on whether they resolve to the same thing instead of whether they're written the same.
  * So `foo()` won't match `foo()` if it's a different function `foo()`, but will match `bar::foo()` if it's the same `foo`.
* Paths in the replacement will now be rendered with appropriate qualification for their context.
  * For example `foo::Bar` will render as just `Bar` inside the module `foo`, but might render as `baz::foo::Bar` from elsewhere.
* This means that all paths in the search pattern and replacement template must be able to be resolved.
* It now also matters where you invoke SSR from, since paths are resolved relative to wherever that is.
* Search now uses find-uses on paths to locate places to try matching. This means that when a path is present in the pattern, search will generally be pretty fast.
* Function calls can now match method calls again, but this time only if they resolve to the same function.

Co-authored-by: David Lattimore <dml@google.com>
2020-07-24 12:46:55 +00:00
Aleksey Kladov
a432f87d66 Cache macro expansion in semantics
#5497 accidentally made syntax highlighting quadratic, due to
 repeated tokentreeizing of macros.
2020-07-24 14:12:13 +02:00
Aleksey Kladov
b9ef6cf295 Add missing cancellation point 2020-07-24 13:51:27 +02:00
David Lattimore
3dac31fe80 SSR: Allow function calls to match method calls
This differs from how this used to work before I removed it in that:
a) It's only one direction. Function calls in the pattern can match
method calls in the code, but not the other way around.
b) We now check that the function call in the pattern resolves to the
same function as the method call in the code.

The lack of (b) was the reason I felt the need to remove the feature
before.
2020-07-24 21:34:00 +10:00
David Lattimore
8d09ab86ed SSR: Disable matching within use declarations
It currently does the wrong thing when the use declaration contains
braces.
2020-07-24 21:34:00 +10:00
David Lattimore
63f500b0ee SSR: Use Definition::find_usages to speed up matching.
When the search pattern contains a path, this substantially speeds up finding matches, especially if the path references a private item.
2020-07-24 21:34:00 +10:00
David Lattimore
757f755c29 SSR: Match paths based on what they resolve to
Also render template paths appropriately for their context.
2020-07-24 21:34:00 +10:00
David Lattimore
3975952601 SSR: Pass current file position through to SSR code.
In a subsequent commit, it will be used for resolving paths.
2020-07-24 21:34:00 +10:00
David Lattimore
02fc3d50ee SSR: Refactor to not rely on recursive search for nesting of matches
Previously, submatches were handled simply by searching in placeholders
for more matches. That only works if we search all nodes in the tree
recursively. In a subsequent commit, I intend to make search not always
be recursive recursive. This commit prepares for that by finding all
matches, even if they overlap, then nesting them and removing
overlapping matches.
2020-07-24 21:34:00 +10:00
David Lattimore
699619a65c SSR: Add a couple of tests for non-recursive search
These tests already pass, however once we switch to non-recursive
search, it'd be easy for these tests to not pass.
2020-07-24 21:34:00 +10:00
David Lattimore
6fcaaa1201 SSR tests: Define all paths needed for templates
In a later commit, paths in templates will be resolved. This allows us
to render the path with appropriate qualifiers for its context. Here we
prepare for that change by updating existing tests where I'd previously
not bothered to define the items that the template referred to.
2020-07-24 21:34:00 +10:00
David Lattimore
a45682ed96 Move iteration over all files into the SSR crate
The methods `edits_for_file` and `find_matches_in_file` are replaced with just `edits` and `matches`. This simplifies the API a bit, but more importantly it makes it possible in a subsequent commit for SSR to decide to not search all files.
2020-07-24 21:34:00 +10:00
David Lattimore
13f901f636 SSR: Move search code into a submodule
Also renamed find_matches to slow_scan_node to reflect that it's a slow
way to do things. Actually the name came from a later commit and
probably makes more sense once there's an alternative.
2020-07-24 21:34:00 +10:00
David Lattimore
113abbeefe SSR: Parse template as Rust code.
This is in preparation for a subsequent commit where we add special
handling for paths in the template, allowing them to be qualified
differently in different contexts.
2020-07-24 21:34:00 +10:00
David Lattimore
1fce8b6ba3 SSR: Change the way rules are stored internally.
Previously we had:

- Multiple rules
  - Each rule had its pattern parsed as an expression, path etc

This meant that there were two levels at which there could be multiple
rules.

Now we just have multiple rules. If a pattern can parse as more than one
kind of thing, then they get stored as multiple separate rules.

We also now don't have separate fields for the different kinds of things
that a pattern can parse as. This makes adding new kinds of things
simpler.

Previously, add_search_pattern would construct a rule with a dummy
replacement. Now the replacement is an Option. This is slightly cleaner
and also opens the way for parsing the replacement template as the same
kind of thing as the search pattern.
2020-07-24 21:34:00 +10:00
David Lattimore
2b53639e38 SSR: Use expect! in tests 2020-07-24 21:34:00 +10:00
bors[bot]
bc0a378070
Merge #5515
5515: Add profiling call r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-24 11:14:07 +00:00
Aleksey Kladov
c0d8921148 Add profiling call 2020-07-24 13:13:36 +02:00
vsrs
57b4ec4d5e Code formatting 2020-07-24 13:20:01 +03:00
vsrs
f195f876c3 Send dynamic didSave only if the client supports 2020-07-24 13:13:39 +03:00
vsrs
594ce72d1e Prepare server capabilities based on client ones. 2020-07-24 13:13:39 +03:00
bors[bot]
6ddcdb8b29
Merge #5511
5511: Set the document version after changes are applied but before vfs r=kjeremy a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-07-23 21:49:51 +00:00
kjeremy
c9531dc797 Set the document version after changes are applied but before vfs 2020-07-23 17:46:21 -04:00
Aleksey Kladov
be06aaecde Lighter weight tempdir 2020-07-23 22:26:25 +02:00
Aleksey Kladov
7c0743293e Require quotes around key-value cfg flags in rust-project.json
This matches rustc command-line flags, as well as the build.rs format.
2020-07-23 19:03:17 +02:00
bors[bot]
243b997df4
Merge #5506
5506: Rename modules r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-23 15:23:25 +00:00
Aleksey Kladov
e2030405d5 Rename modules 2020-07-23 17:23:01 +02:00
bors[bot]
8df105b8b2
Merge #5505
5505: Cleanup CFG API r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-23 14:55:22 +00:00
Aleksey Kladov
38e38d9b29 Cleanup CFG API 2020-07-23 16:53:12 +02:00
bors[bot]
7bada8a76d
Merge #5473
5473: Changes to rust-project.json r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-23 13:58:45 +00:00
Aleksey Kladov
0cf8ee2dc2 Remove dead code 2020-07-23 15:57:25 +02:00
bors[bot]
83f364523f
Merge #5504
5504: Reduce visibility r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-23 13:13:05 +00:00
Aleksey Kladov
28adb8fe16 Reduce visibility 2020-07-23 15:07:01 +02:00
bors[bot]
bb4cb71f80
Merge #5498
5498: assists: change_return_type_to_result: clarify assist description r=matklad a=matthiaskrgr

I had a -> Option<PathBuf> fn, which I wanted to change to Result<PathBuf, _>, but despite advertising to do so, the assist did not change the result type to Result<PathBuf, _> but instead just wrapped it in a Result: <Result<Option<PathBuf>, _>.

I changed the assist description to "Wrap return type in Result" to clarify that the assist only wraps the preexisting type and does not do any actual Option-to-Result refactoring.

Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
2020-07-23 12:48:08 +00:00
bors[bot]
37e1d1c526
Merge #5503
5503: Replace superslice with API on path to stabilization r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-23 11:01:29 +00:00
Aleksey Kladov
4f7a3fba59 Replace superslice with API on path to stabilization 2020-07-23 12:59:18 +02:00
bors[bot]
8a49f93793
Merge #5497
5497: Store macro invocation parameters as text instead of tt r=jonas-schievink a=lnicola

We don't want to expand macros on every source change because it can be arbitrarily slow, but the token trees can be rather large. So instead we can cache the invocation parameters (as text).

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-07-23 10:36:33 +00:00
Aleksey Kladov
c2d8829d56 minor 2020-07-23 10:26:56 +02:00
Matthias Krüger
29d3d04227 assists: change_return_type_to_result: clarify assist description
I had a -> Option<PathBuf> fn, which I wanted to change to Result<PathBuf, _>, but despite advertising to do so, the assist did not
change the result type to Result<PathBuf, _> but instead just wrapped it in a Result: <Result<Option<PathBuf>, _>.

I changed the assist description to "Wrap return type in Result" to clarify that the assist only wraps the preexisting type and does
not do any deep Option-to-Result refactoring.
2020-07-22 22:44:31 +02:00
kjeremy
7eedf19cfa Move deprecated attribute to where it is needed 2020-07-22 15:41:38 -04:00
Laurențiu Nicola
cb958cf5fe Store macro invocation parameters as text instead of tt 2020-07-22 21:50:37 +03:00
kjeremy
9a9c0e1105 Use symbol tags 2020-07-22 12:18:48 -04:00
bors[bot]
1c7d5f513c
Merge #5481
5481: Track document versions in the server r=kjeremy a=kjeremy

This also pushes diagnostics for the correct file version on close so that when it is reopened stale diagnostics are not shown.

Closes #5452 

Co-authored-by: kjeremy <kjeremy@gmail.com>
Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-07-22 13:04:30 +00:00
Jeremy Kolb
4f4582a6ad
Update crates/rust-analyzer/src/main_loop.rs
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-22 08:59:05 -04:00
bors[bot]
dba534a103
Merge #5475
5475: Support `Trait as _` imports r=matklad a=jonas-schievink

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

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-07-22 12:17:51 +00:00
Jonas Schievink
dce9987436 Check that visibility upgrade path is hit 2020-07-22 14:01:50 +02:00
Aleksey Kladov
9ad41eb908 Setup global allocator in the correct crate
It worked before, but was roundabout
2020-07-22 13:42:53 +02:00
Aleksey Kladov
deed44a472 Remove support for jemalloc
We only used it for measuring memory usage, but now we can use glibc's
allocator for that just fine
2020-07-22 13:40:45 +02:00
bors[bot]
26932e0060
Merge #5478
5478: Replace existing visibility modifier in fix_visibility r=matklad a=TimoFreiberg

Fixes #4636

I would have liked to do something about the `// FIXME: this really should be a fix for diagnostic, rather than an assist.`, but that would take a while and there's no reason not to fix this immediately.

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-07-22 11:11:36 +00:00
kjeremy
79a3dd085c Clear diagnostics for known file version on close 2020-07-21 14:18:22 -04:00
kjeremy
97927146db Store document version and pass back to the client 2020-07-21 14:07:42 -04:00
Jonas Schievink
56c090d0d0 Allow gathering memory stats on non-jemalloc Linux 2020-07-21 19:55:54 +02:00
Timo Freiberg
3d9c123104 Replace existing visibility modifier in fix_visibility 2020-07-21 18:58:00 +02:00
bors[bot]
a3ff2751b4
Merge #5476
5476: Cleanup extact variable r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-21 16:10:29 +00:00
Aleksey Kladov
be8a7048df Cleanup extact variable 2020-07-21 18:10:03 +02:00
Jonas Schievink
c07eaf868d Support Trait as _ imports 2020-07-21 17:55:17 +02:00
Aleksey Kladov
3bb1b3070a minor 2020-07-21 17:50:19 +02:00
Aleksey Kladov
b68ef1231d More Rustic API for Env 2020-07-21 17:17:21 +02:00
Aleksey Kladov
b48336bf94 Replace OUT_DIR in project.json with general env
OUT_DIR doesn't make sense here, as this is a cargo-specific concept
2020-07-21 15:12:12 +02:00
Aleksey Kladov
fe87aec7b6 Replace roots with include/exclude directories 2020-07-21 14:57:20 +02:00
Aleksey Kladov
39a2bc5e3c Expose package roots more directly 2020-07-21 12:52:51 +02:00
Laurențiu Nicola
daab8b2fd0 Remove insta dep 2020-07-21 13:11:51 +03:00
Laurențiu Nicola
f7e4b99d15 Replace remaining insta uses 2020-07-21 13:11:46 +03:00
bors[bot]
9518e2f9d6
Merge #5451 #5463 #5465 #5466
5451: Highlight more cases of SyntaxKind when it is a punctuation r=matklad a=GrayJack

This maybe closes #5406
Closes  #5453

Separate what one expect to be a punctuation semantic token (like `,`, `;`, `(`, etc), and what is not (`&`, `::`, `+`, etc)

5463: Bump lexer r=matklad a=kjeremy

Since we're now on rust 1.45

5465: Bump chalk r=matklad a=kjeremy



5466: Do not show default types in function and closure return values r=matklad a=SomeoneToIgnore

Avoid things like 
<img width="522" alt="image" src="https://user-images.githubusercontent.com/2690773/87985936-1bbe4f80-cae5-11ea-9b8a-5383d896c296.png">


Co-authored-by: GrayJack <gr41.j4ck@gmail.com>
Co-authored-by: kjeremy <kjeremy@gmail.com>
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-07-21 09:57:46 +00:00