Jeremy Kolb
001e34e6e3
Clippy trivially_copy_pass_by_ref
2019-07-05 12:02:32 -04:00
bors[bot]
ec6f71576a
Merge #1491
...
1491: More clippy r=matklad a=kjeremy
A few more clippy changes.
I'm a little unsure of the second commit. It's the trivially_copy_pass_by_ref lint and there are a number of places in the code we could use it if it makes sense.
Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2019-07-05 14:19:12 +00:00
Shotaro Yamada
d0e9cd2bc6
Fix clippy::redundant_clone
2019-07-05 12:45:58 +09:00
Jeremy Kolb
6b4ec73b7e
Clippy changes
2019-07-04 23:00:00 -04:00
Jeremy Kolb
4ad9e986ad
Some clippy fixes for 1.36
2019-07-04 17:43:00 -04:00
Aleksey Kladov
1834bae5b8
allow rustfmt to reorder imports
...
This wasn't a right decision in the first place, the feature flag was
broken in the last rustfmt release, and syntax highlighting of imports
is more important anyway
2019-07-04 23:09:09 +03:00
Aleksey Kladov
a198d78bd1
cache chalk queries
...
This gives a significant speedup, because chalk will call these
functions several times even withing a single revision. The only
significant one here is `impl_data`, but I figured it might be good to
cache others just for consistency.
The results I get are:
Before:
from scratch: 16.081457952s
no change: 15.846493ms
trivial change: 352.95592ms
comment change: 361.998408ms
const change: 457.629212ms
After:
from scratch: 14.910610278s
no change: 14.934647ms
trivial change: 85.633023ms
comment change: 96.433023ms
const change: 171.543296ms
Seems like a nice win!
2019-06-26 12:54:13 +03:00
Shotaro Yamada
9668737d05
Add comment
2019-06-25 20:57:42 +09:00
Shotaro Yamada
9e7a6bd66e
Method resolution for slices
2019-06-25 02:17:44 +09:00
Aleksey Kladov
0caec7d250
rename XSignature -> XData
2019-06-18 20:20:08 +03:00
Florian Diebold
ad3673d8d8
Add test for autoderef infinite recursion
2019-06-16 12:25:04 +02:00
Florian Diebold
96c2b9c41d
Simplifications / cleanup from review
2019-06-16 12:25:04 +02:00
Florian Diebold
30647cd195
Some more cleanup
2019-06-15 18:36:58 +02:00
Florian Diebold
94a6aff9f8
Check that Deref has the right number of parameters
2019-06-15 18:33:30 +02:00
Florian Diebold
3e78a6e3e0
Somewhat handle variables in the derefed type, and add another test
2019-06-15 18:21:23 +02:00
Florian Diebold
ca5ed2307c
Implement * operation using Deref trait
2019-06-15 18:21:23 +02:00
Florian Diebold
9c5e7dd849
Implement autoderef using the Deref trait
...
- add support for other lang item targets, since we need the Deref lang item
2019-06-15 18:21:23 +02:00
Florian Diebold
49489dc20c
Add basic infrastructure for assoc type projection
2019-06-15 18:21:23 +02:00
Florian Diebold
6f946f9656
Add test for Deref
2019-06-15 18:21:23 +02:00
Aleksey Kladov
b8cae2cf8f
check for cancellation when executing queries
...
Note that we can't just remove CheckCanceled trait altogether:
sometimes it's useful to check for cancellation while the query is
running! We do this, for example, in the name resolution fixed-point
loop.
2019-06-12 18:47:55 +03:00
Aleksey Kladov
c4512fadb1
remove inherent source impls
2019-06-11 18:28:51 +03:00
Aleksey Kladov
4f94af3c4a
use Source for Function
2019-06-11 18:28:51 +03:00
Aleksey Kladov
caefa6982b
remove some hacks from nameresolution for macros
2019-06-08 20:42:02 +03:00
Aleksey Kladov
780e1a365b
somewhat better name
2019-06-08 18:38:14 +03:00
Andrey Tkachenko
505b8d873f
[ #1083 ] Try block syntax: fix tests
2019-06-06 16:26:54 +04:00
Andrey Tkachenko
281c9eeaff
[ #1083 ] Try block syntax
2019-06-06 15:43:26 +04:00
Alan Du
b28ca32db2
Fix clippy::or_fun_call
2019-06-04 18:05:07 -04:00
Alan Du
40424d4222
Fix clippy::identity_conversion
2019-06-04 18:05:07 -04:00
Alan Du
fb592d76aa
Fix clippy::into_iter_on_ref
2019-06-04 18:05:07 -04:00
Alan Du
ecd420636e
Fix clippy::single_match
2019-06-04 18:05:07 -04:00
Aleksey Kladov
f89d34be6a
don't poison mutex around chalk
...
We use panics for cancellation, so we could trigger panic while
holding the solver. std::sync::Mutex will be poisoned as a result,
which and all further attempts to use solver (from other threads) will
panic as well.
This commit switches to parking_lot::Mutex which just unlocks on panic.
2019-06-01 10:57:44 +03:00
Aleksey Kladov
c6ee9d681c
add tests for primitive types
2019-05-30 15:14:11 +03:00
Aleksey Kladov
97158f5c8a
add built-in types to scopes
2019-05-30 15:03:58 +03:00
Aleksey Kladov
e6545cc647
add ModuleDef::BuiltInType
2019-05-30 14:06:28 +03:00
Aleksey Kladov
6bcc1b8b9e
add cacellation checks to expensive queries
2019-05-29 22:13:03 +03:00
Aleksey Kladov
c8bcfe6a05
fix syntax errors in tests
2019-05-28 18:07:39 +03:00
Aleksey Kladov
5d54aa6781
add union to code_model
2019-05-23 20:18:47 +03:00
Florian Diebold
ced971ee9f
Fix crash with int vars in canonicalization
2019-05-21 20:40:29 +02:00
Florian Diebold
f613c48d2e
Use fuel branch for Chalk
...
This makes sure we don't take too long in trait solving.
2019-05-21 20:40:29 +02:00
Aleksey Kladov
ed943adb29
re-enable chalk
2019-05-21 20:57:36 +03:00
Aleksey Kladov
26463f189f
publish gen_lsp_server 0.2
2019-05-21 18:57:33 +03:00
Aleksey Kladov
f63be06002
profile type inference
2019-05-21 16:26:13 +03:00
Aleksey Kladov
0f3e85002b
profile implements query
2019-05-21 16:04:17 +03:00
Aleksey Kladov
69341a0bbe
add _query to query functions
2019-05-21 12:44:08 +03:00
Aleksey Kladov
4ca8331933
remove minor code duplication
2019-05-21 01:02:29 +03:00
Edwin Cheng
3fc344b9f1
Use normal iteration instead of walk_mut
2019-05-20 17:48:58 +08:00
Edwin Cheng
d4dc879415
Add infer for generic default type
2019-05-19 21:08:16 +08:00
bors[bot]
bebc5c7166
Merge #1271
...
1271: make AstId untyped r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-13 21:04:04 +00:00
Florian Diebold
c29a692137
Increase Chalk solver max_size back to 4
...
Reducing it to 2 was just a failed attempt to see whether that would help fix
some slow cases; in fact, it can create new slow cases by replacing concrete
types by variables.
2019-05-13 22:20:39 +02:00
Aleksey Kladov
549728bba8
make AstId untyped
2019-05-13 19:39:06 +03:00
Florian Diebold
bc59f83991
Use traits from prelude for method resolution
2019-05-12 20:25:26 +02:00
Florian Diebold
7fda874dd4
Blacklist some traits from being considered in where clauses
...
For Send/Sync/Sized, we don't handle auto traits correctly yet and because they
have a lot of impls, they can easily lead to slowdowns. In the case of
Fn/FnMut/FnOnce, we don't parse the special Fn notation correctly yet and don't
handle closures yet, so we are very unlikely to find an impl.
2019-05-12 20:23:57 +02:00
Florian Diebold
c8b85891b0
Fix impl blocks with unresolved target trait being treated as inherent impls
2019-05-12 20:21:45 +02:00
Florian Diebold
cbe75676b9
Add support for inline bounds
...
E.g. impl<T: Clone> Foo for T.
2019-05-11 16:56:36 +02:00
Florian Diebold
d6dc75f9f2
Handle auto traits & negative impls
...
We don't pass field types to Chalk yet though, so the auto trait inference won't
be correct.
2019-05-11 16:21:20 +02:00
Florian Diebold
7744cd41e2
Reduce Chalk max_size parameter, add test for slow case
2019-05-11 16:21:20 +02:00
Florian Diebold
d8cd0e36f5
Handle Chalk conversion for FnDef
2019-05-11 16:21:20 +02:00
Florian Diebold
58b68966bf
Handle resolution errors in where clauses
...
This is slightly hacky, but maybe more elegant than alternative solutions: We
just use a hardcoded Chalk trait ID which we special-case to have no impls.
2019-05-11 16:21:20 +02:00
Florian Diebold
50bbf9eb09
Handle where clauses in trait solving
2019-05-11 16:21:20 +02:00
Florian Diebold
530b3047ed
Deduplicate impls in impls_for_trait
...
This was duplicating impls in dependencies a lot...
2019-05-07 13:45:29 +02:00
Florian Diebold
a78228a39c
Turn implements
into a query again
2019-05-07 13:45:29 +02:00
Sergey Parilin
26ed925685
fill struct fields diagnostic
2019-05-06 17:16:11 +03:00
Florian Diebold
a4eb1a546c
Differentiate Tuple / FnPtr type constructors by cardinality
...
This is necessary because Chalk (reasonably) expects each 'struct' to know how
many type parameters it takes.
2019-05-04 19:11:21 +02:00
Florian Diebold
f43e69a64e
Handle recursive types in canonicalization
2019-05-04 18:25:36 +02:00
Florian Diebold
5795d773db
Remove ToChalk implementation for ApplicationTy
2019-05-04 18:18:30 +02:00
Florian Diebold
621864319f
Make canonicalization API a bit nicer
2019-05-04 18:18:30 +02:00
Florian Diebold
0bcf47b22b
Update Chalk
2019-05-04 18:18:30 +02:00
Florian Diebold
0f34568924
Turn eprintln!s into debug!s
2019-05-04 18:18:30 +02:00
Florian Diebold
7310f3f801
Handle Ty::Unknown in Chalk conversion
...
Badly, but at least it doesn't crash.
2019-05-04 18:18:30 +02:00
Florian Diebold
0ad7317b24
Canonicalize before doing method resolution
2019-05-04 18:18:30 +02:00
Florian Diebold
ef77d83751
Document the peculiarity of the solver query a bit
...
Also remove the only remaining mention of chalk outside of the ty::traits
module.
2019-05-04 18:18:30 +02:00
Florian Diebold
c8a643f090
Move Chalk conversion code to its own module
2019-05-04 18:18:30 +02:00
Florian Diebold
99492278ac
Implement Deref<Target=[Ty]> for Substs
2019-05-04 18:18:30 +02:00
Florian Diebold
6c3ee834d6
Simplify solution_from_chalk
2019-05-04 18:18:30 +02:00
Florian Diebold
b9c0c2abb7
Chalk integration
...
- add proper canonicalization logic
- add conversions from/to Chalk IR
2019-05-04 18:18:30 +02:00
Lenard Pratt
1ab7066e32
Introduced resolve_macro_call on resolver
...
changed to manual expansion
fix for nested macros
2019-04-23 10:17:31 +01:00
Florian Diebold
787fb3e5ec
Add HIR for where clauses & ignore impls with where clauses in trait resolution
...
This prevents any `impl<T> Trait for T where ...` from being treated as a
blanket impl while we don't handle where clauses yet.
2019-04-21 15:01:17 +02:00
Florian Diebold
82751f8a4a
Add a simple test for str method completion
2019-04-20 18:26:53 +02:00
Marco Groppo
8ac3d1f9aa
lang_item_lookup is now a salsa query.
2019-04-20 00:29:16 +02:00
Marco Groppo
8ebb20edce
New krate() method in Resolver.
...
Renamed Impl to ImplBlock.
2019-04-20 00:20:26 +02:00
Marco Groppo
e85ee60c42
Initial support for lang items.
2019-04-20 00:10:19 +02:00
Edwin Cheng
8747c903a2
Refactoring
2019-04-17 09:35:03 +08:00
Edwin Cheng
039ab2e820
Simpliy code
2019-04-17 09:31:53 +08:00
Edwin Cheng
0edb5ce97a
Bug fix and add more comments
2019-04-17 09:31:52 +08:00
Edwin Cheng
180655077a
Fix 1099
2019-04-17 09:31:52 +08:00
Florian Diebold
4f8a49f43c
Refactor method candidate generation a bit
...
This fixes the order in which candidates are chosen a bit (not completely
though, as the ignored test demonstrates), and makes autoderef work with trait
methods. As a side effect, this also makes completion of trait methods work :)
2019-04-14 21:53:35 +02:00
Florian Diebold
8bcbcc454c
Extract generic_params method to a HasGenericParams trait
2019-04-14 13:07:45 +02:00
Florian Diebold
7650a44640
Make callable signature handling a bit nicer
2019-04-14 11:28:53 +02:00
Florian Diebold
9339241b78
Some cleanup
2019-04-14 11:28:53 +02:00
Florian Diebold
a1ed53a4f1
More trait infrastructure
...
- make it possible to get parent trait from method
- add 'obligation' machinery for checking that a type implements a
trait (and inferring facts about type variables from that)
- handle type parameters of traits (to a certain degree)
- improve the hacky implements check to cover enough cases to exercise the
handling of traits with type parameters
- basic canonicalization (will probably also be done by Chalk)
2019-04-14 11:28:53 +02:00
Florian Diebold
413c87f155
Get substs for trait refs in impl blocks
2019-04-14 11:28:53 +02:00
Robin Freyler
6aae0cf7fa
replace usages of algo::generate
with iter::successors
from std
2019-04-13 16:43:49 +02:00
Aleksey Kladov
a2cc76ce63
make resolver private
2019-04-13 11:03:02 +03:00
Aleksey Kladov
58fe5598e7
simplify
2019-04-13 01:32:43 +03:00
Aleksey Kladov
7c13e22334
simplify tests
2019-04-13 00:56:57 +03:00
Aleksey Kladov
10726fdb65
type-safer source-map for bindings
2019-04-10 10:48:15 +03:00
Laurențiu Nicola
61c09edb4a
Avoid two-phase borrow conflict
2019-04-08 16:47:28 +03:00
Lenard Pratt
b27fa33a9f
updated snapshots
2019-04-07 13:23:18 +01:00
Lenard Pratt
e175921932
Added ArrayExprKind,
...
changed the display for fixed array types,
Added Array Enum to ra_hir/expr
2019-04-07 13:23:14 +01:00
Lenard Pratt
2d73c909fe
Added inference of array length
2019-04-07 13:23:12 +01:00
robojumper
ca40ca93a5
Parse and infer tuple indices
2019-04-06 01:07:35 +02:00
bors[bot]
fdbebccd71
Merge #1076
...
1076: Const body inference r=flodiebold a=Lapz
This is the second part of #887 . I've added type inference on const bodies and introduced the DefWithBody containing Function, Const and Static. I want to add tests but im unsure on how I would go about testing that completions work.
Co-authored-by: Lenard Pratt <l3np27@gmail.com>
2019-04-02 19:01:54 +00:00
Lenard Pratt
88e22e9d70
Added const bodies and static body to the ast
...
and added inference the inference test
reduce code duplication
2019-04-02 19:21:36 +01:00
Aleksey Kladov
9e213385c9
switch to new rowan
2019-04-01 12:06:24 +03:00
Florian Diebold
99711c1863
Clean up comments / use nicer Iterator methods
2019-03-25 21:28:36 +01:00
Florian Diebold
0f7e4a7d24
Implement a very naive implements check
...
... to make the infer_trait_method_simple test have the correct result.
2019-03-25 21:28:36 +01:00
Florian Diebold
c947c15ce1
Basics for trait method resolution
2019-03-25 21:28:36 +01:00
Aleksey Kladov
4c4a714328
test diagnostics
2019-03-25 10:52:50 +03:00
Aleksey Kladov
79df62bc74
cleanup
2019-03-25 10:52:50 +03:00
Aleksey Kladov
3fb88e95aa
switch modules to new diagnostics
2019-03-25 10:52:50 +03:00
Aleksey Kladov
fcca35969d
allow dyn diagnostics
2019-03-25 10:52:12 +03:00
Aleksey Kladov
7e8f17188e
diagnostics
2019-03-25 10:52:12 +03:00
Florian Diebold
dbfc68cea0
Fix apply_substs assertion failure
...
Fixes #1030 .
2019-03-23 18:03:09 +01:00
Aleksey Kladov
4fd8cfd6ad
replace todo with fixme
2019-03-23 11:07:09 +03:00
yanchith
504c8c7c2e
Refactor primitive types into more orthogonal representation
2019-03-22 10:09:35 +01:00
Florian Diebold
1ee779d1f7
Assert in apply_substs that the number of parameters doesn't change
...
... and fix a small bug revealed by that.
2019-03-21 22:39:31 +01:00
Florian Diebold
cbb418ebb8
Rename name field to ctor as well
2019-03-21 22:29:12 +01:00
Florian Diebold
f10f5a81b3
TypeName => TypeCtor
2019-03-21 22:20:03 +01:00
Florian Diebold
8a5fbf4713
Remove the old variants replaced by Ty::Apply
2019-03-21 22:17:00 +01:00
Florian Diebold
bc7752e527
Represent FnPtr and Tuple using Substs
2019-03-21 22:11:53 +01:00
Aleksey Kladov
f5165af9a7
make Name::new private
2019-03-20 22:33:26 +03:00
bors[bot]
40c6dd1f4c
Merge #982
...
982: Implement BindingMode for pattern matching. r=flodiebold a=mjkillough
Implement `BindingMode` for pattern matching, so that types can be
correctly inferred using match ergonomics. The binding mode defaults to
`Move` (referred to as 'BindingMode::BindByValue` in rustc), and is
updated by automatic dereferencing of the value being matched.
Fixes #888 .
- [Binding modes in The Reference](https://doc.rust-lang.org/reference/patterns.html#binding-modes )
- [`rustc` implementation](e17c48e2f2/src/librustc_typeck/check/_match.rs (L77)
) (and [definition of `BindingMode`](e957ed9d10/src/librustc/ty/binding.rs
))
- [Match Ergonomics RFC](https://github.com/rust-lang/rfcs/blob/master/text/2005-match-ergonomics.md#binding-mode-rules )
Co-authored-by: Michael Killough <michaeljkillough@gmail.com>
2019-03-17 21:41:37 +00:00
Michael Killough
6299ccd350
Split test case and use tested_by!.
2019-03-17 19:08:51 +00:00
Michael Killough
33add0ee30
Simplify match statement.
2019-03-17 18:50:22 +00:00
Michael Killough
354134ffb4
impl Default for BindingMode.
...
This decouples callers from knowing what the default binding mode of
pattern matching is.
2019-03-17 18:46:01 +00:00
Aleksey Kladov
ee3cf6172b
rename ModuleId -> CrateModuleId
2019-03-17 12:53:22 +03:00
Aleksey Kladov
967a4b64af
Reorganize name resolution
2019-03-17 12:53:22 +03:00
Aleksey Kladov
2195d1db6d
Replace module_tree with CrateDefMap
2019-03-17 12:49:07 +03:00
Michael Killough
b42c5ced68
Implement BindingMode for pattern matching.
...
Implement `BindingMode` for pattern matching, so that types can be
correctly inferred using match ergonomics. The binding mode defaults to
`Move` (referred to as 'BindingMode::BindByValue` in rustc), and is
updated by automatic dereferencing of the value being matched.
2019-03-16 18:13:13 +00:00
Florian Diebold
7faae12311
Remove FnSig from FnDef type
...
It doesn't need to be in there since it's just information from the def. Another
step towards aligning Ty with Chalk's representation.
2019-03-16 17:29:55 +01:00
Florian Diebold
a9ddaba905
Refactor FnSig a bit
2019-03-16 17:21:32 +01:00
Florian Diebold
628b530e92
Some more Ty displaying cleanup
2019-03-16 16:50:31 +01:00
Florian Diebold
c5ee60e05b
Replace Display by a pretty printing trait for Ty
...
This allows removing the names from Adt and FnDef (and more later), as a first
step towards aligning more with chalk's Ty :)
2019-03-16 16:36:59 +01:00
kjeremy
ac678473b8
Use impl_froms!
2019-03-04 09:52:48 -05:00
kjeremy
1578375b89
Make ExpOrPatId private
2019-03-04 09:49:18 -05:00
Jeremy Kolb
ad2da5b1da
Remove commented out code
2019-03-04 08:27:08 -05:00
Jeremy Kolb
3d8d880c59
Use ImplItems instead of just Function
2019-03-04 08:27:08 -05:00
kjeremy
49da9a3e81
Make goto definition/hover resolve constructors
2019-03-04 08:27:08 -05:00
Florian Diebold
2e8f258845
Inline type inference test snapshots
2019-03-03 12:41:42 +01:00
Florian Diebold
affaf7700a
Represent unknown types as {unknown} instead of [unknown]
...
Since the latter could actually be a real type...
2019-03-03 03:00:17 +01:00
Florian Diebold
b7fdad8448
Add a bunch of tests for type inference involving traits
...
None of them works correctly yet, of course.
2019-03-02 16:42:51 +01:00
Aleksey Kladov
eaf1df26e9
rename syntax-mapping -> source-map
2019-03-02 15:40:40 +03:00
Ville Penttinen
29f93a7906
Add static type inference
2019-02-25 10:55:23 +02:00
Ville Penttinen
18b0bd9bff
Add const type inference
2019-02-25 10:51:46 +02:00
Florian Diebold
bd8ed644e4
Rename Type => TypeAlias
2019-02-24 21:36:49 +01:00
Florian Diebold
c3c0979561
Add test for recursive type aliases
2019-02-24 20:54:04 +01:00
Florian Diebold
5d72b96988
Implement support for type aliases
2019-02-24 20:54:04 +01:00
Florian Diebold
82fe7b77a3
Refactor associated method resolution a bit and make it work with generics
2019-02-23 23:00:02 +01:00
Florian Diebold
dcfb4ee702
Split ty.rs into several modules
...
It was just getting too big. We now have:
- ty: the `Ty` enum and helpers
- ty::infer: actual type inference
- ty::lower: lowering from HIR to `Ty`
- ty::op: helpers for binary operations, currently
2019-02-23 15:36:38 +01:00
Florian Diebold
6a04d1f292
Fix resolution of associated method calls across crates
...
I think it'll be better to make the path resolution the number of unresolved
segments, not the first unresolved index; then this error could simply not have
happened. But I'll do that separately.
2019-02-23 12:37:29 +01:00
bors[bot]
3d8a0982a1
Merge #866
...
866: Implement basic support for Associated Methods r=flodiebold a=vipentti
This is my attempt at learning to understand how the type inference works by adding basic support for associated methods. Currently it does not resolve associated types or constants.
The basic idea is that `Resolver::resolve_path` returns a new `PathResult` type, which has two variants, `FullyResolved` and `PartiallyResolved`, fully resolved matches the previous behavior, where as `PartiallyResolved` contains the `PerNs<Resolution` in addition to a `segment_index` which contains the index of the segment which we failed to resolve. This index can then be used to continue inference in `infer_path_expr` using the `Type` we managed to resolve.
This changes some of the previous apis, so looking for feedback and suggestions.
This should enable fixing #832
Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-22 19:58:22 +00:00
Ville Penttinen
39679d499f
Ignore failing test for now
2019-02-22 00:27:22 +02:00
Ville Penttinen
2e7bc905be
Remove Const inference for now, refactor PathResult
2019-02-21 23:57:07 +02:00
Ville Penttinen
816971ebc9
Implement basic support for Associated Methods and Constants
...
This is done in `infer_path_expr`. When `Resolver::resolve_path` returns
`PartiallyResolved`, we use the returned `Resolution` together with the given
`segment_index` to check if we can find something matching the segment at
segment_index in the impls for that particular type.
2019-02-21 12:25:55 +02:00
Florian Diebold
72712b8a42
Fix handling of generics in tuple variants and refactor a bit
...
Also make them display a tiny bit nicer.
Fixes #860 .
2019-02-20 22:48:55 +01:00
bors[bot]
564ab84b78
Merge #852
...
852: Handle != r=flodiebold a=matklad
r? @flodiebold
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-18 09:13:51 +00:00
Aleksey Kladov
4e8a3f565b
handle != operator
2019-02-18 10:09:44 +03:00
Florian Diebold
b82db68400
Handle tuple structs / enum variants properly in type inference
2019-02-17 20:53:13 +01:00
Florian Diebold
795d718ba1
Unify with the autorefed/autoderefed receiver type during method resolution
2019-02-17 14:44:39 +01:00
Florian Diebold
a1bda3fc08
Handle generic args for method calls
2019-02-16 23:06:41 +01:00
Florian Diebold
65bd9bc3a8
Handle impl generics in method calls
2019-02-16 23:06:41 +01:00
Florian Diebold
ccfc6b11c1
Add a test for impl generics
2019-02-16 23:06:41 +01:00
Florian Diebold
0242acae53
Turn ImplBlock into a copy type just containing IDs
...
This makes it more like the other code model types.
Also make Module::definition_source/declaration_source return HirFileIds, to
make them more like the other source functions.
2019-02-16 22:08:13 +01:00
Florian Diebold
e5f9d54661
Fix another crash
2019-02-12 21:49:54 +01:00
Laurențiu Nicola
7e8527f748
Implement completion for associated items
2019-02-12 12:51:01 +02:00
Aleksey Kladov
60524771fd
replace clone with copy
2019-02-12 13:32:34 +03:00
Aleksey Kladov
fa2e6e0bda
fix obsolete comment
2019-02-12 13:29:27 +03:00
Florian Diebold
c098a3fda5
Add comment and mark
2019-02-09 22:03:01 +01:00
Florian Diebold
a28d4befaf
Fix another crash, and try harder to prevent stack overflows
2019-02-09 21:53:55 +01:00
Florian Diebold
c0c3b37255
Fix another crash found when analyzing rustc
2019-02-09 21:37:30 +01:00
Florian Diebold
f1afc93353
Fix handling of literal patterns
...
Wrap them in a LiteralPat node so they can be distinguished from literal
expressions.
2019-02-09 21:37:30 +01:00
Florian Diebold
7ebde241c0
Fix two crashes found by running inference on all of rustc
2019-02-09 21:37:09 +01:00
Aleksey Kladov
12e3b4c70b
reformat the world
2019-02-08 14:49:43 +03:00
kjeremy
6753051a45
Some clippy cleanups
2019-02-06 15:50:26 -05:00
kjeremy
5227102c12
Test more Self inference
2019-02-04 14:44:06 -05:00
Florian Diebold
6b076f1931
Use new Resolver API in type inference
2019-02-01 22:45:23 +01:00
kjeremy
f0fdc9d5c0
Go To Implementation for Trait
2019-01-31 18:34:52 -05:00
bors[bot]
28fdb8d03c
Merge #701
...
701: Minor type inference tweaks r=flodiebold a=marcusklaas
Pass down expectation for reference expressions and type the guard in match expressions.
I wasn't able to add a test for the former addition because the type variable previously introduced would always resolve to the right type in the things I tried!
Co-authored-by: Marcus Klaas de Vries <mail@marcusklaas.nl>
2019-01-30 20:51:47 +00:00
Marcus Klaas de Vries
13cb4a1b37
Add test for passing on ref expectations
2019-01-30 21:14:26 +01:00
Aleksey Kladov
ef7eb8c257
Use Crate instead of CrateId
2019-01-30 22:37:20 +03:00
Jeremy Kolb
3c17643b30
Go to Implementation for structs and enums
2019-01-29 19:13:02 -05:00
Marcus Klaas de Vries
3daca3eb4d
Infer type of match guard
2019-01-28 23:09:14 +01:00
WizardOfMenlo
9416904d14
Added support for primitive types type inference when using std::ops::Not
2019-01-28 14:52:43 +00:00
Marcus Klaas de Vries
6249989e6c
Process second review
2019-01-27 17:59:21 +01:00
Marcus Klaas de Vries
f6eb44cd9e
Use type information from the turbofish
2019-01-27 17:59:21 +01:00
Marcus Klaas de Vries
0da1e8b2f8
Add a FnSig to Ty::FnDef
2019-01-27 17:59:21 +01:00
Marcus Klaas de Vries
04748a0f16
Add missing ty test snapshot
2019-01-27 17:59:21 +01:00
Marcus Klaas de Vries
aa06893a14
Add type params to FnSignature
2019-01-27 17:59:21 +01:00
Marcus Klaas de Vries
3bd47c0285
First attempt at generic type inference for fns
2019-01-27 17:59:21 +01:00
Florian Diebold
94bbb2418a
Add marks
2019-01-26 23:59:11 +01:00
Florian Diebold
77f92674f9
Handle cycles in type vars
...
This might be the cause of #587 .
2019-01-26 23:48:01 +01:00
Aleksey Kladov
619af1e22c
fix AST for if expressions
...
then is not always a block...
2019-01-27 00:37:11 +03:00
Aleksey Kladov
9457b1f0e6
rename source_file -> parse
2019-01-26 11:51:36 +03:00
Aleksey Kladov
4711cbcace
rename FilesDatabase -> SourceDatabase
2019-01-26 11:20:30 +03:00
Aleksey Kladov
be1a005ebd
fold syntax database into files database
2019-01-26 11:09:39 +03:00
Florian Diebold
5a1385007c
Fix type inference of binops on int/float variables
...
Fixes #651 .
2019-01-25 21:32:49 +01:00
Aleksey Kladov
60a607d33f
new struct id
2019-01-24 17:54:18 +03:00
Aleksey Kladov
ec7ed054e0
Functions use new id scheme
2019-01-24 15:28:50 +03:00
Aleksey Kladov
3ab1519cb2
Change ids strategy
...
this is a part of larghish hir refactoring which aims to
* replace per-source-root module trees with per crate trees
* switch from a monotyped DedId to type-specific ids
2019-01-24 13:29:19 +03:00
Aleksey Kladov
7b901f86cd
move SyntaxPtr to ra_syntax
2019-01-23 17:37:10 +03:00
Jeremy A. Kolb
7c27e6d2b3
Update snaps
2019-01-22 09:51:29 -05:00
Florian Diebold
a252110616
Use insta for ty tests
2019-01-21 22:52:35 +01:00
Florian Diebold
e45f476d56
Fix panic trying to get substs on unknown type
...
Fixes #585 .
2019-01-21 21:42:19 +01:00
Florian Diebold
3c4a4c6ae9
Fix panic on inferring field access on an enum
2019-01-20 18:14:19 +01:00
Florian Diebold
969f588025
Generics -> GenericParams
2019-01-19 18:58:04 +01:00
Florian Diebold
9e4b5ecec4
Make generics work in struct patterns
2019-01-19 16:02:06 +01:00
Florian Diebold
d37bb128ef
Collect generic args in struct variant paths as well
2019-01-19 16:02:06 +01:00
Florian Diebold
cc4562ab6e
Collect generic args in type paths
...
E.g. `let x: A<X>` is handled correctly.
2019-01-19 16:02:06 +01:00
Florian Diebold
688a45e00b
Implement beginnings of generics
...
- add HIR for generic params
- resolve generic params in type paths
- add substitions for ADTs
- insert type variables for substitutions
2019-01-19 16:02:06 +01:00
Florian Diebold
415cdc5210
Add some tests
2019-01-19 15:49:48 +01:00
Marcus Klaas de Vries
44e9a9605b
Fixup annotated bindings
2019-01-19 15:37:26 +03:00
Marcus Klaas de Vries
d48d5b8b6c
Add initial (flawed) implementation of binding annotations
2019-01-19 15:37:26 +03:00
Marcus Klaas de Vries
9433a108cf
Make pattern inference work w/o proper expecations
2019-01-19 15:37:25 +03:00
Marcus Klaas de Vries
be1b4034a5
Infer pattern types for lambdas and loops
2019-01-19 15:37:25 +03:00
Marcus Klaas de Vries
06d16a18f6
Implement match binding type inference and arm unification
2019-01-19 15:37:25 +03:00
Marcus Klaas de Vries
ac216880f5
Implement unlabeled struct field pattern inference
2019-01-19 15:37:25 +03:00
Marcus Klaas de Vries
3340807bd2
Get basic struct pattern type inference working!
2019-01-19 15:37:25 +03:00
Marcus Klaas de Vries
9c2d83a4c8
Add crude implementation of tuplestruct pattern inference
2019-01-19 15:37:25 +03:00
Marcus Klaas de Vries
3b0de53904
Work on type inference for ADT patterns
2019-01-19 15:37:25 +03:00
Marcus Klaas de Vries
5648dcd36e
Implement type inference for tuples and refs
2019-01-19 15:37:25 +03:00
Marcus Klaas de Vries
afaa26636e
Add additional pattern variants
2019-01-19 15:37:25 +03:00
Aleksey Kladov
a2ca03d10b
⬆️ salsa
2019-01-17 14:11:00 +03:00
Hirokazu Hata
0aedd4fb2f
Add Ty::Array to walk_mut
2019-01-17 00:08:53 +09:00
Hirokazu Hata
f66ca1bd2e
Fix test case invalid syntax
2019-01-16 23:39:14 +09:00
Hirokazu Hata
478ce1c8b5
Fix infer array test
2019-01-16 23:37:42 +09:00
Hirokazu Hata
2a3262c757
Add infer array test
2019-01-16 23:35:06 +09:00
Marcus Klaas de Vries
a2b6d3da30
Implement rudimentary type inference for unary operators
2019-01-16 00:04:39 +01:00
Aleksey Kladov
8ba9c2d4ce
remove Cancelable from type inference
2019-01-15 20:54:18 +03:00
Aleksey Kladov
b871062e32
remove Cancelable from Ty
2019-01-15 20:43:37 +03:00
Aleksey Kladov
fafcd103d2
remove Cancelable from ids
2019-01-15 19:18:52 +03:00
Aleksey Kladov
18e9a710cd
remove Cancelable from fn_scopes
2019-01-15 19:04:49 +03:00
Aleksey Kladov
8af9a18660
remove Cancelable from Crate API
2019-01-15 18:33:26 +03:00
Aleksey Kladov
c159e414b4
remove Cancelable from Module API, part 2
2019-01-15 18:30:58 +03:00
Aleksey Kladov
11f3c8afb2
remove Cancelable from source binders
2019-01-15 18:13:49 +03:00
Marcus Klaas de Vries
d67eabb512
Fix type inference for raw (byte) strings
2019-01-14 20:56:14 +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
Hirokazu Hata
139da0841d
Fix tuple test case
2019-01-13 22:23:06 +09:00
Hirokazu Hata
829f668bd7
Add infer tuple test
2019-01-13 21:04:03 +09:00
Florian Diebold
1ed7fbfc1b
args -> params
2019-01-12 21:58:16 +01:00
Florian Diebold
5db5f5cc1d
Small improvements from review comments
2019-01-12 21:51:56 +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
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
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
Florian Diebold
7bb279b365
Implement autoderef for field accesses
2019-01-07 14:54:23 +01:00
Florian Diebold
d618b1f2ce
if let -> match
2019-01-07 01:10:29 +01:00
Florian Diebold
71f7d82e45
Introduce ArenaMap
2019-01-07 00:05:19 +01:00
Florian Diebold
cf49a11263
Sort ranges in type inference tests
...
Also rename the files to remove the numbers (they don't serve a purpose now that
there are only the data files).
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
a6f33b4ca5
Add test for invalidation of inferred types when typing inside function
...
This currently fails, but should work once we have hir::Expr.
2019-01-05 22:41:12 +01:00
Marcus Klaas de Vries
4fc233a02e
Implement type inference for boolean operators
2019-01-05 21:28:30 +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
226e31dae9
Add test for self type inference
2019-01-04 18:28:43 +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
a9f55029b9
introduce known names
2018-12-27 20:26:15 +03: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
55c941cd9f
Type field accesses
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
Florian Diebold
4ff1618520
Do name resolution by namespace (types/values)
2018-12-25 15:16:42 +01:00
Florian Diebold
b5b68f2094
Add basic HIR and types for structs/enums
2018-12-25 15:16:42 +01:00
Florian Diebold
4befde1eee
Change inference tests to have one per file
2018-12-24 15:36:54 +01:00
Florian Diebold
655f5bc261
Rename a variable for consistency
2018-12-24 15:19:49 +01:00
Florian Diebold
c85748f5fb
Type the return values of call expressions
2018-12-23 17:29:03 +01:00
Florian Diebold
ef67581104
Resolve paths to defs (functions currently) during type inference
2018-12-23 17:13:11 +01:00
Florian Diebold
93ffbf80c6
Make let statements kind of work
2018-12-23 14:01:50 +01:00
Florian Diebold
515c3bc59b
Cleanup
2018-12-23 13:48:04 +01:00
Florian Diebold
7348f7883f
Add testing infrastructure for type inference
...
- move dir_tests to test_utils for that.
2018-12-23 13:48:04 +01:00
Florian Diebold
3899898d75
Parse integer / float types
2018-12-23 13:48:04 +01:00
Florian Diebold
3ac605e687
Add beginnings of type infrastructure
2018-12-23 13:48:04 +01:00