diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index ecd9a59..f8243d4 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -14,15 +14,15 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - RUST: ["1.48", stable, beta, nightly] + RUST: ["1.56", stable, beta, nightly] steps: - uses: actions/checkout@v2 - name: Set Rust version run: rustup default ${{ matrix.RUST }} - name: Build - run: cargo build --verbose ${{ matrix.RUST != '1.48' && '--features=__tokio' || '' }} + run: cargo build --verbose - name: Run tests - run: cargo test --verbose ${{ matrix.RUST != '1.48' && '--features=__tokio' || '' }} + run: cargo test --verbose no-std-test: runs-on: ubuntu-latest diff --git a/examples/Cargo.toml b/examples/Cargo.toml index e8fa0fd..ad247fa 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -14,16 +14,15 @@ rustdoc-args = ["--document-private-items"] [lib] [features] -default = [] +default = ["std"] # Disables any tests that are not compatible or not intended to run under Miri miri = [] std = [] -__tokio = ["tokio", "std"] [dependencies] ouroboros = { version = "0.15.7", path = "../ouroboros" } -tokio = { version = "1.27.0", features = [ "macros", "rt" ], optional = true } [dev-dependencies] rustversion = "1.0.11" trybuild = "=1.0.50" +tokio = { version = "1.25.0", features = [ "macros", "rt" ] } diff --git a/examples/src/ok_tests.rs b/examples/src/ok_tests.rs index 61ae346..5cf7b4d 100644 --- a/examples/src/ok_tests.rs +++ b/examples/src/ok_tests.rs @@ -91,7 +91,7 @@ fn box_and_ref() { // Miri crashes with Pin> types due to // https://github.com/rust-lang/miri/issues/1038 -#[cfg(all(not(feature = "miri"), feature = "tokio"))] +#[cfg(all(not(feature = "miri"), feature = "std"))] #[tokio::test] async fn async_new() { use std::future::Future; @@ -107,7 +107,7 @@ async fn async_new() { // Miri crashes with Pin> types due to // https://github.com/rust-lang/miri/issues/1038 -#[cfg(all(not(feature = "miri"), feature = "tokio"))] +#[cfg(all(not(feature = "miri"), feature = "std"))] #[tokio::test] async fn async_try_new() { let bar = BoxAndRefAsyncTryBuilder { @@ -123,7 +123,7 @@ async fn async_try_new() { // Miri crashes with Pin> types due to // https://github.com/rust-lang/miri/issues/1038 -#[cfg(all(not(feature = "miri"), feature = "tokio"))] +#[cfg(all(not(feature = "miri"), feature = "std"))] #[tokio::test] async fn async_try_new_err() { let result = BoxAndRefAsyncTryBuilder { diff --git a/ouroboros_macro/Cargo.toml b/ouroboros_macro/Cargo.toml index a350e81..bbd01b6 100644 --- a/ouroboros_macro/Cargo.toml +++ b/ouroboros_macro/Cargo.toml @@ -16,7 +16,7 @@ Inflector = { version = "0.11", default-features = false } proc-macro2 = "1.0" proc-macro-error = "1.0.4" quote = "1.0" -syn = { version = "1.0", features = ["full"] } +syn = { version = "2.0", features = ["full"] } [features] std = [] diff --git a/ouroboros_macro/src/info_structures.rs b/ouroboros_macro/src/info_structures.rs index 22e4cde..0894053 100644 --- a/ouroboros_macro/src/info_structures.rs +++ b/ouroboros_macro/src/info_structures.rs @@ -3,7 +3,7 @@ use proc_macro2::{Ident, TokenStream}; use quote::{format_ident, quote, ToTokens}; use syn::{ punctuated::Punctuated, token::Comma, Attribute, ConstParam, Error, GenericParam, Generics, - LifetimeDef, Type, TypeParam, Visibility, + LifetimeParam, Type, TypeParam, Visibility, }; #[derive(Clone, Copy)] @@ -98,7 +98,7 @@ impl StructInfo { Type(TypeParam { ident, .. }) | Const(ConstParam { ident, .. }) => { ident.to_token_stream() } - Lifetime(LifetimeDef { lifetime, .. }) => lifetime.to_token_stream(), + Lifetime(LifetimeParam { lifetime, .. }) => lifetime.to_token_stream(), }); quote! { <'_, '_, #(#params,)*> } } diff --git a/ouroboros_macro/src/lib.rs b/ouroboros_macro/src/lib.rs index cd12419..b0e5283 100644 --- a/ouroboros_macro/src/lib.rs +++ b/ouroboros_macro/src/lib.rs @@ -50,8 +50,11 @@ fn self_referencing_impl( create_try_builder_and_constructor(&info, options, BuilderType::Sync)?; let (async_try_builder_struct_name, async_try_builder_def, async_try_constructor_def) = create_try_builder_and_constructor(&info, options, BuilderType::Async)?; - let (async_send_try_builder_struct_name, async_send_try_builder_def, async_send_try_constructor_def) = - create_try_builder_and_constructor(&info, options, BuilderType::AsyncSend)?; + let ( + async_send_try_builder_struct_name, + async_send_try_builder_def, + async_send_try_constructor_def, + ) = create_try_builder_and_constructor(&info, options, BuilderType::AsyncSend)?; let with_defs = make_with_functions(&info, options)?; let (with_all_struct_defs, with_all_fn_defs) = make_with_all_function(&info, options)?; diff --git a/ouroboros_macro/src/parse.rs b/ouroboros_macro/src/parse.rs index 546aa7c..19e63e9 100644 --- a/ouroboros_macro/src/parse.rs +++ b/ouroboros_macro/src/parse.rs @@ -1,6 +1,6 @@ use proc_macro2::{Delimiter, Span, TokenTree}; use quote::format_ident; -use syn::{spanned::Spanned, Attribute, Error, Fields, GenericParam, ItemStruct}; +use syn::{spanned::Spanned, Attribute, Error, Fields, GenericParam, ItemStruct, Meta}; use crate::{ covariance_detection::type_is_covariant_over_this_lifetime, @@ -15,12 +15,14 @@ fn handle_borrows_attr( ) -> Result<(), Error> { let mut borrow_mut = false; let mut waiting_for_comma = false; - let tokens = attr.tokens.clone(); - let possible_error = Error::new_spanned(&tokens, "Invalid syntax for borrows() macro."); - let tokens = if let Some(TokenTree::Group(group)) = tokens.into_iter().next() { - group.stream() - } else { - return Err(possible_error); + let tokens = match &attr.meta { + Meta::List(ml) => ml.tokens.clone(), + _ => { + return Err(Error::new_spanned( + &attr.meta, + "Invalid syntax for borrows() macro.", + )) + } }; for token in tokens { if let TokenTree::Ident(ident) = token { @@ -113,7 +115,10 @@ fn parse_derive_token(token: &TokenTree) -> Result, Error> { } fn parse_derive_attribute(attr: &Attribute) -> Result, Error> { - let body = &attr.tokens; + let body = match &attr.meta { + Meta::List(ml) => &ml.tokens, + _ => unreachable!(), + }; if let Some(TokenTree::Group(body)) = body.clone().into_iter().next() { if body.delimiter() != Delimiter::Parenthesis { panic!("TODO: nice error, bad define syntax") @@ -144,7 +149,7 @@ pub fn parse_struct(def: &ItemStruct) -> Result { let mut covariant = type_is_covariant_over_this_lifetime(&field.ty); let mut remove_attrs = Vec::new(); for (index, attr) in field.attrs.iter().enumerate() { - let path = &attr.path; + let path = &attr.path(); if path.leading_colon.is_some() { continue; } @@ -234,7 +239,7 @@ pub fn parse_struct(def: &ItemStruct) -> Result { let mut attributes = Vec::new(); let mut derives = Vec::new(); for attr in &def.attrs { - let p = &attr.path.segments; + let p = &attr.path().segments; if p.len() == 0 { return Err(Error::new(p.span(), &format!("Unsupported attribute"))); }