Rollup merge of #111366 - obeis:ascribe-user-type-variance, r=lcnr
Make `NonUseContext::AscribeUserTy` carry `ty::Variance` Close #108267
This commit is contained in:
commit
41ab8e6b87
4 changed files with 7 additions and 7 deletions
|
@ -55,7 +55,7 @@ pub fn categorize(context: PlaceContext) -> Option<DefUse> {
|
||||||
// `PlaceMention` and `AscribeUserType` both evaluate the place, which must not
|
// `PlaceMention` and `AscribeUserType` both evaluate the place, which must not
|
||||||
// contain dangling references.
|
// contain dangling references.
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::PlaceMention) |
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::PlaceMention) |
|
||||||
PlaceContext::NonUse(NonUseContext::AscribeUserTy) |
|
PlaceContext::NonUse(NonUseContext::AscribeUserTy(_)) |
|
||||||
|
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::AddressOf) |
|
PlaceContext::MutatingUse(MutatingUseContext::AddressOf) |
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) |
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) |
|
||||||
|
|
|
@ -777,7 +777,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
|
||||||
Inspect | Copy | Move | PlaceMention | SharedBorrow | ShallowBorrow | UniqueBorrow
|
Inspect | Copy | Move | PlaceMention | SharedBorrow | ShallowBorrow | UniqueBorrow
|
||||||
| AddressOf | Projection,
|
| AddressOf | Projection,
|
||||||
) => ty::Covariant,
|
) => ty::Covariant,
|
||||||
PlaceContext::NonUse(AscribeUserTy) => ty::Covariant,
|
PlaceContext::NonUse(AscribeUserTy(variance)) => variance,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
|
|
||||||
use crate::mir::*;
|
use crate::mir::*;
|
||||||
use crate::ty::subst::SubstsRef;
|
use crate::ty::subst::SubstsRef;
|
||||||
use crate::ty::{CanonicalUserTypeAnnotation, Ty};
|
use crate::ty::{self, CanonicalUserTypeAnnotation, Ty};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
macro_rules! make_mir_visitor {
|
macro_rules! make_mir_visitor {
|
||||||
|
@ -782,12 +782,12 @@ macro_rules! make_mir_visitor {
|
||||||
|
|
||||||
fn super_ascribe_user_ty(&mut self,
|
fn super_ascribe_user_ty(&mut self,
|
||||||
place: & $($mutability)? Place<'tcx>,
|
place: & $($mutability)? Place<'tcx>,
|
||||||
_variance: $(& $mutability)? ty::Variance,
|
variance: $(& $mutability)? ty::Variance,
|
||||||
user_ty: & $($mutability)? UserTypeProjection,
|
user_ty: & $($mutability)? UserTypeProjection,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
self.visit_place(
|
self.visit_place(
|
||||||
place,
|
place,
|
||||||
PlaceContext::NonUse(NonUseContext::AscribeUserTy),
|
PlaceContext::NonUse(NonUseContext::AscribeUserTy($(* &$mutability *)? variance)),
|
||||||
location
|
location
|
||||||
);
|
);
|
||||||
self.visit_user_type_projection(user_ty);
|
self.visit_user_type_projection(user_ty);
|
||||||
|
@ -1320,7 +1320,7 @@ pub enum NonUseContext {
|
||||||
/// Ending a storage live range.
|
/// Ending a storage live range.
|
||||||
StorageDead,
|
StorageDead,
|
||||||
/// User type annotation assertions for NLL.
|
/// User type annotation assertions for NLL.
|
||||||
AscribeUserTy,
|
AscribeUserTy(ty::Variance),
|
||||||
/// The data of a user variable, for debug info.
|
/// The data of a user variable, for debug info.
|
||||||
VarDebugInfo,
|
VarDebugInfo,
|
||||||
}
|
}
|
||||||
|
|
|
@ -643,7 +643,7 @@ impl UnifyKey for FloatVid {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Decodable, Encodable, Hash, HashStable_Generic)]
|
#[derive(Copy, Clone, PartialEq, Eq, Decodable, Encodable, Hash, HashStable_Generic)]
|
||||||
#[rustc_pass_by_value]
|
#[rustc_pass_by_value]
|
||||||
pub enum Variance {
|
pub enum Variance {
|
||||||
Covariant, // T<A> <: T<B> iff A <: B -- e.g., function return type
|
Covariant, // T<A> <: T<B> iff A <: B -- e.g., function return type
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue