Commit graph

2770 commits

Author SHA1 Message Date
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
765f93b8d8 add is_union to structs AST 2019-05-21 01:15:56 +03:00
Aleksey Kladov
4ca8331933 remove minor code duplication 2019-05-21 01:02:29 +03:00
bors[bot]
9383ae720b Merge #1289
1289: simplify r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-20 20:02:18 +00:00
Aleksey Kladov
9680ae865e simplify 2019-05-20 23:01:49 +03:00
bors[bot]
11742e3371 Merge #1287
1287: Add support of matching literal in mbe r=matklad a=edwin0cheng

This PR adds support of matching literal in mbe , which used in our `T` macro :

```rust
macro_rules! foo {
    ('(') => {
        fn foo() {}
    }
}
```

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-20 19:27:05 +00:00
Aleksey Kladov
87316db0b1 output the progress for real 2019-05-20 21:20:52 +03:00
Edwin Cheng
ad9d2012de Fix match literal 2019-05-20 18:29:02 +08:00
bors[bot]
3894eb77d8 Merge #1286
1286: Add infer for generic default type r=flodiebold a=edwin0cheng

This PR add infer support for generic default type:

```
struct Gen<T=u32> {
    val: T
}
```

* add the (unresolved) defaults from the definition to GenericParams
* add a query generic_defaults that resolves those defaults to types and returns a Substs
* add the missing type in `substs_from_path_segment`
* add tests

based on the idea in this [comment](https://github.com/rust-analyzer/rust-analyzer/issues/1099#issuecomment-484206279)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-20 09:52:15 +00: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
fcffa6ba6b Assert that DB is unwind-safe, instead of proving
Unfortunately, that `: RefUnwindSafe` bound gives rustc a hard time,
so let's remove it for know.

See

* https://github.com/rust-analyzer/rust-analyzer/issues/1283
* https://github.com/rust-lang/rust/pull/60444
* https://github.com/rust-lang/rust/issues/58291

closes #1283
2019-05-18 13:05:42 +03:00
Unreal Hoang
99ad6143cd
rename 2019-05-16 12:53:52 +09:00
Aleksey Kladov
e29a58995b ⬆️ text_unit 2019-05-15 19:19:05 +03:00
Sergey Parilin
993abedd77 apply T! macro where it is possible 2019-05-15 15:35:47 +03:00
Sergey Parilin
d77175ce28 fixed macro for brackets 2019-05-15 12:34:48 +03:00
Aleksey Kladov
d4b1e958c5 show current function in analysis-stats progress bar 2019-05-14 09:58:41 +03: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]
ee0ab7c00b Merge #1272
1272: Error out non single root token tree conversion r=matklad a=edwin0cheng

This PR add a check to prevent non single root token tree conversion between token trees and syntax tree.

It should prevent the assert produced in #1267.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-14 05:41:23 +00:00
Edwin Cheng
10ecb11ff5 Error out non single root token tree conversion 2019-05-14 07:59:28 +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
bors[bot]
033a32f349 Merge #1257
1257: Implemented tkn! macro for syntax kinds r=matklad a=pasa

Implementation of #1248

Co-authored-by: Sergey Parilin <sergey.parilin@fxdd.com>
2019-05-13 13:49:14 +00:00
Sergey Parilin
57bb618fd3 Implemented T! macro for syntax kinds 2019-05-13 15:19:57 +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
bors[bot]
02ba107bbf Merge #1265
1265: drop obsolete render test subcommand r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-12 18:01:28 +00:00
Aleksey Kladov
8ee2926aa2 drop obsolete render test subcommand 2019-05-12 21:00:04 +03:00
Aleksey Kladov
915489714b allow to specify path in analysis-stats 2019-05-12 20:54:44 +03: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
Aleksey Kladov
1667b5cf52 switch to once_cell from lazy_static 2019-05-07 20:54:33 +03:00
bors[bot]
70cd5ffbf5 Merge #1251
1251: Chalk integration improvements r=matklad a=flodiebold

