From: Jayant Chauhan <0001jayant@gmail.com> Date: Fri, 16 Jan 2026 18:35:07 +0000 (+0530) Subject: gccrs: derive: Factor out Eq trait path generation X-Git-Tag: basepoints/gcc-17~1013 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=af2ea0a2fe202e4af546c91f3940fb281c4415db;p=thirdparty%2Fgcc.git gccrs: derive: Factor out Eq trait path generation This patch introduces a local helper in DeriveEq. This removes the duplication of the hardcoded path {core, cmp, Eq} used in both and . gcc/rust/ChangeLog: * expand/rust-derive-eq.cc (get_eq_trait_path): New helper. (DeriveEq::assert_param_is_eq): Use helper. (DeriveEq::eq_impls): Use helper. Signed-off-by: Jayant Chauhan <0001jayant@gmail.com> --- diff --git a/gcc/rust/expand/rust-derive-eq.cc b/gcc/rust/expand/rust-derive-eq.cc index 459ec0e09f3..c0358593b67 100644 --- a/gcc/rust/expand/rust-derive-eq.cc +++ b/gcc/rust/expand/rust-derive-eq.cc @@ -27,6 +27,12 @@ namespace Rust { namespace AST { +static TypePath +get_eq_trait_path (Builder &builder) +{ + return builder.type_path ({"core", "cmp", "Eq"}, true); +} + DeriveEq::DeriveEq (location_t loc) : DeriveVisitor (loc) {} std::vector> @@ -61,7 +67,7 @@ std::unique_ptr DeriveEq::assert_param_is_eq () { auto eq_bound = std::unique_ptr ( - new TraitBound (builder.type_path ({"core", "cmp", "Eq"}, true), loc)); + new TraitBound (get_eq_trait_path (builder), loc)); auto sized_bound = std::unique_ptr ( new TraitBound (builder.type_path (LangItem::Kind::SIZED), loc, false, @@ -113,9 +119,8 @@ DeriveEq::eq_impls ( const std::vector> &type_generics) { // We create two copies of the type-path to avoid duplicate NodeIds - auto eq = builder.type_path ({"core", "cmp", "Eq"}, true); - auto eq_bound - = builder.trait_bound (builder.type_path ({"core", "cmp", "Eq"}, true)); + auto eq = get_eq_trait_path (builder); + auto eq_bound = builder.trait_bound (get_eq_trait_path (builder)); auto steq = builder.type_path (LangItem::Kind::STRUCTURAL_TEQ);