Skip to content

Commit

Permalink
prepare macros v0.2.0 release (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede authored Feb 2, 2021
1 parent 057e7cd commit 66bd5bf
Show file tree
Hide file tree
Showing 19 changed files with 85 additions and 57 deletions.
2 changes: 1 addition & 1 deletion actix-codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "Codec utilities for working with framed protocols"
keywords = ["network", "framework", "async", "futures"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-codec/"
documentation = "https://docs.rs/actix-codec"
categories = ["network-programming", "asynchronous"]
license = "MIT OR Apache-2.0"
edition = "2018"
Expand Down
10 changes: 9 additions & 1 deletion actix-macros/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
## Unreleased - 2021-xx-xx


## 0.2.0 - 2021-02-02
* Update to latest `actix_rt::System::new` signature. [#261]

[#261]: https://github.com/actix/actix-net/pull/261


## 0.2.0-beta.1 - 2021-01-09
* Remove `actix-reexport` feature.
* Remove `actix-reexport` feature. [#218]

[#218]: https://github.com/actix/actix-net/pull/218


## 0.1.3 - 2020-12-03
Expand Down
13 changes: 5 additions & 8 deletions actix-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "actix-macros"
version = "0.2.0-beta.1"
version = "0.2.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix runtime macros"
repository = "https://github.com/actix/actix-net"
documentation = "https://docs.rs/actix-macros/"
description = "Macros for Actix system and runtime"
repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-macros"
categories = ["network-programming", "asynchronous"]
license = "MIT OR Apache-2.0"
edition = "2018"
Expand All @@ -16,11 +16,8 @@ proc-macro = true
quote = "1.0.3"
syn = { version = "^1", features = ["full"] }

[features]
actix-reexport = []

[dev-dependencies]
actix-rt = "2.0.0-beta.2"
actix-rt = "2.0.0-beta.3"

futures-util = { version = "0.3", default-features = false }
trybuild = "1"
62 changes: 33 additions & 29 deletions actix-macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
//! Macros for use with Tokio
//! Macros for Actix system and runtime.
//!
//! The [`actix-rt`](https://docs.rs/actix-rt) crate must be available for macro output to compile.
//!
//! # Entry-point
//! See docs for the [`#[main]`](macro@main) macro.
//!
//! # Tests
//! See docs for the [`#[test]`](macro@test) macro.

#![deny(rust_2018_idioms, nonstandard_style)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
Expand All @@ -7,10 +15,9 @@
use proc_macro::TokenStream;
use quote::quote;

/// Marks async function to be executed by Actix system.
///
/// ## Usage
/// Marks async entry-point function to be executed by Actix system.
///
/// # Examples
/// ```
/// #[actix_rt::main]
/// async fn main() {
Expand All @@ -28,9 +35,12 @@ pub fn main(_: TokenStream, item: TokenStream) -> TokenStream {
let body = &input.block;

if sig.asyncness.is_none() {
return syn::Error::new_spanned(sig.fn_token, "only async fn is supported")
.to_compile_error()
.into();
return syn::Error::new_spanned(
sig.fn_token,
"the async keyword is missing from the function declaration",
)
.to_compile_error()
.into();
}

sig.asyncness = None;
Expand All @@ -45,11 +55,10 @@ pub fn main(_: TokenStream, item: TokenStream) -> TokenStream {
.into()
}

/// Marks async test function to be executed by Actix system.
///
/// ## Usage
/// Marks async test function to be executed in an Actix system.
///
/// ```no_run
/// # Examples
/// ```
/// #[actix_rt::test]
/// async fn my_test() {
/// assert!(true);
Expand All @@ -73,32 +82,27 @@ pub fn test(_: TokenStream, item: TokenStream) -> TokenStream {
if sig.asyncness.is_none() {
return syn::Error::new_spanned(
input.sig.fn_token,
format!("only async fn is supported, {}", input.sig.ident),
"the async keyword is missing from the function declaration",
)
.to_compile_error()
.into();
}

sig.asyncness = None;

let result = if has_test_attr {
quote! {
#(#attrs)*
#vis #sig {
actix_rt::System::new()
.block_on(async { #body })
}
}
let missing_test_attr = if has_test_attr {
quote!()
} else {
quote! {
#[test]
#(#attrs)*
#vis #sig {
actix_rt::System::new()
.block_on(async { #body })
}
}
quote!(#[test])
};

result.into()
(quote! {
#missing_test_attr
#(#attrs)*
#vis #sig {
actix_rt::System::new()
.block_on(async { #body })
}
})
.into()
}
2 changes: 2 additions & 0 deletions actix-macros/tests/trybuild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ fn compile_macros() {
let t = trybuild::TestCases::new();
t.pass("tests/trybuild/main-01-basic.rs");
t.compile_fail("tests/trybuild/main-02-only-async.rs");
t.pass("tests/trybuild/main-03-fn-params.rs");

t.pass("tests/trybuild/test-01-basic.rs");
t.pass("tests/trybuild/test-02-keep-attrs.rs");
t.compile_fail("tests/trybuild/test-03-only-async.rs");
}
2 changes: 1 addition & 1 deletion actix-macros/tests/trybuild/main-02-only-async.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: only async fn is supported
error: the async keyword is missing from the function declaration
--> $DIR/main-02-only-async.rs:2:1
|
2 | fn main() {
Expand Down
6 changes: 6 additions & 0 deletions actix-macros/tests/trybuild/main-03-fn-params.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[actix_rt::main]
async fn main2(_param: bool) {
futures_util::future::ready(()).await
}

fn main() {}
6 changes: 6 additions & 0 deletions actix-macros/tests/trybuild/test-03-only-async.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[actix_rt::test]
fn my_test() {
futures_util::future::ready(()).await
}

fn main() {}
5 changes: 5 additions & 0 deletions actix-macros/tests/trybuild/test-03-only-async.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
error: the async keyword is missing from the function declaration
--> $DIR/test-03-only-async.rs:2:1
|
2 | fn my_test() {
| ^^
2 changes: 1 addition & 1 deletion actix-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "Resource path matching library"
keywords = ["actix"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-router/"
documentation = "https://docs.rs/actix-router"
license = "MIT OR Apache-2.0"
edition = "2018"

Expand Down
6 changes: 3 additions & 3 deletions actix-rt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ authors = [
"Nikolay Kim <fafhrd91@gmail.com>",
"Rob Ede <robjtede@icloud.com>",
]
description = "Tokio-based single-thread async runtime for the Actix ecosystem"
description = "Tokio-based single-threaded async runtime for the Actix ecosystem"
keywords = ["network", "framework", "async", "futures"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-rt/"
documentation = "https://docs.rs/actix-rt"
categories = ["network-programming", "asynchronous"]
license = "MIT OR Apache-2.0"
edition = "2018"
Expand All @@ -23,7 +23,7 @@ default = ["macros"]
macros = ["actix-macros"]

[dependencies]
actix-macros = { version = "0.2.0-beta.1", optional = true }
actix-macros = { version = "0.2.0", optional = true }

futures-core = { version = "0.3", default-features = false }
tokio = { version = "1", features = ["rt", "net", "parking_lot", "signal", "sync", "time"] }
Expand Down
2 changes: 1 addition & 1 deletion actix-rt/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# actix-rt

> Tokio-based single-thread async runtime for the Actix ecosystem.
> Tokio-based single-threaded async runtime for the Actix ecosystem.
See documentation for detailed explanations these components: [https://docs.rs/actix-rt][docs].

Expand Down
2 changes: 1 addition & 1 deletion actix-rt/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Tokio-based single-thread async runtime for the Actix ecosystem.
//! Tokio-based single-threaded async runtime for the Actix ecosystem.
//!
//! In most parts of the the Actix ecosystem, it has been chosen to use !Send futures. For this
//! reason, a single-threaded runtime is appropriate since it is guaranteed that futures will not
Expand Down
4 changes: 2 additions & 2 deletions actix-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "General purpose TCP server built for the Actix ecosystem"
keywords = ["network", "framework", "async", "futures"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-server/"
documentation = "https://docs.rs/actix-server"
categories = ["network-programming", "asynchronous"]
license = "MIT OR Apache-2.0"
exclude = [".gitignore", ".cargo/config"]
Expand All @@ -24,7 +24,7 @@ default = []

[dependencies]
actix-codec = "0.4.0-beta.1"
actix-rt = { version = "2.0.0-beta.2", default-features = false }
actix-rt = { version = "2.0.0-beta.3", default-features = false }
actix-service = "2.0.0-beta.3"
actix-utils = "3.0.0-beta.1"

Expand Down
2 changes: 1 addition & 1 deletion actix-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ futures-core = { version = "0.3.7", default-features = false }
pin-project-lite = "0.2"

[dev-dependencies]
actix-rt = "2.0.0-beta.2"
actix-rt = "2.0.0-beta.3"
futures-util = { version = "0.3.7", default-features = false }
6 changes: 3 additions & 3 deletions actix-tls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "TLS acceptor and connector services for Actix ecosystem"
keywords = ["network", "tls", "ssl", "async", "transport"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-tls/"
documentation = "https://docs.rs/actix-tls"
categories = ["network-programming", "asynchronous"]
license = "MIT OR Apache-2.0"
edition = "2018"
Expand Down Expand Up @@ -41,7 +41,7 @@ uri = ["http"]

[dependencies]
actix-codec = "0.4.0-beta.1"
actix-rt = { version = "2.0.0-beta.2", default-features = false }
actix-rt = { version = "2.0.0-beta.3", default-features = false }
actix-service = "2.0.0-beta.3"
actix-utils = "3.0.0-beta.1"

Expand All @@ -67,7 +67,7 @@ tls-native-tls = { package = "native-tls", version = "0.2", optional = true }
tokio-native-tls = { version = "0.3", optional = true }

[dev-dependencies]
actix-rt = "2.0.0-beta.2"
actix-rt = "2.0.0-beta.3"
actix-server = "2.0.0-beta.2"
bytes = "1"
env_logger = "0.8"
Expand Down
4 changes: 2 additions & 2 deletions actix-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "Support for tokio tracing with Actix services"
keywords = ["network", "framework", "tracing"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-tracing/"
documentation = "https://docs.rs/actix-tracing"
categories = ["network-programming", "asynchronous"]
license = "MIT OR Apache-2.0"
edition = "2018"
Expand All @@ -23,5 +23,5 @@ tracing = "0.1"
tracing-futures = "0.2"

[dev_dependencies]
actix-rt = "2.0.0-beta.2"
actix-rt = "2.0.0-beta.3"
slab = "0.4"
4 changes: 2 additions & 2 deletions actix-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "Various network related services and utilities for the Actix ecos
keywords = ["network", "framework", "async", "futures"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/actix-utils/"
documentation = "https://docs.rs/actix-utils"
categories = ["network-programming", "asynchronous"]
license = "MIT OR Apache-2.0"
edition = "2018"
Expand All @@ -17,7 +17,7 @@ path = "src/lib.rs"

[dependencies]
actix-codec = "0.4.0-beta.1"
actix-rt = { version = "2.0.0-beta.2", default-features = false }
actix-rt = { version = "2.0.0-beta.3", default-features = false }
actix-service = "2.0.0-beta.3"

futures-core = { version = "0.3.7", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion bytestring/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ keywords = ["string", "bytes", "utf8", "web", "actix"]
categories = ["no-std", "web-programming"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/bytestring/"
documentation = "https://docs.rs/bytestring"
license = "MIT OR Apache-2.0"
edition = "2018"

Expand Down

0 comments on commit 66bd5bf

Please sign in to comment.