Commit Graph

5821 Commits

Author SHA1 Message Date
Josh Mcguigan
8c378af721 missing match arms diagnostic 2020-04-07 05:12:08 -07:00
Aleksey Kladov
0215560434 Better naming for scope completion 2020-04-07 13:20:41 +02:00
Aleksey Kladov
a5ffe53c9d Better naming for path completion 2020-04-07 13:19:57 +02:00
Aleksey Kladov
79b48a9e77
Merge pull request #3863 from Veetaha/feature/migrate-to-rast
Migrate tests .txt -> .rast
2020-04-07 13:10:43 +02:00
Aleksey Kladov
baf9fcc38e
Merge pull request #3866 from lnicola/fewer-braces
Fix unnecessary braces warnings
2020-04-07 09:22:33 +02:00
Josh Mcguigan
8f7fceeb9c fix cargo check config with custom command 2020-04-06 21:41:31 -07:00
Leander Tentrup
bf96d46fee Simplify HTML highlighter and add test case for highlight_injection logic 2020-04-06 23:00:09 +02:00
Florian Diebold
236ac630f6 Fix Chalk panic
Fixes #3865. Basically I forgot to shift 'back' when we got `dyn Trait`s back
from Chalk, so after going through Chalk a few times, the panic happened.
2020-04-06 17:26:26 +02:00
Aleksey Kladov
109bb1a793
Merge pull request #3867 from matklad/deny-eprintln
Check for eprintlns on CI
2020-04-06 17:21:47 +02:00
Edwin Cheng
4f70162f54 Add bridge::TokenStream to crate scope 2020-04-06 23:07:48 +08:00
Edwin Cheng
b2844917ad Add proc_macro mod (copy from lib_proc_macro) 2020-04-06 23:07:48 +08:00
Edwin Cheng
40616fdb49 Refactor deps 2020-04-06 23:07:48 +08:00
Aleksey Kladov
bf569f8b29 Check for eprintln on CI 2020-04-06 17:00:18 +02:00
Laurențiu Nicola
52fd2c8e48 Fix unnecessary braces warnings 2020-04-06 17:21:33 +03:00
Edwin Cheng
a569a19ef4 Use log info in trait_solve_query 2020-04-06 21:01:58 +08:00
veetaha
da091b1303 Migrate tests .txt -> .rast
The sytax tree output files now use .rast extension
(rust-analyzer syntax tree or rust abstract syntax tree
(whatever)).
This format has a editors/code/ra_syntax_tree.tmGrammar.json declaration
that supplies nice syntax highlighting for .rast files.
2020-04-06 14:04:26 +03:00
Aleksey Kladov
ec3fb1cdb4
Merge pull request #3853 from matklad/cf
Make control token modifier less ambiguous
2020-04-06 11:53:56 +02:00
bors[bot]
972816b6d4
Merge #3843
3843: Remove rustc_lexer dependency in favour of rustc-ap-rustc_lexer r=est31 a=est31

The latter is auto-published on a regular schedule (Right now weekly).

See also https://github.com/alexcrichton/rustc-auto-publish

Co-authored-by: est31 <MTest31@outlook.com>
2020-04-06 08:42:52 +00:00
bors[bot]
4f904b2970
Merge #3829
3829: Adds to SSR match for semantically equivalent call and method call r=matklad a=mikhail-m1

#3186 
maybe I've missed some corner cases, but it works in general

Co-authored-by: Mikhail Modin <mikhailm1@gmail.com>
2020-04-06 08:15:48 +00:00
est31
2f6914824a Remove rustc_lexer dependency in favour of rustc-ap-rustc_lexer
The latter is auto-published on a regular schedule (Right now weekly).
2020-04-06 10:08:51 +02:00
Aleksey Kladov
48bc0ca745 Make control token modifier less ambiguous
In textmate, keyword.control is used for all kinds of things; in fact,
the default scope mapping for keyword is keyword.control!

So let's add a less ambiguous controlFlow modifier

See Microsoft/vscode#94367
2020-04-06 09:57:50 +02:00
bors[bot]
a93a04fc9e
Merge #3744
3744: Upgrade Chalk r=matklad a=flodiebold



Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-04-06 07:49:09 +00:00
Laurențiu Nicola
7d62280a71 Hide unit fn return types 2020-04-05 21:06:47 +03:00
Florian Diebold
952714685a Upgrade Chalk again
The big change here is counting binders, not
variables (https://github.com/rust-lang/chalk/pull/360). We have to adapt to the
same scheme for our `Ty::Bound`. It's mostly fine though, even makes some things
more clear.
2020-04-05 19:23:18 +02:00
Florian Diebold
3659502816 Upgrade Chalk 2020-04-05 19:23:18 +02:00
Laurențiu Nicola
b58a7f41f1 Fix inference of function pointer return types 2020-04-05 18:18:40 +03:00
bors[bot]
7c2f141591
Merge #3848
3848: Remove unused dependencies r=kjeremy a=est31

Found by cargo-udeps

Co-authored-by: est31 <MTest31@outlook.com>
2020-04-04 18:00:45 +00:00
est31
dc142152e6 Remove unused dependencies 2020-04-04 19:22:14 +02:00
veetaha
a1773f8a67 Remove explicit generic type parameter 2020-04-04 16:12:09 +03:00
veetaha
b5a7cb331f Simplify config 2020-04-04 16:04:49 +03:00
Aleksey Kladov
a5e8dfd024 Add parens for enums 2020-04-03 21:11:05 +02:00
Aleksey Kladov
b1cf95f691 Generalize call parenthesis insertion 2020-04-03 21:01:18 +02:00
Aleksey Kladov
adbcedde18 Remove the second code-path for completing names in patterns 2020-04-03 21:00:15 +02:00
Aleksey Kladov
da8eb29a2f Macro patterns are not confused with expressions.
We treat macro calls as expressions (there's appropriate Into impl),
which causes problem if there's expresison and non-expression macro in
the same node (like in the match arm).

We fix this problem by nesting macor patterns into another node (the
same way we nest path into PathExpr or PathPat). Ideally, we probably
should add a similar nesting for macro expressions, but that needs
some careful thinking about macros in blocks: `{ am_i_expression!() }`.
2020-04-03 16:12:38 +02:00
Aleksey Kladov
0e46ed8420 Cleanups 2020-04-03 15:44:06 +02:00
Edwin Cheng
9a2114b0dd Add doc comment on main.rs 2020-04-03 19:16:54 +08:00
Edwin Cheng
84fb9b44c3 Introduce ra_proc_macro_srv 2020-04-03 19:01:44 +08:00
bors[bot]
77462bba62
Merge #3746
3746: Add create_function assist r=flodiebold a=TimoFreiberg

The function part of #3639, creating methods will come later

- [X] Function arguments
     - [X] Function call arguments
     - [x] Method call arguments
     - [x] Literal arguments
     - [x] Variable reference arguments
- [X] Migrate to `ast::make` API
    Done, but there are some ugly spots.

Issues to handle in another PR:
- function reference arguments: Their type isn't printed properly right now.
    The "insert explicit type" assist has the same issue and this is probably a relatively rare usecase.

- generating proper names for all kinds of argument expressions (if, loop, ...?)
    Without this, it's totally possible for the assist to generate invalid argument names.
    I think the assist it's already helpful enough to be shipped as it is, at least for me the main usecase involves passing in named references.
    Besides, the Rust tooling ecosystem is immature enough that some janky behaviour in a new assist probably won't scare anyone off.

- select the generated placeholder body so it's a bit easier to overwrite it

- create method (`self.foo<|>(..)` or `some_foo.foo<|>(..)`) instead of create_function.
    The main difference would be finding (or creating) the impl block and inserting the `self` argument correctly

- more specific default arg names for literals.
    So far, every generated argument whose name can't be taken from the call site is called `arg` (with a number suffix if necessary).

- creating functions in another module of the same crate.
    E.g. when typing `some_mod::foo<|>(...)` when in `lib.rs`, I'd want to have `foo` generated in `some_mod.rs` and jump there.
    Issues: the mod could exist in `some_mod.rs`, in `lib.rs` as `mod some_mod`, or inside another mod but be imported via `use other_mod::some_mod`.

- refer to arguments of the generated function with a qualified path if the types aren't imported yet
    (alternative: run autoimport. i think starting with a qualified path is cleaner and there's already an assist to replace a qualified path with an import and an unqualified path)

- add type arguments of the arguments to the generated function

- Autocomplete functions with information from unresolved calls (see https://github.com/rust-analyzer/rust-analyzer/pull/3746#issuecomment-605281323)
    Issues: see https://github.com/rust-analyzer/rust-analyzer/pull/3746#issuecomment-605282542. The unresolved call could be anywhere. But just offering this autocompletion for unresolved calls in the same module would already be cool.

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-04-03 08:23:44 +00:00
bors[bot]
2cee8531c5
Merge #3814
3814: Add impl From for enum variant assist r=flodiebold a=mattyhall

Basically adds a From impl for tuple enum variants with one field. It was recommended to me on the zulip to maybe try using the trait solver, but I had trouble with that as, although it could resolve the trait impl, it couldn't resolve the variable unambiguously in real use. I'm also unsure of how it would work if there were already multiple From impls to resolve - I can't see a way we could get more than one solution to my query.

Fixes #3766

Co-authored-by: Matthew Hall <matthew@quickbeam.me.uk>
2020-04-03 07:46:46 +00:00
Leander Tentrup
bb45aca909 Flatten nested highlight ranges during DFS traversal 2020-04-03 09:46:07 +02:00
Mikhail Modin
35a2cd08c1 Adds to SSR match for semantically equivalent call and method call 2020-04-02 20:18:44 +01:00
veetaha
c0cf60dca2 Apply cargo xtask format 2020-04-02 21:12:28 +03:00
veetaha
6190caeeae Migrate to privacy as per review commets 2020-04-02 21:09:03 +03:00
veetaha
bef899aa78 Less mutability 2020-04-02 21:07:05 +03:00
veetaha
a90401aeed Migrate to iters some more 2020-04-02 21:07:05 +03:00
veetaha
987fb26a5b Migrate to iterators 2020-04-02 21:07:05 +03:00
veetaha
b7d5172f69 Simpify workspace handling 2020-04-02 21:07:05 +03:00
veetaha
4b2bf9cf66 Don't clone where you can copy 2020-04-02 21:07:05 +03:00
Matthew Hall
6a2127be28 Cleanup checking for existing impls in impl From assist
Use the trait solver to check if there's an existing implementation of
From<type_in_enum_variant> for the enum.
2020-04-02 18:42:30 +01:00
bors[bot]
23c4ef5aef
Merge #3811
3811: Add inference for literal and range patterns r=kjeremy a=flodiebold

(cc @JoshMcguigan )

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-04-02 15:14:44 +00:00
Aleksey Kladov
8a788c764f Allow fully overriding check and fmt commands 2020-04-02 14:35:51 +02:00
Aleksey Kladov
7a4ebd2c8d Remove vscode_lldb setting 2020-04-02 12:56:14 +02:00
Aleksey Kladov
e21bf1b2b9 Siplify 2020-04-02 12:50:34 +02:00
Aleksey Kladov
48c58309cc Lean onto default implementation of configs 2020-04-02 12:47:58 +02:00
Aleksey Kladov
e4cf40a152 New config in package.json 2020-04-02 12:27:09 +02:00
Aleksey Kladov
0dde0f92de Reorder fields 2020-04-02 11:33:49 +02:00
bors[bot]
98f7842e40
Merge #3820
3820: Remove old syntax highlighting r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-02 07:55:11 +00:00
Aleksey Kladov
309fc70155 Remove old syntax highlighting 2020-04-02 09:52:27 +02:00
o0Ignition0o
f643b4b5f5 Unique package by name and version.
This commit is a fixup of a bug I introduced by using a PackageId to refer to a crate when its name conflicts with a dependency.
It turns out the package id currently is `name version path` while cargo expects `name:version` as argument.
2020-04-02 09:00:44 +02:00
Matthew Hall
1fee60181f Add impl From for enum variant assist
Basically adds a From impl for tuple enum variants with one field. Added
to cover the fairly common case of implementing your own Error that can
be created from another one, although other use cases exist.
2020-04-01 22:26:41 +01:00
Timo Freiberg
10667753c7 Use ast::make API in add_function assist 2020-04-01 23:06:14 +02:00
Timo Freiberg
e5fc42cbc1 Add create_function assist 2020-04-01 23:06:14 +02:00
Florian Diebold
b392a732d3 Add inference for literal and range patterns 2020-04-01 20:27:47 +02:00
bors[bot]
0a41412ced
Merge #3806
3806: lower bool literal value r=flodiebold a=JoshMcguigan

Following up on #3805, this PR adds the literal value to `ast::LiteralKind` so when we lower we can use the actual value from the source code rather than the default value for the type. Ultimately I plan to use this for exhaustiveness checking in #3706.

I didn't include this in the previous PR because I wasn't sure if it made sense to add this information to `ast::LiteralKind` or provide some other mechanism to get this from `ast::Literal`.

For now I've only implemented this for boolean literals, but I think it could be easily extended to other types. A possible exception to this are string literals, since we may not want to clone around an owned string to hold onto in `ast::LiteralKind`, and it'd be nice to avoid adding a generic lifetime as well. Perhaps we won't ever care about the actual value of a string literal? 

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-04-01 17:38:00 +00:00
Aleksey Kladov
1225f719fe Fix pointer syntax 2020-04-01 19:27:45 +02:00
Aleksey Kladov
1ac345a9f6 Centralize defaults 2020-04-01 18:56:47 +02:00
Aleksey Kladov
4936abdd49 Reduce scope of deserialization 2020-04-01 18:51:16 +02:00
Aleksey Kladov
e870cbc23d Centralize client capabilities 2020-04-01 18:46:26 +02:00
Aleksey Kladov
a97e5eb85d Centralize all config 2020-04-01 18:41:43 +02:00
Aleksey Kladov
1e012eb991 Move all config to config 2020-04-01 17:22:56 +02:00
Aleksey Kladov
797cd34c7c Reduce feature flags 2020-04-01 17:00:37 +02:00
bors[bot]
facdf56cf6
Merge #3807
3807: Generalize rustfmt config r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-01 12:34:31 +00:00
Aleksey Kladov
b9bf29019d Move config to config.rs 2020-04-01 14:32:04 +02:00
Aleksey Kladov
6ac9668998 Generalize rustfmt config 2020-04-01 14:26:08 +02:00
bors[bot]
a0cc66475a
Merge #3797
3797: Don't show chaining hints for record literals and unit structs r=matklad a=lnicola

Fixes #3796 

r? @Veetaha

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-04-01 12:18:34 +00:00
Josh Mcguigan
d0b6b2ee2f lower bool literal with the value from source code rather than default bool value 2020-04-01 04:47:41 -07:00
bors[bot]
67351a011b
Merge #3805
3805: lower literal patterns r=JoshMcguigan a=JoshMcguigan

While working on #3706 I discovered literal patterns weren't being lowered. This PR implements that lowering.

Questions for reviewers:

1. This re-uses the existing conversion from `ast::LiteralKind` to `Literal`, but `ast::LiteralKind` doesn't include information about the actual value of the literal, which causes `Literal` to be created with the default value for the type (rather than the actual value in the source code). Am I correct in thinking that we'd eventually want to change things in such a way that we could initialize the `Literal` with the actual literal value? Is there an existing issue for this, or else perhaps I should create one to discuss how it should be implemented? My main question would be whether `ast::LiteralKind` should be extended to hold the actual value, or if we should provide some other way to get that information from `ast::Literal`?
2. I couldn't find tests which directly cover this, but it does seem to work in #3706. Do we have unit tests for this lowering code?
3. I'm not sure why `lit.literal()` returns an `Option`. Is returning a `Pat::Missing` in the `None` case the right thing to do? 
4. I was basically practicing type-system driven development to figure out the transformation from `ast::Pat::LiteralPat` to `Pat::Lit`. I don't have an immediate question here, but I just wanted to ensure this section is looked at closely during review. 

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-04-01 11:22:31 +00:00
Josh Mcguigan
a9d0c9b2a4 lower literal patterns 2020-04-01 04:18:46 -07:00
Aleksey Kladov
cc8113dd46 Simplify error handing 2020-04-01 13:14:38 +02:00
Aleksey Kladov
f01846b8ee Generalize Flycheckconfig 2020-04-01 13:14:38 +02:00
bors[bot]
aad0e63d74
Merge #3779
3779: Complete only missing fields in pats r=matklad a=SomeoneToIgnore

A follow-up for https://github.com/rust-analyzer/rust-analyzer/pull/3694

Same name vs string [issue](https://github.com/rust-analyzer/rust-analyzer/pull/3694#discussion_r396986819) persists here, now I'm able to obtain `ast::Name`, but I see no way to convert it into `hir::Name` or vice versa.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-04-01 10:41:46 +00:00
bors[bot]
ab284f30ce
Merge #3803
3803: Cleanup r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-01 10:34:36 +00:00
Aleksey Kladov
65c89c3a20 Cleanup 2020-04-01 12:34:12 +02:00
Laurențiu Nicola
70960df437 Don't show chaining hints for record literals and unit structs 2020-04-01 13:14:41 +03:00
Kirill Bulatov
1335608dae Unite record completion logic into a single module 2020-04-01 13:03:56 +03:00
bors[bot]
e3a1f1c001
Merge #3765
3765: Adds sort for RecordLit comparison in SSR r=edwin0cheng a=mikhail-m1

an item from #3186 

Co-authored-by: Mikhail Modin <mikhailm1@gmail.com>
2020-04-01 10:01:16 +00:00
Kirill Bulatov
d35b943520 Split draft 2020-04-01 12:49:31 +03:00
Kirill Bulatov
bc71631e75 Complete only missing fields in pats 2020-04-01 12:49:31 +03:00
Aleksey Kladov
b5306ea706 Simplify 2020-04-01 11:16:43 +02:00
Aleksey Kladov
3990d971e5 Crisper name
https://www.flycheck.org/en/latest/
2020-04-01 11:09:19 +02:00
Aleksey Kladov
dda942debe Pull enabled check up 2020-04-01 11:06:16 +02:00
Mikhail Modin
47e8f3c93b Adds sort for RecordLit comparison in SSR 2020-04-01 09:39:33 +01:00
Aleksey Kladov
c86d8d40c2 Streamline flycheck implementation 2020-04-01 09:42:23 +02:00
Aleksey Kladov
b46fd38632 sort imports 2020-04-01 00:16:16 +02:00
bors[bot]
f77fc158fc
Merge #3780 #3787
3780: Simplify r=matklad a=Veetaha

I absolutely love tha fact that removing `.clone()` simplifies the code comparing to other languages where it's actually the contrary (ahem ~~`std::move()`~~)

3787: vscode: add syntax tree inspection hovers and highlights r=matklad a=Veetaha

![inspect-tree](https://user-images.githubusercontent.com/36276403/78029767-c7426900-7369-11ea-9ed6-b8a0f8e05bac.gif)
I implemented the reverse mapping (when you hover in the rust editor), but it seems overcomplicated, so I removed it

Related #3682 

Co-authored-by: veetaha <veetaha2@gmail.com>
Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-03-31 17:40:03 +00:00
Aleksey Kladov
8d27829781 Reduce deps 2020-03-31 19:29:11 +02:00
Aleksey Kladov
a4f9d966f0 Add integrated test for concat include env 2020-03-31 19:19:14 +02:00
veetaha
611adc83da Simplify 2020-03-31 19:00:23 +03:00
Aleksey Kladov
70730d7655 Rename cargo_watch -> flycheck 2020-03-31 17:29:40 +02:00
Edwin Cheng
207903a1c3 Fix rebased 2020-03-31 22:29:27 +08:00