https://gcc.gnu.org/g:c90a9ada247d96025562be15780dba3f3d1f9ec0

commit c90a9ada247d96025562be15780dba3f3d1f9ec0
Author: Jakub Dupak <d...@jakubdupak.com>
Date:   Mon Apr 1 14:06:33 2024 +0200

    borrowck: Remove block braces to satisfy GNU style
    
    gcc/rust/ChangeLog:
    
            * checks/errors/borrowck/rust-bir-dump.cc (renumber_places):
            Remove unecessary braces.
            (Dump::go): Remove unecessary braces.
            (Dump::visit): Remove unecessary braces.
            (Dump::visit_scope): Remove unecessary braces.
            * checks/errors/borrowck/rust-bir-fact-collector.h (class 
FactCollector):
            Remove unecessary braces.
            (points): Remove unecessary braces.
            * checks/errors/borrowck/rust-bir-free-region.h: Remove unecessary 
braces.
            * checks/errors/borrowck/rust-bir-place.h: Remove unecessary braces.
            * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go):
            Remove unecessary braces.
            * checks/errors/borrowck/rust-function-collector.h: Remove 
unecessary braces.
    
    Signed-off-by: Jakub Dupak <d...@jakubdupak.com>

Diff:
---
 gcc/rust/checks/errors/borrowck/rust-bir-dump.cc   | 47 +++++-------
 .../errors/borrowck/rust-bir-fact-collector.h      | 87 +++++++---------------
 .../checks/errors/borrowck/rust-bir-free-region.h  | 16 +---
 gcc/rust/checks/errors/borrowck/rust-bir-place.h   | 17 ++---
 .../checks/errors/borrowck/rust-borrow-checker.cc  |  6 +-
 .../errors/borrowck/rust-function-collector.h      |  4 +-
 6 files changed, 56 insertions(+), 121 deletions(-)

diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc 
b/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
index 51dd14363506..a39f145f8f95 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
@@ -42,13 +42,9 @@ renumber_places (const Function &func, std::vector<PlaceId> 
&place_map)
     {
       const Place &place = func.place_db[in_id];
       if (place.kind == Place::VARIABLE || place.kind == Place::TEMPORARY)
-       {
-         place_map[in_id] = next_out_id++;
-       }
+       place_map[in_id] = next_out_id++;
       else
-       {
-         place_map[in_id] = INVALID_PLACE;
-       }
+       place_map[in_id] = INVALID_PLACE;
     }
 }
 
@@ -138,10 +134,9 @@ Dump::go (bool enable_simplify_cfg)
          stream << ";\n";
        }
       if (!bb_terminated)
-       {
-         stream << indentation << indentation << "goto -> bb"
-                << bb_fold_map[bb.successors.at (0)] << ";\t\t" << i++ << "\n";
-       }
+       stream << indentation << indentation << "goto -> bb"
+              << bb_fold_map[bb.successors.at (0)] << ";\t\t" << i++ << "\n";
+
       stream << indentation << "}\n";
     }
 
@@ -276,15 +271,13 @@ void
 Dump::visit (const CallExpr &expr)
 {
   stream << "Call(";
-  if (auto fn_type
-      = func.place_db[expr.get_callable ()].tyty->try_as<TyTy::FnType> ())
-    {
-      stream << fn_type->get_identifier ();
-    }
+  auto maybe_fn_type
+    = func.place_db[expr.get_callable ()].tyty->try_as<TyTy::FnType> ();
+  if (maybe_fn_type)
+    stream << maybe_fn_type->get_identifier ();
   else
-    {
-      visit_move_place (expr.get_callable ());
-    }
+    visit_move_place (expr.get_callable ());
+
   stream << ")(";
   print_comma_separated (stream, expr.get_arguments (),
                         [this] (PlaceId place_id) {
@@ -321,13 +314,9 @@ void
 Dump::visit (const Assignment &expr)
 {
   if (func.place_db[expr.get_rhs ()].is_rvalue ())
-    {
-      visit_move_place (expr.get_rhs ());
-    }
+    visit_move_place (expr.get_rhs ());
   else
-    {
-      visit_place (expr.get_rhs ());
-    }
+    visit_place (expr.get_rhs ());
 }
 
 std::ostream &
@@ -346,9 +335,8 @@ Dump::visit_scope (ScopeId id, size_t depth)
     return;
 
   if (id > 1)
-    {
-      indent (depth) << "scope " << id - 1 << " {\n";
-    }
+    indent (depth) << "scope " << id - 1 << " {\n";
+
   for (auto &local : scope.locals)
     {
       indent (depth + 1) << "let _";
@@ -357,9 +345,8 @@ Dump::visit_scope (ScopeId id, size_t depth)
       stream << ";\n";
     }
   for (auto &child : scope.children)
-    {
-      visit_scope (child, (id >= 1) ? depth + 1 : depth);
-    }
+    visit_scope (child, (id >= 1) ? depth + 1 : depth);
+
   if (id > 1)
     indent (depth) << "}\n";
 }
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h 
b/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
index 17c198e0fa7f..527ae65606cc 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
@@ -67,9 +67,8 @@ class FactCollector : public Visitor
   {
     std::vector<FreeRegion> free_regions;
     for (size_t i = 0; i < size; i++)
-      {
-       free_regions.push_back (region_binder.get_next_free_region ());
-      }
+      free_regions.push_back (region_binder.get_next_free_region ());
+
     return FreeRegions (std::move (free_regions));
   }
 
@@ -129,9 +128,8 @@ protected: // Main collection entry points (for different 
categories).
          case Place::TEMPORARY:
            facts.path_is_var.emplace_back (place_id, place_id);
            for (auto &region : place.regions)
-             {
-               facts.use_of_var_derefs_origin.emplace_back (place_id, region);
-             }
+             facts.use_of_var_derefs_origin.emplace_back (place_id, region);
+
            // TODO: drop_of_var_derefs_origin
            break;
          case Place::FIELD:
@@ -154,10 +152,9 @@ protected: // Main collection entry points (for different 
categories).
       }
 
     for (PlaceId arg = FIRST_VARIABLE_PLACE + 1; arg < first_local; ++arg)
