[gccrs COMMIT] gccrs: Add missing handling to variance analysis
gerris.rs@gmail.com
gerris.rs@gmail.com
Mon Aug 31 23:28:34 GMT 2026
From: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-tyty-variance-analysis.cc (GenericTyVisitorCtx::lookup_or_add_type):
handle the other tyty types
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
---
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/a64ace613c317103e3a0e347aefd030906d6309b
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/4832
.../typecheck/rust-tyty-variance-analysis.cc | 24 +++++++++++++++----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/gcc/rust/typecheck/rust-tyty-variance-analysis.cc b/gcc/rust/typecheck/rust-tyty-variance-analysis.cc
index ca8e9f6b1..6c6877ef9 100644
--- a/gcc/rust/typecheck/rust-tyty-variance-analysis.cc
+++ b/gcc/rust/typecheck/rust-tyty-variance-analysis.cc
@@ -366,15 +366,29 @@ GenericTyVisitorCtx::lookup_or_add_type (HirId hir_id)
}
SubstitutionRef *subst = nullptr;
- if (auto adt = ty->try_as<ADTType> ())
- {
- subst = adt;
- }
- else
+ switch (ty->get_kind ())
{
+ 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_sorry_at (
ty->get_locus (),
"This is a compiler bug: Unhandled type in variance analysis");
+ break;
}
rust_assert (subst != nullptr);
base-commit: 39b53aaf7fd854dbc61146d62145da5ded61095f
--
2.55.0
More information about the Gcc-rust
mailing list