Skip to content

Commit 842c1cf

Browse files
committed
gccrs: Fix crash in privay reporter for placeholder types
This guards against a crash but i think this should actually be treated as if its a generic type like below. But for now this addresses a crash which can occur. gcc/rust/ChangeLog: * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_base_type_privacy): Add guard for placeholder Signed-off-by: Philip Herron <[email protected]>
1 parent 12e9f5d commit 842c1cf

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,12 @@ PrivacyReporter::check_base_type_privacy (Analysis::NodeMapping &node_mappings,
243243
static_cast<const TyTy::TupleType *> (ty)->get_fields ())
244244
recursive_check (param.get_tyty ());
245245
return;
246-
case TyTy::PLACEHOLDER:
247-
return recursive_check (
248-
// FIXME: Can we use `resolve` here? Is that what we should do?
249-
static_cast<const TyTy::PlaceholderType *> (ty)->resolve ());
246+
case TyTy::PLACEHOLDER: {
247+
const auto p = static_cast<const TyTy::PlaceholderType *> (ty);
248+
if (!p->can_resolve ())
249+
return;
250+
return recursive_check (p->resolve ());
251+
}
250252
case TyTy::PROJECTION:
251253
return recursive_check (
252254
static_cast<const TyTy::ProjectionType *> (ty)->get ());

0 commit comments

Comments
 (0)