diff --git a/futures-macro-async/Cargo.toml b/futures-macro-async/Cargo.toml index 41f4ae18a8..996c0ae2af 100644 --- a/futures-macro-async/Cargo.toml +++ b/futures-macro-async/Cargo.toml @@ -13,12 +13,12 @@ few other assorted macros. proc-macro = true [dependencies] -quote = "0.4" -proc-macro2 = "0.2" +quote = "0.5" +proc-macro2 = "0.3" [dependencies.syn] -version = "0.12.13" -features = ["full", "fold", "parsing", "printing", "extra-traits"] +version = "0.13" +features = ["full", "fold", "parsing", "printing", "extra-traits", "proc-macro"] default-features = false [features] diff --git a/futures-macro-async/src/elision.rs b/futures-macro-async/src/elision.rs index 488a098e75..5d45cdc08b 100644 --- a/futures-macro-async/src/elision.rs +++ b/futures-macro-async/src/elision.rs @@ -1,4 +1,4 @@ -use proc_macro2::{Term, Span}; +use proc_macro2::Span; use syn::*; use syn::punctuated::Punctuated; use syn::token::Comma; @@ -34,7 +34,7 @@ impl<'a> UnelideLifetimes<'a> { // Constitute a new lifetime fn new_lifetime(&mut self) -> Lifetime { let lifetime_name = format!("{}{}", self.lifetime_name, self.count); - let lifetime = Lifetime::new(Term::intern(&lifetime_name), Span::call_site()); + let lifetime = Lifetime::new(&lifetime_name, Span::call_site()); let idx = self.lifetime_index + self.count as usize; self.generics.insert(idx, GenericParam::Lifetime(LifetimeDef::new(lifetime.clone()))); diff --git a/futures-macro-async/src/lib.rs b/futures-macro-async/src/lib.rs index 8354e802ea..09876f2b2b 100644 --- a/futures-macro-async/src/lib.rs +++ b/futures-macro-async/src/lib.rs @@ -29,7 +29,7 @@ if_nightly! { extern crate syn; use proc_macro2::Span; - use proc_macro::{TokenStream, TokenTree, Delimiter, TokenNode}; + use proc_macro::{Delimiter, Group, TokenStream, TokenTree}; use quote::{Tokens, ToTokens}; use syn::*; use syn::punctuated::Punctuated; @@ -444,10 +444,7 @@ if_nightly! { #[proc_macro] pub fn async_block(input: TokenStream) -> TokenStream { - let input = TokenStream::from(TokenTree { - kind: TokenNode::Group(Delimiter::Brace, input), - span: proc_macro::Span::def_site(), - }); + let input = TokenStream::from(TokenTree::Group(Group::new(Delimiter::Brace, input))); let expr = syn::parse(input) .expect("failed to parse tokens as an expression"); let expr = ExpandAsyncFor.fold_expr(expr); @@ -475,10 +472,7 @@ if_nightly! { #[proc_macro] pub fn async_stream_block(input: TokenStream) -> TokenStream { - let input = TokenStream::from(TokenTree { - kind: TokenNode::Group(Delimiter::Brace, input), - span: proc_macro::Span::def_site(), - }); + let input = TokenStream::from(TokenTree::Group(Group::new(Delimiter::Brace, input))); let expr = syn::parse(input) .expect("failed to parse tokens as an expression"); let expr = ExpandAsyncFor.fold_expr(expr); @@ -573,8 +567,8 @@ if_nightly! { let mut spans = Tokens::new(); tokens.to_tokens(&mut spans); let good_tokens = proc_macro2::TokenStream::from(spans).into_iter().collect::>(); - let first_span = good_tokens.first().map(|t| t.span).unwrap_or(Span::def_site()); - let last_span = good_tokens.last().map(|t| t.span).unwrap_or(first_span); + let first_span = good_tokens.first().map(|t| t.span()).unwrap_or(Span::call_site()); + let last_span = good_tokens.last().map(|t| t.span()).unwrap_or(first_span); (first_span, last_span) } @@ -582,10 +576,10 @@ if_nightly! { &(first_span, last_span): &(Span, Span)) -> proc_macro2::TokenStream { let mut new_tokens = input.into_iter().collect::>(); if let Some(token) = new_tokens.first_mut() { - token.span = first_span; + token.set_span(first_span); } for token in new_tokens.iter_mut().skip(1) { - token.span = last_span; + token.set_span(last_span); } new_tokens.into_iter().collect() } @@ -595,8 +589,8 @@ if_nightly! { { let mut new_tokens = Tokens::new(); for token in input.into_iter() { - match token.kind { - proc_macro2::TokenNode::Op('!', _) => tokens.to_tokens(&mut new_tokens), + match token { + proc_macro2::TokenTree::Op(op) if op.op() == '!' => tokens.to_tokens(&mut new_tokens), _ => token.to_tokens(&mut new_tokens), } } @@ -609,8 +603,8 @@ if_nightly! { let mut replacements = replacements.iter().cycle(); let mut new_tokens = Tokens::new(); for token in input.into_iter() { - match token.kind { - proc_macro2::TokenNode::Op('!', _) => { + match token { + proc_macro2::TokenTree::Op(op) if op.op() == '!' => { replacements.next().unwrap().to_tokens(&mut new_tokens); } _ => token.to_tokens(&mut new_tokens), diff --git a/futures/Cargo.toml b/futures/Cargo.toml index f7d792350c..2d6060187b 100644 --- a/futures/Cargo.toml +++ b/futures/Cargo.toml @@ -19,7 +19,7 @@ travis-ci = { repository = "rust-lang-nursery/futures-rs" } appveyor = { repository = "rust-lang-nursery/futures-rs" } [dependencies] -# futures-async-runtime = { path = "../futures-async-runtime", version = "0.2.0", default-features = false } +futures-async-runtime = { path = "../futures-async-runtime", version = "0.2.0", default-features = false } futures-core = { path = "../futures-core", version = "0.2.0", default-features = false } futures-channel = { path = "../futures-channel", version = "0.2.0", default-features = false } futures-executor = { path = "../futures-executor", version = "0.2.0", default-features = false } @@ -27,16 +27,10 @@ futures-io = { path = "../futures-io", version = "0.2.0", default-features = fal futures-sink = { path = "../futures-sink", version = "0.2.0", default-features = false } futures-stable = { path = "../futures-stable", version = "0.2.0", default-features = false } futures-util = { path = "../futures-util", version = "0.2.0", default-features = false } -# futures-macro-async = { path = "../futures-macro-async", version = "0.2.0", optional = true } -# futures-macro-await = { path = "../futures-macro-await", version = "0.2.0", optional = true } +futures-macro-async = { path = "../futures-macro-async", version = "0.2.0", optional = true } +futures-macro-await = { path = "../futures-macro-await", version = "0.2.0", optional = true } [features] -nightly = ["futures-core/nightly", "futures-stable/nightly"] -std = ["futures-core/std", "futures-executor/std", "futures-io/std", "futures-sink/std", "futures-stable/std", "futures-util/std"] +nightly = ["futures-core/nightly", "futures-stable/nightly", "futures-async-runtime/nightly", "futures-macro-async", "futures-macro-await", "futures-macro-async/nightly"] +std = ["futures-core/std", "futures-executor/std", "futures-io/std", "futures-sink/std", "futures-stable/std", "futures-util/std", "futures-async-runtime/std"] default = ["std"] - -# TODO(cramertj) reenable on nightly -# , "futures-async-runtime/nightly", "futures-macro-async", "futures-macro-await", "futures-macro-async/nightly" - -# TODO(cramertj) reenable on std -# "futures-async-runtime/std" diff --git a/futures/src/lib.rs b/futures/src/lib.rs index b78e14ca9d..4e9e3e9ef2 100644 --- a/futures/src/lib.rs +++ b/futures/src/lib.rs @@ -25,7 +25,7 @@ #![cfg_attr(feature = "nightly", feature(cfg_target_has_atomic))] #![cfg_attr(feature = "nightly", feature(use_extern_macros))] -// extern crate futures_async_runtime; +extern crate futures_async_runtime; extern crate futures_core; extern crate futures_channel; extern crate futures_executor; @@ -34,9 +34,8 @@ extern crate futures_sink; extern crate futures_stable; extern crate futures_util; -// TODO(cramertj) reenable -// #[cfg(feature = "nightly")] extern crate futures_macro_async; -// #[cfg(feature = "nightly")] extern crate futures_macro_await; +#[cfg(feature = "nightly")] extern crate futures_macro_async; +#[cfg(feature = "nightly")] extern crate futures_macro_await; pub use futures_core::future::{Future, IntoFuture}; pub use futures_util::future::FutureExt; @@ -289,23 +288,22 @@ pub mod prelude { AsyncWriteExt, }; -// TODO(cramertj) reenable -// #[cfg(feature = "nightly")] -// pub use futures_macro_async::{ -// async, -// async_move, -// async_stream, -// async_stream_move, -// async_block, -// async_stream_block -// }; -// -// #[cfg(feature = "nightly")] -// pub use futures_macro_await::{ -// await, -// stream_yield, -// await_item -// }; + #[cfg(feature = "nightly")] + pub use futures_macro_async::{ + async, + async_move, + async_stream, + async_stream_move, + async_block, + async_stream_block + }; + + #[cfg(feature = "nightly")] + pub use futures_macro_await::{ + await, + stream_yield, + await_item + }; } pub mod sink { @@ -402,11 +400,10 @@ pub mod stable { pub use futures_stable::{StableExecutor, block_on_stable}; } -// TODO(cramertj) reenable -// #[cfg(feature = "nightly")] -// #[doc(hidden)] -// pub mod __rt { -// #[cfg(feature = "std")] -// pub extern crate std; -// pub use futures_async_runtime::*; -// } +#[cfg(feature = "nightly")] +#[doc(hidden)] +pub mod __rt { + #[cfg(feature = "std")] + pub extern crate std; + pub use futures_async_runtime::*; +} diff --git a/futures/tests/async_await/smoke.rs b/futures/tests/async_await/smoke.rs index b86cb9b3fc..c22ab673b7 100644 --- a/futures/tests/async_await/smoke.rs +++ b/futures/tests/async_await/smoke.rs @@ -234,6 +234,6 @@ fn poll_stream_after_error() { #[test] fn run_boxed_future_in_cpu_pool() { - let mut pool = executor::ThreadPool::new(); + let mut pool = executor::ThreadPool::new().unwrap(); pool.spawn(_foo9()).unwrap(); }