mirror of https://github.com/rust-lang/rust.git
Test 1-tuple parentheses wrapping
This commit is contained in:
parent
91a43f0423
commit
72d3b45af0
|
@ -10,6 +10,12 @@ fn main() {
|
|||
|
||||
let _: Option<(i8,)> = Some();
|
||||
//~^ ERROR this enum variant takes 1 argument but 0 arguments were supplied
|
||||
|
||||
let _: Option<(i32,)> = Some(5_usize);
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
let _: Option<(i32,)> = Some((5_usize));
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn int_bool(_: (i32, bool)) {
|
||||
|
|
|
@ -15,7 +15,7 @@ LL | int_bool(1, 2);
|
|||
| expected 1 argument
|
||||
|
|
||||
note: function defined here
|
||||
--> $DIR/args-instead-of-tuple-errors.rs:15:4
|
||||
--> $DIR/args-instead-of-tuple-errors.rs:21:4
|
||||
|
|
||||
LL | fn int_bool(_: (i32, bool)) {
|
||||
| ^^^^^^^^ --------------
|
||||
|
@ -28,6 +28,25 @@ LL | let _: Option<(i8,)> = Some();
|
|||
| |
|
||||
| expected 1 argument
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/args-instead-of-tuple-errors.rs:14:34
|
||||
|
|
||||
LL | let _: Option<(i32,)> = Some(5_usize);
|
||||
| ^^^^^^^ expected tuple, found `usize`
|
||||
|
|
||||
= note: expected tuple `(i32,)`
|
||||
found type `usize`
|
||||
|
||||
For more information about this error, try `rustc --explain E0061`.
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/args-instead-of-tuple-errors.rs:17:34
|
||||
|
|
||||
LL | let _: Option<(i32,)> = Some((5_usize));
|
||||
| ^^^^^^^^^ expected tuple, found `usize`
|
||||
|
|
||||
= note: expected tuple `(i32,)`
|
||||
found type `usize`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0061, E0308.
|
||||
For more information about an error, try `rustc --explain E0061`.
|
||||
|
|
|
@ -11,6 +11,12 @@ fn main() {
|
|||
let _: Option<()> = Some(());
|
||||
//~^ ERROR this enum variant takes 1 argument but 0 arguments were supplied
|
||||
|
||||
let _: Option<(i32,)> = Some((3,));
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
let _: Option<(i32,)> = Some((3,));
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
two_ints((1, 2)); //~ ERROR this function takes 1 argument
|
||||
|
||||
with_generic((3, 4)); //~ ERROR this function takes 1 argument
|
||||
|
|
|
@ -11,6 +11,12 @@ fn main() {
|
|||
let _: Option<()> = Some();
|
||||
//~^ ERROR this enum variant takes 1 argument but 0 arguments were supplied
|
||||
|
||||
let _: Option<(i32,)> = Some(3);
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
let _: Option<(i32,)> = Some((3));
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
two_ints(1, 2); //~ ERROR this function takes 1 argument
|
||||
|
||||
with_generic(3, 4); //~ ERROR this function takes 1 argument
|
||||
|
|
|
@ -31,14 +31,40 @@ help: expected the unit value `()`; create it with empty parentheses
|
|||
LL | let _: Option<()> = Some(());
|
||||
| ++
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/args-instead-of-tuple.rs:14:34
|
||||
|
|
||||
LL | let _: Option<(i32,)> = Some(3);
|
||||
| ^ expected tuple, found integer
|
||||
|
|
||||
= note: expected tuple `(i32,)`
|
||||
found type `{integer}`
|
||||
help: use a trailing comma to create a tuple with one element
|
||||
|
|
||||
LL | let _: Option<(i32,)> = Some((3,));
|
||||
| + ++
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/args-instead-of-tuple.rs:17:34
|
||||
|
|
||||
LL | let _: Option<(i32,)> = Some((3));
|
||||
| ^^^ expected tuple, found integer
|
||||
|
|
||||
= note: expected tuple `(i32,)`
|
||||
found type `{integer}`
|
||||
help: use a trailing comma to create a tuple with one element
|
||||
|
|
||||
LL | let _: Option<(i32,)> = Some((3,));
|
||||
| +
|
||||
|
||||
error[E0061]: this function takes 1 argument but 2 arguments were supplied
|
||||
--> $DIR/args-instead-of-tuple.rs:14:5
|
||||
--> $DIR/args-instead-of-tuple.rs:20:5
|
||||
|
|
||||
LL | two_ints(1, 2);
|
||||
| ^^^^^^^^ - - supplied 2 arguments
|
||||
|
|
||||
note: function defined here
|
||||
--> $DIR/args-instead-of-tuple.rs:19:4
|
||||
--> $DIR/args-instead-of-tuple.rs:25:4
|
||||
|
|
||||
LL | fn two_ints(_: (i32, i32)) {
|
||||
| ^^^^^^^^ -------------
|
||||
|
@ -48,13 +74,13 @@ LL | two_ints((1, 2));
|
|||
| + +
|
||||
|
||||
error[E0061]: this function takes 1 argument but 2 arguments were supplied
|
||||
--> $DIR/args-instead-of-tuple.rs:16:5
|
||||
--> $DIR/args-instead-of-tuple.rs:22:5
|
||||
|
|
||||
LL | with_generic(3, 4);
|
||||
| ^^^^^^^^^^^^ - - supplied 2 arguments
|
||||
|
|
||||
note: function defined here
|
||||
--> $DIR/args-instead-of-tuple.rs:22:4
|
||||
--> $DIR/args-instead-of-tuple.rs:28:4
|
||||
|
|
||||
LL | fn with_generic<T: Copy + Send>((a, b): (i32, T)) {
|
||||
| ^^^^^^^^^^^^ ----------------
|
||||
|
@ -64,13 +90,13 @@ LL | with_generic((3, 4));
|
|||
| + +
|
||||
|
||||
error[E0061]: this function takes 1 argument but 2 arguments were supplied
|
||||
--> $DIR/args-instead-of-tuple.rs:25:9
|
||||
--> $DIR/args-instead-of-tuple.rs:31:9
|
||||
|
|
||||
LL | with_generic(a, b);
|
||||
| ^^^^^^^^^^^^ - - supplied 2 arguments
|
||||
|
|
||||
note: function defined here
|
||||
--> $DIR/args-instead-of-tuple.rs:22:4
|
||||
--> $DIR/args-instead-of-tuple.rs:28:4
|
||||
|
|
||||
LL | fn with_generic<T: Copy + Send>((a, b): (i32, T)) {
|
||||
| ^^^^^^^^^^^^ ----------------
|
||||
|
@ -79,6 +105,7 @@ help: use parentheses to construct a tuple
|
|||
LL | with_generic((a, b));
|
||||
| + +
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0061`.
|
||||
Some errors have detailed explanations: E0061, E0308.
|
||||
For more information about an error, try `rustc --explain E0061`.
|
||||
|
|
|
@ -11,7 +11,7 @@ LL | let _x: (i32,) = (5);
|
|||
help: use a trailing comma to create a tuple with one element
|
||||
|
|
||||
LL | let _x: (i32,) = (5,);
|
||||
| ~~~~
|
||||
| +
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-86100-tuple-paren-comma.rs:13:9
|
||||
|
@ -24,7 +24,7 @@ LL | foo((Some(3)));
|
|||
help: use a trailing comma to create a tuple with one element
|
||||
|
|
||||
LL | foo((Some(3),));
|
||||
| ~~~~~~~~~~
|
||||
| +
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-86100-tuple-paren-comma.rs:17:22
|
||||
|
@ -37,7 +37,7 @@ LL | let _s = S { _s: ("abc".to_string()) };
|
|||
help: use a trailing comma to create a tuple with one element
|
||||
|
|
||||
LL | let _s = S { _s: ("abc".to_string(),) };
|
||||
| ~~~~~~~~~~~~~~~~~~~~
|
||||
| +
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-86100-tuple-paren-comma.rs:23:22
|
||||
|
|
Loading…
Reference in New Issue