Skip to content

Commit e43f28f

Browse files
vorot93carllerche
authored andcommitted
macros: do not automatically pull rt-core (#2038)
1 parent 3cf91db commit e43f28f

File tree

3 files changed

+17
-25
lines changed

3 files changed

+17
-25
lines changed

tokio-macros/src/lib.rs

+5-15
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use proc_macro::TokenStream;
2020
use quote::quote;
2121
use std::num::NonZeroUsize;
2222

23+
#[derive(Clone, Copy, PartialEq)]
2324
enum Runtime {
2425
Basic,
2526
Threaded,
@@ -145,21 +146,10 @@ fn parse_knobs(
145146
}
146147
}
147148

148-
let mut rt = quote! { tokio::runtime::Builder::new() };
149-
match (runtime, is_test) {
150-
(Some(Runtime::Threaded), _) => {
151-
if rt_threaded {
152-
rt = quote! { #rt.threaded_scheduler() }
153-
}
154-
}
155-
(Some(Runtime::Basic), _) => rt = quote! { #rt.basic_scheduler() },
156-
(None, true) => rt = quote! { #rt.basic_scheduler() },
157-
(None, false) => {
158-
if rt_threaded {
159-
rt = quote! { #rt.threaded_scheduler() }
160-
}
161-
}
162-
};
149+
let mut rt = quote! { tokio::runtime::Builder::new().basic_scheduler() };
150+
if rt_threaded && (runtime == Some(Runtime::Threaded) || (runtime.is_none() && !is_test)) {
151+
rt = quote! { #rt.threaded_scheduler() };
152+
}
163153
if let Some(v) = core_threads.map(|v| v.get()) {
164154
rt = quote! { #rt.core_threads(#v) };
165155
}

tokio/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ io-driver = ["mio", "lazy_static"]
5454
io-util = ["memchr"]
5555
# stdin, stdout, stderr
5656
io-std = ["rt-core"]
57-
macros = ["rt-core", "tokio-macros"]
57+
macros = ["tokio-macros"]
5858
net = ["dns", "tcp", "udp", "uds"]
5959
process = [
6060
"io-driver",

tokio/src/lib.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,18 @@ cfg_time! {
264264
mod util;
265265

266266
cfg_macros! {
267-
cfg_rt_threaded! {
268-
#[cfg(not(test))] // Work around for rust-lang/rust#62127
269-
pub use tokio_macros::main_threaded as main;
270-
pub use tokio_macros::test_threaded as test;
271-
}
267+
doc_rt_core! {
268+
cfg_rt_threaded! {
269+
#[cfg(not(test))] // Work around for rust-lang/rust#62127
270+
pub use tokio_macros::main_threaded as main;
271+
pub use tokio_macros::test_threaded as test;
272+
}
272273

273-
cfg_not_rt_threaded! {
274-
#[cfg(not(test))] // Work around for rust-lang/rust#62127
275-
pub use tokio_macros::main_basic as main;
276-
pub use tokio_macros::test_basic as test;
274+
cfg_not_rt_threaded! {
275+
#[cfg(not(test))] // Work around for rust-lang/rust#62127
276+
pub use tokio_macros::main_basic as main;
277+
pub use tokio_macros::test_basic as test;
278+
}
277279
}
278280
}
279281

0 commit comments

Comments
 (0)