about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGiacomo Stevanato <giaco.stevanato@gmail.com>2021-08-03 13:38:48 +0200
committerGiacomo Stevanato <giaco.stevanato@gmail.com>2021-08-03 13:38:48 +0200
commitae313da4ba50aa5f9edcdc647812da6489ffefd2 (patch)
treebafc0e12ff8c234142efdbb64d41becc4dd0ad42
parent2fd874d0d5ec1618e488d0d10b8b67553aeaaf1e (diff)
downloadrust-ae313da4ba50aa5f9edcdc647812da6489ffefd2.tar.gz
rust-ae313da4ba50aa5f9edcdc647812da6489ffefd2.zip
Add regression tests
-rw-r--r--src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/issue-87718.rs9
-rw-r--r--src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.rs8
-rw-r--r--src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.stderr21
3 files changed, 38 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/issue-87718.rs b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/issue-87718.rs
new file mode 100644
index 00000000000..e2ee63821ae
--- /dev/null
+++ b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/issue-87718.rs
@@ -0,0 +1,9 @@
+// check-pass
+
+#![feature(explicit_generic_args_with_impl_trait)]
+
+fn f<T: ?Sized>(_: impl AsRef<T>, _: impl AsRef<T>) {}
+
+fn main() {
+    f::<[u8]>("a", b"a");
+}
diff --git a/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.rs b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.rs
new file mode 100644
index 00000000000..ffb0582fe8d
--- /dev/null
+++ b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.rs
@@ -0,0 +1,8 @@
+#![feature(explicit_generic_args_with_impl_trait)]
+
+fn f<T: ?Sized, U: ?Sized>(_: impl AsRef<T>, _: impl AsRef<U>) {}
+
+fn main() {
+    f::<[u8]>("a", b"a");
+    //~^ ERROR: this function takes 2 generic arguments but 1 generic argument was supplied
+}
diff --git a/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.stderr b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.stderr
new file mode 100644
index 00000000000..233b47445db
--- /dev/null
+++ b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.stderr
@@ -0,0 +1,21 @@
+error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
+  --> $DIR/not-enough-args.rs:6:5
+   |
+LL |     f::<[u8]>("a", b"a");
+   |     ^   ---- supplied 1 generic argument
+   |     |
+   |     expected 2 generic arguments
+   |
+note: function defined here, with 2 generic parameters: `T`, `U`
+  --> $DIR/not-enough-args.rs:3:4
+   |
+LL | fn f<T: ?Sized, U: ?Sized>(_: impl AsRef<T>, _: impl AsRef<U>) {}
+   |    ^ -          -
+help: add missing generic argument
+   |
+LL |     f::<[u8], U>("a", b"a");
+   |             ^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0107`.