https://gcc.gnu.org/g:5c43f87cc16b7e5b596ef24cd8e7f0a59ad95789
commit r16-4806-g5c43f87cc16b7e5b596ef24cd8e7f0a59ad95789 Author: Pierre-Emmanuel Patry <[email protected]> Date: Thu Aug 21 13:15:39 2025 +0200 gccrs: Remove unused variable assignments 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]> Diff: --- 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 33653f5a6512..9a772cba4c60 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 3068f0c6e357..ffa099098c68 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 95e9bc2c17f7..5e321f248c37 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 66ced65ad780..852451aeef4c 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 ());
