diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
commit | a4b7ed7a42c716ab9f05e351f003d589124fd55d (patch) | |
tree | b620cd3f223850b28716e474e80c58059dca5dd4 /tests/ui/tuple | |
parent | Adding upstream version 1.67.1+dfsg1. (diff) | |
download | rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip |
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/tuple')
35 files changed, 624 insertions, 0 deletions
diff --git a/tests/ui/tuple/add-tuple-within-arguments.rs b/tests/ui/tuple/add-tuple-within-arguments.rs new file mode 100644 index 000000000..01b13b29f --- /dev/null +++ b/tests/ui/tuple/add-tuple-within-arguments.rs @@ -0,0 +1,10 @@ +fn foo(s: &str, a: (i32, i32), s2: &str) {} + +fn bar(s: &str, a: (&str,), s2: &str) {} + +fn main() { + foo("hi", 1, 2, "hi"); + //~^ ERROR function takes 3 arguments but 4 arguments were supplied + bar("hi", "hi", "hi"); + //~^ ERROR mismatched types +} diff --git a/tests/ui/tuple/add-tuple-within-arguments.stderr b/tests/ui/tuple/add-tuple-within-arguments.stderr new file mode 100644 index 000000000..2e20a4cca --- /dev/null +++ b/tests/ui/tuple/add-tuple-within-arguments.stderr @@ -0,0 +1,40 @@ +error[E0061]: function takes 3 arguments but 4 arguments were supplied + --> $DIR/add-tuple-within-arguments.rs:6:5 + | +LL | foo("hi", 1, 2, "hi"); + | ^^^ + | +note: function defined here + --> $DIR/add-tuple-within-arguments.rs:1:4 + | +LL | fn foo(s: &str, a: (i32, i32), s2: &str) {} + | ^^^ ------------- +help: wrap these arguments in parentheses to construct a tuple + | +LL | foo("hi", (1, 2), "hi"); + | + + + +error[E0308]: mismatched types + --> $DIR/add-tuple-within-arguments.rs:8:15 + | +LL | bar("hi", "hi", "hi"); + | --- ^^^^ expected tuple, found `&str` + | | + | arguments to this function are incorrect + | + = note: expected tuple `(&str,)` + found reference `&'static str` +note: function defined here + --> $DIR/add-tuple-within-arguments.rs:3:4 + | +LL | fn bar(s: &str, a: (&str,), s2: &str) {} + | ^^^ ---------- +help: use a trailing comma to create a tuple with one element + | +LL | bar("hi", ("hi",), "hi"); + | + ++ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0061, E0308. +For more information about an error, try `rustc --explain E0061`. diff --git a/tests/ui/tuple/array-diagnostics.rs b/tests/ui/tuple/array-diagnostics.rs new file mode 100644 index 000000000..1929dab07 --- /dev/null +++ b/tests/ui/tuple/array-diagnostics.rs @@ -0,0 +1,7 @@ +fn main() { + let _tmp = [ + ("C200B40A82", 3), + ("C200B40A83", 4) //~ ERROR: expected function, found `(&'static str, {integer})` [E0618] + ("C200B40A8537", 5), + ]; +} diff --git a/tests/ui/tuple/array-diagnostics.stderr b/tests/ui/tuple/array-diagnostics.stderr new file mode 100644 index 000000000..a10d7af47 --- /dev/null +++ b/tests/ui/tuple/array-diagnostics.stderr @@ -0,0 +1,9 @@ +error[E0618]: expected function, found `(&'static str, {integer})` + --> $DIR/array-diagnostics.rs:4:9 + | +LL | ("C200B40A83", 4) + | ^^^^^^^^^^^^^^^^^- help: consider separating array elements with a comma: `,` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0618`. diff --git a/tests/ui/tuple/builtin-fail.rs b/tests/ui/tuple/builtin-fail.rs new file mode 100644 index 000000000..312080961 --- /dev/null +++ b/tests/ui/tuple/builtin-fail.rs @@ -0,0 +1,19 @@ +#![feature(tuple_trait)] + +fn assert_is_tuple<T: std::marker::Tuple + ?Sized>() {} + +struct TupleStruct(i32, i32); + +fn from_param_env<T>() { + assert_is_tuple::<T>(); + //~^ ERROR `T` is not a tuple +} + +fn main() { + assert_is_tuple::<i32>(); + //~^ ERROR `i32` is not a tuple + assert_is_tuple::<(i32)>(); + //~^ ERROR `i32` is not a tuple + assert_is_tuple::<TupleStruct>(); + //~^ ERROR `TupleStruct` is not a tuple +} diff --git a/tests/ui/tuple/builtin-fail.stderr b/tests/ui/tuple/builtin-fail.stderr new file mode 100644 index 000000000..e3e29a73f --- /dev/null +++ b/tests/ui/tuple/builtin-fail.stderr @@ -0,0 +1,55 @@ +error[E0277]: `T` is not a tuple + --> $DIR/builtin-fail.rs:8:23 + | +LL | assert_is_tuple::<T>(); + | ^ the trait `Tuple` is not implemented for `T` + | +note: required by a bound in `assert_is_tuple` + --> $DIR/builtin-fail.rs:3:23 + | +LL | fn assert_is_tuple<T: std::marker::Tuple + ?Sized>() {} + | ^^^^^^^^^^^^^^^^^^ required by this bound in `assert_is_tuple` +help: consider restricting type parameter `T` + | +LL | fn from_param_env<T: std::marker::Tuple>() { + | ++++++++++++++++++++ + +error[E0277]: `i32` is not a tuple + --> $DIR/builtin-fail.rs:13:23 + | +LL | assert_is_tuple::<i32>(); + | ^^^ the trait `Tuple` is not implemented for `i32` + | +note: required by a bound in `assert_is_tuple` + --> $DIR/builtin-fail.rs:3:23 + | +LL | fn assert_is_tuple<T: std::marker::Tuple + ?Sized>() {} + | ^^^^^^^^^^^^^^^^^^ required by this bound in `assert_is_tuple` + +error[E0277]: `i32` is not a tuple + --> $DIR/builtin-fail.rs:15:24 + | +LL | assert_is_tuple::<(i32)>(); + | ^^^ the trait `Tuple` is not implemented for `i32` + | +note: required by a bound in `assert_is_tuple` + --> $DIR/builtin-fail.rs:3:23 + | +LL | fn assert_is_tuple<T: std::marker::Tuple + ?Sized>() {} + | ^^^^^^^^^^^^^^^^^^ required by this bound in `assert_is_tuple` + +error[E0277]: `TupleStruct` is not a tuple + --> $DIR/builtin-fail.rs:17:23 + | +LL | assert_is_tuple::<TupleStruct>(); + | ^^^^^^^^^^^ the trait `Tuple` is not implemented for `TupleStruct` + | +note: required by a bound in `assert_is_tuple` + --> $DIR/builtin-fail.rs:3:23 + | +LL | fn assert_is_tuple<T: std::marker::Tuple + ?Sized>() {} + | ^^^^^^^^^^^^^^^^^^ required by this bound in `assert_is_tuple` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/tuple/builtin.rs b/tests/ui/tuple/builtin.rs new file mode 100644 index 000000000..d87ce5263 --- /dev/null +++ b/tests/ui/tuple/builtin.rs @@ -0,0 +1,20 @@ +// check-pass + +#![feature(tuple_trait)] + +fn assert_is_tuple<T: std::marker::Tuple + ?Sized>() {} + +struct Unsized([u8]); + +fn from_param_env<T: std::marker::Tuple + ?Sized>() { + assert_is_tuple::<T>(); +} + +fn main() { + assert_is_tuple::<()>(); + assert_is_tuple::<(i32,)>(); + assert_is_tuple::<(Unsized,)>(); + from_param_env::<()>(); + from_param_env::<(i32,)>(); + from_param_env::<(Unsized,)>(); +} diff --git a/tests/ui/tuple/index-float.rs b/tests/ui/tuple/index-float.rs new file mode 100644 index 000000000..eda2bf485 --- /dev/null +++ b/tests/ui/tuple/index-float.rs @@ -0,0 +1,10 @@ +// check-pass + +fn main() { + let tuple = (((),),); + + let _ = tuple. 0.0; // OK, whitespace + let _ = tuple.0. 0; // OK, whitespace + + let _ = tuple./*special cases*/0.0; // OK, comment +} diff --git a/tests/ui/tuple/index-invalid.rs b/tests/ui/tuple/index-invalid.rs new file mode 100644 index 000000000..d36f6cfe3 --- /dev/null +++ b/tests/ui/tuple/index-invalid.rs @@ -0,0 +1,7 @@ +fn main() { + let _ = (((),),).1.0; //~ ERROR no field `1` on type `(((),),)` + + let _ = (((),),).0.1; //~ ERROR no field `1` on type `((),)` + + let _ = (((),),).000.000; //~ ERROR no field `000` on type `(((),),)` +} diff --git a/tests/ui/tuple/index-invalid.stderr b/tests/ui/tuple/index-invalid.stderr new file mode 100644 index 000000000..8d22f458a --- /dev/null +++ b/tests/ui/tuple/index-invalid.stderr @@ -0,0 +1,21 @@ +error[E0609]: no field `1` on type `(((),),)` + --> $DIR/index-invalid.rs:2:22 + | +LL | let _ = (((),),).1.0; + | ^ + +error[E0609]: no field `1` on type `((),)` + --> $DIR/index-invalid.rs:4:24 + | +LL | let _ = (((),),).0.1; + | ^ + +error[E0609]: no field `000` on type `(((),),)` + --> $DIR/index-invalid.rs:6:22 + | +LL | let _ = (((),),).000.000; + | ^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/tuple/indexing-in-macro.rs b/tests/ui/tuple/indexing-in-macro.rs new file mode 100644 index 000000000..bef4a69ab --- /dev/null +++ b/tests/ui/tuple/indexing-in-macro.rs @@ -0,0 +1,9 @@ +// check-pass + +macro_rules! m { + (.$l:literal) => {}; +} + +m!(.0.0); // OK, `0.0` after a dot is still a float token. + +fn main() {} diff --git a/tests/ui/tuple/nested-index.rs b/tests/ui/tuple/nested-index.rs new file mode 100644 index 000000000..a3232d6fc --- /dev/null +++ b/tests/ui/tuple/nested-index.rs @@ -0,0 +1,12 @@ +// run-pass + +fn main () { + let n = (1, (2, 3)).1.1; + assert_eq!(n, 3); + + let n = (1, (2, (3, 4))).1.1.1; + assert_eq!(n, 4); + + // This is a range expression, not nested indexing. + let _ = 0.0..1.1; +} diff --git a/tests/ui/tuple/one-tuple.rs b/tests/ui/tuple/one-tuple.rs new file mode 100644 index 000000000..00fbadce1 --- /dev/null +++ b/tests/ui/tuple/one-tuple.rs @@ -0,0 +1,15 @@ +// run-pass +// Why one-tuples? Because macros. + + +pub fn main() { + match ('c',) { + (x,) => { + assert_eq!(x, 'c'); + } + } + // test the 1-tuple type too + let x: (char,) = ('d',); + let (y,) = x; + assert_eq!(y, 'd'); +} diff --git a/tests/ui/tuple/tup.rs b/tests/ui/tuple/tup.rs new file mode 100644 index 000000000..160477b0b --- /dev/null +++ b/tests/ui/tuple/tup.rs @@ -0,0 +1,21 @@ +// run-pass + +#![allow(non_camel_case_types)] + +type point = (isize, isize); + +fn f(p: point, x: isize, y: isize) { + let (a, b) = p; + assert_eq!(a, x); + assert_eq!(b, y); +} + +pub fn main() { + let p: point = (10, 20); + let (a, b) = p; + assert_eq!(a, 10); + assert_eq!(b, 20); + let p2: point = p; + f(p, 10, 20); + f(p2, 10, 20); +} diff --git a/tests/ui/tuple/tuple-arity-mismatch.rs b/tests/ui/tuple/tuple-arity-mismatch.rs new file mode 100644 index 000000000..f1e525c93 --- /dev/null +++ b/tests/ui/tuple/tuple-arity-mismatch.rs @@ -0,0 +1,17 @@ +// Issue #6155 + +fn first((value, _): (isize, f64)) -> isize { value } + +fn main() { + let y = first ((1,2.0,3)); + //~^ ERROR mismatched types + //~| expected tuple `(isize, f64)` + //~| found tuple `(isize, f64, {integer})` + //~| expected a tuple with 2 elements, found one with 3 elements + + let y = first ((1,)); + //~^ ERROR mismatched types + //~| expected tuple `(isize, f64)` + //~| found tuple `(isize,)` + //~| expected a tuple with 2 elements, found one with 1 element +} diff --git a/tests/ui/tuple/tuple-arity-mismatch.stderr b/tests/ui/tuple/tuple-arity-mismatch.stderr new file mode 100644 index 000000000..fff7be987 --- /dev/null +++ b/tests/ui/tuple/tuple-arity-mismatch.stderr @@ -0,0 +1,35 @@ +error[E0308]: mismatched types + --> $DIR/tuple-arity-mismatch.rs:6:20 + | +LL | let y = first ((1,2.0,3)); + | ----- ^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements + | | + | arguments to this function are incorrect + | + = note: expected tuple `(isize, f64)` + found tuple `(isize, f64, {integer})` +note: function defined here + --> $DIR/tuple-arity-mismatch.rs:3:4 + | +LL | fn first((value, _): (isize, f64)) -> isize { value } + | ^^^^^ ------------------------ + +error[E0308]: mismatched types + --> $DIR/tuple-arity-mismatch.rs:12:20 + | +LL | let y = first ((1,)); + | ----- ^^^^ expected a tuple with 2 elements, found one with 1 element + | | + | arguments to this function are incorrect + | + = note: expected tuple `(isize, f64)` + found tuple `(isize,)` +note: function defined here + --> $DIR/tuple-arity-mismatch.rs:3:4 + | +LL | fn first((value, _): (isize, f64)) -> isize { value } + | ^^^^^ ------------------------ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/tuple/tuple-index-fat-types.rs b/tests/ui/tuple/tuple-index-fat-types.rs new file mode 100644 index 000000000..5dda1ed97 --- /dev/null +++ b/tests/ui/tuple/tuple-index-fat-types.rs @@ -0,0 +1,13 @@ +// run-pass + +struct Foo<'a>(&'a [isize]); + +fn main() { + let x: &[isize] = &[1, 2, 3]; + let y = (x,); + assert_eq!(y.0, x); + + let x: &[isize] = &[1, 2, 3]; + let y = Foo(x); + assert_eq!(y.0, x); +} diff --git a/tests/ui/tuple/tuple-index-not-tuple.rs b/tests/ui/tuple/tuple-index-not-tuple.rs new file mode 100644 index 000000000..c478e1c67 --- /dev/null +++ b/tests/ui/tuple/tuple-index-not-tuple.rs @@ -0,0 +1,10 @@ +struct Point { x: isize, y: isize } +struct Empty; + +fn main() { + let origin = Point { x: 0, y: 0 }; + origin.0; + //~^ ERROR no field `0` on type `Point` + Empty.0; + //~^ ERROR no field `0` on type `Empty` +} diff --git a/tests/ui/tuple/tuple-index-not-tuple.stderr b/tests/ui/tuple/tuple-index-not-tuple.stderr new file mode 100644 index 000000000..a1bcdfaed --- /dev/null +++ b/tests/ui/tuple/tuple-index-not-tuple.stderr @@ -0,0 +1,15 @@ +error[E0609]: no field `0` on type `Point` + --> $DIR/tuple-index-not-tuple.rs:6:12 + | +LL | origin.0; + | ^ help: a field with a similar name exists: `x` + +error[E0609]: no field `0` on type `Empty` + --> $DIR/tuple-index-not-tuple.rs:8:11 + | +LL | Empty.0; + | ^ unknown field + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/tuple/tuple-index-out-of-bounds.rs b/tests/ui/tuple/tuple-index-out-of-bounds.rs new file mode 100644 index 000000000..c772c0daa --- /dev/null +++ b/tests/ui/tuple/tuple-index-out-of-bounds.rs @@ -0,0 +1,14 @@ +struct Point(i32, i32); + +fn main() { + let origin = Point(0, 0); + origin.0; + origin.1; + origin.2; + //~^ ERROR no field `2` on type `Point` + let tuple = (0, 0); + tuple.0; + tuple.1; + tuple.2; + //~^ ERROR no field `2` on type `({integer}, {integer})` +} diff --git a/tests/ui/tuple/tuple-index-out-of-bounds.stderr b/tests/ui/tuple/tuple-index-out-of-bounds.stderr new file mode 100644 index 000000000..7d7c5cd78 --- /dev/null +++ b/tests/ui/tuple/tuple-index-out-of-bounds.stderr @@ -0,0 +1,15 @@ +error[E0609]: no field `2` on type `Point` + --> $DIR/tuple-index-out-of-bounds.rs:7:12 + | +LL | origin.2; + | ^ help: a field with a similar name exists: `0` + +error[E0609]: no field `2` on type `({integer}, {integer})` + --> $DIR/tuple-index-out-of-bounds.rs:12:11 + | +LL | tuple.2; + | ^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/tuple/tuple-struct-fields/test.rs b/tests/ui/tuple/tuple-struct-fields/test.rs new file mode 100644 index 000000000..00677090d --- /dev/null +++ b/tests/ui/tuple/tuple-struct-fields/test.rs @@ -0,0 +1,9 @@ +mod foo { + type T = (); + struct S1(pub(in foo) (), pub(T), pub(crate) (), pub(((), T))); + struct S2(pub((foo)) ()); + //~^ ERROR expected one of `)` or `,`, found `(` + //~| ERROR cannot find type `foo` in this scope +} + +fn main() {} diff --git a/tests/ui/tuple/tuple-struct-fields/test.stderr b/tests/ui/tuple/tuple-struct-fields/test.stderr new file mode 100644 index 000000000..bfa0b32fd --- /dev/null +++ b/tests/ui/tuple/tuple-struct-fields/test.stderr @@ -0,0 +1,17 @@ +error: expected one of `)` or `,`, found `(` + --> $DIR/test.rs:4:26 + | +LL | struct S2(pub((foo)) ()); + | -^ expected one of `)` or `,` + | | + | help: missing `,` + +error[E0412]: cannot find type `foo` in this scope + --> $DIR/test.rs:4:20 + | +LL | struct S2(pub((foo)) ()); + | ^^^ not found in this scope + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/tuple/tuple-struct-fields/test2.rs b/tests/ui/tuple/tuple-struct-fields/test2.rs new file mode 100644 index 000000000..2b2a2c127 --- /dev/null +++ b/tests/ui/tuple/tuple-struct-fields/test2.rs @@ -0,0 +1,15 @@ +macro_rules! define_struct { + ($t:ty) => { + struct S1(pub $t); + struct S2(pub (in foo) ()); + struct S3(pub $t ()); + //~^ ERROR expected one of `)` or `,`, found `(` + } +} + +mod foo { + define_struct! { (foo) } //~ ERROR cannot find type `foo` in this scope + //~| ERROR cannot find type `foo` in this scope +} + +fn main() {} diff --git a/tests/ui/tuple/tuple-struct-fields/test2.stderr b/tests/ui/tuple/tuple-struct-fields/test2.stderr new file mode 100644 index 000000000..64a9ac135 --- /dev/null +++ b/tests/ui/tuple/tuple-struct-fields/test2.stderr @@ -0,0 +1,28 @@ +error: expected one of `)` or `,`, found `(` + --> $DIR/test2.rs:5:26 + | +LL | struct S3(pub $t ()); + | -^ expected one of `)` or `,` + | | + | help: missing `,` +... +LL | define_struct! { (foo) } + | ------------------------ in this macro invocation + | + = note: this error originates in the macro `define_struct` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0412]: cannot find type `foo` in this scope + --> $DIR/test2.rs:11:23 + | +LL | define_struct! { (foo) } + | ^^^ not found in this scope + +error[E0412]: cannot find type `foo` in this scope + --> $DIR/test2.rs:11:23 + | +LL | define_struct! { (foo) } + | ^^^ not found in this scope + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/tuple/tuple-struct-fields/test3.rs b/tests/ui/tuple/tuple-struct-fields/test3.rs new file mode 100644 index 000000000..98d19426e --- /dev/null +++ b/tests/ui/tuple/tuple-struct-fields/test3.rs @@ -0,0 +1,15 @@ +macro_rules! define_struct { + ($t:ty) => { + struct S1(pub($t)); + struct S2(pub (in foo) ()); + struct S3(pub($t) ()); + //~^ ERROR expected one of `)` or `,`, found `(` + } +} + +mod foo { + define_struct! { foo } //~ ERROR cannot find type `foo` in this scope + //~| ERROR cannot find type `foo` in this scope +} + +fn main() {} diff --git a/tests/ui/tuple/tuple-struct-fields/test3.stderr b/tests/ui/tuple/tuple-struct-fields/test3.stderr new file mode 100644 index 000000000..75262ed57 --- /dev/null +++ b/tests/ui/tuple/tuple-struct-fields/test3.stderr @@ -0,0 +1,28 @@ +error: expected one of `)` or `,`, found `(` + --> $DIR/test3.rs:5:27 + | +LL | struct S3(pub($t) ()); + | -^ expected one of `)` or `,` + | | + | help: missing `,` +... +LL | define_struct! { foo } + | ---------------------- in this macro invocation + | + = note: this error originates in the macro `define_struct` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0412]: cannot find type `foo` in this scope + --> $DIR/test3.rs:11:22 + | +LL | define_struct! { foo } + | ^^^ not found in this scope + +error[E0412]: cannot find type `foo` in this scope + --> $DIR/test3.rs:11:22 + | +LL | define_struct! { foo } + | ^^^ not found in this scope + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/tuple/wrong_argument_ice-2.rs b/tests/ui/tuple/wrong_argument_ice-2.rs new file mode 100644 index 000000000..e1c1d748f --- /dev/null +++ b/tests/ui/tuple/wrong_argument_ice-2.rs @@ -0,0 +1,17 @@ +fn test(t: (i32, i32)) {} + +struct Foo; + +impl Foo { + fn qux(&self) -> i32 { + 0 + } +} + +fn bar() { + let x = Foo; + test(x.qux(), x.qux()); + //~^ ERROR function takes 1 argument but 2 arguments were supplied +} + +fn main() {} diff --git a/tests/ui/tuple/wrong_argument_ice-2.stderr b/tests/ui/tuple/wrong_argument_ice-2.stderr new file mode 100644 index 000000000..412442092 --- /dev/null +++ b/tests/ui/tuple/wrong_argument_ice-2.stderr @@ -0,0 +1,19 @@ +error[E0061]: function takes 1 argument but 2 arguments were supplied + --> $DIR/wrong_argument_ice-2.rs:13:5 + | +LL | test(x.qux(), x.qux()); + | ^^^^ + | +note: function defined here + --> $DIR/wrong_argument_ice-2.rs:1:4 + | +LL | fn test(t: (i32, i32)) {} + | ^^^^ ------------- +help: wrap these arguments in parentheses to construct a tuple + | +LL | test((x.qux(), x.qux())); + | + + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/tuple/wrong_argument_ice-3.rs b/tests/ui/tuple/wrong_argument_ice-3.rs new file mode 100644 index 000000000..96633180b --- /dev/null +++ b/tests/ui/tuple/wrong_argument_ice-3.rs @@ -0,0 +1,17 @@ +struct Process; + +pub type Group = (Vec<String>, Vec<Process>); + +fn test(process: &Process, groups: Vec<Group>) -> Vec<Group> { + let new_group = vec![String::new()]; + + if groups.capacity() == 0 { + groups.push(new_group, vec![process]); + //~^ ERROR this method takes 1 argument but 2 arguments were supplied + return groups; + } + + todo!() +} + +fn main() {} diff --git a/tests/ui/tuple/wrong_argument_ice-3.stderr b/tests/ui/tuple/wrong_argument_ice-3.stderr new file mode 100644 index 000000000..0a503e1fe --- /dev/null +++ b/tests/ui/tuple/wrong_argument_ice-3.stderr @@ -0,0 +1,23 @@ +error[E0061]: this method takes 1 argument but 2 arguments were supplied + --> $DIR/wrong_argument_ice-3.rs:9:16 + | +LL | groups.push(new_group, vec![process]); + | ^^^^ ------------- argument of type `Vec<&Process>` unexpected + | +note: expected tuple, found struct `Vec` + --> $DIR/wrong_argument_ice-3.rs:9:21 + | +LL | groups.push(new_group, vec![process]); + | ^^^^^^^^^ + = note: expected tuple `(Vec<String>, Vec<Process>)` + found struct `Vec<String>` +note: associated function defined here + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL +help: remove the extra argument + | +LL | groups.push(/* (Vec<String>, Vec<Process>) */); + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/tuple/wrong_argument_ice-4.rs b/tests/ui/tuple/wrong_argument_ice-4.rs new file mode 100644 index 000000000..883d92dcc --- /dev/null +++ b/tests/ui/tuple/wrong_argument_ice-4.rs @@ -0,0 +1,6 @@ +fn main() { + (|| {})(|| { + //~^ ERROR function takes 0 arguments but 1 argument was supplied + let b = 1; + }); +} diff --git a/tests/ui/tuple/wrong_argument_ice-4.stderr b/tests/ui/tuple/wrong_argument_ice-4.stderr new file mode 100644 index 000000000..a2686ab94 --- /dev/null +++ b/tests/ui/tuple/wrong_argument_ice-4.stderr @@ -0,0 +1,23 @@ +error[E0057]: this function takes 0 arguments but 1 argument was supplied + --> $DIR/wrong_argument_ice-4.rs:2:5 + | +LL | (|| {})(|| { + | _____^^^^^^^_- +LL | | +LL | | let b = 1; +LL | | }); + | |_____- argument of type `[closure@$DIR/wrong_argument_ice-4.rs:2:13: 2:15]` unexpected + | +note: closure defined here + --> $DIR/wrong_argument_ice-4.rs:2:6 + | +LL | (|| {})(|| { + | ^^ +help: remove the extra argument + | +LL | (|| {})(); + | ~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0057`. diff --git a/tests/ui/tuple/wrong_argument_ice.rs b/tests/ui/tuple/wrong_argument_ice.rs new file mode 100644 index 000000000..b7e0225fe --- /dev/null +++ b/tests/ui/tuple/wrong_argument_ice.rs @@ -0,0 +1,17 @@ +use std::collections::VecDeque; + +pub struct BuildPlanBuilder { + acc: VecDeque<(String, String)>, + current_provides: String, + current_requires: String, +} + +impl BuildPlanBuilder { + pub fn or(&mut self) -> &mut Self { + self.acc.push_back(self.current_provides, self.current_requires); + //~^ ERROR method takes 1 argument but 2 arguments were supplied + self + } +} + +fn main() {} diff --git a/tests/ui/tuple/wrong_argument_ice.stderr b/tests/ui/tuple/wrong_argument_ice.stderr new file mode 100644 index 000000000..f1b00ae0b --- /dev/null +++ b/tests/ui/tuple/wrong_argument_ice.stderr @@ -0,0 +1,16 @@ +error[E0061]: method takes 1 argument but 2 arguments were supplied + --> $DIR/wrong_argument_ice.rs:11:18 + | +LL | self.acc.push_back(self.current_provides, self.current_requires); + | ^^^^^^^^^ + | +note: associated function defined here + --> $SRC_DIR/alloc/src/collections/vec_deque/mod.rs:LL:COL +help: wrap these arguments in parentheses to construct a tuple + | +LL | self.acc.push_back((self.current_provides, self.current_requires)); + | + + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0061`. |