https://gcc.gnu.org/g:83d9ebd601c11c3f976944f2f21037ae9e9e2081
commit r17-4321-g83d9ebd601c11c3f976944f2f21037ae9e9e2081 Author: Philip Herron <[email protected]> Date: Mon Aug 31 22:47:37 2026 +0100 gccrs: Fix debug output of variance analysis to switch to substitutionref gcc/rust/ChangeLog: * typecheck/rust-tyty-variance-analysis.cc (GenericTyPerCrateCtx::debug_print_solutions): we can switch into a substitutionref base class to make this generic Signed-off-by: Philip Herron <[email protected]> Diff: --- gcc/rust/typecheck/rust-tyty-variance-analysis.cc | 62 +++++++++++++---------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/gcc/rust/typecheck/rust-tyty-variance-analysis.cc b/gcc/rust/typecheck/rust-tyty-variance-analysis.cc index 6c6877ef9ecb..2b1a8b7db6f8 100644 --- a/gcc/rust/typecheck/rust-tyty-variance-analysis.cc +++ b/gcc/rust/typecheck/rust-tyty-variance-analysis.cc @@ -180,39 +180,49 @@ GenericTyPerCrateCtx::debug_print_solutions () BaseType *ty = lookup_type (ref); std::string result = "\t"; + SubstitutionRef *subst = nullptr; - if (auto adt = ty->try_as<ADTType> ()) + switch (ty->get_kind ()) { - result += adt->get_identifier (); - result += "<"; + case TypeKind::ADT: + subst = static_cast<ADTType *> (ty); + break; + case TypeKind::FNDEF: + subst = static_cast<FnType *> (ty); + break; + case TypeKind::CLOSURE: + subst = static_cast<ClosureType *> (ty); + break; + case TypeKind::PROJECTION: + subst = static_cast<ProjectionType *> (ty); + break; + default: + rust_unreachable (); + } - size_t i = solution_index; - for (auto ®ion : adt->get_used_arguments ().get_regions ()) - { - (void) region; - if (i > solution_index) - result += ", "; - result += solutions[i].as_string (); - i++; - } - for (auto ¶m : adt->get_substs ()) - { - if (i > solution_index) - result += ", "; - result += param.get_type_representation ().as_string (); - result += "="; - result += solutions[i].as_string (); - i++; - } + result += ty->get_name (); + result += "<"; - result += ">"; + size_t i = solution_index; + for (auto ®ion : subst->get_used_arguments ().get_regions ()) + { + (void) region; + if (i > solution_index) + result += ", "; + result += solutions[i].as_string (); + i++; } - else + for (auto ¶m : subst->get_substs ()) { - rust_sorry_at ( - ty->get_ref (), - "This is a compiler bug: Unhandled type in variance analysis"); + if (i > solution_index) + result += ", "; + result += param.get_type_representation ().as_string (); + result += "="; + result += solutions[i].as_string (); + i++; } + + result += ">"; rust_debug ("%s", result.c_str ()); } }
