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

Add default support for arrays of all sizes #106145

Closed
wants to merge 1 commit into from
Closed

Add default support for arrays of all sizes #106145

wants to merge 1 commit into from

Conversation

saeubank
Copy link

@saeubank saeubank commented Dec 25, 2022

Currently only arrays of up to size 32 support Default.
This expands Default to be allowed for arrays of all sizes.

rust-lang/libs-team#153

@rustbot
Copy link
Collaborator

rustbot commented Dec 25, 2022

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @m-ou-se (or someone else) soon.

Please see the contribution instructions for more information.

@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 Dec 25, 2022
@rustbot
Copy link
Collaborator

rustbot commented Dec 25, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
configure: rust.debug-assertions := True
configure: rust.overflow-checks := True
configure: llvm.assertions      := True
configure: dist.missing-tools   := True
configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
configure: writing `config.toml` in current directory
configure: 
configure: run `python /checkout/x.py --help`
Attempting with retry: make prepare
---
    Checking rand v0.7.3
    Checking alloc v0.0.0 (/checkout/library/alloc)
    Checking std v0.0.0 (/checkout/library/std)
    Checking core v0.0.0 (/checkout/library/core)
error[E0599]: the function or associated item `default` exists for array `[DoesNotImplDefault; 0]`, but its trait bounds were not satisfied
    |
    |
303 |     struct DoesNotImplDefault;
    |     ------------------------- doesn't satisfy `DoesNotImplDefault: Default`
304 |
305 |     let _arr = <[DoesNotImplDefault; 0]>::default();
    |                                           ^^^^^^^ function or associated item cannot be called on `[DoesNotImplDefault; 0]` due to unsatisfied trait bounds
    = note: the following trait bounds were not satisfied:
    = note: the following trait bounds were not satisfied:
            `DoesNotImplDefault: Default`
            which is required by `[DoesNotImplDefault; 0]: Default`
help: consider annotating `DoesNotImplDefault` with `#[derive(Default)]`
303 |     #[derive(Default)]
    |

For more information about this error, try `rustc --explain E0599`.

@saeubank
Copy link
Author

@rustbot label +T-libs-api -T-libs

@rustbot rustbot added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 25, 2022
@saeubank
Copy link
Author

@bors try

@bors
Copy link
Contributor

bors commented Dec 26, 2022

@saeubank: 🔑 Insufficient privileges: not in try users

@dtolnay dtolnay assigned dtolnay and unassigned m-ou-se Dec 26, 2022
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

I am very skeptical that the library API team would be on board with breaking the [T; 0] impl. I'll go ahead and close this PR.

However, the team is interested in approaches that would allow arbitrarily large [T; N] to implement Default, as long as the 0 case continues to work as it currently does. This is already tracked in #61415.

@dtolnay dtolnay closed this Dec 26, 2022
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-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants