Clarify why InhabitedPredicate::instantiate_opt exists
At first glance, the extra casework seems pointless and needlessly error-prone. Clarify that there is a reason for it being there.
This commit is contained in:
parent
60493b8973
commit
da3e73654f
1 changed files with 5 additions and 0 deletions
|
|
@ -236,6 +236,11 @@ impl<'tcx> InhabitedPredicate<'tcx> {
|
|||
self.instantiate_opt(tcx, args).unwrap_or(self)
|
||||
}
|
||||
|
||||
/// Same as [`Self::instantiate`], but if there is no generics to
|
||||
/// instantiate, returns `None`. This is useful because it lets us avoid
|
||||
/// allocating a recursive copy of everything when the result is unchanged.
|
||||
///
|
||||
/// Only used to implement `instantiate` itself.
|
||||
fn instantiate_opt(self, tcx: TyCtxt<'tcx>, args: ty::GenericArgsRef<'tcx>) -> Option<Self> {
|
||||
match self {
|
||||
Self::ConstIsZero(c) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue