]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/ty/adjustment.rs
update async-await send/sync test
[rust.git] / src / librustc / ty / adjustment.rs
index 0c04ba96365ed0999477921692c8ae7737186fac..db034d1618cea6cb35659e1792760e3418c47e5a 100644 (file)
@@ -1,10 +1,9 @@
-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.
@@ -82,6 +81,15 @@ pub struct Adjustment<'tcx> {
     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.
@@ -110,10 +118,13 @@ impl<'tcx> OverloadedDeref<'tcx> {
     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, &[]))
     }
 }
@@ -133,7 +144,7 @@ pub fn method_call(&self, tcx: TyCtxt<'tcx>, source: Ty<'tcx>) -> (DefId, Substs
 #[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable, HashStable)]
 pub enum AllowTwoPhase {
     Yes,
-    No
+    No,
 }
 
 #[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable, HashStable)]
@@ -172,11 +183,11 @@ pub struct CoerceUnsizedInfo {
     /// 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),
 }