diff options
| author | b-naber <b_naber@gmx.de> | 2023-02-15 21:13:12 +0000 |
|---|---|---|
| committer | b-naber <b_naber@gmx.de> | 2023-02-15 21:13:12 +0000 |
| commit | 758cc957638e4edcfd9985e9f32e46f1dbac1fc1 (patch) | |
| tree | 85bd1fd33e1eb98935bfb06c94f12cc6f013d3d8 | |
| parent | 6e1d22828505bd582b899d7ecdba21caf3327ea7 (diff) | |
| download | rust-758cc957638e4edcfd9985e9f32e46f1dbac1fc1.tar.gz rust-758cc957638e4edcfd9985e9f32e46f1dbac1fc1.zip | |
exhaustive matching in get_ambient_variance
| -rw-r--r-- | compiler/rustc_borrowck/src/type_check/mod.rs | 10 |
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, } } |
