Commit Graph

232 Commits

Author SHA1 Message Date
Aleksey Kladov 359d3be308 Fix parsing of blocks without { 2020-05-02 14:35:17 +02:00
Aleksey Kladov 623faefcda Cleanup inline tests 2020-05-02 11:21:39 +02:00
Aleksey Kladov 4f2134cc33 Introduce EffectExpr 2020-05-02 11:21:39 +02:00
Aleksey Kladov fd030f9450 Revert "Merge #4233"
This reverts commit a5f2b16366, reversing
changes made to c96b2180c1.
2020-05-02 01:12:37 +02:00
Aleksey Kladov 292ba6a1f8 Remove dead code, which elaborately pretends to be alive 2020-04-30 22:41:14 +02:00
bors[bot] 745bd45ddb Merge #4227
4227: Report invalid, nested, multi-segment crate-paths r=matklad a=djrenren

There was a bug in the previous path-validating code that didn't detect multi-segment paths that started with `crate`.

```rust
// Successfully reported
use foo::{crate};

// BUG: was not being reported
use foo::{crate::bar};
```

This was due to my confusion about path-associativity. That is, the path with no qualifier is the innermost path, not the outermost. I've updated the code with a lot of comments to explain what's going on. 

This bug was discovered when I found an erroneous `ok` test which I reported here: 
https://github.com/rust-analyzer/rust-analyzer/issues/4226

This test now fails and has been modified, hopefully in the spirit of the original test, to be correct.  Sorry about submitting the bug in the first place!

Co-authored-by: John Renner <john@jrenner.net>
2020-04-30 18:37:35 +00:00
John Renner 513a3615f6 Report invalid, nested, multi-segment crate-paths
Specifically, things like:

use foo::{crate::bar};

Are now being caught, when before we only caught:

use foo::{crate};
2020-04-30 11:16:09 -07:00
Edwin Cheng 45c4f620b1 Special-case try macro_rules 2020-04-30 22:07:46 +08:00
Aleksey Kladov c51c8bfb84 Special-case try macro to better support 2015 edition 2020-04-30 14:17:14 +02:00
Aleksey Kladov 5e5eb6a108 Align grammar for record patterns and literals
The grammar now looks like this

   [name_ref :] pat
2020-04-12 00:00:15 +02:00
Aleksey Kladov 6b49e774e2 Remove dead code 2020-04-11 23:08:05 +02:00
Aleksey Kladov 7a39bc3ba2 Make records grammar more orthogonal
We used

  name [: expr]

grammar before, now it is

  [name :] expr

which makes things simpler
2020-04-11 19:20:41 +02:00
Aleksey Kladov 5c5bde47fb Rename some tokens 2020-04-10 17:07:09 +02:00
Aleksey Kladov 8d71a6bf0c Scale token generation back 2020-04-10 16:10:28 +02:00
Luca Barbieri 74e3b48806 Parse correctly fn f<T>() where T: Fn() -> u8 + Send {}
We used to parse it as T: Fn() -> (u8 + Send), which is different from
the rustc behavior of T: (Fn() -> u8) + Send
2020-04-09 13:05:41 +02:00
Luca Barbieri 60f4d7bd8c Provide more complete AST accessors to support usage in rustc 2020-04-09 11:50:37 +02:00
Edwin Cheng 53d05448c1 Add L_DOLLAR for TYPE_RECOVERY_SET 2020-04-08 18:34:20 +08:00
Aleksey Kladov da8eb29a2f Macro patterns are not confused with expressions.
We treat macro calls as expressions (there's appropriate Into impl),
which causes problem if there's expresison and non-expression macro in
the same node (like in the match arm).

We fix this problem by nesting macor patterns into another node (the
same way we nest path into PathExpr or PathPat). Ideally, we probably
should add a similar nesting for macro expressions, but that needs
some careful thinking about macros in blocks: `{ am_i_expression!() }`.
2020-04-03 16:12:38 +02:00
Aleksey Kladov 0e46ed8420 Cleanups 2020-04-03 15:44:06 +02:00
Aleksey Kladov f6188caaa0 Fix parsing lambdas with return type
We should eat only a single block, and not whatever larger expression
may start with a block.

closes #3721
2020-03-25 17:01:28 +01:00
Aleksey Kladov 89694ec8f6 Support arbitrary discriminants
Closes #3661
2020-03-20 08:50:34 +01:00
Florian Diebold e6ec4a329f Better fix for stuck parser? 2020-03-16 18:38:19 +01:00
Florian Diebold c32529ddd0 Get tests working 2020-03-16 18:38:19 +01:00
Aleksey Kladov bee5cdb359 Parse variadics correctly
closes #3571
2020-03-13 13:54:14 +01:00
Aleksey Kladov 1e19847af3 Move verbose tests out of line 2020-03-13 12:20:42 +01:00
Aleksey Kladov 4a745cc8cf Fix parsing of stement-ish binary expressions
closes #3512
2020-03-11 14:28:18 +01:00
Edwin Cheng 1465cc0c4f Implement concat macro 2020-03-04 01:21:14 +08:00
Aleksey Kladov a1e1869554 Rename ast::ImplBlock -> ast::ImplDef 2020-02-29 21:33:15 +01:00
Edwin Cheng f4e48ad3e4 Parse attr in rhs of let stmts 2020-02-28 13:08:47 +08:00
Veetaha 59dc797eb3 Fix dat comment 2020-02-22 14:16:13 +02:00
Kirill Bulatov eceaf94f19 More manual clippy fixes 2020-02-18 16:12:37 +02:00
Kirill Bulatov b8ddcb0652 Run cargo +nightly fix --clippy -Z unstable-options 2020-02-18 16:03:08 +02:00
Han Mertens b435fe8b77 Add test for unnamed argument in function pointer 2020-02-12 22:55:37 +01:00
Han Mertens 0e10e77a78 Support unnamed arguments in function pointers
Fixes #3089
2020-02-12 21:40:05 +01:00
Matthew Jasper 49b53cd7a0 Address review comments 2020-02-10 20:11:44 +00:00
Matthew Jasper 8c8d0bb34f Add or- and parenthesized-patterns 2020-02-09 22:06:15 +00: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
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
Toby Dimmick 90ff2be4e8 PR tweaks 2020-02-07 12:36:33 +00:00
Toby Dimmick 0183952d2e Closure params test 2020-02-06 20:39:27 +00:00
Toby Dimmick e1921ea59c rustfmt 2020-02-06 20:04:35 +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
Veetaha 3ec781d4f2 ra_syntax: remove code duplication and token reevaluation from ast::Literal::kind() 2020-01-22 13:02:21 +02: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
bors[bot] ea2b27d8b9 Merge #2865
2865: fix(mixed): fixed a couple of typos and added a todo r=kjeremy a=Veetaha

Fixed a couple of typos and added a todo while studying the codebase.

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-01-17 02:20:16 +00:00
Aleksey Kladov 5398b9eeba Minimize test 2020-01-16 18:39:29 +01:00