Nicholas Nethercote
8bd1bcad58
Factor out some code into MatcherPos::repetition
.
...
Also move `create_matches` within `impl MatcherPos`, because it's only
used within that impl block.
2022-03-18 14:09:02 +11:00
Nicholas Nethercote
5bbbee5ba7
Add two useful assertions.
2022-03-18 13:57:11 +11:00
Nicholas Nethercote
95d13fa37d
Move a parse_tt
error case into a separate function.
2022-03-11 14:10:21 +11:00
Nicholas Nethercote
235a87fbd3
Make next_items a SmallVec
.
...
For consistency, and to make the code slightly nicer.
2022-03-11 14:10:21 +11:00
Nicholas Nethercote
c13ca42d67
Move eof_items
handling entirely within inner_parse_loop
.
...
Also rename `inner_parse_loop` as `parse_tt_inner`, because it's no
longer just a loop.
2022-03-11 14:10:21 +11:00
Nicholas Nethercote
9f0798b2eb
Add a useful assertion.
2022-03-11 14:10:21 +11:00
Nicholas Nethercote
4d4baf7c9a
Disallow TokenTree::{MetaVar,MetaVarExpr}
in matchers.
...
They should only appear in transcribers.
2022-03-11 14:10:19 +11:00
Nicholas Nethercote
09c3e82050
Refactor the second half of parse_tt
.
...
The current structure makes it hard to tell that there are just four
distinct code paths, depending on how many items there are in `bb_items`
and `next_items`. This commit introduces a `match` that clarifies
things.
2022-03-11 13:56:54 +11:00
Caio
8073a88f35
Implement macro meta-variable expressions
2022-03-09 16:46:23 -03:00
Matthias Krüger
16c6594f34
Rollup merge of #94547 - nnethercote:parse_tt-cleanups, r=petrochenkov
...
`parse_tt` cleanups
I've been looking closely at this code, and saw some opportunities to improve its readability.
r? ```````@petrochenkov```````
2022-03-03 20:01:45 +01:00
Nicholas Nethercote
97eb1b4669
Change initial_matcher_pos()
into MatcherPos::new()
.
2022-03-03 21:47:02 +11:00
Nicholas Nethercote
e5f3fd6250
Use a better return type for inner_parse_loop
.
...
Because `inner_parse_loop` has only one way to not succeed, not three.
2022-03-03 21:46:59 +11:00
Nicholas Nethercote
643ba50004
Introduce MatcherPosRepetition
.
...
There are three `Option` fields in `MatcherPos` that are only used in
tandem. This commit combines them, making the code slightly easier to
read. (It also makes clear that the `sep` field arguably should have
been `Option<Option<Token>>`!)
2022-03-03 21:45:52 +11:00
Nicholas Nethercote
b9fabc3f9c
Add a static size assertion for MatcherPos
.
2022-03-03 21:45:45 +11:00
Nicholas Nethercote
11c565f14b
Improve if/else formatting in macro_parser.rs.
...
To avoid the strange style where comments force `else` onto its own
line.
The commit also removes several else-after-return constructs, which can
be hard to read.
2022-03-03 21:45:42 +11:00
mark
88b99224c1
add some examples to comments in mbe code
2022-03-02 21:33:43 -06:00
Mark Rousskov
971c549ca3
re-format with new rustfmt
2021-11-30 13:08:41 -05:00
Aaron Hill
822f800ad7
Include macro name in 'local ambiguity' error
...
Currently, we only point at the span of the macro argument. When the
macro call is itself generated by another macro, this can make it
difficult or impossible to determine which macro is responsible for
producing the error.
2021-06-07 20:17:48 -05:00
LingMan
a56bffb4f9
Use Option::map_or instead of .map(..).unwrap_or(..)
2021-01-14 19:23:59 +01:00
mark
40bf3c0f09
Implement edition-based macro pat feature
2020-12-30 09:57:49 -06:00
Wesley Wiser
f1eb88b28a
Revert "Promote missing_fragment_specifier to hard error"
...
This reverts commit 02eae432e7
.
2020-12-22 09:33:16 -05:00
mark
1a7d00a529
implement edition-specific :pat behavior for 2015/18
2020-12-19 07:13:36 -06:00
Camelid
bec1c278b6
Remove docs for non-existent parameters in rustc_expand
2020-12-16 17:34:47 -08:00
mark
9e5f7d5631
mv compiler to compiler/
2020-08-30 18:45:07 +03:00