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

Tracking Issue for const_default_impls #87864

Closed
1 of 3 tasks
fee1-dead opened this issue Aug 8, 2021 · 5 comments
Closed
1 of 3 tasks

Tracking Issue for const_default_impls #87864

fee1-dead opened this issue Aug 8, 2021 · 5 comments
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC F-const_trait_impl `#![feature(const_trait_impl)]` T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@fee1-dead
Copy link
Member

fee1-dead commented Aug 8, 2021

Feature gate: #![feature(const_default_impls)]

This is a tracking issue for const Default impls in the standard library.

Public API

// core::array
impl<T> const Default for [T; 0];

// core::default
impl const Default for ();
impl const Default for bool;
impl const Default for char;
impl const Default for usize;
impl const Default for u8;
impl const Default for u16;
impl const Default for u32;
impl const Default for u64;
impl const Default for u128;
impl const Default for isize;
impl const Default for i8;
impl const Default for i16;
impl const Default for i32;
impl const Default for i64;
impl const Default for i128;
impl const Default for f32;
impl const Default for f64;

// core::hash
impl<H> const Default for BuildHasherDefault<H>;

// core::iter
impl<T> const Default for Empty<T>;

// core::marker
impl<T: ?Sized> const Default for PhantomData<T>;

// core::option
impl<T> const Default for Option<T>;

// core::slice
impl<T> const Default for &[T];
impl<T> const Default for &mut [T];

// core::str
impl const Default for &str;

// core::sync::atomic
impl const Default for AtomicBool;
impl<T> const Default for AtomicPtr<T>;

// alloc::boxed
impl<T> const Default for Box<[T]>;
impl const Default for Box<str>;

// alloc::string
impl const Default for String;

// alloc::vec
impl<T> const Default for Vec<T>;

// std::lazy
impl<T> const Default for SyncOnceCell<T>;

Steps / History

Unresolved Questions

  • None yet.
@fee1-dead fee1-dead added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Aug 8, 2021
@jonas-schievink jonas-schievink added the F-const_trait_impl `#![feature(const_trait_impl)]` label Aug 8, 2021
fee1-dead added a commit to fee1-dead-contrib/rust that referenced this issue Apr 12, 2022
`impl const Default for Box<[T]>` and `Box<str>`

The unstable `const_default_impls` (rust-lang#87864) already include empty `Vec<T>` and `String`. Now we extend that concept to `Box<[T]>` and `Box<str>` as well.

This obviates a hack in `rustc_ast`'s `P::<[T]>::new`.
@kartva
Copy link
Contributor

kartva commented May 29, 2022

What's the status of this issue?

@Liamolucko
Copy link

It's dependent on #67792.

@C0D3-M4513R
Copy link

I stumbled across this pr, as I was trying to implement my own const Default implementations and ran into various errors:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=36cb0ae9a38d3d57000dce3173d38df2

What am I doing wrong here?

@fee1-dead
Copy link
Member Author

See #110395.

@dtolnay
Copy link
Member

dtolnay commented Jun 25, 2024

Based on rg 'const Default' library all these impls have been rolled back as part of #110393.

I'll close the issue since this isn't currently tracking any API requiring Libs-API team attention, but the list of impls at the top of this issue may be useful if const impls ever get reinstated, and we can reopen the issue (or create a new one) at that point.

@dtolnay dtolnay closed this as completed Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC F-const_trait_impl `#![feature(const_trait_impl)]` T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants