Commit graph

6701 commits

Author SHA1 Message Date
bors[bot]
05399250d4
Merge #4421
4421: Find references to a function outside module r=flodiebold a=montekki

Fixes #4188 

Yet again, it looks like although the code in 
da1f316b02/crates/ra_ide_db/src/search.rs (L128-L132)

may be wrong, it is not hit since the `vis` is `None` at this point. The fix is similar to the #4237 case: just add another special case to `Definition::visibility()`.

Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com>
2020-05-11 12:21:08 +00:00
Fedor Sakharov
3d66aa0542
New definition_visibility method 2020-05-11 14:28:14 +03:00
Fedor Sakharov
753e1e679c
Also for consts and type aliases 2020-05-11 13:52:20 +03:00
Fedor Sakharov
762ec9581a
Find references to a function outside module 2020-05-11 12:25:18 +03:00
George Fraser
63b75a40c8 Color for as a regular keyword when it's part of impl _ for _ 2020-05-10 13:11:14 -07:00
George Fraser
3f1c73633e Color in as a control keyword 2020-05-10 13:07:28 -07:00
George Fraser
cff0d6b6e6 Use Property instead of Member for fields 2020-05-10 13:07:28 -07:00
veetaha
2a5ab9f5dd Resolve TODO about macro 2.0 def 2020-05-10 22:08:06 +03:00
veetaha
73c6bc4dbd Fix typo 2020-05-10 21:59:15 +03:00
veetaha
33f240960d Carify on a semicolon in macro call 2020-05-10 21:57:49 +03:00
veetaha
a1dc28f236 Resolve TODO about curly-braced constructions in expression statement 2020-05-10 21:51:53 +03:00
veetaha
8a298eed7a Resolve todos about refs and empty statements 2020-05-10 21:44:14 +03:00
veetaha
f5e2e02aa9 Converted TODO about MacroItems to FIXME as per edwin0cheng 2020-05-10 21:06:12 +03:00
veetaha
71f2be968b Verified ConstArg example, waiting for response on what = sign pertains to 2020-05-10 21:02:21 +03:00
bors[bot]
bfb40a698d
Merge #4396
4396: Improve panic message for ast_from_text r=jonas-schievink a=edwin0cheng

Related: #4368

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-10 18:01:20 +00:00
veetaha
f6fd4c4a74 Correcy use tree and type args docs 2020-05-10 20:52:25 +03:00
bors[bot]
74e72e9afa
Merge #4394 #4414
4394: Simplify r=matklad a=Veetaha



4414: Highlighting improvements r=matklad a=matthewjasper

- `static mut`s are highlighted as `mutable`.
- The name of the macro declared by `macro_rules!` is now highlighted.

Co-authored-by: veetaha <veetaha2@gmail.com>
Co-authored-by: Matthew Jasper <mjjasper1@gmail.com>
2020-05-10 17:47:27 +00:00
bors[bot]
a3dbd272e0
Merge #4406 #4410 #4411 #4417
4406: Update cargo-metadata r=matklad a=edwin0cheng

This PR update `cargo-metadata` to  0.10.0 and it also relax the` serde-derive` deps to 1.0 for tests in `proc-macro-srv`.

cc @robojumper 

r= @matklad  , I think you would have something to say related to https://github.com/serde-rs/json/issues/647#issue-593788429 ?





4410: Improve wording in comment r=matklad a=edwin0cheng



4411: do not remove then block when you unwrap else block #4361 r=matklad a=bnjjj

close #4361 

4417: Omit default types in HirDisplay SourceCode mode r=matklad a=TimoFreiberg

Closes #4390

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-05-10 17:37:07 +00:00
bors[bot]
348cbc054c
Merge #4418
4418: Refactor protocol handling r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-10 17:28:59 +00:00
Aleksey Kladov
3bec2be9de req -> lsp_ext 2020-05-10 19:27:12 +02:00
Aleksey Kladov
bec3bf701c Don't re-export lsp_types 2020-05-10 19:24:02 +02:00
veetaha
2af6b4b67e Correct use cannot have type args as per flodiebold 2020-05-10 20:23:29 +03:00
veetaha
a19b164661 Correct path docs and add colon2 token to Path ast node 2020-05-10 20:21:46 +03:00
Aleksey Kladov
a78e1573b1 Better fn signature 2020-05-10 19:14:02 +02:00
Aleksey Kladov
bd8422643a to_proto::semantic_tokens 2020-05-10 19:09:22 +02:00
Aleksey Kladov
1586bab0b9 Simplify proto conversion
Trait based infra in conv.rs is significantly more complicated than
what we actually need here.
2020-05-10 19:01:26 +02:00
veetaha
eedf11ae88 Add example with const in TypeBound as per flodiebold 2020-05-10 19:24:06 +03:00
veetaha
09c438b47e Properly document const impl as per flodiebold 2020-05-10 19:17:46 +03:00
veetaha
7a49165f5d Remove MacroStmts as per edwin0cheng 2020-05-10 19:11:22 +03:00
Timo Freiberg
cbbbd48325 Omit default types in HirDisplay SourceCode mode 2020-05-10 18:10:15 +02:00
veetaha
258a3461b4 Add proper docs for TokenTree as per edwin0cheng 2020-05-10 19:09:36 +03:00
veetaha
3554866d67 Run codegen of ast types with documentation 2020-05-10 19:06:28 +03:00
Matthew Jasper
22b75c4cea Highlight the name in macro declarations 2020-05-10 16:25:51 +01:00
Matthew Jasper
11c0a5bb60 Highlight mutable statics as mutable 2020-05-10 16:25:51 +01:00
Timo Freiberg
e17193dc51 Expand fixture documentation a little 2020-05-10 16:51:12 +02:00
Timo Freiberg
66db88d226 Trigger change_visibility assist when on an invisible struct field
Union fields apparently don't work :(
2020-05-10 16:51:12 +02:00
Emil Lauridsen
85d44cad45 infer: Make expected rhs type for plain assign the lhs type
This fixes an issue where the following code sample would fail to infer
the type contained in the option:
```rust
fn main() {
    let mut end = None; // TODO: Fix inference for this in RA
    loop {
        end = Some(true);
    }
}
```
2020-05-10 16:24:04 +02:00
Benjamin Coenen
98a7bb2435 do not remove then block when you unwrap else block #4361
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-10 15:31:51 +02:00
Timo Freiberg
7568d07709 Trigger change_visibility assist when on a path to an invisible def 2020-05-10 13:54:04 +02:00
Benjamin Coenen
92b2230fef add if let and while let postfix for Option and Result
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-10 12:45:35 +02:00
Benjamin Coenen
e80903a965 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer into feat_4348 2020-05-10 12:31:55 +02:00
Edwin Cheng
a3375c1a88 Remove dbg 2020-05-10 18:03:44 +08:00
Edwin Cheng
9405116d51 Hot fix panic for function_signature 2020-05-10 16:27:31 +08:00
Edwin Cheng
3de3b52f10 Remove dbg 2020-05-10 06:39:36 +08:00
Edwin Cheng
2400d70442 Update cargo-metadata 2020-05-10 06:22:26 +08:00
Edwin Cheng
0f1d39133c Improve panic message for ast_from_text 2020-05-10 03:46:12 +08:00
veetaha
2f7c30c515 Simplify match 2020-05-09 22:20:11 +03:00
veetaha
a42729a59d Simplify crate graph creation 2020-05-09 21:26:59 +03:00
veetaha
9970dd316b Simplify 2020-05-09 21:05:22 +03:00
bors[bot]
f1cb5b8a29
Merge #4392
4392: Add From should not move the cursor r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-09 14:22:06 +00:00
Aleksey Kladov
d9828a57fc Add From should not move the cursor 2020-05-09 16:21:10 +02:00
Aleksey Kladov
e201e7834d Ascribe more correct types 2020-05-09 15:57:53 +02:00
Aleksey Kladov
5c04d8544c unindent -> dedent 2020-05-09 14:48:43 +02:00
Aleksey Kladov
231fddab54 More fluent indent API 2020-05-09 14:40:11 +02:00
Aleksey Kladov
c6334285e3 Fix visibility 2020-05-09 13:59:25 +02:00
bors[bot]
25e37e2c93
Merge #4175
4175: Introduce HirDisplay method for rendering source code & use it in add_function assist r=flodiebold a=TimoFreiberg

