Commit Graph

13154 Commits

Author SHA1 Message Date
bors[bot]
91c1af3612
Merge #6354
6354: Add tracing to main rust-analyzer binary r=flodiebold a=flodiebold

This makes `CHALK_DEBUG` logging work again e.g. when running `analysis-stats`, which is very helpful for debugging.

This change shouldn't regress compile times at all. The reason for that is that chalk-solve already pulls in these crates, and while that's behind a feature (mostly for our benefit, I think) we never actually disabled that feature 😅 So alternatively, we could disable the feature and maybe get an improvement in compile times. In my test I just did to see the impact of that, this PR actually compiled faster than the one just removing tracing though, so it's probably not a big deal.

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-10-25 12:54:18 +00:00
Florian Diebold
39dfca23f1 Add tracing to main rust-analyzer binary 2020-10-25 13:53:38 +01:00
bors[bot]
34034e4a64
Merge #6353
6353: Get rid of FAKE_PLACEHOLDER r=flodiebold a=flodiebold

The lifetime placeholder can be replaced by the static lifetime, and for array
sizes we should just be using a concrete const.

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-10-25 11:45:00 +00:00
Florian Diebold
6b5f82bcea Get rid of FAKE_PLACEHOLDER
The lifetime placeholder can be replaced by the static lifetime, and for array
sizes we should just be using a concrete const.
2020-10-25 12:42:38 +01:00
bors[bot]
bf84e4958e
Merge #6331 #6342
6331: correct hover text for items with doc attribute with raw strings r=matklad a=JoshMcguigan

Fixes #6300 by improving the handling of raw string literals in attribute style doc comments.

This still has a bug where it could consume too many `"` at the start or end of the comment text, just as the original code had. Not sure if we want to fix that as part of this PR or not? If so, I think I'd prefer to add a unit test for either the `as_simple_key_value` function (I'm not exactly sure where this would belong / how to set this up) or create a `fn(&SmolStr) -> &SmolStr` to unit test by factoring out the `trim` operations from `as_simple_key_value`. Thoughts on this? 

6342: Shorter dependency chain r=matklad a=popzxc

Continuing implementing suggestions from the `Completion refactoring` zulip thread.

This PR does the following:

- Removes dependency of `completions` on `assists` by moving required functionality into `ide_db`.
- Moves completely `call_info` crate into `ide_db` as it looks like it fits perfect there.
- Adds a bunch of new tests and docs.
- Adds the re-export of `base_db` to the `ide_db` and removes direct dependency on `base_db` from other crates.

