Commit Graph

3398 Commits

Author SHA1 Message Date
Matthias Krüger
f2eb47a81b Rollup merge of #145562 - tbu-:pr_simplify_to_string_spec, r=tgross35
Simplify macro generating ToString implementations for `&…&str`

Use deref coercion to let the compiler remove any amount of references. Also use that macro for `Cow` and `String`.
2025-08-27 11:26:49 +02:00
Matthias Krüger
62e5341661 Rollup merge of #145335 - clarfonthey:wtf8-core-alloc, r=Mark-Simulacrum
Move WTF-8 code from std into core and alloc

This is basically a small portion of rust-lang/rust#129411 with a smaller scope. It *does not*\* affect any public APIs; this code is still internal to the standard library. It just moves the WTF-8 code into `core` and `alloc` so it can be accessed by `no_std` crates like `backtrace`.

> \* The only public API this affects is by adding a `Debug` implementation to `std::os::windows::ffi::EncodeWide`, which was not present before. This is due to the fact that `core` requires `Debug` implementations for all types, but `std` does not (yet) require this. Even though this was ultimately changed to be a wrapper over the original type, not a re-export, I decided to keep the `Debug` implementation so it remains useful.

Like we do with ordinary strings, the tests are still located entirely in `alloc`, rather than splitting them into `core` and `alloc`.

----

Reviewer note: for ease of review, this is split into three commits:

1. Moving the original files into their new "locations"
2. Actually modifying the code to compile.
3. Removing aesthetic changes that were made so that the diff for commit 2 was readable.

You can review commits 1 and 3 to verify these claims, but commit 2 contains the majority of the changes you should care about.

----

API changes: `impl Debug for std::os::windows::ffi::EncodeWide`
2025-08-27 07:45:56 +02:00
Tobias Stoeckmann
45296bb633 Fix typo in comment
Turn "any heap allocators" into "any heap allocator".
2025-08-26 22:58:44 +02:00
Guillaume Gomez
9bb7d17d9a Rollup merge of #144373 - hkBst:remove-deprecated-1, r=jhpratt
remove deprecated Error::description in impls

