]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoMerge #8051
bors[bot] [Tue, 16 Mar 2021 13:35:26 +0000 (13:35 +0000)]
Merge #8051

8051: Fix more unused wariable warnings r=lnicola a=lnicola

bors r+

changelog skip

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoFix more unused wariable warnings
Laurențiu Nicola [Tue, 16 Mar 2021 13:34:19 +0000 (15:34 +0200)]
Fix more unused wariable warnings

3 years agoMerge #7498
bors[bot] [Tue, 16 Mar 2021 13:14:48 +0000 (13:14 +0000)]
Merge #7498

7498: Clone for update r=matklad a=matklad

rowan counterpart https://github.com/rust-analyzer/rowan/pull/93

#6857

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoUpgrade rowan
Aleksey Kladov [Sat, 30 Jan 2021 15:19:21 +0000 (18:19 +0300)]
Upgrade rowan

Notably, new rowan comes with support for mutable syntax trees.

3 years agoMerge #7900 #8000
bors[bot] [Tue, 16 Mar 2021 08:05:24 +0000 (08:05 +0000)]
Merge #7900 #8000

7900: show function params in completion detail r=matklad a=JoshMcguigan

This resolves #7842 by updating the detail for function completions from `-> T` to `fn(T, U) -> V`. I added an expicit unit test for this, `ide_completion::render::fn_detail_includes_args_and_return_type`, which passes.

Lots of other unit tests fail (~60 of them) due to this change, although I believe the failures are purely cosmetic (they were testing the exact format of this output). I'm happy to go update those tests, but before I do that I'd like to make sure this is in fact the format we want for the detail?

edit - I realized `UPDATE_EXPECT=1 cargo test` automatically updates `expect!` tests. Big :+1: to whoever worked on that! So I'll go ahead and update all these tests soon. But I still would like to confirm `fn(T, U) -> V` is the desired content in the `detail` field.

8000: Use hir formatter for hover text r=matklad a=oxalica

Fix #2765 , (should) fix #4665

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
Co-authored-by: oxalica <oxalicc@pm.me>
3 years agoMerge #8036 #8046
bors[bot] [Tue, 16 Mar 2021 07:57:33 +0000 (07:57 +0000)]
Merge #8036 #8046

8036: completions: provide relevance bonus for enum types, and suggest ref matches for fn and enum r=matklad a=JoshMcguigan

This PR makes several improvements to completions and completion sorting:

1. Provide exact match type relevance score bonus for enum variants
2. Suggest `&Foo` (ref_match) for enums if that is an exact type match
3. Suggest `&foo()` (ref_match) if `foo` returns a type which would be an exact match either with the reference or due to a `Deref` impl

### Before

![pre-ref-relevance-centralized](https://user-images.githubusercontent.com/22216761/111189377-3f05a580-8573-11eb-89be-58a45cb7f829.png)

### After

![post-ref-relevance-centralized](https://user-images.githubusercontent.com/22216761/111189395-45941d00-8573-11eb-871b-09186b35cbb9.png)

### Caveats

I think generic types will require some kind of fancier logic when testing for `exact_type_match`, so for now `Option`/`Result`/etc unfortunately still don't have great completions.

### Implementation

I implemented this in a way that I think makes it most likely for each completion type to be handled consistently. Just replace `CompletionItem::new` with `CompletionItem::new_with_type_info` and `exact_type_match`/`exact_name_match`/`ref_match` are all handled for you, in a way which is sure to be consistent across completion types.

This approach does introduce some coupling/plumbing that didn't exist before. Notice for example `set_is_local` on the builder, because `set_relevance` was removed from the builder to enforce that the relevance was built "properly" with `CompletionItem::new_with_type_info`. But I think there are benefits to this approach, like `CompletionRelevance` should probably consider deprecation status, and we already tell the builder about that, so in the (likely near term) future we can just pass that information along to `CompletionRelevance` when the user calls `set_deprecated` rather than the user having to manually set it in two places. This basically just hides `CompletionRelevance` from the individual completions, so they only worry about the `CompletionItem` interface. At the moment this seems like a cleaner approach to me, but I'm open to feedback here.

edit - I've reimplemented this in a simpler way, per feedback below.

8046: Prefer match to if let else r=matklad a=matklad

bors r+
🤖

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoPrefer match to if let else
Aleksey Kladov [Tue, 16 Mar 2021 07:51:05 +0000 (10:51 +0300)]
Prefer match to if let else

3 years agoMerge #8045
bors[bot] [Tue, 16 Mar 2021 07:50:04 +0000 (07:50 +0000)]
Merge #8045

8045: Increase fetch-depth to make `git describe` work r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoIncrease fetch-depth to make `git describe` work
Laurențiu Nicola [Tue, 16 Mar 2021 07:48:50 +0000 (09:48 +0200)]
Increase fetch-depth to make `git describe` work

3 years agoMerge #8040
bors[bot] [Tue, 16 Mar 2021 07:41:58 +0000 (07:41 +0000)]
Merge #8040

8040: 7709: Added the check for return type of len function. r=Veykril a=chetankhilosiya

Co-authored-by: Chetan Khilosiya <chetan.khilosiya@gmail.com>
3 years agoMerge #8044
bors[bot] [Tue, 16 Mar 2021 05:48:05 +0000 (05:48 +0000)]
Merge #8044

8044: Fix macro expansion for statements w/o semicolon r=edwin0cheng a=edwin0cheng

Fixes  #7845

And up `ungrammer` to  1.12.

cc @jonas-schievink

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoFix macro expansion for statements w/o semicolon
Edwin Cheng [Tue, 16 Mar 2021 05:44:50 +0000 (13:44 +0800)]
Fix  macro expansion for statements w/o semicolon

3 years agocompletions: centralize calculation of relevance and ref matches
Josh Mcguigan [Tue, 16 Mar 2021 02:26:59 +0000 (19:26 -0700)]
completions: centralize calculation of relevance and ref matches

3 years ago7709: Import changes.
Chetan Khilosiya [Mon, 15 Mar 2021 20:28:21 +0000 (01:58 +0530)]
7709: Import changes.

3 years ago7709: Added the check for return type of len function.
Chetan Khilosiya [Mon, 15 Mar 2021 19:46:59 +0000 (01:16 +0530)]
7709: Added the check for return type of len function.

3 years agoMerge #8039
bors[bot] [Mon, 15 Mar 2021 18:49:07 +0000 (18:49 +0000)]
Merge #8039

8039: Use SmallVec for Substs r=flodiebold a=flodiebold

Doesn't help as much as I hoped, but it helps a bit and I also did some
refactorings that were necessary anyway.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoUse SmallVec for Substs
Florian Diebold [Mon, 15 Mar 2021 18:13:49 +0000 (19:13 +0100)]
Use SmallVec for Substs

Doesn't help as much as I hoped, but it helps a bit and I also did some
refactorings that were necessary anyway.

3 years agoMerge #7970
bors[bot] [Mon, 15 Mar 2021 18:24:22 +0000 (18:24 +0000)]
Merge #7970

7970: Fix incorrect diagnostics for failing built in macros r=jonas-schievink a=brandondong

**Reproduction:**
1. Use a built in macro in such a way that rust-analyzer fails to expand it. For example:

**lib.rs**
```
include!("<valid file but without a .rs extension so it is not indexed by rust-analyzer>");
```
2. rust-analyzer highlights the macro call and says the macro itself cannot be resolved even though include! is in the standard library (unresolved-macro-call diagnostic).
3. No macro-error diagnostic is raised.

**Root cause for incorrect unresolved-macro-call diagnostic:**
1. collector:collect_macro_call is able to resolve include! in legacy scope but the expansion fails. Therefore, it's pushed into unexpanded_macros to be retried with module scope.
2. include! fails at the resolution step in collector:resolve_macros now that it's using module scope. Therefore, it's retained in unexpanded_macros.
3. Finally, collector:finish tries resolving the remaining unexpanded macros but only with module scope. include! again fails at the resolution step so a diagnostic is created.

**Root cause for missing macro-error diagnostic:**
1. In collector:resolve_macros, directive.legacy is None since eager expansion failed in collector:collect_macro_call. The macro_call_as_call_id fails to resolve since we're retrying in module scope. Therefore, collect_macro_expansion is not called for the macro and no macro-error diagnostic is generated.

**Fix:**
- In collector:collect_macro_call, do not add failing built-in macros to the unexpanded_macros list and immediately raise the macro-error diagnostic. This is in contrast to lazy macros which are resolved in collector::resolve_macros and later expanded in collect_macro_expansion where a macro-error diagnostic may be raised.

Co-authored-by: Brandon <brandondong604@hotmail.com>
Co-authored-by: brandondong <brandondong604@hotmail.com>
3 years agoUpdate crates/hir_def/src/nameres/collector.rs
brandondong [Mon, 15 Mar 2021 18:16:58 +0000 (11:16 -0700)]
Update crates/hir_def/src/nameres/collector.rs

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoMerge #8038
bors[bot] [Mon, 15 Mar 2021 18:14:49 +0000 (18:14 +0000)]
Merge #8038

8038: Fix unification logic r=flodiebold a=flodiebold

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoFix unification logic
Florian Diebold [Mon, 15 Mar 2021 17:22:25 +0000 (18:22 +0100)]
Fix unification logic

3 years agoMerge #8028
bors[bot] [Mon, 15 Mar 2021 17:50:20 +0000 (17:50 +0000)]
Merge #8028

8028: Return multiple modules in `parent_module` feature r=matklad a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #8037
bors[bot] [Mon, 15 Mar 2021 17:40:14 +0000 (17:40 +0000)]
Merge #8037

8037: Assist is empty 7709 r=Veykril a=chetankhilosiya

Updated the implementation to get the function from implementation

Co-authored-by: Chetan Khilosiya <chetan.khilosiya@gmail.com>
3 years agoUpdate tests
oxalica [Mon, 15 Mar 2021 17:24:26 +0000 (01:24 +0800)]
Update tests

3 years agoPretty print root module of extern crates
oxalica [Mon, 15 Mar 2021 17:24:21 +0000 (01:24 +0800)]
Pretty print root module of extern crates

3 years ago7709: Updated the implementation.
Chetan Khilosiya [Mon, 15 Mar 2021 17:18:50 +0000 (22:48 +0530)]
7709: Updated the implementation.

The get function from impl method is updated.
and now same method used to get len and is_empty function.

3 years agoClean usage of ShortLabel
oxalica [Mon, 15 Mar 2021 16:58:42 +0000 (00:58 +0800)]
Clean usage of ShortLabel

3 years agoFix trait type parameter
oxalica [Mon, 15 Mar 2021 16:58:29 +0000 (00:58 +0800)]
Fix trait type parameter

3 years agoUse hir formatter more
oxalica [Mon, 15 Mar 2021 16:05:03 +0000 (00:05 +0800)]
Use hir formatter more

3 years agoImpl HirDisplay for function hover message
oxalica [Sun, 14 Mar 2021 12:03:39 +0000 (20:03 +0800)]
Impl HirDisplay for function hover message

3 years agoIntroduce FunctionQualifier for hir::FunctionData
oxalica [Sun, 14 Mar 2021 10:00:11 +0000 (18:00 +0800)]
Introduce FunctionQualifier for hir::FunctionData

3 years agoCollect HirDisplay impls to a single file
oxalica [Sun, 14 Mar 2021 09:36:04 +0000 (17:36 +0800)]
Collect HirDisplay impls to a single file

3 years agoAdd test for hover of macro expanded function
oxalica [Sat, 13 Mar 2021 17:07:05 +0000 (01:07 +0800)]
Add test for hover of macro expanded function

3 years agoMerge #8035
bors[bot] [Mon, 15 Mar 2021 16:51:53 +0000 (16:51 +0000)]
Merge #8035

8035: unqualfied_path completions aren't responsible for variant pattern completions r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agounqualfied_path completions aren't responsible for pattern completions
Lukas Wirth [Mon, 15 Mar 2021 16:23:08 +0000 (17:23 +0100)]
unqualfied_path completions aren't responsible for pattern completions

3 years ago7709: Added the assist to generate is_empty function
Chetan Khilosiya [Thu, 11 Mar 2021 18:55:22 +0000 (00:25 +0530)]
7709: Added the assist to generate is_empty function

the assist will be shown when the len function is implemented.
is_empty internally uses len function.

3 years agoMerge #7992
bors[bot] [Mon, 15 Mar 2021 15:53:15 +0000 (15:53 +0000)]
Merge #7992

7992: improved completion sorting for functions and methods r=JoshMcguigan a=JoshMcguigan

This PR improves completion sorting for functions and methods. Related to #7935.

### Before

The methods are being sorted by `coc` by closeness in file.

![pre-fn-relevance](https://user-images.githubusercontent.com/22216761/111018669-fe3d3f00-836e-11eb-9607-cc05af080a6a.png)

### After

Notice `bbb()` on top (type + name match), followed by `ddd()` (type match).

![image](https://user-images.githubusercontent.com/22216761/111018680-0e551e80-836f-11eb-94b1-c88336ecbc6e.png)

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
3 years agoMerge #8033
bors[bot] [Mon, 15 Mar 2021 15:39:34 +0000 (15:39 +0000)]
Merge #8033

8033: Add test for proc-macro meta info retrieval r=edwin0cheng a=edwin0cheng

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoAdd test for proc-macro meta info retrieval
Edwin Cheng [Mon, 15 Mar 2021 15:38:22 +0000 (23:38 +0800)]
Add test for proc-macro meta info retrieval

3 years agoimplement function completion scoring
Josh Mcguigan [Fri, 12 Mar 2021 23:06:17 +0000 (15:06 -0800)]
implement function completion scoring

3 years agoMerge #8032
bors[bot] [Mon, 15 Mar 2021 15:21:42 +0000 (15:21 +0000)]
Merge #8032

8032: Enable proc-macros by default r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoEnable proc-macros by default
Aleksey Kladov [Mon, 15 Mar 2021 15:19:08 +0000 (18:19 +0300)]
Enable proc-macros by default

3 years agoSupport multiple parents in parentModule in vscode-client
Lukas Wirth [Mon, 15 Mar 2021 14:49:20 +0000 (15:49 +0100)]
Support multiple parents in parentModule in vscode-client

3 years agoMerge #8029
bors[bot] [Mon, 15 Mar 2021 14:42:26 +0000 (14:42 +0000)]
Merge #8029

8029: Enable thread-local coverage marks r=JoshMcguigan a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoMerge #8030
bors[bot] [Mon, 15 Mar 2021 14:34:23 +0000 (14:34 +0000)]
Merge #8030

8030: Add diesel to the benchmark suite r=lnicola a=weiznich

This commit adds diesel to the continuosly run benchmark suite. Diesel
heavily relies internally on macro generated code. Additionally there
are lots of complicated trait releations used as part of their API.
Therefore this benchmark will be quite sensitive to:
* Performance related changes in the macro expanding code
* Performance related changes while resolving trait bounds

CC #7950

cc @lnicola

Co-authored-by: Georg Semmler <github@weiznich.de>
3 years agoAdd diesel to the benchmark suite
Georg Semmler [Mon, 15 Mar 2021 14:19:16 +0000 (15:19 +0100)]
Add diesel to the benchmark suite

This commit adds diesel to the continuosly run benchmark suite. Diesel
heavily relies internally on macro generated code. Additionally there
are lots of complicated trait releations used as part of their API.
Therefore this benchmark will be quite sensitive to:
* Performance related changes in the macro expanding code
* Performance related changes while resolving trait bounds

CC #7950

3 years agoReturn multiple modules in `parent_module`
Lukas Wirth [Mon, 15 Mar 2021 13:51:20 +0000 (14:51 +0100)]
Return multiple modules in `parent_module`

3 years agoMerge #8020
bors[bot] [Mon, 15 Mar 2021 14:08:26 +0000 (14:08 +0000)]
Merge #8020

8020: Power up goto_implementation r=matklad a=Veykril

by allowing it to be invoked on references of names, now showing all (trait)
implementations of the given type in all crates instead of just the defining
crate as well as including support for builtin types

![image](https://user-images.githubusercontent.com/3757771/111144403-52bb0700-8587-11eb-9205-7a2a5b8b75a3.png)
Example screenshot of `impl`s of Box in `log`, `alloc`, `std` and the current crate. Before you had to invoke it on the definition where it would only show the `impls` in `alloc`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoDrop non-working mark
Laurențiu Nicola [Mon, 15 Mar 2021 14:05:16 +0000 (16:05 +0200)]
Drop non-working mark

3 years agoEnable thread-local coverage marks
Laurențiu Nicola [Mon, 15 Mar 2021 14:02:50 +0000 (16:02 +0200)]
Enable thread-local coverage marks

3 years agoMerge #8027
bors[bot] [Mon, 15 Mar 2021 13:42:12 +0000 (13:42 +0000)]
Merge #8027

8027: Completion context remove exact match method in favor of fields r=JoshMcguigan a=JoshMcguigan

This is a minor cleanup PR following #8008. It removes the `expected_name_and_type` method on completion context in favor of using the fields.

I thought this method was used in more places, or else it may have just made sense to make this change directly in #8008 :shrug:

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
3 years agogoto_implementation: Look at the entire crate graph for trait impls
Lukas Wirth [Mon, 15 Mar 2021 13:31:55 +0000 (14:31 +0100)]
goto_implementation: Look at the entire crate graph for trait impls

3 years agoremove expected_name_and_type method on completion context in favor of using fields...
Josh Mcguigan [Mon, 15 Mar 2021 13:25:39 +0000 (06:25 -0700)]
remove expected_name_and_type method on completion context in favor of using fields added in #8008

3 years agoMerge #8015
bors[bot] [Mon, 15 Mar 2021 13:18:26 +0000 (13:18 +0000)]
Merge #8015

8015:  Introduce Semantics::visit_file_defs r=matklad a=Veykril

See https://github.com/rust-analyzer/rust-analyzer/issues/3538#issuecomment-798920601

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #8008
bors[bot] [Mon, 15 Mar 2021 12:59:47 +0000 (12:59 +0000)]
Merge #8008

8008: Completion context expected type r=matklad a=JoshMcguigan

Currently there are two ways completions use to determine the expected type. There is the `expected_type` field on the `CompletionContext`, as well as the `expected_name_and_type` method on the `RenderContext`. These two things returned slightly different results, and their results were only valid if you had pre-checked some (undocumented) invariants. A simple combination of the two approaches doesn't work because they are both too willing to go far up the syntax tree to find something that fits what they are looking for.

This PR makes the following changes:

1. Updates the algorithm that sets `expected_type` on `CompletionContext`
2. Adds `expected_name` field to `CompletionContext`
3. Re-writes the `expected_name_and_type` method to simply return the underlying fields from `CompletionContext` (I'd like to save actually removing this method for a follow up PR just to keep the scope of the changes down)
4. Adds unit tests for the `expected_type`/`expected_name` fields

All the existing unit tests still pass (unmodified), but this new algorithm certainly has some gaps (although I believe all the `FIXME` introduced in this PR are also flaws in the current code). I wanted to stop here and get some feedback though - is this approach fundamentally sound?

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
3 years agoMerge #8018
bors[bot] [Mon, 15 Mar 2021 12:51:27 +0000 (12:51 +0000)]
Merge #8018

8018: Make Ty wrap TyKind in an Arc r=flodiebold a=flodiebold

... to further move towards Chalk.

This is a bit of a slowdown (218ginstr vs 213ginstr for inference on RA), even though it allows us to unwrap the Substs in `TyKind::Ref` etc..

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoSpeedup trait impl search for goto_implementation
Lukas Wirth [Mon, 15 Mar 2021 12:49:21 +0000 (13:49 +0100)]
Speedup trait impl search for goto_implementation

3 years agoMerge #8026
bors[bot] [Mon, 15 Mar 2021 12:39:24 +0000 (12:39 +0000)]
Merge #8026

8026: Simplify source maps for fields r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoSimplify source maps for fields
Aleksey Kladov [Mon, 15 Mar 2021 12:38:50 +0000 (15:38 +0300)]
Simplify source maps for fields

3 years agoupdate algorithm for determining expected type of completion
Josh Mcguigan [Sun, 14 Mar 2021 04:30:14 +0000 (20:30 -0800)]
update algorithm for determining expected type of completion

3 years agoMerge #8025
bors[bot] [Mon, 15 Mar 2021 12:13:01 +0000 (12:13 +0000)]
Merge #8025

8025: Goto definition works for `S { a: }` case r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoGoto definition works for `S { a: }` case
Aleksey Kladov [Mon, 15 Mar 2021 12:02:48 +0000 (15:02 +0300)]
Goto definition works for `S { a: }` case

What happens here is that we lower `: ` to a missing expression, and
then correctly record that the corresponding field expression resolves
to a specific field. Where we fail is in the mapping of syntax to this
missing expression. Doing it via `ast_field.expr()` fails, as that
expression is `None`. Instead, we go in the opposite direcition and ask
each lowered field about its source.

This works, but has wrong complexity `O(N)` and, really, the
implementation is just too complex. We need some better management of
data here.

3 years agomove Semantics::visit_file_defs to ide_db::helpers
Lukas Wirth [Mon, 15 Mar 2021 11:18:52 +0000 (12:18 +0100)]
move Semantics::visit_file_defs to ide_db::helpers

3 years agoIntroduce Semantics::visit_file_defs
Lukas Wirth [Sun, 14 Mar 2021 15:12:38 +0000 (16:12 +0100)]
Introduce Semantics::visit_file_defs

3 years agoPower up goto_implementation
Lukas Wirth [Mon, 15 Mar 2021 09:11:48 +0000 (10:11 +0100)]
Power up goto_implementation

by allowing it to be invoked on references of names, showing all (trait)
implementations of the given type in all crates including builtin types

3 years agoMerge #8021 #8022
bors[bot] [Mon, 15 Mar 2021 10:05:49 +0000 (10:05 +0000)]
Merge #8021 #8022

8021: Enable searching for builtin types r=matklad a=Veykril

Not too sure how useful this is for reference search overall, but for completeness sake it should be there
![image](https://user-images.githubusercontent.com/3757771/111132711-f69db600-8579-11eb-8c90-22fd6862d11f.png)

Also enables document highlighting for them.

8022: some clippy::performance fixes r=matklad a=matthiaskrgr

use vec![] instead of Vec::new() + push()
avoid redundant clones
use chars instead of &str for single char patterns in ends_with() and starts_with()
allocate some Vecs with capacity to avoid unnecessary resizing

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
3 years agoMerge #8023
bors[bot] [Mon, 15 Mar 2021 09:58:25 +0000 (09:58 +0000)]
Merge #8023

8023: Move code to the appropriate layer r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoMove code to the appropriate layer
Aleksey Kladov [Mon, 15 Mar 2021 09:55:27 +0000 (12:55 +0300)]
Move code to the appropriate layer

StructureNodeKind is a type which is specific to a particular feature,
file_structure. It shouldn't be in the "code shared by all ide features"
part.

3 years agoMerge #7975
bors[bot] [Mon, 15 Mar 2021 09:26:58 +0000 (09:26 +0000)]
Merge #7975

7975: Provide regions in file structure r=ivan770 a=ivan770

Closes #7913

https://user-images.githubusercontent.com/14003886/110819163-96b3c080-8296-11eb-993e-a7cdb574a12d.mp4

Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
3 years agosome clippy::performance fixes
Matthias Krüger [Mon, 15 Mar 2021 09:15:08 +0000 (10:15 +0100)]
some clippy::performance fixes

use vec![] instead of Vec::new() +  push()
avoid redundant clones
use chars instead of &str for single char patterns in ends_with() and starts_with()
allocate some Vecs with capacity to avoid unneccessary resizing

3 years agoEnable searching for builtin types
Lukas Wirth [Mon, 15 Mar 2021 08:32:06 +0000 (09:32 +0100)]
Enable searching for builtin types

3 years agoMerge #7966
bors[bot] [Mon, 15 Mar 2021 01:23:29 +0000 (01:23 +0000)]
Merge #7966

7966: Diagnose files that aren't in the module tree r=jonas-schievink a=jonas-schievink

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

I'm not sure if this is the best way to do this. It will cause false positives for all `include!`d files (though I'm not sure how much IDE functionality we have for these).

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoAdd module comment
Jonas Schievink [Mon, 15 Mar 2021 01:23:00 +0000 (02:23 +0100)]
Add module comment

3 years agoUse pub(crate)
Jonas Schievink [Mon, 15 Mar 2021 00:46:59 +0000 (01:46 +0100)]
Use pub(crate)

3 years agoRedo it properly and add a quickfix
Jonas Schievink [Mon, 15 Mar 2021 00:39:23 +0000 (01:39 +0100)]
Redo it properly and add a quickfix

3 years agoMerge #8017
bors[bot] [Sun, 14 Mar 2021 19:46:49 +0000 (19:46 +0000)]
Merge #8017

8017: Don't drop type params in doc-test paths r=Veykril a=Veykril

Closes #7995

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoDon't drop type params in doc-test paths
Lukas Wirth [Sun, 14 Mar 2021 19:16:02 +0000 (20:16 +0100)]
Don't drop type params in doc-test paths

3 years agoDon't use Substs for Ref/Raw/Array/Slice
Florian Diebold [Sun, 14 Mar 2021 16:40:55 +0000 (17:40 +0100)]
Don't use Substs for Ref/Raw/Array/Slice

3 years agoMake CI happy
ivan770 [Sun, 14 Mar 2021 17:05:09 +0000 (19:05 +0200)]
Make CI happy

3 years agoIntroduce StructureNodeKind
ivan770 [Sun, 14 Mar 2021 15:16:29 +0000 (17:16 +0200)]
Introduce StructureNodeKind

3 years agoAdded region intersection test
ivan770 [Sun, 14 Mar 2021 10:52:04 +0000 (12:52 +0200)]
Added region intersection test

3 years agoShorten trim call
ivan770 [Fri, 12 Mar 2021 09:01:43 +0000 (11:01 +0200)]
Shorten trim call

3 years agoProvide regions in file structure
ivan770 [Thu, 11 Mar 2021 16:14:41 +0000 (18:14 +0200)]
Provide regions in file structure

3 years agoMake Ty wrap TyKind in an Arc
Florian Diebold [Sun, 14 Mar 2021 16:25:29 +0000 (17:25 +0100)]
Make Ty wrap TyKind in an Arc

... like it will be in Chalk. We still keep `interned_mut` and
`into_inner` methods that will probably not exist with Chalk.

This worsens performance slightly (5ginstr inference on RA), but doesn't
include other simplifications we can do yet.

3 years agoMerge #8014
bors[bot] [Sun, 14 Mar 2021 15:56:29 +0000 (15:56 +0000)]
Merge #8014

8014: increase completion relevance for items in local scope r=matklad a=JoshMcguigan

This PR provides a small completion relevance score bonus for items in local scope. The changes here are relatively minimal, since `coc` by default pre-sorts by position in file. But as we move toward fully server side sorting #7935 I think we'll want some relevance score bump for items in local scope.

### Before

Note `let~` and `syntax` are both ahead of locals. Ultimately we may decide that `let~` is a high relevance completion given my cursor position here, but that should be done with some explicit scoring on the server side, rather than being caused by (I think) `coc` preferring shorter completions.

![pre-local-score](https://user-images.githubusercontent.com/22216761/111073414-c97ad600-849b-11eb-84e7-fcee130536f0.png)

### After

![post-local-score](https://user-images.githubusercontent.com/22216761/111073422-d0094d80-849b-11eb-92ec-7ae5ec3b190d.png)

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
3 years agoMerge #8016
bors[bot] [Sun, 14 Mar 2021 15:34:37 +0000 (15:34 +0000)]
Merge #8016

8016: More Chalk adaptations r=flodiebold a=flodiebold

 - rename a bunch of fields
 - use `chalk_ir::FnSig`

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoMore renaming
Florian Diebold [Sun, 14 Mar 2021 15:33:27 +0000 (16:33 +0100)]
More renaming

3 years agoUse chalk_ir::FnSig
Florian Diebold [Sun, 14 Mar 2021 15:30:02 +0000 (16:30 +0100)]
Use chalk_ir::FnSig

3 years agoRename some fields to their Chalk names
Florian Diebold [Sun, 14 Mar 2021 15:26:12 +0000 (16:26 +0100)]
Rename some fields to their Chalk names

3 years agoincrease completion relevance for items in local scope
Josh Mcguigan [Sat, 13 Mar 2021 14:13:30 +0000 (06:13 -0800)]
increase completion relevance for items in local scope

3 years agoMerge #7993
bors[bot] [Sun, 14 Mar 2021 14:27:53 +0000 (14:27 +0000)]
Merge #7993

7993: Use auto-deref in completion scoring r=JoshMcguigan a=ivan770

Closes #7982

Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
3 years agoMerge #8013
bors[bot] [Sun, 14 Mar 2021 14:19:31 +0000 (14:19 +0000)]
Merge #8013

8013: Fix `cargo xtask lint` references r=matklad a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoFix `cargo xtask lint` references
Laurențiu Nicola [Sun, 14 Mar 2021 13:24:34 +0000 (15:24 +0200)]
Fix `cargo xtask lint` references

3 years agoMerge #8012
bors[bot] [Sun, 14 Mar 2021 13:10:06 +0000 (13:10 +0000)]
Merge #8012

8012: xtask: replace "lint" command by a simply cargo alias r=matklad a=matthiaskrgr

This strips the run_clippy implementation out of xtask and replaces it by
a simple "cargo lint" alias which runs clippy with the corresponding flags.

Unfortunately  I could not name the alias "clippy" because that would lead to infinite recursion. :sweat_smile:

Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
3 years agoxtask: replace "lint" command by a simply cargo alias
Matthias Krüger [Sun, 14 Mar 2021 12:34:28 +0000 (13:34 +0100)]
xtask: replace "lint" command by a simply cargo alias

This strips the run_clippy implementation out of xtask and replaces it by
a simple "cargo lint" alias which runs clippy with the corresponding flags.

Unfortunately  I could not name the alias "clippy" because that would lead to infinite recursion.

3 years agoMerge #8011
bors[bot] [Sun, 14 Mar 2021 10:50:59 +0000 (10:50 +0000)]
Merge #8011

8011: Add no-sysroot flag for analysis-stats r=edwin0cheng a=edwin0cheng

Add `no-sysroot` flag for `rust-analyzer analysis-stats`. It is very useful for debugging propose.

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
3 years agoAdd no-sysroot flag for analysis-stats
Edwin Cheng [Sun, 14 Mar 2021 10:31:14 +0000 (18:31 +0800)]
Add no-sysroot flag for analysis-stats

3 years agoSkip ref_match on same types, remove sorting in tests
ivan770 [Sun, 14 Mar 2021 10:25:37 +0000 (12:25 +0200)]
Skip ref_match on same types, remove sorting in tests

3 years agoMerge #8010
bors[bot] [Sun, 14 Mar 2021 10:13:38 +0000 (10:13 +0000)]
Merge #8010

8010: Attach trivia to ast::Union nodes r=Veykril a=Veykril

Closes #8007
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoAttach trivia to ast::Union nodes
Lukas Wirth [Sun, 14 Mar 2021 10:11:01 +0000 (11:11 +0100)]
Attach trivia to ast::Union nodes