Skip to content

Documentation for variadics #15387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/bevy_app/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
// `rustdoc_internals` is needed for `#[doc(fake_variadics)]`
#![allow(internal_features)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this only be enabled on docsrs and maybe docsrs_dep to prevent the miniscule chance of it accidentally being depended on elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I have there, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that maybe internal_features should also be under a cfg_attr, should have been clearer

#![cfg_attr(any(docsrs, docsrs_dep), feature(doc_auto_cfg, rustdoc_internals))]
#![forbid(unsafe_code)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
Expand Down
12 changes: 10 additions & 2 deletions crates/bevy_app/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ mod sealed {
}

macro_rules! impl_plugins_tuples {
($(($param: ident, $plugins: ident)),*) => {
($(#[$meta:meta])* $(($param: ident, $plugins: ident)),*) => {
$(#[$meta])*
impl<$($param, $plugins),*> Plugins<(PluginsTupleMarker, $($param,)*)> for ($($plugins,)*)
where
$($plugins: Plugins<$param>),*
Expand All @@ -179,5 +180,12 @@ mod sealed {
}
}

all_tuples!(impl_plugins_tuples, 0, 15, P, S);
all_tuples!(
#[doc(fake_variadic)]
impl_plugins_tuples,
0,
15,
P,
S
);
}
1 change: 1 addition & 0 deletions crates/bevy_ecs/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ macro_rules! tuple_impl {
}
}

$(#[$meta])*
impl<$($name: Bundle),*> DynamicBundle for ($($name,)*) {
#[allow(unused_variables, unused_mut)]
#[inline(always)]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/query/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,6 @@ pub struct AnyOf<T>(PhantomData<T>);

macro_rules! impl_tuple_query_data {
($(#[$meta:meta])* $(($name: ident, $state: ident)),*) => {

#[allow(non_snake_case)]
#[allow(clippy::unused_unit)]
$(#[$meta])*
Expand All @@ -2023,6 +2022,7 @@ macro_rules! impl_tuple_query_data {
type ReadOnly = ($($name::ReadOnly,)*);
}

$(#[$meta])*
/// SAFETY: each item in the tuple is read only
unsafe impl<$($name: ReadOnlyQueryData),*> ReadOnlyQueryData for ($($name,)*) {}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_reflect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@
//! [the language feature for dyn upcasting coercion]: https://github.com/rust-lang/rust/issues/65991
//! [derive macro]: derive@crate::Reflect
//! [`'static` lifetime]: https://doc.rust-lang.org/rust-by-example/scope/lifetime/static_lifetime.html#trait-bound
//! [`Function`]: func::Function
//! [`Function`]: crate::func::Function
//! [derive macro documentation]: derive@crate::Reflect
//! [deriving `Reflect`]: derive@crate::Reflect
//! [type data]: TypeData
Expand Down
34 changes: 28 additions & 6 deletions crates/bevy_reflect/src/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ impl_reflect_tuple! {0: A, 1: B, 2: C, 3: D, 4: E, 5: F, 6: G, 7: H, 8: I, 9: J,

macro_rules! impl_type_path_tuple {
($(#[$meta:meta])*) => {
$(#[$meta])*
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove this if wanted

impl TypePath for () {
fn type_path() -> &'static str {
"()"
Expand Down Expand Up @@ -732,29 +733,50 @@ all_tuples!(
#[cfg(feature = "functions")]
const _: () = {
macro_rules! impl_get_ownership_tuple {
($($name: ident),*) => {
($(#[$meta:meta])* $($name: ident),*) => {
$(#[$meta])*
$crate::func::args::impl_get_ownership!(($($name,)*); <$($name),*>);
};
}

all_tuples!(impl_get_ownership_tuple, 0, 12, P);
all_tuples!(
#[doc(fake_variadic)]
impl_get_ownership_tuple,
0,
12,
P
);

macro_rules! impl_from_arg_tuple {
($($name: ident),*) => {
($(#[$meta:meta])* $($name: ident),*) => {
$(#[$meta])*
$crate::func::args::impl_from_arg!(($($name,)*); <$($name: FromReflect + MaybeTyped + TypePath + GetTypeRegistration),*>);
};
}

all_tuples!(impl_from_arg_tuple, 0, 12, P);
all_tuples!(
#[doc(fake_variadic)]
impl_from_arg_tuple,
0,
12,
P
);

macro_rules! impl_into_return_tuple {
($($name: ident),+) => {
($(#[$meta:meta])* $($name: ident),+) => {
$(#[$meta])*
$crate::func::impl_into_return!(($($name,)*); <$($name: FromReflect + MaybeTyped + TypePath + GetTypeRegistration),*>);
};
}

// The unit type (i.e. `()`) is special-cased, so we skip implementing it here.
all_tuples!(impl_into_return_tuple, 1, 12, P);
all_tuples!(
#[doc(fake_variadic)]
impl_into_return_tuple,
1,
12,
P
);
};

#[cfg(test)]
Expand Down