Commit graph

6701 commits

Author SHA1 Message Date
vsrs
7e9c7ac4ee smoke test 2020-05-16 16:56:41 +03:00
vsrs
2c00bd8c6a Propogate fixture meta to AnalysisHost
Except crate name.
2020-05-16 15:23:43 +03:00
vsrs
2dde9b1994 Use FixtureMeta in MockAnalysis 2020-05-16 13:17:21 +03:00
Florian Diebold
050601ef7b Chalk upgrade 2020-05-16 11:43:48 +02:00
vsrs
256fb7556e Remove temporary FixtureEntry parsed_meta field. 2020-05-16 12:25:26 +03:00
vsrs
d901e0e709 Reimplement ra_db::fixture::ParsedMeta
in terms of test_utils::FixtureMeta
2020-05-16 11:57:41 +03:00
vsrs
eeb98237d1 parse fixture meta in test_utils crate 2020-05-16 11:16:32 +03:00
zbsz
d7d8bfc472 Add 'self to parameter' renaming. 2020-05-15 19:05:59 -07:00
Hasan Ali
001a86dc03 Fix completion and hover for module and function of same name 2020-05-16 01:09:04 +01:00
Florian Diebold
3f42b2e837 Handle Self in values and patterns
I.e.
 - `Self(x)` or `Self` in tuple/unit struct impls
 - `Self::Variant(x)` or `Self::Variant` in enum impls
 - the same in patterns

Fixes #4454.
2020-05-15 17:25:28 +02:00
bors[bot]
d51c1f6217
Merge #4448
4448: Generate configuration for launch.json r=vsrs a=vsrs

This PR adds two new commands: `"rust-analyzer.debug"` and `"rust-analyzer.newDebugConfig"`. The former is a supplement to the existing `"rust-analyzer.run"` command and works the same way: asks for a runnable and starts new debug session. The latter allows adding a new configuration to **launch.json** (or to update an existing one).

If the new option `"rust-analyzer.debug.useLaunchJson"` is set to true then `"rust-analyzer.debug"` and Debug Lens will first look for existing debug configuration in **launch.json**. That is, it has become possible to specify startup arguments, env variables, etc.

`"rust-analyzer.debug.useLaunchJson"` is false by default, but it might be worth making true the default value. Personally I prefer true, but I'm not sure if it is good for all value.

----
I think that this PR also solves https://github.com/rust-analyzer/rust-analyzer/issues/3441.
Both methods to update launch.json mentioned in the issue do not work:
1. Menu. It is only possible to add a launch.json configuration template via a debug adapter. And anyway it's only a template and it is impossible to specify arguments from an extension.

2. DebugConfigurationProvider. The exact opposite situation: it is possible to specify all debug session settings, but it is impossible to export these settings to launch.json.

Separate `"rust-analyzer.newDebugConfig"` command looks better for me.

----
Fixes #4450
Fixes #3441

Co-authored-by: vsrs <vit@conrlab.com>
Co-authored-by: vsrs <62505555+vsrs@users.noreply.github.com>
2020-05-15 14:29:01 +00:00
bors[bot]
982b92f966
Merge #4431
4431: Store proc-macro result in salsa db r=matklad a=edwin0cheng

Fixed #4315 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-15 10:17:42 +00:00
Aleksey Kladov
08027c3075 Cleanups 2020-05-15 02:09:30 +02:00
Aleksey Kladov
f1a5c489fd Better structure 2020-05-15 01:58:39 +02:00
Aleksey Kladov
220813dcb0 Move LSP bits from flycheck to rust-analyzer
There should be only one place that knows about LSP, and that place is
right before we spit JSON on stdout.
2020-05-15 01:52:25 +02:00
bors[bot]
12d82687cd
Merge #4273
4273: Trigger add_vis assist on paths/record fields as well r=flodiebold a=TimoFreiberg

Resolves #4037.

- [x] Function defs
- [x] ADT defs
- [x] Enum variants
- [x] Consts
- [x] Statics
- [x] Traits
- [x] Type aliases
- [x] Modules
- [x] Record fields (using different implementation)
    - [x] struct fields
    - [x] enum variant fields
    -   union fields (`Semantics::resolve_record_field` seems to not work for union fields, so I think this can be handled in a future PR)
- [x] More tests? 
- [x] Improve test fixture code and documentation a bit (see [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/resolve_path.20between.20fixture.20files))

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-05-14 14:29:22 +00:00
Aleksey Kladov
acedad8134 Minor 2020-05-14 15:36:15 +02:00
Aleksey Kladov
fc0c5dfcd1 Put preselect items on top 2020-05-14 15:33:56 +02:00
vsrs
51d5a08255
Better label for a runnable.
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-05-14 16:28:18 +03:00
Aleksey Kladov
90c62bcee9 Prioritize locals with correct types 2020-05-14 15:15:52 +02:00
vsrs
20fdd14c62 Multiple binaries support for launch.json.
Generate unique names on the LSP side.
2020-05-14 16:02:01 +03:00
bors[bot]
f1587ac263
Merge #4445
4445: Correctly fill default type parameters r=flodiebold a=montekki

