Commit Graph

8628 Commits

Author SHA1 Message Date
Igor Aleksanov
ebd30033b3 Fix compilation error 2020-10-12 11:05:00 +03:00
Igor Aleksanov
f2c91fc5a8 Apply suggestions from code review
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-12 11:05:00 +03:00
Igor Aleksanov
9ea57cac0e Fix code style issues 2020-10-12 11:05:00 +03:00
Igor Aleksanov
50a147dcdf Apply case check diagnostic to impl items 2020-10-12 11:05:00 +03:00
Igor Aleksanov
2a72f876d6 Fix issues with match arm bindings 2020-10-12 11:05:00 +03:00
Igor Aleksanov
45ac2b2ede Code style adjustments 2020-10-12 11:05:00 +03:00
Igor Aleksanov
cfbee8d3a3 Remove previously added parameter names from the function data 2020-10-12 11:05:00 +03:00
Igor Aleksanov
b42562b5de Make incorrect case diagnostic work inside of functions 2020-10-12 11:05:00 +03:00
Igor Aleksanov
9ec1741b65 Refactor string helpers for decl_check module 2020-10-12 11:05:00 +03:00
Igor Aleksanov
fb96bba878 Add diagnostics for enum names and variants 2020-10-12 11:05:00 +03:00
Igor Aleksanov
e24e22f288 Add fix for incorrect case diagnostic 2020-10-12 11:04:59 +03:00
Igor Aleksanov
17f1026c46 Improve string helpers functions 2020-10-12 10:59:54 +03:00
Igor Aleksanov
21dd704b6b Check structure fields to be snake_case 2020-10-12 10:59:54 +03:00
Igor Aleksanov
329626124f Add check for structure names to be CamelCase 2020-10-12 10:59:54 +03:00
Igor Aleksanov
1773c6d154 Extract helper functions into a separate module 2020-10-12 10:59:54 +03:00
Igor Aleksanov
f5cea35986 Add checks for function parameters 2020-10-12 10:59:54 +03:00
Igor Aleksanov
4039176ec6 Create basic support for names case checks and implement function name case check 2020-10-12 10:59:54 +03:00
bors[bot]
518f6d7724
Merge #5917
5917: Add a command to open docs for the symbol under the cursor r=matklad a=zacps

#### Todo

- [ ] Decide if there should be a default keybind or context menu entry
- [x] Figure out how to get the documentation path for methods and other non-top-level defs
- [x] Design the protocol extension. In future we'll probably want parameters for local/remote documentation URLs, so that should maybe be done in this PR?
- [x] Code organisation
- [x] Tests


Co-authored-by: Zac Pullar-Strecker <zacmps@gmail.com>
2020-10-12 07:38:24 +00:00
kjeremy
a7d6674e4d Update crates 2020-10-11 18:01:50 -04:00
Lukas Wirth
9909ccb4f4 Fix mut self not emitting mutable binding on self use 2020-10-11 18:39:03 +02:00
Lukas Wirth
1416413d69 Skip macro matcher fragment name semantic highlighting 2020-10-10 23:21:12 +02:00
Kirill Bulatov
2bb80a4f03 Also replace the associated types with iter 2020-10-10 21:39:57 +03:00
Kirill Bulatov
9a72b7bccd Add a test 2020-10-10 20:02:38 +03:00
Rüdiger Herrmann
e90931a204 Show reason for failed rename refactoring
Return an error with a meaningful message for requests to
`textDocument/rename` if the operation cannot be performed.
Pass errors raised by rename handling code to the LSP runtime.

As a consequence, the VS Code client shows and logs the request
as if a server-side programming error occured.

Resolves https://github.com/rust-analyzer/rust-analyzer/issues/3981
2020-10-10 13:46:10 +02:00
bors[bot]
05261f5aeb
Merge #6176
6176: add eprintln in fmt-like postfix r=SomeoneToIgnore a=bnjjj



Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-09 23:16:19 +00:00
Jonas Schievink
5dcbf03d0f adt: correctly inherit field visibility from enum
Previously, "find all references" on a variant field wouldn't find any
references outside the defining module. This is because variant fields
were incorrectly assumed to be private, like struct fields without
explicit visibility, but they actually inherit the enum's visibility.
2020-10-09 20:46:45 +02:00
Jonas Schievink
210456aeaa Treat ast::Name in field patterns as use 2020-10-09 19:56:54 +02:00
Jonas Schievink
55ecfbb99b
Update crates/project_model/src/sysroot.rs
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-10-09 16:17:05 +02:00
Jonas Schievink
7d0772e796 Add note if RUST_SRC_PATH is likely to be wrong 2020-10-09 16:11:16 +02:00
Jonas Schievink
468b804856 Fix source_to_def for named enum variant fields 2020-10-09 02:57:35 +02:00
Benjamin Coenen
3bfa3e8123 when generating new function, focus on return type instead of body
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-08 20:57:18 +02:00
Benjamin Coenen
36459284c7 add eprintln in fmt-like postfix
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-08 20:53:39 +02:00
kjeremy
13bb0404a8 Bump rustc_lexer, cfg-if to 1.0 and add new license to check 2020-10-08 10:39:02 -04:00
bors[bot]
e6a05e6566
Merge #5651
5651: Add track_env_var to the proc macro server r=kjeremy a=lnicola

