Commit Graph

184 Commits

Author SHA1 Message Date
Edwin Cheng
e04c0f4222 Fix panic on eager expansion 2020-03-04 02:41:33 +08:00
Edwin Cheng
fe04c28b59 Add test 2020-03-04 01:21:14 +08:00
Laurențiu Nicola
91e02ace06 Drop larlpop-intern dep 2020-03-03 07:57:16 +02:00
Laurențiu Nicola
f60cf882a8 Update chalk for Ty interners 2020-03-03 00:02:19 +02:00
Laurențiu Nicola
807a56bebf Update chalk for RawId removal 2020-03-02 23:30:38 +02:00
bors[bot]
02f761ba4b
Merge #3397 #3398
3397: Minimal viable meta r=matklad a=matklad



bors r+
🤖

3398: Reformat? r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-02 13:31:56 +00:00
Aleksey Kladov
62e62d1c23 Reformat? 2020-03-02 14:28:34 +01:00
bors[bot]
79c874803b
Merge #3385
3385: Fix #3373 r=matklad a=flodiebold

Basically, we need to allow variables in the caller self type to unify with the
impl's declared self type. That requires some more contortions in the variable
handling. I'm looking forward to (hopefully) handling this in a cleaner way when
we switch to Chalk's types and unification code.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-03-02 13:23:24 +00:00
Josh Mcguigan
f5efa17515 handle array pattern matching type inference 2020-03-01 14:02:32 -08:00
Josh Mcguigan
b9ef7a6b98 remove match statement, handle suffix 2020-03-01 12:13:05 -08:00
Josh Mcguigan
d0e282f6b1 handle arbitrary length slices 2020-03-01 07:35:15 -08:00
Josh Mcguigan
f353625705 match single prefix slice 2020-03-01 06:25:38 -08:00
Florian Diebold
336a3c6121 Fix #3373
Basically, we need to allow variables in the caller self type to unify with the
impl's declared self type. That requires some more contortions in the variable
handling. I'm looking forward to (hopefully) handling this in a cleaner way when
we switch to Chalk's types and unification code.
2020-03-01 14:31:35 +01:00
Florian Diebold
31171eed5e Do autoderef for indexing 2020-02-29 22:48:53 +01:00
Florian Diebold
e313efb992 Do array unsizing for method receivers
It turns out rustc actually only unsizes array method receivers, so we don't
need to do any trait solving for this (at least for now).

Fixes #2670.
2020-02-29 22:48:53 +01:00
Aleksey Kladov
a1e1869554 Rename ast::ImplBlock -> ast::ImplDef 2020-02-29 21:33:15 +01:00
Florian Diebold
5fe220b987 Fix a common false-positive type mismatch
E.g. for `&{ some_string() }` in a context where a `&str` is expected, we
reported a mismatch inside the block. The problem is that we're passing an
expectation of `str` down, but the expectation is more of a hint in this case.
There's a long comment in rustc about this, which I just copied.

