Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Commit

Permalink
Revert into_node and node() changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Apr 26, 2023
1 parent 5ffa8a1 commit a42e77a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 21 deletions.
18 changes: 0 additions & 18 deletions compiler/ast/asdl_rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,24 +711,6 @@ def write_ast_def(mod, typeinfo, f):
}
}
impl<T, U> std::ops::Deref for Located<T, U> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.node
}
pub const fn start(&self) -> Location {
self.location
}
/// Returns the node's [`end_location`](Located::end_location) or [`location`](Located::start) if
/// [`end_location`](Located::end_location) is `None`.
pub fn end(&self) -> Location {
self.end_location.unwrap_or(self.location)
}
}
impl<T, U> std::ops::Deref for Located<T, U> {
type Target = T;
Expand Down
4 changes: 2 additions & 2 deletions compiler/parser/python.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ ClosedPattern: ast::Pattern = {

SequencePattern: ast::PatternKind = {
// A single-item tuple is a special case: it's a group pattern, _not_ a sequence pattern.
<location:@L> "(" <pattern:Pattern> ")" <end_location:@R> => pattern.into_node(),
<location:@L> "(" <pattern:Pattern> ")" <end_location:@R> => pattern.node,
<location:@L> "(" ")" <end_location:@R> => ast::PatternKind::MatchSequence {
patterns: vec![],
},
Expand Down Expand Up @@ -1554,7 +1554,7 @@ Atom<Goal>: ast::Expr = {
},
<location:@L> "(" <left:(<OneOrMore<Test<"all">>> ",")?> <mid:NamedOrStarExpr> <right:("," <TestOrStarNamedExpr>)*> <trailing_comma:","?> ")" <end_location:@R> =>? {
if left.is_none() && right.is_empty() && trailing_comma.is_none() {
if matches!(mid.node(), ast::ExprKind::Starred { .. }) {
if matches!(mid.node, ast::ExprKind::Starred { .. }) {
Err(LexicalError{
error: LexicalErrorType::OtherError("cannot use starred expression here".to_string()),
location: mid.start(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/parser/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub(crate) fn parse_args(func_args: Vec<FunctionArgument>) -> Result<ArgumentLis

// Check if an expression is a starred expression.
fn is_starred(exp: &ast::Expr) -> bool {
matches!(exp.node(), ast::ExprKind::Starred { .. })
matches!(exp.node, ast::ExprKind::Starred { .. })
}

#[cfg(test)]
Expand Down

0 comments on commit a42e77a

Please sign in to comment.