]> git.lizzy.rs Git - rust.git/commitdiff
Restrict concrete types to equivalent types
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Tue, 29 Jan 2019 15:33:53 +0000 (16:33 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Fri, 1 Feb 2019 15:39:50 +0000 (16:39 +0100)
25 files changed:
src/librustc/ich/impls_ty.rs
src/librustc/infer/opaque_types/mod.rs
src/librustc/ty/context.rs
src/librustc/ty/mod.rs
src/librustc_typeck/check/writeback.rs
src/librustc_typeck/collect.rs
src/test/ui/existential_types/different_defining_uses.rs
src/test/ui/existential_types/different_defining_uses.stderr
src/test/ui/existential_types/different_defining_uses_never_type.rs
src/test/ui/existential_types/different_defining_uses_never_type.stderr
src/test/ui/existential_types/generic_different_defining_uses.rs
src/test/ui/existential_types/generic_different_defining_uses.stderr
src/test/ui/existential_types/generic_duplicate_param_use.rs
src/test/ui/existential_types/generic_duplicate_param_use.stderr [new file with mode: 0644]
src/test/ui/existential_types/generic_duplicate_param_use2.rs
src/test/ui/existential_types/generic_duplicate_param_use2.stderr [new file with mode: 0644]
src/test/ui/existential_types/generic_duplicate_param_use3.rs
src/test/ui/existential_types/generic_duplicate_param_use3.stderr [new file with mode: 0644]
src/test/ui/existential_types/generic_duplicate_param_use4.rs
src/test/ui/existential_types/generic_duplicate_param_use4.stderr [new file with mode: 0644]
src/test/ui/existential_types/generic_duplicate_param_use5.rs [new file with mode: 0644]
src/test/ui/existential_types/generic_duplicate_param_use5.stderr [new file with mode: 0644]
src/test/ui/existential_types/generic_duplicate_param_use6.rs [new file with mode: 0644]
src/test/ui/existential_types/generic_duplicate_param_use6.stderr [new file with mode: 0644]
src/test/ui/existential_types/generic_duplicate_param_use7.rs [new file with mode: 0644]

index bd2349161f74a9f8856c238f53067312bcb704a6..040494a2799413e060ab7513078041fc90d55523 100644 (file)
@@ -233,6 +233,11 @@ fn hash_stable<W: StableHasherResult>(&self,
     abi
 });
 
+impl_stable_hash_for!(struct ty::ResolvedOpaqueTy<'tcx> {
+    concrete_type,
+    substs
+});
+
 impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> for ty::Binder<T>
     where T: HashStable<StableHashingContext<'a>>
 {
index 5e94bb1f877fb2539521a23fbdc759cec8cc80d7..eabbb943c6ef2e60bc437ba28984f2bbbeaad517 100644 (file)
@@ -26,7 +26,7 @@ pub struct OpaqueTypeDecl<'tcx> {
     ///
     /// winds up desugared to:
     ///
-    ///     abstract type Foo<'x, T>: Trait<'x>
+    ///     abstract type Foo<'x, X>: Trait<'x>
     ///     fn foo<'a, 'b, T>() -> Foo<'a, T>
     ///
     /// then `substs` would be `['a, T]`.
index 881c0d4e6d23938fc2a982be712b2c9f07953763..350dcdf571be37b5467dec91c25b901438cef8bf 100644 (file)
@@ -315,6 +315,17 @@ pub fn remove(&mut self, id: hir::HirId) -> Option<V> {
     }
 }
 
+/// All information necessary to validate and reveal an `impl Trait` or `existential Type`
+#[derive(RustcEncodable, RustcDecodable, Debug)]
+pub struct ResolvedOpaqueTy<'tcx> {
+    /// The revealed type as seen by this function.
+    pub concrete_type: Ty<'tcx>,
+    /// Generic parameters on the opaque type as passed by this function.
+    /// For `existential type Foo<A, B>; fn foo<T, U>() -> Foo<T, U> { .. }` this is `[T, U]`, not
+    /// `[A, B]`
+    pub substs: &'tcx Substs<'tcx>,
+}
+
 #[derive(RustcEncodable, RustcDecodable, Debug)]
 pub struct TypeckTables<'tcx> {
     /// The HirId::owner all ItemLocalIds in this table are relative to.
