Edwin Cheng
0a06c7e6e6
Implment include macro
2020-03-06 22:58:45 +08:00
Florian Diebold
073a1ef834
Support aliases and Self in struct literals
...
Fixes #3306 .
2020-03-06 15:43:14 +01:00
Aleksey Kladov
fb5891c433
Source map returns a result
...
cc #2236
2020-03-06 14:44:44 +01:00
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
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
Florian Diebold
a5554dcb17
Fix enum constructors
2020-02-07 18:28:10 +01:00
Florian Diebold
4789a993eb
Fix printing of function types
2020-02-07 18:28:10 +01:00
Florian Diebold
16c6937447
Lower impl trait to variables, move away from using placeholders where they don't belong
2020-02-07 18:28:10 +01:00
Florian Diebold
93aa166748
wip lower impl trait to type args
2020-02-07 18:28:10 +01:00
Florian Diebold
9dec65d3b1
wip implement lowering mode
2020-02-07 18:28:10 +01:00
Florian Diebold
7ea4bce1b2
Add impl trait lowering mode
2020-02-07 18:28:10 +01:00
Florian Diebold
22a65b11b3
Introduce TyLoweringContext
2020-02-07 18:28:10 +01:00
Aleksey Kladov
6ca19b2188
Standard formatting for array types
2020-01-28 15:32:20 +01:00
Florian Diebold
339a11c33c
Tweak Chalk settings
2020-01-27 21:52:35 +01:00
Florian Diebold
d3a3e5abdf
Ignore failing impl Trait tests
2020-01-27 21:38:10 +01:00
Florian Diebold
96ddf2962c
Upgrade Chalk
2020-01-27 21:25:33 +01:00
Jeremy Kolb
b89991daed
Update crates
2020-01-26 10:46:45 -05:00
Kirill Bulatov
4029e44102
Omit default parameters for reference types
2020-01-22 16:55:09 +02:00
Florian Diebold
33d637f2dd
Fix inference for shift operators
...
Fixes #2602 .
2020-01-17 16:59:51 +01:00
bors[bot]
767ff2c13c
Merge #2844
...
2844: Use dummy value for line! and column! macro r=matklad a=edwin0cheng
Use dummy value `0` for line! and column! macro.
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-01-14 17:59:24 +00:00
Edwin Cheng
6ebb1edf21
Use dummy value for line! and column! macro
2020-01-15 01:47:01 +08:00
Aleksey Kladov
21c5fd8b1b
Push resolver further up
2020-01-14 14:24:03 +01:00
Aleksey Kladov
7ec62ea5e6
Push resolver up
2020-01-14 14:11:07 +01:00
Aleksey Kladov
52e7f67128
Move impls_future to Type, where it belongs
2020-01-14 11:29:43 +01:00
Aleksey Kladov
5654387e77
Don't panic if chalk panics
2020-01-13 19:00:42 +01:00
Florian Diebold
9dc1826cfa
Fix various names, e.g. Iterator not resolving in core prelude
...
Basically, `Iterator` is re-exported via several steps, which happened to not be
resolved yet when we got to the prelude import, but since the name resolved to
the reexport from `core::iter` (just to no actual items), we gave up trying to
resolve it further.
Maybe part of the problem is that we can have
`PartialResolvedImport::Unresolved` or `PartialResolvedImport::Indeterminate`
with `None` in all namespaces, and handle them differently.
Fixes #2683 .
2020-01-11 23:37:58 +01:00
Florian Diebold
dd6ec81d65
Add test for macro expansion in various expressions
2020-01-10 22:08:02 +01:00
Edwin Cheng
ca62d98781
Expand PAREN_EXPR as expression
2020-01-11 00:29:00 +08:00
bors[bot]
cb160f2a34
Merge #2742
...
2742: Split `infer` query into two for better profiling r=flodiebold a=michalt
This is the same change as we did with `crate_def_map` and it does seem
that we mostly spend time in salsa, without recomputing much on
rust-analyzer side.
Example output:
```
233ms - handle_inlay_hints
163ms - get_inlay_hints
163ms - SourceAnalyzer::new
67ms - def_with_body_from_child_node
67ms - analyze_container
67ms - analyze_container
67ms - Module::from_definition
67ms - Module::from_file
67ms - crate_def_map
0ms - parse_macro_query (6 calls)
0ms - raw_items_query (1 calls)
66ms - ???
0ms - crate_def_map (1 calls)
0ms - crate_def_map (1 calls)
96ms - infer
2ms - trait_solve_query (2 calls)
94ms - ???
0ms - body_with_source_map_query (1 calls)
0ms - crate_def_map (1 calls)
[...]
```
Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
Co-authored-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-03 19:08:32 +00:00
Michal Terepeta
d6c2a59538
Split infer
query into two for better profiling
...
This is the same change as we did with `crate_def_map` and it does seem
that we mostly spend time in salsa, without recomputing much on
rust-analyzer side.
Example output:
```
233ms - handle_inlay_hints
163ms - get_inlay_hints
163ms - SourceAnalyzer::new
67ms - def_with_body_from_child_node
67ms - analyze_container
67ms - analyze_container
67ms - Module::from_definition
67ms - Module::from_file
67ms - crate_def_map
0ms - parse_macro_query (6 calls)
0ms - raw_items_query (1 calls)
66ms - ???
0ms - crate_def_map (1 calls)
0ms - crate_def_map (1 calls)
96ms - infer
2ms - trait_solve_query (2 calls)
94ms - ???
0ms - body_with_source_map_query (1 calls)
0ms - crate_def_map (1 calls)
[...]
```
Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-03 19:58:11 +01:00
Florian Diebold
67240c8d91
Fix #2705
...
The `-` turned into a `+` during a refactoring.
The original issue was caused by `Read` resolving wrongly to a trait without
type parameters instead of a struct with one parameter; this only fixes the
crash, not the wrong resolution.
2020-01-03 14:57:11 +01:00
Emil Lauridsen
8fad8e897a
Resolve traits in infer using lang item infrastructure
2019-12-29 17:39:31 +01:00
Aleksey Kladov
8f36f768e1
Don't add non-impl/trait containers to scope
2019-12-29 14:47:47 +01:00
bors[bot]
823e9193fe
Merge #2657
...
2657: Omit closure parameters in closure type display strings r=flodiebold a=SomeoneToIgnore
Part of https://github.com/rust-analyzer/rust-analyzer/issues/1946
I wonder, should we display the the closure trait (Fn/FnMut/FnOnce) in inlay hints instead of `|...|` at all?
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2019-12-27 10:10:07 +00:00
bors[bot]
3f7e5cde0b
Merge #2661
...
2661: Implement infer await from async function r=flodiebold a=edwin0cheng
This PR is my attempt for trying to add support for infer `.await` expression from an `async` function, by desugaring its return type to `Impl Future<Output=RetType>`.
Note that I don't know it is supposed to desugaring it in that phase, if it is not suitable in current design, just feel free to reject it :)
r=@flodiebold
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-12-24 16:28:46 +00:00
Edwin Cheng
42813126d9
Check if parameters is empty
2019-12-25 00:12:29 +08:00
Edwin Cheng
3a2cf708ed
Add FIXME
2019-12-24 23:39:17 +08:00
Edwin Cheng
0edb5b4a50
Implement infer await from async func
2019-12-24 19:45:28 +08:00