summaryrefslogtreecommitdiffstats
path: root/tests/ui/generics
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/generics')
-rw-r--r--tests/ui/generics/autobind.rs12
-rw-r--r--tests/ui/generics/auxiliary/default_type_params_xc.rs5
-rw-r--r--tests/ui/generics/bad-mid-path-type-params.rs44
-rw-r--r--tests/ui/generics/bad-mid-path-type-params.stderr73
-rw-r--r--tests/ui/generics/generic-alias-unique.rs10
-rw-r--r--tests/ui/generics/generic-arg-mismatch-recover.rs12
-rw-r--r--tests/ui/generics/generic-arg-mismatch-recover.stderr45
-rw-r--r--tests/ui/generics/generic-default-type-params-cross-crate.rs17
-rw-r--r--tests/ui/generics/generic-default-type-params.rs53
-rw-r--r--tests/ui/generics/generic-derived-type.rs21
-rw-r--r--tests/ui/generics/generic-exterior-unique.rs11
-rw-r--r--tests/ui/generics/generic-extern-lifetime.rs15
-rw-r--r--tests/ui/generics/generic-extern-lifetime.stderr42
-rw-r--r--tests/ui/generics/generic-extern-mangle.rs9
-rw-r--r--tests/ui/generics/generic-extern.rs7
-rw-r--r--tests/ui/generics/generic-extern.stderr11
-rw-r--r--tests/ui/generics/generic-fn-infer.rs10
-rw-r--r--tests/ui/generics/generic-fn-twice.rs11
-rw-r--r--tests/ui/generics/generic-fn-unique.rs8
-rw-r--r--tests/ui/generics/generic-fn.rs28
-rw-r--r--tests/ui/generics/generic-function-item-where-type.rs6
-rw-r--r--tests/ui/generics/generic-function-item-where-type.stderr12
-rw-r--r--tests/ui/generics/generic-impl-less-params-with-defaults.rs13
-rw-r--r--tests/ui/generics/generic-impl-less-params-with-defaults.stderr21
-rw-r--r--tests/ui/generics/generic-impl-more-params-with-defaults.rs15
-rw-r--r--tests/ui/generics/generic-impl-more-params-with-defaults.stderr17
-rw-r--r--tests/ui/generics/generic-ivec-leak.rs5
-rw-r--r--tests/ui/generics/generic-lifetime-trait-impl.rs23
-rw-r--r--tests/ui/generics/generic-lifetime-trait-impl.stderr12
-rw-r--r--tests/ui/generics/generic-newtype-struct.rs8
-rw-r--r--tests/ui/generics/generic-no-mangle.fixed159
-rw-r--r--tests/ui/generics/generic-no-mangle.rs159
-rw-r--r--tests/ui/generics/generic-no-mangle.stderr144
-rw-r--r--tests/ui/generics/generic-non-trailing-defaults.rs10
-rw-r--r--tests/ui/generics/generic-non-trailing-defaults.stderr21
-rw-r--r--tests/ui/generics/generic-object.rs21
-rw-r--r--tests/ui/generics/generic-param-attrs.rs38
-rw-r--r--tests/ui/generics/generic-recursive-tag.rs12
-rw-r--r--tests/ui/generics/generic-static-methods.rs21
-rw-r--r--tests/ui/generics/generic-tag-corruption.rs10
-rw-r--r--tests/ui/generics/generic-tag-local.rs8
-rw-r--r--tests/ui/generics/generic-tag-match.rs13
-rw-r--r--tests/ui/generics/generic-tag-values.rs20
-rw-r--r--tests/ui/generics/generic-tag.rs14
-rw-r--r--tests/ui/generics/generic-temporary.rs16
-rw-r--r--tests/ui/generics/generic-tup.rs8
-rw-r--r--tests/ui/generics/generic-type-less-params-with-defaults.rs11
-rw-r--r--tests/ui/generics/generic-type-less-params-with-defaults.stderr19
-rw-r--r--tests/ui/generics/generic-type-more-params-with-defaults.rs11
-rw-r--r--tests/ui/generics/generic-type-more-params-with-defaults.stderr17
-rw-r--r--tests/ui/generics/generic-type-params-forward-mention.rs6
-rw-r--r--tests/ui/generics/generic-type-params-forward-mention.stderr9
-rw-r--r--tests/ui/generics/generic-type-params-name-repr.rs51
-rw-r--r--tests/ui/generics/generic-type-params-name-repr.stderr69
-rw-r--r--tests/ui/generics/generic-type-synonym.rs15
-rw-r--r--tests/ui/generics/generic-type.rs11
-rw-r--r--tests/ui/generics/generic-unique.rs11
-rw-r--r--tests/ui/generics/issue-106694.rs24
-rw-r--r--tests/ui/generics/issue-106694.stderr93
-rw-r--r--tests/ui/generics/issue-1112.rs37
-rw-r--r--tests/ui/generics/issue-2936.rs31
-rw-r--r--tests/ui/generics/issue-32498.rs16
-rw-r--r--tests/ui/generics/issue-333.rs7
-rw-r--r--tests/ui/generics/issue-59508-1.rs16
-rw-r--r--tests/ui/generics/issue-59508-1.stderr8
-rw-r--r--tests/ui/generics/issue-59508.fixed16
-rw-r--r--tests/ui/generics/issue-59508.rs16
-rw-r--r--tests/ui/generics/issue-59508.stderr8
-rw-r--r--tests/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.rs20
-rw-r--r--tests/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr16
-rw-r--r--tests/ui/generics/issue-61631-default-type-param-cannot-reference-self.rs45
-rw-r--r--tests/ui/generics/issue-61631-default-type-param-cannot-reference-self.stderr39
-rw-r--r--tests/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs15
-rw-r--r--tests/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr57
-rw-r--r--tests/ui/generics/issue-80512-param-reordering-with-defaults.rs4
-rw-r--r--tests/ui/generics/issue-80512-param-reordering-with-defaults.stderr8
-rw-r--r--tests/ui/generics/issue-94432-garbage-ice.rs10
-rw-r--r--tests/ui/generics/issue-94923.rs49
-rw-r--r--tests/ui/generics/issue-95208-ignore-qself.fixed11
-rw-r--r--tests/ui/generics/issue-95208-ignore-qself.rs11
-rw-r--r--tests/ui/generics/issue-95208-ignore-qself.stderr10
-rw-r--r--tests/ui/generics/issue-95208.fixed11
-rw-r--r--tests/ui/generics/issue-95208.rs11
-rw-r--r--tests/ui/generics/issue-95208.stderr10
-rw-r--r--tests/ui/generics/issue-98432.rs9
-rw-r--r--tests/ui/generics/issue-98432.stderr14
-rw-r--r--tests/ui/generics/lifetime-before-type-params.rs11
-rw-r--r--tests/ui/generics/lifetime-before-type-params.stderr26
-rw-r--r--tests/ui/generics/mid-path-type-params.rs37
-rw-r--r--tests/ui/generics/param-in-ct-in-ty-param-default.rs4
-rw-r--r--tests/ui/generics/param-in-ct-in-ty-param-default.stderr11
-rw-r--r--tests/ui/generics/post_monomorphization_error_backtrace.rs33
-rw-r--r--tests/ui/generics/post_monomorphization_error_backtrace.stderr31
-rw-r--r--tests/ui/generics/single-colon-path-not-const-generics.rs13
-rw-r--r--tests/ui/generics/single-colon-path-not-const-generics.stderr11
-rw-r--r--tests/ui/generics/type-params-in-for-each.rs23
-rw-r--r--tests/ui/generics/wrong-number-of-args.rs358
-rw-r--r--tests/ui/generics/wrong-number-of-args.stderr1013
98 files changed, 3673 insertions, 0 deletions
diff --git a/tests/ui/generics/autobind.rs b/tests/ui/generics/autobind.rs
new file mode 100644
index 000000000..70606a2a2
--- /dev/null
+++ b/tests/ui/generics/autobind.rs
@@ -0,0 +1,12 @@
+// run-pass
+
+fn f<T>(x: Vec<T>) -> T { return x.into_iter().next().unwrap(); }
+
+fn g<F>(act: F) -> isize where F: FnOnce(Vec<isize>) -> isize { return act(vec![1, 2, 3]); }
+
+pub fn main() {
+ assert_eq!(g(f), 1);
+ let f1 = f;
+ assert_eq!(f1(vec!["x".to_string(), "y".to_string(), "z".to_string()]),
+ "x".to_string());
+}
diff --git a/tests/ui/generics/auxiliary/default_type_params_xc.rs b/tests/ui/generics/auxiliary/default_type_params_xc.rs
new file mode 100644
index 000000000..aacbd672a
--- /dev/null
+++ b/tests/ui/generics/auxiliary/default_type_params_xc.rs
@@ -0,0 +1,5 @@
+pub struct Heap;
+
+pub struct FakeHeap;
+
+pub struct FakeVec<T, A = FakeHeap> { pub f: Option<(T,A)> }
diff --git a/tests/ui/generics/bad-mid-path-type-params.rs b/tests/ui/generics/bad-mid-path-type-params.rs
new file mode 100644
index 000000000..23a5d1525
--- /dev/null
+++ b/tests/ui/generics/bad-mid-path-type-params.rs
@@ -0,0 +1,44 @@
+struct S<T> {
+ contents: T,
+}
+
+impl<T> S<T> {
+ fn new<U>(x: T, _: U) -> S<T> {
+ S {
+ contents: x,
+ }
+ }
+}
+
+trait Trait<T> {
+ fn new<U>(x: T, y: U) -> Self;
+}
+
+struct S2 {
+ contents: isize,
+}
+
+impl Trait<isize> for S2 {
+ fn new<U>(x: isize, _: U) -> S2 {
+ S2 {
+ contents: x,
+ }
+ }
+}
+
+fn foo<'a>() {
+ let _ = S::new::<isize,f64>(1, 1.0);
+ //~^ ERROR this associated function takes 1
+
+ let _ = S::<'a,isize>::new::<f64>(1, 1.0);
+ //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
+
+ let _: S2 = Trait::new::<isize,f64>(1, 1.0);
+ //~^ ERROR this associated function takes 1
+
+ let _: S2 = Trait::<'a,isize>::new::<f64,f64>(1, 1.0);
+ //~^ ERROR this trait takes 0 lifetime arguments but 1 lifetime argument was supplied
+ //~| ERROR this associated function takes 1
+}
+
+fn main() {}
diff --git a/tests/ui/generics/bad-mid-path-type-params.stderr b/tests/ui/generics/bad-mid-path-type-params.stderr
new file mode 100644
index 000000000..aee2b6015
--- /dev/null
+++ b/tests/ui/generics/bad-mid-path-type-params.stderr
@@ -0,0 +1,73 @@
+error[E0107]: this associated function takes 1 generic argument but 2 generic arguments were supplied
+ --> $DIR/bad-mid-path-type-params.rs:30:16
+ |
+LL | let _ = S::new::<isize,f64>(1, 1.0);
+ | ^^^ --- help: remove this generic argument
+ | |
+ | expected 1 generic argument
+ |
+note: associated function defined here, with 1 generic parameter: `U`
+ --> $DIR/bad-mid-path-type-params.rs:6:8
+ |
+LL | fn new<U>(x: T, _: U) -> S<T> {
+ | ^^^ -
+
+error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
+ --> $DIR/bad-mid-path-type-params.rs:33:13
+ |
+LL | let _ = S::<'a,isize>::new::<f64>(1, 1.0);
+ | ^ -- help: remove this lifetime argument
+ | |
+ | expected 0 lifetime arguments
+ |
+note: struct defined here, with 0 lifetime parameters
+ --> $DIR/bad-mid-path-type-params.rs:1:8
+ |
+LL | struct S<T> {
+ | ^
+
+error[E0107]: this associated function takes 1 generic argument but 2 generic arguments were supplied
+ --> $DIR/bad-mid-path-type-params.rs:36:24
+ |
+LL | let _: S2 = Trait::new::<isize,f64>(1, 1.0);
+ | ^^^ --- help: remove this generic argument
+ | |
+ | expected 1 generic argument
+ |
+note: associated function defined here, with 1 generic parameter: `U`
+ --> $DIR/bad-mid-path-type-params.rs:14:8
+ |
+LL | fn new<U>(x: T, y: U) -> Self;
+ | ^^^ -
+
+error[E0107]: this trait takes 0 lifetime arguments but 1 lifetime argument was supplied
+ --> $DIR/bad-mid-path-type-params.rs:39:17
+ |
+LL | let _: S2 = Trait::<'a,isize>::new::<f64,f64>(1, 1.0);
+ | ^^^^^ -- help: remove this lifetime argument
+ | |
+ | expected 0 lifetime arguments
+ |
+note: trait defined here, with 0 lifetime parameters
+ --> $DIR/bad-mid-path-type-params.rs:13:7
+ |
+LL | trait Trait<T> {
+ | ^^^^^
+
+error[E0107]: this associated function takes 1 generic argument but 2 generic arguments were supplied
+ --> $DIR/bad-mid-path-type-params.rs:39:36
+ |
+LL | let _: S2 = Trait::<'a,isize>::new::<f64,f64>(1, 1.0);
+ | ^^^ --- help: remove this generic argument
+ | |
+ | expected 1 generic argument
+ |
+note: associated function defined here, with 1 generic parameter: `U`
+ --> $DIR/bad-mid-path-type-params.rs:14:8
+ |
+LL | fn new<U>(x: T, y: U) -> Self;
+ | ^^^ -
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0107`.
diff --git a/tests/ui/generics/generic-alias-unique.rs b/tests/ui/generics/generic-alias-unique.rs
new file mode 100644
index 000000000..fc1383986
--- /dev/null
+++ b/tests/ui/generics/generic-alias-unique.rs
@@ -0,0 +1,10 @@
+// run-pass
+
+fn id<T:Send>(t: T) -> T { return t; }
+
+pub fn main() {
+ let expected: Box<_> = Box::new(100);
+ let actual = id::<Box<isize>>(expected.clone());
+ println!("{}", *actual);
+ assert_eq!(*expected, *actual);
+}
diff --git a/tests/ui/generics/generic-arg-mismatch-recover.rs b/tests/ui/generics/generic-arg-mismatch-recover.rs
new file mode 100644
index 000000000..2cf7f1d65
--- /dev/null
+++ b/tests/ui/generics/generic-arg-mismatch-recover.rs
@@ -0,0 +1,12 @@
+struct Foo<'a, T: 'a>(&'a T);
+
+struct Bar<'a>(&'a ());
+
+fn main() {
+ Foo::<'static, 'static, ()>(&0);
+ //~^ ERROR this struct takes 1 lifetime argument but 2 lifetime arguments were supplied
+
+ Bar::<'static, 'static, ()>(&());
+ //~^ ERROR this struct takes 1 lifetime argument but 2 lifetime arguments were supplied
+ //~| ERROR this struct takes 0
+}
diff --git a/tests/ui/generics/generic-arg-mismatch-recover.stderr b/tests/ui/generics/generic-arg-mismatch-recover.stderr
new file mode 100644
index 000000000..45fea925f
--- /dev/null
+++ b/tests/ui/generics/generic-arg-mismatch-recover.stderr
@@ -0,0 +1,45 @@
+error[E0107]: this struct takes 1 lifetime argument but 2 lifetime arguments were supplied
+ --> $DIR/generic-arg-mismatch-recover.rs:6:5
+ |
+LL | Foo::<'static, 'static, ()>(&0);
+ | ^^^ ------- help: remove this lifetime argument
+ | |
+ | expected 1 lifetime argument
+ |
+note: struct defined here, with 1 lifetime parameter: `'a`
+ --> $DIR/generic-arg-mismatch-recover.rs:1:8
+ |
+LL | struct Foo<'a, T: 'a>(&'a T);
+ | ^^^ --
+
+error[E0107]: this struct takes 1 lifetime argument but 2 lifetime arguments were supplied
+ --> $DIR/generic-arg-mismatch-recover.rs:9:5
+ |
+LL | Bar::<'static, 'static, ()>(&());
+ | ^^^ ------- help: remove this lifetime argument
+ | |
+ | expected 1 lifetime argument
+ |
+note: struct defined here, with 1 lifetime parameter: `'a`
+ --> $DIR/generic-arg-mismatch-recover.rs:3:8
+ |
+LL | struct Bar<'a>(&'a ());
+ | ^^^ --
+
+error[E0107]: this struct takes 0 generic arguments but 1 generic argument was supplied
+ --> $DIR/generic-arg-mismatch-recover.rs:9:5
+ |
+LL | Bar::<'static, 'static, ()>(&());
+ | ^^^ -- help: remove this generic argument
+ | |
+ | expected 0 generic arguments
+ |
+note: struct defined here, with 0 generic parameters
+ --> $DIR/generic-arg-mismatch-recover.rs:3:8
+ |
+LL | struct Bar<'a>(&'a ());
+ | ^^^
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0107`.
diff --git a/tests/ui/generics/generic-default-type-params-cross-crate.rs b/tests/ui/generics/generic-default-type-params-cross-crate.rs
new file mode 100644
index 000000000..834b15be1
--- /dev/null
+++ b/tests/ui/generics/generic-default-type-params-cross-crate.rs
@@ -0,0 +1,17 @@
+// run-pass
+// aux-build:default_type_params_xc.rs
+
+// pretty-expanded FIXME #23616
+
+extern crate default_type_params_xc;
+
+struct Vec<T, A = default_type_params_xc::Heap>(#[allow(unused_tuple_struct_fields)] Option<(T,A)>);
+
+struct Foo;
+
+fn main() {
+ let _a = Vec::<isize>(None);
+ let _b = Vec::<isize, default_type_params_xc::FakeHeap>(None);
+ let _c = default_type_params_xc::FakeVec::<isize> { f: None };
+ let _d = default_type_params_xc::FakeVec::<isize, Foo> { f: None };
+}
diff --git a/tests/ui/generics/generic-default-type-params.rs b/tests/ui/generics/generic-default-type-params.rs
new file mode 100644
index 000000000..afdd301fd
--- /dev/null
+++ b/tests/ui/generics/generic-default-type-params.rs
@@ -0,0 +1,53 @@
+// run-pass
+struct Foo<A = (isize, char)> {
+ a: A
+}
+
+impl Foo<isize> {
+ fn bar_int(&self) -> isize {
+ self.a
+ }
+}
+
+impl Foo<char> {
+ fn bar_char(&self) -> char {
+ self.a
+ }
+}
+
+impl Foo {
+ fn bar(&self) {
+ let (i, c): (isize, char) = self.a;
+ assert_eq!(Foo { a: i }.bar_int(), i);
+ assert_eq!(Foo { a: c }.bar_char(), c);
+ }
+}
+
+impl<A: Clone> Foo<A> {
+ fn baz(&self) -> A {
+ self.a.clone()
+ }
+}
+
+fn default_foo(x: Foo) {
+ let (i, c): (isize, char) = x.a;
+ assert_eq!(i, 1);
+ assert_eq!(c, 'a');
+
+ x.bar();
+ assert_eq!(x.baz(), (1, 'a'));
+}
+
+#[derive(PartialEq, Debug)]
+struct BazHelper<T>(T);
+
+#[derive(PartialEq, Debug)]
+// Ensure that we can use previous type parameters in defaults.
+struct Baz<T, U = BazHelper<T>, V = Option<U>>(T, U, V);
+
+fn main() {
+ default_foo(Foo { a: (1, 'a') });
+
+ let x: Baz<bool> = Baz(true, BazHelper(false), Some(BazHelper(true)));
+ assert_eq!(x, Baz(true, BazHelper(false), Some(BazHelper(true))));
+}
diff --git a/tests/ui/generics/generic-derived-type.rs b/tests/ui/generics/generic-derived-type.rs
new file mode 100644
index 000000000..c643496fa
--- /dev/null
+++ b/tests/ui/generics/generic-derived-type.rs
@@ -0,0 +1,21 @@
+// run-pass
+fn g<X>(x: X) -> X { return x; }
+
+#[derive(Clone)]
+struct Pair<T> {
+ a: T,
+ b: T
+}
+
+fn f<T:Clone>(t: T) -> Pair<T> {
+ let x: Pair<T> = Pair {a: t.clone(), b: t};
+ return g::<Pair<T>>(x);
+}
+
+pub fn main() {
+ let b = f::<isize>(10);
+ println!("{}" ,b.a);
+ println!("{}", b.b);
+ assert_eq!(b.a, 10);
+ assert_eq!(b.b, 10);
+}
diff --git a/tests/ui/generics/generic-exterior-unique.rs b/tests/ui/generics/generic-exterior-unique.rs
new file mode 100644
index 000000000..10d87f9f4
--- /dev/null
+++ b/tests/ui/generics/generic-exterior-unique.rs
@@ -0,0 +1,11 @@
+// run-pass
+
+struct Recbox<T> {x: Box<T>}
+
+fn reclift<T>(t: T) -> Recbox<T> { return Recbox { x: Box::new(t) }; }
+
+pub fn main() {
+ let foo: isize = 17;
+ let rbfoo: Recbox<isize> = reclift::<isize>(foo);
+ assert_eq!(*rbfoo.x, foo);
+}
diff --git a/tests/ui/generics/generic-extern-lifetime.rs b/tests/ui/generics/generic-extern-lifetime.rs
new file mode 100644
index 000000000..c42744808
--- /dev/null
+++ b/tests/ui/generics/generic-extern-lifetime.rs
@@ -0,0 +1,15 @@
+// Test to make sure the names of the lifetimes are correctly resolved
+// in extern blocks.
+
+extern "C" {
+ pub fn life<'a>(x: &'a i32);
+ pub fn life2<'b>(x: &'a i32, y: &'b i32); //~ ERROR use of undeclared lifetime name `'a`
+ pub fn life3<'a>(x: &'a i32, y: &i32) -> &'a i32;
+ pub fn life4<'b>(x: for<'c> fn(&'a i32)); //~ ERROR use of undeclared lifetime name `'a`
+ pub fn life5<'b>(x: for<'c> fn(&'b i32));
+ pub fn life6<'b>(x: for<'c> fn(&'c i32));
+ pub fn life7<'b>() -> for<'c> fn(&'a i32); //~ ERROR use of undeclared lifetime name `'a`
+ pub fn life8<'b>() -> for<'c> fn(&'b i32);
+ pub fn life9<'b>() -> for<'c> fn(&'c i32);
+}
+fn main() {}
diff --git a/tests/ui/generics/generic-extern-lifetime.stderr b/tests/ui/generics/generic-extern-lifetime.stderr
new file mode 100644
index 000000000..33332e760
--- /dev/null
+++ b/tests/ui/generics/generic-extern-lifetime.stderr
@@ -0,0 +1,42 @@
+error[E0261]: use of undeclared lifetime name `'a`
+ --> $DIR/generic-extern-lifetime.rs:6:26
+ |
+LL | pub fn life2<'b>(x: &'a i32, y: &'b i32);
+ | - ^^ undeclared lifetime
+ | |
+ | help: consider introducing lifetime `'a` here: `'a,`
+
+error[E0261]: use of undeclared lifetime name `'a`
+ --> $DIR/generic-extern-lifetime.rs:8:37
+ |
+LL | pub fn life4<'b>(x: for<'c> fn(&'a i32));
+ | ^^ undeclared lifetime
+ |
+ = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
+help: consider making the type lifetime-generic with a new `'a` lifetime
+ |
+LL | pub fn life4<'b>(x: for<'a, 'c> fn(&'a i32));
+ | +++
+help: consider introducing lifetime `'a` here
+ |
+LL | pub fn life4<'a, 'b>(x: for<'c> fn(&'a i32));
+ | +++
+
+error[E0261]: use of undeclared lifetime name `'a`
+ --> $DIR/generic-extern-lifetime.rs:11:39
+ |
+LL | pub fn life7<'b>() -> for<'c> fn(&'a i32);
+ | ^^ undeclared lifetime
+ |
+help: consider making the type lifetime-generic with a new `'a` lifetime
+ |
+LL | pub fn life7<'b>() -> for<'a, 'c> fn(&'a i32);
+ | +++
+help: consider introducing lifetime `'a` here
+ |
+LL | pub fn life7<'a, 'b>() -> for<'c> fn(&'a i32);
+ | +++
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0261`.
diff --git a/tests/ui/generics/generic-extern-mangle.rs b/tests/ui/generics/generic-extern-mangle.rs
new file mode 100644
index 000000000..985a6f39c
--- /dev/null
+++ b/tests/ui/generics/generic-extern-mangle.rs
@@ -0,0 +1,9 @@
+// run-pass
+use std::ops::Add;
+
+extern "C" fn foo<T: Add>(a: T, b: T) -> T::Output { a + b }
+
+fn main() {
+ assert_eq!(100u8, foo(0u8, 100u8));
+ assert_eq!(100u16, foo(0u16, 100u16));
+}
diff --git a/tests/ui/generics/generic-extern.rs b/tests/ui/generics/generic-extern.rs
new file mode 100644
index 000000000..3690d6fd0
--- /dev/null
+++ b/tests/ui/generics/generic-extern.rs
@@ -0,0 +1,7 @@
+extern "C" {
+ fn foo<T>(); //~ ERROR foreign items may not have type parameters
+}
+
+fn main() {
+ foo::<i32>();
+}
diff --git a/tests/ui/generics/generic-extern.stderr b/tests/ui/generics/generic-extern.stderr
new file mode 100644
index 000000000..c90215b61
--- /dev/null
+++ b/tests/ui/generics/generic-extern.stderr
@@ -0,0 +1,11 @@
+error[E0044]: foreign items may not have type parameters
+ --> $DIR/generic-extern.rs:2:5
+ |
+LL | fn foo<T>();
+ | ^^^^^^^^^^^^ can't have type parameters
+ |
+ = help: replace the type parameters with concrete types like `u32`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0044`.
diff --git a/tests/ui/generics/generic-fn-infer.rs b/tests/ui/generics/generic-fn-infer.rs
new file mode 100644
index 000000000..9ba422473
--- /dev/null
+++ b/tests/ui/generics/generic-fn-infer.rs
@@ -0,0 +1,10 @@
+// run-pass
+
+
+
+
+// Issue #45: infer type parameters in function applications
+
+fn id<T>(x: T) -> T { return x; }
+
+pub fn main() { let x: isize = 42; let y: isize = id(x); assert_eq!(x, y); }
diff --git a/tests/ui/generics/generic-fn-twice.rs b/tests/ui/generics/generic-fn-twice.rs
new file mode 100644
index 000000000..2f25fc24c
--- /dev/null
+++ b/tests/ui/generics/generic-fn-twice.rs
@@ -0,0 +1,11 @@
+// run-pass
+
+
+
+// pretty-expanded FIXME #23616
+
+mod foomod {
+ pub fn foo<T>() { }
+}
+
+pub fn main() { foomod::foo::<isize>(); foomod::foo::<isize>(); }
diff --git a/tests/ui/generics/generic-fn-unique.rs b/tests/ui/generics/generic-fn-unique.rs
new file mode 100644
index 000000000..7e246bce9
--- /dev/null
+++ b/tests/ui/generics/generic-fn-unique.rs
@@ -0,0 +1,8 @@
+// run-pass
+
+fn f<T>(x: Box<T>) -> Box<T> { return x; }
+
+pub fn main() {
+ let x = f(Box::new(3));
+ println!("{}", *x);
+}
diff --git a/tests/ui/generics/generic-fn.rs b/tests/ui/generics/generic-fn.rs
new file mode 100644
index 000000000..8038fabc1
--- /dev/null
+++ b/tests/ui/generics/generic-fn.rs
@@ -0,0 +1,28 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(unused_assignments)]
+
+fn id<T>(x: T) -> T { return x; }
+
+#[derive(Copy, Clone)]
+struct Triple {x: isize, y: isize, z: isize}
+
+pub fn main() {
+ let mut x = 62;
+ let mut y = 63;
+ let a = 'a';
+ let mut b = 'b';
+ let p: Triple = Triple {x: 65, y: 66, z: 67};
+ let mut q: Triple = Triple {x: 68, y: 69, z: 70};
+ y = id::<isize>(x);
+ println!("{}", y);
+ assert_eq!(x, y);
+ b = id::<char>(a);
+ println!("{}", b);
+ assert_eq!(a, b);
+ q = id::<Triple>(p);
+ x = p.z;
+ y = q.z;
+ println!("{}", y);
+ assert_eq!(x, y);
+}
diff --git a/tests/ui/generics/generic-function-item-where-type.rs b/tests/ui/generics/generic-function-item-where-type.rs
new file mode 100644
index 000000000..e1b0578ca
--- /dev/null
+++ b/tests/ui/generics/generic-function-item-where-type.rs
@@ -0,0 +1,6 @@
+fn foo<U>() {}
+
+fn main() {
+ foo::<main>()
+ //~^ ERROR constant provided when a type was expected
+}
diff --git a/tests/ui/generics/generic-function-item-where-type.stderr b/tests/ui/generics/generic-function-item-where-type.stderr
new file mode 100644
index 000000000..88594129c
--- /dev/null
+++ b/tests/ui/generics/generic-function-item-where-type.stderr
@@ -0,0 +1,12 @@
+error[E0747]: constant provided when a type was expected
+ --> $DIR/generic-function-item-where-type.rs:4:11
+ |
+LL | foo::<main>()
+ | ^^^^
+ |
+ = help: `main` is a function item, not a type
+ = help: function item types cannot be named directly
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0747`.
diff --git a/tests/ui/generics/generic-impl-less-params-with-defaults.rs b/tests/ui/generics/generic-impl-less-params-with-defaults.rs
new file mode 100644
index 000000000..66afbb58a
--- /dev/null
+++ b/tests/ui/generics/generic-impl-less-params-with-defaults.rs
@@ -0,0 +1,13 @@
+use std::marker;
+
+struct Foo<A, B, C = (A, B)>(
+ marker::PhantomData<(A,B,C)>);
+
+impl<A, B, C> Foo<A, B, C> {
+ fn new() -> Foo<A, B, C> {Foo(marker::PhantomData)}
+}
+
+fn main() {
+ Foo::<isize>::new();
+ //~^ ERROR this struct takes at least 2 generic arguments but 1 generic argument
+}
diff --git a/tests/ui/generics/generic-impl-less-params-with-defaults.stderr b/tests/ui/generics/generic-impl-less-params-with-defaults.stderr
new file mode 100644
index 000000000..cdbb57902
--- /dev/null
+++ b/tests/ui/generics/generic-impl-less-params-with-defaults.stderr
@@ -0,0 +1,21 @@
+error[E0107]: this struct takes at least 2 generic arguments but 1 generic argument was supplied
+ --> $DIR/generic-impl-less-params-with-defaults.rs:11:5
+ |
+LL | Foo::<isize>::new();
+ | ^^^ ----- supplied 1 generic argument
+ | |
+ | expected at least 2 generic arguments
+ |
+note: struct defined here, with at least 2 generic parameters: `A`, `B`
+ --> $DIR/generic-impl-less-params-with-defaults.rs:3:8
+ |
+LL | struct Foo<A, B, C = (A, B)>(
+ | ^^^ - -
+help: add missing generic argument
+ |
+LL | Foo::<isize, B>::new();
+ | +++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0107`.
diff --git a/tests/ui/generics/generic-impl-more-params-with-defaults.rs b/tests/ui/generics/generic-impl-more-params-with-defaults.rs
new file mode 100644
index 000000000..a28332374
--- /dev/null
+++ b/tests/ui/generics/generic-impl-more-params-with-defaults.rs
@@ -0,0 +1,15 @@
+use std::marker;
+
+struct Heap;
+
+struct Vec<T, A = Heap>(
+ marker::PhantomData<(T,A)>);
+
+impl<T, A> Vec<T, A> {
+ fn new() -> Vec<T, A> {Vec(marker::PhantomData)}
+}
+
+fn main() {
+ Vec::<isize, Heap, bool>::new();
+ //~^ ERROR this struct takes at most 2 generic arguments but 3 generic arguments were supplied
+}
diff --git a/tests/ui/generics/generic-impl-more-params-with-defaults.stderr b/tests/ui/generics/generic-impl-more-params-with-defaults.stderr
new file mode 100644
index 000000000..fe9b670da
--- /dev/null
+++ b/tests/ui/generics/generic-impl-more-params-with-defaults.stderr
@@ -0,0 +1,17 @@
+error[E0107]: this struct takes at most 2 generic arguments but 3 generic arguments were supplied
+ --> $DIR/generic-impl-more-params-with-defaults.rs:13:5
+ |
+LL | Vec::<isize, Heap, bool>::new();
+ | ^^^ ---- help: remove this generic argument
+ | |
+ | expected at most 2 generic arguments
+ |
+note: struct defined here, with at most 2 generic parameters: `T`, `A`
+ --> $DIR/generic-impl-more-params-with-defaults.rs:5:8
+ |
+LL | struct Vec<T, A = Heap>(
+ | ^^^ - --------
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0107`.
diff --git a/tests/ui/generics/generic-ivec-leak.rs b/tests/ui/generics/generic-ivec-leak.rs
new file mode 100644
index 000000000..9610bdcb3
--- /dev/null
+++ b/tests/ui/generics/generic-ivec-leak.rs
@@ -0,0 +1,5 @@
+// run-pass
+#![allow(non_camel_case_types)]
+enum wrapper<T> { wrapped(#[allow(unused_tuple_struct_fields)] T), }
+
+pub fn main() { let _w = wrapper::wrapped(vec![1, 2, 3, 4, 5]); }
diff --git a/tests/ui/generics/generic-lifetime-trait-impl.rs b/tests/ui/generics/generic-lifetime-trait-impl.rs
new file mode 100644
index 000000000..6ffaba19d
--- /dev/null
+++ b/tests/ui/generics/generic-lifetime-trait-impl.rs
@@ -0,0 +1,23 @@
+// This code used to produce an ICE on the definition of trait Bar
+// with the following message:
+//
+// Type parameter out of range when substituting in region 'a (root
+// type=fn(Self) -> 'astr) (space=FnSpace, index=0)
+//
+// Regression test for issue #16218.
+
+trait Bar<'a> {
+ fn dummy(&'a self);
+}
+
+trait Foo<'a> {
+ fn dummy(&'a self) { }
+ fn bar<'b, T: Bar<'b>>(self) -> &'b str;
+}
+
+impl<'a> Foo<'a> for &'a str {
+ fn bar<T: Bar<'a>>(self) -> &'a str { panic!() } //~ ERROR lifetime
+}
+
+fn main() {
+}
diff --git a/tests/ui/generics/generic-lifetime-trait-impl.stderr b/tests/ui/generics/generic-lifetime-trait-impl.stderr
new file mode 100644
index 000000000..4ae5098a1
--- /dev/null
+++ b/tests/ui/generics/generic-lifetime-trait-impl.stderr
@@ -0,0 +1,12 @@
+error[E0195]: lifetime parameters or bounds on method `bar` do not match the trait declaration
+ --> $DIR/generic-lifetime-trait-impl.rs:19:11
+ |
+LL | fn bar<'b, T: Bar<'b>>(self) -> &'b str;
+ | ---------------- lifetimes in impl do not match this method in trait
+...
+LL | fn bar<T: Bar<'a>>(self) -> &'a str { panic!() }
+ | ^^^^^^^^^^^^ lifetimes do not match method in trait
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0195`.
diff --git a/tests/ui/generics/generic-newtype-struct.rs b/tests/ui/generics/generic-newtype-struct.rs
new file mode 100644
index 000000000..aa879f01a
--- /dev/null
+++ b/tests/ui/generics/generic-newtype-struct.rs
@@ -0,0 +1,8 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+struct S<T>(#[allow(unused_tuple_struct_fields)] T);
+
+pub fn main() {
+ let _s = S(2);
+}
diff --git a/tests/ui/generics/generic-no-mangle.fixed b/tests/ui/generics/generic-no-mangle.fixed
new file mode 100644
index 000000000..501acb6e1
--- /dev/null
+++ b/tests/ui/generics/generic-no-mangle.fixed
@@ -0,0 +1,159 @@
+// run-rustfix
+
+#![deny(no_mangle_generic_items)]
+
+
+pub fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled
+
+
+pub extern "C" fn bar<T>() {} //~ ERROR functions generic over types or consts must be mangled
+
+#[no_mangle]
+pub fn baz(x: &i32) -> &i32 { x }
+
+#[no_mangle]
+pub fn qux<'a>(x: &'a i32) -> &i32 { x }
+
+pub struct Foo;
+
+impl Foo {
+
+ pub fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled
+
+
+ pub extern "C" fn bar<T>() {} //~ ERROR functions generic over types or consts must be mangled
+
+ #[no_mangle]
+ pub fn baz(x: &i32) -> &i32 { x }
+
+ #[no_mangle]
+ pub fn qux<'a>(x: &'a i32) -> &i32 { x }
+}
+
+trait Trait1 {
+ fn foo<T>();
+ extern "C" fn bar<T>();
+ fn baz(x: &i32) -> &i32;
+ fn qux<'a>(x: &'a i32) -> &i32;
+}
+
+impl Trait1 for Foo {
+
+ fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled
+
+
+ extern "C" fn bar<T>() {} //~ ERROR functions generic over types or consts must be mangled
+
+ #[no_mangle]
+ fn baz(x: &i32) -> &i32 { x }
+
+ #[no_mangle]
+ fn qux<'a>(x: &'a i32) -> &i32 { x }
+}
+
+trait Trait2<T> {
+ fn foo();
+ fn foo2<U>();
+ extern "C" fn bar();
+ fn baz(x: &i32) -> &i32;
+ fn qux<'a>(x: &'a i32) -> &i32;
+}
+
+impl<T> Trait2<T> for Foo {
+
+ fn foo() {} //~ ERROR functions generic over types or consts must be mangled
+
+
+ fn foo2<U>() {} //~ ERROR functions generic over types or consts must be mangled
+
+
+ extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled
+
+
+ fn baz(x: &i32) -> &i32 { x } //~ ERROR functions generic over types or consts must be mangled
+
+
+ fn qux<'a>(x: &'a i32) -> &i32 { x } //~ ERROR functions generic over types or consts must be mangled
+}
+
+pub struct Bar<T>(#[allow(unused_tuple_struct_fields)] T);
+
+impl<T> Bar<T> {
+
+ pub fn foo() {} //~ ERROR functions generic over types or consts must be mangled
+
+
+ pub extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled
+
+
+ pub fn baz<U>() {} //~ ERROR functions generic over types or consts must be mangled
+}
+
+impl Bar<i32> {
+ #[no_mangle]
+ pub fn qux() {}
+}
+
+trait Trait3 {
+ fn foo();
+ extern "C" fn bar();
+ fn baz<U>();
+}
+
+impl<T> Trait3 for Bar<T> {
+
+ fn foo() {} //~ ERROR functions generic over types or consts must be mangled
+
+
+ extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled
+
+
+ fn baz<U>() {} //~ ERROR functions generic over types or consts must be mangled
+}
+
+pub struct Baz<'a>(#[allow(unused_tuple_struct_fields)] &'a i32);
+
+impl<'a> Baz<'a> {
+ #[no_mangle]
+ pub fn foo() {}
+
+ #[no_mangle]
+ pub fn bar<'b>(x: &'b i32) -> &i32 { x }
+}
+
+trait Trait4 {
+ fn foo();
+ fn bar<'a>(x: &'a i32) -> &i32;
+}
+
+impl Trait4 for Bar<i32> {
+ #[no_mangle]
+ fn foo() {}
+
+ #[no_mangle]
+ fn bar<'b>(x: &'b i32) -> &i32 { x }
+}
+
+impl<'a> Trait4 for Baz<'a> {
+ #[no_mangle]
+ fn foo() {}
+
+ #[no_mangle]
+ fn bar<'b>(x: &'b i32) -> &i32 { x }
+}
+
+trait Trait5<T> {
+ fn foo();
+}
+
+impl Trait5<i32> for Foo {
+ #[no_mangle]
+ fn foo() {}
+}
+
+impl Trait5<i32> for Bar<i32> {
+ #[no_mangle]
+ fn foo() {}
+}
+
+fn main() {}
diff --git a/tests/ui/generics/generic-no-mangle.rs b/tests/ui/generics/generic-no-mangle.rs
new file mode 100644
index 000000000..74e407078
--- /dev/null
+++ b/tests/ui/generics/generic-no-mangle.rs
@@ -0,0 +1,159 @@
+// run-rustfix
+
+#![deny(no_mangle_generic_items)]
+
+#[no_mangle]
+pub fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled
+
+#[no_mangle]
+pub extern "C" fn bar<T>() {} //~ ERROR functions generic over types or consts must be mangled
+
+#[no_mangle]
+pub fn baz(x: &i32) -> &i32 { x }
+
+#[no_mangle]
+pub fn qux<'a>(x: &'a i32) -> &i32 { x }
+
+pub struct Foo;
+
+impl Foo {
+ #[no_mangle]
+ pub fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled
+
+ #[no_mangle]
+ pub extern "C" fn bar<T>() {} //~ ERROR functions generic over types or consts must be mangled
+
+ #[no_mangle]
+ pub fn baz(x: &i32) -> &i32 { x }
+
+ #[no_mangle]
+ pub fn qux<'a>(x: &'a i32) -> &i32 { x }
+}
+
+trait Trait1 {
+ fn foo<T>();
+ extern "C" fn bar<T>();
+ fn baz(x: &i32) -> &i32;
+ fn qux<'a>(x: &'a i32) -> &i32;
+}
+
+impl Trait1 for Foo {
+ #[no_mangle]
+ fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled
+
+ #[no_mangle]
+ extern "C" fn bar<T>() {} //~ ERROR functions generic over types or consts must be mangled
+
+ #[no_mangle]
+ fn baz(x: &i32) -> &i32 { x }
+
+ #[no_mangle]
+ fn qux<'a>(x: &'a i32) -> &i32 { x }
+}
+
+trait Trait2<T> {
+ fn foo();
+ fn foo2<U>();
+ extern "C" fn bar();
+ fn baz(x: &i32) -> &i32;
+ fn qux<'a>(x: &'a i32) -> &i32;
+}
+
+impl<T> Trait2<T> for Foo {
+ #[no_mangle]
+ fn foo() {} //~ ERROR functions generic over types or consts must be mangled
+
+ #[no_mangle]
+ fn foo2<U>() {} //~ ERROR functions generic over types or consts must be mangled
+
+ #[no_mangle]
+ extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled
+
+ #[no_mangle]
+ fn baz(x: &i32) -> &i32 { x } //~ ERROR functions generic over types or consts must be mangled
+
+ #[no_mangle]
+ fn qux<'a>(x: &'a i32) -> &i32 { x } //~ ERROR functions generic over types or consts must be mangled
+}
+
+pub struct Bar<T>(#[allow(unused_tuple_struct_fields)] T);
+
+impl<T> Bar<T> {
+ #[no_mangle]
+ pub fn foo() {} //~ ERROR functions generic over types or consts must be mangled
+
+ #[no_mangle]
+ pub extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled
+
+ #[no_mangle]
+ pub fn baz<U>() {} //~ ERROR functions generic over types or consts must be mangled
+}
+
+impl Bar<i32> {
+ #[no_mangle]
+ pub fn qux() {}
+}
+
+trait Trait3 {
+ fn foo();
+ extern "C" fn bar();
+ fn baz<U>();
+}
+
+impl<T> Trait3 for Bar<T> {
+ #[no_mangle]
+ fn foo() {} //~ ERROR functions generic over types or consts must be mangled
+
+ #[no_mangle]
+ extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled
+
+ #[no_mangle]
+ fn baz<U>() {} //~ ERROR functions generic over types or consts must be mangled
+}
+
+pub struct Baz<'a>(#[allow(unused_tuple_struct_fields)] &'a i32);
+
+impl<'a> Baz<'a> {
+ #[no_mangle]
+ pub fn foo() {}
+
+ #[no_mangle]
+ pub fn bar<'b>(x: &'b i32) -> &i32 { x }
+}
+
+trait Trait4 {
+ fn foo();
+ fn bar<'a>(x: &'a i32) -> &i32;
+}
+
+impl Trait4 for Bar<i32> {
+ #[no_mangle]
+ fn foo() {}
+
+ #[no_mangle]
+ fn bar<'b>(x: &'b i32) -> &i32 { x }
+}
+
+impl<'a> Trait4 for Baz<'a> {
+ #[no_mangle]
+ fn foo() {}
+
+ #[no_mangle]
+ fn bar<'b>(x: &'b i32) -> &i32 { x }
+}
+
+trait Trait5<T> {
+ fn foo();
+}
+
+impl Trait5<i32> for Foo {
+ #[no_mangle]
+ fn foo() {}
+}
+
+impl Trait5<i32> for Bar<i32> {
+ #[no_mangle]
+ fn foo() {}
+}
+
+fn main() {}
diff --git a/tests/ui/generics/generic-no-mangle.stderr b/tests/ui/generics/generic-no-mangle.stderr
new file mode 100644
index 000000000..adfddbe9c
--- /dev/null
+++ b/tests/ui/generics/generic-no-mangle.stderr
@@ -0,0 +1,144 @@
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:6:1
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | pub fn foo<T>() {}
+ | ^^^^^^^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/generic-no-mangle.rs:3:9
+ |
+LL | #![deny(no_mangle_generic_items)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:9:1
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | pub extern "C" fn bar<T>() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:21:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | pub fn foo<T>() {}
+ | ^^^^^^^^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:24:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | pub extern "C" fn bar<T>() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:42:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | fn foo<T>() {}
+ | ^^^^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:45:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | extern "C" fn bar<T>() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:64:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | fn foo() {}
+ | ^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:67:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | fn foo2<U>() {}
+ | ^^^^^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:70:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | extern "C" fn bar() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:73:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | fn baz(x: &i32) -> &i32 { x }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:76:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | fn qux<'a>(x: &'a i32) -> &i32 { x }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:83:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | pub fn foo() {}
+ | ^^^^^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:86:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | pub extern "C" fn bar() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:89:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | pub fn baz<U>() {}
+ | ^^^^^^^^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:105:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | fn foo() {}
+ | ^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:108:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | extern "C" fn bar() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
+error: functions generic over types or consts must be mangled
+ --> $DIR/generic-no-mangle.rs:111:5
+ |
+LL | #[no_mangle]
+ | ------------ help: remove this attribute
+LL | fn baz<U>() {}
+ | ^^^^^^^^^^^^^^
+
+error: aborting due to 17 previous errors
+
diff --git a/tests/ui/generics/generic-non-trailing-defaults.rs b/tests/ui/generics/generic-non-trailing-defaults.rs
new file mode 100644
index 000000000..16ea71d48
--- /dev/null
+++ b/tests/ui/generics/generic-non-trailing-defaults.rs
@@ -0,0 +1,10 @@
+struct Heap;
+
+struct Vec<A = Heap, T>(A, T);
+//~^ ERROR generic parameters with a default must be trailing
+
+struct Foo<A, B = Vec<C>, C>(A, B, C);
+//~^ ERROR generic parameters with a default must be trailing
+//~| ERROR generic parameters with a default cannot use
+
+fn main() {}
diff --git a/tests/ui/generics/generic-non-trailing-defaults.stderr b/tests/ui/generics/generic-non-trailing-defaults.stderr
new file mode 100644
index 000000000..713ba091b
--- /dev/null
+++ b/tests/ui/generics/generic-non-trailing-defaults.stderr
@@ -0,0 +1,21 @@
+error: generic parameters with a default must be trailing
+ --> $DIR/generic-non-trailing-defaults.rs:3:12
+ |
+LL | struct Vec<A = Heap, T>(A, T);
+ | ^
+
+error: generic parameters with a default must be trailing
+ --> $DIR/generic-non-trailing-defaults.rs:6:15
+ |
+LL | struct Foo<A, B = Vec<C>, C>(A, B, C);
+ | ^
+
+error[E0128]: generic parameters with a default cannot use forward declared identifiers
+ --> $DIR/generic-non-trailing-defaults.rs:6:23
+ |
+LL | struct Foo<A, B = Vec<C>, C>(A, B, C);
+ | ^ defaulted generic parameters cannot be forward declared
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0128`.
diff --git a/tests/ui/generics/generic-object.rs b/tests/ui/generics/generic-object.rs
new file mode 100644
index 000000000..851424a11
--- /dev/null
+++ b/tests/ui/generics/generic-object.rs
@@ -0,0 +1,21 @@
+// run-pass
+
+trait Foo<T> {
+ fn get(&self) -> T;
+}
+
+struct S {
+ x: isize
+}
+
+impl Foo<isize> for S {
+ fn get(&self) -> isize {
+ self.x
+ }
+}
+
+pub fn main() {
+ let x = Box::new(S { x: 1 });
+ let y = x as Box<dyn Foo<isize>>;
+ assert_eq!(y.get(), 1);
+}
diff --git a/tests/ui/generics/generic-param-attrs.rs b/tests/ui/generics/generic-param-attrs.rs
new file mode 100644
index 000000000..3c5cc84c6
--- /dev/null
+++ b/tests/ui/generics/generic-param-attrs.rs
@@ -0,0 +1,38 @@
+// This test previously ensured that attributes on formals in generic parameter
+// lists are rejected without a feature gate.
+
+// build-pass (FIXME(62277): could be check-pass?)
+
+#![feature(rustc_attrs)]
+
+struct StLt<#[rustc_dummy] 'a>(&'a u32);
+struct StTy<#[rustc_dummy] I>(I);
+enum EnLt<#[rustc_dummy] 'b> { A(&'b u32), B }
+enum EnTy<#[rustc_dummy] J> { A(J), B }
+trait TrLt<#[rustc_dummy] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; }
+trait TrTy<#[rustc_dummy] K> { fn foo(&self, _: K); }
+type TyLt<#[rustc_dummy] 'd> = &'d u32;
+type TyTy<#[rustc_dummy] L> = (L, );
+
+impl<#[rustc_dummy] 'e> StLt<'e> { }
+impl<#[rustc_dummy] M> StTy<M> { }
+impl<#[rustc_dummy] 'f> TrLt<'f> for StLt<'f> {
+ fn foo(&self, _: &'f [u32]) -> &'f u32 { loop { } }
+}
+impl<#[rustc_dummy] N> TrTy<N> for StTy<N> {
+ fn foo(&self, _: N) { }
+}
+
+fn f_lt<#[rustc_dummy] 'g>(_: &'g [u32]) -> &'g u32 { loop { } }
+fn f_ty<#[rustc_dummy] O>(_: O) { }
+
+impl<I> StTy<I> {
+ fn m_lt<#[rustc_dummy] 'h>(_: &'h [u32]) -> &'h u32 { loop { } }
+ fn m_ty<#[rustc_dummy] P>(_: P) { }
+}
+
+fn hof_lt<Q>(_: Q)
+ where Q: for <#[rustc_dummy] 'i> Fn(&'i [u32]) -> &'i u32
+{}
+
+fn main() {}
diff --git a/tests/ui/generics/generic-recursive-tag.rs b/tests/ui/generics/generic-recursive-tag.rs
new file mode 100644
index 000000000..b344da1c7
--- /dev/null
+++ b/tests/ui/generics/generic-recursive-tag.rs
@@ -0,0 +1,12 @@
+// run-pass
+#![allow(non_camel_case_types)]
+
+enum list<T> { #[allow(unused_tuple_struct_fields)] cons(Box<T>, Box<list<T>>), nil, }
+
+pub fn main() {
+ let _a: list<isize> =
+ list::cons::<isize>(Box::new(10),
+ Box::new(list::cons::<isize>(Box::new(12),
+ Box::new(list::cons::<isize>(Box::new(13),
+ Box::new(list::nil::<isize>))))));
+}
diff --git a/tests/ui/generics/generic-static-methods.rs b/tests/ui/generics/generic-static-methods.rs
new file mode 100644
index 000000000..b39fa081a
--- /dev/null
+++ b/tests/ui/generics/generic-static-methods.rs
@@ -0,0 +1,21 @@
+// run-pass
+#![allow(non_camel_case_types)]
+
+
+trait vec_utils<T> {
+ fn map_<U, F>(x: &Self, f: F) -> Vec<U> where F: FnMut(&T) -> U;
+}
+
+impl<T> vec_utils<T> for Vec<T> {
+ fn map_<U, F>(x: &Vec<T> , mut f: F) -> Vec<U> where F: FnMut(&T) -> U {
+ let mut r = Vec::new();
+ for elt in x {
+ r.push(f(elt));
+ }
+ r
+ }
+}
+
+pub fn main() {
+ assert_eq!(vec_utils::map_(&vec![1,2,3], |&x| x+1), [2,3,4]);
+}
diff --git a/tests/ui/generics/generic-tag-corruption.rs b/tests/ui/generics/generic-tag-corruption.rs
new file mode 100644
index 000000000..35de3c1f7
--- /dev/null
+++ b/tests/ui/generics/generic-tag-corruption.rs
@@ -0,0 +1,10 @@
+// run-pass
+#![allow(non_camel_case_types)]
+
+
+// This used to cause memory corruption in stage 0.
+// pretty-expanded FIXME #23616
+
+enum thing<K> { some(#[allow(unused_tuple_struct_fields)] K), }
+
+pub fn main() { let _x = thing::some("hi".to_string()); }
diff --git a/tests/ui/generics/generic-tag-local.rs b/tests/ui/generics/generic-tag-local.rs
new file mode 100644
index 000000000..c5772e841
--- /dev/null
+++ b/tests/ui/generics/generic-tag-local.rs
@@ -0,0 +1,8 @@
+// run-pass
+#![allow(non_camel_case_types)]
+
+// pretty-expanded FIXME #23616
+
+enum clam<T> { a(#[allow(unused_tuple_struct_fields)] T), }
+
+pub fn main() { let _c = clam::a(3); }
diff --git a/tests/ui/generics/generic-tag-match.rs b/tests/ui/generics/generic-tag-match.rs
new file mode 100644
index 000000000..09ed6a808
--- /dev/null
+++ b/tests/ui/generics/generic-tag-match.rs
@@ -0,0 +1,13 @@
+// run-pass
+#![allow(unused_assignments)]
+#![allow(non_camel_case_types)]
+
+enum foo<T> { arm(T), }
+
+fn altfoo<T>(f: foo<T>) {
+ let mut hit = false;
+ match f { foo::arm::<T>(_x) => { println!("in arm"); hit = true; } }
+ assert!((hit));
+}
+
+pub fn main() { altfoo::<isize>(foo::arm::<isize>(10)); }
diff --git a/tests/ui/generics/generic-tag-values.rs b/tests/ui/generics/generic-tag-values.rs
new file mode 100644
index 000000000..230f477b6
--- /dev/null
+++ b/tests/ui/generics/generic-tag-values.rs
@@ -0,0 +1,20 @@
+// run-pass
+#![allow(non_camel_case_types)]
+
+enum noption<T> { some(T), }
+
+struct Pair { x: isize, y: isize }
+
+pub fn main() {
+ let nop: noption<isize> = noption::some::<isize>(5);
+ match nop { noption::some::<isize>(n) => { println!("{}", n); assert_eq!(n, 5); } }
+ let nop2: noption<Pair> = noption::some(Pair{x: 17, y: 42});
+ match nop2 {
+ noption::some(t) => {
+ println!("{}", t.x);
+ println!("{}", t.y);
+ assert_eq!(t.x, 17);
+ assert_eq!(t.y, 42);
+ }
+ }
+}
diff --git a/tests/ui/generics/generic-tag.rs b/tests/ui/generics/generic-tag.rs
new file mode 100644
index 000000000..31fc2178d
--- /dev/null
+++ b/tests/ui/generics/generic-tag.rs
@@ -0,0 +1,14 @@
+// run-pass
+#![allow(unused_assignments)]
+#![allow(non_camel_case_types)]
+
+// pretty-expanded FIXME #23616
+
+#![allow(unused_variables)]
+
+enum option<T> { some(#[allow(unused_tuple_struct_fields)] Box<T>), none, }
+
+pub fn main() {
+ let mut a: option<isize> = option::some::<isize>(Box::new(10));
+ a = option::none::<isize>;
+}
diff --git a/tests/ui/generics/generic-temporary.rs b/tests/ui/generics/generic-temporary.rs
new file mode 100644
index 000000000..b63b534d0
--- /dev/null
+++ b/tests/ui/generics/generic-temporary.rs
@@ -0,0 +1,16 @@
+// run-pass
+
+fn mk() -> isize { return 1; }
+
+fn chk(a: isize) { println!("{}", a); assert_eq!(a, 1); }
+
+fn apply<T>(produce: fn() -> T,
+ consume: fn(T)) {
+ consume(produce());
+}
+
+pub fn main() {
+ let produce: fn() -> isize = mk;
+ let consume: fn(v: isize) = chk;
+ apply::<isize>(produce, consume);
+}
diff --git a/tests/ui/generics/generic-tup.rs b/tests/ui/generics/generic-tup.rs
new file mode 100644
index 000000000..79ebd648c
--- /dev/null
+++ b/tests/ui/generics/generic-tup.rs
@@ -0,0 +1,8 @@
+// run-pass
+fn get_third<T>(t: (T, T, T)) -> T { let (_, _, x) = t; return x; }
+
+pub fn main() {
+ println!("{}", get_third((1, 2, 3)));
+ assert_eq!(get_third((1, 2, 3)), 3);
+ assert_eq!(get_third((5u8, 6u8, 7u8)), 7u8);
+}
diff --git a/tests/ui/generics/generic-type-less-params-with-defaults.rs b/tests/ui/generics/generic-type-less-params-with-defaults.rs
new file mode 100644
index 000000000..6b877ab8a
--- /dev/null
+++ b/tests/ui/generics/generic-type-less-params-with-defaults.rs
@@ -0,0 +1,11 @@
+use std::marker;
+
+struct Heap;
+
+struct Vec<T, A = Heap>(
+ marker::PhantomData<(T,A)>);
+
+fn main() {
+ let _: Vec;
+ //~^ ERROR missing generics for struct `Vec`
+}
diff --git a/tests/ui/generics/generic-type-less-params-with-defaults.stderr b/tests/ui/generics/generic-type-less-params-with-defaults.stderr
new file mode 100644
index 000000000..6450bbd8b
--- /dev/null
+++ b/tests/ui/generics/generic-type-less-params-with-defaults.stderr
@@ -0,0 +1,19 @@
+error[E0107]: missing generics for struct `Vec`
+ --> $DIR/generic-type-less-params-with-defaults.rs:9:12
+ |
+LL | let _: Vec;
+ | ^^^ expected at least 1 generic argument
+ |
+note: struct defined here, with at least 1 generic parameter: `T`
+ --> $DIR/generic-type-less-params-with-defaults.rs:5:8
+ |
+LL | struct Vec<T, A = Heap>(
+ | ^^^ -
+help: add missing generic argument
+ |
+LL | let _: Vec<T>;
+ | +++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0107`.
diff --git a/tests/ui/generics/generic-type-more-params-with-defaults.rs b/tests/ui/generics/generic-type-more-params-with-defaults.rs
new file mode 100644
index 000000000..3dab03297
--- /dev/null
+++ b/tests/ui/generics/generic-type-more-params-with-defaults.rs
@@ -0,0 +1,11 @@
+use std::marker;
+
+struct Heap;
+
+struct Vec<T, A = Heap>(
+ marker::PhantomData<(T,A)>);
+
+fn main() {
+ let _: Vec<isize, Heap, bool>;
+ //~^ ERROR this struct takes at most 2 generic arguments but 3 generic arguments
+}
diff --git a/tests/ui/generics/generic-type-more-params-with-defaults.stderr b/tests/ui/generics/generic-type-more-params-with-defaults.stderr
new file mode 100644
index 000000000..7f0198f0e
--- /dev/null
+++ b/tests/ui/generics/generic-type-more-params-with-defaults.stderr
@@ -0,0 +1,17 @@
+error[E0107]: this struct takes at most 2 generic arguments but 3 generic arguments were supplied
+ --> $DIR/generic-type-more-params-with-defaults.rs:9:12
+ |
+LL | let _: Vec<isize, Heap, bool>;
+ | ^^^ ---- help: remove this generic argument
+ | |
+ | expected at most 2 generic arguments
+ |
+note: struct defined here, with at most 2 generic parameters: `T`, `A`
+ --> $DIR/generic-type-more-params-with-defaults.rs:5:8
+ |
+LL | struct Vec<T, A = Heap>(
+ | ^^^ - --------
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0107`.
diff --git a/tests/ui/generics/generic-type-params-forward-mention.rs b/tests/ui/generics/generic-type-params-forward-mention.rs
new file mode 100644
index 000000000..000c47095
--- /dev/null
+++ b/tests/ui/generics/generic-type-params-forward-mention.rs
@@ -0,0 +1,6 @@
+// Ensure that we get an error and not an ICE for this problematic case.
+struct Foo<T = Option<U>, U = bool>(T, U);
+//~^ ERROR generic parameters with a default cannot use forward declared identifiers
+fn main() {
+ let x: Foo;
+}
diff --git a/tests/ui/generics/generic-type-params-forward-mention.stderr b/tests/ui/generics/generic-type-params-forward-mention.stderr
new file mode 100644
index 000000000..fa661c274
--- /dev/null
+++ b/tests/ui/generics/generic-type-params-forward-mention.stderr
@@ -0,0 +1,9 @@
+error[E0128]: generic parameters with a default cannot use forward declared identifiers
+ --> $DIR/generic-type-params-forward-mention.rs:2:23
+ |
+LL | struct Foo<T = Option<U>, U = bool>(T, U);
+ | ^ defaulted generic parameters cannot be forward declared
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0128`.
diff --git a/tests/ui/generics/generic-type-params-name-repr.rs b/tests/ui/generics/generic-type-params-name-repr.rs
new file mode 100644
index 000000000..6e0beec66
--- /dev/null
+++ b/tests/ui/generics/generic-type-params-name-repr.rs
@@ -0,0 +1,51 @@
+use std::marker;
+
+struct A;
+struct B;
+struct C;
+struct Foo<T = A, U = B, V = C>(marker::PhantomData<(T,U,V)>);
+
+struct Hash<T>(marker::PhantomData<T>);
+struct HashMap<K, V, H = Hash<K>>(marker::PhantomData<(K,V,H)>);
+
+fn main() {
+ // Ensure that the printed type doesn't include the default type params...
+ let _: Foo<isize> = ();
+ //~^ ERROR mismatched types
+ //~| expected struct `Foo`, found `()`
+ //~| expected struct `Foo<isize>`
+ //~| found unit type `()`
+
+ // ...even when they're present, but the same types as the defaults.
+ let _: Foo<isize, B, C> = ();
+ //~^ ERROR mismatched types
+ //~| expected struct `Foo`, found `()`
+ //~| expected struct `Foo<isize>`
+ //~| found unit type `()`
+
+ // Including cases where the default is using previous type params.
+ let _: HashMap<String, isize> = ();
+ //~^ ERROR mismatched types
+ //~| expected struct `HashMap`, found `()`
+ //~| expected struct `HashMap<String, isize>`
+ //~| found unit type `()`
+ let _: HashMap<String, isize, Hash<String>> = ();
+ //~^ ERROR mismatched types
+ //~| expected struct `HashMap`, found `()`
+ //~| expected struct `HashMap<String, isize>`
+ //~| found unit type `()`
+
+ // But not when there's a different type in between.
+ let _: Foo<A, isize, C> = ();
+ //~^ ERROR mismatched types
+ //~| expected struct `Foo`, found `()`
+ //~| expected struct `Foo<A, isize>`
+ //~| found unit type `()`
+
+ // And don't print <> at all when there's just defaults.
+ let _: Foo<A, B, C> = ();
+ //~^ ERROR mismatched types
+ //~| expected struct `Foo`, found `()`
+ //~| expected struct `Foo`
+ //~| found unit type `()`
+}
diff --git a/tests/ui/generics/generic-type-params-name-repr.stderr b/tests/ui/generics/generic-type-params-name-repr.stderr
new file mode 100644
index 000000000..4c3c00396
--- /dev/null
+++ b/tests/ui/generics/generic-type-params-name-repr.stderr
@@ -0,0 +1,69 @@
+error[E0308]: mismatched types
+ --> $DIR/generic-type-params-name-repr.rs:13:25
+ |
+LL | let _: Foo<isize> = ();
+ | ---------- ^^ expected struct `Foo`, found `()`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `Foo<isize>`
+ found unit type `()`
+
+error[E0308]: mismatched types
+ --> $DIR/generic-type-params-name-repr.rs:20:31
+ |
+LL | let _: Foo<isize, B, C> = ();
+ | ---------------- ^^ expected struct `Foo`, found `()`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `Foo<isize>`
+ found unit type `()`
+
+error[E0308]: mismatched types
+ --> $DIR/generic-type-params-name-repr.rs:27:37
+ |
+LL | let _: HashMap<String, isize> = ();
+ | ---------------------- ^^ expected struct `HashMap`, found `()`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `HashMap<String, isize>`
+ found unit type `()`
+
+error[E0308]: mismatched types
+ --> $DIR/generic-type-params-name-repr.rs:32:51
+ |
+LL | let _: HashMap<String, isize, Hash<String>> = ();
+ | ------------------------------------ ^^ expected struct `HashMap`, found `()`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `HashMap<String, isize>`
+ found unit type `()`
+
+error[E0308]: mismatched types
+ --> $DIR/generic-type-params-name-repr.rs:39:31
+ |
+LL | let _: Foo<A, isize, C> = ();
+ | ---------------- ^^ expected struct `Foo`, found `()`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `Foo<A, isize>`
+ found unit type `()`
+
+error[E0308]: mismatched types
+ --> $DIR/generic-type-params-name-repr.rs:46:27
+ |
+LL | let _: Foo<A, B, C> = ();
+ | ------------ ^^ expected struct `Foo`, found `()`
+ | |
+ | expected due to this
+ |
+ = note: expected struct `Foo`
+ found unit type `()`
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/generics/generic-type-synonym.rs b/tests/ui/generics/generic-type-synonym.rs
new file mode 100644
index 000000000..4f181fbcc
--- /dev/null
+++ b/tests/ui/generics/generic-type-synonym.rs
@@ -0,0 +1,15 @@
+// run-pass
+#![allow(dead_code)]
+
+
+// pretty-expanded FIXME #23616
+
+struct Foo<T> {
+ a: T
+}
+
+type Bar<T> = Foo<T>;
+
+fn takebar<T>(_b: Bar<T>) { }
+
+pub fn main() { }
diff --git a/tests/ui/generics/generic-type.rs b/tests/ui/generics/generic-type.rs
new file mode 100644
index 000000000..aa46db07e
--- /dev/null
+++ b/tests/ui/generics/generic-type.rs
@@ -0,0 +1,11 @@
+// run-pass
+
+
+
+struct Pair<T> {x: T, y: T}
+
+pub fn main() {
+ let x: Pair<isize> = Pair {x: 10, y: 12};
+ assert_eq!(x.x, 10);
+ assert_eq!(x.y, 12);
+}
diff --git a/tests/ui/generics/generic-unique.rs b/tests/ui/generics/generic-unique.rs
new file mode 100644
index 000000000..2f34712ec
--- /dev/null
+++ b/tests/ui/generics/generic-unique.rs
@@ -0,0 +1,11 @@
+// run-pass
+#![allow(dead_code)]
+
+struct Triple<T> { x: T, y: T, z: T }
+
+fn box_it<T>(x: Triple<T>) -> Box<Triple<T>> { return Box::new(x); }
+
+pub fn main() {
+ let x: Box<Triple<isize>> = box_it::<isize>(Triple{x: 1, y: 2, z: 3});
+ assert_eq!(x.y, 2);
+}
diff --git a/tests/ui/generics/issue-106694.rs b/tests/ui/generics/issue-106694.rs
new file mode 100644
index 000000000..c4b02ee81
--- /dev/null
+++ b/tests/ui/generics/issue-106694.rs
@@ -0,0 +1,24 @@
+trait Trait {}
+
+fn foo(_: impl &Trait) {}
+//~^ ERROR expected a trait, found type
+
+fn bar<T: &Trait>(_: T) {}
+//~^ ERROR expected a trait, found type
+
+fn partially_correct_impl(_: impl &*const &Trait + Copy) {}
+//~^ ERROR expected a trait, found type
+
+fn foo_bad(_: impl &BadTrait) {}
+//~^ ERROR expected a trait, found type
+//~^^ ERROR cannot find trait `BadTrait` in this scope
+
+fn bar_bad<T: &BadTrait>(_: T) {}
+//~^ ERROR expected a trait, found type
+//~^^ ERROR cannot find trait `BadTrait` in this scope
+
+fn partially_correct_impl_bad(_: impl &*const &BadTrait + Copy) {}
+//~^ ERROR expected a trait, found type
+//~^^ ERROR cannot find trait `BadTrait` in this scope
+
+fn main() {}
diff --git a/tests/ui/generics/issue-106694.stderr b/tests/ui/generics/issue-106694.stderr
new file mode 100644
index 000000000..235b8982a
--- /dev/null
+++ b/tests/ui/generics/issue-106694.stderr
@@ -0,0 +1,93 @@
+error: expected a trait, found type
+ --> $DIR/issue-106694.rs:3:16
+ |
+LL | fn foo(_: impl &Trait) {}
+ | ^^^^^^
+ |
+help: consider removing the indirection
+ |
+LL - fn foo(_: impl &Trait) {}
+LL + fn foo(_: impl Trait) {}
+ |
+
+error: expected a trait, found type
+ --> $DIR/issue-106694.rs:6:11
+ |
+LL | fn bar<T: &Trait>(_: T) {}
+ | ^^^^^^
+ |
+help: consider removing the indirection
+ |
+LL - fn bar<T: &Trait>(_: T) {}
+LL + fn bar<T: Trait>(_: T) {}
+ |
+
+error: expected a trait, found type
+ --> $DIR/issue-106694.rs:9:35
+ |
+LL | fn partially_correct_impl(_: impl &*const &Trait + Copy) {}
+ | ^^^^^^^^^^^^^^
+ |
+help: consider removing the indirection
+ |
+LL - fn partially_correct_impl(_: impl &*const &Trait + Copy) {}
+LL + fn partially_correct_impl(_: impl Trait + Copy) {}
+ |
+
+error: expected a trait, found type
+ --> $DIR/issue-106694.rs:12:20
+ |
+LL | fn foo_bad(_: impl &BadTrait) {}
+ | ^^^^^^^^^
+ |
+help: consider removing the indirection
+ |
+LL - fn foo_bad(_: impl &BadTrait) {}
+LL + fn foo_bad(_: impl BadTrait) {}
+ |
+
+error: expected a trait, found type
+ --> $DIR/issue-106694.rs:16:15
+ |
+LL | fn bar_bad<T: &BadTrait>(_: T) {}
+ | ^^^^^^^^^
+ |
+help: consider removing the indirection
+ |
+LL - fn bar_bad<T: &BadTrait>(_: T) {}
+LL + fn bar_bad<T: BadTrait>(_: T) {}
+ |
+
+error: expected a trait, found type
+ --> $DIR/issue-106694.rs:20:39
+ |
+LL | fn partially_correct_impl_bad(_: impl &*const &BadTrait + Copy) {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+help: consider removing the indirection
+ |
+LL - fn partially_correct_impl_bad(_: impl &*const &BadTrait + Copy) {}
+LL + fn partially_correct_impl_bad(_: impl BadTrait + Copy) {}
+ |
+
+error[E0405]: cannot find trait `BadTrait` in this scope
+ --> $DIR/issue-106694.rs:12:21
+ |
+LL | fn foo_bad(_: impl &BadTrait) {}
+ | ^^^^^^^^ not found in this scope
+
+error[E0405]: cannot find trait `BadTrait` in this scope
+ --> $DIR/issue-106694.rs:16:16
+ |
+LL | fn bar_bad<T: &BadTrait>(_: T) {}
+ | ^^^^^^^^ not found in this scope
+
+error[E0405]: cannot find trait `BadTrait` in this scope
+ --> $DIR/issue-106694.rs:20:48
+ |
+LL | fn partially_correct_impl_bad(_: impl &*const &BadTrait + Copy) {}
+ | ^^^^^^^^ not found in this scope
+
+error: aborting due to 9 previous errors
+
+For more information about this error, try `rustc --explain E0405`.
diff --git a/tests/ui/generics/issue-1112.rs b/tests/ui/generics/issue-1112.rs
new file mode 100644
index 000000000..3ba7bb217
--- /dev/null
+++ b/tests/ui/generics/issue-1112.rs
@@ -0,0 +1,37 @@
+// run-pass
+#![allow(dead_code)]
+// Issue #1112
+// Alignment of interior pointers to dynamic-size types
+
+
+struct X<T> {
+ a: T,
+ b: u8,
+ c: bool,
+ d: u8,
+ e: u16,
+ f: u8,
+ g: u8
+}
+
+pub fn main() {
+ let x: X<isize> = X {
+ a: 12345678,
+ b: 9,
+ c: true,
+ d: 10,
+ e: 11,
+ f: 12,
+ g: 13
+ };
+ bar(x);
+}
+
+fn bar<T>(x: X<T>) {
+ assert_eq!(x.b, 9);
+ assert_eq!(x.c, true);
+ assert_eq!(x.d, 10);
+ assert_eq!(x.e, 11);
+ assert_eq!(x.f, 12);
+ assert_eq!(x.g, 13);
+}
diff --git a/tests/ui/generics/issue-2936.rs b/tests/ui/generics/issue-2936.rs
new file mode 100644
index 000000000..6b932d01d
--- /dev/null
+++ b/tests/ui/generics/issue-2936.rs
@@ -0,0 +1,31 @@
+// run-pass
+#![allow(non_camel_case_types)]
+
+trait bar<T> {
+ fn get_bar(&self) -> T;
+}
+
+fn foo<T, U: bar<T>>(b: U) -> T {
+ b.get_bar()
+}
+
+struct cbar {
+ x: isize,
+}
+
+impl bar<isize> for cbar {
+ fn get_bar(&self) -> isize {
+ self.x
+ }
+}
+
+fn cbar(x: isize) -> cbar {
+ cbar {
+ x: x
+ }
+}
+
+pub fn main() {
+ let x: isize = foo::<isize, cbar>(cbar(5));
+ assert_eq!(x, 5);
+}
diff --git a/tests/ui/generics/issue-32498.rs b/tests/ui/generics/issue-32498.rs
new file mode 100644
index 000000000..1b5440109
--- /dev/null
+++ b/tests/ui/generics/issue-32498.rs
@@ -0,0 +1,16 @@
+// run-pass
+#![allow(dead_code)]
+
+// Making sure that no overflow occurs.
+
+struct L<T> {
+ n: Option<T>,
+}
+type L8<T> = L<L<L<L<L<L<L<L<T>>>>>>>>;
+type L64<T> = L8<L8<L8<L8<T>>>>;
+
+fn main() {
+ use std::mem::size_of;
+ assert_eq!(size_of::<L64<L64<()>>>(), 1);
+ assert_eq!(size_of::<L<L64<L64<()>>>>(), 1);
+}
diff --git a/tests/ui/generics/issue-333.rs b/tests/ui/generics/issue-333.rs
new file mode 100644
index 000000000..0753aaa07
--- /dev/null
+++ b/tests/ui/generics/issue-333.rs
@@ -0,0 +1,7 @@
+// run-pass
+
+fn quux<T>(x: T) -> T { let f = id::<T>; return f(x); }
+
+fn id<T>(x: T) -> T { return x; }
+
+pub fn main() { assert_eq!(quux(10), 10); }
diff --git a/tests/ui/generics/issue-59508-1.rs b/tests/ui/generics/issue-59508-1.rs
new file mode 100644
index 000000000..8e27749e8
--- /dev/null
+++ b/tests/ui/generics/issue-59508-1.rs
@@ -0,0 +1,16 @@
+#![allow(dead_code)]
+
+// This test checks that generic parameter re-ordering diagnostic suggestions mention that
+// consts come after types and lifetimes.
+// We cannot run rustfix on this test because of the above const generics warning.
+
+struct A;
+
+impl A {
+ pub fn do_things<T, 'a, 'b: 'a>() {
+ //~^ ERROR lifetime parameters must be declared prior to type and const parameters
+ println!("panic");
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/generics/issue-59508-1.stderr b/tests/ui/generics/issue-59508-1.stderr
new file mode 100644
index 000000000..1c510044f
--- /dev/null
+++ b/tests/ui/generics/issue-59508-1.stderr
@@ -0,0 +1,8 @@
+error: lifetime parameters must be declared prior to type and const parameters
+ --> $DIR/issue-59508-1.rs:10:25
+ |
+LL | pub fn do_things<T, 'a, 'b: 'a>() {
+ | ----^^--^^----- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b: 'a, T>`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/generics/issue-59508.fixed b/tests/ui/generics/issue-59508.fixed
new file mode 100644
index 000000000..de8f47d4c
--- /dev/null
+++ b/tests/ui/generics/issue-59508.fixed
@@ -0,0 +1,16 @@
+// run-rustfix
+
+#![allow(dead_code)]
+
+// This test checks that generic parameter re-ordering diagnostic suggestions contain bounds.
+
+struct A;
+
+impl A {
+ pub fn do_things<'a, 'b: 'a, T>() {
+ //~^ ERROR lifetime parameters must be declared prior to type and const parameters
+ println!("panic");
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/generics/issue-59508.rs b/tests/ui/generics/issue-59508.rs
new file mode 100644
index 000000000..a4c7d4ff2
--- /dev/null
+++ b/tests/ui/generics/issue-59508.rs
@@ -0,0 +1,16 @@
+// run-rustfix
+
+#![allow(dead_code)]
+
+// This test checks that generic parameter re-ordering diagnostic suggestions contain bounds.
+
+struct A;
+
+impl A {
+ pub fn do_things<T, 'a, 'b: 'a>() {
+ //~^ ERROR lifetime parameters must be declared prior to type and const parameters
+ println!("panic");
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/generics/issue-59508.stderr b/tests/ui/generics/issue-59508.stderr
new file mode 100644
index 000000000..fd23b6276
--- /dev/null
+++ b/tests/ui/generics/issue-59508.stderr
@@ -0,0 +1,8 @@
+error: lifetime parameters must be declared prior to type and const parameters
+ --> $DIR/issue-59508.rs:10:25
+ |
+LL | pub fn do_things<T, 'a, 'b: 'a>() {
+ | ----^^--^^----- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b: 'a, T>`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.rs b/tests/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.rs
new file mode 100644
index 000000000..cc93794e8
--- /dev/null
+++ b/tests/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.rs
@@ -0,0 +1,20 @@
+#![crate_type="lib"]
+
+// rust-lang/rust#61631: The use of `Self` in the defaults of generic
+// types in a *trait* definition are allowed.
+//
+// It *must* be accepted; we have used this pattern extensively since
+// Rust 1.0 (see e.g. `trait Add<Rhs=Self>`).
+trait Tnobound<P = Self> {}
+
+impl Tnobound for () { }
+
+// This variant is accepted at the definition site; but it will be
+// rejected at every possible usage site (such as the one immediately
+// below). Maybe one day we will attempt to catch it at the definition
+// site, but today this is accepted due to compiler implementation
+// limitations.
+trait Tsized<P: Sized = [Self]> {}
+
+impl Tsized for () {}
+//~^ ERROR the size for values of type `[()]` cannot be known at compilation time [E0277]
diff --git a/tests/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr b/tests/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr
new file mode 100644
index 000000000..679118223
--- /dev/null
+++ b/tests/ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.stderr
@@ -0,0 +1,16 @@
+error[E0277]: the size for values of type `[()]` cannot be known at compilation time
+ --> $DIR/issue-61631-default-type-param-can-reference-self-in-trait.rs:19:6
+ |
+LL | impl Tsized for () {}
+ | ^^^^^^ doesn't have a size known at compile-time
+ |
+ = help: the trait `Sized` is not implemented for `[()]`
+note: required by a bound in `Tsized`
+ --> $DIR/issue-61631-default-type-param-can-reference-self-in-trait.rs:17:14
+ |
+LL | trait Tsized<P: Sized = [Self]> {}
+ | ^^^^^^^^^^^^^^^^^ required by this bound in `Tsized`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/generics/issue-61631-default-type-param-cannot-reference-self.rs b/tests/ui/generics/issue-61631-default-type-param-cannot-reference-self.rs
new file mode 100644
index 000000000..12db143e4
--- /dev/null
+++ b/tests/ui/generics/issue-61631-default-type-param-cannot-reference-self.rs
@@ -0,0 +1,45 @@
+#![crate_type="lib"]
+
+// rust-lang/rust#61631: Uses of `Self` in the defaults of generic
+// types for ADT's are not allowed. We justify this because the `Self`
+// type could be considered the "final" type parameter, that is only
+// well-defined after all of the other type parameters on the ADT have
+// been instantiated.
+//
+// These were previously were ICE'ing at the usage point anyway (see
+// `demo_usages` below), so there should not be any backwards
+// compatibility concern.
+
+struct Snobound<'a, P = Self> { x: Option<&'a P> }
+//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735]
+
+enum Enobound<'a, P = Self> { A, B(Option<&'a P>) }
+//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735]
+
+union Unobound<'a, P = Self> { x: i32, y: Option<&'a P> }
+//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735]
+
+// Disallowing `Self` in defaults sidesteps need to check the bounds
+// on the defaults in cases like these.
+
+struct Ssized<'a, P: Sized = [Self]> { x: Option<&'a P> }
+//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735]
+
+enum Esized<'a, P: Sized = [Self]> { A, B(Option<&'a P>) }
+//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735]
+
+union Usized<'a, P: Sized = [Self]> { x: i32, y: Option<&'a P> }
+//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735]
+
+fn demo_usages() {
+ // An ICE means you only get the error from the first line of the
+ // demo; comment each out to observe the other ICEs when trying
+ // this out on older versions of Rust.
+
+ let _ice: Snobound;
+ let _ice: Enobound;
+ let _ice: Unobound;
+ let _ice: Ssized;
+ let _ice: Esized;
+ let _ice: Usized;
+}
diff --git a/tests/ui/generics/issue-61631-default-type-param-cannot-reference-self.stderr b/tests/ui/generics/issue-61631-default-type-param-cannot-reference-self.stderr
new file mode 100644
index 000000000..f3a550801
--- /dev/null
+++ b/tests/ui/generics/issue-61631-default-type-param-cannot-reference-self.stderr
@@ -0,0 +1,39 @@
+error[E0735]: generic parameters cannot use `Self` in their defaults
+ --> $DIR/issue-61631-default-type-param-cannot-reference-self.rs:13:25
+ |
+LL | struct Snobound<'a, P = Self> { x: Option<&'a P> }
+ | ^^^^ `Self` in generic parameter default
+
+error[E0735]: generic parameters cannot use `Self` in their defaults
+ --> $DIR/issue-61631-default-type-param-cannot-reference-self.rs:16:23
+ |
+LL | enum Enobound<'a, P = Self> { A, B(Option<&'a P>) }
+ | ^^^^ `Self` in generic parameter default
+
+error[E0735]: generic parameters cannot use `Self` in their defaults
+ --> $DIR/issue-61631-default-type-param-cannot-reference-self.rs:19:24
+ |
+LL | union Unobound<'a, P = Self> { x: i32, y: Option<&'a P> }
+ | ^^^^ `Self` in generic parameter default
+
+error[E0735]: generic parameters cannot use `Self` in their defaults
+ --> $DIR/issue-61631-default-type-param-cannot-reference-self.rs:25:31
+ |
+LL | struct Ssized<'a, P: Sized = [Self]> { x: Option<&'a P> }
+ | ^^^^ `Self` in generic parameter default
+
+error[E0735]: generic parameters cannot use `Self` in their defaults
+ --> $DIR/issue-61631-default-type-param-cannot-reference-self.rs:28:29
+ |
+LL | enum Esized<'a, P: Sized = [Self]> { A, B(Option<&'a P>) }
+ | ^^^^ `Self` in generic parameter default
+
+error[E0735]: generic parameters cannot use `Self` in their defaults
+ --> $DIR/issue-61631-default-type-param-cannot-reference-self.rs:31:30
+ |
+LL | union Usized<'a, P: Sized = [Self]> { x: i32, y: Option<&'a P> }
+ | ^^^^ `Self` in generic parameter default
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0735`.
diff --git a/tests/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs b/tests/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs
new file mode 100644
index 000000000..9ea9fc71b
--- /dev/null
+++ b/tests/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs
@@ -0,0 +1,15 @@
+#![crate_type="lib"]
+
+struct Nested<K>(K);
+
+fn should_error<T>() where T : Into<&u32> {}
+//~^ ERROR `&` without an explicit lifetime name cannot be used here [E0637]
+
+trait X<'a, K: 'a> {
+ fn foo<'b, L: X<&'b Nested<K>>>();
+ //~^ ERROR missing lifetime specifier [E0106]
+ //~| ERROR the type `&'b Nested<K>` does not fulfill the required lifetime
+}
+
+fn bar<'b, L: X<&'b Nested<i32>>>(){}
+//~^ ERROR missing lifetime specifier [E0106]
diff --git a/tests/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr b/tests/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr
new file mode 100644
index 000000000..9d859fddf
--- /dev/null
+++ b/tests/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr
@@ -0,0 +1,57 @@
+error[E0637]: `&` without an explicit lifetime name cannot be used here
+ --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:5:37
+ |
+LL | fn should_error<T>() where T : Into<&u32> {}
+ | ^ explicit lifetime name needed here
+ |
+help: consider introducing a higher-ranked lifetime here with `for<'a>`
+ --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:5:32
+ |
+LL | fn should_error<T>() where T : Into<&u32> {}
+ | ^
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:9:20
+ |
+LL | fn foo<'b, L: X<&'b Nested<K>>>();
+ | ^ expected named lifetime parameter
+ |
+note: these named lifetimes are available to use
+ --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:8:9
+ |
+LL | trait X<'a, K: 'a> {
+ | ^^
+LL | fn foo<'b, L: X<&'b Nested<K>>>();
+ | ^^
+help: consider using one of the available lifetimes here
+ |
+LL | fn foo<'b, L: X<'lifetime, &'b Nested<K>>>();
+ | ++++++++++
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:14:16
+ |
+LL | fn bar<'b, L: X<&'b Nested<i32>>>(){}
+ | ^ expected named lifetime parameter
+ |
+help: consider using the `'b` lifetime
+ |
+LL | fn bar<'b, L: X<'b, &'b Nested<i32>>>(){}
+ | +++
+
+error[E0477]: the type `&'b Nested<K>` does not fulfill the required lifetime
+ --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:9:19
+ |
+LL | fn foo<'b, L: X<&'b Nested<K>>>();
+ | ^^^^^^^^^^^^^^^^
+ |
+note: type must satisfy the static lifetime as required by this binding
+ --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:8:16
+ |
+LL | trait X<'a, K: 'a> {
+ | ^^
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0106, E0477, E0637.
+For more information about an error, try `rustc --explain E0106`.
diff --git a/tests/ui/generics/issue-80512-param-reordering-with-defaults.rs b/tests/ui/generics/issue-80512-param-reordering-with-defaults.rs
new file mode 100644
index 000000000..0e208818e
--- /dev/null
+++ b/tests/ui/generics/issue-80512-param-reordering-with-defaults.rs
@@ -0,0 +1,4 @@
+#![crate_type = "lib"]
+
+struct S<T = (), 'a>(&'a T);
+//~^ ERROR lifetime parameters must be declared prior to type and const parameters
diff --git a/tests/ui/generics/issue-80512-param-reordering-with-defaults.stderr b/tests/ui/generics/issue-80512-param-reordering-with-defaults.stderr
new file mode 100644
index 000000000..70793a9c9
--- /dev/null
+++ b/tests/ui/generics/issue-80512-param-reordering-with-defaults.stderr
@@ -0,0 +1,8 @@
+error: lifetime parameters must be declared prior to type and const parameters
+ --> $DIR/issue-80512-param-reordering-with-defaults.rs:3:18
+ |
+LL | struct S<T = (), 'a>(&'a T);
+ | ---------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T = ()>`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/generics/issue-94432-garbage-ice.rs b/tests/ui/generics/issue-94432-garbage-ice.rs
new file mode 100644
index 000000000..d0709e2d2
--- /dev/null
+++ b/tests/ui/generics/issue-94432-garbage-ice.rs
@@ -0,0 +1,10 @@
+// check-fail
+// dont-check-compiler-stdout
+// dont-check-compiler-stderr
+
+fn�a<e>(){fn�p(){e}} //~ ERROR unknown start of token: \u{fffd}
+//~^ ERROR unknown start of token: \u{fffd}
+//~^^ ERROR can't use generic parameters from outer function [E0401]
+//~^^^ WARN type parameter `e` should have an upper camel case name
+
+fn main(){}
diff --git a/tests/ui/generics/issue-94923.rs b/tests/ui/generics/issue-94923.rs
new file mode 100644
index 000000000..d337a5dff
--- /dev/null
+++ b/tests/ui/generics/issue-94923.rs
@@ -0,0 +1,49 @@
+// run-pass
+// regression test for issue #94923
+// min-llvm-version: 15.0.0
+// compile-flags: -C opt-level=3
+
+fn f0<T>(mut x: usize) -> usize {
+ for _ in 0..1000 {
+ x *= 123;
+ x %= 99
+ }
+ x + 321 // function composition is not just longer iteration
+}
+
+fn f1<T>(x: usize) -> usize {
+ f0::<(i8, T)>(f0::<(u8, T)>(x))
+}
+
+fn f2<T>(x: usize) -> usize {
+ f1::<(i8, T)>(f1::<(u8, T)>(x))
+}
+
+fn f3<T>(x: usize) -> usize {
+ f2::<(i8, T)>(f2::<(u8, T)>(x))
+}
+
+fn f4<T>(x: usize) -> usize {
+ f3::<(i8, T)>(f3::<(u8, T)>(x))
+}
+
+fn f5<T>(x: usize) -> usize {
+ f4::<(i8, T)>(f4::<(u8, T)>(x))
+}
+
+fn f6<T>(x: usize) -> usize {
+ f5::<(i8, T)>(f5::<(u8, T)>(x))
+}
+
+fn f7<T>(x: usize) -> usize {
+ f6::<(i8, T)>(f6::<(u8, T)>(x))
+}
+
+fn f8<T>(x: usize) -> usize {
+ f7::<(i8, T)>(f7::<(u8, T)>(x))
+}
+
+fn main() {
+ let y = f8::<()>(1);
+ assert_eq!(y, 348);
+}
diff --git a/tests/ui/generics/issue-95208-ignore-qself.fixed b/tests/ui/generics/issue-95208-ignore-qself.fixed
new file mode 100644
index 000000000..608b4a20f
--- /dev/null
+++ b/tests/ui/generics/issue-95208-ignore-qself.fixed
@@ -0,0 +1,11 @@
+// run-rustfix
+
+#[allow(unused)]
+struct Struct<T>(T);
+
+impl<T: Iterator> Struct<T> where <T as std:: iter::Iterator>::Item: std::fmt::Display {
+//~^ ERROR expected `:` followed by trait or lifetime
+//~| HELP use single colon
+}
+
+fn main() {}
diff --git a/tests/ui/generics/issue-95208-ignore-qself.rs b/tests/ui/generics/issue-95208-ignore-qself.rs
new file mode 100644
index 000000000..da7efd576
--- /dev/null
+++ b/tests/ui/generics/issue-95208-ignore-qself.rs
@@ -0,0 +1,11 @@
+// run-rustfix
+
+#[allow(unused)]
+struct Struct<T>(T);
+
+impl<T: Iterator> Struct<T> where <T as std:: iter::Iterator>::Item:: std::fmt::Display {
+//~^ ERROR expected `:` followed by trait or lifetime
+//~| HELP use single colon
+}
+
+fn main() {}
diff --git a/tests/ui/generics/issue-95208-ignore-qself.stderr b/tests/ui/generics/issue-95208-ignore-qself.stderr
new file mode 100644
index 000000000..acbc1300d
--- /dev/null
+++ b/tests/ui/generics/issue-95208-ignore-qself.stderr
@@ -0,0 +1,10 @@
+error: expected `:` followed by trait or lifetime
+ --> $DIR/issue-95208-ignore-qself.rs:6:88
+ |
+LL | impl<T: Iterator> Struct<T> where <T as std:: iter::Iterator>::Item:: std::fmt::Display {
+ | --- ^
+ | |
+ | help: use single colon: `:`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/generics/issue-95208.fixed b/tests/ui/generics/issue-95208.fixed
new file mode 100644
index 000000000..a0b1e886c
--- /dev/null
+++ b/tests/ui/generics/issue-95208.fixed
@@ -0,0 +1,11 @@
+// run-rustfix
+
+#[allow(unused)]
+struct Struct<T>(T);
+
+impl<T> Struct<T> where T: std::fmt::Display {
+//~^ ERROR expected `:` followed by trait or lifetime
+//~| HELP use single colon
+}
+
+fn main() {}
diff --git a/tests/ui/generics/issue-95208.rs b/tests/ui/generics/issue-95208.rs
new file mode 100644
index 000000000..0e3083484
--- /dev/null
+++ b/tests/ui/generics/issue-95208.rs
@@ -0,0 +1,11 @@
+// run-rustfix
+
+#[allow(unused)]
+struct Struct<T>(T);
+
+impl<T> Struct<T> where T:: std::fmt::Display {
+//~^ ERROR expected `:` followed by trait or lifetime
+//~| HELP use single colon
+}
+
+fn main() {}
diff --git a/tests/ui/generics/issue-95208.stderr b/tests/ui/generics/issue-95208.stderr
new file mode 100644
index 000000000..559527663
--- /dev/null
+++ b/tests/ui/generics/issue-95208.stderr
@@ -0,0 +1,10 @@
+error: expected `:` followed by trait or lifetime
+ --> $DIR/issue-95208.rs:6:46
+ |
+LL | impl<T> Struct<T> where T:: std::fmt::Display {
+ | --- ^
+ | |
+ | help: use single colon: `:`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/generics/issue-98432.rs b/tests/ui/generics/issue-98432.rs
new file mode 100644
index 000000000..780c50d6f
--- /dev/null
+++ b/tests/ui/generics/issue-98432.rs
@@ -0,0 +1,9 @@
+struct Struct<T>(T);
+
+impl<T> Struct<T> {
+ const CONST: fn() = || {
+ struct _Obligation where T:; //~ ERROR can't use generic parameters from outer function
+ };
+}
+
+fn main() {}
diff --git a/tests/ui/generics/issue-98432.stderr b/tests/ui/generics/issue-98432.stderr
new file mode 100644
index 000000000..c7b5c3361
--- /dev/null
+++ b/tests/ui/generics/issue-98432.stderr
@@ -0,0 +1,14 @@
+error[E0401]: can't use generic parameters from outer function
+ --> $DIR/issue-98432.rs:5:34
+ |
+LL | impl<T> Struct<T> {
+ | - type parameter from outer function
+LL | const CONST: fn() = || {
+LL | struct _Obligation where T:;
+ | - ^ use of generic parameter from outer function
+ | |
+ | help: try using a local generic parameter instead: `<T>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0401`.
diff --git a/tests/ui/generics/lifetime-before-type-params.rs b/tests/ui/generics/lifetime-before-type-params.rs
new file mode 100644
index 000000000..d64b1b0b4
--- /dev/null
+++ b/tests/ui/generics/lifetime-before-type-params.rs
@@ -0,0 +1,11 @@
+#![allow(unused)]
+fn first<T, 'a, 'b>() {}
+//~^ ERROR lifetime parameters must be declared prior to type and const parameters
+fn second<'a, T, 'b>() {}
+//~^ ERROR lifetime parameters must be declared prior to type and const parameters
+fn third<T, U, 'a>() {}
+//~^ ERROR lifetime parameters must be declared prior to type and const parameters
+fn fourth<'a, T, 'b, U, 'c, V>() {}
+//~^ ERROR lifetime parameters must be declared prior to type and const parameters
+
+fn main() {}
diff --git a/tests/ui/generics/lifetime-before-type-params.stderr b/tests/ui/generics/lifetime-before-type-params.stderr
new file mode 100644
index 000000000..84825eb4c
--- /dev/null
+++ b/tests/ui/generics/lifetime-before-type-params.stderr
@@ -0,0 +1,26 @@
+error: lifetime parameters must be declared prior to type and const parameters
+ --> $DIR/lifetime-before-type-params.rs:2:13
+ |
+LL | fn first<T, 'a, 'b>() {}
+ | ----^^--^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
+
+error: lifetime parameters must be declared prior to type and const parameters
+ --> $DIR/lifetime-before-type-params.rs:4:18
+ |
+LL | fn second<'a, T, 'b>() {}
+ | --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>`
+
+error: lifetime parameters must be declared prior to type and const parameters
+ --> $DIR/lifetime-before-type-params.rs:6:16
+ |
+LL | fn third<T, U, 'a>() {}
+ | -------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, T, U>`
+
+error: lifetime parameters must be declared prior to type and const parameters
+ --> $DIR/lifetime-before-type-params.rs:8:18
+ |
+LL | fn fourth<'a, T, 'b, U, 'c, V>() {}
+ | --------^^-----^^---- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, 'c, T, U, V>`
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/ui/generics/mid-path-type-params.rs b/tests/ui/generics/mid-path-type-params.rs
new file mode 100644
index 000000000..a8128207c
--- /dev/null
+++ b/tests/ui/generics/mid-path-type-params.rs
@@ -0,0 +1,37 @@
+// run-pass
+
+#![allow(dead_code)]
+// pretty-expanded FIXME #23616
+
+struct S<T> {
+ contents: T,
+}
+
+impl<T> S<T> {
+ fn new<U>(x: T, _: U) -> S<T> {
+ S {
+ contents: x,
+ }
+ }
+}
+
+trait Trait<T> {
+ fn new<U>(x: T, y: U) -> Self;
+}
+
+struct S2 {
+ contents: isize,
+}
+
+impl Trait<isize> for S2 {
+ fn new<U>(x: isize, _: U) -> S2 {
+ S2 {
+ contents: x,
+ }
+ }
+}
+
+pub fn main() {
+ let _ = S::<isize>::new::<f64>(1, 1.0);
+ let _: S2 = Trait::<isize>::new::<f64>(1, 1.0);
+}
diff --git a/tests/ui/generics/param-in-ct-in-ty-param-default.rs b/tests/ui/generics/param-in-ct-in-ty-param-default.rs
new file mode 100644
index 000000000..3c62e4738
--- /dev/null
+++ b/tests/ui/generics/param-in-ct-in-ty-param-default.rs
@@ -0,0 +1,4 @@
+struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U);
+//~^ ERROR generic parameters may not be used in const operations
+
+fn main() {}
diff --git a/tests/ui/generics/param-in-ct-in-ty-param-default.stderr b/tests/ui/generics/param-in-ct-in-ty-param-default.stderr
new file mode 100644
index 000000000..ab09ebcae
--- /dev/null
+++ b/tests/ui/generics/param-in-ct-in-ty-param-default.stderr
@@ -0,0 +1,11 @@
+error: generic parameters may not be used in const operations
+ --> $DIR/param-in-ct-in-ty-param-default.rs:1:44
+ |
+LL | struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U);
+ | ^ cannot perform const operation using `T`
+ |
+ = note: type parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
+
+error: aborting due to previous error
+
diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.rs b/tests/ui/generics/post_monomorphization_error_backtrace.rs
new file mode 100644
index 000000000..1fd9b6b3b
--- /dev/null
+++ b/tests/ui/generics/post_monomorphization_error_backtrace.rs
@@ -0,0 +1,33 @@
+// build-fail
+
+fn assert_zst<T>() {
+ struct F<T>(T);
+ impl<T> F<T> {
+ const V: () = assert!(std::mem::size_of::<T>() == 0);
+ //~^ ERROR: evaluation of `assert_zst::F::<u32>::V` failed [E0080]
+ //~| NOTE: in this expansion of assert!
+ //~| NOTE: the evaluated program panicked
+ //~| ERROR: evaluation of `assert_zst::F::<i32>::V` failed [E0080]
+ //~| NOTE: in this expansion of assert!
+ //~| NOTE: the evaluated program panicked
+ }
+ let _ = F::<T>::V;
+}
+
+fn foo<U>() {
+ assert_zst::<U>()
+ //~^ NOTE: the above error was encountered while instantiating `fn assert_zst::<u32>`
+ //~| NOTE: the above error was encountered while instantiating `fn assert_zst::<i32>`
+}
+
+
+fn bar<V>() {
+ foo::<V>()
+}
+
+fn main() {
+ bar::<()>();
+ bar::<u32>();
+ bar::<u32>();
+ bar::<i32>();
+}
diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.stderr b/tests/ui/generics/post_monomorphization_error_backtrace.stderr
new file mode 100644
index 000000000..0d707d83d
--- /dev/null
+++ b/tests/ui/generics/post_monomorphization_error_backtrace.stderr
@@ -0,0 +1,31 @@
+error[E0080]: evaluation of `assert_zst::F::<u32>::V` failed
+ --> $DIR/post_monomorphization_error_backtrace.rs:6:23
+ |
+LL | const V: () = assert!(std::mem::size_of::<T>() == 0);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: std::mem::size_of::<T>() == 0', $DIR/post_monomorphization_error_backtrace.rs:6:23
+ |
+ = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+note: the above error was encountered while instantiating `fn assert_zst::<u32>`
+ --> $DIR/post_monomorphization_error_backtrace.rs:18:5
+ |
+LL | assert_zst::<U>()
+ | ^^^^^^^^^^^^^^^^^
+
+error[E0080]: evaluation of `assert_zst::F::<i32>::V` failed
+ --> $DIR/post_monomorphization_error_backtrace.rs:6:23
+ |
+LL | const V: () = assert!(std::mem::size_of::<T>() == 0);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: std::mem::size_of::<T>() == 0', $DIR/post_monomorphization_error_backtrace.rs:6:23
+ |
+ = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+note: the above error was encountered while instantiating `fn assert_zst::<i32>`
+ --> $DIR/post_monomorphization_error_backtrace.rs:18:5
+ |
+LL | assert_zst::<U>()
+ | ^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/generics/single-colon-path-not-const-generics.rs b/tests/ui/generics/single-colon-path-not-const-generics.rs
new file mode 100644
index 000000000..55a7ae0bb
--- /dev/null
+++ b/tests/ui/generics/single-colon-path-not-const-generics.rs
@@ -0,0 +1,13 @@
+pub mod foo {
+ pub mod bar {
+ pub struct A;
+ }
+}
+
+pub struct Foo {
+ a: Vec<foo::bar:A>,
+ //~^ ERROR expected
+ //~| HELP path separator
+}
+
+fn main() {}
diff --git a/tests/ui/generics/single-colon-path-not-const-generics.stderr b/tests/ui/generics/single-colon-path-not-const-generics.stderr
new file mode 100644
index 000000000..3eafa9fa5
--- /dev/null
+++ b/tests/ui/generics/single-colon-path-not-const-generics.stderr
@@ -0,0 +1,11 @@
+error: expected one of `,` or `>`, found `:`
+ --> $DIR/single-colon-path-not-const-generics.rs:8:18
+ |
+LL | a: Vec<foo::bar:A>,
+ | ^
+ | |
+ | expected one of `,` or `>`
+ | help: write a path separator here: `::`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/generics/type-params-in-for-each.rs b/tests/ui/generics/type-params-in-for-each.rs
new file mode 100644
index 000000000..53475d280
--- /dev/null
+++ b/tests/ui/generics/type-params-in-for-each.rs
@@ -0,0 +1,23 @@
+// run-pass
+
+#![allow(dead_code)]
+
+// pretty-expanded FIXME #23616
+
+struct S<T> {
+ a: T,
+ b: usize,
+}
+
+fn range_<F>(lo: usize, hi: usize, mut it: F) where F: FnMut(usize) {
+ let mut lo_ = lo;
+ while lo_ < hi { it(lo_); lo_ += 1; }
+}
+
+fn create_index<T>(_index: Vec<S<T>> , _hash_fn: extern "C" fn(T) -> usize) {
+ range_(0, 256, |_i| {
+ let _bucket: Vec<T> = Vec::new();
+ })
+}
+
+pub fn main() { }
diff --git a/tests/ui/generics/wrong-number-of-args.rs b/tests/ui/generics/wrong-number-of-args.rs
new file mode 100644
index 000000000..cd2f96a18
--- /dev/null
+++ b/tests/ui/generics/wrong-number-of-args.rs
@@ -0,0 +1,358 @@
+mod no_generics {
+ struct Ty;
+
+ type A = Ty;
+
+ type B = Ty<'static>;
+ //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument
+ //~| HELP remove these generics
+
+ type C = Ty<'static, usize>;
+ //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument
+ //~| ERROR this struct takes 0 generic arguments but 1 generic argument
+ //~| HELP remove this lifetime argument
+ //~| HELP remove this generic argument
+
+ type D = Ty<'static, usize, { 0 }>;
+ //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument
+ //~| ERROR this struct takes 0 generic arguments but 2 generic arguments
+ //~| HELP remove this lifetime argument
+ //~| HELP remove these generic arguments
+}
+
+mod type_and_type {
+ struct Ty<A, B>;
+
+ type A = Ty;
+ //~^ ERROR missing generics for struct `type_and_type::Ty`
+ //~| HELP add missing
+
+ type B = Ty<usize>;
+ //~^ ERROR this struct takes 2 generic arguments but 1 generic argument
+ //~| HELP add missing
+
+ type C = Ty<usize, String>;
+
+ type D = Ty<usize, String, char>;
+ //~^ ERROR this struct takes 2 generic arguments but 3 generic arguments
+ //~| HELP remove this
+
+ type E = Ty<>;
+ //~^ ERROR this struct takes 2 generic arguments but 0 generic arguments were supplied
+ //~| HELP add missing
+}
+
+mod lifetime_and_type {
+ struct Ty<'a, T>;
+
+ type A = Ty;
+ //~^ ERROR missing generics for struct
+ //~| ERROR missing lifetime specifier
+ //~| HELP add missing
+ //~| HELP consider introducing
+
+ type B = Ty<'static>;
+ //~^ ERROR this struct takes 1 generic argument but 0 generic arguments
+ //~| HELP add missing
+
+ type C = Ty<usize>;
+ //~^ ERROR missing lifetime specifier
+ //~| HELP consider introducing
+
+ type D = Ty<'static, usize>;
+
+ type E = Ty<>;
+ //~^ ERROR this struct takes 1 generic argument but 0 generic arguments
+ //~| ERROR missing lifetime specifier
+ //~| HELP consider introducing
+ //~| HELP add missing
+
+ type F = Ty<'static, usize, 'static, usize>;
+ //~^ ERROR this struct takes 1 lifetime argument but 2 lifetime arguments
+ //~| ERROR this struct takes 1 generic argument but 2 generic arguments
+ //~| HELP remove this lifetime argument
+ //~| HELP remove this generic argument
+}
+
+mod type_and_type_and_type {
+ struct Ty<A, B, C = &'static str>;
+
+ type A = Ty;
+ //~^ ERROR missing generics for struct `type_and_type_and_type::Ty`
+ //~| HELP add missing
+
+ type B = Ty<usize>;
+ //~^ ERROR this struct takes at least 2
+ //~| HELP add missing
+
+ type C = Ty<usize, String>;
+
+ type D = Ty<usize, String, char>;
+
+ type E = Ty<usize, String, char, f64>;
+ //~^ ERROR this struct takes at most 3
+ //~| HELP remove
+
+ type F = Ty<>;
+ //~^ ERROR this struct takes at least 2 generic arguments but 0 generic arguments
+ //~| HELP add missing
+}
+
+// Traits have an implicit `Self` type - these tests ensure we don't accidentally return it
+// somewhere in the message
+mod r#trait {
+ trait NonGeneric {
+ //
+ }
+
+ trait GenericLifetime<'a> {
+ //
+ }
+
+ trait GenericType<A> {
+ //
+ }
+
+ type A = Box<dyn NonGeneric<usize>>;
+ //~^ ERROR this trait takes 0 generic arguments but 1 generic argument
+ //~| HELP remove
+
+ type B = Box<dyn GenericLifetime>;
+ //~^ ERROR missing lifetime specifier
+ //~| HELP consider introducing
+ //~| HELP consider making the bound lifetime-generic
+
+ type C = Box<dyn GenericLifetime<'static, 'static>>;
+ //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+ //~| HELP remove
+
+ type D = Box<dyn GenericType>;
+ //~^ ERROR missing generics for trait `GenericType`
+ //~| HELP add missing
+
+ type E = Box<dyn GenericType<String, usize>>;
+ //~^ ERROR this trait takes 1 generic argument but 2 generic arguments
+ //~| HELP remove
+
+ type F = Box<dyn GenericLifetime<>>;
+ //~^ ERROR missing lifetime specifier
+ //~| HELP consider introducing
+ //~| HELP consider making the bound lifetime-generic
+
+ type G = Box<dyn GenericType<>>;
+ //~^ ERROR this trait takes 1 generic argument but 0 generic arguments
+ //~| HELP add missing
+}
+
+mod associated_item {
+ mod non_generic {
+ trait NonGenericAT {
+ type AssocTy;
+ }
+
+ type A = Box<dyn NonGenericAT<usize, AssocTy=()>>;
+ //~^ ERROR this trait takes 0 generic arguments but 1 generic argument
+ //~| HELP remove
+ }
+
+ mod lifetime {
+ trait GenericLifetimeAT<'a> {
+ type AssocTy;
+ }
+
+ type A = Box<dyn GenericLifetimeAT<AssocTy=()>>;
+ //~^ ERROR missing lifetime specifier
+ //~| HELP consider introducing
+ //~| HELP consider making the bound lifetime-generic
+
+ type B = Box<dyn GenericLifetimeAT<'static, 'static, AssocTy=()>>;
+ //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+ //~| HELP remove
+
+ type C = Box<dyn GenericLifetimeAT<(), AssocTy=()>>;
+ //~^ ERROR missing lifetime specifier
+ //~| HELP consider introducing
+ //~| HELP consider making the bound lifetime-generic
+ //~| ERROR this trait takes 0 generic arguments but 1 generic argument
+ //~| HELP remove
+ }
+
+ mod r#type {
+ trait GenericTypeAT<A> {
+ type AssocTy;
+ }
+
+ type A = Box<dyn GenericTypeAT<AssocTy=()>>;
+ //~^ ERROR this trait takes 1 generic argument but 0 generic arguments
+ //~| HELP add missing
+
+ type B = Box<dyn GenericTypeAT<(), (), AssocTy=()>>;
+ //~^ ERROR this trait takes 1 generic argument but 2 generic arguments
+ //~| HELP remove
+
+ type C = Box<dyn GenericTypeAT<'static, AssocTy=()>>;
+ //~^ ERROR this trait takes 1 generic argument but 0 generic arguments
+ //~| HELP add missing
+ //~| ERROR this trait takes 0 lifetime arguments but 1 lifetime argument was supplied
+ //~| HELP remove
+ }
+
+ mod lifetime_and_type {
+ trait GenericLifetimeTypeAT<'a, A> {
+ type AssocTy;
+ }
+
+ type A = Box<dyn GenericLifetimeTypeAT<AssocTy=()>>;
+ //~^ ERROR this trait takes 1 generic argument but 0 generic arguments
+ //~| HELP add missing
+ //~| ERROR missing lifetime specifier
+ //~| HELP consider introducing
+ //~| HELP consider making the bound lifetime-generic
+
+ type B = Box<dyn GenericLifetimeTypeAT<'static, AssocTy=()>>;
+ //~^ ERROR this trait takes 1 generic argument but 0 generic arguments were supplied
+ //~| HELP add missing
+
+ type C = Box<dyn GenericLifetimeTypeAT<'static, 'static, AssocTy=()>>;
+ //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+ //~| HELP remove
+ //~| ERROR this trait takes 1 generic argument but 0 generic arguments
+ //~| HELP add missing
+
+ type D = Box<dyn GenericLifetimeTypeAT<(), AssocTy=()>>;
+ //~^ ERROR missing lifetime specifier
+ //~| HELP consider introducing
+ //~| HELP consider making the bound lifetime-generic
+
+ type E = Box<dyn GenericLifetimeTypeAT<(), (), AssocTy=()>>;
+ //~^ ERROR missing lifetime specifier
+ //~| HELP consider introducing
+ //~| HELP consider making the bound lifetime-generic
+ //~| ERROR this trait takes 1 generic argument but 2 generic arguments
+ //~| HELP remove
+
+ type F = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), AssocTy=()>>;
+ //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+ //~| HELP remove
+
+ type G = Box<dyn GenericLifetimeTypeAT<'static, (), (), AssocTy=()>>;
+ //~^ ERROR this trait takes 1 generic argument but 2 generic arguments
+ //~| HELP remove
+
+ type H = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), (), AssocTy=()>>;
+ //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+ //~| HELP remove
+ //~| ERROR this trait takes 1 generic argument but 2 generic arguments
+ //~| HELP remove
+ }
+
+ mod type_and_type {
+ trait GenericTypeTypeAT<A, B> {
+ type AssocTy;
+ }
+
+ type A = Box<dyn GenericTypeTypeAT<AssocTy=()>>;
+ //~^ ERROR this trait takes 2 generic arguments but 0 generic arguments
+ //~| HELP add missing
+
+ type B = Box<dyn GenericTypeTypeAT<(), AssocTy=()>>;
+ //~^ ERROR this trait takes 2 generic arguments but 1 generic argument
+ //~| HELP add missing
+
+ type C = Box<dyn GenericTypeTypeAT<(), (), (), AssocTy=()>>;
+ //~^ ERROR this trait takes 2 generic arguments but 3 generic arguments
+ //~| HELP remove
+ }
+
+ mod lifetime_and_lifetime {
+ trait GenericLifetimeLifetimeAT<'a, 'b> {
+ type AssocTy;
+ }
+
+ type A = Box<dyn GenericLifetimeLifetimeAT<AssocTy=()>>;
+ //~^ ERROR missing lifetime specifier
+ //~| HELP consider introducing
+ //~| HELP consider making the bound lifetime-generic
+
+ type B = Box<dyn GenericLifetimeLifetimeAT<'static, AssocTy=()>>;
+ //~^ ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+ //~| HELP add missing lifetime argument
+ }
+
+ mod lifetime_and_lifetime_and_type {
+ trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> {
+ type AssocTy;
+ }
+
+ type A = Box<dyn GenericLifetimeLifetimeTypeAT<AssocTy=()>>;
+ //~^ ERROR missing lifetime specifier
+ //~| HELP consider introducing
+ //~| HELP consider making the bound lifetime-generic
+ //~| ERROR this trait takes 1 generic argument but 0 generic arguments
+ //~| HELP add missing
+
+ type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, AssocTy=()>>;
+ //~^ ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+ //~| HELP add missing lifetime argument
+ //~| ERROR this trait takes 1 generic argument but 0 generic arguments
+ //~| HELP add missing
+
+ type C = Box<dyn GenericLifetimeLifetimeTypeAT<'static, (), AssocTy=()>>;
+ //~^ ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+ //~| HELP add missing lifetime argument
+ }
+}
+
+mod stdlib {
+ mod hash_map {
+ use std::collections::HashMap;
+
+ type A = HashMap;
+ //~^ ERROR missing generics for struct `HashMap`
+ //~| HELP add missing
+
+ type B = HashMap<String>;
+ //~^ ERROR this struct takes at least
+ //~| HELP add missing
+
+ type C = HashMap<'static>;
+ //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument
+ //~| HELP remove these generics
+ //~| ERROR this struct takes at least 2
+ //~| HELP add missing
+
+ type D = HashMap<usize, String, char, f64>;
+ //~^ ERROR this struct takes at most 3
+ //~| HELP remove this
+
+ type E = HashMap<>;
+ //~^ ERROR this struct takes at least 2 generic arguments but 0 generic arguments
+ //~| HELP add missing
+ }
+
+ mod result {
+ type A = Result;
+ //~^ ERROR missing generics for enum `Result`
+ //~| HELP add missing
+
+ type B = Result<String>;
+ //~^ ERROR this enum takes 2 generic arguments but 1 generic argument
+ //~| HELP add missing
+
+ type C = Result<'static>;
+ //~^ ERROR this enum takes 0 lifetime arguments but 1 lifetime argument
+ //~| HELP remove these generics
+ //~| ERROR this enum takes 2 generic arguments but 0 generic arguments
+ //~| HELP add missing
+
+ type D = Result<usize, String, char>;
+ //~^ ERROR this enum takes 2 generic arguments but 3 generic arguments
+ //~| HELP remove
+
+ type E = Result<>;
+ //~^ ERROR this enum takes 2 generic arguments but 0 generic arguments
+ //~| HELP add missing
+ }
+}
+
+fn main() { }
diff --git a/tests/ui/generics/wrong-number-of-args.stderr b/tests/ui/generics/wrong-number-of-args.stderr
new file mode 100644
index 000000000..75e33f680
--- /dev/null
+++ b/tests/ui/generics/wrong-number-of-args.stderr
@@ -0,0 +1,1013 @@
+error[E0106]: missing lifetime specifier
+ --> $DIR/wrong-number-of-args.rs:48:14
+ |
+LL | type A = Ty;
+ | ^^ expected named lifetime parameter
+ |
+help: consider introducing a named lifetime parameter
+ |
+LL | type A<'a> = Ty<'a>;
+ | ++++ ++++
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/wrong-number-of-args.rs:58:16
+ |
+LL | type C = Ty<usize>;
+ | ^ expected named lifetime parameter
+ |
+help: consider introducing a named lifetime parameter
+ |
+LL | type C<'a> = Ty<'a, usize>;
+ | ++++ +++
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/wrong-number-of-args.rs:64:16
+ |
+LL | type E = Ty<>;
+ | ^ expected named lifetime parameter
+ |
+help: consider introducing a named lifetime parameter
+ |
+LL | type E<'a> = Ty<'a, >;
+ | ++++ +++
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/wrong-number-of-args.rs:120:22
+ |
+LL | type B = Box<dyn GenericLifetime>;
+ | ^^^^^^^^^^^^^^^ expected named lifetime parameter
+ |
+ = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
+help: consider making the bound lifetime-generic with a new `'a` lifetime
+ |
+LL | type B = Box<dyn for<'a> GenericLifetime<'a>>;
+ | +++++++ ++++
+help: consider introducing a named lifetime parameter
+ |
+LL | type B<'a> = Box<dyn GenericLifetime<'a>>;
+ | ++++ ++++
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/wrong-number-of-args.rs:137:37
+ |
+LL | type F = Box<dyn GenericLifetime<>>;
+ | ^ expected named lifetime parameter
+ |
+help: consider making the bound lifetime-generic with a new `'a` lifetime
+ |
+LL | type F = Box<dyn for<'a> GenericLifetime<'a, >>;
+ | +++++++ +++
+help: consider introducing a named lifetime parameter
+ |
+LL | type F<'a> = Box<dyn GenericLifetime<'a, >>;
+ | ++++ +++
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/wrong-number-of-args.rs:163:43
+ |
+LL | type A = Box<dyn GenericLifetimeAT<AssocTy=()>>;
+ | ^ expected named lifetime parameter
+ |
+help: consider making the bound lifetime-generic with a new `'a` lifetime
+ |
+LL | type A = Box<dyn for<'a> GenericLifetimeAT<'a, AssocTy=()>>;
+ | +++++++ +++
+help: consider introducing a named lifetime parameter
+ |
+LL | type A<'a> = Box<dyn GenericLifetimeAT<'a, AssocTy=()>>;
+ | ++++ +++
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/wrong-number-of-args.rs:172:43
+ |
+LL | type C = Box<dyn GenericLifetimeAT<(), AssocTy=()>>;
+ | ^ expected named lifetime parameter
+ |
+help: consider making the bound lifetime-generic with a new `'a` lifetime
+ |
+LL | type C = Box<dyn for<'a> GenericLifetimeAT<'a, (), AssocTy=()>>;
+ | +++++++ +++
+help: consider introducing a named lifetime parameter
+ |
+LL | type C<'a> = Box<dyn GenericLifetimeAT<'a, (), AssocTy=()>>;
+ | ++++ +++
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/wrong-number-of-args.rs:205:47
+ |
+LL | type A = Box<dyn GenericLifetimeTypeAT<AssocTy=()>>;
+ | ^ expected named lifetime parameter
+ |
+help: consider making the bound lifetime-generic with a new `'a` lifetime
+ |
+LL | type A = Box<dyn for<'a> GenericLifetimeTypeAT<'a, AssocTy=()>>;
+ | +++++++ +++
+help: consider introducing a named lifetime parameter
+ |
+LL | type A<'a> = Box<dyn GenericLifetimeTypeAT<'a, AssocTy=()>>;
+ | ++++ +++
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/wrong-number-of-args.rs:222:47
+ |
+LL | type D = Box<dyn GenericLifetimeTypeAT<(), AssocTy=()>>;
+ | ^ expected named lifetime parameter
+ |
+help: consider making the bound lifetime-generic with a new `'a` lifetime
+ |
+LL | type D = Box<dyn for<'a> GenericLifetimeTypeAT<'a, (), AssocTy=()>>;
+ | +++++++ +++
+help: consider introducing a named lifetime parameter
+ |
+LL | type D<'a> = Box<dyn GenericLifetimeTypeAT<'a, (), AssocTy=()>>;
+ | ++++ +++
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/wrong-number-of-args.rs:227:47
+ |
+LL | type E = Box<dyn GenericLifetimeTypeAT<(), (), AssocTy=()>>;
+ | ^ expected named lifetime parameter
+ |
+help: consider making the bound lifetime-generic with a new `'a` lifetime
+ |
+LL | type E = Box<dyn for<'a> GenericLifetimeTypeAT<'a, (), (), AssocTy=()>>;
+ | +++++++ +++
+help: consider introducing a named lifetime parameter
+ |
+LL | type E<'a> = Box<dyn GenericLifetimeTypeAT<'a, (), (), AssocTy=()>>;
+ | ++++ +++
+
+error[E0106]: missing lifetime specifiers
+ --> $DIR/wrong-number-of-args.rs:272:51
+ |
+LL | type A = Box<dyn GenericLifetimeLifetimeAT<AssocTy=()>>;
+ | ^ expected 2 lifetime parameters
+ |
+help: consider making the bound lifetime-generic with a new `'a` lifetime
+ |
+LL | type A = Box<dyn for<'a> GenericLifetimeLifetimeAT<'a, 'a, AssocTy=()>>;
+ | +++++++ +++++++
+help: consider introducing a named lifetime parameter
+ |
+LL | type A<'a> = Box<dyn GenericLifetimeLifetimeAT<'a, 'a, AssocTy=()>>;
+ | ++++ +++++++
+
+error[E0106]: missing lifetime specifiers
+ --> $DIR/wrong-number-of-args.rs:287:55
+ |
+LL | type A = Box<dyn GenericLifetimeLifetimeTypeAT<AssocTy=()>>;
+ | ^ expected 2 lifetime parameters
+ |
+help: consider making the bound lifetime-generic with a new `'a` lifetime
+ |
+LL | type A = Box<dyn for<'a> GenericLifetimeLifetimeTypeAT<'a, 'a, AssocTy=()>>;
+ | +++++++ +++++++
+help: consider introducing a named lifetime parameter
+ |
+LL | type A<'a> = Box<dyn GenericLifetimeLifetimeTypeAT<'a, 'a, AssocTy=()>>;
+ | ++++ +++++++
+
+error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
+ --> $DIR/wrong-number-of-args.rs:6:14
+ |
+LL | type B = Ty<'static>;
+ | ^^--------- help: remove these generics
+ | |
+ | expected 0 lifetime arguments
+ |
+note: struct defined here, with 0 lifetime parameters
+ --> $DIR/wrong-number-of-args.rs:2:12
+ |
+LL | struct Ty;
+ | ^^
+
+error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
+ --> $DIR/wrong-number-of-args.rs:10:14
+ |
+LL | type C = Ty<'static, usize>;
+ | ^^ ------- help: remove this lifetime argument
+ | |
+ | expected 0 lifetime arguments
+ |
+note: struct defined here, with 0 lifetime parameters
+ --> $DIR/wrong-number-of-args.rs:2:12
+ |
+LL | struct Ty;
+ | ^^
+
+error[E0107]: this struct takes 0 generic arguments but 1 generic argument was supplied
+ --> $DIR/wrong-number-of-args.rs:10:14
+ |
+LL | type C = Ty<'static, usize>;
+ | ^^ ----- help: remove this generic argument
+ | |
+ | expected 0 generic arguments
+ |
+note: struct defined here, with 0 generic parameters
+ --> $DIR/wrong-number-of-args.rs:2:12
+ |
+LL | struct Ty;
+ | ^^
+
+error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
+ --> $DIR/wrong-number-of-args.rs:16:14
+ |
+LL | type D = Ty<'static, usize, { 0 }>;
+ | ^^ ------- help: remove this lifetime argument
+ | |
+ | expected 0 lifetime arguments
+ |
+note: struct defined here, with 0 lifetime parameters
+ --> $DIR/wrong-number-of-args.rs:2:12
+ |
+LL | struct Ty;
+ | ^^
+
+error[E0107]: this struct takes 0 generic arguments but 2 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:16:14
+ |
+LL | type D = Ty<'static, usize, { 0 }>;
+ | ^^ ------------ help: remove these generic arguments
+ | |
+ | expected 0 generic arguments
+ |
+note: struct defined here, with 0 generic parameters
+ --> $DIR/wrong-number-of-args.rs:2:12
+ |
+LL | struct Ty;
+ | ^^
+
+error[E0107]: missing generics for struct `type_and_type::Ty`
+ --> $DIR/wrong-number-of-args.rs:26:14
+ |
+LL | type A = Ty;
+ | ^^ expected 2 generic arguments
+ |
+note: struct defined here, with 2 generic parameters: `A`, `B`
+ --> $DIR/wrong-number-of-args.rs:24:12
+ |
+LL | struct Ty<A, B>;
+ | ^^ - -
+help: add missing generic arguments
+ |
+LL | type A = Ty<A, B>;
+ | ++++++
+
+error[E0107]: this struct takes 2 generic arguments but 1 generic argument was supplied
+ --> $DIR/wrong-number-of-args.rs:30:14
+ |
+LL | type B = Ty<usize>;
+ | ^^ ----- supplied 1 generic argument
+ | |
+ | expected 2 generic arguments
+ |
+note: struct defined here, with 2 generic parameters: `A`, `B`
+ --> $DIR/wrong-number-of-args.rs:24:12
+ |
+LL | struct Ty<A, B>;
+ | ^^ - -
+help: add missing generic argument
+ |
+LL | type B = Ty<usize, B>;
+ | +++
+
+error[E0107]: this struct takes 2 generic arguments but 3 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:36:14
+ |
+LL | type D = Ty<usize, String, char>;
+ | ^^ ---- help: remove this generic argument
+ | |
+ | expected 2 generic arguments
+ |
+note: struct defined here, with 2 generic parameters: `A`, `B`
+ --> $DIR/wrong-number-of-args.rs:24:12
+ |
+LL | struct Ty<A, B>;
+ | ^^ - -
+
+error[E0107]: this struct takes 2 generic arguments but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:40:14
+ |
+LL | type E = Ty<>;
+ | ^^ expected 2 generic arguments
+ |
+note: struct defined here, with 2 generic parameters: `A`, `B`
+ --> $DIR/wrong-number-of-args.rs:24:12
+ |
+LL | struct Ty<A, B>;
+ | ^^ - -
+help: add missing generic arguments
+ |
+LL | type E = Ty<A, B>;
+ | ++++
+
+error[E0107]: missing generics for struct `lifetime_and_type::Ty`
+ --> $DIR/wrong-number-of-args.rs:48:14
+ |
+LL | type A = Ty;
+ | ^^ expected 1 generic argument
+ |
+note: struct defined here, with 1 generic parameter: `T`
+ --> $DIR/wrong-number-of-args.rs:46:12
+ |
+LL | struct Ty<'a, T>;
+ | ^^ -
+help: add missing generic argument
+ |
+LL | type A = Ty<T>;
+ | +++
+
+error[E0107]: this struct takes 1 generic argument but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:54:14
+ |
+LL | type B = Ty<'static>;
+ | ^^ expected 1 generic argument
+ |
+note: struct defined here, with 1 generic parameter: `T`
+ --> $DIR/wrong-number-of-args.rs:46:12
+ |
+LL | struct Ty<'a, T>;
+ | ^^ -
+help: add missing generic argument
+ |
+LL | type B = Ty<'static, T>;
+ | +++
+
+error[E0107]: this struct takes 1 generic argument but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:64:14
+ |
+LL | type E = Ty<>;
+ | ^^ expected 1 generic argument
+ |
+note: struct defined here, with 1 generic parameter: `T`
+ --> $DIR/wrong-number-of-args.rs:46:12
+ |
+LL | struct Ty<'a, T>;
+ | ^^ -
+help: add missing generic argument
+ |
+LL | type E = Ty<T>;
+ | +
+
+error[E0107]: this struct takes 1 lifetime argument but 2 lifetime arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:70:14
+ |
+LL | type F = Ty<'static, usize, 'static, usize>;
+ | ^^ ------- help: remove this lifetime argument
+ | |
+ | expected 1 lifetime argument
+ |
+note: struct defined here, with 1 lifetime parameter: `'a`
+ --> $DIR/wrong-number-of-args.rs:46:12
+ |
+LL | struct Ty<'a, T>;
+ | ^^ --
+
+error[E0107]: this struct takes 1 generic argument but 2 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:70:14
+ |
+LL | type F = Ty<'static, usize, 'static, usize>;
+ | ^^ ----- help: remove this generic argument
+ | |
+ | expected 1 generic argument
+ |
+note: struct defined here, with 1 generic parameter: `T`
+ --> $DIR/wrong-number-of-args.rs:46:12
+ |
+LL | struct Ty<'a, T>;
+ | ^^ -
+
+error[E0107]: missing generics for struct `type_and_type_and_type::Ty`
+ --> $DIR/wrong-number-of-args.rs:80:14
+ |
+LL | type A = Ty;
+ | ^^ expected at least 2 generic arguments
+ |
+note: struct defined here, with at least 2 generic parameters: `A`, `B`
+ --> $DIR/wrong-number-of-args.rs:78:12
+ |
+LL | struct Ty<A, B, C = &'static str>;
+ | ^^ - -
+help: add missing generic arguments
+ |
+LL | type A = Ty<A, B>;
+ | ++++++
+
+error[E0107]: this struct takes at least 2 generic arguments but 1 generic argument was supplied
+ --> $DIR/wrong-number-of-args.rs:84:14
+ |
+LL | type B = Ty<usize>;
+ | ^^ ----- supplied 1 generic argument
+ | |
+ | expected at least 2 generic arguments
+ |
+note: struct defined here, with at least 2 generic parameters: `A`, `B`
+ --> $DIR/wrong-number-of-args.rs:78:12
+ |
+LL | struct Ty<A, B, C = &'static str>;
+ | ^^ - -
+help: add missing generic argument
+ |
+LL | type B = Ty<usize, B>;
+ | +++
+
+error[E0107]: this struct takes at most 3 generic arguments but 4 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:92:14
+ |
+LL | type E = Ty<usize, String, char, f64>;
+ | ^^ --- help: remove this generic argument
+ | |
+ | expected at most 3 generic arguments
+ |
+note: struct defined here, with at most 3 generic parameters: `A`, `B`, `C`
+ --> $DIR/wrong-number-of-args.rs:78:12
+ |
+LL | struct Ty<A, B, C = &'static str>;
+ | ^^ - - ----------------
+
+error[E0107]: this struct takes at least 2 generic arguments but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:96:14
+ |
+LL | type F = Ty<>;
+ | ^^ expected at least 2 generic arguments
+ |
+note: struct defined here, with at least 2 generic parameters: `A`, `B`
+ --> $DIR/wrong-number-of-args.rs:78:12
+ |
+LL | struct Ty<A, B, C = &'static str>;
+ | ^^ - -
+help: add missing generic arguments
+ |
+LL | type F = Ty<A, B>;
+ | ++++
+
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
+ --> $DIR/wrong-number-of-args.rs:116:22
+ |
+LL | type A = Box<dyn NonGeneric<usize>>;
+ | ^^^^^^^^^^------- help: remove these generics
+ | |
+ | expected 0 generic arguments
+ |
+note: trait defined here, with 0 generic parameters
+ --> $DIR/wrong-number-of-args.rs:104:11
+ |
+LL | trait NonGeneric {
+ | ^^^^^^^^^^
+
+error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:125:22
+ |
+LL | type C = Box<dyn GenericLifetime<'static, 'static>>;
+ | ^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument
+ | |
+ | expected 1 lifetime argument
+ |
+note: trait defined here, with 1 lifetime parameter: `'a`
+ --> $DIR/wrong-number-of-args.rs:108:11
+ |
+LL | trait GenericLifetime<'a> {
+ | ^^^^^^^^^^^^^^^ --
+
+error[E0107]: missing generics for trait `GenericType`
+ --> $DIR/wrong-number-of-args.rs:129:22
+ |
+LL | type D = Box<dyn GenericType>;
+ | ^^^^^^^^^^^ expected 1 generic argument
+ |
+note: trait defined here, with 1 generic parameter: `A`
+ --> $DIR/wrong-number-of-args.rs:112:11
+ |
+LL | trait GenericType<A> {
+ | ^^^^^^^^^^^ -
+help: add missing generic argument
+ |
+LL | type D = Box<dyn GenericType<A>>;
+ | +++
+
+error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:133:22
+ |
+LL | type E = Box<dyn GenericType<String, usize>>;
+ | ^^^^^^^^^^^ ----- help: remove this generic argument
+ | |
+ | expected 1 generic argument
+ |
+note: trait defined here, with 1 generic parameter: `A`
+ --> $DIR/wrong-number-of-args.rs:112:11
+ |
+LL | trait GenericType<A> {
+ | ^^^^^^^^^^^ -
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:142:22
+ |
+LL | type G = Box<dyn GenericType<>>;
+ | ^^^^^^^^^^^ expected 1 generic argument
+ |
+note: trait defined here, with 1 generic parameter: `A`
+ --> $DIR/wrong-number-of-args.rs:112:11
+ |
+LL | trait GenericType<A> {
+ | ^^^^^^^^^^^ -
+help: add missing generic argument
+ |
+LL | type G = Box<dyn GenericType<A>>;
+ | +
+
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
+ --> $DIR/wrong-number-of-args.rs:153:26
+ |
+LL | type A = Box<dyn NonGenericAT<usize, AssocTy=()>>;
+ | ^^^^^^^^^^^^------------------- help: remove these generics
+ | |
+ | expected 0 generic arguments
+ |
+note: trait defined here, with 0 generic parameters
+ --> $DIR/wrong-number-of-args.rs:149:15
+ |
+LL | trait NonGenericAT {
+ | ^^^^^^^^^^^^
+
+error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:168:26
+ |
+LL | type B = Box<dyn GenericLifetimeAT<'static, 'static, AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument
+ | |
+ | expected 1 lifetime argument
+ |
+note: trait defined here, with 1 lifetime parameter: `'a`
+ --> $DIR/wrong-number-of-args.rs:159:15
+ |
+LL | trait GenericLifetimeAT<'a> {
+ | ^^^^^^^^^^^^^^^^^ --
+
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
+ --> $DIR/wrong-number-of-args.rs:172:26
+ |
+LL | type C = Box<dyn GenericLifetimeAT<(), AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^ -- help: remove this generic argument
+ | |
+ | expected 0 generic arguments
+ |
+note: trait defined here, with 0 generic parameters
+ --> $DIR/wrong-number-of-args.rs:159:15
+ |
+LL | trait GenericLifetimeAT<'a> {
+ | ^^^^^^^^^^^^^^^^^
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:185:26
+ |
+LL | type A = Box<dyn GenericTypeAT<AssocTy=()>>;
+ | ^^^^^^^^^^^^^ expected 1 generic argument
+ |
+note: trait defined here, with 1 generic parameter: `A`
+ --> $DIR/wrong-number-of-args.rs:181:15
+ |
+LL | trait GenericTypeAT<A> {
+ | ^^^^^^^^^^^^^ -
+help: add missing generic argument
+ |
+LL | type A = Box<dyn GenericTypeAT<A, AssocTy=()>>;
+ | ++
+
+error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:189:26
+ |
+LL | type B = Box<dyn GenericTypeAT<(), (), AssocTy=()>>;
+ | ^^^^^^^^^^^^^ -- help: remove this generic argument
+ | |
+ | expected 1 generic argument
+ |
+note: trait defined here, with 1 generic parameter: `A`
+ --> $DIR/wrong-number-of-args.rs:181:15
+ |
+LL | trait GenericTypeAT<A> {
+ | ^^^^^^^^^^^^^ -
+
+error[E0107]: this trait takes 0 lifetime arguments but 1 lifetime argument was supplied
+ --> $DIR/wrong-number-of-args.rs:193:26
+ |
+LL | type C = Box<dyn GenericTypeAT<'static, AssocTy=()>>;
+ | ^^^^^^^^^^^^^--------------------- help: remove these generics
+ | |
+ | expected 0 lifetime arguments
+ |
+note: trait defined here, with 0 lifetime parameters
+ --> $DIR/wrong-number-of-args.rs:181:15
+ |
+LL | trait GenericTypeAT<A> {
+ | ^^^^^^^^^^^^^
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:193:26
+ |
+LL | type C = Box<dyn GenericTypeAT<'static, AssocTy=()>>;
+ | ^^^^^^^^^^^^^ expected 1 generic argument
+ |
+note: trait defined here, with 1 generic parameter: `A`
+ --> $DIR/wrong-number-of-args.rs:181:15
+ |
+LL | trait GenericTypeAT<A> {
+ | ^^^^^^^^^^^^^ -
+help: add missing generic argument
+ |
+LL | type C = Box<dyn GenericTypeAT<'static, A, AssocTy=()>>;
+ | +++
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:205:26
+ |
+LL | type A = Box<dyn GenericLifetimeTypeAT<AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument
+ |
+note: trait defined here, with 1 generic parameter: `A`
+ --> $DIR/wrong-number-of-args.rs:201:15
+ |
+LL | trait GenericLifetimeTypeAT<'a, A> {
+ | ^^^^^^^^^^^^^^^^^^^^^ -
+help: add missing generic argument
+ |
+LL | type A = Box<dyn GenericLifetimeTypeAT<A, AssocTy=()>>;
+ | ++
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:212:26
+ |
+LL | type B = Box<dyn GenericLifetimeTypeAT<'static, AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument
+ |
+note: trait defined here, with 1 generic parameter: `A`
+ --> $DIR/wrong-number-of-args.rs:201:15
+ |
+LL | trait GenericLifetimeTypeAT<'a, A> {
+ | ^^^^^^^^^^^^^^^^^^^^^ -
+help: add missing generic argument
+ |
+LL | type B = Box<dyn GenericLifetimeTypeAT<'static, A, AssocTy=()>>;
+ | +++
+
+error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:216:26
+ |
+LL | type C = Box<dyn GenericLifetimeTypeAT<'static, 'static, AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument
+ | |
+ | expected 1 lifetime argument
+ |
+note: trait defined here, with 1 lifetime parameter: `'a`
+ --> $DIR/wrong-number-of-args.rs:201:15
+ |
+LL | trait GenericLifetimeTypeAT<'a, A> {
+ | ^^^^^^^^^^^^^^^^^^^^^ --
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:216:26
+ |
+LL | type C = Box<dyn GenericLifetimeTypeAT<'static, 'static, AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument
+ |
+note: trait defined here, with 1 generic parameter: `A`
+ --> $DIR/wrong-number-of-args.rs:201:15
+ |
+LL | trait GenericLifetimeTypeAT<'a, A> {
+ | ^^^^^^^^^^^^^^^^^^^^^ -
+help: add missing generic argument
+ |
+LL | type C = Box<dyn GenericLifetimeTypeAT<'static, 'static, A, AssocTy=()>>;
+ | +++
+
+error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:227:26
+ |
+LL | type E = Box<dyn GenericLifetimeTypeAT<(), (), AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^ -- help: remove this generic argument
+ | |
+ | expected 1 generic argument
+ |
+note: trait defined here, with 1 generic parameter: `A`
+ --> $DIR/wrong-number-of-args.rs:201:15
+ |
+LL | trait GenericLifetimeTypeAT<'a, A> {
+ | ^^^^^^^^^^^^^^^^^^^^^ -
+
+error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:234:26
+ |
+LL | type F = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument
+ | |
+ | expected 1 lifetime argument
+ |
+note: trait defined here, with 1 lifetime parameter: `'a`
+ --> $DIR/wrong-number-of-args.rs:201:15
+ |
+LL | trait GenericLifetimeTypeAT<'a, A> {
+ | ^^^^^^^^^^^^^^^^^^^^^ --
+
+error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:238:26
+ |
+LL | type G = Box<dyn GenericLifetimeTypeAT<'static, (), (), AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^ -- help: remove this generic argument
+ | |
+ | expected 1 generic argument
+ |
+note: trait defined here, with 1 generic parameter: `A`
+ --> $DIR/wrong-number-of-args.rs:201:15
+ |
+LL | trait GenericLifetimeTypeAT<'a, A> {
+ | ^^^^^^^^^^^^^^^^^^^^^ -
+
+error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:242:26
+ |
+LL | type H = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), (), AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument
+ | |
+ | expected 1 lifetime argument
+ |
+note: trait defined here, with 1 lifetime parameter: `'a`
+ --> $DIR/wrong-number-of-args.rs:201:15
+ |
+LL | trait GenericLifetimeTypeAT<'a, A> {
+ | ^^^^^^^^^^^^^^^^^^^^^ --
+
+error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:242:26
+ |
+LL | type H = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), (), AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^ -- help: remove this generic argument
+ | |
+ | expected 1 generic argument
+ |
+note: trait defined here, with 1 generic parameter: `A`
+ --> $DIR/wrong-number-of-args.rs:201:15
+ |
+LL | trait GenericLifetimeTypeAT<'a, A> {
+ | ^^^^^^^^^^^^^^^^^^^^^ -
+
+error[E0107]: this trait takes 2 generic arguments but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:254:26
+ |
+LL | type A = Box<dyn GenericTypeTypeAT<AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^ expected 2 generic arguments
+ |
+note: trait defined here, with 2 generic parameters: `A`, `B`
+ --> $DIR/wrong-number-of-args.rs:250:15
+ |
+LL | trait GenericTypeTypeAT<A, B> {
+ | ^^^^^^^^^^^^^^^^^ - -
+help: add missing generic arguments
+ |
+LL | type A = Box<dyn GenericTypeTypeAT<A, B, AssocTy=()>>;
+ | +++++
+
+error[E0107]: this trait takes 2 generic arguments but 1 generic argument was supplied
+ --> $DIR/wrong-number-of-args.rs:258:26
+ |
+LL | type B = Box<dyn GenericTypeTypeAT<(), AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^ -- supplied 1 generic argument
+ | |
+ | expected 2 generic arguments
+ |
+note: trait defined here, with 2 generic parameters: `A`, `B`
+ --> $DIR/wrong-number-of-args.rs:250:15
+ |
+LL | trait GenericTypeTypeAT<A, B> {
+ | ^^^^^^^^^^^^^^^^^ - -
+help: add missing generic argument
+ |
+LL | type B = Box<dyn GenericTypeTypeAT<(), B, AssocTy=()>>;
+ | +++
+
+error[E0107]: this trait takes 2 generic arguments but 3 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:262:26
+ |
+LL | type C = Box<dyn GenericTypeTypeAT<(), (), (), AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^ -- help: remove this generic argument
+ | |
+ | expected 2 generic arguments
+ |
+note: trait defined here, with 2 generic parameters: `A`, `B`
+ --> $DIR/wrong-number-of-args.rs:250:15
+ |
+LL | trait GenericTypeTypeAT<A, B> {
+ | ^^^^^^^^^^^^^^^^^ - -
+
+error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+ --> $DIR/wrong-number-of-args.rs:277:26
+ |
+LL | type B = Box<dyn GenericLifetimeLifetimeAT<'static, AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ ------- supplied 1 lifetime argument
+ | |
+ | expected 2 lifetime arguments
+ |
+note: trait defined here, with 2 lifetime parameters: `'a`, `'b`
+ --> $DIR/wrong-number-of-args.rs:268:15
+ |
+LL | trait GenericLifetimeLifetimeAT<'a, 'b> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ -- --
+help: add missing lifetime argument
+ |
+LL | type B = Box<dyn GenericLifetimeLifetimeAT<'static, 'static, AssocTy=()>>;
+ | +++++++++
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:287:26
+ |
+LL | type A = Box<dyn GenericLifetimeLifetimeTypeAT<AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument
+ |
+note: trait defined here, with 1 generic parameter: `A`
+ --> $DIR/wrong-number-of-args.rs:283:15
+ |
+LL | trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -
+help: add missing generic argument
+ |
+LL | type A = Box<dyn GenericLifetimeLifetimeTypeAT<A, AssocTy=()>>;
+ | ++
+
+error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+ --> $DIR/wrong-number-of-args.rs:294:26
+ |
+LL | type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------- supplied 1 lifetime argument
+ | |
+ | expected 2 lifetime arguments
+ |
+note: trait defined here, with 2 lifetime parameters: `'a`, `'b`
+ --> $DIR/wrong-number-of-args.rs:283:15
+ |
+LL | trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- --
+help: add missing lifetime argument
+ |
+LL | type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, 'static, AssocTy=()>>;
+ | +++++++++
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:294:26
+ |
+LL | type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument
+ |
+note: trait defined here, with 1 generic parameter: `A`
+ --> $DIR/wrong-number-of-args.rs:283:15
+ |
+LL | trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -
+help: add missing generic argument
+ |
+LL | type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, A, AssocTy=()>>;
+ | +++
+
+error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+ --> $DIR/wrong-number-of-args.rs:300:26
+ |
+LL | type C = Box<dyn GenericLifetimeLifetimeTypeAT<'static, (), AssocTy=()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------- supplied 1 lifetime argument
+ | |
+ | expected 2 lifetime arguments
+ |
+note: trait defined here, with 2 lifetime parameters: `'a`, `'b`
+ --> $DIR/wrong-number-of-args.rs:283:15
+ |
+LL | trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- --
+help: add missing lifetime argument
+ |
+LL | type C = Box<dyn GenericLifetimeLifetimeTypeAT<'static, 'static, (), AssocTy=()>>;
+ | +++++++++
+
+error[E0107]: missing generics for struct `HashMap`
+ --> $DIR/wrong-number-of-args.rs:310:18
+ |
+LL | type A = HashMap;
+ | ^^^^^^^ expected at least 2 generic arguments
+ |
+help: add missing generic arguments
+ |
+LL | type A = HashMap<K, V>;
+ | ++++++
+
+error[E0107]: this struct takes at least 2 generic arguments but 1 generic argument was supplied
+ --> $DIR/wrong-number-of-args.rs:314:18
+ |
+LL | type B = HashMap<String>;
+ | ^^^^^^^ ------ supplied 1 generic argument
+ | |
+ | expected at least 2 generic arguments
+ |
+help: add missing generic argument
+ |
+LL | type B = HashMap<String, V>;
+ | +++
+
+error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
+ --> $DIR/wrong-number-of-args.rs:318:18
+ |
+LL | type C = HashMap<'static>;
+ | ^^^^^^^--------- help: remove these generics
+ | |
+ | expected 0 lifetime arguments
+
+error[E0107]: this struct takes at least 2 generic arguments but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:318:18
+ |
+LL | type C = HashMap<'static>;
+ | ^^^^^^^ expected at least 2 generic arguments
+ |
+help: add missing generic arguments
+ |
+LL | type C = HashMap<'static, K, V>;
+ | ++++++
+
+error[E0107]: this struct takes at most 3 generic arguments but 4 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:324:18
+ |
+LL | type D = HashMap<usize, String, char, f64>;
+ | ^^^^^^^ --- help: remove this generic argument
+ | |
+ | expected at most 3 generic arguments
+
+error[E0107]: this struct takes at least 2 generic arguments but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:328:18
+ |
+LL | type E = HashMap<>;
+ | ^^^^^^^ expected at least 2 generic arguments
+ |
+help: add missing generic arguments
+ |
+LL | type E = HashMap<K, V>;
+ | ++++
+
+error[E0107]: missing generics for enum `Result`
+ --> $DIR/wrong-number-of-args.rs:334:18
+ |
+LL | type A = Result;
+ | ^^^^^^ expected 2 generic arguments
+ |
+help: add missing generic arguments
+ |
+LL | type A = Result<T, E>;
+ | ++++++
+
+error[E0107]: this enum takes 2 generic arguments but 1 generic argument was supplied
+ --> $DIR/wrong-number-of-args.rs:338:18
+ |
+LL | type B = Result<String>;
+ | ^^^^^^ ------ supplied 1 generic argument
+ | |
+ | expected 2 generic arguments
+ |
+help: add missing generic argument
+ |
+LL | type B = Result<String, E>;
+ | +++
+
+error[E0107]: this enum takes 0 lifetime arguments but 1 lifetime argument was supplied
+ --> $DIR/wrong-number-of-args.rs:342:18
+ |
+LL | type C = Result<'static>;
+ | ^^^^^^--------- help: remove these generics
+ | |
+ | expected 0 lifetime arguments
+
+error[E0107]: this enum takes 2 generic arguments but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:342:18
+ |
+LL | type C = Result<'static>;
+ | ^^^^^^ expected 2 generic arguments
+ |
+help: add missing generic arguments
+ |
+LL | type C = Result<'static, T, E>;
+ | ++++++
+
+error[E0107]: this enum takes 2 generic arguments but 3 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:348:18
+ |
+LL | type D = Result<usize, String, char>;
+ | ^^^^^^ ---- help: remove this generic argument
+ | |
+ | expected 2 generic arguments
+
+error[E0107]: this enum takes 2 generic arguments but 0 generic arguments were supplied
+ --> $DIR/wrong-number-of-args.rs:352:18
+ |
+LL | type E = Result<>;
+ | ^^^^^^ expected 2 generic arguments
+ |
+help: add missing generic arguments
+ |
+LL | type E = Result<T, E>;
+ | ++++
+
+error: aborting due to 71 previous errors
+
+Some errors have detailed explanations: E0106, E0107.
+For more information about an error, try `rustc --explain E0106`.