I get this error
src/main.rs:11:38: 11:42 error: expected type, found keyword `impl`
src/main.rs:11 fn long_running_future(a: u32) -> impl Future<Item = u32, Error = ()> { futures::done(Ok(a)) }
^~~~
while trying to format the following bit of code that compiles and runs just fine
#![feature(conservative_impl_trait)]
extern crate futures;
extern crate futures_cpupool;
use std::sync::mpsc::channel;
use futures::Future;
use futures_cpupool::CpuPool;
fn long_running_future(a: u32) -> impl Future<Item = u32, Error = ()> { futures::done(Ok(a)) }
fn main() {
// Create a worker thread pool with four threads
let pool = CpuPool::new(4);
// Execute some work on the thread pool, optionally closing over data.
let a = pool.spawn(long_running_future(2));
let b = pool.spawn(long_running_future(100));
// Express some further computation once the work is completed on the thread
// pool.
let c = a.join(b).map(|(a, b)| a + b).wait().unwrap();
// Print out the result
println!("{:?}", c);
}
see also #1145
Someone with knowledge of all the changes in syntex_syntax (this project is now ten version behind) needs to do the upgrade - I attempted it but its non-trivial
I have a branch with the Syntex update almost ready, once that lands, this should be easy to fix.
A fast fix:
file src/types.rs
change :
ast::TyKind::ImplTrait(..) => Some(String::from("impl TODO")),
to:
ast::TyKind::ImplTrait(ref it) => it.rewrite(context, width, offset).map(|it_str| format!("impl {}", it_str)),
Is this available in a release? I see that play no longer messes up impl trait, but I know that I recently updated and still saw this behavior.
@nikomatsakis it should be in the release I did at the weekend (0.6.3, iirc).
@nikomatsakis Has this resurfaced? I'm seeing -> impl Future<> converted into impl TODO in the latest nightly.
@wagerlabs I can't reproduce that, I'm getting impl Future just fine
@nrc What's your rustfmt version? I'm getting this behavior with 0.6.2.
Upgrading to 0.9 via cargo install rustfmt --force fixes this.
0.6 is pretty old. I'm using master, which is nightly-0.1.4
@nrc How do you keep rustfmt in sync with nightly builds? Do you cargo install rustfmt-nightly --force periodically?
@wagerlabs I think you have to, yes. (I actually build from source pretty much every day, so I'm not a good person to ask about this)
Most helpful comment
I have a branch with the Syntex update almost ready, once that lands, this should be easy to fix.