Commit graph

1101 commits

Author SHA1 Message Date
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
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
4083caa233 Add a HirDisplay implementation for TraitRef 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
bors[bot]
aa7bdfd37f Merge #1208
1208: [WIP] Goto for Macro's r=matklad a=Lapz

Adds goto definition for macros. Currently only works for macros in the current crate ~~otherwise it panics~~. Proper macro resolution needs to be added for it to resolve macros in other crates.

Todo
- [X] Allow goto from macro calls
- [X] Fix panics
- [x] Add tests



![Screen Recording 2019-04-25 at 18 00 24](https://user-images.githubusercontent.com/19998186/56754499-1dd01c00-6785-11e9-9e9a-1e36de70cfa3.gif)



Co-authored-by: Lenard Pratt <l3np27@gmail.com>
2019-05-04 18:38:10 +00: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
19fbd91998 Simplify subst / subst_bound_vars a bit 2019-05-04 18:41:48 +02:00
Lenard Pratt
8198e13c26 Added local macro goto 2019-05-04 17:39:51 +01: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
Florian Diebold
6269791d36 Add Ty::Bound variant for use in Chalk integration 2019-05-04 18:18:30 +02:00
Aleksey Kladov
bcf45371ff make macro expansion into a proper query 2019-05-04 18:01:43 +03:00
Aleksey Kladov
87a1e276d5 minor, move 2019-05-04 17:42:24 +03:00
Aleksey Kladov
5dc384132f introduce macro_arg intermediate query
Currently, when expanding macros, we look at the source code
directly (we invoke ast_id_to_node query via to_node method).

This is less then ideal, because it make us re-expand macros after
every source change.

This commit establishes a salsa-firewall: a query to get macro call's
token tree. Unlike the syntax tree, token tree changes only if we
actually modify the macro itself.
2019-05-04 17:38:09 +03:00
Aleksey Kladov
8876f44054 Revert "eagarly clean astd maps"
This reverts commit 6c63a59425.

This causes massive slowdowns: looks like we accidentally have some source-depndent
2019-05-04 16:04:34 +03:00
Aleksey Kladov
6c63a59425 eagarly clean astd maps 2019-05-04 11:53:44 +03:00
Aleksey Kladov
594aac059e Use correct FileId when expanding macros in expressions 2019-05-01 15:53:13 +03:00
Felix S. Klock II
d694b0174a Sidestep two-phase borrow violation signaled by mutable_borrow_reservation_conflict.
See rust-lang/rust#59159 for further information/discussion.
2019-04-29 14:03:51 +02:00
Edwin Cheng
dfab545d5d Add more information on macro rules fail to parse 2019-04-26 02:03:55 +08:00
Aleksey Kladov
848cb16a01 drop empty file 2019-04-25 10:07:23 +03: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
Lenard Pratt
ce211434a6 Added macro resolution and expansion 2019-04-22 21:35:44 +01:00
Lenard Pratt
afaeb18910 Addeded resolver and db 2019-04-22 21:33:48 +01:00
bors[bot]
c416caeda2 Merge #1194
1194: Pr 1190 r=matklad a=matklad



Co-authored-by: Andrea Pretto <eulerdisk@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-22 13:19:47 +00:00
Aleksey Kladov
aa1ef6ae9a unused import 2019-04-22 16:18:14 +03:00
Aleksey Kladov
e01052d1f0 move auto-imoprter into IDE
auto-import is purely an IDE concern, so it should be done outside of
HIR
2019-04-22 15:56:28 +03:00
Edwin Cheng
d6d9aa2003 Change macro stack monitor test to func ptr based 2019-04-22 17:15:22 +08:00
Edwin Cheng
b177813f3b Add mbe expand limit and poision macro set 2019-04-22 15:33:55 +08:00
Andrea Pretto
200032852b complete_import: prevent panic when the anchor is the completion source range
(fix rebase mess)

 Please enter the commit message for your changes. Lines starting
2019-04-22 00:48:43 +02:00
Andrea Pretto
9144214958 complete_import: add new import resolver infrastructure with some hardcoded importable name.
Changes complete_scope to support that.
2019-04-22 00:14:58 +02:00
Andrea Pretto
766813898f auto_import: make auto import working with target as a list of SmolStr instead of ast::Path 2019-04-22 00:13:00 +02:00
Edwin Cheng
9a5b9638c1 Add more information on parse_macro fail 2019-04-22 05:04:37 +08: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
bors[bot]
fa15c4d75e Merge #1175
1175: Fix bugs and add error log about macro expansion r=matklad a=edwin0cheng

This PR fixed / add following things:

* Add a fused count which stop recursion of macro expansion in name resolution.
* Add some logs when macro expansion fails
* Add `$crate` meta variable support in mbe, which create a `$crate` ident token in token tree.
* Fixed matching a `$REPEAT` pattern inside a subtree, e.g. `(fn $name:ident {$($i:ident)*} ) => {...}`
* Remove composite-able punct token in syntax node to token conversion. 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-21 10:34:07 +00:00
Florian Diebold
82751f8a4a Add a simple test for str method completion 2019-04-20 18:26:53 +02:00
Edwin Cheng
9e35bf91b8 Fix bugs 2019-04-20 23:53:39 +08: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