From: Pierre-Emmanuel Patry <[email protected]>

Multiple local variables were not read beyond their assignments.

gcc/rust/ChangeLog:

        * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Remove
        unused assignment.
        * typecheck/rust-hir-type-check-path.cc 
(TypeCheckExpr::resolve_segments):
        Likewise.
        * typecheck/rust-tyty.cc (ParamType::handle_substitions): Likewise.
        * typecheck/rust-unify.cc (UnifyRules::go): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
---
 gcc/rust/typecheck/rust-hir-type-check-expr.cc | 7 +++----
 gcc/rust/typecheck/rust-hir-type-check-path.cc | 5 ++---
 gcc/rust/typecheck/rust-tyty.cc                | 2 +-
 gcc/rust/typecheck/rust-unify.cc               | 7 ++-----
 4 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc 
b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
index 33653f5a651..9a772cba4c6 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
@@ -629,10 +629,9 @@ TypeCheckExpr::visit (HIR::BlockExpr &expr)
       if (s->is_unit_check_needed () && !resolved->is_unit ())
        {
          auto unit = TyTy::TupleType::get_unit_type ();
-         resolved
-           = unify_site (s->get_mappings ().get_hirid (),
-                         TyTy::TyWithLocation (unit),
-                         TyTy::TyWithLocation (resolved), s->get_locus ());
+         unify_site (s->get_mappings ().get_hirid (),
+                     TyTy::TyWithLocation (unit),
+                     TyTy::TyWithLocation (resolved), s->get_locus ());
        }
     }
 
diff --git a/gcc/rust/typecheck/rust-hir-type-check-path.cc 
b/gcc/rust/typecheck/rust-hir-type-check-path.cc
index 3068f0c6e35..ffa099098c6 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-path.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-path.cc
@@ -517,9 +517,8 @@ TypeCheckExpr::resolve_segments (NodeId 
root_resolved_node_id,
              const auto &predicate
                = impl_block_ty->lookup_predicate (trait_ref.get_defid ());
              if (!predicate.is_error ())
-               impl_block_ty
-                 = associated->setup_associated_types (prev_segment, predicate,
-                                                       nullptr, false);
+               associated->setup_associated_types (prev_segment, predicate,
+                                                   nullptr, false);
            }
        }
 
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc
index 95e9bc2c17f..5e321f248c3 100644
--- a/gcc/rust/typecheck/rust-tyty.cc
+++ b/gcc/rust/typecheck/rust-tyty.cc
@@ -3566,7 +3566,7 @@ ParamType::handle_substitions 
(SubstitutionArgumentMappings &subst_mappings)
     {
       const ParamType &pp = *static_cast<const ParamType *> (resolved);
       if (pp.can_resolve ())
-       resolved = pp.resolve ();
+       pp.resolve ();
     }
 
   // this is the new subst that this needs to pass
diff --git a/gcc/rust/typecheck/rust-unify.cc b/gcc/rust/typecheck/rust-unify.cc
index 66ced65ad78..852451aeef4 100644
--- a/gcc/rust/typecheck/rust-unify.cc
+++ b/gcc/rust/typecheck/rust-unify.cc
@@ -155,11 +155,8 @@ UnifyRules::emit_abi_mismatch (const TyTy::FnType 
&expected,
 TyTy::BaseType *
 UnifyRules::go ()
 {
-  TyTy::BaseType *ltype = lhs.get_ty ();
-  TyTy::BaseType *rtype = rhs.get_ty ();
-
-  ltype = lhs.get_ty ()->destructure ();
-  rtype = rhs.get_ty ()->destructure ();
+  TyTy::BaseType *ltype = lhs.get_ty ()->destructure ();
+  TyTy::BaseType *rtype = rhs.get_ty ()->destructure ();
 
   rust_debug ("unify::go ltype={%s} rtype={%s}", ltype->debug_str ().c_str (),
              rtype->debug_str ().c_str ());
-- 
2.50.1

Reply via email to