mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Emit a sensible error message if one or more of the parameters isn't enough context to instantiate a polymorphic function
This commit is contained in:
parent
b3c4c1426a
commit
679dca8541
@ -673,14 +673,19 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
|||||||
in
|
in
|
||||||
let arg_ty_opts = Array.map (fun ty -> Some ty) arg_tys in
|
let arg_ty_opts = Array.map (fun ty -> Some ty) arg_tys in
|
||||||
ignore (demand_fn ~param_handler:param_handler arg_ty_opts ty);
|
ignore (demand_fn ~param_handler:param_handler arg_ty_opts ty);
|
||||||
let get_subst subst_opt =
|
let get_subst i subst_opt =
|
||||||
match subst_opt with
|
match subst_opt with
|
||||||
Some subst -> subst
|
Some subst -> subst
|
||||||
| None ->
|
| None ->
|
||||||
Common.bug ()
|
Common.err
|
||||||
"internal_check_outer_lval: subst not found"
|
None
|
||||||
|
"not enough context to instantiate parameter %d of the \
|
||||||
|
function with type '%a'; please supply type parameters \
|
||||||
|
explicitly"
|
||||||
|
(i + 1)
|
||||||
|
sprintf_ltype lty
|
||||||
in
|
in
|
||||||
let substs = Array.map get_subst substs in
|
let substs = Array.mapi get_subst substs in
|
||||||
begin
|
begin
|
||||||
match beta_reduce (Semant.lval_base_id lval) lty substs with
|
match beta_reduce (Semant.lval_base_id lval) lty substs with
|
||||||
LTYPE_mono ty -> yield_ty ty
|
LTYPE_mono ty -> yield_ty ty
|
||||||
|
Loading…
Reference in New Issue
Block a user