A few improvements that came up while working on where clause support:
 - turn `implements` into a query again to improve performance
 - allow skipping to a specific function with `analysis-stats`, e.g. `ra_cli analysis-stats --only world_symbols`
 - deduplicate impls in impls_for_trait -- previously many impls e.g. from std where repeated many times, this should help performance as well...
 - add a `HirDisplay` implementation for TraitRef (not used here anywhere, but useful for debugging)

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-05-07 17:37:47 +00:00
Aleksey Kladov
313314e14b share literal validation logic with compiler 2019-05-07 19:41:59 +03: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
880ef25a9e Allow targeting a specific function with analysis-stats
This can be useful for debugging.
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
12f8472d28 removed duplicating fill_struct_fields assist 2019-05-06 17:26:09 +03:00
Sergey Parilin
26ed925685 fill struct fields diagnostic 2019-05-06 17:16:11 +03:00
Jeremy Kolb
293cc81bf1 Remove collect 2019-05-05 13:28:22 -04:00
Marco Groppo
7e7ea0e79d Profile diagnostics. 2019-05-05 16:32:53 +02:00
Edwin Cheng
a48e33f139 Fixed missing empty vars 2019-05-05 10:32:57 +08: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
bors[bot]
9c49f6c36e Merge #1216
1216: Basic Chalk integration r=matklad a=flodiebold

This replaces the ad-hoc `implements` check by Chalk. It doesn't yet any new functionality (e.g. where clauses aren't passed to Chalk yet). The tests that exist actually work, but it needs some refactoring, currently crashes when running analysis on the RA repo, and depends on rust-lang/chalk#216 which isn't merged yet 😄 

The main work here is converting stuff back and forth and providing Chalk with the information it needs, and the canonicalization logic. Since canonicalization depends a lot on the inference table, I don't think we can currently reuse the logic from Chalk, so we need to implement it ourselves; it's not actually that complicated anyway ;) I realized that we need a `Ty::Bound` variant separate from `Ty::Param` -- these are two different things, and I think type parameters inside a function actually need to be represented in Chalk as `Placeholder` types.

~~Currently this crashes in the 'real' world because we don't yet do canonicalization when filtering method candidates. Proper canonicalization needs the inference table (to collapse different inference variables that have already been unified), but we need to be able to call the method candidate selection from the completion code... So I'm currently thinking how to best handle that 😄~~

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-05-04 18:07:09 +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
Edwin Cheng
1a3800df60 Fix $true and $false as $var name error 2019-05-05 00:49:50 +08: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
bors[bot]
e1ea2500fc Merge #1238
1238: Macro queries r=edwin0cheng a=matklad

In https://github.com/rust-analyzer/rust-analyzer/pull/1231, I've added aggressive clean up of `ast_id_to_node` query. 

The result of this query is a `SyntaxTree`, and we don't want to retain syntax trees in memory unless absolutely necessary.

Moreover, `SyntaxTree` has identity equality semantics, meaning that we'll get a diffferent syntax tree for a file after every reparse. That means that `ast_id_to_node` query should not genereally be used in HIR, unless it is behind some kind of salsa firewall, like the `raw` module of name resoulution.

However, that PR resulted in the abysmal performance: turns out we were using  ast_id_to_node quite heavily in hir when expanding macros! 

So this PR  installs the more incremental-friendly query structure:

* converting source to token tree is now a query; changing source without affecting token-trees will now preserve macro expansions
* expand macro (tt -> tt) is now a query as well, so we cache macro expansions *before* parsing them into item lists or expressions, which is nice: we can cache expansion without knowing the calling context!

r? @edwin0cheng 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-04 15:54:04 +00: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
Edwin Cheng
50f288db92 Add test 2019-05-04 22:32:48 +08:00
Edwin Cheng
0c4efbb2b6 Error out when parse_subtree is not a subtree 2019-05-04 21:57:20 +08: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
bors[bot]
b1febf2e6d Merge #1235
1235: revert eagarly clean astd maps r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-04 12:30:13 +00:00
Aleksey Kladov
ca5aedc9bf revert eagarly clean astd maps
This causes massive slowdown :-(
2019-05-04 15:29:35 +03:00
bors[bot]
dc666c8101 Merge #1230
1230: Desugar doc comments to `#[doc = "...."]` attributes in `syntax node` to tt conversion r=matklad a=edwin0cheng

As discussed in [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/MBE.20discussion/near/164446835), this PR desugar doc comments to  `#[doc = "...."]` in `syntax node` to tt conversion. 

Note that after this PR, all obvious mbe bugs in dogfooding are fixed. (i.e. No parsing or expanding mbe error in `env RUST_LOG=ra_hir=WARN target\release\ra_cli.exe analysis-stats`) 🎉

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-04 12:17:13 +00:00
Edwin Cheng
036141663b Quote the quoted comment 2019-05-04 19:34:02 +08:00
Edwin Cheng
048f12d9f0 Use explict escape_default instead of dbg print 2019-05-04 17:03:22 +08:00
Aleksey Kladov
6c63a59425 eagarly clean astd maps 2019-05-04 11:53:44 +03:00
Edwin Cheng
e7e896170a Convert doc comment to attr 2019-05-04 15:00:16 +08:00
Edwin Cheng
4ba4747578 Mark unused mbe variable as Binding::Empty 2019-05-04 01:14:25 +08:00
Edwin Cheng
31909cc7d7 By pass unbind $var while mbe expanding 2019-05-03 23:23:21 +08:00
Edwin Cheng
e8e46100d6 Refactor out tests module and remove empty subtree 2019-05-03 21:38:00 +08:00
bors[bot]
b29f442c8b Merge #1227
1227: Add `default_type` method in `TypeParam` Node r=matklad a=edwin0cheng

This PR add a `default_type` method in `TypeParam` Node which allow future PR to handle #1099 case.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-03 13:06:55 +00:00
Edwin Cheng
9e4fee8b41 Add default type param in TypeParam Node 2019-05-03 12:18:35 +08:00
Edwin Cheng
11d6a1449d Fixed old incorrect test 2019-05-03 00:20:27 +08:00
Edwin Cheng
ab91050d49 Fix typo 2019-05-03 00:01:48 +08:00
Edwin Cheng
91745c62f8 Compare text instead 2019-05-02 23:59:13 +08:00
Edwin Cheng
1446d620c5 Add empty bindings and some refactoring 2019-05-02 23:23:14 +08:00
Edwin Cheng
35c4633150 Make vis matcher optional and fix typo 2019-05-02 21:24:51 +08:00
Edwin Cheng
779676f782 Remove unused code in subtree_source 2019-05-02 10:19:12 +08:00
Edwin Cheng
a7ef9bac4e Formating 2019-05-02 10:08:11 +08:00
Edwin Cheng
6b2985ebc7 Remove unused code and add space bewteen tt 2019-05-02 10:02:17 +08:00
bors[bot]
12629d5e4f Merge #1222
1222: Skip Dollars when bump raw  token r=matklad a=edwin0cheng

This PR fixed a bug while parsing token_tree, it should skip all L_DOLLAR AND R_DOLLAR.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-01 17:45:56 +00:00
bors[bot]
817a38538f Merge #1223
1223: Move guard to arm body assist r=matklad a=unrealhoang

This is my attempt at #1206 

Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
2019-05-01 17:28:07 +00:00
Unreal Hoang
d1c21b85cf
add complex match case and documentation 2019-05-02 01:41:02 +09:00
Unreal Hoang
f83e452b1e
move guard to arm body assist. 2019-05-02 00:42:00 +09:00
Edwin Cheng
a42f26502d Skip Dollars when bump raw token 2019-05-01 22:39:47 +08:00
bors[bot]
71c13528cd Merge #1220
1220: Add macro pat parsing r=matklad a=edwin0cheng

This PR add support to parsing macro call in pattern , e.g :
```
let m!(x) = 0;
```

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-05-01 14:09:44 +00:00
Aleksey Kladov
594aac059e Use correct FileId when expanding macros in expressions 2019-05-01 15:53:13 +03:00
Edwin Cheng
b454eb5a60 Add macro pat parsing 2019-04-30 23:22:48 +08: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
bors[bot]
6618d1edc3 Merge #1213
1213: Make lexer produce only single character puncts r=matklad a=edwin0cheng

As discussed in Zulip, this PR change `lexer` to produce only single char punct.

* Remove producing `DOTDOTDOT, DOTDOTEQ, DOTDOT, COLONCOLON, EQEQ, FAT_ARROW, NEQ, THIN_ARROW` in lexer.
* Add required code in parser to make sure everythings works fine.
* Change some tests (Mainly because the `ast::token_tree` is different)

Note: i think the use of `COLON` in rust is too overloaded :)


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-28 16:51:02 +00:00
Edwin Cheng
d436ab0581 Refactor parser handle mult-char punct internally 2019-04-28 23:46:03 +08:00
Florian Diebold
85633656df Fix hover on the beginning of a nested expression
E.g. in
```
let foo = 1u32;
if true {
   <|>foo;
}
```
the hover shows `()`, the type of the whole if expression, instead of the more
sensible `u32`. The reason for this was that the search for an expression was
slightly left-biased: When on the edge between two tokens, it first looked at
all ancestors of the left token and then of the right token. Instead merge the
ancestors in ascending order, so that we get the smaller of the two possible
expressions.
2019-04-28 16:03:49 +02:00
kjeremy
d8649c1af8 Simplify 2019-04-26 11:42:56 -04:00
kjeremy
4251f083b5 Add is_empty to Arena 2019-04-26 11:42:10 -04:00
kjeremy
47f10fce8a Pass in char instead of single-char string 2019-04-26 11:41:58 -04:00
kjeremy
70dc33e00c Elide lifetime 2019-04-26 11:41:14 -04:00
Edwin Cheng
1908819bf6 Use panic instead of unwrap 2019-04-26 02:56:44 +08:00
Edwin Cheng
c55a2dbc1d Fix more bugs 2019-04-26 02:03:56 +08:00
Edwin Cheng
299d97b6d9 Add handling token seperator in mbe 2019-04-26 02:03:55 +08:00
Edwin Cheng
dfab545d5d Add more information on macro rules fail to parse 2019-04-26 02:03:55 +08:00
Edwin Cheng
e4e2338f97 Fix incorrect repeat sep eating 2019-04-26 02:03:55 +08:00
Aleksey Kladov
848cb16a01 drop empty file 2019-04-25 10:07:23 +03:00
kjeremy
558bdf73c8 simplify match 2019-04-24 14:45:02 -04:00
kjeremy
f69bf6a12b See through references 2019-04-24 12:09:29 -04:00
bors[bot]
6009af9b7c Merge #1200
1200: Allows searching for case-equivalent symbols (fixes #1151) r=matklad a=jrvidal

I couldn't find a nice, functional way of calculating the ranges in one pass so I resorted to a plain old `for` loop.

Co-authored-by: Roberto Vidal <vidal.roberto.j@gmail.com>
2019-04-23 21:25:37 +00:00
Roberto Vidal
dd8c3840cb CR corrections 2019-04-23 22:19:45 +02:00
kjeremy
a5bf0cdb97 Simplify 2019-04-23 15:44:37 -04:00
kjeremy
7125192c1e Basic resolution for ADT 2019-04-23 14:32:47 -04:00
Roberto Vidal
b56f010201 Allows searching for case-equivalent symbols (fixes #1151) 2019-04-23 20:11:45 +02:00
bors[bot]
a094d5c621 Merge #1147
1147: Handle macros in type checking / HIR r=matklad a=Lapz

An other attempt at  #1102. I will need to flatten the nested if statements and im also not sure if the way that i get the resolver and module will always work

Co-authored-by: Lenard Pratt <l3np27@gmail.com>
2019-04-23 12:49:31 +00: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
Edwin Cheng
6c913d8fa7 Add ... parsing for fn pointer type 2019-04-23 11:10:41 +08: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
Edwin Cheng
fccd045229 Add cached for SubtreeSource 2019-04-22 22:46:39 +08: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
c27a3da5e8 remove path_ident from CompletionContext
We really shouldn't be looking at the identifier at point. Instead,
all filtering and sorting should be implemented at the layer above.

This layer should probably be home for auto-import completions as
well, but, since that is not yet implemented, let's just stick this
into complete_scope.
2019-04-22 16:04:56 +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
bors[bot]
6162278075 Merge #1193
1193: Add a test for #1178 case r=edwin0cheng a=edwin0cheng

A little PR to add a test case for #1178

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-22 12:22:08 +00:00
Edwin Cheng
bb84fce1a4 Remove unused print out 2019-04-22 20:21:14 +08:00
Edwin Cheng
1cdfc38066 Add a test for #1178 case 2019-04-22 20:14:46 +08:00
bors[bot]
38c0a1e333 Merge #1184
1184: Start structured editing API r=matklad a=matklad

I think I finally understand how to provide nice, mutable structured editing API on top of red-green trees.

The problem I am trying to solve is that any modification to a particular `SyntaxNode` returns an independent new file. So, if you are editing a struct literal, and add a field, you get back a SourceFile, and you have to find the struct literal inside it yourself! This happens because our trees are immutable, but have parent pointers. 

The main idea here is to introduce `AstEditor<T>` type, which abstracts away that API. So, you create an `AstEditor` for node you want to edit and call various `&mut` taking methods on it. Internally, `AstEditor` stores both the original node and the current node. All edits are applied to the current node, which is replaced by the corresponding node in the new file. In the end, `AstEditor` computes a text edit between old and new nodes.

Note that this also should sole a problem when you create an anchor pointing to a subnode and mutate the parent node, invalidating anchor. Because mutation needs `&mut`, all anchors must be killed before modification. 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-22 10:08:18 +00:00
Aleksey Kladov
b73a978b95 drop useless test 2019-04-22 13:05:01 +03:00
Aleksey Kladov
268e739c94 move add_missing_members to structured editing API
Currently, this is more code, and we also loose auto-indenting of
bodies, but, long-term, this is the right approach
2019-04-22 13:01:33 +03:00
Edwin Cheng
ad1c3b5bd6 Use map, sum in Subtree::coount instead of fold 2019-04-22 17:37:27 +08:00
Edwin Cheng
d6d9aa2003 Change macro stack monitor test to func ptr based 2019-04-22 17:15:22 +08:00
Aleksey Kladov
b811922a53 fix postfix match indent 2019-04-22 10:38:39 +03:00
Edwin Cheng
b177813f3b Add mbe expand limit and poision macro set 2019-04-22 15:33:55 +08:00
Aleksey Kladov
5b2fd86d25 more type safety 2019-04-22 10:11:06 +03: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
cf0eff2e33 auto_import: better no anchor management 2019-04-22 00:13:00 +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
Andrea Pretto
0e0ae47b47 auto_import: use TextEditBuilder instead of AssistBuilder to make it more reusable 2019-04-22 00:13:00 +02:00
Aleksey Kladov
97f41d7343 test short structs 2019-04-22 00:52:21 +03:00
Edwin Cheng
120bfde3c2 Add tests 2019-04-22 05:04:37 +08:00
Edwin Cheng
3d1cdc834d Fix offset bug in SourceWalker 2019-04-22 05:04:37 +08:00
Edwin Cheng
49c9686c3c Handle *+ case and single token case 2019-04-22 05:04:37 +08:00
Edwin Cheng
bcf5cf8ac6 fix mbe_parser rhs colon parsing 2019-04-22 05:04:37 +08:00
Edwin Cheng
9a5b9638c1 Add more information on parse_macro fail 2019-04-22 05:04:37 +08:00
Edwin Cheng
da05bbcfb1 Fix lifetime in tt to syntax node conversion 2019-04-22 05:04:36 +08:00
Aleksey Kladov
f313ac45af use structured editing API for fill struct assist 2019-04-21 22:13:52 +03:00
Aleksey Kladov
7cc845e88d start structured editing API 2019-04-21 20:51:20 +03: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
Aleksey Kladov
47672726d8 ⬆️ lsp 2019-04-21 15:17:22 +03: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
Aleksey Kladov
fa12ed2b8f switch to official extend selection API 2019-04-21 12:13:48 +03:00
Florian Diebold
82751f8a4a Add a simple test for str method completion 2019-04-20 18:26:53 +02:00
bors[bot]
4ad2e4ce4e Merge #1154
1154: Initial support for lang items (and str completion) r=flodiebold a=marcogroppo

This PR adds partial support for lang items.
For now, the only supported lang items are the ones that target an impl block.

Lang items are now resolved during type inference - this means that `str` completion now works.

Fixes #1139.

(thanks Florian Diebold for the help!)


Co-authored-by: Marco Groppo <marco.groppo@gmail.com>
2019-04-20 16:13:50 +00: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
210c762fe6 Disable test_tt_xx 2019-04-20 02:41:13 +08:00
Edwin Cheng
41c1a639c3 Disable tt matcher 2019-04-20 02:19:46 +08:00
Edwin Cheng
1afde29adb Add back missing assert 2019-04-19 21:52:54 +08:00
Edwin Cheng
763569017a Fix bug for ident to lifetime 2019-04-19 21:43:41 +08:00
Edwin Cheng
87ff908135 Add vis matcher 2019-04-19 21:38:26 +08:00
Edwin Cheng
c5983b85fc Add literal matcher 2019-04-19 21:21:47 +08:00
Edwin Cheng
313854c728 Add lifetime matcher 2019-04-19 21:15:19 +08:00
Edwin Cheng
59b6cc780b add tt matcher 2019-04-19 19:41:59 +08:00
Edwin Cheng
762819864f add block matcher 2019-04-19 19:33:29 +08:00
Edwin Cheng
8092b6487f Add block matcher 2019-04-19 18:30:43 +08:00
bors[bot]
ab0a96586f Merge #1148
1148: Add token_tree_to_xxx functions r=matklad a=edwin0cheng

<del>As discus in  PR #1147 , this PR added a `mbe::MacroKind` .
Currently only 2 kind of macro are supported, `SourceFile` and `Block`.</del>

Added following functions for `tt::TokenTree` and `ast::Node` conversion:

* token_tree_to_expr
* token_tree_to_pat
* token_tree_to_ty
* token_tree_to_macro_stmts
* token_tree_to_macro_items

And added two new syntax kind:

* MACRO_ITEMS
* MACRO_STMTS

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-19 08:56:39 +00:00
Edwin Cheng
a6d51e0961 Return Result for token_tree_to_xx functions 2019-04-19 04:03:22 +08:00
Edwin Cheng
c0f19d7005 Add expr, pat, ty and macro_stmts 2019-04-19 03:49:56 +08:00
Edwin Cheng
3ff5440a50 Add MacroItems and MacroStmts in grammer.ron 2019-04-19 02:47:29 +08:00
Edwin Cheng
e8ddeb869d Fix missing last token in mbe $repeat parsing 2019-04-18 23:33:54 +08:00
Edwin Cheng
e944fd059d Add item matcher in mbe 2019-04-18 10:21:36 +08:00
bors[bot]
112fd0ec7d Merge #1160
1160: better formatting when adding trait members r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-17 11:11:31 +00:00
Aleksey Kladov
a27fc96aa1 better formatting when adding trait members
* it's conventional not to use one-liners
* new placement is more predictable, b/c it does not depend on
  header's length
2019-04-17 14:05:02 +03:00
bors[bot]
4c8e6e89aa Merge #1145
1145: Fix #1099, plug self type type parameters in infer_path_expr r=flodiebold a=edwin0cheng

As discussed in #1099, this PR try to "plug" a `self type` type parameters in `infer_path_expr`.
All the cases in 1099 was fixed and tested.
And luckily, this PR fixed bug #1030 again and make the test output correct.





Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-17 11:03:34 +00:00
Aleksey Kladov
f75feb6724 cleanup cancellation
Now that we explicitelly exit the reading loop on exit notification,
we can assume that the sender is always alive
2019-04-17 11:47:38 +03:00
bors[bot]
d3afb1b378 Merge #1153
1153: "Restart server" command r=jrvidal a=jrvidal

The only tricky aspect is that fact that once the `exit` command has been received, we no longer need to join on the reader thread. 

Also, I think `terminateProcesses.sh` was not working properly. In fact, the very same script from the vscode language server implementation is not working either! It's because of that I noticed the reader thread issue 😮 

Co-authored-by: Roberto Vidal <vidal.roberto.j@gmail.com>
2019-04-17 05:51:12 +00:00
Edwin Cheng
57e4122b89 Add mbe stmt matcher 2019-04-17 12:34:43 +08: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