From 758cc957638e4edcfd9985e9f32e46f1dbac1fc1 Mon Sep 17 00:00:00 2001 From: b-naber Date: Wed, 15 Feb 2023 21:13:12 +0000 Subject: [PATCH] exhaustive matching in get_ambient_variance --- compiler/rustc_borrowck/src/type_check/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 4244c76be13..c2d6e22d57b 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -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, } }