-use crate::hir;
-use crate::hir::def_id::DefId;
-use crate::ty::{self, Ty, TyCtxt};
use crate::ty::subst::SubstsRef;
+use crate::ty::{self, Ty, TyCtxt};
+use rustc_hir as hir;
+use rustc_hir::def_id::DefId;
use rustc_macros::HashStable;
-
#[derive(Clone, Copy, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable)]
pub enum PointerCast {
/// Go from a fn-item type to a fn-pointer type.
pub target: Ty<'tcx>,
}
+impl Adjustment<'tcx> {
+ pub fn is_region_borrow(&self) -> bool {
+ match self.kind {
+ Adjust::Borrow(AutoBorrow::Ref(..)) => true,
+ _ => false,
+ }
+ }
+}
+
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
pub enum Adjust<'tcx> {
/// Go from ! to any type.
pub fn method_call(&self, tcx: TyCtxt<'tcx>, source: Ty<'tcx>) -> (DefId, SubstsRef<'tcx>) {
let trait_def_id = match self.mutbl {
hir::Mutability::Not => tcx.lang_items().deref_trait(),
- hir::Mutability::Mut => tcx.lang_items().deref_mut_trait()
+ hir::Mutability::Mut => tcx.lang_items().deref_mut_trait(),
};
- let method_def_id = tcx.associated_items(trait_def_id.unwrap())
- .find(|m| m.kind == ty::AssocKind::Method).unwrap().def_id;
+ let method_def_id = tcx
+ .associated_items(trait_def_id.unwrap())
+ .find(|m| m.kind == ty::AssocKind::Method)
+ .unwrap()
+ .def_id;
(method_def_id, tcx.mk_substs_trait(source, &[]))
}
}
#[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable, HashStable)]
pub enum AllowTwoPhase {
Yes,
- No
+ No,
}
#[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable, HashStable)]
/// coercion is it? This applies to impls of `CoerceUnsized` for
/// structs, primarily, where we store a bit of info about which
/// fields need to be coerced.
- pub custom_kind: Option<CustomCoerceUnsized>
+ pub custom_kind: Option<CustomCoerceUnsized>,
}
#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, HashStable)]
pub enum CustomCoerceUnsized {
/// Records the index of the field being coerced.
- Struct(usize)
+ Struct(usize),
}