Next feature for #3639.

So far the only change in the new `HirDisplay` method is that paths are qualified, but more changes will be necessary (omitting the function name from function types, returning an error instead of printing `"{unknown}"`, probably more).

Is that approach okay?

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-05-09 09:29:11 +00:00
Aaron Wood
beb79ed104 Begin transition to new fields for JsonProject crate cfgs
This starts the transition to a new method of documenting the cfgs that are
enabled for a given crate in the json file.  This is changing from a list
of atoms and a dict of key:value pairs, to a list of strings that is
equivalent to that returned by `rustc --print cfg ..`, and parsed in the
same manner by rust-analyzer.

This is the first of two changes, which adds the new field that contains
the list of strings.  Next change will complete the transition and remove
the previous fields.
2020-05-08 16:59:52 -07:00
veetaha
e83a2912b8 Simpify project discovery 2020-05-09 02:51:59 +03:00
veetaha
aca9aa8b7e Simplify 2020-05-09 02:27:44 +03:00
Florian Diebold
a3d866e776 Handle coercing function types to function pointers in match
E.g. in
```rust
match x {
    1 => function1,
    2 => function2,
}
```
we need to try coercing both to pointers. Turns out this is a special case in
rustc as well (see the link in the comment).
2020-05-08 22:14:01 +02:00
bors[bot]
f9ec7cebef
Merge #4377
4377: Implement better handling of divergence r=matklad a=flodiebold

Divergence here means that for some reason, the end of a block will not be reached. We tried to model this just using the never type, but that doesn't work fully (e.g. in `let x = { loop {}; "foo" };` x should still have type `&str`); so this introduces a `diverges` flag that the type checker keeps track of, like rustc does. We also add some checking for `break`, but no support for break-with-value or labeled breaks yet.

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-05-08 18:09:25 +00:00
Florian Diebold
d0129c4ddb Add diagnostic for break outside of loop 2020-05-08 19:48:03 +02:00
Florian Diebold
f8bf94a4b9 Use matches! 2020-05-08 19:30:02 +02:00
bors[bot]
d81e19286f
Merge #4378
4378: Add stderr to error message r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-08 16:54:38 +00:00
Aleksey Kladov
f739e0119c Add stderr to error message 2020-05-08 18:53:53 +02:00
Florian Diebold
b60970fd20 Handle break somewhat better
Still no break-with-value or labels, but at least we know that `loop { break; }`
doesn't diverge.
2020-05-08 18:28:01 +02:00
Florian Diebold
fe7bf993aa Implement better handling of divergence
Divergence here means that for some reason, the end of a block will not be
reached. We tried to model this just using the never type, but that doesn't work
fully (e.g. in `let x = { loop {}; "foo" };` x should still have type `&str`);
so this introduces a `diverges` flag that the type checker keeps track of, like
rustc does.
2020-05-08 18:15:24 +02:00
Timo Freiberg
64e6b8200b Use new HirDisplay variant in add_function assist 2020-05-08 17:14:45 +02:00
Timo Freiberg
fe93675e8a New HirDisplay method for displaying sourcecode 2020-05-08 17:12:18 +02:00
Florian Diebold
f5177f91ae Fix type of byte literals
They're `&[u8; N]`, not `&[u8]` (see #4374).
2020-05-08 15:18:33 +02:00
Aleksey Kladov
ecff5dc141 Cleanup 2020-05-08 14:55:28 +02:00
Aleksey Kladov
7c0409e0c7 Cleanup 2020-05-08 12:34:39 +02:00
Aleksey Kladov
6713be0b13 Rename ra_env -> ra_toolchain 2020-05-08 12:25:36 +02:00
bors[bot]
8295a9340c
Merge #4329
4329: Look for `cargo`, `rustc`, and `rustup` in standard installation path r=matklad a=cdisselkoen

Discussed in #3118.  This is approximately a 90% fix for the issue described there.

This PR creates a new crate `ra_env` with a function `get_path_for_executable()`; see docs there.  `get_path_for_executable()` improves and generalizes the function `cargo_binary()` which was previously duplicated in the `ra_project_model` and `ra_flycheck` crates.  (Both of those crates now depend on the new `ra_env` crate.)  The new function checks (e.g.) `$CARGO` and `$PATH`, but also falls back on `~/.cargo/bin` manually before erroring out.  This should allow most users to not have to worry about setting the `$CARGO` or `$PATH` variables for VSCode, which can be difficult e.g. on macOS as discussed in #3118.

I've attempted to replace all calls to `cargo`, `rustc`, and `rustup` in rust-analyzer with appropriate invocations of `get_path_for_executable()`; I don't think I've missed any in Rust code, but there is at least one invocation in TypeScript code which I haven't fixed.  (I'm not sure whether it's affected by the same problem or not.) a4778ddb7a/editors/code/src/cargo.ts (L79)

I'm sure this PR could be improved a bunch, so I'm happy to take feedback/suggestions on how to solve this problem better, or just bikeshedding variable/function/crate names etc.

cc @Veetaha 

Fixes #3118.

Co-authored-by: Craig Disselkoen <craigdissel@gmail.com>
Co-authored-by: veetaha <veetaha2@gmail.com>
2020-05-08 10:11:19 +00:00
Aleksey Kladov
d3110859ba Move feature desugaring to the right abstraction layer 2020-05-08 02:56:53 +02:00
Craig Disselkoen
3077eae2a6 use home crate instead of dirs 2020-05-07 12:06:44 -07:00
bors[bot]
1b136aae0b
Merge #4296
4296: Support cargo:rustc-cfg in build.rs r=matklad a=robojumper

Fixes #4238.

Co-authored-by: robojumper <robojumper@gmail.com>
2020-05-07 18:50:00 +00:00
bors[bot]
97b9b364d6
Merge #4362
4362: do not show runnables for main function outside of a binary target  r=matklad a=bnjjj

close #4356

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-07 17:30:13 +00:00
bors[bot]
fd84c31ff7
Merge #4346
4346: Fix rename of enum variant visible from module r=matklad a=montekki

Probably fixes #4237 

It looks like the ref is found correctly in this case but it's visibility is not correctly determined. I took a stab at fixing that by adding an implementation of `HasVisibility` for `EnumVariant` so it works more or less the same way it does for struct fields.

In other words, the `search_range` here does not contain the ref since it's not considered visible:

efd8e34c39/crates/ra_ide_db/src/search.rs (L209-L214)


Before that I tried to populate `ItemScope` with visible enum variants but that ended up with breaking tests all over the place and also it looked illogical in the end: `ItemScope` is not populated with, say, public struct fields and the same should be true for `enum` variants.

I've added two more or less identical tests: one for the case with a struct field rename and one for enum variant rename; the test for struct should probably be removed and the names should be changed.


Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com>
2020-05-07 16:29:01 +00:00
Aleksey Kladov
1e790ea314 Simplify 2020-05-07 17:32:01 +02:00
Aleksey Kladov
28fcff125a Nicer API 2020-05-07 17:29:23 +02:00
Aleksey Kladov
c6b81bc013 Rename AssitLabel -> Assist 2020-05-07 17:18:28 +02:00
Benjamin Coenen
c839d4f7a9 do not show runnables for main function outside of a binary target #4356
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-07 16:52:14 +02:00
Aleksey Kladov
4867968d22 Refactor assists API to be more convenient for adding new assists
It now duplicates completion API in its shape.
2020-05-07 16:27:54 +02:00
Fedor Sakharov
210f0cbd27
Remove HasVisibility implementation 2020-05-07 16:31:51 +03:00
Aleksey Kladov
43cedecf68 Fix panic in FunctionSignature 2020-05-07 14:29:01 +02:00
Benjamin Coenen
6203e9c4fa add if let and while let postfix for Option and Result #4348
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-07 11:23:38 +02:00
Craig Disselkoen
227929f9dd simplify by using bail! macro 2020-05-06 13:29:22 -07:00
Craig Disselkoen
5d4648884b cargo fmt 2020-05-06 12:47:13 -07:00
Craig Disselkoen
44b01ccff3 return a PathBuf instead of String 2020-05-06 12:39:11 -07:00
bors[bot]
1a0988b899
Merge #4316 #4351
4316: do not truncate display for hover r=matklad a=bnjjj

