use crate::hir::def::{CtorKind, Namespace};
use crate::hir::def_id::DefId;
use crate::hir::{self, InlineAsm as HirInlineAsm};
-use crate::mir::interpret::{ConstValue, PanicInfo, Scalar};
+use crate::mir::interpret::{PanicInfo, Scalar};
use crate::mir::visit::MirVisitable;
use crate::ty::adjustment::PointerCast;
use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
}
/// The lowered representation of a single function.
-#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, TypeFoldable)]
pub struct Body<'tcx> {
/// A list of basic blocks. References to basic block use a newtyped index type `BasicBlock`
/// that indexes into this vector.
}
}
-#[derive(Copy, Clone, Debug, HashStable)]
+#[derive(Copy, Clone, Debug, HashStable, TypeFoldable)]
pub enum ClearCrossCrate<T> {
Clear,
Set(T),
///
/// This can be a binding declared by the user, a temporary inserted by the compiler, a function
/// argument, or the return place.
-#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
+#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
pub struct LocalDecl<'tcx> {
/// Whether this is a mutable minding (i.e., `let x` or `let mut x`).
///
///////////////////////////////////////////////////////////////////////////
// BasicBlockData and Terminator
-#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
+#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
pub struct BasicBlockData<'tcx> {
/// List of statements in this block.
pub statements: Vec<Statement<'tcx>>,
values
.iter()
.map(|&u| {
- tcx.mk_const(ty::Const {
- val: ConstValue::Scalar(Scalar::from_uint(u, size).into()),
- ty: switch_ty,
- })
+ ty::Const::from_scalar(
+ tcx,
+ Scalar::from_uint(u, size).into(),
+ switch_ty,
+ )
.to_string()
.into()
})
///////////////////////////////////////////////////////////////////////////
// Statements
-#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
+#[derive(Clone, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
pub struct Statement<'tcx> {
pub source_info: SourceInfo,
pub kind: StatementKind<'tcx>,
}
}
-#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
+#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
pub enum StatementKind<'tcx> {
/// Write the RHS Rvalue to the LHS Place.
Assign(Box<(Place<'tcx>, Rvalue<'tcx>)>),
ForIndex,
}
-#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
+#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
pub struct InlineAsm<'tcx> {
pub asm: HirInlineAsm,
pub outputs: Box<[Place<'tcx>]>,
/// The first will lead to the constraint `w: &'1 str` (for some
/// inferred region `'1`). The second will lead to the constraint `w:
/// &'static str`.
-#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
+#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
pub struct UserTypeProjections {
pub(crate) contents: Vec<(UserTypeProjection, Span)>,
}
-BraceStructTypeFoldableImpl! {
- impl<'tcx> TypeFoldable<'tcx> for UserTypeProjections {
- contents
- }
-}
-
impl<'tcx> UserTypeProjections {
pub fn none() -> Self {
UserTypeProjections { contents: vec![] }
}
/// The layout of generator state.
-#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
+#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
pub struct GeneratorLayout<'tcx> {
/// The type of every local stored inside the generator.
pub field_tys: IndexVec<GeneratorSavedLocal, Ty<'tcx>>,
pub used_mut_upvars: SmallVec<[Field; 8]>,
}
+/// The result of the `mir_const_qualif` query.
+///
+/// Each field corresponds to an implementer of the `Qualif` trait in
+/// `librustc_mir/transform/check_consts/qualifs.rs`. See that file for more information on each
+/// `Qualif`.
+#[derive(Clone, Copy, Debug, Default, RustcEncodable, RustcDecodable, HashStable)]
+pub struct ConstQualifs {
+ pub has_mut_interior: bool,
+ pub needs_drop: bool,
+}
+
/// After we borrow check a closure, we are left with various
/// requirements that we have inferred between the free regions that
/// appear in the closure's signature or on its field types. These
UserTypeAnnotationIndex,
}
-BraceStructTypeFoldableImpl! {
- impl<'tcx> TypeFoldable<'tcx> for Body<'tcx> {
- phase,
- basic_blocks,
- source_scopes,
- source_scope_local_data,
- yield_ty,
- generator_drop,
- generator_layout,
- local_decls,
- user_type_annotations,
- arg_count,
- __upvar_debuginfo_codegen_only_do_not_use,
- spread_arg,
- control_flow_destroyed,
- span,
- cache,
- }
-}
-
-BraceStructTypeFoldableImpl! {
- impl<'tcx> TypeFoldable<'tcx> for GeneratorLayout<'tcx> {
- field_tys,
- variant_fields,
- storage_conflicts,
- __local_debuginfo_codegen_only_do_not_use,
- }
-}
-
-BraceStructTypeFoldableImpl! {
- impl<'tcx> TypeFoldable<'tcx> for LocalDecl<'tcx> {
- mutability,
- is_user_variable,
- internal,
- ty,
- user_ty,
- name,
- source_info,
- is_block_tail,
- visibility_scope,
- }
-}
-
-BraceStructTypeFoldableImpl! {
- impl<'tcx> TypeFoldable<'tcx> for BasicBlockData<'tcx> {
- statements,
- terminator,
- is_cleanup,
- }
-}
-
-BraceStructTypeFoldableImpl! {
- impl<'tcx> TypeFoldable<'tcx> for Statement<'tcx> {
- source_info, kind
- }
-}
-
-EnumTypeFoldableImpl! {
- impl<'tcx> TypeFoldable<'tcx> for StatementKind<'tcx> {
- (StatementKind::Assign)(a),
- (StatementKind::FakeRead)(cause, place),
- (StatementKind::SetDiscriminant) { place, variant_index },
- (StatementKind::StorageLive)(a),
- (StatementKind::StorageDead)(a),
- (StatementKind::InlineAsm)(a),
- (StatementKind::Retag)(kind, place),
- (StatementKind::AscribeUserType)(a, v),
- (StatementKind::Nop),
- }
-}
-
-BraceStructTypeFoldableImpl! {
- impl<'tcx> TypeFoldable<'tcx> for InlineAsm<'tcx> {
- asm,
- outputs,
- inputs,
- }
-}
-
-EnumTypeFoldableImpl! {
- impl<'tcx, T> TypeFoldable<'tcx> for ClearCrossCrate<T> {
- (ClearCrossCrate::Clear),
- (ClearCrossCrate::Set)(a),
- } where T: TypeFoldable<'tcx>
-}
-
impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
use crate::mir::TerminatorKind::*;