[committed,045/103] gccrs: Formatting cleanup in HIR lowering pattern

Message ID 20230221120230.596966-46-arthur.cohen@embecosm.com
State Unresolved
Headers
Series [committed,001/103] gccrs: Fix missing dead code analysis ICE on local enum definition |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Arthur Cohen Feb. 21, 2023, 12:01 p.m. UTC
  From: Philip Herron <philip.herron@embecosm.com>

gcc/rust/ChangeLog:

	* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::ASTLoweringPattern):
	Improve formatting.
	(ASTLoweringPattern::translate): Likewise.
	* hir/rust-ast-lower-pattern.h: Likewise.
	* resolve/rust-ast-resolve-expr.h: Likewise.
---
 gcc/rust/hir/rust-ast-lower-pattern.cc   | 18 ++++++++++
 gcc/rust/hir/rust-ast-lower-pattern.h    | 24 ++-----------
 gcc/rust/resolve/rust-ast-resolve-expr.h | 43 ------------------------
 3 files changed, 20 insertions(+), 65 deletions(-)
  

Patch

diff --git a/gcc/rust/hir/rust-ast-lower-pattern.cc b/gcc/rust/hir/rust-ast-lower-pattern.cc
index 37bee38fd83..30a188286c8 100644
--- a/gcc/rust/hir/rust-ast-lower-pattern.cc
+++ b/gcc/rust/hir/rust-ast-lower-pattern.cc
@@ -22,6 +22,24 @@ 
 namespace Rust {
 namespace HIR {
 
+ASTLoweringPattern::ASTLoweringPattern () : translated (nullptr) {}
+
+HIR::Pattern *
+ASTLoweringPattern::translate (AST::Pattern *pattern)
+{
+  ASTLoweringPattern resolver;
+  pattern->accept_vis (resolver);
+
+  rust_assert (resolver.translated != nullptr);
+
+  resolver.mappings->insert_hir_pattern (resolver.translated);
+  resolver.mappings->insert_location (
+    resolver.translated->get_pattern_mappings ().get_hirid (),
+    pattern->get_locus ());
+
+  return resolver.translated;
+}
+
 void
 ASTLoweringPattern::visit (AST::IdentifierPattern &pattern)
 {
diff --git a/gcc/rust/hir/rust-ast-lower-pattern.h b/gcc/rust/hir/rust-ast-lower-pattern.h
index f47699d15ea..8b191d56868 100644
--- a/gcc/rust/hir/rust-ast-lower-pattern.h
+++ b/gcc/rust/hir/rust-ast-lower-pattern.h
@@ -29,39 +29,19 @@  class ASTLoweringPattern : public ASTLoweringBase
   using Rust::HIR::ASTLoweringBase::visit;
 
 public:
-  static HIR::Pattern *translate (AST::Pattern *pattern)
-  {
-    ASTLoweringPattern resolver;
-    pattern->accept_vis (resolver);
-
-    rust_assert (resolver.translated != nullptr);
-
-    resolver.mappings->insert_hir_pattern (resolver.translated);
-    resolver.mappings->insert_location (
-      resolver.translated->get_pattern_mappings ().get_hirid (),
-      pattern->get_locus ());
-
-    return resolver.translated;
-  }
+  static HIR::Pattern *translate (AST::Pattern *pattern);
 
   void visit (AST::IdentifierPattern &pattern) override;
-
   void visit (AST::PathInExpression &pattern) override;
-
   void visit (AST::StructPattern &pattern) override;
-
   void visit (AST::TupleStructPattern &pattern) override;
-
   void visit (AST::WildcardPattern &pattern) override;
-
   void visit (AST::TuplePattern &pattern) override;
-
   void visit (AST::LiteralPattern &pattern) override;
-
   void visit (AST::RangePattern &pattern) override;
 
 private:
-  ASTLoweringPattern () : translated (nullptr) {}
+  ASTLoweringPattern ();
 
   HIR::Pattern *translated;
 };
diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.h b/gcc/rust/resolve/rust-ast-resolve-expr.h
index 57beab700d7..60ae1720811 100644
--- a/gcc/rust/resolve/rust-ast-resolve-expr.h
+++ b/gcc/rust/resolve/rust-ast-resolve-expr.h
@@ -34,89 +34,46 @@  public:
 		  const CanonicalPath &canonical_prefix);
 
   void visit (AST::TupleIndexExpr &expr) override;
-
   void visit (AST::TupleExpr &expr) override;
-
   void visit (AST::PathInExpression &expr) override;
-
   void visit (AST::QualifiedPathInExpression &expr) override;
-
   void visit (AST::ReturnExpr &expr) override;
-
   void visit (AST::CallExpr &expr) override;
-
   void visit (AST::MethodCallExpr &expr) override;
-
   void visit (AST::AssignmentExpr &expr) override;
-
   void visit (AST::IdentifierExpr &expr) override;
-
   void visit (AST::ArithmeticOrLogicalExpr &expr) override;
-
   void visit (AST::CompoundAssignmentExpr &expr) override;
-
   void visit (AST::ComparisonExpr &expr) override;
-
   void visit (AST::LazyBooleanExpr &expr) override;
-
   void visit (AST::NegationExpr &expr) override;
-
   void visit (AST::TypeCastExpr &expr) override;
-
   void visit (AST::IfExpr &expr) override;
-
   void visit (AST::IfExprConseqElse &expr) override;
-
   void visit (AST::IfExprConseqIf &expr) override;
-
   void visit (AST::IfLetExpr &expr) override;
-
   void visit (AST::BlockExpr &expr) override;
-
   void visit (AST::UnsafeBlockExpr &expr) override;
-
   void visit (AST::ArrayElemsValues &elems) override;
-
   void visit (AST::ArrayExpr &expr) override;
-
   void visit (AST::ArrayIndexExpr &expr) override;
-
   void visit (AST::ArrayElemsCopied &elems) override;
-
-  // this this an empty struct constructor like 'S {}'
   void visit (AST::StructExprStruct &struct_expr) override;
-
-  // this this a struct constructor with fields
   void visit (AST::StructExprStructFields &struct_expr) override;
-
   void visit (AST::GroupedExpr &expr) override;
-
   void visit (AST::FieldAccessExpr &expr) override;
-
   void visit (AST::LoopExpr &expr) override;
-
   void visit (AST::BreakExpr &expr) override;
-
   void visit (AST::WhileLoopExpr &expr) override;
-
   void visit (AST::ForLoopExpr &expr) override;
-
   void visit (AST::ContinueExpr &expr) override;
-
   void visit (AST::BorrowExpr &expr) override;
-
   void visit (AST::DereferenceExpr &expr) override;
-
   void visit (AST::MatchExpr &expr) override;
-
   void visit (AST::RangeFromToExpr &expr) override;
-
   void visit (AST::RangeFromExpr &expr) override;
-
   void visit (AST::RangeToExpr &expr) override;
-
   void visit (AST::RangeFullExpr &expr) override;
-
   void visit (AST::RangeFromToInclExpr &expr) override;
 
 private: