Commit Graph

139 Commits

Author SHA1 Message Date
pcpthm
a67fe4ea7e Fix parse tree of attribute on match arm 2019-03-17 20:57:27 +09:00
pcpthm
a1d84f5fb0 Allow attribute on struct literal field 2019-03-17 19:08:35 +09:00
Michael Chesser
943d2fb781 Add test for minus in inner pattern 2019-03-14 19:24:12 +10:30
Caio
cc9721996c Add test for async block 2019-03-10 14:35:25 -03:00
Caio
ad72699553 Add async keyword 2019-03-09 20:40:22 -03:00
Ville Penttinen
1f4468a8da Add support for parsing multiple if and while-let patterns 2019-03-04 19:10:14 +02:00
Aleksey Kladov
90122542b2 allow mut ident patterns in trait methods
closes #928
2019-03-04 17:47:02 +03:00
Aleksey Kladov
0a19f4f1b4 allow aliases in underscores
this helps with

    use foo::Trait as _;

syntax
2019-03-04 16:40:08 +03:00
bors[bot]
dc8bcc1e42 Merge #926
926: allow vararg functions r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-03-04 12:49:37 +00:00
Aleksey Kladov
77f2381eea improve error recovery
parse the contents of error block as an expression
2019-03-04 15:31:18 +03:00
Aleksey Kladov
a99b1db49f allow vararg functions 2019-03-04 14:34:59 +03:00
Aleksey Kladov
78f10fcdc4 rename type to type_alias in the AST as well 2019-02-25 13:49:32 +03:00
Aleksey Kladov
f7f99af0a6 kill utils module 2019-02-21 15:57:40 +03:00
Ville Penttinen
58d14bcaf7 Enable parsing attributes for generic lifetimes and type parameters 2019-02-17 23:32:10 +02:00
Ville Penttinen
96e3ac389f Parse only outer_attributes for match arms for now 2019-02-17 19:48:08 +02:00
Ville Penttinen
1c97c1ac11 Enable parsing of attributes inside a match block
We allow invalid inner attributes to be parsed, e.g. inner attributes that are
not directly after the opening brace of the match block.

Instead we run validation on `MatchArmList` to allow better reporting of errors.
2019-02-17 19:26:57 +02:00
Aleksey Kladov
4e91c23c79 rename yellow -> syntax_node
why yellow in the first place? Its red + green.
2019-02-12 19:02:30 +03:00
Aleksey Kladov
2efdf41bdb make macro a NameOwner 2019-02-11 19:24:13 +03:00
Florian Diebold
f1afc93353 Fix handling of literal patterns
Wrap them in a LiteralPat node so they can be distinguished from literal
expressions.
2019-02-09 21:37:30 +01:00
Aleksey Kladov
12e3b4c70b reformat the world 2019-02-08 14:49:43 +03:00
Florian Diebold
e163c908ac Add AST for extern crate
Also change it to parse the crate name as a NAME_REF, not a NAME.
2019-02-04 21:49:34 +01:00
DJMcNab
7417c0775b Fix number of extern_inner_attributes 2019-02-02 16:18:12 +00:00
bors[bot]
97ade89993 Merge #692
692: [WIP] Correctly parse attributes  r=matklad a=DJMcNab

Reference - https://doc.rust-lang.org/reference/attributes.html
This fixes/investigates inner attributes for:

- [x] `impl` blocks
- [x] `extern` blocks
- [x] `fn`s (fixes #689)
- [x] `mod`s (already supported)
- [x] 'block expressions' (the long text just describes all 'blocks' used as statements)

This also investigates/fixes outer attributes for:

- [ ] 'most statements' (see also: #685, https://doc.rust-lang.org/reference/expressions.html#expression-attributes)
- [x] Enum variants, Struct and Union fields (Fixed in #507)
- [ ] 'Match expression arms' (@matklad can you provide a test case which explains what this means?)
- [ ] 'Generic lifetime or type parameters'
- [ ] 'Elements of array expressions, tuple expressions, call expressions, tuple-style struct and enum variant expressions'
- [ ] 'The tail expression of block expressions'

Co-authored-by: DJMcNab <36049421+djmcnab@users.noreply.github.com>
2019-01-31 07:06:31 +00:00
Marcus Klaas de Vries
3daca3eb4d Infer type of match guard 2019-01-28 23:09:14 +01:00
DJMcNab
00e6b5d26c Parse and validate attributes in blocks 2019-01-28 20:03:56 +00:00
DJMcNab
137b1ccb71 Add a test for inner attributes on extern blocks 2019-01-27 15:20:36 +00:00
DJMcNab
73b075c556 Correctly parse inner attributes of impl blocks 2019-01-27 14:55:03 +00:00
DJMcNab
7055d43c3a Make attrs be a child of the let statement 2019-01-26 22:02:23 +00:00
DJMcNab
55a3e21ac4 Support attributes on let statements 2019-01-26 21:35:03 +00:00
DJMcNab
7a76433c45 Struct literals should not be a BlockLike::Block 2019-01-26 18:45:29 +00:00
bors[bot]
2acaa92c93 Merge #660
660: Support macro calls in type position r=matklad a=regiontog

A [playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=fdc6dd4ddaece92a72fa2a292b75e27c) demonstrating the syntax in question.

Co-authored-by: Erlend Tobiassen <erlend.tobiassen@gmail.com>
2019-01-26 10:23:28 +00:00
Erlend Tobiassen
e28bd099d6
Support macro calls in type position 2019-01-25 23:56:31 +01:00
Aleksey Kladov
23172a116c rename POS_FIELD -> POS_FIELD_DEF
to match NAMED_FIELD_DEF
2019-01-26 00:24:12 +03:00
DJMcNab
4899e7be76 Support universal function call syntax in function calls 2019-01-24 21:19:16 +00:00
Josh Robson Chase
2ffea72f74 More correct raw ident handling 2019-01-23 13:57:17 -05:00
Josh Robson Chase
3b70acad01 Use IDENT for both raw and normal idents 2019-01-23 13:19:49 -05:00
Josh Robson Chase
1cd6d6539a Add raw idents to lexer and parser 2019-01-23 13:17:41 -05:00
Erlend Tobiassen
c550c6759d
Add test for placeholder parameters in trait fn defs 2019-01-22 18:46:15 +01:00
Erlend Tobiassen
8198cde13b
Update tests after allowing where predicate to accept types 2019-01-22 14:32:23 +01:00
Marcus Klaas de Vries
fa43ef30f4 Change parsing of struct field patterns 2019-01-19 15:37:26 +03:00
Marcus Klaas de Vries
bcbfa2cc11 Finish move of StructField for pattern type inference 2019-01-19 15:37:26 +03:00
DJMcNab
0b9e462ab0 Fix handling of attributes in positional field lists 2019-01-12 15:42:12 +00:00
DJMcNab
afdb569902 Fix handling of where clauses in tuple structs 2019-01-10 18:21:01 +00:00
Aleksey Kladov
d91a98ec84 switch ra_syntax to new rowan API 2019-01-08 11:20:15 +03:00
Florian Diebold
bb029cd29b Rename traits::impl_item -> impl_block as well, as well as the tests 2019-01-04 19:15:15 +01:00
Florian Diebold
fe6c4115f6 Rename ImplItem to ImplBlock
rustc uses the name ImplItem for items in impls, not the impl {} block itself,
which could lead to confusion.
2019-01-04 18:28:36 +01:00
csmoe
8a6d6ac132 add mod doc comment test 2019-01-04 21:28:09 +08:00
DJMcNab
0ddeb3b824 Fix the same bug as #396 but for bytes too 2019-01-01 12:10:21 +00:00
DJMcNab
72ab6f7727 Fix the panic found whilst fuzzing 2018-12-31 23:02:04 +00:00
bors[bot]
c0d1b17a4e Merge #366
366: parse minus before number literal pattern r=matklad a=csmoe

r?@matklad

![unknown](https://user-images.githubusercontent.com/35686186/50547871-d5449e00-0c7d-11e9-9ff5-1031e78019de.png)


Co-authored-by: csmoe <csmoe@msn.com>
2018-12-30 16:40:16 +00:00
csmoe
53c94e3ad8 parse minus before number literal 2018-12-30 23:25:07 +08:00
DJMcNab
b67a4e7a57 Add fuzz failure to the fuzz-failures directory 2018-12-29 12:45:48 +00:00
Aleksey Kladov
49b0fe20ab fix suffix ranges 2018-12-27 15:10:30 +03:00
Florian Diebold
0d724ea572 Improve parsing of incomplete field accesses in preparation for field completion
We need to be able to get the receiver even if there is no field name yet, and
currently "a." wouldn't get parsed as a field name at all. This seems to help.
2018-12-25 15:16:42 +01:00
Florian Diebold
515c3bc59b Cleanup 2018-12-23 13:48:04 +01:00
Florian Diebold
7348f7883f Add testing infrastructure for type inference
- move dir_tests to test_utils for that.
2018-12-23 13:48:04 +01:00
DJMcNab
1dffbe5c37 Remove TODO on self_hosting_parsing
This improving this code is not a good use of people-time, and this
might be the most performant approach nonwithstanding
an api for this use case being added to walkdir
2018-12-21 22:44:31 +00:00
DJMcNab
bd5a358910 Fix where clauses using fully qualified path syntax 2018-12-21 17:20:38 +00:00
DJMcNab
9beee92500 Add comment about the source of the weird_exprs test 2018-12-21 10:03:02 +00:00
DJMcNab
da6be9fdda Add weird_exprs test 2018-12-20 19:47:29 +00:00
DJMcNab
a349db7178 Run gen-tests 2018-12-20 19:10:37 +00:00
DJMcNab
134fe4f566 Fix the tests and fix the precommit hook 2018-12-20 16:45:54 +00:00
DJMcNab
63ca8bc91a Change parser tests dir to inline/ok and inline/err 2018-12-20 15:09:22 +00:00
DJMcNab
e2a7e94518 Ensure that the parser tests pass or fail correctly 2018-12-20 13:33:00 +00:00
DJMcNab
5205c016e9 Fix ambiguity with if break
Brought up by #290
2018-12-20 11:35:02 +00:00
DJMcNab
a3b842fb8b Add tests and only traverse in the crates directory 2018-12-19 21:19:32 +00:00
DJMcNab
db67741430 Move is_block to lower in the call tree 2018-12-19 20:55:24 +00:00
DJMcNab
def0a95d35 Revert "Revert to f6f7c5"
This approach is correct, but it needs an addition to Restrictions too

This reverts commit ad00d0c8a5f64142e6636e8b048204c8f8982f4a.
2018-12-19 20:12:18 +00:00
DJMcNab
cd8e33fb7e Revert to f6f7c5 2018-12-19 20:12:18 +00:00
DJMcNab
7a8560ba38 Fix expression parsing by bailing out upon a macro block being found
TODO: Fix this when the block like macro is in expression position

E.g. `test(test!{})` currently parses
2018-12-19 20:12:18 +00:00
DJMcNab
20bbe0127c Fix parsing of inclusive ranges (#214)
I'm not certain that this is correct, so extra eyes would be good
2018-12-19 20:12:18 +00:00
DJMcNab
0b77eec922 Add a test to ensure that we can parse each file
Note that this has a non-spurious failure in ra_analysis/src/mock_analysis
2018-12-19 20:12:18 +00:00
Roland Ruckerbauer
d0f1334226 Fixed cast expression parsing in ra_syntax.
The cast expression expected any type via types::type_() function,
but the language spec does only allow TypeNoBounds (types without direct extra bounds
via `+`).

**Example:**

```rust
fn test() {
	6i8 as i32 + 5;
}
```

This fails, because the types::type_() function which should parse the type after the
as keyword is greedy, and takes all plus sign after path types as extra.

My proposed fix is to replace the not implemented `type_no_plus()` just calls (`type_()`)
function, which is used at several places. The replacement is `type_with_bounds_cond(p: &mut Parser, allow_bounds: bool)`, which passes the condition to relevant sub-parsers.

This function is then called by `type_()` and the new public `type_no_bounds()`.
2018-12-17 17:26:24 +01:00
Bernardo
0527e3b283 rename Edit to TextEdit and AtomEdit to AtomTextEdit 2018-12-11 19:07:17 +01:00
DJMcNab
455ef940fe Update use path test 2018-12-05 22:08:00 +00:00
DJMcNab
0a82d768c4 Improve/add the use_item documentation 2018-12-05 21:43:40 +00:00
Aleksey Kladov
2ed1514df3 rename ROOT -> SOURCE_FILE 2018-11-07 18:42:36 +03:00
Aleksey Kladov
f8b36bbc3b Rename File -> SourceFileNode 2018-11-07 18:42:36 +03:00
Aleksey Kladov
ec131b6c7b grammar: fix where clause parsing
closes #205
2018-11-06 21:19:32 +03:00
Aleksey Kladov
9010cb9839 grammar: for predicates in where
closes #191
2018-11-05 11:24:08 +03:00
Jeremy A. Kolb
61f3a438d3 Cargo Format
Run `cargo fmt` and ignore generated files
2018-10-16 09:41:10 -04:00
Aleksey Kladov
376639c70f Parse crate paths in expressions 2018-10-15 20:52:56 +03:00
Aleksey Kladov
a05e09e9c5 Attach comments smartly 2018-10-08 17:36:38 +03:00
Daniel McNab
a55ef9b3ed Support leading pipe in match arms 2018-10-03 21:47:03 +01:00
Aleksey Kladov
baaf027da0 support 2018 paths 2018-09-29 14:53:23 +03:00
csmoe
8b710e9535 generate testsuite for impl_type 2018-09-26 16:53:16 +08:00
csmoe
edf1cc3582 parse impl type 2018-09-25 22:21:16 +08:00
csmoe
e446316585 add test for impl recovery 2018-09-24 11:44:43 +08:00
Aleksey Kladov
b5021411a8 rename all things 2018-09-16 13:07:39 +03:00