See https://github.com/rust-lang/rust/pull/74653.

Fixes #6054.
Fixes #5640, maybe.

Should be merged when 1.47 is released.

Proc macros still don't work for me, but it no longer crashes.



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-10-08 14:27:30 +00:00
Laurențiu Nicola
3d169bd3f4 Add track_env_var to the proc macro server 2020-10-08 17:06:20 +03:00
Zac Pullar-Strecker
3bd4fe96dc Remove methodowner & fix formatting 2020-10-08 15:50:48 +13:00
Zac Pullar-Strecker
8af1dd7337 Rebase fixes 2020-10-08 15:22:57 +13:00
Zac Pullar-Strecker
d2c68809ea Changes from review 2020-10-08 15:05:24 +13:00
Zac Pullar-Strecker
e4a787fcbc Remove outdated part of doc_links module docs 2020-10-08 15:05:23 +13:00
Zac Pullar-Strecker
f6759ba3bb Add ignored test to demonstrate ImportMap bug 2020-10-08 15:05:23 +13:00
Zac Pullar-Strecker
6cae6b8f3c Fix namespace detection & function test 2020-10-08 15:04:57 +13:00
Zac Pullar-Strecker
37a4d060a7 Add tests 2020-10-08 15:04:57 +13:00
Zac Pullar-Strecker
ec75d8bd75 Update tests for new function field 2020-10-08 15:04:57 +13:00
Zac Pullar-Strecker
26086faab2 Change Option::Some bug to a fixme note
IMO this is too much work to be worth fixing at the moment.
2020-10-08 15:04:57 +13:00
Zac Pullar-Strecker
c648884397 Differentiate method/tymethod by determining 'defaultness'
Currently a method only has defaultness if it is a provided trait
method, but this will change when specialisation is available and may
need to become a concept known to hir.

I opted to go for a 'fewest changes' approach given specialisation is
still under development.
2020-10-08 15:04:21 +13:00
Zac Pullar-Strecker
974518fde7 Code reorganisation and field support 2020-10-08 15:04:20 +13:00
Zac Pullar-Strecker
a14194b428 Changes from review 2020-10-08 15:01:30 +13:00
Zac Pullar-Strecker
8c32bdea36 Rename ide::link_rewrite -> ide::doc_links & tidy imports 2020-10-08 15:01:30 +13:00
Zac Pullar-Strecker
a06d736b77 Add support for struct & trait methods 2020-10-08 14:59:31 +13:00
Zac Pullar-Strecker
bfda0d2583 WIP: Command to open docs under cursor 2020-10-08 14:59:31 +13:00
bors[bot]
e95e666b10
Merge #6161
6161: Bump chalk to use latest git to get upstream fix r=jonas-schievink a=Ameobea

 * Chalk very recently (like an hour ago) merged a fix that prevents rust analyzer from panicking.  This allows it to be usable again for code that hits those situations.  See #6134, #6145, Probably #6120

Co-authored-by: Casey Primozic <me@ameo.link>
2020-10-07 20:46:33 +00:00
Casey Primozic
37df2138ec
Switch from git to latest tagged release of chalk deps 2020-10-07 12:11:22 -07:00
bors[bot]
83a651b123
Merge #6154
6154: Shorten type hints for std::iter Iterators r=SomeoneToIgnore a=Veykril

Fixes #3750.

This re-exports the `hir_expand::name::known` module to be able to fetch the `Iterator` and `iter` names.
I'm not sure if there is anything to do with `Solution::Ambig` in `normalize_trait_assoc_type` or whether discarding those results is always wanted.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-07 11:52:05 +00:00
Lukas Wirth
783af171f7 Clean up inlay_hints 2020-10-07 13:18:12 +02:00
Aleksey Kladov
6219142c96 Better progress API
Percentage is a UI concern, the physical fact here is fraction. It's
sad that percentage bleeds into the protocol level, we even duplicated
this bad API ourselves!
2020-10-07 12:15:37 +02:00
Lukas Wirth
e106857e80 Shorten iterator hints for std::iter iterators behind references 2020-10-07 12:14:08 +02:00
Aleksey Kladov
fd8622e1ec Cleanup 2020-10-07 11:55:20 +02:00
bors[bot]
faddea9353
Merge #6158
6158: Fix for negative literals in macros r=matklad a=cutsoy

_This pull request fixes #6028._

When writing `-42.0f32` in Rust, it is usually parsed as two different tokens (a minus operator and a float literal).