Fixes #3877 

So, basically even if the parameters are omitted from the `impl` block, check the parameters in `trait` if they have a default type, and if they do go from `hir` to `ast::TypeArg`. I've added a helper for that but I am not sure that it's a proper way to go from `hir` to `ast` here.

Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com>
2020-05-14 11:20:42 +00:00
Fedor Sakharov
ccd5268374
Ty -> Type 2020-05-14 13:53:45 +03:00
Fedor Sakharov
12bf008ab1
Adds a param_idx helper 2020-05-14 13:47:36 +03:00
Edwin Cheng
20f7068b68 Store proc-macro result in salsa db 2020-05-14 17:57:51 +08:00
bors[bot]
5148d6dc66
Merge #4405
4405: Make some stuff public so that they can be reused by other tools r=pksunkara a=pksunkara

So, my little experiment of building a code analysis tool using rust-analyzer is successful. I am going to proceed to build the tool now. This PR makes the needed things public.

I know there were some things about trying to change stuff regarding loading workspaces, which would make it more easier for other tools to reuse. But, until then, it should be okay using this `load_cargo` fn.

Btw, if I were publish my tool, I would need the `ra` crates to be released. Since @matklad told me that he doesn't want to care about breaking stuff, I would propose the following.

Every monday, during the weekly release, we release a new pre v1 minor version of all the crates. That way, we don't need to care about breaking stuff but still have rust-analyzer on crates.io.

I made https://github.com/pksunkara/cargo-workspaces to help release workspace crates easily.

So, coming week, we start with `0.1.0`, then week after that, we release `0.2.0` and then `0.3.0` etc.. until we decide on `1.0.0` which is probably when the compiler team also starts using the crates. There is no limit to the minor versions (we can even have `0.150.0` or `0.1500.0`), so I don't see anything wrong with this strategy.

Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-05-14 09:23:34 +00:00
Pavan Kumar Sunkara
9f0a7eb97b Make some stuff public so that they can be reused by other tools 2020-05-14 11:14:46 +02:00
Fedor Sakharov
2dfbec149f
Fix formatting 2020-05-14 10:31:34 +03:00
Fedor Sakharov
7e9396c7eb
Change type_arg to type_ref func 2020-05-14 10:14:04 +03:00
Fedor Sakharov
a55ad20388
Use generic_defaults and display_source_code 2020-05-14 09:56:20 +03:00
Trevor Spiteri
2d0a949236 Use back ticks instead of single quotes around code 2020-05-14 01:06:07 +02:00
Laurențiu Nicola
55e914a2a1 Remove hidden VARIATION SELECTOR-16 2020-05-13 17:26:57 +03:00
Fedor Sakharov
00f3b6c59a
Correctly fill default type parameters 2020-05-13 16:07:44 +03:00
bors[bot]
a84bd9e18c
Merge #4434
4434: add more specific match postfix for Result and Option r=matklad a=bnjjj

In order to have the same behavior than `if let` and `while let`

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-13 09:25:01 +00:00
bors[bot]
9594fe33fa
Merge #4083
4083: Smol documentation for ast nodes r=matklad a=Veetaha

There is a tremendous amount of TODOs to clarify the topics I am not certain about.
Please @matklad, @edwin0cheng review carefully, I even left some mentions of your names in todos to put your attention where you most probably can give comments.

In order to simplify the review, I separated the codegen (i.e. changes in `ast/generated/nodes.rs`) from `ast_src` changes (they in fact just duplicate one another) into two commits.

Also, I had to hack a little bit to let the docs be generated as doc comments and not as doc attributes because it's easier to read them this way and IIRC we don't support hints for `#[doc = ""]` attributes for now...

Closes #3682 