close #4311 

4351: Fix Windows server path r=matklad a=lnicola

CC @Coder-256.

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-05-06 16:54:31 +00:00
bors[bot]
b832dfc917
Merge #4331
4331: Fixture improvements r=TimoFreiberg a=TimoFreiberg

As mentioned in [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/resolve_path.20between.20fixture.20files) :)

I think always allowing unindented first lines is friendlier than making the user fix it and I don't see any drawbacks.

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-05-06 16:18:17 +00:00
Timo Freiberg
86fa80e5b3 Allow fixture strings with unindented first line
This allows fixtures like
        "//- /lib.rs
         ...
         //- /foo.rs
         ...
"
2020-05-06 18:09:28 +02:00
Timo Freiberg
8a5d14453e Add fixture doc comment 2020-05-06 18:09:28 +02:00
Benjamin Coenen
51c02ab84f add Ok wrapping
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-06 17:45:55 +02:00
bors[bot]
e99447ffbf
Merge #4347
4347: Fix usefulness check for never type r=flodiebold a=MikailBag



Co-authored-by: Mikail Bagishov <bagishov.mikail@yandex.ru>
2020-05-06 15:11:26 +00:00
Mikail Bagishov
7c94fa7d01
Fix usefulness check for never type 2020-05-06 17:59:27 +03:00
Aleksey Kladov
020ca6695f Simplify 2020-05-06 16:39:11 +02:00
Fedor Sakharov
bd9f1f7eb7
Fix rename of enum variant visible from module 2020-05-06 17:35:22 +03:00
Aleksey Kladov
4d50709a96 Minor 2020-05-06 16:10:35 +02:00
Aleksey Kladov
0970c3454b Rename 2020-05-06 16:10:35 +02:00
Aleksey Kladov
fdd4df97ba Use SourceChange for assists 2020-05-06 15:43:47 +02:00
Aleksey Kladov
1116c9a0e9 Fix TODO 2020-05-06 13:21:49 +02:00
Aleksey Kladov
233f01c9ba Move target to AssistLabel
Target is used for assists sorting, so we need it before we compute
the action.
2020-05-06 12:51:28 +02:00
Benjamin Coenen
1ec953f117 do not truncate display for hover
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-06 11:33:43 +02:00
Aleksey Kladov
3850b1c086 Lift SourceChange to the ra_ide_db 2020-05-06 11:32:34 +02:00
Aleksey Kladov
beb35c3ecb Fix capitalization 2020-05-06 11:19:43 +02:00
Benjamin Coenen
550c629498 do not truncate display for hover
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-06 11:08:50 +02:00
Aleksey Kladov
eea431180e Regenerate 2020-05-06 10:21:35 +02:00
Aleksey Kladov
d308ff910b Merge doc_tests and tests 2020-05-06 10:18:12 +02:00
Aleksey Kladov
25e6bbde01 Merge assits::test_helpers and tests 2020-05-06 10:16:55 +02:00
Benjamin Coenen
c4d128e454 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer into fix_4311 2020-05-06 09:57:00 +02:00
Craig Disselkoen
1b76b4281e simplify some code using early returns 2020-05-05 16:12:56 -07:00
Craig Disselkoen
3e603a8fdd add module-level docs so that tests pass 2020-05-05 16:12:56 -07:00
Craig Disselkoen
7e60264ba0 cargo fmt 2020-05-05 16:12:56 -07:00
Craig Disselkoen
303b444dbb pull function out into new crate ra_env; use in ra_flycheck as well 2020-05-05 16:12:56 -07:00
Craig Disselkoen
5aa1bba107 more generic, find rustc as well 2020-05-05 16:12:56 -07:00
Craig Disselkoen
ffaef1b7ae ra_project_model: look for Cargo in more places
See #3118
2020-05-05 16:12:56 -07:00
bors[bot]
30eb458b4f
Merge #4332
4332: Refactor TextEdit r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-05 21:50:47 +00:00
Aleksey Kladov
ca9e0f5fe9 Fixup tests 2020-05-05 23:48:26 +02:00
Aleksey Kladov
27c7ef6d65 Use more natural signature for Edit::apply 2020-05-05 23:23:29 +02:00
Aleksey Kladov
4a6fa8f0df Rename AtomTextEdit -> Indel 2020-05-05 23:15:49 +02:00
guigui64
c22660179c
add the allFeatures flag (true by default) 2020-05-05 22:46:42 +02:00
Aleksey Kladov
381cbc6088 Minor cleanups 2020-05-05 22:14:01 +02:00
bors[bot]
d38741f681
Merge #4327
4327: Refactor assists r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-05 19:36:53 +00:00
Aleksey Kladov
3908fad1fe Normalize naming of diagnostics 2020-05-05 21:35:30 +02:00
Aleksey Kladov
df00da15c4 Fix compilation 2020-05-05 20:45:44 +02:00
Aleksey Kladov
aee22c73c3 Move group_label where it belongs 2020-05-05 20:42:52 +02:00
Aleksey Kladov
6c2414430a use GroupLabel for type safety 2020-05-05 20:34:45 +02:00
Aleksey Kladov
d5b9282ede Minor rename 2020-05-05 20:33:10 +02:00
Aleksey Kladov
13c078db9c Flip Assist::new arguments 2020-05-05 20:30:33 +02:00
bors[bot]
a4778ddb7a
Merge #4325
4325: Fix column conversion for supplementary plane characters r=matklad a=lnicola

Fixes https://github.com/rust-analyzer/rust-analyzer/pull/4276#issuecomment-623079855.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-05 18:10:39 +00:00
Laurențiu Nicola
1d794e8590 Fix column conversion for supplementary plane characters 2020-05-05 20:30:52 +03:00
bors[bot]
8803e748a6
Merge #4166
4166: Defining a default target to support cross-compilation targets  r=matklad a=FuriouZz

Related to #4163 

Co-authored-by: Christophe MASSOLIN <christophe.massolin@gmail.com>
2020-05-05 17:25:52 +00:00
bors[bot]
df7b59081f
Merge #4323
4323: Add tests for #4306 r=kjeremy a=lnicola

CC @kjeremy 

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-05 17:01:46 +00:00
Laurențiu Nicola
7ec1b63f81 Add tests for #4306 2020-05-05 19:39:45 +03:00
Christophe MASSOLIN
04e32fbffc Remove code duplicates 2020-05-05 18:23:47 +02:00
bors[bot]
f0411ff9e0
Merge #4320
4320: add doctest support r=matklad a=bnjjj

close #4317

preview:

<img width="253" alt="Capture d’écran 2020-05-05 à 17 39 58" src="https://user-images.githubusercontent.com/5719034/81086040-45110b80-8ef8-11ea-9c05-79c6fe400fc3.png">


Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-05 16:22:31 +00:00
Christophe MASSOLIN
14dde99627 Pass cargo.target to rustc 2020-05-05 18:15:13 +02:00
Christophe MASSOLIN
0ab4340cdb Rename defaultTarget to target 2020-05-05 18:01:54 +02:00
Edwin Cheng
92665358cd Rename ImplItem to AssocItem 2020-05-05 23:56:10 +08:00
Benjamin Coenen
fe52f8f028 add doctest support #4317
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-05 17:44:27 +02:00
bors[bot]
756e91732b
Merge #4305
4305: Favor types for record type struct in name resolution r=matklad a=edwin0cheng

Fixed #4235

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-05 15:06:41 +00:00
Edwin Cheng
07de8ea165 invert if 2020-05-05 23:01:07 +08:00
bors[bot]
f68e099777
Merge #4265
4265: Make `change_visibility` assist work for tuple struct fields r=matklad a=Jesse-Bakker

Fixes #4206 

Co-authored-by: Jesse Bakker <git@jessebakker.com>
2020-05-05 14:42:33 +00:00
robojumper
f2dd233ddc Assume cargo_metadata uses String for cfgs soon 2020-05-05 14:53:52 +02:00
robojumper
059fc86963 Merge heavy tests 2020-05-05 14:53:18 +02:00
Benjamin Coenen
0bf02f5cca do not truncate display for hover #4311
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-05 14:29:25 +02:00
bors[bot]
d1c1c01309
Merge #4306 #4308
4306: Make incremental sync opt-out and fix line index rebuild r=matklad a=lnicola



4308: Update server binary paths in docs r=matklad a=Coder-256

Fixed incorrect macOS path and converted to a list. Also, should the Windows path include `matklad.rust-analyzer`? (I can't check)

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Co-authored-by: Jacob Greenfield <jacob@jacobgreenfield.me>
2020-05-05 10:02:56 +00:00
Benjamin Coenen
831bb1cf91 refactor: use attrsOwner directly in is_cfg_enabled
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-05 09:34:07 +02:00
Edwin Cheng
cf821cc332 Change union resolve types only 2020-05-05 01:19:54 +08:00
Edwin Cheng
e921195d93 Change favor_types to has_constructor 2020-05-05 01:15:27 +08:00
Laurențiu Nicola
7c1d5f286a Fix line index rebuild during incremental changes 2020-05-04 20:04:30 +03:00
Laurențiu Nicola
191abf3685 Make incremental sync opt-out 2020-05-04 19:54:39 +03:00
Edwin Cheng
5ae18f4f81 Remove unused import 2020-05-05 00:34:54 +08:00
Edwin Cheng
204c8de3bf Add test for issue 2020-05-05 00:29:47 +08:00
Edwin Cheng
af001677d1 Fix test 2020-05-05 00:17:30 +08:00
Edwin Cheng
8d96db3417 Favor types for Record in name resolution 2020-05-05 00:17:22 +08:00
Aleksey Kladov
b211c5814e Remove false positive attr compleitons 2020-05-04 16:48:50 +02:00
Aleksey Kladov
8f4478390e Qualify ast types 2020-05-04 15:33:08 +02:00
Aleksey Kladov
e9643ab74c Cleanup imports 2020-05-04 15:33:08 +02:00
Aleksey Kladov
71f6d58e31 Remove unnecessary condition
No tests fail, and quick manual testing shows that there are no
false-positives. In general, each completion contributor should be
independent from the others.
2020-05-04 15:32:23 +02:00
Aleksey Kladov
d7450222a9 Simplify 2020-05-04 14:55:24 +02:00
bors[bot]
580c5a969d
Merge #4297
4297: refactor: use parent instead ancestors for use alias r=matklad a=bnjjj

Linked to this comment https://github.com/rust-analyzer/rust-analyzer/pull/4269/files#r419343670

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-04 12:37:41 +00:00
Aleksey Kladov
802617ccc2 Simplify 2020-05-04 14:16:10 +02:00
Benjamin Coenen
e88c3e4fcd refactor: use parent instead ancestors for use alias
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-04 13:42:30 +02:00
robojumper
2980ba1fde Support build.rs cargo:rustc-cfg 2020-05-04 13:29:09 +02:00
bors[bot]
57f285d0eb
Merge #4283
4283: Support macro for trait items r=matklad a=edwin0cheng

Fixed  #4039

r? @flodiebold 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
Co-authored-by: Edwin Cheng <edwin@m-inverse.com>
2020-05-04 10:49:24 +00:00
Edwin Cheng
5899c8eaa9 Fixes names for collect_item funtions 2020-05-04 18:34:32 +08:00
bors[bot]
b1a5dc8c8b
Merge #4269 #4293
4269: add support of use alias semantic in definition r=matklad a=bnjjj

close #4202 

4293: no doctests for flycheck r=matklad a=matklad



bors r+
🤖

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-04 10:34:06 +00:00
Aleksey Kladov
6af464d185 no doctests for flycheck 2020-05-04 12:26:52 +02:00
Aleksey Kladov
710e430dbb Fix focus range for TypeParam
closes #4274
2020-05-04 12:25:32 +02:00
Aleksey Kladov
13bce1a164 Add test marks 2020-05-04 12:10:26 +02:00
bors[bot]
3b1d983085
Merge #4282
4282: More name hints omitting heuristics r=matklad a=SomeoneToIgnore

Omit parameter name hints for cases like the first two parameters from the screenshot:

<img width="394" alt="Screenshot 2020-05-03 at 15 06 34" src="https://user-images.githubusercontent.com/2690773/80914717-165b2f80-8d56-11ea-8675-040972f70d98.png">


Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-05-04 08:36:48 +00:00
Kirill Bulatov
30817de3af Code review fixes
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-04 11:04:02 +03:00
bors[bot]
d855280818
Merge #4285
4285: add support of cfg attributes on enum variants r=edwin0cheng a=bnjjj

close #4279

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-04 03:18:48 +00:00
bors[bot]
57ec813294
Merge #4286
4286: Make incremental sync opt-in r=matklad a=lnicola

@matklad do you want to merge this? I'd make it opt-out, but it's fine to test it more.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-04 03:03:52 +00:00
bors[bot]
6a48a94d47
Merge #4268
4268: Support auto-import in macro r=SomeoneToIgnore a=edwin0cheng

Fixed: #3854

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-03 22:52:10 +00:00
Kirill Bulatov
66882f1a24 Move snake case method to heck 2020-05-03 21:35:21 +03:00
Laurențiu Nicola
87a18b18ea Make incremental sync opt-in 2020-05-03 20:58:07 +03:00
Benjamin Coenen
bed115d6e1 add support of cfg attributes on enum variants #4279
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-03 17:56:45 +02:00
Edwin Cheng
73ed2f2e90 Remove whitespaces 2020-05-03 22:15:07 +08:00
Edwin Cheng
8b6216df05 Support macro for trait items 2020-05-03 22:08:39 +08:00
Kirill Bulatov
ba8ffab644 Omit name hints for enum names similar to parameter names 2020-05-03 15:55:08 +03:00
Kirill Bulatov
8eb820f460 Omit name hints for method names similar to parameter names 2020-05-03 15:55:08 +03:00
bors[bot]
baa35b02b2
Merge #4280
4280: Add documents owner for ImplDef and SourceFile r=matklad a=edwin0cheng

When working on #3182, I found that `ImplDef` and `SourceFile` do not implemet `DocCommentsOwer` trait, and I tested it in `cargo doc` that `impl` could has some doc-comments.

I am not so sure about `SourceFile` case, but in theory if that file is a crate root, the doc comment of it should represent the whole crate documentation, right ?

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-03 10:46:07 +00:00
Edwin Cheng
f90fbaf6a6 Add documents owner for ImplDef and SourceFile 2020-05-03 18:00:27 +08:00
bors[bot]
76c2f4ef49
Merge #4278
4278: Log panics in apply_document_changes r=matklad a=lnicola

This doesn't necessarily help (because of https://github.com/rust-analyzer/rust-analyzer/issues/4263#issuecomment-623078531), but maybe we could leave it in there for a while in case it catches something.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-03 09:48:44 +00:00
Laurențiu Nicola
074d1ac2f7 Log panics in apply_document_changes 2020-05-03 12:46:20 +03:00
bors[bot]
682c079043
Merge #4276
4276: Don't count start of non-ASCII characters as being inside of them r=matklad a=lnicola

I'm still not sure that `utf16_to_utf8_col` is correct for code points from Supplementary Planes. These have two UTF-16 code units, and I feel we're not going to count them correctly.

Fixes the crash in https://github.com/rust-analyzer/rust-analyzer/issues/4263#issuecomment-622988258.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-03 08:57:02 +00:00
Laurențiu Nicola
16d3bb9106 Don't count start of non-ASCII characters as being inside of them 2020-05-03 09:54:39 +03:00
Kirill Bulatov
2fd054f276 Fix derive argument parsing 2020-05-02 23:47:51 +03:00
Benjamin Coenen
99c2ca8494 add support of use alias semantic in definition #4202
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-02 21:42:27 +02:00
Kirill Bulatov
9f0ed7ed92 Separate macros completion from other 2020-05-02 22:33:23 +03:00
Edwin Cheng
2034002413 Support auto-import in macro 2020-05-03 03:24:55 +08:00
Kirill Bulatov
fee74851b0 Propose custom derives in completion 2020-05-02 22:24:27 +03:00
Kirill Bulatov
767bff89ed Complete standard derives 2020-05-02 21:41:02 +03:00
Kirill Bulatov
c4b32d1534 Fix the extension method 2020-05-02 21:41:02 +03:00
Benjamin Coenen
4613497a77 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer into fix_4202 2020-05-02 20:27:02 +02:00
Jesse Bakker
b5c330bf5a Make change_visibility assist work for tuple struct field visibility 2020-05-02 18:25:38 +02:00
bors[bot]
89e1f97515
Merge #4207 #4253
4207: Add unwrap block assist #4156 r=matklad a=bnjjj

close issue #4156 

4253: Remove `workspaceLoaded` setting r=matklad a=eminence

The `workspaceLoaded` notification setting was originally designed to
control the display of a popup message that said:

    "workspace loaded, {} rust packages"

This popup was removed and replaced by a much sleeker message in the
VSCode status bar that provides a real-time status while loading:

    rust-analyzer: {}/{} packages

This was done as part of #3587

The change in this PR simply renames this setting from `workspaceLoaded` to
`progress` to better describe what it actually controls.  At the moment,
the only type of progress message that is controlled by this setting is
the initial load messages, but in theory other messages could also be
controlled by this setting.


Reviewer notes:

* If we didn't like the idea of causing minor breaking to user's config, we could keep the setting name as `workspaceLoaded`
* I think we can now close both #2719 and #3176 since the notification dialog in question no longer exists (actually I think you can close those issues even if you reject this PR 😄 )

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Andrew Chin <achin@eminence32.net>
2020-05-02 12:44:55 +00:00
Aleksey Kladov
359d3be308 Fix parsing of blocks without { 2020-05-02 14:35:17 +02:00
Benjamin Coenen
fdf86637bf Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-05-02 13:39:05 +02:00
Benjamin Coenen
6d5f3922f7 Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-02 12:31:11 +02:00
bors[bot]
fb8fb65131
Merge #4234
4234: Support local_inner_macros r=jonas-schievink a=edwin0cheng

This PR implements `#[macro_export(local_inner_macros)]` support. 

Note that the rustc implementation is quite [hacky][1] too. :)

[1]: 614f273e93/src/librustc_resolve/macros.rs (L456)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-02 10:30:49 +00:00
Benjamin Coenen
0b40876b99 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-05-02 12:25:04 +02:00
Benjamin Coenen
eea21738ab Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-02 12:20:39 +02:00
bors[bot]
75bc024946
Merge #4257
4257: ast::EffectExpr r=matklad a=matklad

closes #4230 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-02 09:57:45 +00:00
Aleksey Kladov
b73dbbfbf2 Add missing members generates indented blocks 2020-05-02 11:53:07 +02:00
bors[bot]
235728319f
Merge #4256
4256: Improve formatting of analyzer status text r=flodiebold a=eminence

The old formatting had everything on 1 line, making it quite hard to read:

    requests:    1 textDocument/documentSymbol         2ms    2 textDocument/codeAction             2ms    3 rust-analyzer/inlayHints            20ms    4 textDocument/foldingRange           108ms    6 textDocument/codeLens               66ms    5 textDocument/semanticTokens/range   76ms    8 rust-analyzer/inlayHints            195ms    7 textDocument/semanticTokens         250ms    9 textDocument/semanticTokens/range   108ms


It now looks like this:

```
requests:
*   1 textDocument/documentSymbol         11ms
    2 textDocument/codeAction             15ms
    3 rust-analyzer/inlayHints            4ms
    5 textDocument/foldingRange           3ms
    4 textDocument/semanticTokens/range   45ms
    6 textDocument/codeLens               182ms
    8 rust-analyzer/inlayHints            124ms
    7 textDocument/semanticTokens         127ms
    9 textDocument/documentHighlight      2ms
   10 textDocument/codeAction             3ms
```

Co-authored-by: Andrew Chin <achin@eminence32.net>
2020-05-02 09:45:37 +00:00
Aleksey Kladov
b58dfd24f1 Add smoke test for decorated blocks 2020-05-02 11:27:28 +02:00
Aleksey Kladov
623faefcda Cleanup inline tests 2020-05-02 11:21:39 +02:00
Aleksey Kladov
642a3392d9 Update test data 2020-05-02 11:21:39 +02:00
Aleksey Kladov
4f2134cc33 Introduce EffectExpr 2020-05-02 11:21:39 +02:00
Aleksey Kladov
247d32cbfd Test/check the whole package
Closes #4255
2020-05-02 10:57:37 +02:00
Edwin Cheng
edf0b4c152 Test whether it is bang macro properly 2020-05-02 10:16:26 +08:00
Edwin Cheng
291d03949b Add test in name resolutions 2020-05-02 10:06:17 +08:00
Edwin Cheng
443762cda9
Update crates/ra_hir_expand/src/builtin_derive.rs
Fix spacing

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-05-02 09:56:38 +08:00
Andrew Chin
65234e8828 Remove workspaceLoaded setting
The `workspaceLoaded` notification setting was originally designed to
control the display of a popup message that said:

  "workspace loaded, {} rust packages"

This popup was removed and replaced by a much sleeker message in the
VSCode status bar that provides a real-time status while loading:

  rust-analyzer: {}/{} packages

This was done as part of #3587

The new status-bar indicator is unobtrusive and shouldn't need to be
disabled.  So this setting is removed.
2020-05-01 21:04:41 -04:00
Andrew Chin
76f34a15e6 Improve formatting of analyzer status text 2020-05-01 19:13:52 -04:00
Aleksey Kladov
fd030f9450 Revert "Merge #4233"
This reverts commit a5f2b16366, reversing
changes made to c96b2180c1.
2020-05-02 01:12:37 +02:00
kjeremy
810c961961 Update crates 2020-05-01 18:26:42 -04:00
bors[bot]
3232fd5179
Merge #4220 #4240
4220: Introduce LowerCtx r=matklad a=edwin0cheng

This PR introduces `LowerCtx` for path lowering. 

After this PR, there are only 2 places remains for using deprecated `Path::from_ast`, which is related to `AstTransform` I am not familiar. I would like to change these in another PR by others ;)

related disscusiion:  https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Path.3A.3Afrom_src

And also fixed part of https://github.com/rust-analyzer/rust-analyzer/issues/4176#issuecomment-620672930

4240: Bump deps r=matklad a=lnicola



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-05-01 20:16:25 +00:00
bors[bot]
8d02b24b25
Merge #4244
4244: Show unsafe trait in hover r=matklad a=DianaNites

Following on #2450 and #4210, for traits.
`unsafe` is the only qualifier they can have, though.

Co-authored-by: Diana <5275194+DianaNites@users.noreply.github.com>
2020-05-01 19:45:48 +00:00
bors[bot]
21588e15df
Merge #4246
4246: Validate uses of self and super r=matklad a=djrenren

This change follows on the validation of the `crate` keyword in paths. It verifies the following things:

`super`:
 - May only be preceded by other `super` segments
 - If in a `UseItem` then all semantically preceding paths also consist only of `super`

`self`
 - May only be the start of a path


Just a note, a couple times while working on this I found myself really wanting a Visitor of some sort so that I could traverse descendants while skipping sub-trees that are unimportant. Iterators don't really work for this, so as you can see I reached for recursion. Considering paths are generally small a fancy debounced visitor probably isn't important but figured I'd say something in case we had something like this lying around and I wasn't using it.