The last point is controversial, I guess, but I noticed that in places where `ide_db` is used, `base_db` is also *always* used. Thus I think the dependency on the `base_db` is implied by the fact of `ide_db` interfaces, and thus it makes sense to just provide `base_db` out of the box.


Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
2020-10-24 19:08:12 +00:00
bors[bot]
11e18c31df
Merge #6344
6344: Bump deps r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-10-24 18:58:02 +00:00
bors[bot]
d5c294f78c
Merge #6337
6337: Fix indentation of inserted use statements r=flodiebold a=flodiebold



Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-10-24 16:26:08 +00:00
Florian Diebold
bc65200105 Fix indentation of inserted use statements 2020-10-24 18:25:23 +02:00
Laurențiu Nicola
c81d044622 Bump chalk 2020-10-24 17:14:05 +03:00
Laurențiu Nicola
4834015fd1 Bump rustc_lexer 2020-10-24 17:11:58 +03:00
Laurențiu Nicola
09468ce370 Bump deps 2020-10-24 17:10:36 +03:00
Igor Aleksanov
19cce08662 Re-export base_db from ide_db 2020-10-24 11:39:57 +03:00
Igor Aleksanov
2c787676c9 Add tests for traits functions in ide_db 2020-10-24 11:29:16 +03:00
Igor Aleksanov
b6ea56ea09 Make call_info a part of ide_db 2020-10-24 11:07:10 +03:00
Igor Aleksanov
8d3d509af7 Remove dependency on 'assists' from 'completion' crate 2020-10-24 10:47:23 +03:00
bors[bot]
4105378dc7
Merge #6330
6330: Textmate grammar: raw IDs, underscore fixes (closes #6293, #6340) r=dustypomerleau a=dustypomerleau

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

I've included the possibility of the `r#` prefix in:

- function definitions
- function/method calls
- variables/parameters

This way the raw ID will simply get whatever the intended scope was, instead of a unique scope that might be inappropriately themed for its purpose.

Will wait a bit for feedback, in case there are other places you might use raw IDs.

Co-authored-by: Dusty Pomerleau <dustypomerleau@users.noreply.github.com>
2020-10-24 03:31:17 +00:00
Josh Mcguigan
4e76e884bd correct hover for items with doc attribute with raw strings 2020-10-23 19:36:30 -07:00
Dusty Pomerleau
f352b98f7e fix: underscores, raw IDs
- remove comment scope from ignored params
- underscores will automatically receive variable/param scope
- add raw ID syntax to modules, functions, and variables
2020-10-24 13:00:26 +11:00
bors[bot]
2fa942ad30
Merge #6251 #6310
6251: Semantic Highlight: Add Callable modifier for variables r=matklad a=GrayJack

This PR added the `HighlightModifier::Callable` variant and assigned it to variables and parameters that are fn pointers, closures and implements FnOnce trait.

This allows to colorize these variables/parameters when used in call expression.



6310: Rewrite algo::diff to support insertion and deletion r=matklad a=Veykril

This in turn also makes `algo::diff` generate finer diffs(maybe even minimal diffs?) as insertions and deletions aren't always represented as as replacements of parent nodes now.

Required for #6287 to go on.

Co-authored-by: GrayJack <gr41.j4ck@gmail.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-23 22:12:15 +00:00
bors[bot]
c483212f27
Merge #6339
6339: Diagnose #[cfg]s in bodies r=matklad a=jonas-schievink

This PR threads diagnostics through body lowering using the `BodySourceMap`, and emits `InactiveCode` diagnostics for expressions, statements, and match arms that are `#[cfg]`d out.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-10-23 22:05:25 +00:00
bors[bot]
ea25ae614b
Merge #6336
6336: Improve Chalk debugging r=matklad a=flodiebold

 - add panic context for the trait goal if CHALK_DEBUG is set
 - print the Chalk program even if we're panicking
 - log goal/solution while TLS is still set

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-10-23 21:54:45 +00:00
bors[bot]
0c6f10ce42
Merge #6341
6341: Complete variants when only enun name is typed r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-10-23 21:42:53 +00:00
Aleksey Kladov
f9b81369e2 Complete variants when only enun name is typed
This allows the client to filter `Foo::Bar` when *either* `Foo` or
`Bar` is typed.
2020-10-23 23:41:47 +02:00
Jonas Schievink
5350c15e27 Fix name of InactiveCode diagnostic 2020-10-23 19:31:11 +02:00
Jonas Schievink
93dc6f511b Diagnose #[cfg]s in bodies 2020-10-23 19:27:04 +02:00
Florian Diebold
baeb16e83f Improve Chalk debugging
- add panic context for the trait goal if CHALK_DEBUG is set
 - print the Chalk program even if we're panicking
 - log goal/solution while TLS is still set
2020-10-23 15:28:02 +02:00
bors[bot]
dd8a75b2cf
Merge #6335
6335: Fix panic context r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-10-23 13:19:09 +00:00
Aleksey Kladov
1a74f25f90 Fix panic context 2020-10-23 15:18:33 +02:00
bors[bot]
81609960fa
Merge #6324
6324: Improve #[cfg] diagnostics r=jonas-schievink a=jonas-schievink

Unfortunately I ran into https://github.com/rust-analyzer/rust-analyzer/issues/4058 while testing this on https://github.com/nrf-rs/nrf-hal/, so I didn't see much of it in action yet, but it does seem to work.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-10-23 10:38:30 +00:00
Jonas Schievink
a246d4f599 cfg: move tests to separate file
that way we don't have to re-check the entire project when a test is
changed
2020-10-23 12:14:58 +02:00
Jonas Schievink
dab8870f5c Reorder items 2020-10-23 12:12:03 +02:00
Jonas Schievink
bfe1efca26 Use format_to
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-10-23 12:12:03 +02:00
bors[bot]
8b3c851dd3
Merge #6098
6098: Insert ref for completions r=adamrk a=adamrk

Follow up to https://github.com/rust-analyzer/rust-analyzer/pull/5846. When we have a local in scope which needs a ref or mutable ref to match the name and type of the active in the completion context then a new completion item with `&` or `&mut ` is inserted. E.g.
```rust
fn foo(arg: &i32){};
fn main() {
    let arg = 1_i32;
    foo(a<|>)
}
```
now offers `&arg` as a completion option with the highest score.

Co-authored-by: adamrk <ark.email@gmail.com>
2020-10-22 20:46:24 +00:00
adamrk
3dbbcfca67 Insert ref for completions 2020-10-22 22:45:14 +02:00
bors[bot]
edf46a13a6
Merge #6325 #6327
6325: Add generated diagnostic docs to the manual r=matklad a=flodiebold

It seemed that we're not actually including the generated diagnostic docs anywhere yet? So I added something to the manual. This is completely untested though.

6327: Update debugging.md r=matklad a=stanciuadrian

`on_task` is no longer there.
I have used `on_request` instead.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Co-authored-by: Adrian Stanciu <stanciu.adrian@gmail.com>
2020-10-22 18:15:48 +00:00
bors[bot]
3d349597fd
Merge #6326
6326: hide paramater inlay hints for cloned vars if applicable r=SomeoneToIgnore a=Veykril

This causes `foo.clone()` parameters to be handled as if they were just `foo` parameters for inlay hint logic.

Fixes #6315 

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-22 18:09:43 +00:00
Jonas Schievink
dbd6266bc9
Update crates/cfg/src/cfg_expr.rs
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-10-22 20:08:27 +02:00
Adrian Stanciu
5f5b1ffdd1
Update debugging.md 2020-10-22 21:04:09 +03:00
Lukas Wirth
78c3e4a23c Hide paramater inlay hints for cloned vars if applicable 2020-10-22 19:44:52 +02:00
Florian Diebold
b59a0dbf6a Add generated diagnostic docs to the manual 2020-10-22 19:42:01 +02:00
Jonas Schievink
3421b645e6 Emit better #[cfg] diagnostics 2020-10-22 19:19:18 +02:00
Jonas Schievink
978cc93649 Fix typo 2020-10-22 19:19:05 +02:00
Jonas Schievink
68b17986c7 Implement DNF-based #[cfg] introspection 2020-10-22 17:57:00 +02:00
bors[bot]
31db677a94
Merge #6319
6319: Properly identify camel cased acronyms as UpperCamelCase r=popzxc a=ArifRoktim

This closes #6305.

Co-authored-by: Arif Roktim <arifrroktim@gmail.com>
2020-10-22 14:24:10 +00:00
Lukas Wirth
0059188e77 algo::diff tests 2020-10-22 14:48:24 +02:00
bors[bot]
ab53bb8718
Merge #6320 #6321
6320: Textmate grammar: prevent line comments from breaking block comments (closes #6281) r=matklad a=dustypomerleau

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

Previously, line comments were able to break block comments by essentially commenting out the closing `*/`, resulting in a never-ending comment. This PR splits block comments into a separate repository group to fix this problem.

Since the comment scopes also include ignored parameters and inferred types, I've added the change proposed by @bnjjj in https://github.com/rust-analyzer/rust-analyzer/pull/6317, in order to close https://github.com/rust-analyzer/rust-analyzer/issues/6311 as well.

6321: Fix opening module documentation opening parent documentation instead r=matklad a=zacps

The whole path/URL joining code is kind of ugly which is what led to
this, but at the same time I don't really want to rewrite it right
now...

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

Co-authored-by: Dusty Pomerleau <dustypomerleau@users.noreply.github.com>
Co-authored-by: Zac Pullar-Strecker <zacmps@gmail.com>
2020-10-22 12:04:50 +00:00
bors[bot]
af75a08116
Merge #6314
6314: generate assist respect cfg attributes  r=matklad a=bnjjj

close #6312

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-22 11:58:11 +00:00
Lukas Wirth
d86863aeb4 Rewrite algo::diff to support insertion and deletion 2020-10-22 09:51:11 +02:00
Benjamin Coenen
f1fda43485 generate_impl assist respect cfg attributes #6312
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-22 09:48:48 +02:00
Zac Pullar-Strecker
68c67efa68 Fix opening module documentation opening parent documentation instead
The whole path/URL joining code is kind of ugly which is what led to
this, but at the same time I don't really want to rewrite it right
now...
2020-10-22 17:33:52 +13:00