Writeback min_capture map to TypeckResults
- Derive TypeFoldable on `hir::place::Place` and associated structs, to them to be written into typeck results. Co-authored-by: Jennifer Wills <wills.jenniferg@gmail.com> Co-authored-by: Logan Mosier <logmosier@gmail.com>
This commit is contained in:
parent
15eaa0020b
commit
76c68aa182
4 changed files with 94 additions and 64 deletions
|
@ -4,7 +4,18 @@ use crate::ty::Ty;
|
|||
use rustc_hir::HirId;
|
||||
use rustc_target::abi::VariantIdx;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
TyEncodable,
|
||||
TyDecodable,
|
||||
TypeFoldable,
|
||||
HashStable
|
||||
)]
|
||||
pub enum PlaceBase {
|
||||
/// A temporary variable
|
||||
Rvalue,
|
||||
|
@ -16,7 +27,18 @@ pub enum PlaceBase {
|
|||
Upvar(ty::UpvarId),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
TyEncodable,
|
||||
TyDecodable,
|
||||
TypeFoldable,
|
||||
HashStable
|
||||
)]
|
||||
pub enum ProjectionKind {
|
||||
/// A dereference of a pointer, reference or `Box<T>` of the given type
|
||||
Deref,
|
||||
|
@ -36,7 +58,18 @@ pub enum ProjectionKind {
|
|||
Subslice,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
TyEncodable,
|
||||
TyDecodable,
|
||||
TypeFoldable,
|
||||
HashStable
|
||||
)]
|
||||
pub struct Projection<'tcx> {
|
||||
/// Type after the projection is being applied.
|
||||
pub ty: Ty<'tcx>,
|
||||
|
@ -48,7 +81,7 @@ pub struct Projection<'tcx> {
|
|||
/// A `Place` represents how a value is located in memory.
|
||||
///
|
||||
/// This is an HIR version of `mir::Place`
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, TypeFoldable, HashStable)]
|
||||
pub struct Place<'tcx> {
|
||||
/// The type of the `PlaceBase`
|
||||
pub base_ty: Ty<'tcx>,
|
||||
|
@ -61,7 +94,7 @@ pub struct Place<'tcx> {
|
|||
/// A `PlaceWithHirId` represents how a value is located in memory.
|
||||
///
|
||||
/// This is an HIR version of `mir::Place`
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, TypeFoldable, HashStable)]
|
||||
pub struct PlaceWithHirId<'tcx> {
|
||||
/// `HirId` of the expression or pattern producing this value.
|
||||
pub hir_id: HirId,
|
||||
|
|
|
@ -672,7 +672,18 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TyS<'tcx> {
|
|||
#[rustc_diagnostic_item = "Ty"]
|
||||
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
TyEncodable,
|
||||
TyDecodable,
|
||||
TypeFoldable,
|
||||
HashStable
|
||||
)]
|
||||
pub struct UpvarPath {
|
||||
pub hir_id: hir::HirId,
|
||||
}
|
||||
|
@ -680,7 +691,7 @@ pub struct UpvarPath {
|
|||
/// Upvars do not get their own `NodeId`. Instead, we use the pair of
|
||||
/// the original var ID (that is, the root variable that is referenced
|
||||
/// by the upvar) and the ID of the closure expression.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable, TypeFoldable, HashStable)]
|
||||
pub struct UpvarId {
|
||||
pub var_path: UpvarPath,
|
||||
pub closure_expr_id: LocalDefId,
|
||||
|
@ -692,7 +703,7 @@ impl UpvarId {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, TyEncodable, TyDecodable, Copy, HashStable)]
|
||||
#[derive(Clone, PartialEq, Debug, TyEncodable, TyDecodable, TypeFoldable, Copy, HashStable)]
|
||||
pub enum BorrowKind {
|
||||
/// Data must be immutable and is aliasable.
|
||||
ImmBorrow,
|
||||
|
@ -746,7 +757,7 @@ pub enum BorrowKind {
|
|||
|
||||
/// Information describing the capture of an upvar. This is computed
|
||||
/// during `typeck`, specifically by `regionck`.
|
||||
#[derive(PartialEq, Clone, Debug, Copy, TyEncodable, TyDecodable, HashStable)]
|
||||
#[derive(PartialEq, Clone, Debug, Copy, TyEncodable, TyDecodable, TypeFoldable, HashStable)]
|
||||
pub enum UpvarCapture<'tcx> {
|
||||
/// Upvar is captured by value. This is always true when the
|
||||
/// closure is labeled `move`, but can also be true in other cases
|
||||
|
@ -763,7 +774,7 @@ pub enum UpvarCapture<'tcx> {
|
|||
ByRef(UpvarBorrow<'tcx>),
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone, Copy, TyEncodable, TyDecodable, HashStable)]
|
||||
#[derive(PartialEq, Clone, Copy, TyEncodable, TyDecodable, TypeFoldable, HashStable)]
|
||||
pub struct UpvarBorrow<'tcx> {
|
||||
/// The kind of borrow: by-ref upvars have access to shared
|
||||
/// immutable borrows, which are not part of the normal language
|
||||
|
@ -790,7 +801,7 @@ pub type RootVariableMinCaptureList<'tcx> = FxIndexMap<hir::HirId, MinCaptureLis
|
|||
pub type MinCaptureList<'tcx> = Vec<CapturedPlace<'tcx>>;
|
||||
|
||||
/// A `Place` and the corresponding `CaptureInfo`.
|
||||
#[derive(PartialEq, Clone, Debug, TyEncodable, TyDecodable, HashStable)]
|
||||
#[derive(PartialEq, Clone, Debug, TyEncodable, TyDecodable, TypeFoldable, HashStable)]
|
||||
pub struct CapturedPlace<'tcx> {
|
||||
pub place: HirPlace<'tcx>,
|
||||
pub info: CaptureInfo<'tcx>,
|
||||
|
@ -799,7 +810,7 @@ pub struct CapturedPlace<'tcx> {
|
|||
/// Part of `MinCaptureInformationMap`; describes the capture kind (&, &mut, move)
|
||||
/// for a particular capture as well as identifying the part of the source code
|
||||
/// that triggered this capture to occur.
|
||||
#[derive(PartialEq, Clone, Debug, Copy, TyEncodable, TyDecodable, HashStable)]
|
||||
#[derive(PartialEq, Clone, Debug, Copy, TyEncodable, TyDecodable, TypeFoldable, HashStable)]
|
||||
pub struct CaptureInfo<'tcx> {
|
||||
/// Expr Id pointing to use that resulted in selecting the current capture kind
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue