-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-type-systemArea: Type systemArea: Type system
Description
fn foo<T>(mut f: T) where T: FnMut() {
f();
}
#[cfg(error)]
fn bar() {
let n = 42;
foo(|| { println!("{}", n); });
}
#[cfg(not(error))]
fn bar() {
let n: i32 = 42;
foo(|| { println!("{}", n); });
}
fn main() {
bar();
}This yields the following error:
% rustc infer_int.rs --cfg error
infer_int.rs:8:5: 8:8 error: unable to infer enough type information about `closure[infer_int.rs:8:9: 8:34]`; type annotations required
infer_int.rs:8 foo(|| { println!("{}", n); });
^~~
error: aborting due to previous error
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-type-systemArea: Type systemArea: Type system