Handle generics with ParamEnv

This commit is contained in:
Rob Pilling 2022-01-16 21:47:44 +00:00
parent 54d2d30662
commit a129a85144
4 changed files with 54 additions and 4 deletions

View file

@ -12,7 +12,16 @@ fn main() {
//~^ ERROR this enum variant takes 1 argument but 0 arguments were supplied
two_ints((1, 2)); //~ ERROR this function takes 1 argument
with_generic((3, 4)); //~ ERROR this function takes 1 argument
}
fn two_ints(_: (i32, i32)) {
}
fn with_generic<T: Copy + Send>((a, b): (i32, T)) {
if false {
// test generics/bound handling
with_generic((a, b)); //~ ERROR this function takes 1 argument
}
}

View file

@ -12,7 +12,16 @@ fn main() {
//~^ ERROR this enum variant takes 1 argument but 0 arguments were supplied
two_ints(1, 2); //~ ERROR this function takes 1 argument
with_generic(3, 4); //~ ERROR this function takes 1 argument
}
fn two_ints(_: (i32, i32)) {
}
fn with_generic<T: Copy + Send>((a, b): (i32, T)) {
if false {
// test generics/bound handling
with_generic(a, b); //~ ERROR this function takes 1 argument
}
}

View file

@ -38,7 +38,7 @@ LL | two_ints(1, 2);
| ^^^^^^^^ - - supplied 2 arguments
|
note: function defined here
--> $DIR/args-instead-of-tuple.rs:17:4
--> $DIR/args-instead-of-tuple.rs:19:4
|
LL | fn two_ints(_: (i32, i32)) {
| ^^^^^^^^ -------------
@ -47,6 +47,38 @@ help: use parentheses to construct a tuple
LL | two_ints((1, 2));
| + +
error: aborting due to 4 previous errors
error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/args-instead-of-tuple.rs:16:5
|
LL | with_generic(3, 4);
| ^^^^^^^^^^^^ - - supplied 2 arguments
|
note: function defined here
--> $DIR/args-instead-of-tuple.rs:22:4
|
LL | fn with_generic<T: Copy + Send>((a, b): (i32, T)) {
| ^^^^^^^^^^^^ ----------------
help: use parentheses to construct a tuple
|
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
|
LL | with_generic(a, b);
| ^^^^^^^^^^^^ - - supplied 2 arguments
|
note: function defined here
--> $DIR/args-instead-of-tuple.rs:22:4
|
LL | fn with_generic<T: Copy + Send>((a, b): (i32, T)) {
| ^^^^^^^^^^^^ ----------------
help: use parentheses to construct a tuple
|
LL | with_generic((a, b));
| + +
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0061`.