From: Philip Herron <[email protected]>
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]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github:
https://github.com/Rust-GCC/gccrs/commit/eb62f35f76d3070ca32f73c3b7663484b23cd1f8
The commit has NOT been mentioned in any issue.
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4833
.../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 6c6877ef9..2b1a8b7db 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 ());
}
}
base-commit: 7ce9f8446d5665ec49137fd7f9d325694ffb4e76
--
2.55.0