Skip to content

Rollup of 8 pull requests #94571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Mar 4, 2022
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
55f938b
update docs for `simplify_type`
lcnr Feb 21, 2022
ba2e0ca
typo
lcnr Feb 21, 2022
bac5523
Use cgroup quotas for calculating `available_parallelism`
the8472 Jan 9, 2022
af6d2ed
hardcode /sys/fs/cgroup instead of doing a lookup via mountinfo
the8472 Mar 2, 2022
e18abbf
update available_parallelism docs since cgroups and sched_getaffinity…
the8472 Mar 2, 2022
37c1eb0
Doc: Fix use of quote instead of backstick in Adapter::map.
darnuria Mar 3, 2022
e3f04de
Add test for higher kinded functions generated by macros
GuillaumeGomez Mar 3, 2022
11c565f
Improve if/else formatting in macro_parser.rs.
nnethercote Mar 3, 2022
b9fabc3
Add a static size assertion for `MatcherPos`.
nnethercote Mar 3, 2022
643ba50
Introduce `MatcherPosRepetition`.
nnethercote Mar 3, 2022
e5f3fd6
Use a better return type for `inner_parse_loop`.
nnethercote Mar 3, 2022
97eb1b4
Change `initial_matcher_pos()` into `MatcherPos::new()`.
nnethercote Mar 3, 2022
5164884
Fix invalid lint_node_id being put on a removed stmt
Urgau Mar 3, 2022
00fffdd
all: fix some typos
cuishuang Mar 3, 2022
ff19c05
remove a unnecessary `..` pattern
TaKO8Ki Mar 3, 2022
a638f50
Rollup merge of #92697 - the8472:cgroups, r=joshtriplett
matthiaskrgr Mar 3, 2022
fec7a79
Rollup merge of #94057 - lcnr:simplify_type-uwu, r=nikomatsakis
matthiaskrgr Mar 3, 2022
16c6594
Rollup merge of #94547 - nnethercote:parse_tt-cleanups, r=petrochenkov
matthiaskrgr Mar 3, 2022
835eaaa
Rollup merge of #94550 - GuillaumeGomez:HKF-macros, r=notriddle
matthiaskrgr Mar 3, 2022
40c146c
Rollup merge of #94551 - darnuria:doc-map-backstick, r=dtolnay
matthiaskrgr Mar 3, 2022
26cbf91
Rollup merge of #94554 - Urgau:stmt-node-id-ice, r=petrochenkov
matthiaskrgr Mar 3, 2022
939c158
Rollup merge of #94555 - cuishuang:master, r=oli-obk
matthiaskrgr Mar 3, 2022
cfa58df
Rollup merge of #94563 - TaKO8Ki:remove-unnecessary-patten-for-ignori…
matthiaskrgr Mar 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change initial_matcher_pos() into MatcherPos::new().
  • Loading branch information
nnethercote committed Mar 3, 2022
commit 97eb1b4669b893bf01cbc362e82ee10cfe8aff1c
58 changes: 29 additions & 29 deletions compiler/rustc_expand/src/mbe/macro_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ type NamedMatchVec = SmallVec<[NamedMatch; 4]>;
/// lifetime. By separating `'tt` from `'root`, we can show that.
#[derive(Clone)]
struct MatcherPos<'root, 'tt> {
/// The token or sequence of tokens that make up the matcher
/// The token or sequence of tokens that make up the matcher. `elts` is short for "elements".
top_elts: TokenTreeOrTokenTreeSlice<'tt>,

/// The position of the "dot" in this matcher
Expand Down Expand Up @@ -203,6 +203,33 @@ struct MatcherPos<'root, 'tt> {
rustc_data_structures::static_assert_size!(MatcherPos<'_, '_>, 192);

impl<'root, 'tt> MatcherPos<'root, 'tt> {
/// Generates the top-level matcher position in which the "dot" is before the first token of
/// the matcher `ms`.
fn new(ms: &'tt [TokenTree]) -> Self {
let match_idx_hi = count_names(ms);
MatcherPos {
// Start with the top level matcher given to us.
top_elts: TtSeq(ms),

// The "dot" is before the first token of the matcher.
idx: 0,

// Initialize `matches` to a bunch of empty `Vec`s -- one for each metavar in
// `top_elts`. `match_lo` for `top_elts` is 0 and `match_hi` is `match_idx_hi`.
// `match_cur` is 0 since we haven't actually matched anything yet.
matches: create_matches(match_idx_hi),
match_lo: 0,
match_cur: 0,
match_hi: match_idx_hi,

// Haven't descended into any delimiters, so this is empty.
stack: smallvec![],

// Haven't descended into any sequences, so this is `None`.
repetition: None,
}
}

/// Adds `m` as a named match for the `idx`-th metavar.
fn push_match(&mut self, idx: usize, m: NamedMatch) {
let matches = Lrc::make_mut(&mut self.matches[idx]);
Expand Down Expand Up @@ -314,33 +341,6 @@ fn create_matches(len: usize) -> Box<[Lrc<NamedMatchVec>]> {
.into_boxed_slice()
}

/// Generates the top-level matcher position in which the "dot" is before the first token of the
/// matcher `ms`.
fn initial_matcher_pos<'root, 'tt>(ms: &'tt [TokenTree]) -> MatcherPos<'root, 'tt> {
let match_idx_hi = count_names(ms);
let matches = create_matches(match_idx_hi);
MatcherPos {
// Start with the top level matcher given to us
top_elts: TtSeq(ms), // "elts" is an abbr. for "elements"
// The "dot" is before the first token of the matcher
idx: 0,

// Initialize `matches` to a bunch of empty `Vec`s -- one for each metavar in `top_elts`.
// `match_lo` for `top_elts` is 0 and `match_hi` is `matches.len()`. `match_cur` is 0 since
// we haven't actually matched anything yet.
matches,
match_lo: 0,
match_cur: 0,
match_hi: match_idx_hi,

// Haven't descended into any delimiters, so empty stack
stack: smallvec![],

// Haven't descended into any sequences, so this is `None`.
repetition: None,
}
}

/// `NamedMatch` is a pattern-match result for a single `token::MATCH_NONTERMINAL`:
/// so it is associated with a single ident in a parse, and all
/// `MatchedNonterminal`s in the `NamedMatch` have the same non-terminal type
Expand Down Expand Up @@ -642,7 +642,7 @@ pub(super) fn parse_tt(
//
// This MatcherPos instance is allocated on the stack. All others -- and
// there are frequently *no* others! -- are allocated on the heap.
let mut initial = initial_matcher_pos(ms);
let mut initial = MatcherPos::new(ms);
let mut cur_items = smallvec![MatcherPosHandle::Ref(&mut initial)];
let mut next_items = Vec::new();

Expand Down