Commit graph

8410 commits

Author SHA1 Message Date
Lukas Wirth
cd6cd91bf3 Tidy up recursive_merge implementation 2020-09-12 23:27:01 +02:00
Jonas Schievink
07a704e31c Implement box pattern inference 2020-09-12 21:18:57 +02:00
Jonas Schievink
2de6eb7bc8 Add box pattern test 2020-09-12 21:15:00 +02:00
Lukas Wirth
a898752881 Reimplement import merging by making it recursive properly nesting all levels 2020-09-12 19:19:19 +02:00
Lukas Wirth
adc4c6b9d7 Make MergeBehaviour configurable 2020-09-12 12:11:16 +02:00
Kirill Bulatov
779ea2ea0a Properly preserve macro braces 2020-09-11 22:16:22 +03:00
oxalica
529c369c9b
Fix type walking about type of async block 2020-09-12 01:08:50 +08:00
oxalica
cc4e287bb5
Fix and prettify comments 2020-09-12 00:12:42 +08:00
oxalica
8ebf3596b7
Complete trait impl immediately after type/const/fn 2020-09-11 23:05:10 +08:00
bors[bot]
568dc38b7b
Merge #5955
5955: Remove merge import code duplication r=jonas-schievink a=Veykril

This removes the code duplication caused by #5935, this also allows the assist to merge imports that have equal visibility and prevents merges of unequal visibility. This PR also fixes an iteration mistake in the mentioned PR:

Turns out I made a mistake when writing the `segment_iter` function, I was assuming that the `children` of a path will just be the segments, which is obviously not the case. This also brings insertion order of shorter paths in line with how `rustfmt` orders them.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-09-11 14:01:20 +00:00
bors[bot]
96e988fcc3
Merge #5951 #5975
5951: Rename record_field_pat to record_pat_field r=jonas-schievink a=pksunkara

The token was renamed but not this.

5975: Report better errors in project.json/sysroot r=jonas-schievink a=jonas-schievink

This does a bunch of light refactoring so that the `Sysroot` is loaded later, which makes sure that any errors are reported to the user. I then added a check that reports an error if libcore is missing in the loaded sysroot. Since a sysroot without libcore is very useless, this indicates a configuration error.

Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-09-11 13:47:33 +00:00
bors[bot]
87c8dfcadd
Merge #5970
5970: Use better heuristics for replacement text when removing dbg! r=jonas-schievink a=SomeoneToIgnore

Closes https://github.com/rust-analyzer/rust-analyzer/issues/5911

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-09-11 13:41:15 +00:00
Jonas Schievink
681ac6294a Report better errors in project.json/sysroot 2020-09-11 14:48:56 +02:00
bors[bot]
4f1167d8dd
Merge #5969
5969: Propose module name completion options r=jonas-schievink a=SomeoneToIgnore

<img width="539" alt="image" src="https://user-images.githubusercontent.com/2690773/92663009-cb0aec00-f308-11ea-9ef5-1faa91518031.png">

Currently traverses the whole file set every time we try to complete the module, as discussed in https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/mod.3C.7C.3E.20completion

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-09-11 11:37:04 +00:00
Kirill Bulatov
ca698a0b8c Adjust the test comment 2020-09-11 14:16:15 +03:00
bors[bot]
eb7136f76d
Merge #5957
5957: Add consuming modifier to lvalues that are passed by value and not Copy r=jonas-schievink a=Nashenas88

Related to #5856 

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-09-10 21:59:00 +00:00
Kirill Bulatov
b477f99bd9 One more test 2020-09-11 00:20:13 +03:00
bors[bot]
868f4b5756
Merge #5956
5956: Highlight errors in macros r=jonas-schievink a=popzxc

Resolves #4924 

This PR makes rust-analyzer highlight not only the source place when error originates in macro, but also the exact places in macro which caused an error.

This is done by creating an inverse diagnostic, which points to the macro and cross-references the source place.

![изображение](https://user-images.githubusercontent.com/12111581/92319594-b71e6c00-f022-11ea-94c1-f412905269dd.png)


Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
2020-09-10 20:55:06 +00:00
Pavan Kumar Sunkara
4d97f5f037 Rename record_field_pat to record_pat_field 2020-09-10 18:56:04 +02:00
oxalica
251ef93ac3
Implement async blocks 2020-09-10 20:01:23 +08:00
Kirill Bulatov
208d4609b0 Use better heuristics for replacement text when removing dbg! 2020-09-10 14:14:24 +03:00
Kirill Bulatov
492e3c40f6 One more test 2020-09-10 01:58:29 +03:00
Kirill Bulatov
9863798480 Rename the method to avoid false promises 2020-09-10 01:45:49 +03:00
Kirill Bulatov
f4ee885b3b Add VirtualPath tests 2020-09-10 01:42:20 +03:00
Kirill Bulatov
a7d75463c7 Fix the tests 2020-09-10 01:42:20 +03:00
Kirill Bulatov
5aebf54fd4 Add tests 2020-09-10 01:42:20 +03:00
Kirill Bulatov
dbf70cd015 Properly handle mod.rs imports 2020-09-10 01:42:20 +03:00
Kirill Bulatov
9fb83211f9 Complete semicolon when needed 2020-09-10 01:42:20 +03:00
Kirill Bulatov
57a260f579 Properly reacto to keywords 2020-09-10 01:42:20 +03:00
Kirill Bulatov
cc43abcde8 Less false positive completion candidates 2020-09-10 01:42:20 +03:00
Kirill Bulatov
3fd6f45141 Properly handle nested submodules in the same file 2020-09-10 01:42:20 +03:00
Kirill Bulatov
f9c14ac720 Move most of the logic into the completion module 2020-09-10 01:42:20 +03:00
Kirill Bulatov
6ba479cd05 Finally cretae the mod completion module 2020-09-10 01:42:20 +03:00
Kirill Bulatov
33179a0ae1 Move rust-related logic from vfs to base_db level 2020-09-10 01:42:20 +03:00
Kirill Bulatov
b2bcc5278d Properly handle special cases (binaries, mod.rs) 2020-09-10 01:42:20 +03:00
Kirill Bulatov
486c5c3285 Exclude special files 2020-09-10 01:42:20 +03:00
Kirill Bulatov
897a4c702e Implement file name & extension retrieval method for VirtualPath 2020-09-10 01:42:20 +03:00
Kirill Bulatov
d163f9f114 Small refactoring 2020-09-10 01:42:20 +03:00
Kirill Bulatov
8aa740dab4 Happy path implemented 2020-09-10 01:42:20 +03:00
Kirill Bulatov
0de71f7bc9 Properly use FileSet API 2020-09-10 01:42:20 +03:00
Kirill Bulatov
17870a3e2c Better API 2020-09-10 01:42:20 +03:00
Kirill Bulatov
4bed588001 First steps for mod<|> completion 2020-09-10 01:42:20 +03:00
bors[bot]
5c336e266f
Merge #5968
5968: Lookup ADT and associated type names for chalk debugging / tweak chalk interner r=flodiebold a=nathanwhit

This PR improves the chalk program writing integration by looking up the names for ADTs and associated types, making the output much more readable.

There are also a few small changes to the interner, which gives some nice performance improvements. We clone `Ty`s and `ProgramClause`s relatively often in chalk, so wrapping them in `Arc`s is a perf win. This takes the time for performing type inference on the rust-analyzer codebase from 40s to 33s on my machine.

Co-authored-by: Nathan Whitaker <nathan.whitaker01@gmail.com>
2020-09-09 17:20:39 +00:00
Nathan Whitaker
bf0b194fed Tweak interner for chalk 2020-09-09 12:55:38 -04:00
Nathan Whitaker
20663a2a8b Lookup ADT and assoc. type names for chalk debug 2020-09-09 12:55:05 -04:00
Paul Daniel Faria
a1a7b07ad3 Fix handling of consuming self, refactor shared logic into a single function 2020-09-06 14:34:01 -04:00
Paul Daniel Faria
7af947a032 Add consuming modifier to lvalues that are passed by value and not Copy 2020-09-06 12:26:53 -04:00
Igor Aleksanov
023e3a1dea Highlight errors in macros 2020-09-06 09:22:01 +03:00
Lukas Wirth
74b755d233 Allow merge_imports assists to merge imports of equal visibility 2020-09-05 16:15:16 +02:00
Lukas Wirth
7ccb198af8 Remove duplicated import merge logic 2020-09-05 15:51:26 +02:00
Lukas Wirth
d201317c67 Fix segment_iter not iterating segments properly 2020-09-05 15:44:54 +02:00
bors[bot]
0275b08d15
Merge #5940
5940: Implement "Replace `impl Trait` function argument with the named generic" assist. r=matklad a=alekseysidorov

Fixes #5085 

Co-authored-by: Aleksei Sidorov <gorthauer87@yandex.ru>
2020-09-04 21:54:42 +00:00
Aleksei Sidorov
e1b8d836a9 Remove unnecessary comma 2020-09-04 22:58:50 +03:00
Aleksei Sidorov
ef0a1b2e58 Fix tests 2020-09-04 17:55:27 +03:00
bors[bot]
9dfa69a44a
Merge #5935
5935: Rewrite import insertion r=matklad a=Veykril

This is my attempt at refactoring the import insertion #3947. I hope what I created here is somewhat in line with what was requested, it wouldn't surprise me .

`common_prefix` is a copy from `merge_imports.rs` so those should be unified somewhere, `try_merge_trees` is also copied from there but slighly modified to take the `MergeBehaviour` enum into account.
`MergeBehaviour` should in the end become a configuration option, and the order if `ImportGroup` probably as well?

I'm not too familiar with the assist stuff and the like which is why I dont know what i have to do with `insert_use_statement` and `find_insert_use_container` for now.

I will most likely add more test cases in the end as well as I currently only tried to hit every path in `find_insert_position`. 
Some of the merge tests also fail atm due to them not sorting what they insert. There is also this test case I'm not sure if we want to support it. I would assume we want to? https://github.com/rust-analyzer/rust-analyzer/pull/5935/files#diff-6923916dd8bdd2f1ab4b984adacd265fR540-R547

The entire module was rewritten so looking at the the file itself is probably better than looking at the diff.

Regarding the sub issues of #3947:
- #3301: This is fixed with the rewrite, what this implementation does is that it scans through the first occurence of groupings and picks the appropriate one out. This means the user can actually rearrange the groupings on a per file basis to their liking. If a group isnt being found it is inserted according to the `ImportGroup` variant order(Would be nice if this was configurable I imagine).
- #3831: This should be fixed with the introduced `MergeBehaviour` enum and it's `Last` variant.
- #3946: This should also be [fixed](https://github.com/rust-analyzer/rust-analyzer/pull/5935/files#diff-6923916dd8bdd2f1ab4b984adacd265fR87)
- #5795: This is fixed in the sense that the grouping search picks the first group that is of the same kind as the import that is being added. So if  there is a random import in the middle of the program it should only be considered if there is no group of the same kind in the file already present.
- the last point in the list I havent checked yet, tho I got the feeling that it's not gonna be too simple as that will require knowledge of whether in this example `ast` is a crate or the module that is already imported.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-09-04 13:28:05 +00:00
Aleksei Sidorov
a1c060c8d0 Update codegen 2020-09-04 15:28:08 +03:00
Aleksei Sidorov
477fa75cfb Fix nitpicks 2020-09-04 15:24:36 +03:00
kjeremy
11758d518a Up proc-macro2 to 1.20
This changes the way Display is implemented
2020-09-03 17:40:12 -04:00
Lukas Wirth
82f61e6629 Add extra insert_use test for pub(crate) re-export handling 2020-09-03 20:26:27 +02:00
Lukas Wirth
d29b69cbe6 Disable insert_import in extract_struct_from_enum_variant until its fixed 2020-09-03 18:36:08 +02:00
Lukas Wirth
7de2a30f40 Fix import insertion breaking nested modules 2020-09-03 18:36:08 +02:00
Lukas Wirth
98e2f674e9 Fix inserting imports in front of inner attributes 2020-09-03 18:36:08 +02:00
Lukas Wirth
c1925df7fc Replace insert_use_statement with the new insert_use 2020-09-03 18:36:08 +02:00
Lukas Wirth
952f385682 Impl make::blank_line 2020-09-03 18:36:07 +02:00
Lukas Wirth
07ff9eeca8 Use mark to check that paths that are too long will not be merged 2020-09-03 18:36:07 +02:00
Lukas Wirth
74186d3ae7 Tidy up tests and apply suggested changes 2020-09-03 18:36:07 +02:00
Lukas Wirth
903c7eb2e5 Add more import insertion tests 2020-09-03 18:36:07 +02:00
Lukas Wirth
ed37335c01 Begin refactor of import insertion 2020-09-03 18:36:07 +02:00
Aleksei Sidorov
7259cc82f3 Resolve most of corner cases 2020-09-03 17:46:04 +03:00
Aleksei Sidorov
fe3170dc34 Initial implementation of the #5085 issue 2020-09-03 14:47:07 +03:00
Aleksey Kladov
9684daa029 Actually assert disjointness 2020-09-03 13:37:36 +02:00
bors[bot]
a000346ab2
Merge #5941
5941: Unify naming
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-09-03 10:23:08 +00:00
Aleksey Kladov
75b1f9ee23 Unify naming 2020-09-03 12:18:46 +02:00
bors[bot]
d2c3832a8a
Merge #5937
5937: Chalk 0.25 r=matklad a=kjeremy

Picks up flodiebold's infinite loop fix

Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-09-03 10:13:41 +00:00
Andy Russell
24805d1d80
default checkOnSave.enable to true in server 2020-09-02 17:44:21 -04:00
adamrk
5cd2c67c25 Make unify private again 2020-09-02 22:55:05 +02:00
adamrk
66658f1168 Trim mut keyword in fn completion 2020-09-02 22:49:21 +02:00
adamrk
e11cd8fe35 Remove exposing unification 2020-09-02 22:33:54 +02:00
adamrk
d9bb86ad7d Collect locals in context 2020-09-02 22:14:37 +02:00
kjeremy
5e4195bb6a Chalk 0.25
Picks up flodiebold's infinite loop fix
2020-09-02 14:07:06 -04:00
kjeremy
36692bdffa Switch to upstream ENUM_MEMBER 2020-09-02 09:40:59 -04:00
kjeremy
b527257330 Move to vscode-languageclient 7.0.0-next.9
Stabilizes call hierarchy and semantic tokens features.
2020-09-02 09:40:59 -04:00
adamrk
04fc937700 Add back Param struct 2020-09-01 22:13:12 +02:00
Aramis Razzaghipour
321108673d Document VS Code setting needed for on-typing assists 2020-09-01 23:40:53 +10:00
Aleksey Kladov
7f54ded71b Bump token expansion limit
We hit this for redis crate, reported at

Reported at
https://www.reddit.com/r/rust/comments/ikfsf8/rustanalyzer_doesnt_work_with_the_redis_crate/
2020-09-01 14:55:41 +02:00
Aleksey Kladov
b1f59ff6c1 Reduce path_from_text usage 2020-08-31 15:47:42 +02:00
Aleksey Kladov
60706fca8e Remove dead code 2020-08-31 15:46:57 +02:00
adamrk
c6ddb90714 Add references to fn args during completion 2020-08-30 12:34:32 +02:00
Kirill Bulatov
3ac9732ca3 Fix some typos 2020-08-28 21:55:24 +03:00
Aleksey Kladov
c692b5d76d ⬆️ expect-test 2020-08-28 14:47:14 +02:00
Aleksey Kladov
07da02fc37 ⬆️ crates 2020-08-27 19:06:00 +02:00
Aleksey Kladov
4b989009e3 CONST LOOPS ARE HERE 2020-08-27 18:12:01 +02:00
Aleksey Kladov
4d0cfc07fd Minor 2020-08-27 15:02:56 +02:00
bors[bot]
e7da5816d6
Merge #5895
5895: Tease apart orthogonal concerns in markdown link rewriting
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-26 18:26:07 +00:00
Aleksey Kladov
f8a59adf5e Tease apart orthogonal concerns in markdown link rewriting
`hir` should know nothing about URLs, markdown and html. It should
only be able to:

* resolve stringy path from documentation
* generate canonical stringy path for a def

In contrast, link rewriting should not care about semantics of paths
and names resolution, and should be concern only with text mangling
bits.
2020-08-26 20:24:00 +02:00
bors[bot]
7e012ae8b5
Merge #5893
5893: Allow running a test as a binary r=matklad a=jonas-schievink

If a test uses `harness = false`, it just contains an `fn main` that is executed via `cargo test`. This adds support for that.

Note though that Cargo doesn't actually tell us whether `harness = false`, so this hint will always show up when you put an `fn main` into an integration test. Normally people shouldn't be doing that if they do use the harness though.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-08-26 17:41:45 +00:00
Aleksey Kladov
1c0ac2b9b4 Cleanup hover links tests 2020-08-26 18:36:16 +02:00
Jonas Schievink
964219f0be Allow running a test as a binary 2020-08-26 17:33:03 +02:00
León Orell Valerian Liehr
63caef372a Improve support for code block attributes 2020-08-26 15:55:06 +02:00
Aleksey Kladov
7431ec82c9 Simplify 2020-08-26 13:40:45 +02:00
bors[bot]
868aaf2bc6
Merge #5889
5889: Allow logging to file r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-26 11:21:17 +00:00
Aleksey Kladov
ed6304131a Simplify 2020-08-26 13:20:46 +02:00
Aleksey Kladov
bb50614d88 Simplify help 2020-08-26 13:20:46 +02:00
Aleksey Kladov
a53c6f6fee Allow redirecting logs to a specific file
There's a surprising lack of crates which are like env_logger, but
also allow writing to a file. Let's write our own then!
2020-08-26 13:20:46 +02:00
Aleksey Kladov
0fc8fd2bd5 **Inline Variable** works with field shorthand 2020-08-26 13:03:14 +02:00
Aleksey Kladov
189521a4db Add sysroot shortcut to rust-project.json 2020-08-25 19:41:56 +02:00
Aleksey Kladov
c6dffe479b Cleanup heavy tests 2020-08-25 19:26:45 +02:00
Aleksey Kladov
9786a8f2d4 Don't expose indexing details 2020-08-25 18:40:41 +02:00
Aleksey Kladov
4f6ca0e081 Minor 2020-08-25 18:07:25 +02:00
Aleksey Kladov
7239d8ca95 Provide better stack trace for overlapping edits
Overlapping indels are a bug. Checking this *always* is tricky (needs
a sorted data structure to not suffer O(N^2) perf). But
opportunistically checking small indels should give provide 80% of the
benefits.
2020-08-25 17:59:37 +02:00
Aleksey Kladov
7fcda5aa46 Prepare to share sysroot lowering code between Cargo & ProjectJSON 2020-08-25 17:53:24 +02:00
Aleksey Kladov
18b667cfcb Complete pub in fields 2020-08-25 17:22:23 +02:00
Aleksey Kladov
6b8bc132dc Prep work for overriding sysroot
The idea here is to make auto-discovery optional, and to allow to set
the path to sysroot directly. This is handy for JSON projects.
2020-08-25 17:04:24 +02:00
Aleksey Kladov
cd9ecdf467 Remove monomorphisation from doclinks resolving code 2020-08-25 14:58:22 +02:00
Aleksey Kladov
66e5ced894 Remove AttrDef 2020-08-25 14:44:15 +02:00
Aleksey Kladov
7487885309 Simplify 2020-08-25 12:58:00 +02:00
Aleksey Kladov
575fb9ab6a Move attrs from code_module to a separate module 2020-08-25 12:56:01 +02:00
Aleksey Kladov
663749beab Minor 2020-08-25 12:48:00 +02:00
Aleksey Kladov
b45dd9ef54 Use the same abstraction for attrs and docs
Doc comments *are* attributes, so there's no reason to have two crates
here.
2020-08-25 12:13:31 +02:00
bors[bot]
59c77ff062
Merge #5866
5866: Improve logging
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-25 09:46:21 +00:00
Aleksey Kladov
3a72afed8c Improve logging 2020-08-25 11:43:21 +02:00
bors[bot]
96cbad9fb5
Merge #4873
4873: Resolve links in hover documentation r=matklad a=zacps

This PR resolves links in hover documentation. Both the upcoming intra-doc-links style and the old "path-based" style.

## Todo

* [x] More tests
* [ ] Benchmark (Is there an easy way to benchmark this?)
* [x] ~~Resolve issues with the markdown parser/get rid of it~~ Migrate to `pulldown_cmark_to_cmark`
* [x] Reorganise code (Tips appreciated)

---

Fixes #503

Co-authored-by: Zac Pullar-Strecker <zacmps@gmail.com>
2020-08-25 09:11:26 +00:00
Aleksey Kladov
7721accebf Cleanup invert-if
* stick to trivial factory functions in make
* compress the logic for inverting Option/Result
2020-08-25 11:00:32 +02:00
Zac Pullar-Strecker
b835f06cec Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links 2020-08-25 16:44:36 +12:00
Zac Pullar-Strecker
452afaebe1 Changes from review 2020-08-25 16:40:43 +12:00
Jonas Schievink
f3ac19e8cd Support extern types 2020-08-24 22:02:55 +02:00
Pavan Kumar Sunkara
b2d43daeb4 Allow rust-analyzer auto publishing 2020-08-24 17:27:17 +02:00
bors[bot]
81fa00c5b5
Merge #5733
5733: Fix expand glob import bugs r=matklad a=unexge

fixes https://github.com/rust-analyzer/rust-analyzer/issues/5709

TODOs:
- [x] Incorrect node replacing
<details>
    <summary>Details</summary>

```rust
use crate::{
    body::scope::{ExprScopes, ScopeId},
    body::Body,
    builtin_type::BuiltinType,
    db::DefDatabase,
    expr::{ExprId, PatId},
    generics::GenericParams,
    item_scope::{BuiltinShadowMode, BUILTIN_SCOPE},
    nameres::CrateDefMap,
    path::*<|>,
    per_ns::PerNs,
    visibility::{RawVisibility, Visibility},
    AdtId, AssocContainerId, ConstId, ContainerId, DefWithBodyId, EnumId, EnumVariantId,
    FunctionId, GenericDefId, HasModule, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId,
    StaticId, StructId, TraitId, TypeAliasId, TypeParamId, VariantId,
};
```
becames
```rust
use crate::{PathKind, name, name, ModPath};
```
</details>

- [x] Ignoring visibility
<details>
    <summary>Details</summary>

```rust
mod foo {
    mod bar {
        pub struct Bar;
    }
}

use foo::bar::*;

fn baz(bar: Bar) {}
```
becames
```rust
mod foo {
    mod bar {
        pub struct Bar;
    }
}

use foo::bar::Bar;

fn baz(bar: Bar) {}
```
although mod `bar` is private
</details>

- [x] Eating attributes

Co-authored-by: unexge <unexge@gmail.com>
2020-08-24 14:26:33 +00:00
Pavan Kumar Sunkara
63f63acc7c Add TBD description to arena 2020-08-24 13:29:10 +02:00
bors[bot]
31cb13dde8
Merge #4776
4776: Do a weekly minor publish to crates.io r=matklad a=pksunkara

This is the same system I set up on Chalk repo.

Every week it creates a new minor version, pushes it to github and then deploys it to crates.io.

Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-08-24 11:14:45 +00:00
bors[bot]
150e3843b0
Merge #5845
5845: Omit lenses for not runnable doctests r=matklad a=SomeoneToIgnore

Ideally, we should properly parse the doctest attributes before, but since I need it for the code lens only, this way should suffice for now

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-08-24 11:08:11 +00:00
Pavan Kumar Sunkara
335add49db Add description for crates that will be published 2020-08-24 13:07:22 +02:00
Zac Pullar-Strecker
5452368fad Renames, comments, and dead code removal 2020-08-24 21:50:30 +12:00
Zac Pullar-Strecker
7bbca7a1b3 Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links 2020-08-24 21:20:13 +12:00
Pavan Kumar Sunkara
a8fa5cd42e Add version to deps in cargo.toml 2020-08-24 11:10:41 +02:00
Zac Pullar-Strecker
ca464650ee Add a test to document unimplemented case 2020-08-24 20:47:10 +12:00
Zac Pullar-Strecker
4f5f608b49 Reorganise code 2020-08-24 20:26:45 +12:00
dragfire
1d129a7172 Invert if should be smart about is_some, is_none, is_ok, is_err 2020-08-23 22:30:34 -06:00
Kirill Bulatov
cdd75a699a Omit lenses for not runnable doctests 2020-08-22 22:03:02 +03:00
bors[bot]
e65d48d1fb
Merge #5823
5823: Don't underline function definition if self is &mut r=Nashenas88 a=matklad

The self is right there, and is already underlined, so it makes little
sense to emit even more underlines.

before:
![before](https://user-images.githubusercontent.com/1711539/90672843-0d379500-e257-11ea-840f-b0caed4410f1.png)
after:
![after](https://user-images.githubusercontent.com/1711539/90672840-0c9efe80-e257-11ea-9739-23af433841c6.png)



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-22 14:41:17 +00:00
Aleksey Kladov
863b1fb731 ⬆️ ungrammar 2020-08-21 19:14:05 +02:00
Aleksey Kladov
b0fd3faf36 Switch to expect_test from crates.io 2020-08-21 13:19:31 +02:00
Aleksey Kladov
66e0c9f840 Remove expect crate 2020-08-21 13:15:56 +02:00
unexge
ef54e8451d Use new Definition::usages API in expand glob import 2020-08-20 21:35:47 +03:00
unexge
5cff4b60be Fix importing private modules in expand glob import 2020-08-20 21:34:53 +03:00
unexge
5d28dec7b9 Fix importing unused traits in expand glob import 2020-08-20 21:34:53 +03:00
unexge
585f5d4901 Use fixme instead of todo 2020-08-20 21:34:53 +03:00
unexge
0847bc801e Use Definition::find_usages for finding used items in expand glob import 2020-08-20 21:34:53 +03:00
unexge
11d048af03 Run rustfmt 2020-08-20 21:34:53 +03:00
unexge
bb72150f02 Handle more cases in AST replacing in expand glob import 2020-08-20 21:34:53 +03:00
unexge
128eef779f Improve AST replacing in expand glob import 2020-08-20 21:34:53 +03:00
Aleksey Kladov
e262149b7c Optimize reference search 2020-08-20 00:54:44 +02:00
Aleksey Kladov
8000d1d30d Don't underline function definition if self is &mut
The self is right there, and is already underlined, so it makes little
sense to emit even more underlines.
2020-08-19 20:02:33 +02:00
bors[bot]
9051d6bc36
Merge #5822
5822: Remove dead code
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-19 17:56:19 +00:00
Aleksey Kladov
eb7bb2cba0 Remove dead code 2020-08-19 19:54:00 +02:00
Aleksey Kladov
4b5b55f6f3 **Remove Unused Parameter** refactoring 2020-08-19 19:40:55 +02:00
Aleksey Kladov
81b0976187 Future proof find-usages API
We might want to provide more efficient impls for check if usages
exist, limiting the search, filtering and cancellation, so let's
violate YAGNI a bit here.
2020-08-19 18:58:48 +02:00
Aleksey Kladov
b56e020077 Apply couple of rule of thumbs to simplify highlighting code
Main one: instead of adding a parameter to function to handle special
case, make the caller handle it.

Second main one: make sure that function does a reasonable thing.
`highlight_def` picks  a color for def, *regardless* of the context
the def is use. Feeding an info from the call-site muddies the
responsibilities here.

Minor smells, flagging the function as having space for improvement in
the first place:

* many parameters, some of which are set as constants on most
call-sites (introduce severalfunction instad)
* boolean param (add two functions instead)
2020-08-19 17:53:41 +02:00
Aleksey Kladov
11a1bb1c3e Inline trivial function 2020-08-19 17:41:56 +02:00
Aleksey Kladov
a9778c6d73 Simplify 2020-08-19 17:37:19 +02:00
Aleksey Kladov
0b62b990ba Minor 2020-08-19 17:33:25 +02:00
Aleksey Kladov
422ac441c2 Minor cleanups 2020-08-19 17:31:26 +02:00
Aleksey Kladov
5da1dc9a8b Better name 2020-08-19 17:30:43 +02:00
Aleksey Kladov
61754678fb Better API factoring around self access modes 2020-08-19 17:02:50 +02:00
Aleksey Kladov
73f4fcbd0f Better error if Cargo is not in Path 2020-08-19 16:34:11 +02:00
Aleksey Kladov
70fd542822 Introduce hir::Param
We generally shouldn't expose TypeRef out of hir. So, let's just use a
placehoder here.
2020-08-19 16:04:18 +02:00
Aleksey Kladov
b9b4693ce3 Add SelfParam to code_model 2020-08-19 15:16:24 +02:00
Aleksey Kladov
a3b0a3aeb8 Minor cleanups 2020-08-19 13:46:34 +02:00
bors[bot]
63ac896655
Merge #5811
5811: Minor
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-19 11:34:29 +00:00
Aleksey Kladov
80ea7f3c81 Minor 2020-08-19 13:33:51 +02:00
bors[bot]
529ca7e5e0
Merge #5643
5643: Add new consuming modifier, apply consuming and mutable to methods r=matklad a=Nashenas88

This adds a new `consuming` semantic modifier for syntax highlighters.

This also emits `mutable` and `consuming` in two cases:

- When a method takes `&mut self`, then it now has `function.mutable` emitted.
- When a method takes `self`, and the type of `Self` is not `Copy`, then `function.consuming` is emitted.

CC @flodiebold 

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-08-19 11:27:02 +00:00
Aleksey Kladov
17d6efe6f2 Make RacyFlag actually work 2020-08-18 23:51:01 +02:00
Aleksey Kladov
27ccc95c60 Cleanup feature generation 2020-08-18 19:36:27 +02:00
bors[bot]
f18f9da7d8
Merge #5695
5695: Added completion for unstable features r=matklad a=Fihtangolz

Added xtask for downloading list of unstable features from the unstable book and codegen for it. Also included small changes from linter.

Co-authored-by: Dmitry <mamhigtt@gmail.com>
Co-authored-by: Dmitry Opokin <mamhigtt@gmail.com>
2020-08-18 16:49:06 +00:00
bors[bot]
aa2def023e
Merge #5804
5804: Add type safety to diagnostic codes
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-18 16:40:12 +00:00
Aleksey Kladov
8146669542 Add type safety to diagnostic codes 2020-08-18 18:39:43 +02:00
bors[bot]
d21d5e42c4
Merge #5800
5800: Speedup ty tests
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-18 15:22:12 +00:00
Aleksey Kladov
aad911fb0c Speedup ty tests
Closes #5792
2020-08-18 17:20:57 +02:00
bors[bot]
0df9ecedb4
Merge #5798
5798: Introduce Label
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-18 14:51:10 +00:00
Aleksey Kladov
aa1a7a5414 Introduce Label 2020-08-18 16:50:07 +02:00
bors[bot]
e81c310b62
Merge #5797
5797: Minor
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-18 14:22:36 +00:00
Aleksey Kladov
eb81731600 Minor 2020-08-18 16:22:01 +02:00
bors[bot]
0e66dc690e
Merge #5796
5796: Align diagnostics config with the rest of rust-analyzer
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-18 14:12:00 +00:00
Aleksey Kladov
0866b1be89 Align diagnostics config with the rest of rust-analyzer 2020-08-18 16:03:15 +02:00
Dmitry
e18748ed15 Merge remote-tracking branch 'rust-analyzer/master' 2020-08-18 19:37:22 +07:00
bors[bot]
a3947129c5
Merge #5794
5794: Simplify building a symbol hierarchy
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-08-18 12:32:32 +00:00
Aleksey Kladov
e01cfe2b45 Simplify building a symbol hierarchy 2020-08-18 14:29:31 +02:00
bors[bot]
b8dfc331ab
Merge #5682
5682: Add an option to disable diagnostics r=matklad a=popzxc

As far as I know, currently it's not possible to disable a selected type of diagnostics provided by `rust-analyzer`.

This causes an inconvenient situation with a false-positive warnings: you either have to disable all the diagnostics, or you have to ignore these warnings.

There are some open issues related to this problem, e.g.: https://github.com/rust-analyzer/rust-analyzer/issues/5412, https://github.com/rust-analyzer/rust-analyzer/issues/5502

This PR attempts to make it possible to selectively disable some diagnostics on per-project basis.

Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
2020-08-18 12:04:49 +00:00
bors[bot]
2252a65f23
Merge #5687
5687: Fix document symbols order r=matklad a=magurotuna

Resolves #5655 
And adds tests for `handle_document_symbol`, both with `hierarchical_symbols` enabled and with it disabled.

Previously document symbols were displayed in reverse order  in sublime text with its LSP plugin, but this patch fixes it like this:

![image](https://user-images.githubusercontent.com/23649474/89709020-fbccce00-d9b6-11ea-83b0-c88dc9f7977f.png)


Co-authored-by: Yusuke Tanaka <yusuktan@maguro.dev>
2020-08-18 11:58:02 +00:00
Aleksey Kladov
9389e313d0 Minor 2020-08-18 13:20:28 +02:00
bors[bot]
a95c5e2121
Merge #5758
5758: SSR: Explicitly autoderef and ref placeholders as needed r=matklad a=davidlattimore

Structural search replace now inserts *, & and &mut in the replacement to match any auto[de]ref in the matched code.

e.g. `$a.foo() ==>> bar($a)` might convert `x.foo()` to `bar(&mut x)`

Co-authored-by: David Lattimore <dml@google.com>
2020-08-18 10:52:27 +00:00
David Lattimore
29e6238cb7 SSR: A few small refactorings 2020-08-18 20:39:55 +10:00
Igor Aleksanov
34847c8d96 Move analysis config structure to the config.rs 2020-08-18 13:35:36 +03:00
Igor Aleksanov
b56cfcca10 Make disabled diagnostics an argument of corresponding function 2020-08-18 13:32:29 +03:00
Aleksey Kladov
6cff076513 Revive cache cleaning
The idea here is that, on CI, we only want to cache crates.io
dependencies, and not local crates. This keeps the size of the cache
low, and also improves performance, as network and moving files on
disk (on Windows) can be slow.
2020-08-18 11:07:21 +02:00
CAD97
c822bb68ce Fix missing match arm false error on unknown type 2020-08-17 13:27:12 -04:00
CAD97
2eaf79cfbb Document missing match arm false positive
This should already be guarded against
(d2212a49f6/crates/hir_ty/src/diagnostics/expr.rs (L225-L230))
but it isn't preventing this false positive for some reason.
2020-08-17 13:19:15 -04:00
bors[bot]
7d95a8447c
Merge #5776 #5780
5776: Fix eslint errors on .eslintrc.js and rollup.config.js r=matklad a=fuafa

Eslint complains if these two files does not include in the `tsconfig.json`.
```
Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: .eslintrc.js.
The file must be included in at least one of the projects provided.eslint
```
![image](https://user-images.githubusercontent.com/20750310/90338269-176d4f80-e01b-11ea-8710-3ea817b235d2.png)



5780: Fixup whitespace when adding missing impl items r=matklad a=jDomantas

Generate properly formatted whitespace when adding impl items - with an empty line between items and removing extra whitespace that often appears at the end.

This is my first time working on rust analyzer so I'm not very familiar with its internal APIs. If there's a better way to do such syntax tree editing I'd be glad to hear it.

Co-authored-by: xiaofa <xiaofalzx@gmail.com>
Co-authored-by: jDomantas <djadenkus@gmail.com>
2020-08-17 14:30:24 +00:00
bors[bot]
6826dd044a
Merge #5782
5782: Fix StatusNotification r=matklad a=vsrs

This PR fixes the following:

As per specification `params` property in [NotificationMessage ](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#notificationMessage) should be `array | object` while RA uses `"loading" | "ready" | "invalid" | "needsReload"`.

Co-authored-by: vsrs <vit@conrlab.com>
2020-08-17 14:23:03 +00:00
Aleksey Kladov
6a4c9fc9fd Don't make fields private unless you have to 2020-08-17 16:11:29 +02:00