-      {
-       facts.path_assigned_at_base.emplace_back (
-         arg, get_point (0, 0, PointPosition::START));
-      }
+      facts.path_assigned_at_base.emplace_back (
+       arg, get_point (0, 0, PointPosition::START));
+
     for (PlaceId place = first_local; place < place_db.size (); ++place)
       {
        if (place_db[place].is_var ())
@@ -560,17 +557,13 @@ protected: // Generic BIR operations.
   {
     place_db.for_each_path_segment (place_id, [&] (PlaceId id) {
       for (auto loan : place_db[id].borrowed_by)
-       {
-         facts.loan_invalidated_at.emplace_back (get_current_point_start (),
-                                                 loan);
-       }
+       facts.loan_invalidated_at.emplace_back (get_current_point_start (),
+                                               loan);
     });
     place_db.for_each_path_from_root (place_id, [&] (PlaceId id) {
       for (auto loan : place_db[id].borrowed_by)
-       {
-         facts.loan_invalidated_at.emplace_back (get_current_point_start (),
-                                                 loan);
-       }
+       facts.loan_invalidated_at.emplace_back (get_current_point_start (),
+                                               loan);
     });
   }
 
@@ -583,14 +576,10 @@ protected: // Generic BIR operations.
          if (mutability == Mutability::Imm
              && place_db.get_loans ()[other_loan].mutability
                   == Mutability::Imm)
-           {
-             continue;
-           }
+           continue;
          else
-           {
-             facts.loan_invalidated_at.emplace_back (
-               get_current_point_start (), other_loan);
-           }
+           facts.loan_invalidated_at.emplace_back (get_current_point_start (),
+                                                   other_loan);
        }
     });
 
@@ -600,14 +589,10 @@ protected: // Generic BIR operations.
          if (mutability == Mutability::Imm
              && place_db.get_loans ()[other_loan].mutability
                   == Mutability::Imm)
-           {
-             continue;
-           }
+           continue;
          else
-           {
-             facts.loan_invalidated_at.emplace_back (
-               get_current_point_start (), other_loan);
-           }
+           facts.loan_invalidated_at.emplace_back (get_current_point_start (),
+                                                   other_loan);
        }
     });
   }
@@ -618,9 +603,7 @@ protected: // Generic BIR operations.
       if (id == place_id)
        return;
       if (place_db[id].kind == Place::DEREF)
-       {
-         rust_error_at (location, "Cannot move from behind a reference.");
-       }
+       rust_error_at (location, "Cannot move from behind a reference.");
     });
   }
 
@@ -654,13 +637,9 @@ protected: // Subset helpers.
   void push_subset (Variance variance, FreeRegion lhs, FreeRegion rhs)
   {
     if (variance.is_covariant ())
-      {
-       push_subset (lhs, rhs);
-      }
+      push_subset (lhs, rhs);
     else if (variance.is_contravariant ())
-      {
-       push_subset (rhs, lhs);
-      }
+      push_subset (rhs, lhs);
     else if (variance.is_invariant ())
       {
        push_subset (lhs, rhs);
@@ -671,13 +650,9 @@ protected: // Subset helpers.
   void push_subset_all (Variance variance, FreeRegion lhs, FreeRegion rhs)
   {
     if (variance.is_covariant ())
-      {
-       push_subset_all (lhs, rhs);
-      }
+      push_subset_all (lhs, rhs);
     else if (variance.is_contravariant ())
-      {
-       push_subset_all (rhs, lhs);
-      }
+      push_subset_all (rhs, lhs);
     else if (variance.is_invariant ())
       {
        push_subset_all (lhs, rhs);
@@ -701,9 +676,7 @@ protected: // Subset helpers.
     rust_assert (lhs.size () == rhs.size ());
     rust_assert (lhs.size () == variances.size ());
     for (size_t i = 0; i < lhs.size (); ++i)
-      {
-       push_subset (variances[i], lhs[i], rhs[i]);
-      }
+      push_subset (variances[i], lhs[i], rhs[i]);
   }
 
   void push_subset_all (TyTy::BaseType *type, FreeRegions lhs, FreeRegions rhs)
@@ -714,9 +687,7 @@ protected: // Subset helpers.
     rust_assert (lhs.size () == rhs.size ());
     rust_assert (lhs.size () == variances.size ());
     for (size_t i = 0; i < lhs.size (); ++i)
-      {
-       push_subset_all (variances[i], lhs[i], rhs[i]);
-      }
+      push_subset_all (variances[i], lhs[i], rhs[i]);
   }
 
   void push_subset_user (TyTy::BaseType *type, FreeRegions free_regions,
@@ -731,18 +702,14 @@ protected: // Subset helpers.
     for (size_t i = 0; i < free_regions.size (); ++i)
       {
        if (user_regions[i].is_named ())
-         {
-           push_subset (variances[i], free_regions[i],
-                        {Polonius::Origin (user_regions[i].get_index ())});
-         }
+         push_subset (variances[i], free_regions[i],
+                      {Polonius::Origin (user_regions[i].get_index ())});
        else if (user_regions[i].is_anonymous ())
          {
            // IGNORE
          }
        else
-         {
-           rust_internal_error_at (UNKNOWN_LOCATION, "Unexpected region type");
-         }
+         rust_internal_error_at (UNKNOWN_LOCATION, "Unexpected region type");
       }
   }
 
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-free-region.h 
b/gcc/rust/checks/errors/borrowck/rust-bir-free-region.h
index 0560a894ab06..e5d6ef3c98be 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-free-region.h
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-free-region.h
@@ -75,21 +75,13 @@ public:
     for (auto &region : regions)
       {
        if (region.is_early_bound ())
-         {
-           free_regions.push_back (parent_free_regions[region.get_index ()]);
-         }
+         free_regions.push_back (parent_free_regions[region.get_index ()]);
        else if (region.is_static ())
-         {
-           free_regions.push_back (0);
-         }
+         free_regions.push_back (0);
        else if (region.is_anonymous ())
-         {
-           free_regions.push_back (get_next_free_region ());
-         }
+         free_regions.push_back (get_next_free_region ());
        else if (region.is_named ())
-         {
-           rust_unreachable (); // FIXME
-         }
+         rust_unreachable (); // FIXME
        else
          {
            rust_sorry_at (UNKNOWN_LOCATION, "Unimplemented");
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-place.h 
b/gcc/rust/checks/errors/borrowck/rust-bir-place.h
index f22ab112b3e2..752c8f42c007 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-place.h
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-place.h
@@ -233,28 +233,21 @@ public:
     PlaceId new_place = places.size () - 1;
     Place &new_place_ref = places[new_place]; // Intentional shadowing.
     if (last_sibling == 0)
-      {
-       places[new_place_ref.path.parent].path.first_child = new_place;
-      }
+      places[new_place_ref.path.parent].path.first_child = new_place;
     else
-      {
-       places[last_sibling].path.next_sibling = new_place;
-      }
+      places[last_sibling].path.next_sibling = new_place;
 
     if (new_place_ref.kind == Place::VARIABLE
        || new_place_ref.kind == Place::TEMPORARY)
-      {
-       scopes[current_scope].locals.push_back (new_place);
-      }
+      scopes[current_scope].locals.push_back (new_place);
 
     auto variances = Resolver::TypeCheckContext::get ()
                       ->get_variance_analysis_ctx ()
                       .query_type_variances (new_place_ref.tyty);
     std::vector<Polonius::Origin> regions;
     for (size_t i = 0; i < variances.size (); i++)
-      {
-       regions.push_back (next_free_region++);
-      }
+      regions.push_back (next_free_region++);
+
     new_place_ref.regions.set_from (std::move (regions));
 
     return new_place;
diff --git a/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc 
b/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc
index 77726eb1c265..ae06aadaa5b1 100644
--- a/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc
@@ -92,10 +92,8 @@ BorrowChecker::go (HIR::Crate &crate)
     }
 
   for (auto closure ATTRIBUTE_UNUSED : collector.get_closures ())
-    {
-      rust_sorry_at (closure->get_locus (),
-                    "Closure borrow checking is not implemented yet.");
-    }
+    rust_sorry_at (closure->get_locus (),
+                  "Closure borrow checking is not implemented yet.");
 }
 
 } // namespace HIR
diff --git a/gcc/rust/checks/errors/borrowck/rust-function-collector.h 
b/gcc/rust/checks/errors/borrowck/rust-function-collector.h
index 272f20d5f935..7058451f2b59 100644
--- a/gcc/rust/checks/errors/borrowck/rust-function-collector.h
+++ b/gcc/rust/checks/errors/borrowck/rust-function-collector.h
@@ -50,9 +50,7 @@ protected:
   template <typename T> void visit_all (std::vector<std::unique_ptr<T>> &items)
   {
     for (std::unique_ptr<T> &item : items)
-      {
-       item->accept_vis (*this);
-      }
+      item->accept_vis (*this);
   }
 
   void visit (HIR::Function &function) override

Reply via email to