From 2a7d49b296dccc7a6ee995cd09c2660d5a6619be Mon Sep 17 00:00:00 2001 From: Alan Lawrence Date: Tue, 5 Sep 2023 16:00:55 +0100 Subject: [PATCH] panic => expect (*2) --- src/types/custom.rs | 5 ++++- src/types/type_param.rs | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/types/custom.rs b/src/types/custom.rs index 248413863..b5b5baea5 100644 --- a/src/types/custom.rs +++ b/src/types/custom.rs @@ -89,7 +89,10 @@ impl CustomType { } pub(super) fn substitute(&self, exts: &ExtensionRegistry, args: &[TypeArg]) -> Self { - let bound = self.get_type_def(exts).unwrap().bound(args); + let bound = self + .get_type_def(exts) + .expect("validate should rule this out") + .bound(args); assert!(self.bound.contains(bound)); Self { args: self diff --git a/src/types/type_param.rs b/src/types/type_param.rs index 715dc7917..e1f11c97c 100644 --- a/src/types/type_param.rs +++ b/src/types/type_param.rs @@ -167,8 +167,10 @@ impl TypeArg { TypeArg::Sequence(elems.iter().map(|ta| ta.substitute(exts, args)).collect()) } TypeArg::Extensions(es) => TypeArg::Extensions(es.substitute(args)), - // Caller should already have checked arg against bound (cached here): - TypeArg::Variable(TypeArgVariable { idx, .. }) => args.get(*idx).unwrap().clone(), + TypeArg::Variable(TypeArgVariable { idx, .. }) => args + .get(*idx) + .expect("validate + check_type_args should rule this out") + .clone(), } } }