@@ -417,7 +428,7 @@ pub struct TypeckTables<'tcx> {
 
     /// All the existential types that are restricted to concrete types
     /// by this function
-    pub concrete_existential_types: FxHashMap<DefId, Ty<'tcx>>,
+    pub concrete_existential_types: FxHashMap<DefId, ResolvedOpaqueTy<'tcx>>,
 
     /// Given the closure ID this map provides the list of UpvarIDs used by it.
     /// The upvarID contains the HIR node ID and it also contains the full path
index c9089428b23245c24ac45af7bdc3f46325c51560..3a7441e9215df8dec869bbcfd5a107db2995aa33 100644 (file)
@@ -74,7 +74,7 @@
 pub use self::context::{Lift, TypeckTables, CtxtInterners};
 pub use self::context::{
     UserTypeAnnotationIndex, UserType, CanonicalUserType,
-    CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations,
+    CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, ResolvedOpaqueTy,
 };
 
 pub use self::instance::{Instance, InstanceDef};
index 00917be538fb3305a6aea4df5ac5b848e99f6acf..c9dd83dcd5e2282ab5ef82fe910207e46288c861 100644 (file)
@@ -567,17 +567,23 @@ fn visit_opaque_types(&mut self, span: Span) {
                 }
             }
 
+            let new = ty::ResolvedOpaqueTy {
+                concrete_type: definition_ty,
+                substs: self.tcx().lift_to_global(&opaque_defn.substs).unwrap(),
+            };
+
             let old = self.tables
                 .concrete_existential_types
