Commit graph

120 commits

Author SHA1 Message Date
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
Kirill Bulatov
242be3631e Omit closure parameters 2019-12-23 18:30:25 +02:00
Florian Diebold
1f7f4578f7 Filter out error predicates in type bounds as well 2019-12-23 00:08:03 +01:00
Florian Diebold
4053fcfca0 Introduce our own Chalk TypeFamily, instead of using ChalkIr
It's not very different, except we can directly use Salsa IDs instead of casting
them. This means we need to refactor the handling of errors to get rid of
UNKNOWN_TRAIT though.
2019-12-23 00:08:03 +01:00
Florian Diebold
6b5efe5bda Refactor Chalk integration some more 2019-12-23 00:08:03 +01:00
Florian Diebold
67a2555f6d Update Chalk, clean up Chalk integration a bit 2019-12-23 00:08:03 +01:00
Aleksey Kladov
e424545c0f Rudimentary name resolution for local items 2019-12-22 22:41:21 +01:00
bors[bot]
3ebf15c9b2
Merge #2626
2626: Recursive collect macros in impl items r=matklad a=edwin0cheng



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-12-21 10:12:18 +00:00
bors[bot]
1cbef27ff8
Merge #2625
2625: Clippy lints r=matklad a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-12-21 06:12:36 +00:00
Edwin Cheng
360de5ba71 Recursive collect macros in impl items 2019-12-21 05:02:31 +08:00
kjeremy
0d5d63a80e Clippy lints 2019-12-20 15:14:30 -05:00
bors[bot]
6eab968c60
Merge #2624
2624: Separate module item from module scope r=matklad a=matklad

bors r+

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-12-20 19:51:03 +00:00
bors[bot]
f578cd2182
Merge #2623
2623: Add support macros in impl blocks r=matklad a=edwin0cheng

This PR add support for macros in impl blocks, which reuse `Expander` for macro expansion.

see also: #2459 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-12-20 19:42:46 +00:00
Edwin Cheng
ad81d1dbc1 Add support macros in impl blocks 2019-12-21 03:37:03 +08:00
Florian Diebold
44b00aed4a Coerce closures to fn pointers
E.g. `let x: fn(A) -> B = |x| { y };`
2019-12-20 18:54:33 +01:00
Florian Diebold
9c3f00a906 Fix coercion of last expression in function body 2019-12-20 18:28:21 +01:00
Florian Diebold
2a8c9100bf Handle closure return types
Fixes #2547.
2019-12-20 18:16:11 +01:00
Aleksey Kladov
1b8ce5b37b Move impls to ItemScope 2019-12-20 16:52:02 +01:00