exhaustive matching in get_ambient_variance

This commit is contained in:
b-naber 2023-02-15 21:13:12 +00:00
parent 6e1d228285
commit 758cc95763

View File

@ -767,9 +767,17 @@ fn error(&mut self) -> Ty<'tcx> {
}
fn get_ambient_variance(&self, context: PlaceContext) -> ty::Variance {
use rustc_middle::mir::visit::NonMutatingUseContext::*;
use rustc_middle::mir::visit::NonUseContext::*;
match context {
PlaceContext::MutatingUse(_) => ty::Invariant,
PlaceContext::NonMutatingUse(_) | PlaceContext::NonUse(_) => ty::Covariant,
PlaceContext::NonUse(StorageDead | StorageLive | VarDebugInfo) => ty::Invariant,
PlaceContext::NonMutatingUse(
Inspect | Copy | Move | SharedBorrow | ShallowBorrow | UniqueBorrow | AddressOf
| Projection,
) => ty::Covariant,
PlaceContext::NonUse(AscribeUserTy) => ty::Covariant,
}
}