-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unboxed closures: Type inferencer failed to detect closure argument types #17907
Comments
cc me. I think that we may be able to make this inference work more uniformly using the new trait infrastructure. In principle, trying to match the |
cc @pcwalton |
I was recently running into a similar issue and chalked it up to what I was working on. cc me. |
Another case, I am unsure if it is related or not, but I had code that was working, wrapped the FnOnce argument w/ Option and the type inferencer could not figure it out. #![feature(unboxed_closures)]
#![feature(overloaded_calls)]
fn action<T, F: FnOnce(Option<T>)>(val: T, cb: F) {
cb(Some(val));
}
pub fn main() {
let (tx, rx) = channel::<&'static str>();
// Required for compiling vv
action("zomg", |:v: /* Option<&'static str> */| tx.send(v.unwrap()));
assert_eq!(rx.recv(), "zomg");
println!("Done");
} |
An almost minimal test: #![feature(unboxed_closures)]
fn doit<T, F: Fn(T)>(val: T, f: F) { f.call((val,)); }
fn doit_boxed<T>(val: T, f: |T|) { f(val); }
pub fn main() {
doit_boxed(0i, |x| { x.to_int(); });
doit(0i, |&: x/*: int*/| { x.to_int(); });
} error:
Seems related to the method syntax (and thus maybe AutoDeref). |
Tackling this next. |
You can also see tests in https://github.com/TeXitoi/rust-mdo/tree/unboxed-closure |
Oh nice, I didn't realize you had an unboxed closures version. The macro I used was based on yours of course (mentioned in the README). |
I think this was fixed by PR #19089, at least for the most part. Open if you disagree. |
internal: Replace once_cell with std's recently stabilized OnceCell/Lock and LazyCell/Lock This doesn't get rid of the once_cell dependency, unfortunately, since we have dependencies that use it, but it's a nice to do cleanup. And when our deps will eventually get rid of once_cell we will get rid of it for free.
Output:
The text was updated successfully, but these errors were encountered: