Commit graph

989 commits

Author SHA1 Message Date
Han Mertens
537da096fe Run cargo xtask codegen 2020-02-12 23:09:13 +01:00
Kirill Bulatov
2a7d97d829 Fix the trailing whitespace test 2020-02-12 17:04:16 +02:00
Kirill Bulatov
848c576266 Introduce AttrKind 2020-02-12 16:44:52 +02:00
Kirill Bulatov
1596b31698 Do not add imports before inner attributes 2020-02-12 16:21:55 +02:00
bors[bot]
759100fb0d
Merge #3062
3062: Implement slice pattern AST > HIR lowering r=jplatte a=jplatte

WIP. The necessary changes for parsing are implemented, but actual inference is not yet. Just wanted to upload what I've got so far so it doesn't get duplicated :)

Will fix #3043

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2020-02-11 21:46:36 +00:00
Jonas Platte
a3b104aa6d
Implement slice pattern AST > HIR lowering 2020-02-11 22:33:11 +01:00
Matthew Jasper
49b53cd7a0 Address review comments 2020-02-10 20:11:44 +00:00
Matthew Jasper
504e2a46bd Update tests for or-patterns 2020-02-09 22:06:28 +00:00
Matthew Jasper
8c8d0bb34f Add or- and parenthesized-patterns 2020-02-09 22:06:15 +00:00
Florian Diebold
9bb699b28d Some README fixes/cleanups
Make capitalization more consistent and fix some typos.
2020-02-09 13:35:54 +01:00
Kirill Bulatov
740a26b7d2 Rename add import assist 2020-02-07 23:53:08 +02:00
bors[bot]
8337dcd9e2
Merge #3047
3047: Update async unsafe fn ordering in parser r=matklad a=kiljacken

As of rust-lang/rust#61319 the correct order for functions that are both unsafe and async is: `async unsafe fn` and not `unsafe async fn`.

This commit updates the parser tests to reflect this, and corrects parsing behavior to accept the correct ordering.

Fixes #3025

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2020-02-07 13:21:02 +00:00
bors[bot]
6d6a995e09
Merge #3040
3040: Rework value parameter parsing r=matklad a=tobz1000

Fixes #2847.

- `Fn__(...)` parameters with idents/patterns no longer parse
- Trait function parameters with arbitrary patterns parse
- Trait function parameters without idents/patterns no longer parse
- `fn(...)` parameters no longer parse with patterns other than a single ident

__Question__: The pre-existing test `param_list_opt_patterns` has been kept as-is, although the name no longer makes sense (it's testing `Fn__(...)` params, which aren't allowed patterns any more). What would be best to do about this?

Co-authored-by: Toby Dimmick <tobydimmick@pm.me>
2020-02-07 13:13:36 +00:00
Emil Lauridsen
73ec2ab184 Update async unsafe fn ordering.
As of rust-lang/rust#61319 the correct order for functions that are both
unsafe and async is: `async unsafe fn` and not `unsafe async fn`.

This commit updates the parser tests to reflect this, and corrects
parsing behavior to accept the correct ordering.

