]> 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 ee83000c44003a92fb144c5c0da5d9c33260afe7..563fba52aefca4b13331e6b300fdb891c1adb60b 100644 (file)
@@ -1436,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_ {
@@ -1463,7 +1469,16 @@ pub enum Ty_ {
     TyTraitObject(HirVec<PolyTraitRef>, Lifetime),
     /// An exsitentially quantified (there exists a type satisfying) `impl
     /// Bound1 + Bound2 + Bound3` type where `Bound` is a trait or a lifetime.
-    TyImplTraitExistential(TyParamBounds),
+    ///
+    /// 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),