Aleksey Kladov
5a6db3ca29
fix parsing of for loops inside expressions
...
closes #2051
2019-10-28 15:41:34 +03:00
Jeremy Kolb
44f2805fee
Fix syntax
2019-10-28 08:32:23 -04:00
Jeremy Kolb
49e89772f6
Preliminary enum variant support
2019-10-28 08:32:22 -04:00
Jeremy Kolb
55d4b06a53
Add disciminant
2019-10-28 08:32:22 -04:00
Jeremy Kolb
5a59bc9fcb
WIP: Expand signature help
...
This is hacky but works for tuple structs. Proof of concept.
2019-10-28 08:32:22 -04:00
bors[bot]
02828520a7
Merge #2097
...
2097: Be more precise with function signatures r=matklad a=kjeremy
Finds the closest call expr.
Fixes #2093
Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2019-10-28 11:53:16 +00:00
Jeremy Kolb
1438f38eb6
Preserve whitespace at the end of doc comments
...
Whitespace can have special meaning in markdown. For instance
ending a line with three spaces will render a new line.
Note that this behavior diverges from RLS.
Fixes #1997
2019-10-27 16:56:25 -04:00
bors[bot]
46b63c462d
Merge #2099
...
2099: Fix panic on raw string assist r=matklad a=aee11
Strings that do not contain two quotation marks would cause a slice indexing panic because `find_usual_string_range` would return a range that only contained a single quotation mark.
Panic example:
```
fn main() {
let s = "<|>
}
```
I noticed a lot of panics from the `make_raw_string` assist while working on another issue today.
Co-authored-by: Alexander Elís Ebenesersson <alex2789@gmail.com>
2019-10-27 19:20:01 +00:00
Alexander Elís Ebenesersson
17bd3e59f8
Fix panic on raw string assist
...
Strings that do not contain two quotation marks
would cause a slice indexing panic because code
was assuming `find_usual_string_range` would return
a string with two quotes, but it would incorrectly
also return text ranges containing only a single quote.
2019-10-28 03:00:28 +09:00
Jeremy Kolb
a0d55edc38
Be more precise with function signatures
...
Fixes #2093
2019-10-27 12:26:44 -04:00
Aleksey Kladov
ad3fe316c6
further simplify assists
2019-10-27 18:22:14 +03:00
Aleksey Kladov
b6fcacd96d
move all assists to use generated docs
2019-10-27 17:49:39 +03:00
Aleksey Kladov
cda6355de2
simplify AssistCtx API
...
We never actually use ability to create multiple actions out of a
single context
2019-10-27 17:35:37 +03:00
Aleksey Kladov
9e638c9f3e
simplify
2019-10-27 17:27:05 +03:00
bors[bot]
ad950830d0
Merge #2090
...
2090: move public stuff to top r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-10-27 14:13:09 +00:00
Aleksey Kladov
85c64ec7be
use new api for flip_trait_bound assist
2019-10-27 17:02:43 +03:00
Wesley Norris
fc2fc8528b
Add tests for the trait bound flip assist.
...
Co-authored-by: vlthr <vlthr@users.noreply.github.com>
2019-10-27 16:52:33 +03:00
Wesley Norris
3a64a85a52
Fixes #2054 .
...
This adds the `flip_trait_bound` assist which allows for the swapping of two trait bounds in a trait list that are next to each other.
2019-10-27 16:52:33 +03:00
Aleksey Kladov
be0f48f7cf
move public stuff to top
2019-10-27 16:48:20 +03:00
Aleksey Kladov
73532e900e
rename auto_import -> add_import
...
We are long way from auto imports at the moment
2019-10-27 16:46:49 +03:00
Alexander Elís Ebenesersson
3e7e3fdf16
extend selection in trait bound extends to plus
...
When multiple traits bounds are present, expanded selection
from a single trait bound will include the nearest plus sign
(and whitespace after) before including the whole trait bound.
2019-10-27 21:29:06 +09:00
Aleksey Kladov
8464c45086
remove relative_path_buf workaround
...
The upstream problem was fixed with the change to 1.0
2019-10-27 12:36:40 +03:00
Aleksey Kladov
da5528824a
document almost all assists
2019-10-27 12:23:22 +03:00
Aleksey Kladov
860bbd56ef
lightly document assist_ctx module
2019-10-27 12:04:06 +03:00
Aleksey Kladov
8118dc1bb9
use more consistent naming
...
I think this is the first time I use global rename for rust-analyzer
itself :-)
2019-10-27 11:53:09 +03:00
Aleksey Kladov
61349a3d18
extract assist helper for getting a specific token
2019-10-27 11:53:01 +03:00
Aleksey Kladov
3840324429
raw string assists work in macros
2019-10-27 11:49:13 +03:00
Aleksey Kladov
a490ba06fa
document some more assists
2019-10-27 11:26:46 +03:00
Aleksey Kladov
cf4720ffd5
use unicode bar for drawing the cursor
2019-10-26 21:22:40 +03:00
Aleksey Kladov
4a83aae098
support range selection in assist docs
2019-10-26 20:57:23 +03:00
Aleksey Kladov
431e4ff4ef
avoid TextEditorBuilder for simple edits
2019-10-26 20:09:56 +03:00
Aleksey Kladov
a5cbd8d5e8
check style for assist docs
2019-10-26 19:08:13 +03:00
Aleksey Kladov
4ef9b8d17a
use correct spacing for enum pattern
2019-10-26 18:03:55 +03:00
Aleksey Kladov
3126152a84
document a couple of assists
2019-10-26 17:37:55 +03:00
Aleksey Kladov
394e474479
add blank lines for readability
2019-10-26 17:27:47 +03:00
Florian Diebold
b342ee5616
Upgrade Chalk (without using its dyn/impl Trait support)
2019-10-26 15:11:39 +02:00
Aleksey Kladov
d385438bcc
generate more assists docs
2019-10-25 23:38:15 +03:00
bors[bot]
c48b467eff
Merge #2069
...
2069: auto-generate assists docs and tests r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-10-25 11:50:06 +00:00
Aleksey Kladov
0dd35ff2b2
auto-generate assists docs and tests
2019-10-25 14:47:48 +03:00
bors[bot]
5f779f6c46
Merge #2066
...
2066: insert space after `->` r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-10-25 11:24:43 +00:00
Laurențiu Nicola
27a0cb3025
Specify working chalk revisions in manifest
2019-10-25 13:33:14 +03:00
Aleksey Kladov
d5cd8b5be2
disable the new typing handler for ->
...
It doesn't actually work with LSP
2019-10-25 13:03:57 +03:00
Aleksey Kladov
53e3bee0cf
insert space after ->
2019-10-25 12:41:34 +03:00
Aleksey Kladov
ea948e9fbb
refactor typing_handlers
2019-10-25 12:04:17 +03:00
Aleksey Kladov
6f00bb1cb0
introduce SingleFileChange
2019-10-25 11:49:38 +03:00
Aleksey Kladov
b112430ca7
move source change to a dedicated file
2019-10-25 11:30:50 +03:00
Aleksey Kladov
8d2fd59cfb
make typing infra slightly more extensible
2019-10-25 11:30:46 +03:00
Aleksey Kladov
dc65219ae1
document feature flags
2019-10-25 09:00:30 +03:00
kjeremy
64c1dd10b8
bump insta
2019-10-24 10:35:22 -04:00
bors[bot]
95cf5c86fa
Merge #2059
...
2059: for highlighting, search only the current file r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-10-24 11:17:03 +00:00
Aleksey Kladov
4529da906d
for highlighting, search only the current file
2019-10-24 14:16:36 +03:00
Aleksey Kladov
6d186ec3be
add search scope stuct
2019-10-24 13:41:25 +03:00
Aleksey Kladov
5750ee69ff
add --with-deps option to analysis-stats
2019-10-24 12:32:19 +03:00
Aleksey Kladov
ac1b7b07e7
add some profiling calls
2019-10-24 10:37:20 +03:00
Aleksey Kladov
418fbc8662
don't die if a sync task panics
2019-10-24 09:56:30 +03:00
Aleksey Kladov
baa968e71c
show unaccounted for time in profiling
2019-10-24 09:14:33 +03:00
Aleksey Kladov
b5f13d8d51
xtask: move codegen to a module
2019-10-23 18:57:18 +03:00
bors[bot]
edf4d8e555
Merge #2049
...
2049: add couple of profiling calls r=matklad a=matklad
bors r+
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-10-23 15:44:40 +00:00
Aleksey Kladov
f5bf7f29b5
add couple of profiling calls
2019-10-23 18:26:43 +03:00
Aleksey Kladov
afc6ee251d
minor cleanup
2019-10-23 17:41:15 +03:00
Aleksey Kladov
68ea9bd1bf
restore assert
2019-10-23 11:31:16 +03:00
Ekaterina Babshukova
decfd28bd1
some fixes, add docs
2019-10-23 00:35:06 +03:00
Ekaterina Babshukova
b5a3ee93e2
support items that visible to the parent module
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
55e1910d00
classify module from declaration
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
93c179531b
fix highlighting
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
328be5721a
remove SearchScope
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
88ff88d318
use Lazy, some fixes
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
19fbf2c16b
remove unreachable!()
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
835173d065
replace trait by a bunch of functions
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
d26d0ada50
restructure a bit
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
0dd08b8023
classify definition of a function right
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
79e6b3b0d1
make handle_references
accept refs from other files
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
df8441b24e
some fixes, add tests
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
5b03773fbe
implement search of references
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
01853e8d6c
find scope for Declaration
item
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
121aa35f12
return Declaration from classify_name_ref
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
83f780eabf
return Declaration from classify_name
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
0b5d0a41fd
replace a chain of if let
by macro
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
d6ae1b5f0f
refactor name_ref_kind.rs
2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
11577288c2
initial classify_name
2019-10-22 23:47:31 +03:00
bors[bot]
c15ee97fff
Merge #2046
...
2046: Bump crates r=matklad a=kjeremy
Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-10-22 17:22:09 +00:00
bors[bot]
ba95de936d
Merge #1933
...
1933: Adds "replace with guarded return" assist r=matklad a=mikhail-m1
first draft for #1782 . I'm pretty sure I missed something.
Co-authored-by: Mikhail Modin <mikhailm1@gmail.com>
2019-10-22 17:10:17 +00:00
kjeremy
e9bab85b65
Bump crates
2019-10-22 13:01:26 -04:00
bors[bot]
8f4480d180
Merge #2044
...
2044: Fixup folding ranges for clients with lineFoldingOnly=true r=matklad a=ztlpn
Fixes #2033
Co-authored-by: Alex Zatelepin <mvzp10@gmail.com>
2019-10-22 07:57:37 +00:00
Alex Zatelepin
6d105ccd93
add test #2033
2019-10-21 22:34:44 +03:00
Alex Zatelepin
9d5e932626
fixup folding ranges for "lineFoldingOnly" clients #2033
2019-10-21 21:35:42 +03:00
oxalica
24d50ebcd1
Guess macro braces from docs
2019-10-21 02:16:01 +08:00
Mikhail Modin
fb215dc192
Adds "replace with guarded return" assist
2019-10-20 19:14:32 +01:00
Aleksey Kladov
5376c769f0
rename tools -> xtask
2019-10-17 23:14:05 +03:00
Aleksey Kladov
7b15c4f7ae
WIP: move to xtasks
2019-10-17 22:54:38 +03:00
kjeremy
c3045c68a9
relative-path 1.0
2019-10-17 13:08:33 -04:00
Laurențiu Nicola
a6b980d6d4
Bump deps
2019-10-17 18:08:11 +03:00
bors[bot]
762fce5bdd
Merge #2012
...
2012: #1435 postfix completion for integer literals r=matklad a=pasa
Fix for #1435 Incorrect postfix completion for integer literals
Co-authored-by: Sergey Parilin <parilinsa@gmail.com>
2019-10-17 11:21:00 +00:00
bors[bot]
84d9fd1864
Merge #1998
...
1998: No need to make config pub r=matklad a=kjeremy
Just a drive by
Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-10-17 11:10:25 +00:00
Aleksey Kladov
260ae2dbc9
minor cleanup
2019-10-16 13:26:02 +03:00
Sergey Parilin
bec47e221f
#1435 postfix completion for integer literals
2019-10-14 18:39:40 +03:00
bors[bot]
8e3864fd58
Merge #2008
...
2008: Prepare SourceDatabase API for lazy file loading r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-10-14 13:26:42 +00:00
Aleksey Kladov
abf2179c0b
Prepare SourceDatabase API for lazy file loading
2019-10-14 16:23:55 +03:00
bors[bot]
e182825170
Merge #2006
...
2006: Improvements around `Arc<[T]>` r=matklad a=sinkuu
First commit tries to avoid cloning `Arc<[T]>` to a temporary `Vec` for mutating it, if there are no other strong references. Second commit utilizes [`FromIterator for Arc<[T]>`](https://doc.rust-lang.org/std/sync/struct.Arc.html#impl-FromIterator%3CT%3E ) instead of `.collect::<Vec<_>>().into()` to avoid allocation in `From<Vec<T>> for Arc<[T]>`.
Co-authored-by: Shotaro Yamada <sinkuu@sinkuu.xyz>
2019-10-14 13:14:18 +00:00
bors[bot]
1f4fbc0035
Merge #2007
...
2007: remove one more dependency on source roots r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-10-14 12:22:54 +00:00
Aleksey Kladov
1555a1aa0d
remove one more dependency on source roots
2019-10-14 15:15:47 +03:00
bors[bot]
bc7de5d47a
Merge #2002
...
2002: Remove unused dependencies r=matklad a=sinkuu
Co-authored-by: Shotaro Yamada <sinkuu@sinkuu.xyz>
2019-10-14 11:10:20 +00:00
Shotaro Yamada
e4ffa79b3e
Enable serde
feature in ra_syntax/Cargo.toml
2019-10-14 19:56:29 +09:00
Shotaro Yamada
3a55b5bf01
make_mut_slice
2019-10-14 19:50:12 +09:00
bors[bot]
691bc27686
Merge #1999
...
1999: Simplify find().is_some() to any() r=matklad a=kjeremy
Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-10-14 09:44:04 +00:00
bors[bot]
85361e8d50
Merge #2000
...
2000: Use correct db type r=matklad a=kjeremy
I think this is more correct. No test fallouts.
Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-10-14 09:34:29 +00:00
Shotaro Yamada
b462eb96b8
import make_mut_arc_slice
2019-10-14 17:21:38 +09:00
Shotaro Yamada
965ca0d271
.collect()
directly into Arc<[T]>
2019-10-14 14:25:05 +09:00
Shotaro Yamada
f8d4cdc170
Avoid cloning Arc<[T]>
into a vec if possible
2019-10-14 14:25:05 +09:00
Aleksey Kladov
c00f298fd2
add syntax-tree based indents
2019-10-12 22:07:47 +03:00
Florian Diebold
2955fbc7e1
Split up infer.rs further
...
- coercion logic goes to `coerce.rs`
- expression inference goes to `expr.rs`
- pattern inference goes to `pat.rs`
2019-10-12 18:41:11 +02:00
Shotaro Yamada
5ca6281164
Remove unused dependencies
2019-10-12 08:00:54 +09:00
Shotaro Yamada
8c72c00abd
Remove smol_str dependency from ra_syntax
2019-10-12 07:48:23 +09:00
kjeremy
a1d631da4f
Use correct db type
2019-10-11 15:56:17 -04:00
kjeremy
53d1673edc
use any()
2019-10-11 15:55:45 -04:00
kjeremy
04963fa14d
No need to make config pub
2019-10-11 15:13:15 -04:00
bors[bot]
0896ca04c4
Merge #1989
...
1989: Chalk update to simplified IR r=flodiebold a=kjeremy
Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-10-11 11:12:27 +00:00
Aleksey Kladov
ebca677180
reduce visibility
2019-10-11 11:37:54 +03:00
bors[bot]
f70c54ccfb
Merge #1994
...
1994: remove last traces of source roots from hir r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-10-11 07:49:39 +00:00
Aleksey Kladov
e44c7ce200
remove last traces of source roots from hir
2019-10-11 10:48:46 +03:00
Shotaro Yamada
0d0a444d43
Remove as_original_file
2019-10-11 06:53:43 +09:00
Shotaro Yamada
04741ae2bc
Use original_file
instead of as_original_file
2019-10-11 06:50:53 +09:00
kjeremy
4ba2c5b2de
Chalk update to simplified IR
2019-10-10 14:51:50 -04:00
bors[bot]
da190278e9
Merge #1981
...
1981: tweak fn labels in completion r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-10-10 15:15:46 +00:00
Aleksey Kladov
8d3d5cbdb0
tweak fn labels in completion
2019-10-10 18:09:14 +03:00
Aleksey Kladov
29e83988be
don't special case macro_use
2019-10-10 17:48:30 +03:00
Aleksey Kladov
89826a50fc
don't special case path attr
2019-10-10 17:42:29 +03:00
Aleksey Kladov
b36b8970cc
simplify a bit
2019-10-10 17:23:01 +03:00
Aleksey Kladov
5140283277
simplify some tests
2019-10-10 14:51:35 +03:00
Aleksey Kladov
ce0d4a3b1d
Refactor and fix some more edge cases around name resolution
2019-10-10 14:46:14 +03:00
Aleksey Kladov
31561b118f
if completion does auto-insertion, indicate this in the label
2019-10-10 13:18:42 +03:00
Ekaterina Babshukova
aa2f58550a
add module
methods
2019-10-09 14:59:47 +03:00
bors[bot]
afc871199d
Merge #1973
...
1973: add <> for type aliases as well r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-10-09 08:54:00 +00:00
Aleksey Kladov
d9f83d9b16
add <> for type aliases as well
2019-10-09 11:53:32 +03:00
Aleksey Kladov
048be5d9a3
smal cleanup
2019-10-09 11:26:41 +03:00
bors[bot]
b976772566
Merge #1972
...
1972: extend selection correctly handles commas in tuples r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-10-09 08:26:31 +00:00
Aleksey Kladov
8d65530843
extend selection correctly handles commas in tuples
2019-10-09 11:26:09 +03:00
Aleksey Kladov
e0b1c17dcb
add <>
when completing generic types
2019-10-08 21:14:52 +03:00
Aleksey Kladov
f4fa98b1bf
simplify
2019-10-08 20:34:30 +03:00
Aleksey Kladov
5144f3b22f
refactor
2019-10-08 20:33:43 +03:00
Aleksey Kladov
2f85a640a2
refactor
2019-10-08 20:32:19 +03:00
bors[bot]
06a8deae4a
Merge #1969
...
1969: restore coloring of attributes r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-10-08 11:55:27 +00:00
Aleksey Kladov
6503add6e3
restore coloring of attributes
2019-10-08 14:52:03 +03:00
bors[bot]
92cf0eba93
Merge #1924
...
1924: Support inferring&completing `Self` type in enum/struct/union definitions r=ice1000 a=ice1000
Signed-off-by: ice1000 <ice1000kotlin@foxmail.com>
An attempt to fix #1908 .
This code works, but I believe the implementation is ugly. Please give me suggestions!
Co-authored-by: ice1000 <ice1000kotlin@foxmail.com>
2019-10-08 11:46:14 +00:00
Aleksey Kladov
857f419c9d
hard-code nightly-only CFGs
2019-10-08 14:43:29 +03:00
Aleksey Kladov
972079c0e3
macro DSL for cfg in tests
2019-10-08 14:39:44 +03:00
ice1000
b043358be9
Address comments: fix docs, add completion test for Self
.
2019-10-08 07:32:41 -04:00
Aleksey Kladov
355419d404
use slightly more idiomatic api for cfg
2019-10-08 14:22:49 +03:00
bors[bot]
93199002af
Merge #1922
...
1922: feat(assists): Make raw string unescaped r=matklad a=Geobert
Last piece of https://github.com/rust-analyzer/rust-analyzer/issues/1730
Co-authored-by: Geobert Quach <geobert@protonmail.com>
2019-10-08 09:52:22 +00:00
bors[bot]
d9338dfa98
Merge #1951
...
1951: Lower the precedence of the `as` operator. r=matklad a=goffrie
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.
Fixes #1851 .
Co-authored-by: Geoffry Song <goffrie@gmail.com>
2019-10-08 08:44:26 +00:00
ice1000
6bad638928
Support inferring Self
type in enum definitions
...
Signed-off-by: ice1000 <ice1000kotlin@foxmail.com>
2019-10-07 19:40:14 -04:00
Geoffry Song
b4fe06bc17
Move tests around
2019-10-05 16:33:05 -07:00
bors[bot]
d3872964f8
Merge #1960
...
1960: Replace AST visitors with macro r=viorina a=viorina
Fixes #1672 .
Co-authored-by: Ekaterina Babshukova <ekaterina.babshukova@yandex.ru>
2019-10-05 14:54:25 +00:00
Ekaterina Babshukova
311dbb8545
remove visitor
module
2019-10-05 17:48:31 +03:00
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
Aleksey Kladov
d57b993ade
fix infinite loop in the parser
...
closes #1866
2019-09-20 16:57:31 +03:00
bors[bot]
c733993658
Merge #1881
...
1881: don't confuse macro with != r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-09-20 13:24:07 +00:00
Aleksey Kladov
0f70290b6e
don't confuse macro with !=
...
closes #1871
2019-09-20 16:23:24 +03:00
bors[bot]
b19da133ee
Merge #1850
...
1850: feat(assists): raw string <-> usual string manipulation r=matklad a=Geobert
Fixes #1730
Co-authored-by: Geobert Quach <geobert@protonmail.com>
2019-09-20 10:40:15 +00:00
Geobert Quach
ce4d843656
feat(assists): Apply comments
2019-09-19 22:12:28 +01:00
Geobert Quach
a3ab80b332
feat(assists): Rename escape_quote
to escape_double_quote
2019-09-19 22:12:28 +01:00
Geobert Quach
889f1f0a7c
feature(assists): Fix regression
2019-09-19 22:12:28 +01:00
Geobert Quach
016c997243
feat(assists): manage "
when removing hash and make_usual_string
2019-09-19 22:12:28 +01:00
Geobert Quach
b6d55290a1
feat(assists): raw string <-> usual string manipulation
...
Fixes #1730
2019-09-19 22:12:28 +01:00
kjeremy
e26c41d611
A few doc comments
2019-09-19 17:07:23 -04:00
kjeremy
883edd002e
Replace usages of bump_any with bump
2019-09-19 15:51:46 -04:00
bors[bot]
cd9b222ba0
Merge #1853
...
1853: Introduce FromSource trait r=matklad a=viorina
The idea is to provide an ability to get HIR from AST in a more general way than it's possible using `source_binder`.
It also could help with #1622 fixing.
Co-authored-by: Ekaterina Babshukova <ekaterina.babshukova@yandex.ru>
2019-09-19 18:18:41 +00:00
Ekaterina Babshukova
2867c40925
introduce FromSource trait
2019-09-19 19:38:27 +03:00
bors[bot]
44bab3621d
Merge #1873
...
1873: `fold_kind`: `MATCH_ARM_LIST => FoldKind::Block` r=matklad a=Centril
As suggested by @matklad in https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/folding.20of.20.60match.60.20and.20.60if.60/near/176109093 .
This should let folks fold all the arms in a `match` expression rather than just each arm individually.
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2019-09-19 15:56:38 +00:00
Mazdak Farrokhzad
2be9031935
Pacify rustfmt.
2019-09-19 17:37:41 +02:00
bors[bot]
4eb0bb4810
Merge #1874
...
1874: move fold conversino to conv.rs r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-09-19 15:31:42 +00:00
Aleksey Kladov
36732a42bd
move fold conversino to conv.rs
2019-09-19 18:27:47 +03:00
Mazdak Farrokhzad
1f97445f39
fold_kind
: MATCH_ARM_LIST => FoldKind::Block
2019-09-19 17:22:08 +02:00
Aleksey Kladov
184e80007b
fix typo
2019-09-19 18:18:58 +03:00
Aleksey Kladov
b31b7ab238
slightly cleanup macro tests
2019-09-19 13:44:51 +03:00
Aleksey Kladov
1e16ac0315
tweak installation process
2019-09-18 14:24:20 +03:00
Aleksey Kladov
7d15c81a33
account for impls generated by macros
2019-09-18 04:34:48 +03:00
bors[bot]
54379ec6f8
Merge #1862
...
1862: Assoc item resolution refactoring (again) r=flodiebold a=flodiebold
This is #1849 , with the associated type selection code removed for now. Handling cycles there will need some more thought.
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-09-17 21:16:28 +00:00
Florian Diebold
c2f9558e1a
Remove assoc type selection code for now to fix crashes
2019-09-17 23:11:20 +02:00
Florian Diebold
69c8cfc4c1
Add test for T::Item
cycles
2019-09-17 23:06:05 +02:00
Aleksey Kladov
2890a1450a
remove confusing code
...
I must confess I don't really understand what this code is trying to
do, but it definitely misreports changes during fixedpoint iteration,
and no tests fail if I remove it, so...
2019-09-17 21:04:15 +03:00
Aleksey Kladov
9ad2cea251
show error log by default
2019-09-17 20:53:12 +03:00
Florian Diebold
a040fde3ae
Remove TraitItem and ImplItem in favor of AssocItem
2019-09-17 19:47:45 +02:00
Florian Diebold
53a932509d
Small review improvements
2019-09-17 19:47:45 +02:00
Florian Diebold
35d1c03896
Add test for <T>::Item
2019-09-17 19:47:45 +02:00
Florian Diebold
fe1dfd2b20
Refactor some more
...
Type-relative paths (`<T>::foo`) also need to work in type context, for example
`<T>::Item` is legal. So rather than returning the type ref from the resolver
function, just check it before.
2019-09-17 19:47:45 +02:00
Florian Diebold
406280e52f
Refactor associated item resolution more
...
When resolving an associated item in value namespace, use the `Ty` lowering code
for the segments before the last instead of replicating it.
2019-09-17 19:47:45 +02:00
Florian Diebold
828d60574f
Refactor a bit to prepare for resolving trait assoc items
2019-09-17 19:47:45 +02:00
Florian Diebold
913ab1ec0a
Resolve assoc types on type parameters
...
E.g. `fn foo<T: Iterator>() -> T::Item`. It seems that rustc does this only for
type parameters and only based on their bounds, so we also only consider traits
from bounds.
2019-09-17 19:47:45 +02:00
Florian Diebold
16ee779483
Adapt some tests
2019-09-17 19:47:45 +02:00
Aleksey Kladov
4551182f94
use usual token tree for macro expansion
2019-09-17 15:51:48 +03:00
Aleksey Kladov
37ef8927c3
split mbe expander code into two modules
2019-09-17 02:06:14 +03:00
bors[bot]
ba583091e6
Merge #1817
...
1817: Support path starting with a type r=matklad a=uHOOCCOOHu
The path syntax `<Ty>::foo`
Co-authored-by: uHOOCCOOHu <hooccooh1896@gmail.com>
2019-09-16 12:43:21 +00:00
Dylan MacKenzie
cd8155b7f7
Remove is_unnamed
2019-09-15 23:08:32 -07:00
Dylan MacKenzie
beac779c96
Gracefully handle const _
items in ConstData
2019-09-15 16:48:50 -07:00
uHOOCCOOHu
7ed3be3291
Define known paths and group names
2019-09-15 20:14:33 +08:00
uHOOCCOOHu
de9670fe45
Move store TypeRef of type based path in PathKind
2019-09-15 19:48:24 +08:00
uHOOCCOOHu
4926bed426
Support path starting with a type
2019-09-15 19:40:32 +08:00
bors[bot]
2d79a1ad83
Merge #1848
...
1848: Parse `..` as a full pattern r=matklad a=ecstatic-morse
Resolves #1479 .
This PR implements [RFC 2707](https://github.com/rust-lang/rfcs/pull/2707 ) in the parser. It introduces a new `DotDotPat` AST node modeled on `PlaceholderPat` and changes the parsing of tuple and slice patterns to conform to the RFC.
Notably, this PR does *not* change the resulting AST when `..` appears in a struct pattern (e.g. `Struct { a, b: c, .. }`). I *think* this is the behavior mandated by RFC 2707, but someone should confirm this.
Co-authored-by: Dylan MacKenzie <ecstaticmorse@gmail.com>
2019-09-15 07:10:16 +00:00
Dylan MacKenzie
0956323bb7
Generate dot_dot_test
2019-09-14 17:08:22 -07:00
Dylan MacKenzie
da3815122d
Bless old tests containing a ..
pattern
2019-09-14 17:08:22 -07:00
Dylan MacKenzie
4a3a15f0e7
Parse ..
as a proper pattern
2019-09-14 17:08:22 -07:00
Dylan MacKenzie
426112c97e
Add DotDotPat
to AST
...
This is modeled on `PlaceholderPat`.
2019-09-14 17:08:22 -07:00
Dylan MacKenzie
c413f444a0
Add tests for underscores in const
and static
items
2019-09-14 16:31:09 -07:00
Dylan MacKenzie
253a18f938
Allow an underscore as the identifier in const
items
2019-09-14 16:31:09 -07:00
Florian Diebold
613863abb9
Remove a dbg!
2019-09-14 11:05:42 +02:00
Florian Diebold
dc935be1b5
Support bare Trait
without dyn
2019-09-14 10:20:41 +02:00
Florian Diebold
a61615c955
Upgrade Chalk
...
... and remove Ty::UnselectedProjection. It'll be handled differently.
2019-09-14 10:04:56 +02:00
Aleksey Kladov
7be7f67198
rename add_resolution -> add_scope_def
2019-09-13 16:39:51 +03:00
Aleksey Kladov
2fbe79ed9a
make PerNs non-generic
2019-09-13 16:38:59 +03:00
Aleksey Kladov
51e2d76b98
Specify desirable namespace when calling resolve
...
That way, we are able to get rid of a number of unreachable statements
2019-09-13 16:24:10 +03:00
Aleksey Kladov
114a1b878e
rename AdtDef -> Adt
2019-09-13 00:34:52 +03:00
Aleksey Kladov
bcf30d389c
generalize impl_froms to nested enums
2019-09-13 00:31:04 +03:00
Aleksey Kladov
45117c6388
make various enums "inherit" from AdtDef
2019-09-13 00:10:16 +03:00
Aleksey Kladov
63e1e63a91
start cleaning up the resolution
...
Nameres related types, like `PerNs<Resolution>`, can represent
unreasonable situations, like a local in a type namespace. We should
clean this up, by requiring that call-site specifies the kind of
resolution it expects.
2019-09-12 21:34:22 +03:00
JasperDeSutter
e6ee324b85
add macros with local_inner_macros argument
2019-09-12 14:41:16 +02:00
bors[bot]
a1261631a8
Merge #1818
...
1818: Infer box expression r=matklad a=uHOOCCOOHu
Infer `box e` to be `std::boxed::Box<T>` where `e: T`
Co-authored-by: uHOOCCOOHu <hooccooh1896@gmail.com>
2019-09-12 10:53:29 +00:00
bors[bot]
561e7aea5b
Merge #1821
...
1821: Macro completion tweaks r=matklad a=SomeoneToIgnore
Thanks @uHOOCCOOHu for making the macro completion happen :)
I've added a few tweaks to the current completion to make it a bit more convenient:
* Automatically add braces and put the editor cursor inside of them:
<img width="159" alt="image" src="https://user-images.githubusercontent.com/2690773/64737220-022b9f00-d4f5-11e9-8088-76d4678921ab.png ">
Currently I have to add the braces manually which is a bit cumbersome.
One further improvement can be to detect if macro accepts no parameters and place the cursor differently for this case.
* Add an exclamation mark to the macro completion label
This helps to distinguish macros from other completion items and also allows to show only macros in completion if you type `!`:
<img width="722" alt="image" src="https://user-images.githubusercontent.com/2690773/64736987-8b8ea180-d4f4-11e9-8355-2ce4f83b7aa8.png ">
<img width="732" alt="image" src="https://user-images.githubusercontent.com/2690773/64737214-ffc94500-d4f4-11e9-946e-1ba2db1c7fb1.png ">
Additionally, automatic formatting hooks had adjusted two `help.rs` files, I've added them as a last commit to the PR even though they are not really related.
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2019-09-12 10:45:47 +00:00
Aleksey Kladov
0ffd1fdbe4
fix panic when fetching generics
...
due to macro expansion, the root node is not always a file
2019-09-12 13:12:26 +03:00
Aleksey Kladov
3c68da792b
don't break parser error recovery in presence of macros
...
Parser has the invariant that `{}` are balanced.
Previous code tried (unsucesfuly) maintain the same invariant for
`$()` as well, but it was done in a rather ad-hoc manner: it's not at
all obvious that it is possible to maintain both invariants!
2019-09-12 12:38:07 +03:00
Kirill Bulatov
9c2a3da67c
Complete vec macros with square brackets
2019-09-12 12:16:09 +03:00
Kirill Bulatov
2ca8ba783c
Fix the formatting issues
2019-09-12 12:16:09 +03:00
Kirill Bulatov
1852b27233
Add !
to the macro completion label
2019-09-12 12:15:33 +03:00
Kirill Bulatov
037e02c08d
Complete macros parenthesis
2019-09-12 12:15:33 +03:00
Aleksey Kladov
a31933e4b5
add quiet mode to analysis-stats
2019-09-12 11:45:33 +03:00
Aleksey Kladov
81e216a079
analysis stats uses positional arg again
2019-09-12 11:14:09 +03:00
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
6353b1621f
Split out complete_macro_in_item_position
2019-09-11 22:44:44 +08: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
Aleksey Kladov
b9d9db83d1
cleanup dollar handling in expressions
2019-09-10 21:28:27 +03:00
bors[bot]
1140a83c1b
Merge #1806
...
1806: refactor(args): Switch to pico-args r=matklad a=Geobert
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/1768
Co-authored-by: Geobert Quach <geobert@protonmail.com>
2019-09-10 17:37:21 +00:00
Aleksey Kladov
4fdaec99c0
simiplify
2019-09-10 20:28:50 +03:00
Aleksey Kladov
6e5198cd6d
add fragmets to expansion
2019-09-10 20:26:41 +03:00
Geobert Quach
aa894ace1f
refactor(args): Apply comments
2019-09-10 16:17:11 +01:00
Aleksey Kladov
ed726081d1
add a jointness parser tests
...
cc https://github.com/rust-lang/rust/issues/64242
2019-09-10 15:57:51 +03:00
Aleksey Kladov
1c5800dee8
"Fix" mbe to work with decomposed tokens
...
We regressed $i * 2 where $i = 1 + 1, need to fix that!
2019-09-10 15:56:05 +03:00
Aleksey Kladov
40170885e7
WIP: switch to fully decomposed tokens internally
2019-09-10 15:46:39 +03:00
Geobert Quach
4e94c46713
refactor(args): Switch to pico-args in ra_tools
2019-09-10 12:56:45 +01:00
Geobert Quach
735845d86e
refactor(args): Switch to pico-args
2019-09-10 11:31:40 +01:00
uHOOCCOOHu
c66a789a04
Show macro definition in hover text
2019-09-10 13:33:02 +08:00
uHOOCCOOHu
7de9537ccc
Support completion for macros
2019-09-10 13:32:47 +08:00
Aleksey Kladov
d8aa9a1d81
introduce bump as a better-checked alternative to bump_any
2019-09-10 01:03:00 +03:00
Aleksey Kladov
e2b378ef7e
rename bump -> bump_any
2019-09-10 01:00:38 +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
bors[bot]
7258523a51
Merge #1789
...
1789: Debug r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-09-09 14:35:21 +00: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
7910202ecd
tiny simplification
2019-09-09 13:23:41 +03: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
bors[bot]
734a43e95a
Merge #1793
...
1793: Fix outer doc-comments of `macro_rules` r=matklad a=uHOOCCOOHu
Document comments of `macro_rules!` is currently parsed outside the `MACRO_CALL` node,
which makes `DocCommentsOwner::doc_comments()` always empty.
For the input:
```rust
/// Some docs
macro_rules! foo {
() => {};
}
```
Current parsing tree is:
```
SOURCE_FILE
COMMENT // <- This should be children of MACRO_CALL
WHITESPACE
MACRO_CALL
PATH
<...omitted...>
```
It should be:
```
SOURCE_FILE
MACRO_CALL
COMMENT
WHITESPACE
PATH
<...omitted...>
```
Co-authored-by: uHOOCCOOHu <hooccooh1896@gmail.com>
2019-09-09 08:45:00 +00:00
uHOOCCOOHu
f3cbdb07c5
Fix outer doc-comments of macro_rules
2019-09-09 11:13:14 +08: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
Nelson Chen
14585468e2
Minor typo fix for ra_assists code doc
2019-09-08 02:10:53 -07: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
Aleksey Kladov
6c11935712
simplify
2019-09-06 21:57:11 +03:00
Aleksey Kladov
219287a14c
don't deadlock on shutdown
...
Specifically, when we tear down IO threads, we should take care to
dispose connection.
closes #1775
2019-09-06 20:58:21 +03:00
Aleksey Kladov
28df377759
add option to disable notify
2019-09-06 17:21:29 +03: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]
4576e6597e
Merge #1772
...
1772: switch to rustc_lexer crate r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-09-05 20:12:19 +00:00
Aleksey Kladov
7a9d7dd637
switch to rustc_lexer crate
2019-09-05 23:07:17 +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
bors[bot]
c705fff309
Merge #1770
...
1770: rename test file to match impl file r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-09-05 18:54:20 +00:00
Aleksey Kladov
5a38a80d1a
rename test file to match impl file
2019-09-05 21:43:32 +03:00
Aleksey Kladov
33965f0f3e
fix renaming of modules
2019-09-05 21:36:40 +03:00
Aleksey Kladov
3e5f7299e1
move mod resolution to a separate file
2019-09-05 20:27:10 +03:00
Aleksey Kladov
b2be998b7b
better error recovery for use trees
2019-09-05 19:53:07 +03:00
bors[bot]
edc2016f8b
Merge #1766
...
1766: always use \n newlines r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-09-05 14:51:14 +00:00
Aleksey Kladov
8b8a11ded7
always use \n newlines
2019-09-05 17:50:39 +03:00
ivfranco
4854408f28
close #1763
2019-09-05 22:04:56 +08: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]
82f3317e2b
Merge #1761
...
1761: "move type bounds to where clause" assist r=matklad a=viorina
Co-authored-by: Ekaterina Babshukova <ekaterina.babshukova@yandex.ru>
2019-09-05 10:39:35 +00:00
Ekaterina Babshukova
acb89d2be1
add assist to move type bounds to where clause
2019-09-05 13:29:13 +03: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
kjeremy
cb063a9b30
lsp-types 0.61.0
2019-09-03 10:50:39 -04: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