Skip to content

Commit

Permalink
Appease clippy::match_wildcard_for_single_variants
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Dec 6, 2023
1 parent 05379fc commit 8582d28
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 30 deletions.
17 changes: 8 additions & 9 deletions crates/codegen/parser/runtime/src/cst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub enum Node {
Token(Rc<TokenNode>),
}

#[allow(clippy::match_wildcard_for_single_variants)]
impl Node {
pub fn rule(kind: RuleKind, children: Vec<Self>) -> Self {
let text_len = children.iter().map(Node::text_len).sum();
Expand Down Expand Up @@ -74,29 +73,29 @@ impl Node {

pub fn as_rule(&self) -> Option<&Rc<RuleNode>> {
match self {
Self::Rule(node) => Some(node),
_ => None,
Self::Rule(rule) => Some(rule),
Self::Token(..) => None,
}
}

pub fn into_rule(self) -> Option<Rc<RuleNode>> {
match self {
Self::Rule(node) => Some(node),
_ => None,
Self::Rule(rule) => Some(rule),
Self::Token(..) => None,
}
}

pub fn as_token(&self) -> Option<&Rc<TokenNode>> {
match self {
Self::Token(node) => Some(node),
_ => None,
Self::Token(token) => Some(token),
Self::Rule(..) => None,
}
}

pub fn into_token(self) -> Option<Rc<TokenNode>> {
match self {
Self::Token(node) => Some(node),
_ => None,
Self::Token(token) => Some(token),
Self::Rule(..) => None,
}
}

Expand Down
5 changes: 2 additions & 3 deletions crates/solidity/inputs/language/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,18 @@ enum ParserThunk {
Regular(Rc<NamedParserThunk>),
Precedence(Rc<NamedPrecedenceParserThunk>),
}
#[allow(clippy::match_wildcard_for_single_variants)]
impl ParserThunk {
fn as_regular_def(&self) -> &OnceCell<ParserDefinitionNode> {
match self {
ParserThunk::Regular(thunk) => &thunk.def,
_ => panic!("Expected a regular parser thunk"),
ParserThunk::Precedence(..) => panic!("Expected a regular parser thunk"),
}
}

fn as_precedence_def(&self) -> &OnceCell<PrecedenceParserDefinitionNode> {
match self {
ParserThunk::Precedence(thunk) => &thunk.def,
_ => panic!("Expected a precedence parser thunk"),
ParserThunk::Regular(..) => panic!("Expected a precedence parser thunk"),
}
}
}
Expand Down
17 changes: 8 additions & 9 deletions crates/solidity/outputs/cargo/crate/src/generated/cst.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions crates/solidity/outputs/npm/crate/src/generated/cst.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8582d28

Please sign in to comment.