Handle generics with ParamEnv
This commit is contained in:
parent
54d2d30662
commit
a129a85144
@ -18,7 +18,7 @@ use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{ExprKind, Node, QPath};
|
||||
use rustc_middle::ty::adjustment::AllowTwoPhase;
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::{self, ParamEnv, Ty};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::{self, MultiSpan, Span};
|
||||
@ -514,7 +514,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let supplied_types: Vec<_> = provided_args.iter().map(|arg| self.check_expr(arg)).collect();
|
||||
|
||||
let all_match = iter::zip(expected_types, supplied_types)
|
||||
.all(|(expected, supplied)| self.can_eq(ParamEnv::empty(), expected, supplied).is_ok());
|
||||
.all(|(expected, supplied)| self.can_eq(self.param_env, expected, supplied).is_ok());
|
||||
|
||||
if all_match {
|
||||
match provided_args {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user