Co-authored-by: John Renner <john@jrenner.net>
2020-05-01 19:24:25 +00:00
kjeremy
99826dab15 Address comments 2020-05-01 14:12:31 -04:00
kjeremy
ee1628dba0 Mark most assists as the base "refactor" type
Most of them area. We will separate them out later but this gets them to
show up in the "refactor" menu of vscode.
2020-05-01 13:44:32 -04:00
kjeremy
e75565c73f Advertise support for all the builtin CodeActionKinds
Even thought we don't return all of these we eventually will so might as
well advertise now.
2020-05-01 13:44:32 -04:00
kjeremy
e3ee61f5e8 Filter out CodeActions if a server only support commands. 2020-05-01 13:44:32 -04:00
Diana
375dd18dc0 Fix pub(self) visibility?
Clippy complained about it and it seems wrong
2020-05-01 12:09:47 -04:00
John Renner
3bb46042fb Validate uses of self and super 2020-05-01 08:59:24 -07:00
Diana
ebff5762e9 Test for unsafe trait 2020-05-01 11:49:51 -04:00
Diana
6833183ab4 Unsafe traits 2020-05-01 11:49:41 -04:00
Benjamin Coenen
df7899e47a Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-01 16:41:29 +02:00
Benjamin Coenen
dc34162450 Merge branch 'master' of github.com:rust-analyzer/rust-analyzer 2020-05-01 16:26:30 +02:00
Benjamin Coenen
19e28888aa wip
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-01 16:26:22 +02:00
Edwin Cheng
7bbdeb43a4 Make AttrQuery copyable 2020-05-01 20:58:24 +08:00
Laurențiu Nicola
1e20467c3a Bump deps 2020-05-01 15:29:03 +03:00
Edwin Cheng
44f5e2048c Remove lower_path from AssistCtx to Semantic 2020-05-01 20:05:12 +08:00
Edwin Cheng
bdcf6f5658 Introduce LowerCtx for path lowering 2020-05-01 20:01:17 +08:00
Edwin Cheng
1635d22a35 Add test 2020-05-01 20:01:17 +08:00
Edwin Cheng
e4267967a8 Support local_inner_macros 2020-05-01 11:23:03 +08:00
Aleksey Kladov
14126349be Kill more zombies 2020-04-30 22:58:26 +02:00
Aleksey Kladov
1865dedadf Introduce BlockModifier 2020-04-30 22:58:26 +02:00
Aleksey Kladov
292ba6a1f8 Remove dead code, which elaborately pretends to be alive 2020-04-30 22:41:14 +02:00
Aleksey Kladov
15cfa9a808 Fix a bunch of false-positives in join-lines 2020-04-30 22:08:50 +02:00
bors[bot]
23c889694e
Merge #4153
4153: Add support for incremental text synchronization r=matklad a=lnicola

Fixes #3762.

This still needs a `ra_vfs` PR, but I want to know I'm on the right track. I tested the change and it didn't crash horribly, but YMMV.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-04-30 19:00:30 +00:00
bors[bot]
745bd45ddb
Merge #4227
4227: Report invalid, nested, multi-segment crate-paths r=matklad a=djrenren

There was a bug in the previous path-validating code that didn't detect multi-segment paths that started with `crate`.

```rust
// Successfully reported
use foo::{crate};

// BUG: was not being reported
use foo::{crate::bar};
```

This was due to my confusion about path-associativity. That is, the path with no qualifier is the innermost path, not the outermost. I've updated the code with a lot of comments to explain what's going on. 

This bug was discovered when I found an erroneous `ok` test which I reported here: 
https://github.com/rust-analyzer/rust-analyzer/issues/4226

This test now fails and has been modified, hopefully in the spirit of the original test, to be correct.  Sorry about submitting the bug in the first place!

Co-authored-by: John Renner <john@jrenner.net>
2020-04-30 18:37:35 +00:00
Laurențiu Nicola
1a2d4e2921 Add support for incremental text synchronization 2020-04-30 21:26:57 +03:00
John Renner
513a3615f6 Report invalid, nested, multi-segment crate-paths
Specifically, things like:

use foo::{crate::bar};

Are now being caught, when before we only caught:

use foo::{crate};
2020-04-30 11:16:09 -07:00
Edwin Cheng
45c4f620b1 Special-case try macro_rules 2020-04-30 22:07:46 +08:00
Aleksey Kladov
c51c8bfb84 Special-case try macro to better support 2015 edition 2020-04-30 14:17:14 +02:00
bors[bot]
fdaddb98b5
Merge #4210
4210: Include function qualifiers in signature r=matklad a=oxalica

Fixes #2450

It seems there's no test for `ra_ide/display/{short_label,function_signature}`. I'm not sure how to setup it.

Manually tested:
<img width="428" alt="Screenshot_20200430_004434" src="https://user-images.githubusercontent.com/14816024/80622769-d6f1c200-8a7b-11ea-91f3-e94bfb2703c5.png">


Co-authored-by: oxalica <oxalicc@pm.me>
2020-04-30 11:09:57 +00:00
bors[bot]
95e8766db6
Merge #4178
4178: Validate the location of `crate` in paths r=matklad a=djrenren

**This solution does not fully handle `use` statements. See below**

This pull requests implements simple validation of usages of the `crate` keyword in `Path`s. Specifically it validates that:

- If a `PathSegment` is starts with the `crate` keyword, it is also the first segment of the `Path`
- All other usages of `crate` in `Path`s are considered errors.

This aligns with `rustc`'s rules. Unlike rustc this implementation does not issue a special error message in the case of `::crate` but it does catch the error.

Furthermore, this change does not cover all error cases. Specifically the following is not caught:

```rust
use foo::{crate}
```

This is because this check is context sensitive. From an AST perspective, `crate` is the root of the `Path`. Only by inspecting the full `UseItem` do we see that it is not in fact the root. This problem becomes worse because `UseTree`s are allowed to be arbitrarily nested:

```rust
use {crate, {{crate, foo::{crate}}}
```

So this is a hard problem to solve without essentially a breadth-first search. In a traditional compiler, I'd say this error is most easily found during the AST -> HIR conversion pass but within rust-analyzer I'm not sure where it belongs.  

Under the implementation in this PR, such errors are ignored so we're *more correct* just not *entirely correct*. 

Co-authored-by: John Renner <john@jrenner.net>
2020-04-30 10:17:40 +00:00
oxalica
b9b342ff93
Add tests of showing function qualifiers 2020-04-30 12:54:16 +08:00
Jonas Schievink
0cd6a88cf6 if let -> match 2020-04-30 00:10:30 +02:00
Jonas Schievink
15233a467d ? 2020-04-30 00:10:30 +02:00
Jonas Schievink
cafa7a780a Use or-patterns more 2020-04-30 00:10:30 +02:00
Jonas Schievink
3e41483932 Remove .clone() 2020-04-30 00:10:30 +02:00
Jonas Schievink
3cb73da949 Rename to associated_type_shorthand_candidates 2020-04-30 00:10:30 +02:00
Jonas Schievink
8c2670026a Complete assoc. items on type parameters 2020-04-30 00:10:30 +02:00
John Renner
0af727da91 Validate the location of crate in paths 2020-04-29 11:06:51 -07:00
oxalica
414d8d9c38
Include function qualifiers in signature 2020-04-30 00:34:46 +08:00
bors[bot]
1cde354c35
Merge #4119
4119: Cache proc-macro dlls r=matklad a=edwin0cheng

This PR try to fix a deadlock in proc-macro srv by not unloading dlls.

Currently we load and unload dlls for each request, however rustc TLS is leaky , such that if we do it a lot of times, all TLS index will be consumed and it will be deadlocked inside panic (it is because panic itself is using TLS too).


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-29 13:28:57 +00:00
Benjamin Coenen
bbe22640b8 Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-29 14:53:47 +02:00
Aleksey Kladov
b4dd475257 More principled approach for finding From trait 2020-04-29 14:51:44 +02:00
Benjamin Coenen
76733f0cd4 Add unwrap block assist #4156
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-29 14:08:30 +02:00
bors[bot]
c3dfeba165
Merge #4204
4204: Use specific pattern when translating if-let-else to match r=matklad a=matklad

We *probably* should actually use the same machinery here, as we do
for fill match arms, but just special-casing options and results seems
to be a good first step.



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-29 10:01:26 +00:00
Aleksey Kladov
7c3c289dab Use specific pattern when translating if-let-else to match
We *probably* should actually use the same machinery here, as we do
for fill match arms, but just special-casing options and results seems
to be a good first step.
2020-04-29 11:59:11 +02:00
Aleksey Kladov
041aea2263 Better filtering of qualified enum variants in completion 2020-04-29 11:26:21 +02:00
Aleksey Kladov
73bef854ab Move shared assist code to utils 2020-04-29 10:38:51 +02:00
Jonas Schievink
8cb139090f Complete union fields after dot 2020-04-28 22:45:46 +02:00
bors[bot]
07f690ddf6
Merge #4161
4161: lsp-types 0.74 r=kjeremy a=kjeremy

* Fixes a bunch of param types to take partial progress into account.
* Will allow us to support insert/replace text in completions

Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-04-28 20:12:44 +00:00
bors[bot]
db441de0a8
Merge #4193
4193: Make it impossible to forget to add a semantic token type / modifier r=kjeremy a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-28 20:05:08 +00:00
bors[bot]
2096db90b4
Merge #4184
4184: Treat comments beginning with four slashes as regular line comments r=kjeremy a=adamrk

Addresses https://github.com/rust-analyzer/rust-analyzer/issues/4040

Co-authored-by: adamrk <ark.email@gmail.com>
2020-04-28 19:57:23 +00:00
adamrk
0bd7d81805 Fix comment prefix method for four slash comments 2020-04-28 21:13:37 +02:00
bors[bot]
9230ae5492
Merge #4148
4148: Simplify profiler impl (bubble up Option) r=matklad a=Veetaha



Co-authored-by: veetaha <veetaha2@gmail.com>
2020-04-28 18:44:34 +00:00
Aleksey Kladov
890938a48c Make it impossible to forget to add a semantic token type / modifier 2020-04-28 17:14:05 +02:00
Leander Tentrup
052e9faa90 Introduce new semantic highlight token for format specifier 2020-04-28 11:13:12 +02:00
adamrk
b6560e3ebb Treat comments beginning with four slashes as regular line comments 2020-04-28 10:23:45 +02:00
Christophe MASSOLIN
e7523511ce [config] remove RustcConfig 2020-04-28 00:17:23 +02:00
Christophe MASSOLIN
ed5af989f4 [config] rename cargo.defaultTarget 2020-04-28 00:15:54 +02:00
bors[bot]
da1f316b02
Merge #4173
4173: Use core instead of std for builtin derive macros r=edwin0cheng a=edwin0cheng

Fixed #4087.

We can't use `$crate` here right now because : 

1. We have to able to detect `macro` 2.0 in collecting phase for finding `rustc_builtin_macro` attrs.
2. And we have to make hygiene works for builtin derive macro.

