Commit Graph

155 Commits

Author SHA1 Message Date
Aleksey Kladov
5a6db3ca29 fix parsing of for loops inside expressions
closes #2051
2019-10-28 15:41:34 +03: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
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
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
71efdaa636
Parse correct AttrInput 2019-09-30 16:11:40 +08:00
Aleksey Kladov
d847d53e36 Start simplifying editing API 2019-09-26 22:22:08 +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
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
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
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
kjeremy
883edd002e Replace usages of bump_any with bump 2019-09-19 15:51:46 -04: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
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
253a18f938 Allow an underscore as the identifier in const items 2019-09-14 16:31:09 -07: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
Aleksey Kladov
b9d9db83d1 cleanup dollar handling in expressions 2019-09-10 21:28:27 +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
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
Aleksey Kladov
7910202ecd tiny simplification 2019-09-09 13:23:41 +03:00
Aleksey Kladov
b2be998b7b better error recovery for use trees 2019-09-05 19:53:07 +03:00
Aleksey Kladov
3c2dea7f55 always wrap block into an expression 2019-09-02 20:15:51 +03:00
Aleksey Kladov
c89abd4262 simplify 2019-09-02 18:58:21 +03:00
Aleksey Kladov
32bebfaf0e cleanup 2019-09-02 17:37:48 +03:00
Dylan MacKenzie
c08ad1cf8a Handle Struct { box i } syntax
Named structs can have `box` patterns that will bind to their fields.
This is similar to the behavior of the `ref` and `mut` fields, but is at
least a little bit surprising.
2019-08-23 16:20:18 -07:00
Dylan MacKenzie
83433cd1f0 Centralize box pattern tests in patterns.rs 2019-08-23 16:19:53 -07:00
Dylan MacKenzie
ab51f57e1d Parse BoxPat 2019-08-23 16:07:11 -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
Dylan MacKenzie
3e14b16c4d Add test for nested box pattern 2019-08-22 12:53:54 -07:00
Dylan MacKenzie
f3b320adf4 Add BOX_KW to PATTERN_FIRST 2019-08-22 12:33:03 -07:00
Aleksey Kladov
00ccc6c292 use derive(Debug) for SyntaxKind 2019-08-19 13:11:51 +03:00
Aleksey Kladov
038975b348 plug new boilerplate_gen into ra_tools 2019-08-19 12:26:34 +03:00
Aleksey Kladov
832b40a075 use new quote-generated syntax kinds 2019-08-19 11:42:39 +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
2bebdf0b37 fix error of RangeFrom in for-loop 2019-08-14 11:55:21 +08:00
Evgenii P
8222a1fddf Fix is_path_start to accept T![<], fix is_path_start usages 2019-08-13 22:36:01 +07:00