You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry this is a vague bug report and a crap example, it comes from trans_struct in expr.rs, the following fails:
let mut need_base: Vec<_> = repeat(true).take(field_tys.len()).collect();
let numbered_fields = fields.iter().map(|field| {
let opt_pos =
field_tys.iter().position(|field_ty|
field_ty.name == field.ident.node.name);
let result = match opt_pos {
Some(i) => {
need_base[i] = false;
(i, &*field.expr)
}
None => {
tcx.sess.span_bug(field.span,
"Couldn't find field in struct type")
}
};
result
}).collect::<Vec<_>>();
Changing Vec<_> to Vec<bool> makes it compile.
The error message is unable to infer enough type information about "closure[/home/ncameron/rust3/src/librustc_trans/trans/expr.rs:1390:74: 1405:10]; type annotations required".
The reason I think this is a bug and not just annoying is that it is so obvious that the parameter is bool.
fnfoo<F:FnMut(&[u8])>(mutf:F){f(b"hello ");f(b"world!");}fnmain(){letmut v = Vec::new();// error: unable to infer enough type information about `closure[...]`; type annotations requiredfoo(|buf| v.extend(buf.iter().cloned()));println!("{:?}", v);}
At least we need a good error message here. It says "type annotations required", but doesn't say which ones (and confusingly enough, variables above that closure have to be annotated).
Sorry this is a vague bug report and a crap example, it comes from
trans_struct
in expr.rs, the following fails:Changing
Vec<_>
toVec<bool>
makes it compile.The error message is
unable to infer enough type information about "closure[/home/ncameron/rust3/src/librustc_trans/trans/expr.rs:1390:74: 1405:10]
; type annotations required".The reason I think this is a bug and not just annoying is that it is so obvious that the parameter is
bool
.cc @nikomatsakis
The text was updated successfully, but these errors were encountered: