Commit Graph

3581 Commits

Author SHA1 Message Date
bors[bot]
ae6305b90c
Merge #1928
1928: Support `#[cfg(..)]` r=matklad a=oxalica

This PR implement `#[cfg(..)]` conditional compilation. It read default cfg options from `rustc --print cfg` with also hard-coded `test` and `debug_assertion` enabled.
Front-end settings are **not** included in this PR.

There is also a known issue that inner control attributes are totally ignored. I think it is **not** a part of `cfg` and create a separated issue for it. #1949

Fixes #1920 

Related: #1073 


Co-authored-by: uHOOCCOOHu <hooccooh1896@gmail.com>
Co-authored-by: oxalica <oxalicc@pm.me>
2019-10-05 14:25:59 +00:00
Ekaterina Babshukova
2fc2290173 replace AST visitors with macro 2019-10-05 17:03:03 +03:00
oxalica
c6303d9fee
Use raw cfgs in json project and fix typo 2019-10-05 20:55:27 +08:00
Geobert Quach
31663c1368 feat(assists): Address some PR comments 2019-10-04 18:32:14 +01:00
Lúcás Meier
e17243d698 [#1807] Refactor file structure
Use the more conventional way of importing the ast types, and
put the assist at the top of the file.
2019-10-04 10:51:41 +02:00
Lúcás Meier
1ed1e3d4a7 Fix formatting 2019-10-04 08:21:24 +02:00
Lúcás Meier
e769a54502 Create an assist for applying De Morgan's law
Fixes #1807

This assist can transform expressions of the form `!x || !y` into
`!(x && y)`. This also works with `&&`.

This assist will only trigger if the cursor is on the central logical
operator.

The main limitation of this current implementation is that both operands
need to be an explicit negation, either of the form `!x`, or `x != y`.
More operands could be accepted, but this would complicate the implementation
quite a bit.
2019-10-03 22:48:35 +02:00
Lúcás Meier
ad65ba4062 WIP: Add demorgan application with naive negation 2019-10-03 22:19:46 +02:00
Geoffry Song
9638adaa40 Fix parsing of block expressions in "forbid_structs" contexts.
Forbidding block expressions entirely is too strict; instead, we should only
forbid them in contexts where we are parsing an optional RHS (i.e. the RHS of a
range expression).
2019-10-03 00:39:52 -07:00
Geoffry Song
b63f260bbc Lower the precedence of the as operator.
Previously, the `as` operator was being parsed like a postfix expression, and
therefore being given the highest possible precedence. That caused it to bind
more tightly than prefix operators, which it should not. Instead, parse it
somewhat like a normal binary expression with some special-casing.
2019-10-03 00:27:09 -07:00
bors[bot]
e1c3675951
Merge #1945
1945: Handle divergence in type inference for blocks r=flodiebold a=lnicola

Fixes #1944.

The `infer_basics` test is failing, not sure what to do about it.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2019-10-02 18:57:20 +00:00
uHOOCCOOHu
b271cb18d5
Add docs 2019-10-03 02:50:22 +08:00
uHOOCCOOHu
1067a1c5f6
Read default cfgs from rustc 2019-10-03 02:28:03 +08:00
uHOOCCOOHu
e0100e63ae
Optimize 2019-10-03 02:28:03 +08:00
uHOOCCOOHu
43f09ad36c
Refactor CfgOptions inside 2019-10-03 02:28:02 +08:00
uHOOCCOOHu
a49ad47e5a
Support cfg attribute on impl blocks 2019-10-03 02:28:02 +08:00
uHOOCCOOHu
d2ea776b8f
Enable CfgOptions test for workspace crates 2019-10-03 02:28:02 +08:00
uHOOCCOOHu
b1ed887d81
Introduce ra_cfg to parse and evaluate CfgExpr 2019-10-03 02:28:02 +08:00
uHOOCCOOHu
ffe179a736
Pass attributes as token tree to DefCollector 2019-10-03 02:27:11 +08:00
kjeremy
b4e6939760 Update pico-args 2019-10-02 10:58:15 -04:00
Laurențiu Nicola
f491567fb3 Handle divergence in type inference for blocks 2019-10-02 17:31:34 +03:00
Geobert Quach
6195096fb4 feat(assists): Even smarter with hashes
Count `"#*` streak only, extract the counting in a function, unit test this function
2019-10-01 21:36:14 +01:00
Geobert Quach
b06c5fac14 feat(assists): Be smart about hashes
Add max_hashes_streak + 1 hashes to the raw string
2019-09-30 19:50:44 +01:00
Alexander Andreev
a47bca636c Change user message. 2019-09-30 13:31:28 +03:00
Alexander Andreev
506222a9b1 Drop debug strings. 2019-09-30 12:09:56 +03:00
Alexander Andreev
81efd696cc Merge branch 'master' into feature/issue/1856
# Conflicts:
#	crates/ra_assists/src/ast_editor.rs
2019-09-30 12:07:26 +03:00
Alexander Andreev
fdbd6bb11a Added test for check doc strings in crates.
#1856
2019-09-30 11:58:53 +03:00
uHOOCCOOHu
f7e12559cb
Fixes 2019-09-30 16:17:54 +08:00
uHOOCCOOHu
5a4b4f507e
Fix API of Attr 2019-09-30 16:17:53 +08:00
uHOOCCOOHu
71efdaa636
Parse correct AttrInput 2019-09-30 16:11:40 +08:00
Aleksey Kladov
4acadbdca6 cleanup editor 2019-09-30 10:08:28 +03:00
Aleksey Kladov
05ca252fb5 remove ast_editor.rs 2019-09-30 10:05:12 +03:00
Aleksey Kladov
054c53aeb9 move remove bounds to ast/edit.rs 2019-09-30 09:56:20 +03:00
Aleksey Kladov
e010b144d5 move field list to ast/edit.rs 2019-09-30 09:27:26 +03:00
Geobert Quach
e293c34e85 feat(assists): Keep only one version of make_raw_string 2019-09-29 19:16:59 +01:00
Aleksey Kladov
0840ec038b migrate add impl items to the new editing API 2019-09-28 20:10:53 +03:00
Aleksey Kladov
5dbbfda34a simplify strip attrs 2019-09-28 19:50:16 +03:00
Aleksey Kladov
e60677178e correctly reset chalk state after a panic 2019-09-28 18:49:00 +03:00
Aleksey Kladov
35f1655b0b replace horrible hack with a slightly less horrible one 2019-09-27 20:47:36 +03:00
bors[bot]
2b69c84396
Merge #1815
1815: Support correct `$crate` expansion in macros r=uHOOCCOOHu a=uHOOCCOOHu

This PR makes normal use cases of `$crate` from macros work as expected.

It makes more macros from `std` work. Type inference works well with `panic`, `unimplemented`, `format`, and maybe more.
Sadly that `vec![1, 2, 3]` still not works, but it is not longer an issue about macro.

Screenshot:
![Screenshot_20190927_022136](https://user-images.githubusercontent.com/14816024/65714465-b4568f80-e0cd-11e9-8043-dd44c2ae8040.png)




Co-authored-by: uHOOCCOOHu <hooccooh1896@gmail.com>
2019-09-27 02:58:26 +00:00
uHOOCCOOHu
edadeb95be
Fix 2019-09-27 10:55:25 +08:00
Florian Diebold
daaf46177e Add SubstsBuilder
+ further refactoring.
2019-09-26 23:03:39 +02:00
Geobert Quach
281e107155 feat(assists): Make raw string unescaped 2019-09-26 20:31:45 +01:00
Aleksey Kladov
d847d53e36 Start simplifying editing API 2019-09-26 22:22:08 +03:00
uHOOCCOOHu
2ecb126f5c
Support $crate in item and expr place. 2019-09-27 02:05:06 +08:00
uHOOCCOOHu
8cd23a4fb8
Store crate info in MacroDefId 2019-09-27 02:05:06 +08:00
uHOOCCOOHu
128dc5355b
Refactor Name ready for hygienic macro 2019-09-27 02:04:47 +08:00
Aleksey Kladov
1a4b424005 move diff to ra_syntax 2019-09-26 15:56:52 +03:00
Aleksey Kladov
183a38fb50 keep ast creation API simple 2019-09-26 15:29:28 +03:00
bors[bot]
d6bbdfefa7
Merge #1917
1917: disable periodic GC r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-09-26 09:33:18 +00:00
Aleksey Kladov
fabb32693f disable periodic GC
There's hypothesis that it doesn't do anything useful now that we have
LRU...
2019-09-26 12:31:16 +03:00
uHOOCCOOHu
29e56b8ee4
Support all coercion places 2019-09-26 06:16:58 +08:00
uHOOCCOOHu
5807e261c2
Support custom CoerceUnsized
Split out tests about coercion
2019-09-26 06:16:52 +08:00
uHOOCCOOHu
bf161fa3e5
Better handle never type and branch merging
Split out tests for never type to another file
2019-09-26 06:04:43 +08:00
uHOOCCOOHu
4bb66df6de
Support basic implicit type coerce 2019-09-26 06:04:39 +08:00
uHOOCCOOHu
5205c84ec7
Support auto-deref in argument position 2019-09-26 06:02:04 +08:00
bors[bot]
870ce4b1a5
Merge #1912
1912: add new editing API, suitable for modifying several nodes at once r=viorina a=matklad

r? @viorina 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-09-25 20:44:20 +00:00
Florian Diebold
c35ef5013c Resolve trait associated items
E.g. `Default::default` or `<Foo as Default>::default`.
2019-09-25 21:41:17 +02:00
Florian Diebold
d0d1a202d4 Fix retrieval of the Fn traits
I used the wrong query, so it only used the lang items from the respective
crate...
2019-09-25 20:04:37 +02:00
Aleksey Kladov
a525e830a6 add new editing API, suitable for modifying several nodes at once 2019-09-25 17:57:12 +03:00
bors[bot]
a452e50e0e
Merge #1911
1911: fewer monomorphisations r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-09-25 14:19:46 +00:00
Aleksey Kladov
b7422bd1ab fewer monomorphisations 2019-09-25 17:19:16 +03:00
Aleksey Kladov
efeae82f52 clean up naming 2019-09-25 15:58:40 +03:00
Aleksey Kladov
98639d835c cleanup diagnostics 2019-09-25 15:39:41 +03:00
Aleksey Kladov
32843ae6f7 shorten AstBuilder names 2019-09-25 15:28:26 +03:00
Aleksey Kladov
546f031e4e minor builder cleanups 2019-09-25 15:26:05 +03:00
Aleksey Kladov
25fca04753 cleaned up record field builder 2019-09-25 15:09:03 +03:00
Aleksey Kladov
69689625ce move ast builder to a separate file 2019-09-25 14:35:26 +03:00
Aleksey Kladov
f32081fa18 move assists to subdir 2019-09-25 14:29:41 +03:00
bors[bot]
63433ba79a
Merge #1906
1906: Add missing lang-items to `def_crates` r=matklad a=sinkuu



Co-authored-by: Shotaro Yamada <sinkuu@sinkuu.xyz>
2019-09-25 08:55:32 +00:00
Shotaro Yamada
89d0ff1623 Add missing lang-items to def_crates 2019-09-25 12:02:53 +09:00
Shotaro Yamada
9c45a9e586 Remove redundant clone() 2019-09-25 10:32:01 +09:00
Shotaro Yamada
7e0fa71532 Avoid intermediate allocation 2019-09-25 10:30:33 +09:00
Florian Diebold
6a86706650 Implement the call argument checking order hack for closures 2019-09-24 23:05:12 +02:00
Florian Diebold
a0aeb6e7ad Make the closure_1 test work 2019-09-24 23:05:12 +02:00
Florian Diebold
3b06faad26 Make closures impl closure traits 2019-09-24 23:05:12 +02:00
Florian Diebold
619a8185a6 Give closures types 2019-09-24 23:05:12 +02:00
Florian Diebold
7bb6fdcf52 Upgrade Chalk again 2019-09-24 22:29:52 +02:00
Aleksey Kladov
66101e931c simplify 2019-09-24 09:28:16 +03:00
bors[bot]
c12a713739
Merge #1898
1898: Drive by lints r=kjeremy a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2019-09-23 18:47:14 +00:00
Jeremy Kolb
13d7fc1620
Revert Self 2019-09-23 14:38:05 -04:00
Florian Diebold
6df9c4035a Upgrade Chalk 2019-09-23 20:36:15 +02:00
kjeremy
1808175f98 Drive by lints 2019-09-23 14:31:30 -04:00
Florian Diebold
4f1afe77b9 Split off path expression inference code into submodule 2019-09-23 18:53:52 +02:00
bors[bot]
c2d9cca4e4
Merge #1895
1895: Handle associated type shorthand (`T::Item`) (Second attempt) r=flodiebold a=flodiebold

This is only allowed for generic parameters (including `Self` in traits), and
special care needs to be taken to not run into cycles while resolving it,
because we use the where clauses of the generic parameter to find candidates for
the trait containing the associated type, but the where clauses may themselves
contain instances of short-hand associated types.

In some cases this is even fine, e.g. we might have `T: Trait<U::Item>, U:
Iterator`. If there is a cycle, we'll currently panic, which isn't great, but
better than overflowing the stack...

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-09-22 22:01:38 +00:00
Aleksey Kladov
43da23401d remove obsolete TOOD
I have no idea what I've meant to fix here :-(
2019-09-22 23:43:37 +03:00
Aleksey Kladov
9a0fef71cc test for TOODs as well 2019-09-22 23:43:23 +03:00
Aleksey Kladov
76290afa9a minor cleanup 2019-09-22 23:39:29 +03:00
Florian Diebold
bc905d202c Handle projection types from Chalk 2019-09-22 20:08:46 +02:00
Florian Diebold
18bf278c25 Handle associated type shorthand (T::Item)
This is only allowed for generic parameters (including `Self` in traits), and
special care needs to be taken to not run into cycles while resolving it,
because we use the where clauses of the generic parameter to find candidates for
the trait containing the associated type, but the where clauses may themselves
contain instances of short-hand associated types.

In some cases this is even fine, e.g. we might have `T: Trait<U::Item>, U:
Iterator`. If there is a cycle, we'll currently panic, which isn't great, but
better than overflowing the stack...
2019-09-22 20:02:32 +02:00
Jens Hausdorf
c70e30e409
Support open source version of vscode as well 2019-09-21 10:24:41 +02:00
kjeremy
fef7fcf5a9 Support loop as argument 2019-09-20 16:35:29 -04:00
bors[bot]
07bbe57fef
Merge #1888
1888: allow compiling ra_ide_api on wasm r=matklad a=matklad

bors r+

this is from #1746 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-09-20 18:21:18 +00:00
Aleksey Kladov
4d81432213 allow compiling ra_ide_api on wasm 2019-09-20 20:39:02 +03:00
kjeremy
2d99e6de27 Simplify match arm 2019-09-20 12:03:25 -04:00
bors[bot]
3575f7c4a2
Merge #1884
1884: Add indexing to record_field_pat r=matklad a=kjeremy

Fixes #1870 

Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-09-20 15:54:01 +00:00
kjeremy
17a45a686c Apply suggestion 2019-09-20 11:49:45 -04:00
bors[bot]
0492b18ed4
Merge #1883
1883: Fix path attribute causing false "unresolved module" error for submodules r=matklad a=gfreezy

fixed #1880

Co-authored-by: gfreezy <gfreezy@gmail.com>
2019-09-20 15:45:58 +00:00
kjeremy
5a65d4d9fb Add indexing to record_field_pat 2019-09-20 11:43:34 -04:00
gfreezy
6a4cf48bff fix module attr path 2019-09-20 23:20:43 +08:00