about summary refs log tree commit diff
diff options
context:
space:
mode:
authorb-naber <b_naber@gmx.de>2023-02-15 21:13:12 +0000
committerb-naber <b_naber@gmx.de>2023-02-15 21:13:12 +0000
commit758cc957638e4edcfd9985e9f32e46f1dbac1fc1 (patch)
tree85bd1fd33e1eb98935bfb06c94f12cc6f013d3d8
parent6e1d22828505bd582b899d7ecdba21caf3327ea7 (diff)
downloadrust-758cc957638e4edcfd9985e9f32e46f1dbac1fc1.tar.gz
rust-758cc957638e4edcfd9985e9f32e46f1dbac1fc1.zip
exhaustive matching in get_ambient_variance
-rw-r--r--compiler/rustc_borrowck/src/type_check/mod.rs10
1 files changed, 9 insertions, 1 deletions
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,
         }
     }