r= @flodiebold 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-27 20:12:27 +00:00
Edwin Cheng
c69f9c1b0a Check dep name to detect it is core 2020-04-28 04:11:24 +08:00
Edwin Cheng
6d3b0af900 Use empty-deps tricks to detect it is core 2020-04-28 03:32:47 +08:00
Edwin Cheng
213d208e2d Add test 2020-04-28 02:10:17 +08:00
Edwin Cheng
6a5014329a Use core instead of std for builtin derive macros 2020-04-28 01:48:55 +08:00
Christophe MASSOLIN
b7edffe244 Started rust-analyzer.cargo.defaultTarget implementation 2020-04-27 00:11:04 +02:00
kjeremy
61f1c0a990 lsp-types 0.74
* Fixes a bunch of param types to take partial progress into account.
* Will allow us to support insert/replace text in completions
2020-04-26 16:05:22 -04:00
Florian Diebold
497073abc6 For associated type shorthand (T::Item), use the substs from the where clause
So e.g. if we have `fn foo<T: SomeTrait<u32>>() -> T::Item`, we want to lower
that to `<T as SomeTrait<u32>>::Item` and not `<T as SomeTrait<_>>::Item`.
2020-04-26 16:58:08 +02:00
Edwin Cheng
bfce657377 Generate uniq name 2020-04-26 18:59:09 +08:00
Edwin Cheng
183673655f Simpify code 2020-04-26 17:58:56 +08:00
Edwin Cheng
fb996cae6b Fix 2020-04-26 17:17:37 +08:00
Edwin Cheng
3bad5587c8 Compare timestamp 2020-04-26 17:17:37 +08:00
Edwin Cheng
5a5bba5a46 Copy dylib to temp directory 2020-04-26 17:17:37 +08:00
Edwin Cheng
3e24444aee Cacheproc-macro dlls 2020-04-26 17:17:37 +08:00
bors[bot]
ef67e0a497
Merge #4155
4155: Precompute expected type during completion r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-26 08:54:42 +00:00
Aleksey Kladov
05cdc87158 Precompute expected type during completion 2020-04-26 10:54:08 +02:00
Aleksey Kladov
5ef0f44499 Add cargo test to the list of Run commands 2020-04-26 10:40:34 +02:00
veetaha
24d18d92f6 Simplify profiler impl (bubble up Option and shorten code 2020-04-26 00:55:49 +03:00
Jonas Schievink
5a355ff52b Fix broken test 2020-04-25 22:23:56 +02:00
Jonas Schievink
76d6f54471 Don't add call parens when an fn type is expected 2020-04-25 22:18:57 +02:00
bors[bot]
45832b990c
Merge #4145
4145: Remove dead code r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-25 19:30:04 +00:00
bors[bot]
7021352dc2
Merge #4113 #4136 #4141 #4142
4113: Support returning non-hierarchical symbols r=matklad a=kjeremy

If `hierarchicalDocumentSymbolSupport` is not true in the client capabilites
then it does not support the `DocumentSymbol[]` return type from the
`textDocument/documentSymbol` request and we must fall back to `SymbolInformation[]`.

This is one of the few requests that use the client capabilities to
differentiate between return types and could cause problems for clients.

See https://github.com/microsoft/language-server-protocol/pull/538#issuecomment-442510767 for more context.

Found while looking at #144

4136: add support for cfg feature attributes on expression #4063 r=matklad a=bnjjj

close issue #4063

4141: Fix typo r=matklad a=Veetaha



4142: Remove unnecessary async from vscode language client creation r=matklad a=Veetaha



Co-authored-by: kjeremy <kjeremy@gmail.com>
Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: veetaha <veetaha2@gmail.com>
2020-04-25 19:23:15 +00:00
Aleksey Kladov
bd9ede0ec9 Extract messy tree handling out of profiling code 2020-04-25 21:22:40 +02:00
Aleksey Kladov
0f099ead88 Fix panic in NoSuchField diagnostic 2020-04-25 21:09:33 +02:00
Aleksey Kladov
95b989ec30 Simplify 2020-04-25 19:50:42 +02:00
veetaha
f52e2f6840 Fix typo 2020-04-25 20:49:51 +03:00
Aleksey Kladov
726938f598 Simplify hprof 2020-04-25 19:30:00 +02:00
Aleksey Kladov
b3e9f3d143 Move hprof to a separate file 2020-04-25 19:30:00 +02:00
Aleksey Kladov
7623db1106 minor clenup 2020-04-25 19:30:00 +02:00
bors[bot]
5671bacfa6
Merge #4139
4139: Add check for rules that no repetition which could match an empty token r=matklad a=edwin0cheng

Fix #4103

for `/ui/issues/issue-57597.rs`

This is `ParseError` of the macro rules , because it is how rustc handle it : 

a58b1ed44f/src/librustc_expand/mbe/macro_rules.rs (L558)


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-25 16:26:51 +00:00
bors[bot]
67afeebaf5
Merge #4137
4137: Prefer core/alloc paths on #![no_std] r=matklad a=jonas-schievink



Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-04-25 16:19:21 +00:00
Edwin Cheng
d5eb43f246 Checks no repetition for an empty token 2020-04-25 23:30:10 +08:00
bors[bot]
fc57358efd
Merge #4133
4133: main: eagerly prime goto-definition caches r=matklad a=BurntSushi

This commit eagerly primes the caches used by goto-definition by
submitting a "phantom" goto-definition request. This is perhaps a bit
circuitous, but it does actually get the job done. The result of this
change is that once RA is finished its initial loading of a project,
goto-definition requests are instant. There don't appear to be any more
surprise latency spikes.

This _partially_ addresses #1650 in that it front-loads the latency of the
first goto-definition request, which in turn makes it more predictable and
less surprising. In particular, this addresses the use case where one opens
the text editor, starts reading code for a while, and only later issues the
first goto-definition request. Before this PR, that first goto-definition request
is guaranteed to have high latency in any reasonably sized project. But
after this PR, there's a good chance that it will now be instant.

What this _doesn't_ address is that initial loading time. In fact, it makes it
longer by adding a phantom goto-definition request to the initial startup
sequence. However, I observed that while this did make initial loading
slower, it was overall a somewhat small (but not insignificant) fraction
of initial loading time.

-----

At least, the above is what I _want_ to do. The actual change in this PR is just a proof-of-concept. I came up with after an evening of printf-debugging. Once I found the spot where this cache priming should go, I was unsure of how to generate a phantom input. So I just took an input I knew worked from my printf-debugging and hacked it in. Obviously, what I'd like to do is make this more general such that it will always work.

I don't know whether this is the "right" approach or not. My guess is that there is perhaps a cleaner solution that more directly primes whatever cache is being lazily populated rather than fudging the issue with a phantom goto-definition request.

I created this as a draft PR because I'd really like help making this general. I think whether y'all want to accept this patch is perhaps a separate question. IMO, it seems like a good idea, but to be honest, I'm happy to maintain this patch on my own since it's so trivial. But I would like to generalize it so that it will work in any project.

My thinking is that all I really need to do is find a file and a token somewhere in the loaded project, and then use that as input. But I don't quite know how to connect all the data structures to do that. Any help would be appreciated!

cc @matklad since I've been a worm in your ear about this problem. :-)

Co-authored-by: Andrew Gallant <jamslam@gmail.com>
2020-04-25 14:30:10 +00:00
Jonas Schievink
3cf2c3b943 Prefer core/alloc paths on #![no_std] 2020-04-25 16:27:34 +02:00
Andrew Gallant
0c12b7e8c8
main: fix bug where thread pool isn't joined
Pointed out here:
https://github.com/rust-analyzer/rust-analyzer/pull/4133#issuecomment-619386272
2020-04-25 10:26:33 -04:00
Benjamin Coenen
b87b335e68 add support for cfg feature attributes on expression #4063
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-25 15:48:04 +02:00
Andrew Gallant
c1a31d4261
main: eagerly prime goto-definition caches
This commit makes RA more aggressive about eagerly priming the caches.
In particular, this fixes an issue where even after RA was done priming
its caches, an initial goto-definition request would have very high
latency. This fixes that issue by requesting syntax highlighting for
everything. It is presumed that this is a tad wasteful, but not overly
so.

This commit also tweaks the logic that determines when the cache is
primed. Namely, instead of just priming it when the state is loaded
initially, we attempt to prime it whenever some state changes. This
fixes an issue where if a modification notification is seen before cache
priming is done, it would stop the cache priming early.
2020-04-25 09:28:34 -04:00
Aleksey Kladov
970dbf8717 Rename StructField -> Field 2020-04-25 14:23:34 +02:00
bors[bot]
7bc7173230
Merge #4134
4134: Special case for empty comments in doc comment kind  r=matklad a=edwin0cheng

Part of #4103

Fix `ui/empty/empty-comment.rs macros`

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-25 10:53:40 +00:00
Edwin Cheng
f0fece4be0 Fix whitespaces 2020-04-25 18:49:46 +08:00
bors[bot]
f654f49435
Merge #4125
4125: Avoid lossy OsString conversions r=matklad a=lnicola

This is a bit invasive, and perhaps for not much benefit since non-UTF-8 environment variables don't work anyway.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-04-25 10:35:14 +00:00
Aleksey Kladov
e873469500 text-size 1.0.0 2020-04-25 12:15:32 +02:00
Aleksey Kladov
63a462f37c Switch to TryFrom 2020-04-25 11:59:18 +02:00
Aleksey Kladov
dc2151085e Cleanups 2020-04-25 11:59:18 +02:00
Aleksey Kladov
8843588fca Convert tests to text-size 2020-04-25 11:59:18 +02:00
Aleksey Kladov
b1d5817dd1 Convert code to text-size 2020-04-25 11:59:18 +02:00
Edwin Cheng
d20eea073e Special case for empty comments 2020-04-25 17:37:34 +08:00
Laurențiu Nicola
58dde891f8 Avoid lossy OsString conversions 2020-04-25 12:19:23 +03:00
bors[bot]
27a7718880
Merge #4128
4128: Include correct item path for variant completions r=matklad a=jonas-schievink

The test would previously suggest `E::V`, which is not enough to name the variant as the enum is in a module. Now it correctly suggests the full path `m::E::V`.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-04-24 21:11:19 +00:00
Aleksey Kladov
aa669c5ba5 Don't print cargo version to stdout, breaking everything 2020-04-24 23:02:10 +02:00
Jonas Schievink
e131763fb8 Include correct item path for variant completions 2020-04-24 22:18:59 +02:00
bors[bot]
51a0058d4c
Merge #3998 #4006
3998: Make add_function generate functions in other modules via qualified path r=matklad a=TimoFreiberg

Additional feature for #3639 

- [x] Add tests for paths with more segments
- [x] Make generating the function in another file work
- [x] Add `pub` or `pub(crate)` to the generated function if it's generated in a different module
- [x] Make the assist jump to the edited file
- [x] Enable file support in the `check_assist` helper

4006: Syntax highlighting for format strings r=matklad a=ltentrup

I have an implementation for syntax highlighting for format string modifiers `{}`.
The first commit refactors the changes in #3826 into a separate struct.
The second commit implements the highlighting: first we check in a macro call whether the macro is a format macro from `std`. In this case, we remember the format string node. If we encounter this node during syntax highlighting, we check for the format modifiers `{}` using regular expressions.

There are a few places which I am not quite sure:
- Is the way I extract the macro names correct?
- Is the `HighlightTag::Attribute` suitable for highlighting the `{}`?

Let me know what you think, any feedback is welcome!

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
Co-authored-by: Leander Tentrup <ltentrup@users.noreply.github.com>
2020-04-24 20:10:54 +00:00
bors[bot]
e55b1833ff
Merge #4127
4127: More helpful error message if toolchain is not in PATH r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-24 20:03:33 +00:00
Aleksey Kladov
6c400b3e33 More helpful error message if toolchain is not in PATH 2020-04-24 22:01:32 +02:00
Jonas Schievink
7b9553a703 Don't omit methods with self from path completion 2020-04-24 21:46:18 +02:00
Roberto Vidal
0dab5d5879 Adds attribute completions (#3941) 2020-04-24 17:54:52 +02:00
kjeremy
0619c67ac6 Support returning non-hierarchical symbols
If `hierarchicalDocumentSymbolSupport` is not true in the client capabilites
then it does not support the `DocumentSymbol[]` return type from the
`textDocument/documentSymbol` request and we must fall back to `SymbolInformation[]`.

This is one of the few requests that use the client capabilities to
differentiate between return types and could cause problems for clients.

See https://github.com/microsoft/language-server-protocol/pull/538#issuecomment-442510767 for more context.

Found while looking at #144
2020-04-24 10:11:57 -04:00
kjeremy
ae1f77e5e9 Add hierarchical symbols client capability 2020-04-24 10:08:45 -04:00
Aleksey Kladov
62e08fa53d Better label for macros completion 2020-04-24 13:25:37 +02:00
bors[bot]
44e6c2cb54
Merge #4101
4101: Panic proc macro srv if read request failed r=matklad a=edwin0cheng

This PR fixed a bug when the rust-analyzer is killed suddenly, the `rust-analyzer proc-macro` will become stale.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-24 01:28:53 +00:00
Edwin Cheng
a83d1743a5 Refactor a bit 2020-04-24 09:27:37 +08:00
Aleksey Kladov
440cd05edb Honor snippet capability
closes #2518
2020-04-24 02:41:07 +02:00
Aleksey Kladov
5fd5de4061 Make sure that adding a snippet requires corresponding capability 2020-04-24 02:26:38 +02:00
Aleksey Kladov
b3050bded1 Introduce internal snippet cap 2020-04-24 02:06:12 +02:00
Aleksey Kladov
bd3b239390 Move CompletionConfig to a separate module 2020-04-24 02:01:23 +02:00
Aleksey Kladov
88d243c742 Don't set sortText
I might be reading this wrong, but it looks like we are setting it to
essentially arbitrary string at the moment, as there are no defined
order on the items in the *set* of completions.
2020-04-24 01:53:37 +02:00
Aleksey Kladov
647683b9bb Add test marks 2020-04-24 01:48:32 +02:00
Aleksey Kladov
09a4b78775 Introduce ActiveParameter 2020-04-24 01:46:00 +02:00