Co-authored-by: veetaha <veetaha2@gmail.com>
2020-05-13 09:09:46 +00:00
Trevor Spiteri
3583e0fe2b fix typo unimplementated -> unimplemented
Pretty harmless typo, but it does get exposed in
lsp-rust-analyzer-expand-macro.
2020-05-12 23:51:38 +02:00
veetaha
8d4c11625a Remove an equals sign from ConstArg (this probably pertains only to ConstParam)
(As per matklad)
2020-05-12 23:57:04 +03:00
veetaha
51edfbaffe Convert TODO to a Note(matklad) 2020-05-12 23:50:52 +03:00
veetaha
65b380fa8d Convert to TODOs to FIXMEs as per matklad 2020-05-12 23:48:04 +03:00
veetaha
55a29982c0 Revert "Remove MacroStmts as per edwin0cheng" (cc @edwin0cheng) and add a fixme to document it.
This reverts commit 7a49165f5d.
MacroStmts ast node is not used by itself, but it pertains
to SyntaxNodeKind MACRO_STMTS that is used by ra_paser, so
even tho the node itself is not used, it is better to keep it
with a FIXME to actually add a doc comment when it becomes useful.
2020-05-12 23:45:29 +03:00
veetaha
24b27abf9f Add a doc comment on the difference between Name and NameRef ast nodes 2020-05-12 23:31:37 +03:00
Benjamin Coenen
df33022408 add more specific match postfix for Result and Option
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-12 11:48:58 +02:00
bors[bot]
2c9878a2fc
Merge #4423
4423: add tests module snippet r=bnjjj a=bnjjj

Request from a friend coming from intellij Rust

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-11 18:15:31 +00:00
bors[bot]
0063ad970d
Merge #4358
4358: add if let and while let postfix for Option and Result #4348 r=matklad a=bnjjj

close #4348 

I also added `while let` for iterator or stream it could be useful 

![iflet](https://user-images.githubusercontent.com/5719034/81278000-676c6b80-9055-11ea-87ad-6b8476dd983f.gif)


Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-11 18:08:26 +00:00
Benjamin Coenen
72e3d2260b add tests module snippet
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-11 19:59:58 +02:00
bors[bot]
848aa56df5
Merge #4397
4397: Textmate cooperation r=matklad a=georgewfraser

This PR tweaks the fallback TextMate scopes to make them more consistent with the existing grammar and other languages, and edits the builtin TextMate grammar to align with semantic coloring. Before is on the left, after is on the right:

<img width="855" alt="Screen Shot 2020-05-10 at 1 45 51 PM" src="https://user-images.githubusercontent.com/1369240/81512320-a8be7e80-92d4-11ea-8940-2c03f6769015.png">

**Use keyword.other for regular keywords instead of keyword**. This is a really peculiar quirk of TextMate conventions, but virtually *all* TextMate grammars use `keyword.other` (colored blue in VSCode Dark+) for regular keywords and `keyword.control` (colored purple in VSCode Dark+) for control keywords. The TextMate scope `keyword` is colored like control keywords, not regular keywords. It may seem strange that the `keyword` scope is not the right fallback for the `keyword` semantic token, but TextMate has a long and weird history. Note how keywords change from purple back to blue (what they were before semantic coloring was added):

**(1) Use punctuation.section.embedded for format specifiers**. This aligns with how Typescript colors formatting directives:

<img width="238" alt="Screen Shot 2020-05-09 at 10 54 01 AM" src="https://user-images.githubusercontent.com/1369240/81481258-93b5f280-91e3-11ea-99c2-c6d258c5bcad.png">

**(2) Consistently use `entity.name.type.*` scopes for type names**. Avoid using `entity.name.*` which gets colored like a keyword.

**(3) Use Property instead of Member for fields**. Property and Member are very similar, but if you look at the TextMate fallback scopes, it's clear that Member is intended for function-like-things (methods?) and Property is intended for variable-like-things.

**(4) Color `for` as a regular keyword when it's part of `impl Trait for Struct`**. 

**(5) Use `variable.other.constant` for constants instead of `entity.name.constant`**. In the latest VSCode insiders, variable.other.constant has a subtly different color that differentiates constants from ordinary variables. It looks close to the green of types but it's not the same---it's a new color recently added to take advantage of semantic coloring.

I also made some minor changes that make the TextMate scopes better match the semantic scopes. The effect of this for the user is you observe less of a change when semantic coloring "activates". You can see the changes I made relative to the built-in TextMate grammar here:

a91d15c80c..97428b6d52 (diff-6966c729b862f79f79bf7258eb3e0885)


Co-authored-by: George Fraser <george@fivetran.com>
2020-05-11 17:33:38 +00:00
bors[bot]
de1fe23c1e
Merge #4403
4403: Check client capabilities before sending progress notifications r=kjeremy a=kjeremy

Fixes #4384

Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-05-11 17:25:34 +00:00
Jeremy Kolb
d4471dccfe Check client capabilities before sending progress notifications
Fixes #4384
2020-05-11 13:16:46 -04:00
Aleksey Kladov
72e229fcb3 Use RA_LOG instead of RUST_LOG for logging
RUST_LOG might be set up for debugging the user's problem, slowing
down rust-analyzer considerably. That's the same reason why rustc uses
RUSTC_LOG.
2020-05-11 19:16:00 +02:00
Benjamin Coenen
4e54b1ca46 add tests module snippet
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-05-11 18:11:23 +02:00
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