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
Florian Diebold
6c70619b01
Deal better with implicit type parameters and argument lists
2020-02-07 18:28:10 +01:00
Florian Diebold
dded90a748
Formatting
2020-02-07 18:28:10 +01:00
Florian Diebold
6787f124b5
Clean up RPIT a bit
2020-02-07 18:28:10 +01:00
Florian Diebold
0718682cff
Fix compilation of other crates
2020-02-07 18:28:10 +01:00
Florian Diebold
a3d8cffde3
Use variables in predicates as well
2020-02-07 18:28:10 +01:00
Florian Diebold
86348f5994
Comment fixes / todos
2020-02-07 18:28:10 +01:00
Florian Diebold
3397ca679f
Fix APIT some more
2020-02-07 18:28:10 +01:00
Florian Diebold
c6654fd4a7
Fix APIT
2020-02-07 18:28:10 +01:00
Florian Diebold
ed25cf70d5
Change Ty::Param to contain param ID
2020-02-07 18:28:10 +01:00
Florian Diebold
f8b7b64bce
WIP use params for APIT
2020-02-07 18:28:10 +01:00
Florian Diebold
33aa2f8e4f
Fix assoc type selection
2020-02-07 18:28:10 +01:00
Florian Diebold
4a8279a21a
Fix another test
2020-02-07 18:28:10 +01:00
Florian Diebold
dbc14f9d57
First stab at desugaring bounds for APIT
2020-02-07 18:28:10 +01:00
Florian Diebold
a9430865b3
Fix crash
2020-02-07 18:28:10 +01:00