Skip to content

Commit

Permalink
exhaustive matching in get_ambient_variance
Browse files Browse the repository at this point in the history
  • Loading branch information
b-naber committed Feb 15, 2023
1 parent 6e1d228 commit 758cc95
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,17 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, '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,
}
}

Expand Down

0 comments on commit 758cc95

Please sign in to comment.