Skip to content

Commit

Permalink
rustc: Be careful about calls to fn types that contain nested errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Apr 5, 2013
1 parent d716398 commit 13801f6
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,22 +1135,23 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
sugar: ast::CallSugar,
deref_args: DerefArgs) -> ty::t
{
match ty::get(method_fn_ty).sty {
ty::ty_bare_fn(ref fty) => {
check_argument_types(fcx, sp, fty.sig.inputs, callee_expr,
args, sugar, deref_args);
fty.sig.output
}
ty::ty_err => {
let err_inputs = err_args(fcx.tcx(), args.len());
check_argument_types(fcx, sp, err_inputs, callee_expr,
args, sugar, deref_args);
method_fn_ty
}
_ => {
fcx.tcx().sess.span_bug(
sp,
fmt!("Method without bare fn type"));
if ty::type_is_error(method_fn_ty) {
let err_inputs = err_args(fcx.tcx(), args.len());
check_argument_types(fcx, sp, err_inputs, callee_expr,
args, sugar, deref_args);
method_fn_ty
} else {
match ty::get(method_fn_ty).sty {
ty::ty_bare_fn(ref fty) => {
check_argument_types(fcx, sp, fty.sig.inputs, callee_expr,
args, sugar, deref_args);
fty.sig.output
}
_ => {
fcx.tcx().sess.span_bug(
sp,
fmt!("Method without bare fn type"));
}
}
}
}
Expand Down

5 comments on commit 13801f6

@bors
Copy link
Contributor

@bors bors commented on 13801f6 Apr 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from nikomatsakis
at nikomatsakis@13801f6

@bors
Copy link
Contributor

@bors bors commented on 13801f6 Apr 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nikomatsakis/rust/issue-4183-trait_ref = 13801f6 into auto

@bors
Copy link
Contributor

@bors bors commented on 13801f6 Apr 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nikomatsakis/rust/issue-4183-trait_ref = 13801f6 merged ok, testing candidate = 08e2cf8

@bors
Copy link
Contributor

@bors bors commented on 13801f6 Apr 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 13801f6 Apr 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = 08e2cf8

Please sign in to comment.