[libs-api permission](https://github.com/rust-lang/libs-team/issues/615#issuecomment-3074045829)

r? `@cuviper`
or `@jhpratt`
2025-08-26 16:34:09 +02:00
Marijn Schouten
845311a065 remove deprecated Error::description in impls 2025-08-26 06:36:53 +00:00
Marijn Schouten
1b77387085 Prevent confusion with insertion-ordered maps. 2025-08-24 10:50:20 +00:00
Marijn Schouten
bb7993f807 focus more on ordered aspect and restore old comments 2025-08-24 10:50:20 +00:00
Marijn Schouten
3f339ab849 Dial down detail of B-tree description
fixes 134088, though it is a shame to lose some of this wonderful detail.
2025-08-24 10:50:20 +00:00
ltdk
7c81a067ea Diff-massaging commit 2025-08-20 20:31:33 -04:00
ltdk
2914291e09 Move WTF-8 code from std to core/alloc 2025-08-20 20:31:33 -04:00
ltdk
5a2fceefd3 Copy WTF-8 code into core/alloc (for better diffs) 2025-08-20 20:31:33 -04:00
bors
040a98af70 Auto merge of #144086 - clubby789:alloc-zeroed, r=nikic
Pass `alloc-variant-zeroed` to LLVM

Makes use of https://github.com/llvm/llvm-project/pull/138299 (once we pull in a version of LLVM with this attribute). ~~Unfortunately also requires https://github.com/llvm/llvm-project/pull/149336 to work.~~

Closes rust-lang/rust#104847
2025-08-20 17:16:34 +00:00
clubby789
8ea3b09381 Pass alloc-variant-zeroed to LLVM 2025-08-20 17:08:46 +01:00
Tobias Bucher
cb5a4d138a Use ToString specialization macro also for Cow and String 2025-08-19 17:35:56 +02:00
Tobias Bucher
6a24ae96ea Simplify macro generating ToString implementations for &…&str
Use deref coercion to let the compiler remove any amount of references.
2025-08-19 17:35:55 +02:00
Jacob Pratt
41e40f3630 Rollup merge of #143717 - Jules-Bertholet:pin-default, r=dtolnay
Add `Default` impls for `Pin`ned `Box`, `Rc`, `Arc`

Fixes rust-lang/rust#143688.

`@rustbot` label T-libs-api needs-fcp

Also needs a crater run, as the `Box` impls could theoretically be breaking due to `#[fundamental]` (though a [cursory search](https://github.com/search?q=%2Fimpl%28%3C.*%3E%29%3F+Default+for+Pin%3C%2F+path%3A*.rs&type=code) suggests this is unlikely to cause issues).
2025-08-15 18:13:26 -04:00
ltdk
d6945f6d8c Add cast_init and cast_uninit methods for pointers 2025-08-12 16:57:56 -04:00
SabrinaJewson
1ce4b370e4 Handle the capacity == 0 case 2025-08-12 05:12:34 +01:00
SabrinaJewson
45e2449b2a Respond to review comments 2025-08-11 19:02:00 +01:00
SabrinaJewson
19df24b3b8 Make explicit guarantees about Vec’s allocator
This commit amends the documentation of `Vec::as_mut_ptr` and
`Vec::into_raw_parts` to make it explicit that such calls may be paired
with calls to `dealloc` with a suitable layout. This guarantee was
effectively already provided by the docs of `Vec::from_raw_parts`
mentioning `alloc`.

Additionally, we copy-paste and adjust the “Memory layout” section from
the documentation of `std::boxed` to `std::vec`. This explains the allocator
guarantees in more detail.
2025-08-11 17:15:53 +01:00
Ada Alakbarova
c0a3e4802a {BTree,Hash}Map: add "Entry API" section heading 2025-08-09 19:41:32 +02:00
bors
cd434309ef Auto merge of #144997 - BoxyUwU:bootstrap_bump, r=Mark-Simulacrum
bump bootstrap compiler to 1.90 beta

There were significantly less `cfg(bootstrap)` and `cfg(not(bootstrap))` this release. Presumably due to the fact that we change the bootstrap stage orderings to reduce the need for them and it was successful 🙏
2025-08-07 10:56:05 +00:00
Boxy
9ccc9f177e replace version placeholder 2025-08-06 13:22:38 +01:00
Jonathan Brouwer
b3317dd055 Correct the use of must_use on btree::IterMut
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-04 22:20:30 +02:00
Kivooeo
b5a4e5d73f remove gates 2025-08-04 01:24:22 +05:00
Samuel Tardieu
d082ff4c04 Rollup merge of #144478 - joshtriplett:doc-code-formatting-prep, r=Amanieu
Improve formatting of doc code blocks

We don't currently apply automatic formatting to doc comment code blocks. As a
result, it has built up various idiosyncracies, which make such automatic
formatting difficult. Some of those idiosyncracies also make things harder for
human readers or other tools.

This PR makes a few improvements to doc code formatting, in the hopes of making
future automatic formatting easier, as well as in many cases providing net
readability improvements.

I would suggest reading each commit separately, as each commit contains one
class of changes.
2025-08-02 11:24:24 +02:00
Stuart Cook
dc8aec4cf2 Rollup merge of #135975 - balt-dev:master, r=tgross35
Implement `push_mut`

Implementation of rust-lang/rust#135974.
2025-07-31 15:41:58 +10:00
Balt
3ccfa14e48 Implement push_mut 2025-07-30 12:26:16 -05:00
Scott McMurray
173926da2b Remove [T]::array_chunks(_mut) 2025-07-27 23:03:07 -07:00
Josh Triplett
b6c54a97b3 Avoid placing // FIXME comments inside doc code blocks
This leads tools like rustfmt to get confused, because the doc code
block effectively spans two doc comments. As a result, the tools think
the first code block is unclosed, and the subsequent terminator opens a
new block.

Move the FIXME comments outside the doc code blocks, instead.
2025-07-25 22:02:09 -07:00
Josh Triplett
715088094c Improve and regularize comment placement in doc code
Because doc code does not get automatically formatted, some doc code has
creative placements of comments that automatic formatting can't handle.
Reformat those comments to make the resulting code support standard Rust
formatting without breaking; this is generally an improvement to
readability as well.

Some comments are not indented to the prevailing indent, and are instead
aligned under some bit of code. Indent them to the prevailing indent,
and put spaces *inside* the comments to align them with code.

Some comments span several lines of code (which aren't the line the
comment is about) and expect alignment. Reformat them into one comment
not broken up by unrelated intervening code.

Some comments are placed on the same line as an opening brace, placing
them effectively inside the subsequent block, such that formatting would
typically format them like a line of that block. Move those comments to
attach them to what they apply to.

Some comments are placed on the same line as a one-line braced block,
effectively attaching them to the closing brace, even though they're
about the code inside the block. Reformat to make sure the comment will
stay on the same line as the code it's commenting.
2025-07-25 22:02:09 -07:00
Trevor Gross
51c5f191de Remove compiler-builtins-mangled-names
This config was added in 207de019dc ("libary: Forward
compiler-builtins "asm"  and "mangled-names" feature") but it does not
appear this has ever been used. The PR adding it (RUST-78472) says that
this was exposed to help with configuration and points at the [Hermit
Cargo config], but as far as I can tell, this feature name has never
been mentioned in that repository's git history.

Thus, clean up a seemingly unneeded feature.

[Hermit Cargo config]: ab2b830930/.cargo/config
2025-07-25 19:21:20 -05:00
Trevor Gross
a076bd8a61 Remove compiler-builtins-no-asm
This feature used to be for when Cranelift didn't support inline
assembly, but its last uses were removed in 52933e0bd2 ("Don't disable
inline asm usage in compiler-builtins when the cranelift backend is
enabled"). and cba05a7a14 ("Support naked functions").

This doesn't remove the feature from the `compiler-builtins` crate, that
will be done separately in the subtree repo.
2025-07-25 17:08:57 -05:00
Guillaume Gomez
a27f3e3fd1 Rename tests/codegen into tests/codegen-llvm 2025-07-22 14:28:48 +02:00
Thalia Archibald
175afd7618 Stabilize new_zeroed_alloc 2025-07-19 20:25:35 -07:00
Matthias Krüger
744ca5959a Rollup merge of #143909 - nik-rev:patch-1, r=jhpratt
docs(alloc::fmt): Make type optional, instead of matching empty string

Think this is clearer.

Noticed as I was implementing [`tree-sitter-rust-format-args`](https://github.com/nik-rev/tree-sitter-rust-format-args), and attempting to match the empty string results in an error.
2025-07-18 14:49:19 +02:00
León Orell Valerian Liehr
83288db888 Rollup merge of #143595 - fee1-dead-contrib:push-sylpykzkmynr, r=RalfJung,fee1-dead
add `const_make_global`; err for `const_allocate` ptrs if didn't call

Implements as discussed on Zulip: [#t-compiler/const-eval > const heap](https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/const.20heap/with/527125421)

r? ```@rust-lang/wg-const-eval```

Fixes https://github.com/rust-lang/rust/issues/129233
2025-07-17 03:58:30 +02:00
Jules Bertholet
87dd4695fe Add Default impls for Pinned Box, Rc, Arc 2025-07-15 17:41:31 -04:00
Deadbeef
3f2dc2bd1a add const_make_global; err for const_allocate ptrs if didn't call
Co-Authored-By: Ralf Jung <post@ralfj.de>
Co-Authored-By: Oli Scherer <github333195615777966@oli-obk.de>
2025-07-16 00:32:12 +08:00
bors
3014e79f9c Auto merge of #143877 - xizheyin:143813, r=scottmcm,saethlin
`std::vec`: Add UB check for `set_len`, `from_raw_parts_in`, and etc.

Closes rust-lang/rust#143813

I noticed that `from_parts_in` do the similar things like `from_raw_parts_in`, so I add the UB check in the last commit. If it is not appropriate, I will remove it.

And I fix a typo in the first commit.

r? `@scottmcm`
2025-07-15 14:47:10 +00:00
Nik Revenco
f5485e5564 docs(alloc::fmt): Make type optional, instead of matching the empty string 2025-07-13 23:24:27 +01:00
Deadbeef
6b02597ed3 update issue number for const_trait_impl 2025-07-13 23:55:06 +08:00
xizheyin
48caa5f889 std::vec: Add UB check in from_parts_in
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-13 16:18:56 +08:00
xizheyin
090c177003 std::vec: Add UB check in from_raw_parts_in
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-13 16:17:43 +08:00
xizheyin
1cab09ed9c std::vec: Upgrade debug_assert to UB check in set_len
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-13 16:06:53 +08:00
xizheyin
10866f4617 Fix typo in std::vec
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-13 15:51:32 +08:00
bors
f838cbc06d Auto merge of #134628 - estebank:const-default, r=oli-obk
Make `Default` const and add some `const Default` impls

Full list of `impl const Default` types:

- ()
- bool
- char
- std::ascii::Char
- usize
- u8
- u16
- u32
- u64
- u128
- i8
- i16
- i32
- i64
- i128
- f16
- f32
- f64
- f128
- std::marker::PhantomData<T>
- Option<T>
- std::iter::Empty<T>
- std::ptr::Alignment
- &[T]
- &mut [T]
- &str
- &mut str
- String
- Vec<T>
2025-07-08 14:04:40 +00:00
Matthias Krüger
fd05071727 Rollup merge of #143608 - codexarafat:fix-string-doc, r=Noratrieb
Fix in std::String docs

This PR removes the word “else” from the sentence ('something else similar') in the String documentation to improve clarity.
Fixes rust-lang/rust#143579.
2025-07-08 03:09:59 +02:00
Matthias Krüger
d41f046de5 Rollup merge of #142098 - GuillaumeGomez:int_format_into, r=Amanieu
Implement `int_format_into` feature

I took over rust-lang/rust#138338 with `@madhav-madhusoodanan's` approval.

Since https://github.com/rust-lang/rust/pull/136264, a lot of changes happened so I made use of them to reduce the number of changes.

ACP approval: https://github.com/rust-lang/libs-team/issues/546#issuecomment-2707244569

## Associated Issue
- https://github.com/rust-lang/rust/issues/138215

r? `@hanna-kruppe`
2025-07-08 03:09:56 +02:00
Esteban Küber
c3301503b9 Make Default const and add some const Default impls
Full list of `impl const Default` types:

- ()
- bool
- char
- Cell
- std::ascii::Char
- usize
- u8
- u16
- u32
- u64
- u128
- i8
- i16
- i32
- i64
- i128
- f16
- f32
- f64
- f128
- std::marker::PhantomData<T>
- Option<T>
- std::iter::Empty<T>
- std::ptr::Alignment
- &[T]
- &mut [T]
- &str
- &mut str
- String
- Vec<T>
2025-07-07 22:09:37 +00:00