But a procedural macro can also generate new tokens, including negative [float literals](https://doc.rust-lang.org/stable/proc_macro/struct.Literal.html#method.f32_suffixed):

```rust
#[proc_macro]
fn example_verbose(input: TokenStream) -> TokenStream {
    let literal = Literal::f32_suffixed(-42.0);
    quote! { #literal }
}
```

or even shorter

```rust
#[proc_macro]
fn example(input: TokenStream) -> TokenStream {
    let literal = -42.0f32;
    quote! { #literal }
}
```

Unfortunately, these currently cause RA to crash:

```
thread '<unnamed>' panicked at 'Fail to convert given literal Literal {
    text: "-42.0f32",
    id: TokenId(
        4294967295,
    ),
}', crates/mbe/src/subtree_source.rs:161:28
```

This pull request contains both a fix 8cf9362 and a unit test 27798ee. In addition, I installed the patched server with `cargo xtask install --server` and verified in VSCode that it no longer crashes when a procedural macro returns a negative number literal.

Co-authored-by: Tim <tim@glacyr.com>
2020-10-07 09:32:47 +00:00
Lukas Wirth
209e9b9926 Shorten iterator chain hints 2020-10-07 11:30:42 +02:00
bors[bot]
a184c83535
Merge #6160
6160: Add validation check for ambiguous trait objects r=matklad a=Veykril

Fixes #285.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-07 09:12:09 +00:00
Lukas Wirth
c133651e0a Move IntoIterator into FamousDefs 2020-10-07 10:14:42 +02:00
Casey Primozic
13bdadb515
Make unimplemented match variants explicit 2020-10-06 23:56:31 -07:00
Casey Primozic
f40e86e141
todo!() -> unimplemented!() // FIXME for CI 2020-10-06 15:19:34 -07:00
Casey Primozic
56a8a7645f
Bump chalk to use latest git to get fix
* Chalk very recently (like an hour ago) merged a fix that prevents rust analyzer from panicking.  This allows it to be usable again for code that hits those situations.  See #6134, #6145, Probably #6120
2020-10-06 15:05:20 -07:00
Lukas Wirth
6f38552edb Add validation check for ambiguous trait objects 2020-10-06 23:52:00 +02:00
Tim
27798ee575
Added unit test for negative number literals in macros. 2020-10-06 22:28:13 +02:00
Tim
8cf9362984
Fixed parsing of negative number literals in macros. 2020-10-06 22:28:13 +02:00
Lukas Wirth
c6f1de6ac5 Use FamousDefs for shorten_iterator hint 2020-10-06 21:25:39 +02:00
bors[bot]
bf1043cac2
Merge #6128
6128: Trim all trailing whitespace in onEnter r=matklad a=repnop

Fixes #5848

Co-authored-by: Wesley Norris <repnop@outlook.com>
2020-10-06 18:17:49 +00:00
Aleksey Kladov
d7991f5f21 Document privacy invariant of SyntaxPtr 2020-10-06 20:06:14 +02:00
bors[bot]
57735f2a32
Merge #6140
6140: honour hover.content_format client capability r=lnicola a=robinvd

This removes all markdown when the client does not support the markdown MarkupKind.

Otherwise the output on the editor will have some markdown boilerplate, making it less readable.

For example kak_lsp does not currently support markdown.
![image](https://user-images.githubusercontent.com/22073483/95112949-ef0ff080-0741-11eb-82a7-0594fa2cd736.png)

after:
![image](https://user-images.githubusercontent.com/22073483/95113089-2bdbe780-0742-11eb-94fa-bcfec6d7347a.png)



Co-authored-by: Robin van Dijk <robin@robinjint.nl>
2020-10-06 17:51:20 +00:00
Aleksey Kladov
801e5b453c Add test makr 2020-10-06 19:20:56 +02:00
Lukas Wirth
aaa3905fdd Shorten type hints for std::iter Iterators 2020-10-06 19:20:42 +02:00
Aleksey Kladov
0d3bc38577 Constrain ImportMap to only store simple paths 2020-10-06 17:04:29 +02:00
Robin van Dijk
bd7bf4a276 add break after codeblocks 2020-10-06 16:34:38 +02:00
Robin van Dijk
bc890ed5b0 add doc describing limited capabilities 2020-10-06 16:34:26 +02:00
bors[bot]
81d6816f17
Merge #6150
6150: Move ModPath->ast::Path function to IDE layer r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-10-06 14:21:05 +00:00
Aleksey Kladov
2090b534fc Move ModPath->ast::Path function to IDE layer
closes #6092
2020-10-06 16:19:18 +02:00
bors[bot]
8bf13292f0
Merge #6148
6148: Fix trait object hir formatting behind pointer and references r=matklad a=Veykril

Fixes #6064

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-06 13:28:03 +00:00
Lukas Wirth
643bbf15a2 Fix trait object hir formatting behind pointer and references 2020-10-06 14:40:27 +02:00
bors[bot]
87cb840a4e
Merge #6124
6124: Better normalized crate name usage r=jonas-schievink a=SomeoneToIgnore

Closes https://github.com/rust-analyzer/rust-analyzer/issues/5343 
Closes https://github.com/rust-analyzer/rust-analyzer/issues/5932

Uses normalized name for code snippets (to be able to test the fix), hover messages and documentation rewrite links (are there any tests for those?).
Also renamed the field to better resemble the semantics.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-10-06 11:51:15 +00:00
bors[bot]
af0e54a566
Merge #6139
6139: Make find_path_prefixed configurable r=matklad a=Veykril

This makes `find_path_prefixed` more configurable allowing one to choose whether it always returns absolute paths, self-prefixed paths or to ignore local imports when building the path. 

The config names are just thrown in here, taking better names if they exist :)

This should fix #6131 as well?

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-06 11:43:08 +00:00
Kirill Bulatov
af4ae86e27 Do not leave braces for colons in dbg! 2020-10-06 14:21:22 +03:00
bors[bot]
dd6a352e64
Merge #6111
6111: Add assist for converting the base of integer literals. r=SomeoneToIgnore a=vlakreeh

This PR adds an assist similar to Intellij's [convert number to](https://i.imgur.com/JH6wstP.png). It also does a small refactor to [assists/src/tests.rs](fc34403018/crates/assists/src/tests.rs) to add the ability to specify the resolved assist for a specific action within an assist group.

## Demo
![Demo of the assist in action](https://i.imgur.com/MBhdPFH.gif)

Co-authored-by: vlakreeh <zeb@zebulon.dev>
2020-10-05 22:00:40 +00:00
Jonas Schievink
8ab7696acd Account for proc macro helpers when parsing attr 2020-10-05 23:41:16 +02:00
bors[bot]
44587d1bfc
Merge #6127
6127: Correctly complete items with leading underscore r=SomeoneToIgnore a=fmease

Fixes #6091. Let me know if the test is placed into the right file or if it is even desired.

Co-authored-by: León Orell Valerian Liehr <liehr.exchange@gmx.net>
2020-10-05 21:27:18 +00:00
Aleksey Kladov
bff812ddfe Fix feature name 2020-10-05 20:25:11 +02:00
Robin van Dijk
81f61afa9f add docstring 2020-10-05 20:06:25 +02:00
Robin van Dijk
c3cc361294 honor content_format clientcap
This removes all markdown when the client does not support the markdown MarkupKind

Otherwise the output on the editor will have some markdown boilerplate, making it less readable
2020-10-05 19:27:29 +02:00
Lukas Wirth
8699331014 Make ImportPrefix a configuration option 2020-10-05 17:41:49 +02:00
Lukas Wirth
67e71619b9 Make find_path_prefixed configurable 2020-10-05 17:12:37 +02:00
Wesley Norris
adb3c56ff0 Trim all trailing whitespace in onEnter
Fixes #5848
2020-10-03 14:17:21 -04:00
Igor Aleksanov
3cadba4956 Improve readability in inlay_hints.rs 2020-10-03 13:44:43 +03:00
Igor Aleksanov
91a09f50f4 Remove 'for_expr' test from inlay_hints.rs 2020-10-03 08:58:17 +03:00
Igor Aleksanov
a58441ad1b Make the tests for complete/incomplete for inlay hints work 2020-10-03 08:37:58 +03:00
Igor Aleksanov
8ca214fbfb Better inlay hints in 'for' loops 2020-10-03 08:30:25 +03:00
León Orell Valerian Liehr
32864e3b49 Correctly complete items with leading underscore 2020-10-03 03:00:09 +02:00
Aleksey Kladov
3290bb4112 Simplify ast_transform 2020-10-02 20:52:48 +02:00
Kirill Bulatov
9d19e5b962 Properly name the field 2020-10-02 21:38:22 +03:00
Kirill Bulatov
99952f3be2 Fix the hover dash issues 2020-10-02 21:16:22 +03:00
Kirill Bulatov
cae2e859ff Add a dash test 2020-10-02 20:59:32 +03:00
Aleksey Kladov
b06259673f rename mock_analysis -> fixture 2020-10-02 17:49:44 +02:00
Aleksey Kladov
09348b2474 Get rid of MockAnalysis 2020-10-02 17:31:20 +02:00
Aleksey Kladov
eeb27f95f1 Rewrite fixtures on top of Change 2020-10-02 16:45:08 +02:00
Aleksey Kladov
8716c4cec3 Move ide::AnalysisChange -> base_db::Change
This seems like a better factoring logically; ideally, clients shouldn't touch
`set_` methods of the database directly. Additionally, I think this
should remove the unfortunate duplication in fixture code.
2020-10-02 16:45:08 +02:00
Aleksey Kladov
700c9bc019 Expectify find_references tests 2020-10-02 16:42:48 +02:00
Aleksey Kladov
763b13a74e Reduce visibiity 2020-10-02 14:26:40 +02:00
bors[bot]
6574a6f448
Merge #5988
5988: Postfix completions for fmt-like string literals r=matklad a=popzxc

This pull request adds a bunch of new postfix completions for `format`-like string literls.

For example, `"{32} {some_var:?}".println` will expand to `println!("{} {:?}", 32, some_var)`.

Postfix completions were added for most common format-like macros:

- `println` -> `println!(...)`
- `fmt` -> `format!(...)`
- `panic` -> `panic!(...)`
- `log` macros:
  + `logi` -> `log::info!(...)`
  + `logw` -> `log::warn!(...)`
  + `loge` -> `log::error!(...)`
  + `logt` -> `log::trace!(...)`
  + `logd` -> `log::debug!(...)`

![fmt_postfix](https://user-images.githubusercontent.com/12111581/92998650-a048af80-f523-11ea-8fd8-410146de8caa.gif)



Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
2020-10-02 12:13:53 +00:00
Igor Aleksanov
97f2905dec Use expect_test to make format_str_parser test more data-driven 2020-10-02 14:51:20 +03:00
Igor Aleksanov
76d0546ac7 Use lookup table instead of enum for postfix completion kinds 2020-10-02 13:33:27 +03:00
Igor Aleksanov
b7ac540f15 Use ast::String for extracting string literal contents 2020-10-02 13:23:49 +03:00
Igor Aleksanov
2557cb8518 Improve format-like completions code appearance 2020-10-02 12:49:33 +03:00
Igor Aleksanov
777ccb58f0 Add missing entry to doc-comment 2020-10-02 12:42:39 +03:00
Igor Aleksanov
cd3d654f60 Simplify is_string_literal function 2020-10-02 12:42:39 +03:00
Igor Aleksanov
e447b3a4a2 Improve checks for postfix suggestions 2020-10-02 12:42:39 +03:00
Igor Aleksanov
ea320141c6 Add postfix completion for format-like string literals 2020-10-02 12:42:39 +03:00
bors[bot]
d8e5265309
Merge #5954
5954: Add flexible configuration for runnables r=popzxc a=popzxc

This PR introduces two new configuration options for runnables: `overrideCargo` and `cargoExtraArgs`.
These options are applied to all the "run" tasks of rust analyzer, such as binaries and tests.

Overall motivation is that rust-analyzer provides similar options, for example, for `rustfmt`, but not for runnables.

## `overrideCargo`

This option allows user to replace `cargo` command with something else (well, something that is compatible with the cargo arguments).

Motivation is that some projects may have wrappers around cargo (or even whole alternatives to cargo), which do something related to the project, and only then run `cargo`. With this feature, such users will be able to use lens and run tests directly from the IDE rather than from terminal.

![cargo_override](https://user-images.githubusercontent.com/12111581/92306622-2f404f80-ef99-11ea-9bb7-6c6192a2c54a.gif)

## `cargoExtraArgs`

This option allows user to add any additional arguments for `cargo`, such as `--release`.

It may be useful, for example, if project has big integration tests which take too long in debug mode, or if any other `cargo` flag has to be passed.

![cargo_extra_args](https://user-images.githubusercontent.com/12111581/92306658-821a0700-ef99-11ea-8be9-bf0aff78e154.gif)

Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
2020-10-02 09:42:03 +00:00
Igor Aleksanov
4ebacf9024 Fix failing test 2020-10-02 12:35:25 +03:00
Igor Aleksanov
4a1b4b23bb Replace 'cargo_prefix' option with 'override_cargo' 2020-10-02 12:34:27 +03:00
Igor Aleksanov
2c125f3c63 Add support of runnables arguments in Rust Analyzer 2020-10-02 12:34:27 +03:00
bors[bot]
40a028c9a8
Merge #6105
6105: Fix path comparison not comparing paths correctly with unequal lengths r=matklad a=Veykril

~~This PR includes the commit from #6102 there as I found a bug while writing that(so either merging this or both in order works) so I included a test there already which was just ignored.~~ This PR fixes that, basically inserting imports didn't consider path length for equality, so depending on the order it might insert the path before or after another import if they only differ in segment length.

~~Diff without the commit of #6102 2d90d3937d~~



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-02 09:30:25 +00:00
bors[bot]
e535489f03
Merge #6104
6104: Minor clippy performance suggestions r=matklad a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-10-02 08:07:42 +00:00
kjeremy
ff678e1349 Up rustc-ap-rustc_lexer to 681
cargo update as well
2020-10-01 15:21:13 -04:00
Lukas Wirth
95ea23cdef Fix path comparison not comparing paths correctly with unequal lengths 2020-10-01 17:18:34 +02:00
kjeremy
82d6cfd495 Minor clippy performance suggestions 2020-09-30 15:22:49 -04:00
Lukas Wirth
0671bf2d73 Fix MergingBehaviour::Last not working properly 2020-09-30 19:09:17 +02:00
vlakreeh
b2bfadb52c Add tests for convert integer literal assist 2020-09-29 19:05:17 -04:00
vlakreeh
91b4746c01 Add ability to specify ResolvedAssist by label 2020-09-29 18:22:09 -04:00
Aleksey Kladov
af8063fe37 Extend **Status** command to also show dep info for the file
This should help with troubleshooting wrong project configuration
2020-09-29 22:13:23 +02:00
Aleksey Kladov
e7df0ad2fb Remove periodic gc stub 2020-09-29 21:22:48 +02:00
Aleksey Kladov
8e34c0fb73 More panic_context 2020-09-29 20:49:48 +02:00
vlakreeh
c84fdb8b3e Add convert integer literal assist 2020-09-29 14:48:43 -04:00
Aleksey Kladov
d3a2b21a8c Add panic_context module for better panic messages 2020-09-29 20:20:47 +02:00
vsrs
91da41b3b1 Replace "No references" with "0 references". 2020-09-29 15:29:20 +03:00
vsrs
cd5eeb904e Add tests 2020-09-29 15:29:20 +03:00
vsrs
1895716c88 Do not show references CodeLens for tests. 2020-09-29 15:29:20 +03:00
vsrs
06fbd69050 Make method references CodeLens lazy. 2020-09-29 15:29:20 +03:00
vsrs
b7fda5f936 Make method references CodeLens off by default. 2020-09-29 15:29:20 +03:00
vsrs
eeb40dbece Add method references CodeLens 2020-09-29 15:29:20 +03:00
flw
e73ee9dfa2
Add hover config linksInHover to suppress links 2020-09-29 19:47:18 +08:00
bors[bot]
18c62c8a39
Merge #6019
6019: Remove make::path_from_text r=matklad a=Veykril

This removes the `make::path_from_text` function, which according to a note should've been private. I removed it since it didn't really serve a purpose as it was simply wrapping `make::ast_from_text`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-09-29 10:29:33 +00:00
bors[bot]
7b674f9ab4
Merge #6088
6088: Update chalk to 0.30.0 r=flodiebold a=nathanwhit

Fixes #6078 and CI failures.



Co-authored-by: Nathan Whitaker <nathan.whitaker01@gmail.com>
2020-09-28 18:30:50 +00:00
Nathan Whitaker
f50458deaf Update chalk to 0.30.0 2020-09-28 14:24:11 -04:00
Aleksey Kladov
6ff78962b3 Microoptimize 2020-09-28 19:06:51 +02:00
Jeremy Kolb
76dfac7894 chalk 0.29.0 2020-09-28 07:44:27 -04:00
bors[bot]
0fb5d9d87a
Merge #6033
6033: Make name resolution resolve proc macros instead of relying purely on the build system r=matklad a=jonas-schievink

This makes name resolution look at proc-macro declaration attributes like `#[proc_macro_derive]` and defines the right proc macro in the macro namespace, fixing unresolved custom derives like `thiserror::Error` (which can cause false positives, now that we emit diagnostics for unresolved imports).

This works even when proc-macro support is turned off, in which case we fall back to a dummy expander that always returns an error. IMO this is the right way to handle at least the name resolution part of proc. macros, while the *expansion* itself should rely on the build system to build and provide the macro DLL. It does mean that they may go out of sync, but we can provide diagnostics if that happens (something like "could not find macro X in crate Y – ensure that all files of crate Y are saved").

I think it is valuable to be able to reason about proc macros even when we can't expand them, since proc macro expansion can break between Rust releases or users might not want to turn it on for performance reasons. It allows us to provide better diagnostics on any proc macro invocation we're not expanding (like a weak warning that informs the user that proc macro support is turned off, or that it has been disabled because the server crashed).

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

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-09-28 11:03:47 +00:00
Jonas Schievink
e88e4fbb7b Add more comments about proc macro resolution 2020-09-28 13:02:28 +02:00
Jonas Schievink
e799dbe5d7 Simplify iterator chain 2020-09-28 12:51:40 +02:00
bors[bot]
000046cfa0
Merge #6085
6085: Mark unresolved imports diagnostic as experimental r=jonas-schievink a=jonas-schievink

It causes a lot of false positives for people. We collected all of the known ones during the last week.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-09-28 10:47:33 +00:00
Jonas Schievink
f0b5832cb8 Mark unresolved imports diagnostic as experimental 2020-09-28 12:45:20 +02:00
Jonas Schievink
1a28f30ba4 Spawn a flycheck instance per workspace 2020-09-27 19:41:54 +02:00
bors[bot]
662ed41ebc
Merge #6073
6073: Dont unnecessarily unnest imports r=matklad a=Veykril

Fixes #6071

This has the side effect that paths that refer to items inside of the current module get prefixed with `self`. Changing this behavior is unfortunately not straightforward should it be unwanted, though I don't see a problem with this as prefixing imports like this with `self` is what I do personally anyways 😅. You can see what I mean with this in one of the tests which had to be changed in `crates/ssr/src/tests.rs`.

There is one test that i still have to look at though, ~~which I by accident pushed with `#[ignore]` on it~~, which is `different_crate_renamed`, for some reason this now doesn't use the crate alias. This also makes me believe that aliases in general will break with this. So maybe this is not as straight forwards as I'd hoped for, but I don't really know how aliases work here.

Edit: The failing test should work now

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-09-25 14:57:15 +00:00
bors[bot]
dc09f1597f
Merge #6076
6076: Update chalk to 0.28.0 r=matklad a=vandenheuvel



Co-authored-by: Bram van den Heuvel <bram@vandenheuvel.online>
2020-09-25 14:47:56 +00:00
Bram van den Heuvel
dff6895ce8 Update chalk to 0.28.0 2020-09-25 15:29:31 +02:00
Lukas Wirth
747f6f64d7 Remove partial import test in insert_use 2020-09-25 15:21:50 +02:00
Lukas Wirth
e1d6981f90 Don't unnecessarily unnest imports for import insertion 2020-09-25 15:19:22 +02:00
bors[bot]
cfe987bcdf
Merge #6055
6055: Add ok postfix completion r=matklad a=mullr

Wrapping values in `Ok(...)` is so pervasive that it seems reasonable for it to
have its own postfix completion.


Co-authored-by: Russell Mull <russell.mull@gmail.com>
2020-09-25 11:55:35 +00:00
bors[bot]
163ffb8803
Merge #6072
6072: Cleanup unintended unresolved reference in syntax higlighting test r=matklad a=Nashenas88

Fixes the issue brought up here https://github.com/rust-analyzer/rust-analyzer/pull/5957#discussion_r486625707

cc @jonas-schievink 

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-09-25 11:49:12 +00:00
Jean SIMARD
875ad9b5c4
Bump smol_str from 0.1.16 to 0.1.17 2020-09-24 16:39:08 +02:00
Paul Daniel Faria
ed8968af49 Cleanup unintended unresolved reference in syntax higlighting test 2020-09-24 10:14:25 -04:00
bors[bot]
5d137f21f2
Merge #6056
6056: Add dbgr postfix completion r=matklad a=lnicola

Expanding to `dbg!(&e)`.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-09-24 14:14:01 +00:00
bors[bot]
9d3483a74d
Merge #5846
5846: Add references to fn args during completion r=matklad a=adamrk

When completing a function call, if there is an argument taken as a ref or mut ref which matches the name and type of a variable in scope, we will insert a `&` or `&mut` when filling in the function arguments. This addresses https://github.com/rust-analyzer/rust-analyzer/issues/5449.

E.g. 
```rust
fn foo(x: &i32) {}
fn main() {
  let x = 5;
  foo # completing foo here generates `foo(&x)` now instead of `foo(x)`
}
```

Co-authored-by: adamrk <ark.email@gmail.com>
2020-09-24 12:23:28 +00:00
kjeremy
95d7e3ce49 lsp-types 0.82 2020-09-23 15:41:55 -04:00
Laurențiu Nicola
eb0e710779 Add dbgr postfix completion 2020-09-22 08:54:57 +03:00
Russell Mull
197d1e1b05 Cargo fmt 2020-09-21 17:47:20 -07:00
Russell Mull
e3b19da8c1 Add ok postfix completion 2020-09-21 17:15:20 -07:00
Aleksey Kladov
fcc3c49013
Apply suggestions from code review
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-09-21 15:35:42 +03:00
Aleksey Kladov
8e3082ff6e Document AstTransformation 2020-09-21 12:36:51 +02:00
Aleksey Kladov
2c916bbc18 Document SemanticScope 2020-09-21 12:30:55 +02:00
bors[bot]
3b52d3181a
Merge #6043
6043: Allow missing trait members assist without needing braces r=matklad a=M-J-Hooper

Assist to complete missing items when implementing a trait does not appear without impl def braces (see #5144 ).

The reason behind this was that this assist is based on `ast::AssocItemList` which only appears in the AST after the braces are added to the impl def.

Instead of relying on and replacing the item list, we now instead replace the entire `ast::Impl` and add the item list if its missing.

Co-authored-by: Matt Hooper <matthewjhooper94@gmail.com>
2020-09-21 09:06:24 +00:00
Matt Hooper
7d90bb1f47 Rename impl edit method to be more explicit 2020-09-21 10:01:50 +01:00
Matt Hooper
532be0e780 Added test for impl member assist when impl def is missing braces 2020-09-21 09:48:51 +01:00
Matt Hooper
9724af038b Replace entire impl def instead of only associated items for missing impl member assist (if braces are missing from an impl def then there is no associated item list in the AST) 2020-09-21 00:42:27 +01:00
Matt Hooper
ae7c982421 Add make utility for empty associated item lists 2020-09-21 00:39:17 +01:00
Matt Hooper
4362297a0b Add edit utility for adding an associated item list to a impl def 2020-09-21 00:38:18 +01:00
bors[bot]
e70cf706bb
Merge #6018
6018: Correct project_root path for ProjectJson. r=jonas-schievink a=woody77

It was already the folder containing the rust-project.json file, not the file itself.  This also removes the Option-ness of it, since it's now an infallible operation to set the member value.

Co-authored-by: Aaron Wood <aaronwood@google.com>
2020-09-20 19:25:09 +00:00
Aaron Wood
38f1ce633d Add rustdoc for ProjectJson methods 2020-09-20 12:06:12 -07:00
bors[bot]
fb1b0a4bff
Merge #6036
6036: Don't re-read open files from disk when reloading a workspace r=kjeremy a=lnicola

Fixes #5742
Fixes #4263

or so I hope.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-09-18 21:29:47 +00:00
Laurențiu Nicola
5a0bad7754 Don't re-read open files from disk when reloading a workspace 2020-09-18 22:15:44 +03:00
Jonas Schievink
46c5b557fe Log failure to load crate root file 2020-09-18 19:27:19 +02:00
Jonas Schievink
7474a42b00 Remove incorrect docs 2020-09-18 18:09:47 +02:00
Jonas Schievink
baab72e611 Reduce visibility of non-proc-macros
proc-macro crates only export proc-macros, but currently other items
are also considered public (and show up in completion)
2020-09-18 17:50:04 +02:00
kjeremy
c7243e4a59 Support active parameters at the per-signature level
Update crates
2020-09-18 11:39:25 -04:00
Jonas Schievink
069045015c Remove obsolete proc macro collection code
The new attribute-based resolution takes care of this
2020-09-18 16:52:24 +02:00
Jonas Schievink
5486b70bc0 Use hir_def to resolve proc macros 2020-09-18 16:43:50 +02:00
Jonas Schievink
dfa3a3f017 Add test 2020-09-18 16:37:12 +02:00
Jonas Schievink
9dc0afe854 Rename CustomDerive to ProcMacro
It handles fn-like macros too, and will handle attribute macros in the
future
2020-09-18 15:37:31 +02:00
Jonas Schievink
700a3d5d75 Invert condition to unindent code 2020-09-18 12:32:07 +02:00
Jonas Schievink
d328ee647f Use log::error! in a few more places 2020-09-17 17:37:52 +02:00
Jonas Schievink
6eea06415d Give ExternCrate a Name, not a ModPath 2020-09-17 15:28:23 +02:00
bors[bot]
d84c18d989
Merge #6017
6017: Don't return any TextEdit if formatting is unchanged r=jonas-schievink a=cuviper

I found that `textDocument/formatting` was always returning a full
`TextEdit` replacement, even when there are no changes, which caused Vim
(w/ vim-lsp) to always indicate a modified buffer after formatting. We
can easily compare whether there were changes and return `null` if not,
so the client knows there's nothing to do.

Co-authored-by: Josh Stone <cuviper@gmail.com>
2020-09-17 13:08:09 +00:00
bors[bot]
933fc1eb18
Merge #6016
6016: Emit diagnostics for unresolved imports and extern crates r=jonas-schievink a=jonas-schievink

AFAIK, we don't have any major bugs in name resolution that would cause a lot of false positives here (except procedural attribute macro support and some rare issues around `#[path]` on module files), so these are *not* marked as experimental diagnostics right now.

I noticed that diagnostics in a file sometimes don't get displayed after opening, but require some edit to be performed. This seems like a preexisting issue though.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-09-17 13:00:25 +00:00
Jonas Schievink
0dca7acf0f Don't diagnose imports whose base crate is missing 2020-09-17 14:48:17 +02:00
bors[bot]
3877421373
Merge #5989
5989: Rewrite import merging r=jonas-schievink a=Veykril

Rewrites how import merging is being handled. It is now a recursive function to properly handle merging of intermediate levels in the import trees. With this ordering the imports is also now possible tho it doesn't quite order it the same way as `rustfmt` does yet, namely it orders lowercase identifiers after uppercase identifiers as that is the standard character order that rust uses. This also fixes a few weird behaviors that were visible in some of the `replace_qualified_name_with_use.rs` tests.

This really took longer than I was hoping for, fighting with import trees is quite the exhausting task 😅 

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-09-16 20:03:41 +00:00
Lukas Wirth
f2ae412ccf Remove make::path_from_text 2020-09-16 21:36:10 +02:00
Aaron Wood
2fbb09a73f Correct project_root path for ProjectJson.
It was already the folder containing the rust-project.json file, not the file itself.
2020-09-16 12:09:44 -07:00
Lukas Wirth
45298b5d2a Add make::glob_use_tree function to create star-only UseTree 2020-09-16 20:33:08 +02:00
bors[bot]
4bc8015370
Merge #6013
6013: Add support for custom flycheck commands with JSON project workspaces r=jonas-schievink a=woody77

Enable flychecks with JSON project workspaces if an override command was provided as part
of the client configuration:

```
    "rust-analyzer.checkOnSave.enable": true,
    "rust-analyzer.checkOnSave.overrideCommand": ["custom_tool", "arg1", "arg2"],
```


Co-authored-by: Aaron Wood <aaronwood@google.com>
2020-09-16 18:04:29 +00:00
bors[bot]
5df69d9034
Merge #5993
5993: Update chalk to 0.27 and add support for extern opaque types. r=crlf0710 a=crlf0710



Co-authored-by: Charles Lew <crlf0710@gmail.com>
2020-09-16 17:07:05 +00:00
Josh Stone
29c3421391 Don't return any TextEdit if formatting is unchanged
I found that `textDocument/formatting` was always returning a full
`TextEdit` replacement, even when there are no changes, which caused Vim
(w/ vim-lsp) to always indicate a modified buffer after formatting. We
can easily compare whether there were changes and return `null` if not,
so the client knows there's nothing to do.
2020-09-16 10:05:41 -07:00