Skip to content

Commit 758cc95

Browse files
committed
exhaustive matching in get_ambient_variance
1 parent 6e1d228 commit 758cc95

File tree

1 file changed

+9
-1
lines changed
  • compiler/rustc_borrowck/src/type_check

1 file changed

+9
-1
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -767,9 +767,17 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
767767
}
768768

769769
fn get_ambient_variance(&self, context: PlaceContext) -> ty::Variance {
770+
use rustc_middle::mir::visit::NonMutatingUseContext::*;
771+
use rustc_middle::mir::visit::NonUseContext::*;
772+
770773
match context {
771774
PlaceContext::MutatingUse(_) => ty::Invariant,
772-
PlaceContext::NonMutatingUse(_) | PlaceContext::NonUse(_) => ty::Covariant,
775+
PlaceContext::NonUse(StorageDead | StorageLive | VarDebugInfo) => ty::Invariant,
776+
PlaceContext::NonMutatingUse(
777+
Inspect | Copy | Move | SharedBorrow | ShallowBorrow | UniqueBorrow | AddressOf
778+
| Projection,
779+
) => ty::Covariant,
780+
PlaceContext::NonUse(AscribeUserTy) => ty::Covariant,
773781
}
774782
}
775783

0 commit comments

Comments
 (0)