Skip to content

Commit 13801f6

Browse files
committed
rustc: Be careful about calls to fn types that contain nested errors
1 parent d716398 commit 13801f6

File tree

1 file changed

+17
-16
lines changed
  • src/librustc/middle/typeck/check

1 file changed

+17
-16
lines changed

src/librustc/middle/typeck/check/mod.rs

+17-16
Original file line numberDiff line numberDiff line change
@@ -1135,22 +1135,23 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
11351135
sugar: ast::CallSugar,
11361136
deref_args: DerefArgs) -> ty::t
11371137
{
1138-
match ty::get(method_fn_ty).sty {
1139-
ty::ty_bare_fn(ref fty) => {
1140-
check_argument_types(fcx, sp, fty.sig.inputs, callee_expr,
1141-
args, sugar, deref_args);
1142-
fty.sig.output
1143-
}
1144-
ty::ty_err => {
1145-
let err_inputs = err_args(fcx.tcx(), args.len());
1146-
check_argument_types(fcx, sp, err_inputs, callee_expr,
1147-
args, sugar, deref_args);
1148-
method_fn_ty
1149-
}
1150-
_ => {
1151-
fcx.tcx().sess.span_bug(
1152-
sp,
1153-
fmt!("Method without bare fn type"));
1138+
if ty::type_is_error(method_fn_ty) {
1139+
let err_inputs = err_args(fcx.tcx(), args.len());
1140+
check_argument_types(fcx, sp, err_inputs, callee_expr,
1141+
args, sugar, deref_args);
1142+
method_fn_ty
1143+
} else {
1144+
match ty::get(method_fn_ty).sty {
1145+
ty::ty_bare_fn(ref fty) => {
1146+
check_argument_types(fcx, sp, fty.sig.inputs, callee_expr,
1147+
args, sugar, deref_args);
1148+
fty.sig.output
1149+
}
1150+
_ => {
1151+
fcx.tcx().sess.span_bug(
1152+
sp,
1153+
fmt!("Method without bare fn type"));
1154+
}
11541155
}
11551156
}
11561157
}

0 commit comments

Comments
 (0)