Commit graph

264 commits

Author SHA1 Message Date
Daniel Eades
aa90d02079 remove useless operations 2023-01-02 15:02:54 +00:00
Daniel Eades
0a0817905e return value directly from if/else block 2023-01-02 15:02:54 +00:00
Maybe Waffle
4a16afa264 Parse do yeet expressions 2022-12-28 22:42:26 +00:00
Yuri Astrakhan
d3dbf9c194 Moar linting: needless_borrow, let_unit_value, ...
* There are a few needless borrows that don't seem to be needed. I even did a quick assembly comparison and posted a q to stackoveflow on it. See [here](https://stackoverflow.com/questions/74910196/advantages-of-pass-by-ref-val-with-impl-intoiteratoritem-impl-asrefstr)
* removed several `let _ = ...` when they don't look necessary (even a few ones that were not suggested by clippy (?))
* there were a few `then(|| ctor{})` that clippy suggested to replace with `then_some(ctor{})` -- seems reasonable?
* some unneeded assignment+return - keep the code a bit leaner
* a few `writeln!` instead of `write!`, or even consolidate write!
* a nice optimization to use `ch.is_ascii_digit` instead of `ch.is_digit(10)`
2022-12-25 05:07:47 -05:00
Yuri Astrakhan
e16c76e3c3 Inline all format arguments where possible
This makes code more readale and concise,
moving all format arguments like `format!("{}", foo)`
into the more compact `format!("{foo}")` form.

The change was automatically created with, so there are far less change
of an accidental typo.

