]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/hir/mod.rs
Fix impl Trait Lifetime Handling
[rust.git] / src / librustc / hir / mod.rs
index c9b1d70e7b60df57d2ebecc1c137384714a6ad97..563fba52aefca4b13331e6b300fdb891c1adb60b 100644 (file)
@@ -1028,6 +1028,18 @@ pub fn id(&self) -> BodyId {
     }
 }
 
+#[derive(Copy, Clone, Debug)]
+pub enum BodyOwnerKind {
+    /// Functions and methods.
+    Fn,
+
+    /// Constants and associated constants.
+    Const,
+
+    /// Initializer of a `static` item.
+    Static(Mutability),
+}
+
 /// An expression
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
 pub struct Expr {
@@ -1424,6 +1436,12 @@ pub struct BareFnTy {
     pub arg_names: HirVec<Spanned<Name>>,
 }
 
+#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+pub struct ExistTy {
+    pub generics: Generics,
+    pub bounds: TyParamBounds,
+}
+
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
 /// The different kinds of types recognized by the compiler
 pub enum Ty_ {
@@ -1449,9 +1467,21 @@ pub enum Ty_ {
     /// A trait object type `Bound1 + Bound2 + Bound3`
     /// where `Bound` is a trait or a lifetime.
     TyTraitObject(HirVec<PolyTraitRef>, Lifetime),
-    /// An `impl Bound1 + Bound2 + Bound3` type
-    /// where `Bound` is a trait or a lifetime.
-    TyImplTrait(TyParamBounds),
+    /// An exsitentially quantified (there exists a type satisfying) `impl
+    /// Bound1 + Bound2 + Bound3` type where `Bound` is a trait or a lifetime.
+    ///
+    /// The `ExistTy` structure emulates an
+    /// `abstract type Foo<'a, 'b>: MyTrait<'a, 'b>;`.
+    ///
+    /// The `HirVec<Lifetime>` is the list of lifetimes applied as parameters
+    /// to the `abstract type`, e.g. the `'c` and `'d` in `-> Foo<'c, 'd>`.
+    /// This list is only a list of lifetimes and not type parameters
+    /// because all in-scope type parameters are captured by `impl Trait`,
+    /// so they are resolved directly through the parent `Generics`.
+    TyImplTraitExistential(ExistTy, HirVec<Lifetime>),
+    /// An universally quantified (for all types satisfying) `impl
+    /// Bound1 + Bound2 + Bound3` type where `Bound` is a trait or a lifetime.
+    TyImplTraitUniversal(DefId, TyParamBounds),
     /// Unused for now
     TyTypeof(BodyId),
     /// TyInfer means the type should be inferred instead of it having been
@@ -1949,7 +1979,7 @@ pub fn descriptive_variant(&self) -> &str {
 }
 
 /// A free variable referred to in a function.
-#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
+#[derive(Debug, Copy, Clone, RustcEncodable, RustcDecodable)]
 pub struct Freevar {
     /// The variable being accessed free.
     pub def: Def,