Commit Graph

297 Commits

Author SHA1 Message Date
Aleksey Kladov
970dbf8717 Rename StructField -> Field 2020-04-25 14:23:34 +02:00
Aleksey Kladov
8843588fca Convert tests to text-size 2020-04-25 11:59:18 +02:00
Aleksey Kladov
b1d5817dd1 Convert code to text-size 2020-04-25 11:59:18 +02:00
bors[bot]
5eb51c1e60
Merge #4106
4106: Fix wrong substitution code r=matklad a=flodiebold

We need to shift in when we're substituting inside a binder.

This should fix #4053 (it doesn't fix the occasional overflow that also occurs on the Diesel codebase though).

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-04-23 21:58:52 +00:00
Florian Diebold
0c01b4eb6a Fix wrong substitution code
We need to shift in when we're substituting inside a binder.

This should fix #4053 (it doesn't fix the occasional overflow that also occurs
on the Diesel codebase though).
2020-04-23 23:53:08 +02:00
Aleksey Kladov
27dd0086ea Fully get rid of SyntaxNodePtr::range 2020-04-23 21:23:36 +02:00
Florian Diebold
0be68a4825 Update Chalk, and cache Chalk env elaboration through a query
This should fix some of the worst performance problems.
2020-04-20 19:16:01 +02:00
Aleksey Kladov
b79fd82559 Correctly infer types in guard expressions
The root cause was that we forgot to add bindings from the arm to the
guard expression

closes #3980
2020-04-18 22:16:04 +02:00
Aleksey Kladov
fa2ea8f494 Fix goto definition for record patterns 2020-04-18 22:11:49 +02:00
Josh Mcguigan
7adb681b1f missing match arm diagnostic support enum record type 2020-04-18 05:54:56 -07:00
bors[bot]
162481d5ce
Merge #4023
4023: Fix another crash from wrong binders r=matklad a=flodiebold

Basically, if we had something like `dyn Trait<T>` (where `T` is a type parameter) in an impl we lowered that to `dyn Trait<^0.0>`, when it should be `dyn Trait<^1.0>` because the `dyn` introduces a new binder. With one type parameter, that's just wrong, with two, it'll lead to crashes.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-04-18 08:48:08 +00:00
Florian Diebold
d3cb9ea0bf Fix another crash from wrong binders
Basically, if we had something like `dyn Trait<T>` (where `T` is a type
parameter) in an impl we lowered that to `dyn Trait<^0.0>`, when it should be
`dyn Trait<^1.0>` because the `dyn` introduces a new binder. With one type
parameter, that's just wrong, with two, it'll lead to crashes.
2020-04-18 00:01:09 +02:00
Florian Diebold
6a7fc76b89 Fix type equality for dyn Trait
Fixes a lot of false type mismatches.

(And as always when touching the unification code, I have to say I'm looking
forward to replacing it by Chalk's...)
2020-04-17 19:42:36 +02:00
Florian Diebold
fbd95785a6 Add two more tests for associated types 2020-04-17 18:27:38 +02:00
bors[bot]
179d983535
Merge #4012
4012: fix panic on ellipsis in pattern r=flodiebold a=JoshMcguigan

fixes #3999

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-04-17 12:39:20 +00:00
Josh Mcguigan
408f914bf4 fix panic on ellipsis in pattern 2020-04-17 05:36:44 -07:00
Aleksey Kladov
146f6f5a45 Simplify Diagnostic structure
It's not entirely clear what subnode ranges should mean in the
presence of macros, so let's leave them out for now. We are not using
them heavily anyway.
2020-04-17 13:56:42 +02:00
Aleksey Kladov
a8196ffe84 Correctly highlight ranges of diagnostics from macros
closes #2799
2020-04-17 13:56:38 +02:00
Aleksey Kladov
302bf97bbf Don't expose impl details of SyntaxPtr 2020-04-17 12:25:41 +02:00
bors[bot]
0390d62168
Merge #3979
3979: fix missing match arm false positive for enum with no variants r=flodiebold a=JoshMcguigan

fixes #3974

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-04-16 12:57:31 +00:00
Josh Mcguigan
360bdf653b fix false positive for enum with no variants 2020-04-16 05:37:49 -07:00
Florian Diebold
39fe3a6486 Test for non-working proc macro server assoc types 2020-04-16 13:06:23 +02:00
Florian Diebold
14570df015 Switch Chalk to recursive solver
+ various fixes related to that.
2020-04-16 13:06:23 +02:00
Florian Diebold
e8d0d79a0c Update Chalk 2020-04-16 12:39:00 +02:00
bors[bot]
1e0ba04033
Merge #3966 #3968
3966: Add support for bounds on associated types in trait definitions r=matklad a=flodiebold

E.g.
```rust
trait Trait {
    type Item: SomeOtherTrait;
}
```
Note that these don't simply desugar to where clauses; as I understand it, where clauses have to be proved by the *user* of the trait, but these bounds are proved by the *implementor*. (Also, where clauses on associated types are unstable.)

(Another one from my recursive solver branch...)

3968: Remove format from syntax_bridge hot path r=matklad a=edwin0cheng

Although only around 1% speed up by running:

```
Measure-Command {start-process .\target\release\rust-analyzer "analysis-stats -q ." -NoNewWindow -wait}
```

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-15 09:29:36 +00:00
bors[bot]
d61909f904
Merge #3964 #3965 #3967
3964: Nicer Chalk debug logs r=matklad a=flodiebold

I'm looking at a lot of Chalk debug logs at the moment, so here's a few changes to make them slightly nicer...

3965: Implement inline associated type bounds r=matklad a=flodiebold

Like `Iterator<Item: SomeTrait>`.

This is an unstable feature, but it's used in the standard library e.g. in the definition of Flatten, so we can't get away with not implementing it :)

