bors[bot]
cd24349997
Merge #1691
...
1691: Show inherent and trait impls of structs and enums r=viorina a=viorina
Co-authored-by: Ekaterina Babshukova <ekaterina.babshukova@yandex.ru>
2019-08-16 14:24:51 +00:00
Ekaterina Babshukova
35a04ec066
show inherent and trait impls of structs and enums
2019-08-16 17:07:45 +03:00
Aleksey Kladov
343463c824
implement durability
2019-08-15 15:27:00 +03:00
Aleksey Kladov
9266c18ce6
switch from volatile to untracked read
2019-08-15 15:24:02 +03:00
Florian Diebold
5af9691dc9
Handle placeholder assoc types when Chalk produces them
2019-08-12 21:43:00 +02:00
Florian Diebold
9d72b14cfe
Normalize assoc types in more places
2019-08-12 21:43:00 +02:00
Florian Diebold
11b9845afd
Improve debug logging a bit
2019-08-12 21:43:00 +02:00
Florian Diebold
6265497523
Normalize associated types during inference
2019-08-12 21:43:00 +02:00
Florian Diebold
22724f37f3
Lower fully qualified associated type paths
...
I.e. `<T as Trait>::Foo`.
2019-08-12 21:43:00 +02:00
Florian Diebold
6cfdfdecba
Add representations of associated types
...
This adds three different representations, copied from the Chalk model:
- `Ty::Projection` is an associated type projection written somewhere in the
code, like `<Foo as Trait>::Bar`.
- `Ty::UnselectedProjection` is similar, but we don't know the trait
yet (`Foo::Bar`).
- The above representations are normalized to their actual types during type
inference. When that isn't possible, for example for `T::Item` inside an `fn
foo<T: Iterator>`, the type is normalized to an application type with
`TypeCtor::AssociatedType`.
2019-08-12 21:43:00 +02:00
Florian Diebold
3a9a0bc968
Add another test for assoc type resolution
2019-08-12 21:43:00 +02:00
Aleksey Kladov
6efc79b89d
implement while let desugaring
2019-08-07 15:14:22 +02:00
Evgenii P
858736c477
do fixup: remove unused import
2019-08-03 02:46:00 +07:00
Evgenii P
291bd81e74
Relax trait solving more for completion
2019-08-03 01:56:27 +07:00
Evgenii P
30bc3b93be
rustfmt
2019-08-03 01:16:20 +07:00
Evgenii P
c417b98f02
Implement completion for the .await syntax
2019-08-03 01:15:43 +07:00
Phil Ellison
d79dc38e99
Move assist test, add literal type inference test
2019-07-29 19:02:03 +01:00
bors[bot]
443061e752
Merge #1570
...
1570: switch to upstream rowan's API r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-21 13:48:46 +00:00
Ekaterina Babshukova
5fe19d2fbd
provide completion in struct patterns
2019-07-21 14:41:33 +03:00
Aleksey Kladov
d52ee59a71
streamline API
2019-07-21 13:28:58 +03:00
bors[bot]
dac6adbef9
Merge #1562
...
1562: Continue support for .await r=matklad a=unrealhoang
- add await expr to ast and HIR Expr
- infer type for `.await`
Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
2019-07-20 11:27:50 +00:00
Unreal Hoang
bacf926a77
infer type for await
...
by projecting inner_ty to Future::Output alias
2019-07-20 20:12:19 +09:00
Unreal Hoang
5ac9f5cdc7
add await expr to ast
2019-07-20 19:35:49 +09:00
Aleksey Kladov
f3bdbec1b6
rename range -> text_range
2019-07-20 12:58:27 +03:00
Aleksey Kladov
e2b28f5bb8
migrate ra_hir to the new rowan
2019-07-19 13:16:25 +03:00
Florian Diebold
c8284d8424
Switch to Chalk master, without fuel
2019-07-15 08:49:55 +02:00
Florian Diebold
dcb0c02e3a
Remove blacklist, instead mark Sized
as non-enumerable
...
This seems to be enough to prevent hanging in rust-analyzer, Chalk and the rustc
repo.
2019-07-15 08:49:55 +02:00
Florian Diebold
e2bce9e7eb
Cargo update, including updating Chalk
2019-07-14 18:22:47 +02:00
Florian Diebold
1e60ba8927
Have InferenceContext contain an InferenceResult instead of duplicating all fields
2019-07-14 18:22:47 +02:00
Florian Diebold
0a20770f46
Some renamings for clarity
2019-07-14 18:22:47 +02:00
Ekaterina Babshukova
2a1e11b36f
complete fields in enum variants
2019-07-12 20:31:49 +03:00
Aleksey Kladov
61135d4d4d
fix profile name
2019-07-09 11:13:15 +03:00
bors[bot]
f59cd1a4a0
Merge #1515
...
1515: Trait environment r=matklad a=flodiebold
This adds the environment, i.e. the set of `where` clauses in scope, when solving trait goals. That means that e.g. in
```rust
fn foo<T: SomeTrait>(t: T) {}
```
, we are able to complete methods of `SomeTrait` on the `t`. This affects the trait APIs quite a bit (since every method that needs to be able to solve for some trait needs to get this environment somehow), so I thought I'd do it rather sooner than later ;)
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-07-09 07:50:18 +00:00
bors[bot]
35f28c538a
Merge #1512
...
1512: Infer ? operator r=unrealhoang a=unrealhoang
Logical continuation of https://github.com/rust-analyzer/rust-analyzer/pull/1501
cc https://github.com/rust-analyzer/rust-analyzer/issues/1426
Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
2019-07-09 00:41:03 +00:00
Unreal Hoang
9a0d4b16b7
beautify tests
2019-07-09 09:27:03 +09:00
Florian Diebold
9afbf2dff4
Unify normalize
and implements
to simplify code
2019-07-08 21:47:37 +02:00
Florian Diebold
15862fc041
Use environment for associated type normalization as well
2019-07-08 21:20:17 +02:00
Florian Diebold
b1b12072ed
Start handling environment in trait resolution
...
I.e. if we are inside a function with some where clauses, we assume these where
clauses hold.
2019-07-08 21:20:17 +02:00
Florian Diebold
638100dc8b
Refactor a bit & introduce Environment struct
2019-07-08 21:20:17 +02:00
Marco Groppo
95d78a8d8d
Look for the fXX_runtime lang items during method resolution.
2019-07-08 20:37:29 +02:00
Unreal Hoang
741fc8fbfc
use namespaced consts for KnownName
2019-07-09 01:00:47 +09:00
Unreal Hoang
944f71afc6
projection over std::ops::Try::Ok to infer try/?
2019-07-09 00:19:09 +09:00
Muhammad Mominul Huque
09b72489dd
cargo format
2019-07-08 04:09:35 +06:00
Muhammad Mominul Huque
012fec54dc
Constify KnownName's
2019-07-08 03:29:38 +06:00
bors[bot]
1b38ca3b87
Merge #1501
...
1501: Infer for loop variable r=flodiebold a=unrealhoang
My take on https://github.com/rust-analyzer/rust-analyzer/issues/1425
Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
2019-07-07 15:20:09 +00:00
bors[bot]
6c31f5b0a7
Merge #1499
...
1499: processing attribute #[path] of module r=matklad a=andreevlex
support two cases
- simple name file `foo.rs`
- declaration in mod.rs
#1211
Co-authored-by: Alexander Andreev <andreevlex.as@gmail.com>
2019-07-07 13:48:58 +00:00
Unreal Hoang
f7cd40d830
add projection to infer for loop variable
2019-07-07 22:26:51 +09:00
Alexander Andreev
1c582be63b
Moved module resolution test in mods.rs
2019-07-07 16:06:54 +03:00
Florian Diebold
f854a29c9a
Make EnumVariant a GenericDef and simplify some code
2019-07-06 17:43:13 +02:00
Florian Diebold
065d398701
Add trait obligations for where clauses when calling functions/methods
...
E.g. if we call `foo<T: Into<u32>>(x)`, that adds an obligation that `x:
Into<u32>`, etc.
2019-07-06 17:34:05 +02:00
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