-
Notifications
You must be signed in to change notification settings - Fork 13.7k
alloc: make Cow From impls const #146067
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
alloc: make Cow From impls const #146067
Conversation
|
@@ -245,7 +245,8 @@ impl<'a> From<&'a ByteStr> for ByteString { | |||
} | |||
|
|||
#[unstable(feature = "bstr", issue = "134915")] | |||
impl<'a> From<ByteString> for Cow<'a, ByteStr> { | |||
#[rustc_const_unstable(feature = "const_from", issue = "143773")] | |||
impl<'a> const From<ByteString> for Cow<'a, ByteStr> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have the equivalent for String? And is ByteString const constructible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oli-obk Yes, the equivalent for String is in this same patch.
ByteString is const constructible:
#[repr(transparent)]
pub struct ByteString(pub Vec<u8>);
Both Vec and String are const constructible:
https://doc.rust-lang.org/std/vec/struct.Vec.html#method.new
https://doc.rust-lang.org/std/string/struct.String.html#method.new
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh lol i stopped scrolling and didnt see the other files
@bors r+ |
@bors rollup |
alloc: make Cow From impls const This is an expansion of rust-lang#143773 for the `Cow` `From` conversions. r? `@oli-obk`
Rollup of 10 pull requests Successful merges: - #144066 (stabilize c-style varargs for sysv64, win64, efiapi, aapcs) - #145783 (add span to struct pattern rest (..)) - #145961 (resolve: Avoid a regression from splitting prelude into two scopes) - #145962 (Ensure we emit an allocator shim when only some crate types need one) - #146064 (Add compiler error when trying to use concat metavar expr in repetitions) - #146067 (alloc: make Cow From impls const) - #146070 (rustdoc-search: skip loading unneeded fnData) - #146089 (fix a constness ordering bug in rustfmt) - #146094 (Make `Parser::parse_for_head` public for rustfmt usage) - #146102 (Remove dead code stemming from an old effects desugaring) r? `@ghost` `@rustbot` modify labels: rollup
Does anyone read the tracking issues any more? Whatever. I explicitly had this as part of #144289 and was not including it because the other reviewer, @tgross35, expressed apprehension about adding heap-allocated trait impls at the end. Part of this PR exists as #145279, which you would find out if you read the comments on the tracking issue you linked. |
alloc: make Cow From impls const This is an expansion of rust-lang#143773 for the `Cow` `From` conversions. r? `@oli-obk`
Rollup of 9 pull requests Successful merges: - #145783 (add span to struct pattern rest (..)) - #145961 (resolve: Avoid a regression from splitting prelude into two scopes) - #145962 (Ensure we emit an allocator shim when only some crate types need one) - #146064 (Add compiler error when trying to use concat metavar expr in repetitions) - #146067 (alloc: make Cow From impls const) - #146070 (rustdoc-search: skip loading unneeded fnData) - #146089 (fix a constness ordering bug in rustfmt) - #146094 (Make `Parser::parse_for_head` public for rustfmt usage) - #146102 (Remove dead code stemming from an old effects desugaring) r? `@ghost` `@rustbot` modify labels: rollup
@bors r- |
This is an expansion of #143773 for the
Cow
From
conversions.r? @oli-obk