-                .insert(def_id, definition_ty);
+                .insert(def_id, new);
             if let Some(old) = old {
-                if old != definition_ty {
+                if old.concrete_type != definition_ty || old.substs != opaque_defn.substs {
                     span_bug!(
                         span,
                         "visit_opaque_types tried to write \
-                        different types for the same existential type: {:?}, {:?}, {:?}",
+                        different types for the same existential type: {:?}, {:?}, {:?}, {:?}",
                         def_id,
                         definition_ty,
+                        opaque_defn,
                         old,
                     );
                 }
index e4fc1925eb377923c5ee94587543ec25c5415121..7cdcfec339eeeed6eb41cd479e0be4e9d8a17544 100644 (file)
 use middle::weak_lang_items;
 use rustc::mir::mono::Linkage;
 use rustc::ty::query::Providers;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::{Subst, Substs};
 use rustc::ty::util::Discr;
 use rustc::ty::util::IntTypeExt;
+use rustc::ty::subst::UnpackedKind;
 use rustc::ty::{self, AdtKind, ToPolyTraitRef, Ty, TyCtxt};
 use rustc::ty::{ReprOptions, ToPredicate};
 use rustc::util::captures::Captures;
@@ -1193,7 +1194,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
                     tcx.typeck_tables_of(owner)
                         .concrete_existential_types
                         .get(&def_id)
-                        .cloned()
+                        .map(|opaque| opaque.concrete_type)
                         .unwrap_or_else(|| {
                             // This can occur if some error in the
                             // owner fn prevented us from populating
@@ -1325,7 +1326,13 @@ fn find_existential_constraints<'a, 'tcx>(
     struct ConstraintLocator<'a, 'tcx: 'a> {
         tcx: TyCtxt<'a, 'tcx, 'tcx>,
         def_id: DefId,
-        found: Option<(Span, ty::Ty<'tcx>)>,
+        // First found type span, actual type, mapping from the existential type's generic
+        // parameters to the concrete type's generic parameters
+        //
+        // The mapping is an index for each use site of a generic parameter in the concrete type
+        //
+        // The indices index into the generic parameters on the existential type.
+        found: Option<(Span, ty::Ty<'tcx>, Vec<usize>)>,
     }
 
     impl<'a, 'tcx> ConstraintLocator<'a, 'tcx> {
@@ -1340,13 +1347,50 @@ fn check(&mut self, def_id: DefId) {
                 .tcx
                 .typeck_tables_of(def_id)
                 .concrete_existential_types
-                .get(&self.def_id)
-                .cloned();
-            if let Some(ty) = ty {
+                .get(&self.def_id);
+            if let Some(ty::ResolvedOpaqueTy { concrete_type, substs }) = ty {
                 // FIXME(oli-obk): trace the actual span from inference to improve errors
                 let span = self.tcx.def_span(def_id);
-                if let Some((prev_span, prev_ty)) = self.found {
-                    let mut ty = ty.walk().fuse();
+                // used to quickly look up the position of a generic parameter
+                let mut index_map: FxHashMap<ty::ParamTy, usize> = FxHashMap::default();
+                // skip binder is ok, since we only use this to find generic parameters and their
+                // positions.
+                for subst in substs.iter() {
+                    if let UnpackedKind::Type(ty) = subst.unpack() {
+                        if let ty::Param(p) = ty.sty {
+                            let idx = index_map.len();
+                            if index_map.insert(p, idx).is_some() {
+                                // there was already an entry for `p`, meaning a generic parameter
+                                // was used twice
+                                self.tcx.sess.span_err(
+                                    span,
+                                    &format!("defining existential type use restricts existential \
+                                    type by using the generic parameter `{}` twice", p.name),
+                                );
+                                return;
+                            }
+                        } else {
+                            self.tcx.sess.delay_span_bug(
+                                span,
+                                &format!(
+                                    "non-defining exist ty use in defining scope: {:?}, {:?}",
+                                    concrete_type, substs,
+                                ),
+                            );
+                        }
+                    }
+                }
+                // compute the index within the existential type for each generic parameter used in
+                // the concrete type
+                let indices = concrete_type
+                    .subst(self.tcx, substs)
+                    .walk()
+                    .filter_map(|t| match &t.sty {
+                    ty::Param(p) => Some(*index_map.get(p).unwrap()),
+                    _ => None,
+                }).collect();
+                if let Some((prev_span, prev_ty, ref prev_indices)) = self.found {
+                    let mut ty = concrete_type.walk().fuse();
                     let mut prev_ty = prev_ty.walk().fuse();
                     let iter_eq = (&mut ty).zip(&mut prev_ty).all(|(t, p)| match (&t.sty, &p.sty) {
                         // type parameters are equal to any other type parameter for the purpose of
@@ -1359,13 +1403,21 @@ fn check(&mut self, def_id: DefId) {
                         // found different concrete types for the existential type
                         let mut err = self.tcx.sess.struct_span_err(
                             span,
-                            "defining existential type use differs from previous",
+                            "concrete type differs from previous defining existential type use",
+                        );
+                        err.span_note(prev_span, "previous use here");
+                        err.emit();
+                    } else if indices != *prev_indices {
+                        // found "same" concrete types, but the generic parameter order differs
+                        let mut err = self.tcx.sess.struct_span_err(
+                            span,
+                            "concrete type's generic parameters differ from previous defining use",
                         );
                         err.span_note(prev_span, "previous use here");
                         err.emit();
                     }
                 } else {
-                    self.found = Some((span, ty));
+                    self.found = Some((span, concrete_type, indices));
                 }
             }
         }
@@ -1424,7 +1476,7 @@ fn visit_trait_item(&mut self, it: &'tcx TraitItem) {
     }
 
     match locator.found {
-        Some((_, ty)) => ty,
+        Some((_, ty, _)) => ty,
         None => {
             let span = tcx.def_span(def_id);
             tcx.sess.span_err(span, "could not find defining uses");
index c51fca75a24e928c834c111f2e35b6f760fe356a..a8670cc07f2e1370494dd82736fa27b7091e7b5d 100644 (file)
@@ -9,6 +9,6 @@ fn foo() -> Foo {
     ""
 }
 
-fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
+fn bar() -> Foo { //~ ERROR concrete type differs from previous
     42i32
 }
index f782a002297329eb8f3e886ef8e12c815d0ce851..3b3449bbf11f4944dec725e14b6a22fbe7236c86 100644 (file)
@@ -1,7 +1,7 @@
-error: defining existential type use differs from previous
+error: concrete type differs from previous defining existential type use
   --> $DIR/different_defining_uses.rs:12:1
    |
-LL | / fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
+LL | / fn bar() -> Foo { //~ ERROR concrete type differs from previous
 LL | |     42i32
 LL | | }
    | |_^
index c6c6ae8d2dccffea5c4112d6c9be38713303ca5a..13ada63e4bc45fa256ee6f9286feb19f419be862 100644 (file)
@@ -9,10 +9,10 @@ fn foo() -> Foo {
     ""
 }
 
-fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
+fn bar() -> Foo { //~ ERROR concrete type differs from previous
     panic!()
 }
 
-fn boo() -> Foo { //~ ERROR defining existential type use differs from previous
+fn boo() -> Foo { //~ ERROR concrete type differs from previous
     loop {}
 }
index 04b0cf277845514567e8f8e3dbd4cf17b627fc77..161111e3379f5a2be2d78742211d908e9438d697 100644 (file)
@@ -1,7 +1,7 @@
-error: defining existential type use differs from previous
+error: concrete type differs from previous defining existential type use
   --> $DIR/different_defining_uses_never_type.rs:12:1
    |
-LL | / fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
+LL | / fn bar() -> Foo { //~ ERROR concrete type differs from previous
 LL | |     panic!()
 LL | | }
    | |_^
@@ -14,10 +14,10 @@ LL | |     ""
 LL | | }
    | |_^
 
-error: defining existential type use differs from previous
+error: concrete type differs from previous defining existential type use
   --> $DIR/different_defining_uses_never_type.rs:16:1
    |
-LL | / fn boo() -> Foo { //~ ERROR defining existential type use differs from previous
+LL | / fn boo() -> Foo { //~ ERROR concrete type differs from previous
 LL | |     loop {}
 LL | | }
    | |_^
index 3bd104251fb700abdb7a49da585a077ec513b23a..ce3ab88a1c0bbe8cb3113075863571659568bff4 100644 (file)
@@ -8,6 +8,6 @@ fn my_iter<T>(t: T) -> MyIter<T> {
     std::iter::once(t)
 }
 
-fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR defining existential type use differs from previous
+fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR concrete type differs from previous
     Some(t).into_iter()
 }
index 234bcf232ae794d58be14cdf7c2c8bd7d694fca6..89f70a873d9dc6799fcdea6d39b8a356462619db 100644 (file)
@@ -1,7 +1,7 @@
-error: defining existential type use differs from previous
+error: concrete type differs from previous defining existential type use
   --> $DIR/generic_different_defining_uses.rs:11:1
    |
-LL | / fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR defining existential type use differs from previous
+LL | / fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR concrete type differs from previous
 LL | |     Some(t).into_iter()
 LL | | }
    | |_^
index d08cd88c600d083e0ab339bcd255b3c5c95721d7..3f8753333aa7a2b77fd3000ece68ff39f3e8efd0 100644 (file)
@@ -1,4 +1,3 @@
-// compile-pass
 #![feature(existential_type)]
 
 use std::fmt::Debug;
@@ -7,7 +6,9 @@ fn main() {}
 
 // test that unused generic parameters are ok
 existential type Two<T, U>: Debug;
+//~^ could not find defining uses
 
 fn one<T: Debug>(t: T) -> Two<T, T> {
+//~^ ERROR defining existential type use restricts existential type
     t
 }
diff --git a/src/test/ui/existential_types/generic_duplicate_param_use.stderr b/src/test/ui/existential_types/generic_duplicate_param_use.stderr
new file mode 100644 (file)
index 0000000..d4deda9
--- /dev/null
@@ -0,0 +1,17 @@
+error: defining existential type use restricts existential type by using the generic parameter `T` twice
+  --> $DIR/generic_duplicate_param_use.rs:11:1
+   |
+LL | / fn one<T: Debug>(t: T) -> Two<T, T> {
+LL | | //~^ ERROR defining existential type use restricts existential type
+LL | |     t
+LL | | }
+   | |_^
+
+error: could not find defining uses
+  --> $DIR/generic_duplicate_param_use.rs:8:1
+   |
+LL | existential type Two<T, U>: Debug;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
index c27fbb74cf19d5fa1a7e68e333ac4bfec525af52..3842292decd57e4badb7074a659cce91169a0e87 100644 (file)
@@ -1,4 +1,3 @@
-// compile-pass
 #![feature(existential_type)]
 
 use std::fmt::Debug;
@@ -9,6 +8,7 @@ fn main() {}
 existential type Two<T, U>: Debug;
 
 fn one<T: Debug>(t: T) -> Two<T, T> {
+//~^ defining existential type use restricts existential type
     t
 }
 
diff --git a/src/test/ui/existential_types/generic_duplicate_param_use2.stderr b/src/test/ui/existential_types/generic_duplicate_param_use2.stderr
new file mode 100644 (file)
index 0000000..0a8be32
--- /dev/null
@@ -0,0 +1,11 @@
+error: defining existential type use restricts existential type by using the generic parameter `T` twice
+  --> $DIR/generic_duplicate_param_use2.rs:10:1
+   |
+LL | / fn one<T: Debug>(t: T) -> Two<T, T> {
+LL | | //~^ defining existential type use restricts existential type
+LL | |     t
+LL | | }
+   | |_^
+
+error: aborting due to previous error
+
index b4d1b26dbabda388bdf651fa7f42f0fe9a103ddc..05c77c8947333c241832c32915f7c17721177227 100644 (file)
@@ -1,4 +1,3 @@
-// compile-pass
 #![feature(existential_type)]
 
 use std::fmt::Debug;
@@ -9,6 +8,7 @@ fn main() {}
 existential type Two<T, U>: Debug;
 
 fn one<T: Debug>(t: T) -> Two<T, T> {
+//~^ defining existential type use restricts existential type
     t
 }
 
@@ -17,5 +17,6 @@ fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> {
 }
 
 fn three<T, U: Debug>(_: T, u: U) -> Two<T, U> {
+//~^ concrete type's generic parameters differ from previous defining use
     u
 }
diff --git a/src/test/ui/existential_types/generic_duplicate_param_use3.stderr b/src/test/ui/existential_types/generic_duplicate_param_use3.stderr
new file mode 100644 (file)
index 0000000..8f860e7
--- /dev/null
@@ -0,0 +1,28 @@
+error: defining existential type use restricts existential type by using the generic parameter `T` twice
+  --> $DIR/generic_duplicate_param_use3.rs:10:1
+   |
+LL | / fn one<T: Debug>(t: T) -> Two<T, T> {
+LL | | //~^ defining existential type use restricts existential type
+LL | |     t
+LL | | }
+   | |_^
+
+error: concrete type's generic parameters differ from previous defining use
+  --> $DIR/generic_duplicate_param_use3.rs:19:1
+   |
+LL | / fn three<T, U: Debug>(_: T, u: U) -> Two<T, U> {
+LL | | //~^ concrete type's generic parameters differ from previous defining use
+LL | |     u
+LL | | }
+   | |_^
+   |
+note: previous use here
+  --> $DIR/generic_duplicate_param_use3.rs:15:1
+   |
+LL | / fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> {
+LL | |     t
+LL | | }
+   | |_^
+
+error: aborting due to 2 previous errors
+
index afab86c3ff07589107928a0f05c8f7fed700e4f4..609dbe06cd7335c39f485e13e62ea84b65612625 100644 (file)
@@ -1,4 +1,3 @@
-// compile-pass
 #![feature(existential_type)]
 
 use std::fmt::Debug;
@@ -9,6 +8,7 @@ fn main() {}
 existential type Two<T, U>: Debug;
 
 fn one<T: Debug>(t: T) -> Two<T, T> {
+//~^ ERROR defining existential type use restricts existential type
     t
 }
 
diff --git a/src/test/ui/existential_types/generic_duplicate_param_use4.stderr b/src/test/ui/existential_types/generic_duplicate_param_use4.stderr
new file mode 100644 (file)
index 0000000..24b1caf
--- /dev/null
@@ -0,0 +1,11 @@
+error: defining existential type use restricts existential type by using the generic parameter `T` twice
+  --> $DIR/generic_duplicate_param_use4.rs:10:1
+   |
+LL | / fn one<T: Debug>(t: T) -> Two<T, T> {
+LL | | //~^ ERROR defining existential type use restricts existential type
+LL | |     t
+LL | | }
+   | |_^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/existential_types/generic_duplicate_param_use5.rs b/src/test/ui/existential_types/generic_duplicate_param_use5.rs
new file mode 100644 (file)
index 0000000..3f4a23b
--- /dev/null
@@ -0,0 +1,17 @@
+#![feature(existential_type)]
+
+use std::fmt::Debug;
+
+fn main() {}
+
+// test that unused generic parameters are ok
+existential type Two<T, U>: Debug;
+
+fn two<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
+    (t, u)
+}
+
+fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
+//~^ concrete type differs from previous
+    (u, t)
+}
diff --git a/src/test/ui/existential_types/generic_duplicate_param_use5.stderr b/src/test/ui/existential_types/generic_duplicate_param_use5.stderr
new file mode 100644 (file)
index 0000000..52befb9
--- /dev/null
@@ -0,0 +1,19 @@
+error: concrete type differs from previous defining existential type use
+  --> $DIR/generic_duplicate_param_use5.rs:14:1
+   |
+LL | / fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
+LL | | //~^ concrete type differs from previous
+LL | |     (u, t)
+LL | | }
+   | |_^
+   |
+note: previous use here
+  --> $DIR/generic_duplicate_param_use5.rs:10:1
+   |
+LL | / fn two<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
+LL | |     (t, u)
+LL | | }
+   | |_^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/existential_types/generic_duplicate_param_use6.rs b/src/test/ui/existential_types/generic_duplicate_param_use6.rs
new file mode 100644 (file)
index 0000000..3b8c563
--- /dev/null
@@ -0,0 +1,17 @@
+#![feature(existential_type)]
+
+use std::fmt::Debug;
+
+fn main() {}
+
+// test that unused generic parameters are ok
+existential type Two<T, U>: Debug;
+
+fn two<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
+    (t, t)
+}
+
+fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
+//~^ concrete type differs from previous
+    (u, t)
+}
diff --git a/src/test/ui/existential_types/generic_duplicate_param_use6.stderr b/src/test/ui/existential_types/generic_duplicate_param_use6.stderr
new file mode 100644 (file)
index 0000000..2bf1d0c
--- /dev/null
@@ -0,0 +1,19 @@
+error: concrete type differs from previous defining existential type use
+  --> $DIR/generic_duplicate_param_use6.rs:14:1
+   |
+LL | / fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
+LL | | //~^ concrete type differs from previous
+LL | |     (u, t)
+LL | | }
+   | |_^
+   |
+note: previous use here
+  --> $DIR/generic_duplicate_param_use6.rs:10:1
+   |
+LL | / fn two<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
+LL | |     (t, t)
+LL | | }
+   | |_^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/existential_types/generic_duplicate_param_use7.rs b/src/test/ui/existential_types/generic_duplicate_param_use7.rs
new file mode 100644 (file)
index 0000000..3906b85
--- /dev/null
@@ -0,0 +1,16 @@
+// compile-pass
+#![feature(existential_type)]
+
+use std::fmt::Debug;
+
+fn main() {}
+
+existential type Two<A, B>: Debug;
+
+fn two<T: Debug + Copy, U>(t: T, u: U) -> Two<T, U> {
+    (t, t)
+}
+
+fn three<T: Debug, U>(t: T, t2: T, u: U) -> Two<T, U> {
+    (t, t2)
+}