Skip to content

refactor: introduce SequenceExpr::word_seq()#3659

Merged
elijah-potter merged 4 commits into
Automattic:masterfrom
hippietrail:sequence-expr-from-words
Jun 15, 2026
Merged

refactor: introduce SequenceExpr::word_seq()#3659
elijah-potter merged 4 commits into
Automattic:masterfrom
hippietrail:sequence-expr-from-words

Conversation

@hippietrail

Copy link
Copy Markdown
Collaborator

Issues

N/A

Description

I thought there was a pattern of linters using sequences of words separated by whitespace and realized a new ctor and builder on SequenceExpr could take an array of just the words and add in the whitespace elements.

It turned out that only one linter used more than two words but there were also a few uses of fixed_phrase that are probably more efficient as word_seq.

Demo

How Has This Been Tested?

cargo test

AI Disclosure

  • I am a human and didn't use any AI.
  • I used LLM features of my editor, but not an agent.
  • I used an AI agent interactively.
  • I am an agent or I got an agent to do the work autonomously.

Checklist

  • I have performed a self-review of my own code
  • I have added tests to cover my changes
  • I have considered splitting this into smaller pull requests.

@elijah-potter elijah-potter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good. Just one nit.

Comment thread harper-core/src/expr/sequence_expr.rs Outdated

/// Match a series of words separated by whitespace.
pub fn then_word_seq(self, words: &'static [&'static str]) -> Self {
debug_assert!(!words.is_empty(), "words must not be empty");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like it should be OK for it to be empty. People may insert an empty array for debugging purposes.

@elijah-potter elijah-potter enabled auto-merge June 15, 2026 17:56
@elijah-potter elijah-potter added this pull request to the merge queue Jun 15, 2026
Merged via the queue into Automattic:master with commit 449184c Jun 15, 2026
12 checks passed
@hippietrail hippietrail deleted the sequence-expr-from-words branch June 16, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants