Skip to content

Commit

Permalink
Rollup merge of rust-lang#129525 - notriddle:notriddle/fake-variadic-…
Browse files Browse the repository at this point in the history
…tuple-array, r=GuillaumeGomez

rustdoc: clean up tuple <-> primitive conversion docs

This adds a minor missing feature to `fake_variadic`, so that it can render `impl From<(T,)> for [T; 1]` correctly.
  • Loading branch information
matthiaskrgr authored Aug 25, 2024
2 parents 8ea71ae + 49aa496 commit ff769ee
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions core/src/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,29 @@ macro_rules! tuple_impls {
}
}

#[stable(feature = "array_tuple_conv", since = "1.71.0")]
impl<T> From<[T; ${count($T)}]> for ($(${ignore($T)} T,)+) {
#[inline]
#[allow(non_snake_case)]
fn from(array: [T; ${count($T)}]) -> Self {
let [$($T,)+] = array;
($($T,)+)
maybe_tuple_doc! {
$($T)+ @
#[stable(feature = "array_tuple_conv", since = "1.71.0")]
impl<T> From<[T; ${count($T)}]> for ($(${ignore($T)} T,)+) {
#[inline]
#[allow(non_snake_case)]
fn from(array: [T; ${count($T)}]) -> Self {
let [$($T,)+] = array;
($($T,)+)
}
}
}

#[stable(feature = "array_tuple_conv", since = "1.71.0")]
impl<T> From<($(${ignore($T)} T,)+)> for [T; ${count($T)}] {
#[inline]
#[allow(non_snake_case)]
fn from(tuple: ($(${ignore($T)} T,)+)) -> Self {
let ($($T,)+) = tuple;
[$($T,)+]
maybe_tuple_doc! {
$($T)+ @
#[stable(feature = "array_tuple_conv", since = "1.71.0")]
impl<T> From<($(${ignore($T)} T,)+)> for [T; ${count($T)}] {
#[inline]
#[allow(non_snake_case)]
fn from(tuple: ($(${ignore($T)} T,)+)) -> Self {
let ($($T,)+) = tuple;
[$($T,)+]
}
}
}
}
Expand All @@ -148,7 +154,7 @@ macro_rules! tuple_impls {
// Otherwise, it hides the docs entirely.
macro_rules! maybe_tuple_doc {
($a:ident @ #[$meta:meta] $item:item) => {
#[doc(fake_variadic)]
#[cfg_attr(not(bootstrap), doc(fake_variadic))]
#[doc = "This trait is implemented for tuples up to twelve items long."]
#[$meta]
$item
Expand Down

0 comments on commit ff769ee

Please sign in to comment.