uHOOCCOOHu
8c078a0164
Infer box expression
2019-09-12 02:35:09 +08:00
bors[bot]
6ce6744e18
Merge #1796
...
1796: Support completion for macros r=matklad a=uHOOCCOOHu
This is based on #1795 , and fixes #1727
Also prettify hover text of macros.
Some screenshorts below:
Completion in item place.
<img width="416" alt="Screenshot_20190910_134056" src="https://user-images.githubusercontent.com/14816024/64587159-fa72da00-d3d0-11e9-86bb-c98f169ec08d.png ">
After pressing `tab`.
<img width="313" alt="Screenshot_20190910_134111" src="https://user-images.githubusercontent.com/14816024/64587160-fa72da00-d3d0-11e9-9464-21e3f6957bd7.png ">
Complete macros from `std`.
<img width="588" alt="Screenshot_20190910_134147" src="https://user-images.githubusercontent.com/14816024/64587161-fb0b7080-d3d0-11e9-866e-5161f0d1b546.png ">
Hover text.
<img width="521" alt="Screenshot_20190910_134242" src="https://user-images.githubusercontent.com/14816024/64587162-fb0b7080-d3d0-11e9-8f09-ad17e3f6702a.png ">
Co-authored-by: uHOOCCOOHu <hooccooh1896@gmail.com>
2019-09-11 14:49:57 +00:00
uHOOCCOOHu
c033d18700
Fix typo
2019-09-11 22:39:02 +08:00
Aleksey Kladov
9eb14e1170
cleanup expansion to item list
2019-09-10 22:22:57 +03:00
bors[bot]
c3d96f64ef
Merge #1795
...
1795: Make macro scope a real name scope and fix some details r=matklad a=uHOOCCOOHu
This PR make macro's module scope a real name scope in `PerNs`, instead of handling `Either<PerNs, MacroDef>` everywhere.
In `rustc`, the macro scope behave exactly the same as type and value scope.
It is valid that macros, types and values having exact the same name, and a `use` statement will import all of them. This happened to module `alloc::vec` and macro `alloc::vec!`.
So `Either` is not suitable here.
There is a trap that not only does `#[macro_use]` import all `#[macro_export] macro_rules`, but also imports all macros `use`d in the crate root.
In other words, it just _imports all macros in the module scope of crate root_. (Visibility of `use` doesn't matter.)
And it also happened to `libstd` which has `use alloc_crate::vec;` in crate root to re-export `alloc::vec`, which it both a module and a macro.
The current implementation of `#[macro_use] extern crate` doesn't work here, so that is why only macros directly from `libstd` like `dbg!` work, while `vec!` from `liballoc` doesn't.
This PR fixes this.
Another point is that, after some tests, I figure out that _`macro_rules` does NOT define macro in current module scope at all_.
It defines itself in legacy textual scope. And if `#[macro_export]` is given, it also is defined ONLY in module scope of crate root. (Then being `macro_use`d, as mentioned above)
(Well, the nightly [Declarative Macro 2.0](https://github.com/rust-lang/rust/issues/39412 ) simply always define in current module scope only, just like normal items do. But it is not yet supported by us)
After this PR, in my test, all non-builtin macros are resolved now. (Hover text for documentation is available) So it fixes #1688 . Since compiler builtin macros are marked as `#[rustc_doc_only_macro]` instead of `#[macro_export]`, we can simply tweak the condition to let it resolved, but it may cause expansion error.
Some critical notes are also given in doc-comments.
<img width="447" alt="Screenshot_20190909_223859" src="https://user-images.githubusercontent.com/14816024/64540366-ac1ef600-d352-11e9-804f-566ba7559206.png ">
Co-authored-by: uHOOCCOOHu <hooccooh1896@gmail.com>
2019-09-09 21:09:23 +00:00
Niko Matsakis
85fdf57dbd
modify tests
...
Some method resolution tests now yield `{unknown}` where they did not
before.
Other tests now succeed, likely because this is helping the solver
steer its efforts.
2019-09-09 16:05:31 -04:00
Niko Matsakis
3f9996d18a
also make "unknown" case non-enumerable
2019-09-09 15:30:26 -04:00
Niko Matsakis
65582933cf
make all traits non-enumerable
...
As discussed on Zulip, this actually matches the present behavior of
rustc.
2019-09-09 15:24:24 -04:00
uHOOCCOOHu
5f48ef3902
Strip
2019-09-10 01:21:29 +08:00
Aleksey Kladov
e5a8093dd4
document module
2019-09-09 17:31:11 +03:00
uHOOCCOOHu
40f9134159
Make macro scope a real name scope
...
Fix some details about module scoping
2019-09-09 20:54:02 +08:00
Aleksey Kladov
ef2b84ddf1
introduce hir debugging infra
...
This is to make debugging rust-analyzer easier.
The idea is that `dbg!(krate.debug(db))` will print the actual, fuzzy
crate name, instead of precise ID. Debug printing infra is a separate
thing, to make sure that the actual hir doesn't have access to global
information.
Do not use `.debug` for `log::` logging: debugging executes queries,
and might introduce unneded dependencies to the crate graph
2019-09-09 12:32:16 +03:00
uHOOCCOOHu
9ed21d65fb
Fix test
2019-09-09 01:34:53 +08:00
uHOOCCOOHu
92c07803cc
Rename textual_macro
-> legacy_macro
...
Add comments
2019-09-09 01:34:53 +08:00
uHOOCCOOHu
f7f7c2aff8
Revert "Replace with immutable map to avoid heavy cloning"
...
This reverts commit 2c494eb803c88ef5d23607c3b156fce60c2b8076.
See: https://github.com/rust-analyzer/rust-analyzer/pull/1784#issuecomment-529119924
2019-09-09 01:34:53 +08:00
uHOOCCOOHu
c90256429b
Replace with immutable map to avoid heavy cloning
2019-09-09 01:34:53 +08:00
uHOOCCOOHu
26b092bd3b
Resolve textual scoped macros inside item
2019-09-09 01:34:53 +08:00
uHOOCCOOHu
e0f305a6bf
Support textual scoped macros
2019-09-09 01:33:28 +08:00
Aleksey Kladov
6021a2a83a
cleanup hir db imports
2019-09-08 09:55:12 +03:00
Aleksey Kladov
bcc9a28734
don't cycle when processing macros from prelude in prelude
2019-09-07 21:47:59 +03:00
Florian Diebold
8fb3cab76c
Fix crash for super trait cycles
2019-09-07 16:49:57 +02:00
Florian Diebold
9db34eec20
Fix Chalk environments
...
The clauses need to be wrapped in `FromEnv` clauses for elaboration (i.e.
things like inferring `T: Clone` from `T: Copy`) to work correctly.
2019-09-07 16:30:37 +02:00
Florian Diebold
a1776b27c7
Use traits from where clauses for method resolution
...
E.g. if we have `T: some::Trait`, we can call methods from that trait without it
needing to be in scope.
2019-09-07 16:30:31 +02:00
Florian Diebold
d21cdf3c99
Lower Fn(X, Y) -> Z
paths
2019-09-07 15:13:05 +02:00
Florian Diebold
60bdb66ef2
Lower bounds on trait definition, and resolve assoc types from super traits
2019-09-07 14:31:43 +02:00
Florian Diebold
4ae4d9c311
Add some more tests
2019-09-07 13:35:41 +02:00
bors[bot]
007737a0e7
Merge #1779
...
1779: minor r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-09-06 11:33:37 +00:00
Aleksey Kladov
f477f2516a
minor
2019-09-06 14:30:24 +03:00
Aleksey Kladov
9ae455ea52
make source_root API more abstract
2019-09-06 14:21:11 +03:00
bors[bot]
419eec3d2f
Merge #1771
...
1771: Further tweak for macro_use on extern crate r=matklad a=uHOOCCOOHu
Some more tweaks to #1743 to behave more like `rustc`
1. Hoist macros from `#[macro_use] extern crate`, so that they can be used before `extern crate`.
2. Implicit `#[macro_use]` for `prelude` if exists
Co-authored-by: uHOOCCOOHu <hooccooh1896@gmail.com>
2019-09-05 19:50:06 +00:00
Aleksey Kladov
5a38a80d1a
rename test file to match impl file
2019-09-05 21:43:32 +03:00
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
Aleksey Kladov
a6df224f7d
minor
2019-07-19 18:25:07 +03:00
Aleksey Kladov
5c594bcb48
cleanup casts
2019-07-19 18:22:00 +03:00
Aleksey Kladov
f9d9e0a1f7
several highlighting cleanups
...
* make stuff more type-safe by using `BindPat` instead of just `Pat`
* don't add `mut` into binding hash
* reset shadow counter when we enter a function
2019-07-19 16:09:32 +03:00
Aleksey Kladov
e2b28f5bb8
migrate ra_hir to the new rowan
2019-07-19 13:16:25 +03:00
Aleksey Kladov
df33e7685b
use Parse in mbe
2019-07-18 23:19:04 +03:00
Ekaterina Babshukova
4abe03879b
highlight mutable variables differently
2019-07-18 18:52:50 +03:00
Aleksey Kladov
0fb4b896e2
use more correct phantom types for ptrs
2019-07-18 18:13:32 +03:00
kjeremy
1fcc002677
cargo update
2019-07-15 15:07:11 -04: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
Alexander Andreev
9c75f30272
Fixed request comments
2019-07-14 09:24:18 +03:00
Alexander Andreev
22b863c534
Fixed comments
2019-07-13 21:51:20 +03:00
Alexander Andreev
1f0e9c149f
More resolution modules with attribute path
...
#1211
2019-07-13 21:26:04 +03:00
Ekaterina Babshukova
2a1e11b36f
complete fields in enum variants
2019-07-12 20:31:49 +03:00
Aleksey Kladov
deab4caa7b
make Parse fields private
...
this is in preparation for the new rowan API
2019-07-12 19:41:13 +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
Shotaro Yamada
a426de60ad
Remove unused dependencies
2019-07-09 00:28:00 +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
Alexander Andreev
8579a9b834
Added support attribute path in resolusion module fn
2019-07-06 21:54:21 +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
Alexander Andreev
35a0f04128
Added extract path attribute for current module
...
#1211
2019-07-06 14:04:56 +03:00
bors[bot]
a9dcd2cdca
Merge #1495
...
1495: use correct file for diagnostics r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-05 16:43:23 +00:00
Aleksey Kladov
0b5e399190
use correct file for diagnostics
...
closes #1475
2019-07-05 19:40:02 +03:00
bors[bot]
3775e5e27d
Merge #1494
...
1494: properly restrict diagnostics to a single file r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-05 16:30:38 +00:00
Aleksey Kladov
fd30ec406b
properly restrict diagnostics to a single file
2019-07-05 19:27:20 +03: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
1a950cdbcf
&self -> self
...
https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref
2019-07-04 23:01:40 -04: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
bors[bot]
cacdb0eab8
Merge #1486
...
1486: allow rustfmt to reorder imports r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-04 20:09:32 +00: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
Alexander Andreev
6263aa13d0
Fixed request changes
2019-07-03 22:17:43 +03:00
Alexander Andreev
02e9e46ed6
Move resolve raw name in name.rs
...
Added test for check module resolution with raw name
2019-07-03 22:01:41 +03:00
Alexander Andreev
018bf3d7b1
Added resolve submodules with raw name
...
#1211
2019-07-03 17:37:56 +03:00
Shotaro Yamada
546442df68
Add completion for type aliases
2019-07-03 03:08:39 +09:00
Aleksey Kladov
e7164e6aeb
put source maps first for better stats
2019-06-30 16:35:40 +03:00
Aleksey Kladov
d70520eb38
print memory usage for queries
2019-06-30 14:49:45 +03:00
Florian Diebold
d37f960dfa
Complete associated methods on enums (and unions) as well
2019-06-29 12:40:01 +02:00
Aleksey Kladov
6e2369938a
make sure that CrateDefMap is independent from syntax
2019-06-26 21:50:42 +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
kjeremy
f8f136e990
Bump cargo_metadata, ena, flexi_logger
2019-06-20 15:09:39 -04:00
Aleksey Kladov
bcff61257a
Add firewall query to lang items
...
With an intermediate query, changing one module won't cause reparsing
of all modules
2019-06-19 23:46:50 +03: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
ff6f6b3a52
move docs under code model
2019-06-11 18:28:51 +03:00
Aleksey Kladov
f6c227babd
fix compilation
2019-06-11 18:28:51 +03:00
Aleksey Kladov
14b1f87634
minor formatting
2019-06-11 18:28:51 +03:00
Aleksey Kladov
26753f0e49
remove unneded From(..) impl
2019-06-11 18:28:51 +03:00
Aleksey Kladov
0dcaded439
move source to a seaparate file
2019-06-11 18:28:51 +03:00
Aleksey Kladov
c4512fadb1
remove inherent source impls
2019-06-11 18:28:51 +03:00
Aleksey Kladov
dd63f17027
use Source for module, part 2
2019-06-11 18:28:51 +03:00
Aleksey Kladov
0145d06515
use Source for module, part 1
2019-06-11 18:28:51 +03:00
Aleksey Kladov
178d8e96b5
use Source for StructField
2019-06-11 18:28:51 +03:00
Aleksey Kladov
8b94b429e5
use Source for MacroDef
2019-06-11 18:28:51 +03:00
Aleksey Kladov
a6e339e822
use Source for impl block
2019-06-11 18:28:51 +03:00
Aleksey Kladov
f411c2988d
use Source for Trait
2019-06-11 18:28:51 +03:00
Aleksey Kladov
f2ccc54468
use Source for TypeAlias
2019-06-11 18:28:51 +03:00
Aleksey Kladov
46bc8675ed
use Source for statics and consts
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
36865adcb9
Introduce HasSource trait
2019-06-11 18:28:51 +03:00
Aleksey Kladov
2a1fe26b6d
use Source more
2019-06-11 18:28:51 +03:00
Aleksey Kladov
91c120ccea
introduce Source struct
2019-06-11 18:28:51 +03:00
Aleksey Kladov
156b7ee842
use single version of either in hir
2019-06-11 01:26:20 +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
Aleksey Kladov
ac64967872
add a fixme
2019-06-08 14:55:25 +03:00
Aleksey Kladov
1b783e33e9
one macro def should be enough
2019-06-08 14:48:56 +03:00
Aleksey Kladov
2c28f5245d
make documenation a query
2019-06-08 14:36:39 +03:00
Aleksey Kladov
33026c654e
make Docs handing more ideomatic
2019-06-08 14:16:05 +03:00
Aleksey Kladov
5dc2789895
Move docs to dedicated module
2019-06-08 13:53: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
csmoe
44363cd5d2
fix: clean up warnings
...
Change-Id: I91a468f6e846ac28574825b8ee7aa02fbff68f63
2019-06-06 10:06:46 +08:00
Alan Du
02b6f871f1
Fix clippy::iter_cloned_collect
2019-06-04 18:05:07 -04:00
Alan Du
9b54b06ee3
Fix clippy::option_map_or_none
2019-06-04 18:05:07 -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
ed3d93b875
Fix clippy::single_char_pattern
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
619a615298
Fix clippy::len_zero
2019-06-04 18:05:07 -04:00
Alan Du
fafca4cb11
Fix clippy::ptr_arg
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
8b7f58976b
don't cache parses twice
...
Before this commit, `Parse`s for original file ended up two times in
salsa's db: first, when we parse original file, and second, when we
parse macro or a file.
Given that parse trees are the worst ofenders in terms of memory, it
makes sense to make sure we store them only once.
2019-06-02 20:15:10 +03:00
Aleksey Kladov
5af9e475f4
add AstDatabase
2019-06-02 12:27:36 +03:00
Aleksey Kladov
f7d3a87305
collect impl source maps
2019-06-01 22:31:22 +03:00
Aleksey Kladov
d7a2a9171e
don't cache ast_id_to_node
2019-06-01 22:14:42 +03:00
bors[bot]
ccec71165b
Merge #1360
...
1360: Improve goto definition for MBE r=matklad a=edwin0cheng
This PR improve the macro resolution for goto definition and expression macro invocation by using proper path resolution for external macros.
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-06-01 17:48:06 +00:00
Edwin Cheng
371961be0e
Improve goto definition for MBE
2019-06-01 19:34:19 +08: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
4e5b02966b
add list of builtin types
2019-05-30 14:26:27 +03:00
Aleksey Kladov
e6545cc647
add ModuleDef::BuiltInType
2019-05-30 14:06:28 +03:00
Aleksey Kladov
18ed351747
⬆️ parking_lot
2019-05-30 12:02:30 +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
a2845bb1f5
check cancellation when expanding macros
2019-05-27 14:41:14 +03:00
Edwin Cheng
6d68d60d32
Formatting
2019-05-27 15:37:22 +08:00
Edwin Cheng
d6e6a98c03
Add Test for new item resolution
2019-05-26 20:11:18 +08:00
Edwin Cheng
b72074a715
Use ItemOrMacro in item resolution
2019-05-26 20:10:56 +08:00
Edwin Cheng
c0dc14ba5a
Add Either dep
2019-05-26 20:10:05 +08:00
Edwin Cheng
d5fbce4458
Put back unexpaned_macros after resolve
2019-05-26 13:38:03 +08:00
Aleksey Kladov
ef3169a33a
rename code_model_api -> code_model
2019-05-23 21:14:19 +03:00
Aleksey Kladov
0e57d58dd0
kill code_model_impl
2019-05-23 21:13:22 +03:00
Aleksey Kladov
ce82fbfc44
remove more references
2019-05-23 21:08:10 +03:00
Aleksey Kladov
bde9cab66e
remove references
2019-05-23 21:01:31 +03:00
Aleksey Kladov
7f22f90503
kill krate_impl
2019-05-23 20:30:09 +03:00
Aleksey Kladov
dbd02546b9
fix signature
2019-05-23 20:25:55 +03:00
Aleksey Kladov
5d54aa6781
add union to code_model
2019-05-23 20:18:47 +03:00
Aleksey Kladov
f15bb3c98a
add profile calls to parsing/expansion routines
2019-05-22 11:31:07 +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
908c9589a8
fix odrer-of-iteration bug in tests
2019-05-21 14:51:52 +03:00
Aleksey Kladov
0efb5364c3
sort hash maps for tests
2019-05-21 14:14:31 +03:00
bors[bot]
c59a3cdb03
Merge #1296
...
1296: ⬆️ insta r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-21 10:28:55 +00:00
Aleksey Kladov
507c97a18c
⬆️ insta
2019-05-21 13:21:54 +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
Aleksey Kladov
9680ae865e
simplify
2019-05-20 23:01:49 +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
Edwin Cheng
e74d8f148b
Add default type to GenericParam
2019-05-19 17:44:29 +08:00
Aleksey Kladov
caa8663c08
allow expanding expressions
2019-05-14 09:03:43 +03:00
Aleksey Kladov
16c7405262
expand to syntax node
2019-05-14 09:03:43 +03:00
Aleksey Kladov
101b3abfd7
store macro kind in HirFileId
2019-05-14 09:03:43 +03: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
Aleksey Kladov
9cba67b2ad
simplify
2019-05-12 23:03:37 +03:00
Aleksey Kladov
98531dc785
simplify
2019-05-12 22:51:03 +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