From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../const-args.rs | 21 +++++++++++++++++++++ .../explicit-generic-args-for-impl.rs | 5 +++++ .../explicit-generic-args-for-impl.stderr | 18 ++++++++++++++++++ .../explicit-generic-args.rs | 7 +++++++ .../issue-87718.rs | 7 +++++++ .../not-enough-args.rs | 6 ++++++ .../not-enough-args.stderr | 21 +++++++++++++++++++++ 7 files changed, 85 insertions(+) create mode 100644 src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/const-args.rs create mode 100644 src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args-for-impl.rs create mode 100644 src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args-for-impl.stderr create mode 100644 src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args.rs create mode 100644 src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/issue-87718.rs create mode 100644 src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.rs create mode 100644 src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.stderr (limited to 'src/test/ui/impl-trait/explicit-generic-args-with-impl-trait') diff --git a/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/const-args.rs b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/const-args.rs new file mode 100644 index 000000000..1aa23c608 --- /dev/null +++ b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/const-args.rs @@ -0,0 +1,21 @@ +// check-pass + +trait Usizer { + fn m(self) -> usize; +} + +fn f(u: impl Usizer) -> usize { + N + u.m() +} + +struct Usizable; + +impl Usizer for Usizable { + fn m(self) -> usize { + 16 + } +} + +fn main() { + assert_eq!(f::<4usize>(Usizable), 20usize); +} diff --git a/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args-for-impl.rs b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args-for-impl.rs new file mode 100644 index 000000000..3b1024d61 --- /dev/null +++ b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args-for-impl.rs @@ -0,0 +1,5 @@ +fn foo(_f: impl AsRef) {} + +fn main() { + foo::("".to_string()); //~ ERROR E0107 +} diff --git a/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args-for-impl.stderr b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args-for-impl.stderr new file mode 100644 index 000000000..c8b82783e --- /dev/null +++ b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args-for-impl.stderr @@ -0,0 +1,18 @@ +error[E0107]: this function takes 1 generic argument but 2 generic arguments were supplied + --> $DIR/explicit-generic-args-for-impl.rs:4:5 + | +LL | foo::("".to_string()); + | ^^^ ------ help: remove this generic argument + | | + | expected 1 generic argument + | +note: function defined here, with 1 generic parameter: `T` + --> $DIR/explicit-generic-args-for-impl.rs:1:4 + | +LL | fn foo(_f: impl AsRef) {} + | ^^^ - + = note: `impl Trait` cannot be explicitly specified as a generic argument + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0107`. diff --git a/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args.rs b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args.rs new file mode 100644 index 000000000..99e0931ab --- /dev/null +++ b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args.rs @@ -0,0 +1,7 @@ +// check-pass + +fn foo(_f: impl AsRef) {} + +fn main() { + foo::("".to_string()); +} 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 000000000..987df4997 --- /dev/null +++ b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/issue-87718.rs @@ -0,0 +1,7 @@ +// check-pass + +fn f(_: impl AsRef, _: impl AsRef) {} + +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 000000000..7249a36f5 --- /dev/null +++ b/src/test/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.rs @@ -0,0 +1,6 @@ +fn f(_: impl AsRef, _: impl AsRef) {} + +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 000000000..9d6db88d3 --- /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:4: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:1:4 + | +LL | fn f(_: impl AsRef, _: impl AsRef) {} + | ^ - - +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`. -- cgit v1.2.3