diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
commit | 631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch) | |
tree | a1b87c8f8cad01cf18f7c5f57a08f102771ed303 /tests/ui/generics | |
parent | Adding debian version 1.69.0+dfsg1-1. (diff) | |
download | rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/generics')
5 files changed, 76 insertions, 0 deletions
diff --git a/tests/ui/generics/auxiliary/foreign-generic-mismatch.rs b/tests/ui/generics/auxiliary/foreign-generic-mismatch.rs new file mode 100644 index 000000000..d89c1e036 --- /dev/null +++ b/tests/ui/generics/auxiliary/foreign-generic-mismatch.rs @@ -0,0 +1,3 @@ +pub fn const_arg<const N: usize, T>() {} + +pub fn lt_arg<'a: 'a>() {} diff --git a/tests/ui/generics/foreign-generic-mismatch.rs b/tests/ui/generics/foreign-generic-mismatch.rs new file mode 100644 index 000000000..403fd73d7 --- /dev/null +++ b/tests/ui/generics/foreign-generic-mismatch.rs @@ -0,0 +1,10 @@ +// aux-build: foreign-generic-mismatch.rs + +extern crate foreign_generic_mismatch; + +fn main() { + foreign_generic_mismatch::const_arg::<()>(); + //~^ ERROR function takes 2 generic arguments but 1 generic argument was supplied + foreign_generic_mismatch::lt_arg::<'static, 'static>(); + //~^ ERROR function takes 1 lifetime argument but 2 lifetime arguments were supplied +} diff --git a/tests/ui/generics/foreign-generic-mismatch.stderr b/tests/ui/generics/foreign-generic-mismatch.stderr new file mode 100644 index 000000000..5322b3f91 --- /dev/null +++ b/tests/ui/generics/foreign-generic-mismatch.stderr @@ -0,0 +1,35 @@ +error[E0107]: function takes 2 generic arguments but 1 generic argument was supplied + --> $DIR/foreign-generic-mismatch.rs:6:31 + | +LL | foreign_generic_mismatch::const_arg::<()>(); + | ^^^^^^^^^ -- supplied 1 generic argument + | | + | expected 2 generic arguments + | +note: function defined here, with 2 generic parameters: `N`, `T` + --> $DIR/auxiliary/foreign-generic-mismatch.rs:1:8 + | +LL | pub fn const_arg<const N: usize, T>() {} + | ^^^^^^^^^ -------------- - +help: add missing generic argument + | +LL | foreign_generic_mismatch::const_arg::<(), T>(); + | +++ + +error[E0107]: function takes 1 lifetime argument but 2 lifetime arguments were supplied + --> $DIR/foreign-generic-mismatch.rs:8:31 + | +LL | foreign_generic_mismatch::lt_arg::<'static, 'static>(); + | ^^^^^^ ------- help: remove this lifetime argument + | | + | expected 1 lifetime argument + | +note: function defined here, with 1 lifetime parameter: `'a` + --> $DIR/auxiliary/foreign-generic-mismatch.rs:3:8 + | +LL | pub fn lt_arg<'a: 'a>() {} + | ^^^^^^ -- + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/generics/slightly-nice-generic-literal-messages.rs b/tests/ui/generics/slightly-nice-generic-literal-messages.rs new file mode 100644 index 000000000..268009f65 --- /dev/null +++ b/tests/ui/generics/slightly-nice-generic-literal-messages.rs @@ -0,0 +1,14 @@ +use std::marker; + +struct Foo<T,U>(T, marker::PhantomData<U>); + +fn main() { + match Foo(1.1, marker::PhantomData) { + 1 => {} + //~^ ERROR mismatched types + //~| expected struct `Foo<{float}, _>` + //~| found type `{integer}` + //~| expected `Foo<{float}, _>`, found integer + } + +} diff --git a/tests/ui/generics/slightly-nice-generic-literal-messages.stderr b/tests/ui/generics/slightly-nice-generic-literal-messages.stderr new file mode 100644 index 000000000..83ef522ab --- /dev/null +++ b/tests/ui/generics/slightly-nice-generic-literal-messages.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/slightly-nice-generic-literal-messages.rs:7:9 + | +LL | match Foo(1.1, marker::PhantomData) { + | ----------------------------- this expression has type `Foo<{float}, _>` +LL | 1 => {} + | ^ expected `Foo<{float}, _>`, found integer + | + = note: expected struct `Foo<{float}, _>` + found type `{integer}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. |