Skip to content

Commit

Permalink
panic => expect (*2)
Browse files Browse the repository at this point in the history
  • Loading branch information
acl-cqc committed Sep 5, 2023
1 parent 9132e43 commit 2a7d49b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/types/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/types/type_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
}
Expand Down

0 comments on commit 2a7d49b

Please sign in to comment.