Also, fix reported location for type mismatches in macros.
2020-02-29 15:31:07 +01:00
Aleksey Kladov
c6247f74c7 Basic injections 2020-02-27 16:16:13 +01:00
Laurențiu Nicola
ed69482d90 Bump chalk and replace TypeFamily with Interner 2020-02-24 22:36:57 +02:00
Florian Diebold
5a6e770f99 Shorten some code 2020-02-22 13:15:54 +01:00
Florian Diebold
3e106c77ff Rework find_super_trait_path to protect against cycles 2020-02-22 13:14:39 +01:00
Florian Diebold
c200025794 Fix shift_bound_vars
It should only shift free vars (maybe the name isn't the best...)
2020-02-22 11:09:21 +01:00
Florian Diebold
463df6720c Fix wrong handling of bare dyn Trait exposed by canonicalizer fix
The self type in the `dyn Trait` trait ref should always be ^0, but we didn't
put that in there in the bare case.
2020-02-22 11:09:21 +01:00
Florian Diebold
2d5ab63247 Add &dyn Trait -> &dyn SuperTrait coercion, and fix &T -> &dyn Trait 2020-02-22 11:09:21 +01:00
Florian Diebold
f126808b2e Fix handling of binders in canonicalization
I'm looking forward to getting rid of this in favor of Chalk's implementation.
2020-02-22 11:09:21 +01:00
Florian Diebold
0dfbbaf03b Implement dyn Trait unsizing as well 2020-02-22 11:09:21 +01:00
Florian Diebold
de39d221a1 Implement unsize coercion using proper trait solving 2020-02-22 11:09:21 +01:00
Florian Diebold
f1f45f9191 Fix handling of const patterns
E.g. in `match x { None => ... }`, `None` is a path pattern (resolving to the
option variant), not a binding. To determine this, we need to try to resolve the
name during lowering. This isn't too hard since we already need to resolve names
for macro expansion anyway (though maybe a bit hacky).

Fixes #1618.
2020-02-21 17:01:19 +01:00
Florian Diebold
e50201345e Normalize associated types in types coming from Chalk
Fixes #3232.
2020-02-21 14:06:19 +01:00
bors[bot]
e00b9ca3c9
Merge #3215
3215: Exclude methods from non-parameter types introduced by generic constraints r=flodiebold a=lnicola

Fixes #3184.

r? @flodiebold

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-02-19 19:46:37 +00:00
Aleksey Kladov
9549aad525 Fill missing fields of enum variants 2020-02-19 18:17:09 +01:00
Laurențiu Nicola
5b05209744 Exclude methods from non-parameter types introduced by generic constraints 2020-02-19 10:46:13 +02:00
Kirill Bulatov
f6816c253b Update versions 2020-02-18 16:12:40 +02:00
Kirill Bulatov
eceaf94f19 More manual clippy fixes 2020-02-18 16:12:37 +02:00
Kirill Bulatov
b8ddcb0652 Run cargo +nightly fix --clippy -Z unstable-options 2020-02-18 16:03:08 +02:00
bors[bot]
fcf15cc05a
Merge #3169
3169: Show record field names in Enum completion r=flodiebold a=adamrk

Adresses https://github.com/rust-analyzer/rust-analyzer/issues/2947.
Previously the details shown when autocompleting an Enum variant would look like the variant was a tuple even if it was a record:
![2020-02-16-15:59:32_crop](https://user-images.githubusercontent.com/16367467/74607233-64f21980-50d7-11ea-99db-e973e29c71d7.png)

This change will show the names of the fields for a record and use curly braces instead of parentheses:
![2020-02-16-15:33:00_crop](https://user-images.githubusercontent.com/16367467/74607251-8ce17d00-50d7-11ea-9d4d-38d198a4aec0.png)

This required exposing the type `adt::StructKind` from `ra_hir` and adding a function 
```
kind(self, db: &impl HirDatabase) -> StructKind
```
in the `impl` of `EnumVariant`. 

There was also a previously existing function `is_unit(self, db: &impl HirDatabase) -> bool` for `EnumVariant` which I removed because it seemed redundant after adding `kind`.

Co-authored-by: adamrk <ark.email@gmail.com>
2020-02-17 10:54:32 +00:00
adamrk
0e260aa6b1 use 'if let' instead of match on kind in lower.rs 2020-02-17 11:53:12 +01:00
adamrk
68d3743faf replace uses of VariantData::is_unit with VariantData::kind 2020-02-16 16:10:32 +01:00
Florian Diebold
e14e7ffa34 Fix coercion of &T to itself
The autoderef coercion logic did not handle matching placeholders. This led to
some type mismatches.
2020-02-16 12:58:20 +01:00
Florian Diebold
3484d727c3 Extend analysis-stats a bit
This adds some tools helpful when debugging nondeterminism in analysis-stats:
 - a `--randomize` option that analyses everything in random order
 - a `-vv` option that prints even more detail

Also add a debug log if Chalk fuel is exhausted (which would be a source of
nondeterminism, but didn't happen in my tests).

I found one source of nondeterminism (rust-lang/chalk#331), but there are still
other cases remaining.
2020-02-15 18:04:01 +01:00
bors[bot]
b2b94cbf71
Merge #3147
3147: Check that impl self type matches up with expected self type in path mode r=matklad a=flodiebold

Fixes #3144.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-02-14 20:32:55 +00:00
Florian Diebold
f47dc4de8d Check that impl self type matches up with expected self type in path mode
Fixes #3144.
2020-02-14 21:08:25 +01:00
Florian Diebold
001dd6a200 Make Self implement the trait inside trait default methods 2020-02-14 20:39:04 +01:00
Florian Diebold
5028b86cb8 Move hir_fmt code to display module 2020-02-14 15:01:42 +01:00
Florian Diebold
a324d066cb Rename Ty::Param => Ty::Placeholder
This aligns more with Chalk.
2020-02-14 14:44:00 +01:00
Florian Diebold
43df7c3d53 Don't let unknown match arms fall back to ! 2020-02-11 21:09:11 +01:00
Matthew Jasper
8c8d0bb34f Add or- and parenthesized-patterns 2020-02-09 22:06:15 +00:00
Florian Diebold
eefe02ce6e Add two more tests 2020-02-07 18:28:11 +01:00
Florian Diebold
9d6061f3bb Fix some TODOs 2020-02-07 18:28:11 +01:00
Florian Diebold
b0bb8622ee Don't print implicit type args from impl Trait 2020-02-07 18:28:11 +01:00