(This is cherry-picked from my recursive solver branch, where it works better, but I did manage to write a test that works with the current Chalk solver as well...)

3967: Handle `Self::Type` in trait definitions when referring to own associated type r=matklad a=flodiebold

It was implemented for other generic parameters for the trait, but not for `Self`.

(Last one off my recursive solver branch 😄 )

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-04-15 09:19:46 +00:00
bors[bot]
9726401eae
Merge #3963
3963: Upgrade Chalk r=matklad a=flodiebold



Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-04-15 09:08:39 +00:00
kjeremy
eedab116ab insta 0.16 2020-04-14 13:57:02 -04:00
Josh Mcguigan
ee822d19b7 handle tuple patterns with ellipsis 2020-04-13 08:19:19 -07:00
Florian Diebold
d88d67819b Handle Self::Type in trait definitions when referring to own associated type
It was implemented for other generic parameters for the trait, but not for `Self`.
2020-04-13 16:32:23 +02:00
Florian Diebold
c216a93da7 Upgrade Chalk 2020-04-13 16:18:25 +02:00
Florian Diebold
c8b2ec8c20 Add support for bounds on associated types in trait definitions
E.g.
```
trait Trait {
    type Item: SomeOtherTrait;
}
```
Note that these don't simply desugar to where clauses; as I understand it, where
clauses have to be proved by the *user* of the trait, but these bounds are proved
by the *implementor*. (Also, where clauses on associated types are unstable.)
2020-04-13 15:57:28 +02:00
Florian Diebold
db32a2e421 Implement inline associated type bounds
Like `Iterator<Item: SomeTrait>`.

This is an unstable feature, but it's used in the standard library e.g. in the
definition of Flatten, so we can't get away with not implementing it :)
2020-04-13 15:07:39 +02:00
Florian Diebold
2e7b88b525 Nicer display of projections in Chalk logs 2020-04-13 14:46:03 +02:00
Florian Diebold
7886513f89 Nicer display of closures in Chalk logs 2020-04-13 14:31:03 +02:00
bors[bot]
268b798729
Merge #3938
3938: fix missing match arm false positive r=flodiebold a=JoshMcguigan

This fixes #3932 by skipping the missing match arm diagnostic in the case any of the match arms don't type check properly against the match expression. 

I think this is the appropriate behavior for this diagnostic, since `is_useful` relies on all match arms being well formed, and the case of a malformed match arm should probably be handled by a different diagnostic.

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-04-12 08:30:24 +00:00
Josh Mcguigan
bb2e5308b7 missing match arm add test cases to demonstrate enum tuple struct with ellipsis behavior 2020-04-11 21:20:52 -07:00
Josh Mcguigan
a59179ac2d missing match arms add test cases to demonstrate behavior of tuple with pattern 2020-04-11 20:50:54 -07:00
Aleksey Kladov
5e5eb6a108 Align grammar for record patterns and literals
The grammar now looks like this

   [name_ref :] pat
2020-04-12 00:00:15 +02:00
bors[bot]
1a1c09ed3e
Merge #3951
3951: Simplify records grammar r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-11 17:37:02 +00:00
Aleksey Kladov
0aece75cdd Remove dead code 2020-04-11 19:36:31 +02:00
Florian Diebold
a2783df3f0 Look up impls by self type
This speeds up inference in analysis-stats by ~30% (even more with the recursive
solver).
2020-04-11 18:04:09 +02:00
Josh Mcguigan
aec20e5094 missing match arm add test for partially diverging type 2020-04-11 07:13:47 -07:00
Josh Mcguigan
26e5bb0a4e missing match arms add tests for match expression diverging 2020-04-11 07:07:47 -07:00
Josh Mcguigan
d1338354ca fix match arm false positive 2020-04-10 20:14:53 -07:00
Aleksey Kladov
c1244c853c Forward compat 2020-04-11 00:27:00 +02:00
Aleksey Kladov
5e2f29af85 Add failing test 2020-04-10 19:43:37 +02:00
bors[bot]
38e0d0f334
Merge #3905
3905: add ellipsis field to hir pat record r=matklad a=JoshMcguigan

This PR corrects a `fixme`, adding an `ellipsis` field to the hir `Pat::Record` type. It will also be unlock some useful follow on work for #3894.

Additionally it adds a diagnostic for missing fields in record patterns.

~~Marking as a draft because I don't have any tests, and a small amount of manual testing on my branch from #3894 suggests it might *not* be working. Any thoughts on how I can best test this, or else pointers on where I might be going wrong?~~

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-04-10 13:52:25 +00:00
Josh Mcguigan
e63315b8f1 add record pat missing field diagnostic 2020-04-10 06:35:52 -07:00
Florian Diebold
a0a80a4103 Implement Chalk's debug methods using TLS
Chalk now panics if we don't implement these methods and run with CHALK_DEBUG,
so I thought I'd try to implement them 'properly'. Sadly, it seems impossible to
do without transmuting lifetimes somewhere. The problem is that we need a `&dyn
HirDatabase` to get names etc., which we can't just put into TLS. I thought I
could just use `scoped-tls`, but that doesn't support references to unsized
types. So I put the `&dyn` into another struct and put the reference to *that*
into the TLS, but I have to transmute the lifetime to 'static for that to work.
2020-04-10 15:04:06 +02:00