Fixes #3025
2020-02-07 13:51:51 +01:00
Aleksey Kladov
36ee9ecb67 Cleanup early return assist 2020-02-07 12:30:39 +01:00
Aleksey Kladov
aa1234e02b Generalize invert_if to just always work 2020-02-07 12:14:33 +01:00
Aleksey Kladov
56e3fbe588 A tiny bit more consistent API 2020-02-06 23:59:27 +01:00
Toby Dimmick
0183952d2e Closure params test 2020-02-06 20:39:27 +00:00
Toby Dimmick
7e66785859 Rework value parameter parsing
- `Fn__(...)` parameters with idents/patterns no longer parse
- Trait function parameters with arbitrary patterns parse
- Trait function parameters without idents/patterns no longer parse
- `fn(...)` parameters no longer parse with patterns other than a single ident
2020-02-06 19:45:51 +00:00
Aleksey Kladov
a4c6e8c4e2 Refactor if-let -> match assist to use ast::make 2020-02-05 14:08:16 +01:00
Aleksey Kladov
4ea0c12cf1 Make sure that newly created nodes are the root of the tree 2020-02-04 13:22:32 +01:00
Veetaha
a3e5663ae0 ra_syntax: added tests for tokenization errors 2020-02-04 00:00:55 +02:00
Veetaha
9367b9a292 ra_syntax: add backticks around tokens specimen 2020-02-04 00:00:55 +02:00
Veetaha
c3117eea31 ra_syntax: removed unnecessary init statement from reparsing tests 2020-02-04 00:00:55 +02:00
Veetaha
58e01d8754 ra_syntax: rename first_token() -> lex_first_token() 2020-02-04 00:00:55 +02:00
Veetaha
b1764d85fc ra_syntax: fixed a typo in doc comment 2020-02-04 00:00:55 +02:00
Veetaha
9e7eaa959f ra_syntax: refactored the lexer design as per @matklad and @kiljacken PR review 2020-02-04 00:00:55 +02:00
Veetaha
bf60661aa3 ra_syntax: remove backticks from TokenizeError message since that is not Markdown ;( 2020-02-04 00:00:55 +02:00
Veetaha
c6d0881382 add better docs for tokenize errors 2020-02-04 00:00:55 +02:00
Veetaha
ffe00631d5 ra_syntax: moved ParsedToken derive attribute under the doc comment 2020-02-04 00:00:55 +02:00
Veetaha
a2bc4c2a74 ra_syntax: fixed doc comment 2020-02-04 00:00:55 +02:00
Veetaha
ac37a11f04 Reimplemented lexer with vectors instead of iterators 2020-02-04 00:00:55 +02:00
Veetaha
ad24976da3 ra_syntax: changed added diagnostics information returned from tokenize() (implemented with iterators) 2020-02-04 00:00:55 +02:00
Veetaha
fa31841f1f Fixed a typo 2020-01-22 13:02:21 +02:00
Veetaha
1ac105056a Fixed a typo 2020-01-22 13:02:21 +02:00
Veetaha
b6be1b6f61 Preserved a comment on the bug previously present in ast::Literal::kind() 2020-01-22 13:02:21 +02:00
Veetaha
3ec781d4f2 ra_syntax: remove code duplication and token reevaluation from ast::Literal::kind() 2020-01-22 13:02:21 +02:00
TomasKralCZ
72792f6bc5 changed 'descendants()' to 'children()' 2020-01-20 10:19:33 +01:00
TomasKralCZ
f67ee69777 added eq_token() method to LetStmt 2020-01-19 18:55:56 +01:00
Aleksey Kladov
3a859e587f Nest attrs into exprs in function args 2020-01-17 11:47:07 +01:00
Aleksey Kladov
b7c45fba57 Extract expr_with_attrs 2020-01-17 11:44:40 +01:00
Aleksey Kladov
90b8a31b83
Merge pull request #2813 from jyn514/arg_attributes
Allow attributes before function arguments
2020-01-17 11:15:07 +01:00
Joshua Nelson
f077d5c303
move inline function closer to relevant code
also updates generated inline tests
2020-01-16 22:20:17 -05:00
Aleksey Kladov
5398b9eeba Minimize test 2020-01-16 18:39:29 +01:00
Aleksey Kladov
ab0a11b1de Simplify array parsing 2020-01-16 18:35:03 +01:00
bors[bot]
e614356de1
Merge #2827
2827: Fix array element attribute position r=matklad a=edwin0cheng

This PR fixed a bug which an ATTR node insert in the wrong place in array element. ~~And introduce `precede_next` for allow outer attributes to insert into a parsed `expr`.~~  

related #2783

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-01-16 15:49:23 +00:00
Edwin Cheng
ed8d5c86e3 Fix array element attribute position 2020-01-16 23:37:43 +08:00
bors[bot]
c78d269b66
Merge #2837
2837: Accidentally quadratic r=matklad a=matklad

Our syntax highlighting is accdentally quadratic. Current state of the PR fixes it in a pretty crude way, looks like for the proper fix we need to redo how source-analyzer works. 

**NB:** don't be scared by diff stats, that's mostly a test-data file

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-15 19:38:10 +00:00
Aleksey Kladov
ef1326ee19 More orthogonal path editing 2020-01-15 18:48:28 +01:00
Aleksey Kladov
7d2d3ac3db More fluent API 2020-01-15 18:30:23 +01:00
Aleksey Kladov
c84010e246 Slightly more fluent API 2020-01-15 18:14:49 +01:00
Aleksey Kladov
8296d3208d Simplify 2020-01-15 18:01:05 +01:00
Aleksey Kladov
448575aa4a Simplify 2020-01-15 18:01:05 +01:00
Aleksey Kladov
35bfeaf4af Add a test 2020-01-15 16:52:28 +01:00
Veetaha
60251da204 refactor(ra_syntax.validation): removed code duplication from validate_literal() function 2020-01-14 04:09:03 +02:00
kjeremy
a82c679c97 Some clippy lints 2020-01-13 11:27:06 -05:00
Joshua Nelson
c3ac2c93fb
Allow attributes before function arguments
This adds support for function calls of the form:

```rust
  (
    #[attr(...)] 1.2,
    #[attr_one(...)]
    #[attr_two(...)]
    1.5,
    ... etc ...
  )
```

Closes https://github.com/rust-analyzer/rust-analyzer/issues/2801
2020-01-12 10:25:41 -05:00
Florian Diebold
2c11a9b42d Qualify paths in 'fill match arms' assist 2020-01-12 11:34:52 +01:00
Florian Diebold
15fc643e05 Fix ordering problem between qualifying paths and substituting params 2020-01-11 23:33:04 +01:00
Florian Diebold
4545f289a9 Handle type args 2020-01-11 23:33:04 +01:00
Jeremy Kolb
d993f329a0 Basic DocumentHighlightKind support for assignments 2020-01-10 15:14:19 -05:00
Emil Lauridsen
aa433c67d8 Parse trait aliases 2020-01-09 18:40:01 +01:00
Aleksey Kladov
47785b0cd4 ⬆️ rowan 2020-01-09 16:33:02 +01:00
Michael Chesser
ce1b34fd59 Improve const generics parsing
- Handle const generics type args
- Fix issue with const generic as first parameter in trait impl
2020-01-07 09:29:03 +10:30
Jeremy Kolb
5afb22e2b3 BinOp helper to detect assignment 2020-01-04 15:54:31 -05:00
Aleksey Kladov
b5e7186265 remove unused file 2020-01-04 10:58:10 +01:00
Aleksey Kladov
084bd304f3 Switch ast declaration from ron to a macro 2020-01-03 21:54:10 +01:00
Florian Diebold
79c90b5641 Collect visibility of items during nameres 2019-12-26 16:23:40 +01:00
Florian Diebold
069bf55cca Add infrastructure for visibility on syntax and hir_def level 2019-12-26 16:23:40 +01:00
Edwin Cheng
208ad97fdc Remove AsyncOwner 2019-12-25 00:25:18 +08:00
Edwin Cheng
0edb5b4a50 Implement infer await from async func 2019-12-24 19:45:28 +08:00
bors[bot]
436df298ba
Merge #2642
2642: Use name instead of ident in parser for macro 2.0 syntax r=matklad a=edwin0cheng



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-12-22 08:05:02 +00:00
bors[bot]
d33493d779
Merge #2641
2641: Parse const generics r=matklad a=roblabla

Adds very primitive support for parsing const generics (`const IDENT: TY`) so that rust-analyzer stops complaining about the syntax being invalid.

Fixes #1574
Fixes #2281 

Co-authored-by: roblabla <unfiltered@roblab.la>
2019-12-22 07:56:33 +00:00
Edwin Cheng
737045c1ea Use name instead of ident for macro 2.0 sytnax 2019-12-22 11:11:10 +08:00
roblabla
b04d4a88d1 Parse const generics
Fixes #1574
Fixes #2281
2019-12-22 01:32:08 +00:00
bors[bot]
90ef070db3
Merge #2628
2628: Add macro 2.0 support in parser r=matklad a=edwin0cheng

This PR added a new syntax kind : `MACRO_DEF` and a keyword `MACRO_KW`

there are two syntax for declarative macro 2.0 :
1. Normal : `macro m { ($i:ident) => {} }` , which handle similar to legacy one. 
2. Call like: `macro m($i:ident) {}`, it produces a single token tree which have two child token trees : `($i:ident)` and `{}`

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-12-21 10:47:47 +00:00
Edwin Cheng
bea8f58118 Add macro 2.0 support in parser 2019-12-21 18:29:14 +08:00
kjeremy
0d5d63a80e Clippy lints 2019-12-20 15:14:30 -05:00
Florian Diebold
2a8c9100bf Handle closure return types
Fixes #2547.
2019-12-20 18:16:11 +01:00
Edwin Cheng
4a7e19946a Fix parser for macro call in pattern position 2019-12-20 23:26:04 +08:00
kjeremy
f22aabc136 Use unwrap_or_default 2019-12-20 09:43:30 -05:00
Aleksey Kladov
3e2f4e4293 Improve recovery for incomplete lambdas 2019-12-17 12:11:01 +01:00
Aleksey Kladov
b0739d5a26 Avoid recompiling serde 2019-12-12 14:11:06 +01:00
Aleksey Kladov
8c86963d47 DynMap
This might, or might not help us to reduce boilerplate associated with
plumbing values from analysis to the IDE layer
2019-12-06 21:28:05 +01:00
Aleksey Kladov
193b1a7437 ⬆️ rowan 2019-12-04 17:15:55 +01:00
ice1000
379482068d Add ModuleItemsOwner to Block 2019-12-03 12:07:39 -05:00
Aleksey Kladov
5fd68b5929 Fix hir for ast::UnionDef 2019-11-25 17:50:49 +03:00
Aleksey Kladov
e1c0bdaf75 Introduce dedicated AST node for union
Although structs and unions have the same syntax and differ only in
the keyword, re-using the single syntax node for both of them leads to
confusion in practice, and propagates further down the hir in an
upleasent way.

Moreover, static and consts also share syntax, but we use different
nodes for them.
2019-11-25 17:50:49 +03:00
bors[bot]
7b6aa7c34e
Merge #2343
2343: implement assist invert_if r=matklad a=bravomikekilo

fix [issue 2219 invert if condition](https://github.com/rust-analyzer/rust-analyzer/issues/2219)
I put the assist cursor range to `if` of the if expression, because both condition and body will be replaced. Is there any way to replace them without cover the cursor position?
@matklad 

Co-authored-by: bravomikekilo <bmk1221@126.com>
2019-11-24 08:32:07 +00:00
bravomikekilo
adac4fc2f2 do refact and fix some issue 2019-11-24 13:14:57 +08:00
Aleksey Kladov
d8caf56dfc Uniformalize naming 2019-11-22 21:52:06 +03:00
Aleksey Kladov
cebeedc66f Next gen IDs for functions
The current system with AstIds has two primaraly drawbacks:

* It is possible to manufacture IDs out of thin air.
  For example, it's possible to create IDs for items which are not
  considered in CrateDefMap due to cfg. Or it is possible to mixup
  structs and unions, because they share ID space.

* Getting the ID of a parent requires a secondary index.

Instead, the plan is to pursue the more traditional approach, where
each items stores the id of the parent declaration. This makes
`FromSource` more awkward, but also more correct: now, to get from an
AST to HIR, we first do this recursively for the parent item, and the
just search the children of the parent for the matching def
2019-11-20 16:22:58 +03:00
Aleksey Kladov
0e771915fa Allow non-path default type parameters 2019-11-20 11:46:44 +03:00
Aleksey Kladov
83a8430e0a ⬆️ rowan 2019-11-19 21:13:36 +03:00
DJMcNab
27ce1e822b Remove the custom impl of AttrsOwner for ImplItem
The default impl should have the same behaviour, and it can be generated
by codegen.
See also `ModuleItem` and `NominalDef`
2019-11-18 18:13:56 +00:00
Aleksey Kladov
7e2f4b30db Disable doctests 2019-11-17 18:35:05 +03:00
Aleksey Kladov
5b54a93fe7 Add ast for plain and raw string literals 2019-11-16 22:50:41 +03:00
Aleksey Kladov
d898ecb8f2 Force passing Source when creating a SourceAnalyzer 2019-11-16 02:12:35 +03:00
Geoffry Song
5645c153e0 Attempt to implement typed accessors 2019-11-15 12:05:29 -08:00
Geoffry Song
a68aefdc46 Move inclusive range check to validation 2019-11-15 01:04:45 -08:00
Geoffry Song
989cebc99c Fix parsing of "postfix" range expressions.
Right now they are handled in `postfix_dot_expr`, but that doesn't allow it to
correctly handle precedence. Integrate it more tightly with the Pratt parser
instead.

Also includes a drive-by fix for parsing `match .. {}`.

Fixes #2242.
2019-11-15 00:18:28 -08:00
Aleksey Kladov
4cea6bb6f1 Make make:: builders slightly more convenient 2019-11-13 11:59:18 +03:00
Aleksey Kladov
e177c65e36 Use strongly-typed ast building for early-return assist 2019-11-13 11:54:21 +03:00
Aleksey Kladov
1860f9ab43 Forbid visibility qualifiers in traits 2019-11-11 11:26:57 +03:00
bors[bot]
fe6ba12a77
Merge #2149
2149: Handle IfLet in convert_to_guarded_return. r=matklad a=krk

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/2124

I could not move the cursor position out of `let`:
`le<|>t` vs `let<|>`.

Also, please suggest extra test cases.

Co-authored-by: krk <keremkat@gmail.com>
2019-11-04 09:06:53 +00:00
krk
91ab3f8760 Support paths other than "Some". 2019-11-01 18:18:58 +01:00
kjeremy
dcc0a9cd7e Attach docs to statics 2019-10-31 16:21:46 -04:00
krk
4a4d9f7a90 Handle IfLet in convert_to_guarded_return. 2019-10-31 21:10:58 +01:00
kjeremy
78f93c8033 traits => match_ast! 2019-10-30 16:08:59 -04:00
kjeremy
7ad55e976c Document match_ast! 2019-10-30 14:38:45 -04:00
kjeremy
b441b4e8ef Some clippy fixes 2019-10-30 13:36:37 -04:00
Aleksey Kladov
5a6db3ca29 fix parsing of for loops inside expressions
closes #2051
2019-10-28 15:41:34 +03: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
Aleksey Kladov
4ef9b8d17a use correct spacing for enum pattern 2019-10-26 18:03:55 +03: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
Laurențiu Nicola
a6b980d6d4 Bump deps 2019-10-17 18:08:11 +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
Aleksey Kladov
c00f298fd2 add syntax-tree based indents 2019-10-12 22:07:47 +03:00
Shotaro Yamada
8c72c00abd Remove smol_str dependency from ra_syntax 2019-10-12 07:48:23 +09: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
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
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
uHOOCCOOHu
ffe179a736
Pass attributes as token tree to DefCollector 2019-10-03 02:27:11 +08: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
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
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
Aleksey Kladov
d847d53e36 Start simplifying editing API 2019-09-26 22:22:08 +03: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
Aleksey Kladov
a525e830a6 add new editing API, suitable for modifying several nodes at once 2019-09-25 17:57:12 +03:00
Aleksey Kladov
b7422bd1ab fewer monomorphisations 2019-09-25 17:19:16 +03:00
Aleksey Kladov
66101e931c simplify 2019-09-24 09:28:16 +03:00
kjeremy
fef7fcf5a9 Support loop as argument 2019-09-20 16:35:29 -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
5a65d4d9fb Add indexing to record_field_pat 2019-09-20 11:43:34 -04:00
Aleksey Kladov
d57b993ade fix infinite loop in the parser
closes #1866
2019-09-20 16:57:31 +03:00
Aleksey Kladov
0f70290b6e don't confuse macro with !=
closes #1871
2019-09-20 16:23:24 +03: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
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
uHOOCCOOHu
8c078a0164
Infer box expression 2019-09-12 02:35:09 +08: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
40170885e7 WIP: switch to fully decomposed tokens internally 2019-09-10 15:46:39 +03:00
uHOOCCOOHu
f3cbdb07c5
Fix outer doc-comments of macro_rules 2019-09-09 11:13:14 +08:00
Florian Diebold
d21cdf3c99 Lower Fn(X, Y) -> Z paths 2019-09-07 15:13:05 +02:00
Aleksey Kladov
7a9d7dd637 switch to rustc_lexer crate 2019-09-05 23:07:17 +03:00
Aleksey Kladov
b2be998b7b better error recovery for use trees 2019-09-05 19:53:07 +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
Aleksey Kladov
9c3b25177e Correctly build BodySourceMap for macro-expanded expressions 2019-09-03 11:04:38 +03:00
Aleksey Kladov
e94587e315 fix assists 2019-09-02 21:52:06 +03:00
Aleksey Kladov
5e3f291195 fix hir for new block syntax 2019-09-02 21:23:19 +03:00
Aleksey Kladov
dcf8e89503 fix generated AST 2019-09-02 20:15:51 +03:00
Aleksey Kladov
470fc4765c update test data 2019-09-02 20:15:51 +03:00
Aleksey Kladov
3c2dea7f55 always wrap block into an expression 2019-09-02 20:15:51 +03:00
Aleksey Kladov
f377b94628 remove useless trait 2019-09-02 19:45:41 +03:00
Florian Diebold
f92177cfb5 Add an expr_source method analogous to the source methods in the code model
... and use that instead of exposing the source map.
2019-09-02 14:56:38 +02:00
uHOOCCOOHu
f5bea9051b
Support resolution of #[macro_use] extern crate 2019-09-01 01:54:41 +08:00
bors[bot]
cd433ed194
Merge #1734
1734: Strip indents and empty lines in check_apply_diagnostic_fix_from_position r=matklad a=matklad



Co-authored-by: Phil Ellison <phil.j.ellison@gmail.com>
2019-08-25 09:58:54 +00:00
Phil Ellison
200470692f Cast SyntaxNodePtr to AstPtr directly 2019-08-25 12:56:23 +03:00
Dylan MacKenzie
c93903e9c7 Generate and bless tests 2019-08-23 16:24:30 -07:00
Dylan MacKenzie
83433cd1f0 Centralize box pattern tests in patterns.rs 2019-08-23 16:19:53 -07:00
Dylan MacKenzie
e6f3790106 Add BoxPat variant 2019-08-23 15:11:34 -07:00
Aleksey Kladov
5b18a4eef9 rename struct -> record, pos -> tuple 2019-08-23 16:59:50 +03:00
Aleksey Kladov
bbcca4f735 make ast object safe 2019-08-23 15:06:47 +03:00
bors[bot]
0c35d82329
Merge #1721 #1723
1721: Impl/dyn trait r=flodiebold a=flodiebold

This adds support for `impl Trait` and `dyn Trait` types as far as possible without Chalk. So we can represent them in the type system, and handle them in method resolution, but Chalk doesn't know about them yet. There's a small temporary hack here where we bypass Chalk during method resolution, so we can handle simple method calls on them and completion works.

Fixes #1608.

1723: Make sysroot use `RUST_SRC_PATH` if set r=matklad a=bkchr



Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
2019-08-22 20:06:32 +00:00
Florian Diebold
4768f5e717 Improve/fix type bound lowering 2019-08-22 21:58:29 +02:00
Dylan MacKenzie
3e14b16c4d Add test for nested box pattern 2019-08-22 12:53:54 -07:00
Florian Diebold
16a7d8cc85 Add impl Trait and dyn Trait types
- refactor bounds handling in the AST a bit
 - add HIR for bounds
 - add `Ty::Dyn` and `Ty::Opaque` variants and lower `dyn Trait` / `impl Trait`
   syntax to them
2019-08-22 19:33:00 +02:00
Aleksey Kladov
9f238930f1 Don't add ? bounds as real bounds
closes #1709
2019-08-22 15:35:42 +03:00
Aleksey Kladov
deba1fedfa ⬆️ rustc_lexer 2019-08-20 19:53:05 +03:00
Aleksey Kladov
39e444d701 remove ast::*Kind enums
With the new owned trees, we don't need an indirection here
2019-08-19 13:58:49 +03:00
Aleksey Kladov
39f50e7bd7 use new quote-generated ast 2019-08-18 23:36:22 +03:00
Aleksey Kladov
8cefdb5527 use quote! macro to generate grammar
We already use syn&quote elsewhere (transitively), so it make sense to
cut down on the number of technologies and get rid of tera
2019-08-18 23:11:08 +03:00
Aleksey Kladov
d545a5c75c deserialize grammar 2019-08-18 21:54:51 +03:00
Aleksey Kladov
7e5a186c1f Introduce separate hir::BinaryOp
Unlike ast::BinOp, it has significantly more structure to it, so it's
easier to, say, handle all assignment-like operations in the same way.
2019-08-17 17:42:41 +03:00
Aleksey Kladov
8919aa8065 implement accessors for IndexExpr 2019-08-17 17:17:01 +03:00
Aleksey Kladov
fd4c083e42 simplify 2019-08-17 17:14:22 +03:00
bors[bot]
5ed6a13a2c Merge #1685
1685: fix error of RangeFrom in for-loop r=DJMcNab a=bravomikekilo

fix [issue-1542](https://github.com/rust-analyzer/rust-analyzer/issues/1542) @matklad 

Co-authored-by: bravomikekilo <bmk1221@126.com>
2019-08-15 05:49:13 +00:00
bors[bot]
19e0d7d596 Merge #1676
1676: Fix for<'lifetime> for types specified by path r=matklad a=eupn

Fixes #1467.

Co-authored-by: Evgenii P <eupn@protonmail.com>
2019-08-14 15:10:31 +00:00
bravomikekilo
4f31fed362 fix test position 2019-08-14 21:20:04 +08:00
bravomikekilo
3fce56280f fix test 2019-08-14 12:42:58 +08:00
bravomikekilo
2bebdf0b37 fix error of RangeFrom in for-loop 2019-08-14 11:55:21 +08:00
bors[bot]
978e3e384b Merge #1636
1636: fix block parse problem r=matklad a=bravomikekilo

try to fix [issue-1598](https://github.com/rust-analyzer/rust-analyzer/issues/1598).

Co-authored-by: bravomikekilo <bmk1221@126.com>
2019-08-13 12:46:47 +00:00
bravomikekilo
eb0e9bd981 add inline test 2019-08-13 18:17:10 +08:00
Florian Diebold
22724f37f3 Lower fully qualified associated type paths
I.e. `<T as Trait>::Foo`.
2019-08-12 21:43:00 +02:00
Evgenii P
f1e62501c3 Fix for<'lifetime> for types specified by path 2019-08-11 16:56:05 +07:00
Aleksey Kladov
f3ee5a1509 Move numeric names inside of NameRef 2019-08-09 12:16:47 +02:00
Evgenii P
957b5ed23a Parse tuple struct field initialization 2019-08-09 15:38:52 +07:00
Evgenii P
db4839033c Change macro to function 2019-08-09 15:04:13 +07:00
Evgenii P
073cf42391 rustfmt 2019-08-09 14:23:13 +07:00
Evgenii P
f4a6d92050 Reduce code duplication in lexer by introducing small macro 2019-08-09 14:08:34 +07:00
bors[bot]
87608904f6 Merge #1661
1661: Parse function parameters attributes r=matklad a=eupn

Fixes #1397. The [RFC-2565](https://github.com/rust-lang/rfcs/blob/master/text/2565-formal-function-parameter-attributes.md) specifies `#[attributes]` to function parameters:

```rust
fn foo(#[attr] a, #[unused] b, #[must_use] ...) {
    // ...
}
```

This PR adds those attributes into grammar and to the parser, extending corresponding inline tests.

Co-authored-by: Evgenii P <eupn@protonmail.com>
2019-08-08 13:04:28 +00:00
Evgenii P
6fa2d82147 Fix parser tests according to review 2019-08-08 09:12:07 +07:00
Aleksey Kladov
d6ab1af086 assoc types bounds 2019-08-07 21:00:02 +02:00
Evgenii P
9ea36703d2 Fix variadic arg inline test 2019-08-07 23:48:21 +07:00
Evgenii P
3fb58c620c Add function parameters attributes 2019-08-07 23:42:28 +07:00
bors[bot]
658382c1f5 Merge #1640
1640: Bump deps r=matklad a=lnicola

`insta`, `unicode-xid` and others

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2019-08-04 08:12:12 +00:00
Laurențiu Nicola
5153001889 Bump deps 2019-08-04 10:43:51 +03:00
kjeremy
0f61aa1f09 Unconditionally trim the end of comments 2019-07-31 13:59:14 -04:00
kjeremy
d65dc40348 Removes */ in block doc comments 2019-07-31 11:43:00 -04:00
kjeremy
4fccad9b2c Add explicit newline preserving tests 2019-07-31 10:46:15 -04:00
Phil Ellison
e6113c0998 Add merge_match_arm assist, bump rowan to 0.6.1 2019-07-29 21:59:52 +01:00
bors[bot]
a5fe9f7a87 Merge #1604
1604: Fix failing type interference for floating point literal r=matklad a=theotherphil

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/1592

Co-authored-by: Phil Ellison <phil.j.ellison@gmail.com>
2019-07-29 19:02:39 +00:00
Phil Ellison
fab8e9bb8a cargo format 2019-07-28 20:54:37 +01:00
Phil Ellison
4fd7ad908b Add special case for f32 and f43 suffices on Literal.kind 2019-07-28 20:47:44 +01:00
Phil Ellison
578bc05ca4 Add issue link and trailing newline 2019-07-28 20:25:06 +01:00
Phil Ellison
fe1b1dd7d9 More direct failing test 2019-07-28 19:52:30 +01:00
Aleksey Kladov
459241f272 move syntax tests to unit tests 2019-07-24 12:49:19 +03:00
bors[bot]
bf3030404e Merge #1584
1584: switch to upstream unescape r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-24 09:03:26 +00:00
Aleksey Kladov
2473cb6a5c switch to upstream unescape 2019-07-24 11:47:28 +03:00
bors[bot]
a971c6d32d Merge #1583
1583: ⬆️ rowan r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-24 08:44:40 +00:00
Aleksey Kladov
c79eea9fc1 ⬆️ rowan 2019-07-24 11:28:53 +03:00
bors[bot]
25921f5a5f Merge #1573
1573: fix: parse box syntax inside parentheses r=matklad a=csmoe

r? @matklad 

Co-authored-by: csmoe <csmoe@msn.com>
2019-07-24 08:27:46 +00:00
Aleksey Kladov
700669bbd0 kill old lexer 2019-07-22 17:56:19 +03:00
Aleksey Kladov
75761c0e47 add rustc_lexer 2019-07-22 17:47:33 +03:00
csmoe
8fe58c3598 fix: parse box syntax inside parentheses 2019-07-22 20:52:10 +08:00
Aleksey Kladov
773ad2edb3 simiplify 2019-07-21 13:34:15 +03:00
Aleksey Kladov
d52ee59a71 streamline API 2019-07-21 13:28:58 +03:00
Aleksey Kladov
62be91b82d minor, move type 2019-07-21 13:08:32 +03:00
Aleksey Kladov
c9cfd57eea switch to upstream rowan's API 2019-07-20 20:12:06 +03:00
bors[bot]
3983ccca4a Merge #1566
1566: align SyntaxText API with upstream r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-20 13:52:33 +00:00
Aleksey Kladov
f6bcc2d745 align SyntaxText API with upstream 2019-07-20 16:52:11 +03:00
bors[bot]
dac6adbef9 Merge #1562
1562: Continue support for .await r=matklad a=unrealhoang

- add await expr to ast and HIR Expr
- infer type for `.await`

Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
2019-07-20 11:27:50 +00:00
Unreal Hoang
5ac9f5cdc7
add await expr to ast 2019-07-20 19:35:49 +09:00
bors[bot]
6b352ffeb3 Merge #1560
1560: move debug_dump to fmt::Debug r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-20 09:59:10 +00:00
Aleksey Kladov
f3bdbec1b6 rename range -> text_range 2019-07-20 12:58:27 +03:00
Aleksey Kladov
6d5d82e412 move debug_dump to fmt::Debug 2019-07-20 12:48:24 +03:00
Unreal Hoang
3a7f07c62d
add await to syntax, parser for await_expr 2019-07-20 17:41:31 +09:00
Aleksey Kladov
d92a88bf09 remove lifetime from syntax node text 2019-07-19 21:41:36 +03:00
Aleksey Kladov
0025299370 sane indexing in text 2019-07-19 20:55:32 +03:00
Aleksey Kladov
8467ba8cdb flip syntax text to use internal iteration 2019-07-19 20:29:59 +03:00
Aleksey Kladov
8f032d6a58 drop memory size of subtree
it wasn't too accurate and the new measurement method of dropping the
database completely is better anyway
2019-07-19 19:55:54 +03:00
Aleksey Kladov
191a6ba330 convenience api 2019-07-19 19:05:34 +03:00
Aleksey Kladov
5c594bcb48 cleanup casts 2019-07-19 18:22:00 +03:00
Aleksey Kladov
f9d9e0a1f7 several highlighting cleanups
* make stuff more type-safe by using `BindPat` instead of just `Pat`
* don't add `mut` into binding hash
* reset shadow counter when we enter a function
2019-07-19 16:09:32 +03:00
Aleksey Kladov
d4a66166c0 switch to the upstream rowan 2019-07-19 14:15:01 +03:00
Aleksey Kladov
0343c4a815 migrate ra_assists to the new AST 2019-07-19 13:16:25 +03:00
Aleksey Kladov
e2b28f5bb8 migrate ra_hir to the new rowan 2019-07-19 13:16:25 +03:00
Aleksey Kladov
d402974aa0 migrate ra_syntax to the new rowan API 2019-07-19 13:16:24 +03:00
Aleksey Kladov
df33e7685b use Parse in mbe 2019-07-18 23:19:04 +03:00
Aleksey Kladov
a6224f3620 make Parse generic 2019-07-18 22:55:04 +03:00
Aleksey Kladov
1edec77e58 cleanup imports 2019-07-18 20:16:33 +03:00
Ekaterina Babshukova
4abe03879b highlight mutable variables differently 2019-07-18 18:52:50 +03:00
Aleksey Kladov
0fb4b896e2 use more correct phantom types for ptrs 2019-07-18 18:13:32 +03:00
Aleksey Kladov
deab4caa7b make Parse fields private
this is in preparation for the new rowan API
2019-07-12 19:41:13 +03:00
Pascal Hertleif
6e87065968 Make clippy a bit happier
Random drive-by fix. I honestly blame rust-analyzer itself on this,
because I set its watch mode to use `cargo clippy` 🤷
2019-07-10 17:05:39 +02:00
Pascal Hertleif
d0ff53de2d Resolve a FIXME
Now that we are using a newer smol_str release this can be simplified :)
2019-07-10 17:04:38 +02:00
Shotaro Yamada
a426de60ad Remove unused dependencies 2019-07-09 00:28:00 +09:00
Muhammad Mominul Huque
012fec54dc
Constify KnownName's 2019-07-08 03:29:38 +06:00
Jeremy Kolb
6b4ec73b7e Clippy changes 2019-07-04 23:00:00 -04:00
Jeremy Kolb
4ad9e986ad Some clippy fixes for 1.36 2019-07-04 17:43:00 -04:00
Aleksey Kladov
1834bae5b8 allow rustfmt to reorder imports
This wasn't a right decision in the first place, the feature flag was
broken in the last rustfmt release, and syntax highlighting of imports
is more important anyway
2019-07-04 23:09:09 +03:00
Ryan Cumming
2959aa446e Remove parse error on array initializer attributes
This is actually allowed by the `rustc` parser but most attributes will
fail later due to attributes on expressions being experimental.
2019-06-30 19:55:50 +10:00
Ryan Cumming
b01496538c Support attributes on array members
Array members are allow to have attributes such as `#[cfg]`.

This is a bit tricky as we don't know if the first expression is an
initializer or a member until we encounter a `;`. This reuses a trick
from `stmt` where we remember if we saw an attribute and then raise an
error if the first expression ends up being an initializer.

This isn't perfect as the error isn't correctly located on the attribute
or initializer; it ends up immediately after the `;`.
2019-06-30 18:36:54 +10:00
zjy
de930237ff fixed #1384 2019-06-28 15:22:17 +08:00
bors[bot]
67ecc88f66 Merge #1415
1415: fix: specialization r=matklad a=csmoe

Closes #1402 
r? @matklad 

Co-authored-by: csmoe <csmoe@msn.com>
2019-06-24 10:10:05 +00:00
csmoe
d04473accb fix: specialization(with blindly parsing)
Change-Id: Ic5d2767e8781568d76d4d0013cd6081e95ae8a95
2019-06-19 18:37:38 +08:00
csmoe
d6533994e4 fix: box_pattern
Change-Id: I45a856d74fb616d3bce33050f9e69d327186bd59
2019-06-19 14:28:50 +08:00
csmoe
5999733ca6 fix: box_syntax(#1412)
Change-Id: I6e20e0163fa545de37226c1561b3b7103615626c
2019-06-18 21:46:47 +08:00
Shotaro Yamada
774537fb01 Fix formatting 2019-06-16 01:45:38 +09:00
Shotaro Yamada
474a04615c Skip attrs in Literal::token 2019-06-15 23:36:12 +09:00
Muhammad Mominul Huque
f032eeb05f
Get rid of failure: ra_batch ra_cli 2019-06-15 13:24:02 +06:00
csmoe
2ca9f71897 fix: support existential type 2019-06-12 14:32:39 +00:00
csmoe
205a8278a9 fix: never type with binding
Change-Id: I14e1bc628b9d2dfdb1f40de3d3707f4e872767f2
2019-06-07 19:49:49 +08:00
Andrey Tkachenko
505b8d873f [#1083] Try block syntax: fix tests 2019-06-06 16:26:54 +04:00
Andrey Tkachenko
281c9eeaff [#1083] Try block syntax 2019-06-06 15:43:26 +04:00
csmoe
44363cd5d2 fix: clean up warnings
Change-Id: I91a468f6e846ac28574825b8ee7aa02fbff68f63
2019-06-06 10:06:46 +08:00
Alan Du
b28ca32db2 Fix clippy::or_fun_call 2019-06-04 18:05:07 -04:00
Alan Du
ed3d93b875 Fix clippy::single_char_pattern 2019-06-04 18:05:07 -04:00
Aleksey Kladov
18ed351747 ⬆️ parking_lot 2019-05-30 12:02:30 +03:00
Aleksey Kladov
38cb88307e flip Into to From 2019-05-29 10:31:07 +03:00
Aleksey Kladov
2e722ec54b show error offsets in tests 2019-05-29 10:31:07 +03:00
Aleksey Kladov
0efbcdf435 remove old parsing methods 2019-05-28 17:34:28 +03:00
Aleksey Kladov
310bfe57bd update test data 2019-05-28 17:09:45 +03:00
Aleksey Kladov
bc2550b196 update tests 2019-05-28 16:59:22 +03:00
Aleksey Kladov
afeaea7051 drop error from SOurceFile constructor 2019-05-28 16:34:23 +03:00
Aleksey Kladov
1cece9f219 return errors from tree builder 2019-05-28 16:26:14 +03:00
Aleksey Kladov
90926b9479 drop errors from SyntaxNode 2019-05-28 16:15:17 +03:00
Aleksey Kladov
f52eda675e add Parse 2019-05-28 16:15:17 +03:00