Aleksey Kladov
3e5f7299e1
move mod resolution to a separate file
2019-09-05 20:27:10 +03:00
uHOOCCOOHu
67d33cc21a
Hoist macros from extern crate with macro_use
2019-09-05 18:50:04 +08:00
uHOOCCOOHu
dec43a0c5d
Consider prelude to be macro_use
2019-09-05 18:50:04 +08:00
bors[bot]
6702f5b7b5
Merge #1743
...
1743: Support `#[macro_use]` on `extern crate` r=matklad a=uHOOCCOOHu
Unfortunately, #1688 is still an issue. My guess is wrong :(
Co-authored-by: uHOOCCOOHu <hooccooh1896@gmail.com>
2019-09-05 09:04:02 +00:00
uHOOCCOOHu
3ff5d7e73c
Fix typo
2019-09-05 12:03:32 +08:00
uHOOCCOOHu
0d23286caf
Let macro_use
bypass module scope
2019-09-05 11:46:00 +08:00
Florian Diebold
b8c1e402fa
Make type walking infrastructure a bit nicer
...
If/when we switch to using Chalk's Ty, we'll need to replace this by its `Fold`
trait, but I didn't want to import the whole thing just yet.
2019-09-03 14:00:35 +02:00
Florian Diebold
c4fcfa2b0d
Properly format impl Trait<Type = Foo>
types
...
It's a bit complicated because we basically have to 'undo' the desugaring, and
the result is very dependent on the specifics of the desugaring and will
probably produce weird results otherwise.
2019-09-03 14:00:35 +02:00
Florian Diebold
741e350d4b
Add support for associated type bindings (where Trait<Type = X>
)
2019-09-03 14:00:35 +02:00
Florian Diebold
966ab9abd2
Add test for assoc type bindings
2019-09-03 13:25:29 +02:00
Aleksey Kladov
9c3b25177e
Correctly build BodySourceMap for macro-expanded expressions
2019-09-03 11:04:38 +03:00
Aleksey Kladov
4b51c92fee
slightly simplify expr lowering flow
2019-09-03 09:41:21 +03:00
Aleksey Kladov
da850361ba
clearer ignore
2019-09-03 09:01:09 +03:00
Aleksey Kladov
82b218b7bf
remove needless refs
2019-09-03 08:59:44 +03:00
Aleksey Kladov
48ffbf29b7
use recrod terminology for hir::Pat
2019-09-03 08:59:09 +03:00
Aleksey Kladov
db69d134fb
move expr lowering to lower
2019-09-03 08:56:36 +03:00
Aleksey Kladov
5e3f291195
fix hir for new block syntax
2019-09-02 21:23:19 +03:00
Aleksey Kladov
f377b94628
remove useless trait
2019-09-02 19:45:41 +03:00
Florian Diebold
f92177cfb5
Add an expr_source method analogous to the source methods in the code model
...
... and use that instead of exposing the source map.
2019-09-02 14:56:38 +02:00
Florian Diebold
a7858bb7bf
Report type mismatches in analysis-stats
...
Only the number usually; each one individually when running with -v.
2019-09-02 14:56:38 +02:00
uHOOCCOOHu
a66214b34e
Fix import strategy of macro_use
and its test
2019-09-02 14:36:20 +08:00
Aleksey Kladov
4b6bccb58c
⬆️ once_cell
2019-09-01 23:18:15 +03:00
uHOOCCOOHu
dfa758f6a9
Add test
2019-09-01 02:03:33 +08:00
uHOOCCOOHu
f5bea9051b
Support resolution of #[macro_use] extern crate
2019-09-01 01:54:41 +08:00
Aleksey Kladov
0f6c048ce1
⬆️ insta
2019-08-29 17:04:01 +03:00
Kirill Bulatov
4adfdea1ad
Small fixes
2019-08-26 23:00:35 +03:00
Kirill Bulatov
590aed2eec
Remove redundant tests
2019-08-26 23:00:27 +03:00
Florian Diebold
c256a72b03
Fix 'missing Ok in tail expr' validation
...
Because of the coercion change, the type mismatch now only happens on the block
expression.
2019-08-26 22:44:50 +03:00
Florian Diebold
e37b6c5837
Make infer_block not unify; add back calculate_least_upper_bound
2019-08-26 22:44:50 +03:00
Kirill Bulatov
44386d5373
An attempt to add the coercion logic for Never
2019-08-26 22:44:50 +03:00
Kirill Bulatov
89f3cc587d
Properly coerce never types
2019-08-26 22:44:50 +03:00
Kirill Bulatov
8b612251fd
Remove extra inference test
2019-08-26 22:44:50 +03:00
Kirill Bulatov
44cf7b34fe
Fix never in if expressions
2019-08-26 22:44:50 +03:00
Kirill Bulatov
c1f47c3788
Add test marks
2019-08-26 22:44:50 +03:00
Kirill Bulatov
0ce05633a1
Fix match type inference for Never match arms
2019-08-26 22:44:50 +03:00
Kirill Bulatov
f63cfd5fca
Tests
2019-08-26 22:44:50 +03:00
bors[bot]
cd433ed194
Merge #1734
...
1734: Strip indents and empty lines in check_apply_diagnostic_fix_from_position r=matklad a=matklad
Co-authored-by: Phil Ellison <phil.j.ellison@gmail.com>
2019-08-25 09:58:54 +00:00
Phil Ellison
6620949cae
Simplify checking return type, add new test
2019-08-25 12:56:23 +03:00
Phil Ellison
6a04e9ce14
Fix build for Diagnostic type change
2019-08-25 12:56:23 +03:00
Phil Ellison
200470692f
Cast SyntaxNodePtr to AstPtr directly
2019-08-25 12:56:23 +03:00
Phil Ellison
c8911e872e
Remove reliance on expr ordering
2019-08-25 12:56:23 +03:00
Phil Ellison
4f6f3933ec
cargo format
2019-08-25 12:55:56 +03:00
Phil Ellison
a40e390860
Check type rather than just name in ok-wrapping diagnostic. Add test for handling generic functions (which currently fails)
2019-08-25 12:55:56 +03:00
Phil Ellison
d025016f92
Mock std String and Result types in tests for ok-wrapping diagnostic
2019-08-25 12:55:55 +03:00
Phil Ellison
bacb938ab0
Add type_mismatches to InferenceResult and use this in ok-wrapping code fix
2019-08-25 12:55:55 +03:00
Phil Ellison
d00a285fa7
Initial implementation of Ok-wrapping
2019-08-25 12:55:55 +03:00
Dylan MacKenzie
1e991f2eaf
Convert BoxPat
to Missing
in HIR
2019-08-23 16:07:11 -07:00
Aleksey Kladov
5b18a4eef9
rename struct -> record, pos -> tuple
2019-08-23 16:59:50 +03:00
Florian Diebold
4768f5e717
Improve/fix type bound lowering
2019-08-22 21:58:29 +02:00
Florian Diebold
b1a40042e8
Handle impl/dyn Trait in method resolution
...
When we have one of these, the `Trait` doesn't need to be in scope to call its
methods. So we need to consider this when looking for method
candidates. (Actually I think the same is true when we have a bound `T:
some::Trait`, but we don't handle that yet).
At the same time, since Chalk doesn't handle these types yet, add a small hack
to skip Chalk in method resolution and just consider `impl Trait: Trait` always
true. This is enough to e.g. get completions for `impl Trait`, but since we
don't do any unification we won't infer the return type of e.g. `impl
Into<i64>::into()`.
2019-08-22 21:55:11 +02:00
Florian Diebold
16a7d8cc85
Add impl Trait
and dyn Trait
types
...
- refactor bounds handling in the AST a bit
- add HIR for bounds
- add `Ty::Dyn` and `Ty::Opaque` variants and lower `dyn Trait` / `impl Trait`
syntax to them
2019-08-22 19:33:00 +02:00
Aleksey Kladov
9f238930f1
Don't add ?
bounds as real bounds
...
closes #1709
2019-08-22 15:35:42 +03:00
Aleksey Kladov
b50a04827c
remove ast::*Kind from hir
2019-08-19 14:04:51 +03:00
Aleksey Kladov
189d879659
implement initial type inference for index expressions
2019-08-17 18:05:20 +03:00
Aleksey Kladov
b082cd679a
normalize ordering ops
2019-08-17 17:51:01 +03:00
Aleksey Kladov
7e5a186c1f
Introduce separate hir::BinaryOp
...
Unlike ast::BinOp, it has significantly more structure to it, so it's
easier to, say, handle all assignment-like operations in the same way.
2019-08-17 17:42:41 +03:00
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
Evgenii P
475a93097f
Use Source in Diagnostic and implement
2019-08-12 23:06:08 +07:00
Aleksey Kladov
6efc79b89d
implement while let desugaring
2019-08-07 15:14:22 +02:00
Aleksey Kladov
39967a85e1
refactor if-let lowering
...
mainly to get rid of unwraps
2019-08-07 13:57:24 +02:00
Aleksey Kladov
4d6475ada0
refactor if lowering
2019-08-07 12:32:32 +02:00
bors[bot]
4912cc35af
Merge #1634
...
1634: Implement .await completion for futures r=flodiebold a=eupn
Closes #1263 with completion for `.await` syntax for types that are implementing `std::future::Future` trait.
r? @flodiebold
Co-authored-by: Evgenii P <eupn@protonmail.com>
2019-08-04 09:42:17 +00:00
bors[bot]
658382c1f5
Merge #1640
...
1640: Bump deps r=matklad a=lnicola
`insta`, `unicode-xid` and others
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2019-08-04 08:12:12 +00:00
Laurențiu Nicola
5153001889
Bump deps
2019-08-04 10:43:51 +03:00
Evgenii P
9f9c5aa659
rustfmt
2019-08-04 08:45:14 +07:00
Evgenii P
8597af8ed4
Idiomatic return
2019-08-04 08:08:46 +07:00
Evgenii P
d610adfc2b
Employ early return pattern more
2019-08-04 08:03:17 +07:00
Evgenii P
4034ea9e4e
source_binder.rs: fix order of imports
2019-08-04 07:56:29 +07:00
Alexander Andreev
83fe7b5fcb
Resolve out of line modules inside inline module with attribute path
...
Fixed #1510
Fixed #1529
2019-08-03 19:44:59 +03:00
Evgenii P
6a94f203fc
Use std::future::Future trait from stdlib
2019-08-03 17:07:20 +07: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
ab7774545c
Use future lang item instead of hardcoded std::future::Future
2019-08-03 01:53:51 +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
kjeremy
8d2068cf32
Update insta to 0.9.0 and cargo update
2019-07-31 10:05:00 -04:00
bors[bot]
a5fe9f7a87
Merge #1604
...
1604: Fix failing type interference for floating point literal r=matklad a=theotherphil
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/1592
Co-authored-by: Phil Ellison <phil.j.ellison@gmail.com>
2019-07-29 19:02:39 +00:00
Phil Ellison
d79dc38e99
Move assist test, add literal type inference test
2019-07-29 19:02:03 +01:00
Alexander Andreev
3629268f71
Fixed request changes.
2019-07-29 15:16:58 +03:00
Alexander Andreev
538ec1122b
Added resolve modules inside inline module
...
#1510
2019-07-29 09:54:40 +03:00
Ekaterina Babshukova
8e49bb664a
show local variable types in completion
2019-07-23 19:26:27 +03: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
6d5d82e412
move debug_dump to fmt::Debug
2019-07-20 12:48:24 +03:00
Aleksey Kladov
8467ba8cdb
flip syntax text to use internal iteration
2019-07-19 20:29:59 +03:00