Commit Graph

97 Commits

Author SHA1 Message Date
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
bors[bot]
d590f6ce12
Merge #2592
2592: Add std::ops::Index support for infering r=edwin0cheng a=edwin0cheng

see also #2534

Seem like this can't fix #2534 for this case:

```rust
fn foo3(bar: [usize; 2]) {
    let baz = bar[1];   // <--- baz is still unknown ?
    println!("{}", baz);
}
```

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-12-20 14:36:53 +00:00
Aleksey Kladov
1234dda9ee Use generic ItemLoc for impls 2019-12-20 13:47:44 +01:00
Aleksey Kladov
f42697e54b Support for nested traits 2019-12-20 12:29:25 +01:00
Aleksey Kladov
ac5a3f611b Support for nested ADT 2019-12-20 12:20:49 +01:00
Aleksey Kladov
94ad07af4b Introduce ContainerId 2019-12-20 12:07:23 +01:00
Aleksey Kladov
8fc20b6503 Rename ContainerId -> AssocContainerId 2019-12-20 12:00:05 +01:00
Edwin Cheng
76d688a328 Use fill instread of for loop 2019-12-20 03:04:55 +08:00
Aleksey Kladov
ba12e83c26 Add body as a possible container for items 2019-12-19 18:12:46 +01:00
Kirill Bulatov
4ed78f80f4 Remove TruncateOptions struct 2019-12-19 16:43:41 +02:00
Edwin Cheng
b61ad6a964 Use build_for_def 2019-12-19 22:28:52 +08:00
Kirill Bulatov
14c167a9f6 Omit default parameter types 2019-12-19 12:27:33 +02:00
Edwin Cheng
dddee23f43 Add std::ops::Index support for infering 2019-12-19 12:45:07 +08:00
Aleksey Kladov
04715cbe1c Forbid <T>::foo syntax in mod paths 2019-12-18 17:41:33 +01:00
Florian Diebold
91853590a9 Add test mark 2019-12-15 21:06:08 +01:00
Florian Diebold
6e1c2d0df8 Handle impl Trait more correctly
When calling a function, argument-position impl Trait is transparent; same for
return-position impl Trait when inside the function. So in these cases, we need
to represent that type not by `Ty::Opaque`, but by a type variable that can be
unified with whatever flows into there.
2019-12-15 18:56:38 +01:00
Florian Diebold
ac961b2614 Add test for unifying impl Trait 2019-12-15 17:45:32 +01:00
Aleksey Kladov
2619950b3b Use different types for path with and without generics 2019-12-14 19:15:40 +01:00
Florian Diebold
f02fcc1644 Use path macro 2019-12-13 22:33:38 +01:00
Florian Diebold
6911bc89a7 Rename N! to name! 2019-12-13 22:33:38 +01:00
Florian Diebold
259c42f00e Add macros for known names and paths 2019-12-13 22:33:37 +01:00
Emil Lauridsen
7705209051 Correctly infer - and ! using std::ops::{Neg,Not} 2019-12-13 12:45:38 +01:00
Emil Lauridsen
95dc2de8e9 Add helper for resolving associated type of trait in infer 2019-12-13 12:45:37 +01:00
Aleksey Kladov
56710f119b Move enum&union to new loc 2019-12-12 15:11:57 +01:00