John Millikin
82a9f94de5
Closure-consuming helper functions for fmt::Debug
helpers
2023-11-10 07:50:11 +09:00
Matt Harding
19caba0008
Remove trailing whitespace
2023-11-09 07:00:31 +00:00
Matt Harding
9bfe49e00a
Add note on how 0 flag overrides fill character
2023-11-09 06:31:50 +00:00
Matt Harding
c493634064
Add link to Formatting traits from alternate forms
2023-11-08 14:56:35 +00:00
Niklas Fiekas
0bccdb34a2
Stabilize slice_group_by
...
Renamed "group by" to "chunk by" a per #80552 .
Newly stable items:
* `core::slice::ChunkBy`
* `core::slice::ChunkByMut`
* `[T]::chunk`
* `[T]::chunk_by`
Closes #80552 .
2023-11-07 17:46:00 +01:00
bors
da1e0d1d75
Auto merge of #116218 - tgross35:const-maybe-uninit-zeroed, r=dtolnay
...
Stabilize `const_maybe_uninit_zeroed` and `const_mem_zeroed`
Make `MaybeUninit::zeroed` and `mem::zeroed` const stable. Newly stable API:
```rust
// core::mem
pub const unsafe fn zeroed<T>() ->;
impl<T> MaybeUninit<T> {
pub const fn zeroed() -> MaybeUninit<T>;
}
```
This relies on features based around `const_mut_refs`. Per `@RalfJung,` this should be OK since we do not leak any `&mut` to the user.
For this to be possible, intrinsics `assert_zero_valid` and `assert_mem_uninitialized_valid` were made const stable.
Tracking issue: #91850
Zulip discussion: https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60const_mut_refs.60.20dependents
r? libs-api
`@rustbot` label -T-libs +T-libs-api +A-const-eval
cc `@RalfJung` `@oli-obk` `@rust-lang/wg-const-eval`
2023-11-05 05:56:21 +00:00
bors
f5ca57e153
Auto merge of #117503 - kornelski:hint-try-reserved, r=workingjubilee
...
Hint optimizer about try-reserved capacity
This is #116568 , but limited only to the less-common `try_reserve` functions to reduce bloat in debug binaries from debug info, while still addressing the main use-case #116570
2023-11-05 00:03:41 +00:00
Trevor Gross
f6ce646d3f
Stabilize const_maybe_uninit_zeroed
...
Make `MaybeUninit::zeroed` const stable. Newly stable API:
// core::mem
impl<T> MaybeUninit<T> {
pub const fn zeroed() -> MaybeUninit<T>;
}
Use of `const_mut_refs` should be acceptable since we do not leak the
mutability.
Tracking issue: #91850
2023-11-04 15:27:25 -04:00
alpharush
c7d8c65c1a
docs: clarify explicitly freeing heap allocated memory
2023-11-04 03:00:43 -05:00
ltdk
8337e86b28
Add insta-stable std: #️⃣ :{DefaultHasher, RandomState} exports
2023-11-02 20:35:20 -04:00
Kornel
029fbd67ef
Hint optimizer about reserved capacity
2023-11-02 00:52:06 +00:00
Bugen Zhao
c872ccc510
delegate box error provide
...
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
2023-10-31 16:35:59 +08:00
bors
bcb5798dd8
Auto merge of #117332 - saethlin:panic-immediate-abort, r=workingjubilee
...
Increase the reach of panic_immediate_abort
I wanted to use/abuse this recently as part of another project, and I was surprised how many panic-related things were left in my binaries if I built a large crate with the feature enabled along with LTO. These changes get all the panic-related symbols that I could find out of my set of locally installed Rust utilities.
2023-10-30 00:03:47 +00:00
Ben Kimock
2e7364a586
Increase the reach of panic_immediate_abort
2023-10-29 09:31:07 -04:00
coekjan
4dd7568a97
mark constructor of BinaryHeap
as const fn
2023-10-28 21:30:43 +08:00
Maybe Waffle
e36224118f
Stabilize [const_]pointer_byte_offsets
2023-10-25 22:35:12 +00:00
Gimbles
695beca219
Update boxed.rs
2023-10-21 23:41:32 +05:30
Oli Scherer
e96ce20b34
s/generator/coroutine/
2023-10-20 21:14:01 +00:00
Oli Scherer
60956837cf
s/Generator/Coroutine/
2023-10-20 21:10:38 +00:00
Muhammad Hamza
540921e468
Stablize arc_unwrap_or_clone
2023-10-19 22:40:08 +05:00
Ben Kimock
33b0e4be06
Automatically enable cross-crate inlining for small functions
2023-10-17 19:53:51 -04:00
Arthur Carcano
0bcac8a7f2
Add invariant to Vec::pop that len < cap if pop successful
...
Fixes: https://github.com/rust-lang/rust/issues/114334
2023-10-16 18:49:25 +02:00
bors
39acbed8d6
Auto merge of #116407 - Mark-Simulacrum:bootstrap-bump, r=onur-ozkan
...
Bump bootstrap compiler to just-released beta
https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2023-10-14 05:44:48 +00:00
bors
6d05c430d2
Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease
...
rustdoc: show crate name beside smaller logo
*Blocked on https://github.com/rust-lang/cargo/pull/12800 *
## Summary
In this PR, the crate name and version are always shown in the sidebar, even in subpages, and the lateral navigation is always shown in the sidebar, even in modules.
Clicking the crate name does the same thing clicking the logo always did: take you to the crate root (the crate's home page, at least within Rustdoc).
The Rust logo is also no longer shown by default for non-Rust docs.
### Screenshots
<details><summary>Before</summary>
| | Macro | Module |
|--|-------|--------|
| In crate |  |
| In module[^1] |  | 
[^1]: This PR also includes a bug fix for derive macros not showing up in the lateral navigation part of the sidebar
</details>
#### Whole sidebar screenshots
| | Macro | Module |
|--|-------|--------|
| In crate |  | 
| In module |  | 
#### Different logo configurations
| | Short crate name | Long crate name |
|---------|------------------|-----------------|
| Root | ![short-root] | ![long-root]
| Subpage | ![short-subpage] | ![long-subpage]
[short-root]: https://github.com/rust-lang/rust/assets/1593513/9e2b4fa8-f581-4106-b562-1e0372c13f79
[short-subpage]: https://github.com/rust-lang/rust/assets/1593513/8331cdb8-fa13-4671-a1e2-dcc1cdca7451
[long-root]: https://github.com/rust-lang/rust/assets/1593513/7d377fec-0f1d-4343-9f82-0e35a8f58056
[long-subpage]: https://github.com/rust-lang/rust/assets/1593513/3b3094a4-63c9-477c-8c15-b6075837df30
##### Without a logo

### Preview pages
https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket/index.html
https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket_sync_db_pools/index.html
https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust-compiler/index.html
https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust/std/index.html
https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/tokio/index.html
## Motivation
This improves visual information density (the construct with the logo and crate name is *shorter* than the logo on its own, because it's not square) and navigation clarity (we can now see what clicking the Rust logo does, specifically).
Compare this with the layout at [Phoenix's Hexdocs] (which is what this proposal is closely based on), the old proposal on [Internals Discourse] (which always says "Rust standard library" in the sidebar, but doesn't do the side-by-side layout).
[Phoenix's Hexdocs]: https://hexdocs.pm/phoenix/1.7.7/overview.html
[Internals Discourse]: https://internals.rust-lang.org/t/poc-of-a-new-design-for-the-generated-rustdoc/11018
## Guide-level explanation
This PR cleans up some of the sidebar navigation.
It makes the logo in the desktop sidebar a bit smaller, and puts the crate name and version next to it (either beside it, or below it, depending on if there's space), making it clearer what clicking on it does: click the crate name to open the crate's home page. It also removes the Rust logo from non-official-Rust crates, again to make the navigation and supply chain clearer (since the crate name has been added, the logo is no longer necessary for navigation).
It adds a bit more clarifying information for lateral navigation. On items that don't add their own sidebar items, it just shows its siblings directly below the crate name and logo, but for other items, it shows "In crate alloc" instead of just "In alloc". It also shows the lateral navigation tools on module pages, making modules consistent with every other item.
## Drawbacks
While this actually takes up less screen real estate than the old layout on desktop, it takes up more HTML. It's also a bit more visually complex.
## Rationale and alternatives
I could do what the Internals POC did and keep the vertically stacked layout all the time, instead of doing a horizontal stack where possible. It would take up more screen real estate, though.
## Prior art
This design is lifted almost verbatim from Hexdocs. It seems to work for them. [`opentelemetry_process_propagator`], for example, has a long application name.
[`opentelemetry_process_propagator`]: https://hexdocs.pm/opentelemetry_process_propagator/OpentelemetryProcessPropagator.html
## Unresolved questions
Maybe we should encourage crate authors to include their own logo more often? It certainly helps give people a better sense of "place." This seems to be blocked on coming up with an API to do it without requiring them to host the file somewhere.
## Future possibilities
Beyond this, plenty of other changes could be made to improve the layout, like
* Fix things so that clicking an item in the sidebar doesn't cause it to scroll back to the top.
* The [Internals demo](https://utherii.github.io/new.html ) does this right: clicking an item in the sidebar changes the content area, but the sidebar itself does not change. This is nice, because clicking is cheap and I can skim the opening few paragraphs while browsing.
* The layout of the docs sidebar causes trouble to implement this, because it's different on different pages, but at least fix this on the file browser.
* Come up with a less cluttered way to do disclosure. There's a lot of `[-]` on the page.
* We don't lack ideas to fix this one. We have *too many*.
* Do a better job of separating local navigation (vec::Vec links to vec::IntoIter) and the table of contents (vec::Vec links to vec::Vec::new).
* A possibility: add a Back arrow next to the "In [module]" header?

* Give readers more control of how much rustdoc shows them, and giving doc authors more control of how much it generates. Basically, https://github.com/rust-lang/rust/pull/115660 is great, let's do it too.
But those are mostly orthogonal, not future possibilities unlocked by this change.
2023-10-11 06:28:36 +00:00
Ali MJ Al-Nasrawy
38654ad741
Rollup merge of #95967 - CAD97:from-utf16, r=dtolnay
...
Add explicit-endian String::from_utf16 variants
This adds the following APIs under `feature(str_from_utf16_endian)`:
```rust
impl String {
pub fn from_utf16le(v: &[u8]) -> Result<String, FromUtf16Error>;
pub fn from_utf16le_lossy(v: &[u8]) -> String;
pub fn from_utf16be(v: &[u8]) -> Result<String, FromUtf16Error>;
pub fn from_utf16be_lossy(v: &[u8]) -> String;
}
```
These are versions of `String::from_utf16` that explicitly take [UTF-16LE and UTF-16BE](https://unicode.org/faq/utf_bom.html#gen7 ). Notably, we can do better than just the obvious `decode_utf16(v.array_chunks::<2>().copied().map(u16::from_le_bytes)).collect()` in that:
- We handle the case where the byte slice is not an even number of bytes, and
- In the case that the UTF-16 is native endian and the slice is aligned, we can forward to `String::from_utf16`.
If the Unicode Consortium actively defines how to handle character replacement when decoding a UTF-16 bytestream with a trailing odd byte, I was unable to find reference. However, the behavior implemented here is fairly self-evidently correct: replace the single errant byte with the replacement character.
2023-10-11 03:53:16 +03:00
Sven Bartscher
d60b43c06a
Make BTreeSet::new_in const
2023-10-09 11:17:56 +02:00
Sven Bartscher
bbc230478c
Make BTreeMap::new_in const
...
Closes rust-lang/wg-allocators#118
2023-10-09 11:08:48 +02:00
Michael Howell
c6e6ecb1af
rustdoc: remove rust logo from non-Rust crates
2023-10-08 20:17:53 -07:00
Mark Rousskov
ea1066d0be
Bump to latest beta
2023-10-08 19:57:43 -04:00
Jason Newcomb
d464b72970
Add more diagnostic items for clippy
2023-10-05 18:21:47 -04:00
Jubilee
ea3454eabb
Rollup merge of #116223 - catandcoder:master, r=cjgillot
...
Fix misuses of a vs an
Fixes the misuse of "a" vs "an", according to English grammatical
expectations and using https://www.a-or-an.com/
2023-10-05 00:56:29 -07:00
Mark Rousskov
787d32324c
Bump version placeholders
2023-10-03 20:26:36 -04:00
cui fliter
f44d116e1f
Fix misuses of a vs an
...
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-10-04 08:01:11 +08:00
Scott McMurray
f8fc0d7716
Use addr_eq
in {Arc,Rc}::ptr_eq
...
Since it's made for stuff like this (see 106447)
2023-10-02 17:32:01 -07:00
bors
4efd65571e
Auto merge of #115546 - SUPERCILEX:patch-2, r=Amanieu
...
Weaken needlessly restrictive orderings on Arc::*_count
Follow up to https://github.com/rust-lang/rust/pull/95183 from this zulip: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Why.20does.20Arc.3A.3Astrong_count.20use.20Acquire.20instead.20of.20Relaxed.3F/near/386213850
I'd like to use the strong_count for a lockless algorithm I'm writing, but I don't need acquire semantics so that's pointlessly restrictive on arm/risc-v.
2023-09-30 02:15:19 +00:00
Christopher Durham
5facc32e22
fix char imports
2023-09-29 00:04:57 -04:00
Christopher Durham
1efea31385
add str_from_utf16_endian tracking issue
2023-09-28 23:56:27 -04:00
Christopher Durham
3d448bd067
style nits
...
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2023-09-28 23:56:10 -04:00
CAD97
8047f8fb51
Add feature(str_from_utf16_endian)
2023-09-28 23:54:38 -04:00
bors
46da927abb
Auto merge of #114041 - nvzqz:nvzqz/shared_from_array, r=dtolnay
...
Implement `From<[T; N]>` for `Rc<[T]>` and `Arc<[T]>`
Given that `Box<[T]>` already has this conversion, the shared counterparts should also have it.
2023-09-28 06:16:01 +00:00
bors
aeaa5c30e5
Auto merge of #111278 - EFanZh:implement-from-array-refs-for-vec, r=dtolnay
...
Implement `From<{&,&mut} [T; N]>` for `Vec<T>` where `T: Clone`
Currently, if `T` implements `Clone`, we can create a `Vec<T>` from an `&[T]` or an `&mut [T]`, can we also support creating a `Vec<T>` from an `&[T; N]` or an `&mut [T; N]`? Also, do I need to add `#[inline]` to the implementation?
ACP: rust-lang/libs-team#220. [Accepted]
Closes #100880 .
2023-09-28 04:26:40 +00:00
Dylan DPC
6011fd4655
Rollup merge of #115477 - kellerkindt:stabilized_int_impl, r=dtolnay
...
Stabilize the `Saturating` type
Closes #87920
Closes #92354
Stabilization report https://github.com/rust-lang/rust/issues/87920#issuecomment-1652346124
FCP https://github.com/rust-lang/rust/issues/87920#issuecomment-1676438885
2023-09-17 11:23:24 +00:00
Matthias Krüger
e2ea347517
Rollup merge of #115895 - 52:patch-docs-vec-truncate, r=dtolnay
...
Improve Vec(Deque)::truncate documentation
Fixes #115784
2023-09-16 23:20:43 +02:00
Matthias Krüger
633f143921
Rollup merge of #115560 - ShE3py:format-results, r=dtolnay
...
Update doc for `alloc::format!` and `core::concat!`
Closes #115551 .
Used comments instead of `assert!`s as [`std::fmt`](https://doc.rust-lang.org/std/fmt/index.html#usage ) uses comments.
Should all the str-related macros (`format!`, `format_args!`, `concat!`, `stringify!`, `println!`, `writeln!`, etc.) references each others? For instance, [`concat!`](https://doc.rust-lang.org/core/macro.concat.html ) mentions that integers are stringified, but don't link to `stringify!`.
`@rustbot` label +A-docs +A-fmt
2023-09-16 23:20:41 +02:00
Matthias Krüger
b8c4b78a79
Rollup merge of #115487 - ModProg:patch-1, r=dtolnay
...
Improve documentation on when signes are printed by default
I found the original formulation a bit irritating, but not sure if I really improved it.
2023-09-16 23:20:40 +02:00
mxnkarou
1c7a77a638
edit std::collections::VecDeque
docs
2023-09-16 15:52:34 +02:00
mxnkarou
d1ff5e174b
edit std::vec::Vec::truncate
docs
2023-09-16 15:46:31 +02:00
bors
635c4a5e61
Auto merge of #114494 - est31:extend_useless_ptr_null_checks, r=jackh726
...
Make useless_ptr_null_checks smarter about some std functions
This teaches the `useless_ptr_null_checks` lint that some std functions can't ever return null pointers, because they need to point to valid data, get references as input, etc.
This is achieved by introducing an `#[rustc_never_returns_null_ptr]` attribute and adding it to these std functions (gated behind bootstrap `cfg_attr`).
Later on, the attribute could maybe be used to tell LLVM that the returned pointer is never null. I don't expect much impact of that though, as the functions are pretty shallow and usually the input data is already never null.
Follow-up of PR #113657
Fixes #114442
2023-09-16 03:40:20 +00:00
ShE3py
94e651b9b2
Update doc for alloc::format!
and core::concat!
2023-09-06 15:11:21 +02:00
Alex Saveau
4c2f1c615b
Weaken needlessly restrictive orderings on Arc::*_count
...
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-09-04 21:48:51 +01:00