```
cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2022-12-24 14:36:10 -05:00
Yuri Astrakhan
1d59c7b667 Remove non-needed clones
I am not certain if this will improve performance,
but it seems having a .clone() without any need should be removed.

This was done with clippy, and manually reviewed:

```
cargo clippy --fix -- -A clippy::all -D clippy::redundant_clone
```
2022-12-23 02:20:03 -05:00
Jonas Schievink
c110481dd4 Reset parser step count when bumping 2022-12-19 16:27:00 +01:00
Dezhi Wu
258e532434 docs: update the comment and add a test to half_open_range_pat 2022-12-16 10:44:25 +08:00
Dezhi Wu
6a295fcd3b fix: add a check for if token in patterns parser
Closes #13776
2022-12-15 12:46:02 +08:00
Jonas Schievink
9e0aaf4cf3 Parse ..= X patterns 2022-12-13 17:32:25 +01:00
Jonas Schievink
ed48bd8b9d Fix parsing of _ = x in closure body 2022-12-12 12:57:29 +01:00
Lukas Wirth
ffd7bf8bf9 Bump Cargo rust-version fields to latest stable 2022-11-07 12:59:51 +01:00
bors
93c52e41ec Auto merge of #13160 - ChayimFriedman2:parse-parenthesized-type-path-with-coloncolon, r=jonas-schievink
fix: Parse TypePathFn with preceding `::`

e.g. `impl Fn::() -> ()`.

Fixes #13157. This was the problem, not that the path was not at the end.

I could unify the parsing of `::` of TypePathFn with that of generic arg list, but some code relies on the `::` of generic arg list to be inside it.
2022-09-01 21:00:14 +00:00
Chayim Refael Friedman
d786a40e73 Parse TypePathFn with preceding ::
e.g. `impl Fn::() -> ()`.
2022-08-31 23:19:09 +00:00
bors
d9e22079c4 Auto merge of #12963 - DesmondWillowbrook:clippy-matches-sourcegen, r=Veykril
clippy: make generated code nice to read

Feel free to close if this is too minor.

(For context, I _have_ read the clippy policy in `dev/style.md`)
2022-08-31 08:37:14 +00:00
Jonas Schievink
8969655ed6 Allow leading | in more pattern positions 2022-08-23 16:31:59 +02:00
Lukas Wirth
49d24f639f Recover from missing ellipsis in record literals for path expressions 2022-08-09 18:23:25 +02:00
Ryo Yoshida
b14062aaec
Parse range patterns in let statement with type annotation 2022-08-09 00:00:22 +09:00
Kartavya Vashishtha
bcab4be938
regenerate files with new syntax 2022-08-07 17:38:20 +05:30
Ryo Yoshida
a81c7a2974
Parse range patterns in struct and slice without trailing comma 2022-08-07 17:19:15 +09:00
cynecx
902fd6ddcd fix: complete path of existing record expr 2022-07-29 17:24:05 +02:00
Amos Wenger
7e285e1ef5 Run cargo fmt 2022-07-20 15:06:15 +02:00
Amos Wenger
816f7fe12a Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
Amos Wenger
23d25a3094 Enable extra warnings required by rust-lang/rust 2022-07-20 15:00:17 +02:00
Amos Wenger
1b416473a3 Upgrade to expect-test@1.4.0
cf. https://github.com/rust-analyzer/expect-test/issues/33
cf. https://github.com/rust-lang/rust/pull/99444#issuecomment-1188844202
2022-07-19 13:00:45 +02:00
Jonas Schievink
6c6ae965ba Update remaining GitHub URLs 2022-07-08 15:44:49 +02:00
Lukas Wirth
76ae5434fa internal: Bump Dependencies 2022-06-10 17:30:02 +02:00
XFFXFF
df67bbdcb3 fix: parsing of ? opt-out trait bounds
thanks to Veykril
2022-06-02 21:30:18 +08:00
Jonas Schievink
9bd11459ba Revert "Auto merge of #12149 - jonas-schievink:literally-just-a-literal, r=jonas-schievink"
This reverts commit cc9ae2b89e, reversing
changes made to 7dfd1cb572.
2022-05-13 15:08:14 +02:00
Jonas Schievink
4fcdb96789 Revert "fix: Remap float parts as integers when parsed as indices"
This reverts commit dbb066b99e.
2022-05-13 15:05:03 +02:00
Jonas Schievink
73e0e17b52 Revert "Don't remap float tokens to INT_NUMBER"
This reverts commit cb5e8da88a.
2022-05-13 15:04:36 +02:00
Jonas Schievink
cb5e8da88a Don't remap float tokens to INT_NUMBER 2022-05-12 19:01:09 +02:00
Lukas Wirth
dbb066b99e fix: Remap float parts as integers when parsed as indices 2022-05-07 12:52:15 +02:00
Jonas Schievink
37443eb9a1 Maybe everything else *should* have to deal with it 2022-05-05 16:28:59 +02:00
Jonas Schievink
2fe38d3b63 Indicate the number of float tokens in the first token 2022-05-05 16:28:59 +02:00
Jonas Schievink
34dc8e9383 Wrap floats in token trees in FLOAT_LITERAL node 2022-05-05 16:28:59 +02:00
Jonas Schievink
2a755495d0 Add tests 2022-05-05 16:28:59 +02:00
Jonas Schievink
1bc3305d95 Split float literal tokens at the . 2022-05-05 16:28:58 +02:00
Jonas Schievink
502c519e7d Wrap float literals in their own node 2022-05-05 16:28:14 +02:00
Jonas Schievink
1f50e19eb2 Add a Converter type for token conversion 2022-05-02 17:47:12 +02:00
Lukas Wirth
e2344e78f3 fix: Use pattern recovery set when parsing ident patterns 2022-04-27 19:08:50 +02:00
XFFXFF
6580d75308 update parser to support associated const equality 2022-04-17 20:26:06 +08:00
Lukas Wirth
d8341c5b92 Parse for<'a> closure syntax 2022-04-10 17:50:14 +02:00
Jonas Schievink
872b7b9660 Wrap macros in expr position in MacroExpr node 2022-04-05 17:43:34 +02:00
hkalbasi
049f0a6d2c recover from missing type annotation 2022-04-01 17:20:54 +04:30
Jonas Schievink
42ecf406e8 Remove parser restriction on varargs positioning 2022-03-31 16:03:27 +02:00
Lukas Wirth
8e91bb7660 minor: Bump dependencies 2022-03-22 17:42:24 +01:00
Steven Joruk
8a28430676 refactor: Rename and move const_arg_path
It wasn't testing the `const_arg` code path, it was actually hitting
const_param's default value code path, so move it to the right place
and rename it.
2022-03-11 22:28:38 +00:00
Steven Joruk
e84453c47f refactor: Rename const_arg_content to const_arg_expr 2022-03-11 22:28:35 +00:00
Steven Joruk
972f50da2d fix: Stop wrapping ConstParam's default values in ConstArg
This was causing ConstParam::default_val to always return None for block
expressions.

CONST_ARG@24..29
  BLOCK_EXPR@24..29
    ...
2022-03-11 19:51:35 +00:00