Commit graph

64 commits

Author SHA1 Message Date
Aleksey Kladov
f1367e0370 remove Cancelable from navigation target 2019-01-15 18:50:16 +03:00
Aleksey Kladov
9446be2999 remove Cancelable from adt API 2019-01-15 18:43:25 +03:00
Aleksey Kladov
fedd320cf2 check_canceled does not return Result 2019-01-15 15:45:48 +03:00
Marcus Klaas de Vries
37ba237e66 Address issues found in review 2019-01-14 21:52:08 +01:00
Marcus Klaas de Vries
a9a6a50c75 Fixup tests 2019-01-14 19:30:21 +01:00
Marcus Klaas de Vries
81bc8e4973 don't try to treat arrays and tuples as literals 2019-01-14 13:55:49 +01:00
Marcus Klaas de Vries
1574715be5 Use type variables to determine exact type for ambiguous numeric literals 2019-01-14 13:54:31 +01:00
Marcus Klaas de Vries
5f5dc20d85 Try implementing integer type inference (WIP) 2019-01-14 13:52:57 +01:00
Marcus Klaas de Vries
a6146d35b1 Implement type inference for literals (WIP) 2019-01-14 13:52:55 +01:00
Aleksey Kladov
eedc08300c goto defenition works for type-inferred methods 2019-01-13 18:56:57 +03:00
Hirokazu Hata
6e73cc89b6 Implement tuple inference 2019-01-13 21:10:01 +09:00
Florian Diebold
1ed7fbfc1b args -> params 2019-01-12 21:58:16 +01:00
Florian Diebold
082ef52bcb Implement basic inherent method resolution 2019-01-12 15:01:19 +01:00
Florian Diebold
1212e59bee Fix assertion error in unification (hopefully)
Currently, all types that we handle during inference need to be resolved as far
as possible at the time. It's maybe too brittle of an invariant; I need to think
how we can do this better. This should fix #484 though, I hope (if
it's the same case as I managed to reproduce).
2019-01-11 22:59:00 +01:00
Aleksey Kladov
f193fbcbae actually produce missing def kinds 2019-01-11 21:02:12 +03:00
Marcus Klaas de Vries
978de5cf8b Implement type inference for enum variants 2019-01-10 14:32:56 +01:00
Aleksey Kladov
e8815b614e nicer trailing comma handling in types 2019-01-09 19:14:21 +03:00
Marcus Klaas de Vries
0b8fbb4fad Fix typos in ARCHITECTURE.md and a number of crates
specifically: gen_lsp_server, ra_arena, ra_cli, ra_db, ra_hir
2019-01-09 01:17:09 +01:00
Aleksey Kladov
695294bbb9 ra_db is independent from editor 2019-01-08 21:03:42 +03:00
Marcus Klaas de Vries
e51d44a2de Process explicit type hints for str, bool and char 2019-01-07 20:43:41 +01:00
Marcus Klaas de Vries
5d15dd70b0 Tidy up binary operator type inference; add test file 2019-01-07 20:39:23 +01:00
Marcus Klaas de Vries
7b0eaef580 Implement type inference for more binary operators
Mostly just for primitive numeric types such as u32 and f64. Not
yet a general solution using trait resolution.
2019-01-07 20:11:31 +01:00
Marcus Klaas de Vries
3238c06a5a Add remaining binary operations to AST 2019-01-07 19:04:25 +01:00
Florian Diebold
7bb279b365 Implement autoderef for field accesses 2019-01-07 14:54:23 +01:00
Florian Diebold
71f7d82e45 Introduce ArenaMap 2019-01-07 00:05:19 +01:00
Florian Diebold
6210e82041 Use HIR Expr for type inference
Now we can reuse the type inference inside a function when typing whitespace
etc. :)
2019-01-07 00:05:19 +01:00
bors[bot]
31c1999505 Merge #440
440: Implement type inference for boolean operators r=flodiebold a=marcusklaas

Tried implementing the easiest part of https://github.com/rust-analyzer/rust-analyzer/issues/390. Hope this is somewhat close to what the intent of the issue was. Found it surprisingly easy to find my way around the repository - it's well organized!

Very grateful for any pointers.

Co-authored-by: Marcus Klaas de Vries <mail@marcusklaas.nl>
2019-01-06 21:28:36 +00:00
Marcus Klaas de Vries
82d9a77dad Touch up type inference for boolean operators
Also try to infer its subexpressions and set type expectations
whenever possible.
2019-01-06 22:17:54 +01:00
Florian Diebold
8e3e5ab2c8 Make FnScopes use hir::Expr
This was a bit complicated. I've added a wrapper type for now that does the
LocalSyntaxPtr <-> ExprId translation; we might want to get rid of that or give
it a nicer interface.
2019-01-06 00:29:36 +01:00
Marcus Klaas de Vries
4fc233a02e Implement type inference for boolean operators 2019-01-05 21:28:30 +01:00
Florian Diebold
334ca0d9a7 Rename ImplBlock::target -> target_type, and add target_trait already 2019-01-04 19:16:39 +01:00
Florian Diebold
6ab0e292d2 Refactor a bit 2019-01-04 19:14:22 +01:00
Florian Diebold
538147bf94 Resolve the Self type 2019-01-04 19:13:50 +01:00
Florian Diebold
d4db61b9a1 Resolve the self parameter during type inference 2019-01-04 19:12:29 +01:00
Florian Diebold
111126ed3c Type the self parameter 2019-01-04 19:10:50 +01:00
Florian Diebold
4142792d1f Add more docs in ty.rs
Also get rid of the indirection through query_definitions for the type-related
queries.
2018-12-29 20:27:13 +01:00
Florian Diebold
b1590bdf6a Missing return type means unit, not unknown 2018-12-29 12:08:57 +01:00
Florian Diebold
cfa1de72eb Implement type variables
This will really become necessary when we implement generics, but even now, it
allows us to reason 'backwards' to infer types of expressions that we didn't
understand for some reason.

We use ena, the union-find implementation extracted from rustc, to keep track of
type variables.
2018-12-29 12:04:34 +01:00
Aleksey Kladov
7928995876 nameify structs&enums 2018-12-28 21:34:58 +03:00
Aleksey Kladov
a9f55029b9 introduce known names 2018-12-27 20:26:15 +03:00
Aleksey Kladov
d963042ca9 introduce hir::Name 2018-12-27 20:07:21 +03:00
Florian Diebold
bc745a1396 Resolve field types lazily
I.e. not already when getting the HIR for the struct.
2018-12-25 21:40:33 +01:00
Florian Diebold
cdca397061 Add a hir::TypeRef as an intermediate between ast::TypeRef and ty::Ty 2018-12-25 21:14:13 +01:00
Florian Diebold
2870effd5c Implement reference / pointer types
- parse them
 - infer types of & and * expressions
2018-12-25 20:36:06 +01:00
Florian Diebold
b96d361239 Handle structs/enums with missing names a bit better 2018-12-25 17:55:50 +01:00
Florian Diebold
3befd1a9e8 Cleanup 2018-12-25 15:44:10 +01:00
Florian Diebold
ab0b63992b Implement basic completion for fields 2018-12-25 15:27:15 +01:00
Florian Diebold
55c941cd9f Type field accesses 2018-12-25 15:16:42 +01:00
Florian Diebold
07a7285965 Collect field data for structs/enum variants 2018-12-25 15:16:42 +01:00
Florian Diebold
6fcd38cc81 Infer result of struct literals, and recurse into their child expressions 2018-12-25 15:16:42 +01:00