Skip to content
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

impl AsRef<[T; N]> and AsMut<[T; N]> for [T; N] #129872

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GrigorenkoPV
Copy link
Contributor

@GrigorenkoPV GrigorenkoPV commented Sep 2, 2024

Fixes #129849.

Apparently .as_ref() is widely used on arrays to mean .as_slice(), so some Edition sorcery similar to #84147 or #124097 is required.

TODO

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 2, 2024
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling crypto-common v0.1.6
error[E0282]: type annotations needed
   --> /cargo/registry/src/index.crates.io-6f17d22bba15001f/itertools-0.12.1/src/tuple_impl.rs:366:30
    |
336 | / macro_rules! impl_tuple_collect {
337 | |     ($dummy:ident,) => {}; // stop
338 | |     ($dummy:ident, $($Y:ident,)*) => (
339 | |         impl_tuple_collect!($($Y,)*);
    | |         |
    | |         in this macro invocation (#2)
    | |         in this macro invocation (#3)
...   |
...   |
366 | |                     if i < s.len() {
...   |
399 | |     )
400 | | }
    | | -
    | | -
    | | |
    | | in this expansion of `impl_tuple_collect!` (#1)
    | |_in this expansion of `impl_tuple_collect!` (#2)
    |   in this expansion of `impl_tuple_collect!` (#3)
401 |   impl_tuple_collect!(dummy, a, b, c, d, e, f, g, h, i, j, k, l,);

   Compiling num_cpus v1.16.0
error[E0282]: type annotations needed
   --> /cargo/registry/src/index.crates.io-6f17d22bba15001f/itertools-0.12.1/src/tuple_impl.rs:366:30
   --> /cargo/registry/src/index.crates.io-6f17d22bba15001f/itertools-0.12.1/src/tuple_impl.rs:366:30
    |
336 | / macro_rules! impl_tuple_collect {
337 | |     ($dummy:ident,) => {}; // stop
338 | |     ($dummy:ident, $($Y:ident,)*) => (
339 | |         impl_tuple_collect!($($Y,)*);
...   |
...   |
366 | |                     if i < s.len() {
...   |
399 | |     )
400 | | }
    | | -
    | | -
    | | |
    | |_in this expansion of `impl_tuple_collect!` (#1)
    |   in this expansion of `impl_tuple_collect!` (#2)
401 |   impl_tuple_collect!(dummy, a, b, c, d, e, f, g, h, i, j, k, l,);

error[E0282]: type annotations needed
   --> /cargo/registry/src/index.crates.io-6f17d22bba15001f/itertools-0.12.1/src/tuple_impl.rs:366:30
    |
    |
336 | / macro_rules! impl_tuple_collect {
337 | |     ($dummy:ident,) => {}; // stop
338 | |     ($dummy:ident, $($Y:ident,)*) => (
339 | |         impl_tuple_collect!($($Y,)*);
...   |
366 | |                     if i < s.len() {
...   |
399 | |     )
400 | | }
    | |_- in this expansion of `impl_tuple_collect!`
    | |_- in this expansion of `impl_tuple_collect!`
401 |   impl_tuple_collect!(dummy, a, b, c, d, e, f, g, h, i, j, k, l,);

   Compiling block-buffer v0.10.4
   Compiling rustc-rayon-core v0.5.0
   Compiling memmap2 v0.2.3

@compiler-errors
Copy link
Member

I am not on T-libs-api, but I don't believe this implementation carries its weight, for the record. Also, it's almost certainly too late to introduce anything new to edition 2024, especially with such weak justification as a single issue report on the tracker.

@GrigorenkoPV
Copy link
Contributor Author

Also, it's almost certainly too late to introduce anything new to edition 2024

Well, fair enough. I've overestimated this a bit.

I am not on T-libs-api, but I don't believe this implementation carries its weight, for the record.

From what I can tell, there is an intent to eventually add a blanket AsRef<T> for T where T: ?Sized, but it is currently not possible because of overlapping, so in the meantime there are some concrete impls as a replacement. So I'd argue this impl should exist in the meantime.

But anyways, there seems to be no sense in rushing to get this in 2024 edition and there is quite a bit of time before the next (2027?) one, so I guess I will go through the proper ACP process first, even though it will take quite a while.

Thank you for the cool-headed perspective and quick feedback on this! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing AsMut<[T;N]> for [T;N]
4 participants