Skip to content

Commit a609d38

Browse files
bors-ferrocene[bot]ouz-aKobzolFedericoStrabvanjoi
authored
Merge #23
23: Fix divergence from upstream `master` r=tshepang a=pvdrz * rust-lang/rust#116381 * rust-lang/rust#116360 * rust-lang/rust#116353 * rust-lang/rust#116406 * rust-lang/rust#116408 * rust-lang/rust#116395 * rust-lang/rust#116393 * rust-lang/rust#116388 * rust-lang/rust#116365 * rust-lang/rust#116363 * rust-lang/rust#116146 * rust-lang/rust#115961 * rust-lang/rust#116386 * rust-lang/rust#116367 * rust-lang/rust#105394 * rust-lang/rust#115301 * rust-lang/rust#116384 * rust-lang/rust#116379 * rust-lang/rust#116328 * rust-lang/rust#116282 * rust-lang/rust#116261 * rust-lang/rust#114654 * rust-lang/rust#116376 * rust-lang/rust#116374 * rust-lang/rust#116371 * rust-lang/rust#116358 * rust-lang/rust#116210 * rust-lang/rust#115863 * rust-lang/rust#115025 * rust-lang/rust#116372 * rust-lang/rust#116361 * rust-lang/rust#116355 * rust-lang/rust#116351 * rust-lang/rust#116158 * rust-lang/rust#115726 * rust-lang/rust#113053 * rust-lang/rust#116083 * rust-lang/rust#102099 * rust-lang/rust#116356 * rust-lang/rust#116350 * rust-lang/rust#116349 * rust-lang/rust#116289 * rust-lang/rust#114454 * rust-lang/rust#114453 * rust-lang/rust#116331 * rust-lang/rust#116346 * rust-lang/rust#116340 * rust-lang/rust#116326 * rust-lang/rust#116313 * rust-lang/rust#116276 * rust-lang/rust#115898 * rust-lang/rust#116325 * rust-lang/rust#116317 * rust-lang/rust#116207 * rust-lang/rust#116281 * rust-lang/rust#116304 * rust-lang/rust#116259 * rust-lang/rust#116228 * rust-lang/rust#116224 * rust-lang/rust#115554 * rust-lang/rust#116311 * rust-lang/rust#116299 * rust-lang/rust#116295 * rust-lang/rust#116292 * rust-lang/rust#116307 * rust-lang/rust#115670 * rust-lang/rust#116225 * rust-lang/rust#116302 * rust-lang/rust#116108 * rust-lang/rust#116160 * rust-lang/rust#116157 * rust-lang/rust#116127 * rust-lang/rust#116286 * rust-lang/rust#116254 * rust-lang/rust#116195 * rust-lang/rust#116280 * rust-lang/rust#115933 * rust-lang/rust#115546 * rust-lang/rust#115368 * rust-lang/rust#116275 * rust-lang/rust#116263 * rust-lang/rust#116241 * rust-lang/rust#116216 * rust-lang/rust#116030 * rust-lang/rust#116024 * rust-lang/rust#112123 * rust-lang/rust#113301 * rust-lang/rust#113797 * rust-lang/rust#115759 * rust-lang/rust#116260 * rust-lang/rust#116253 * rust-lang/rust#116245 * rust-lang/rust#116239 * rust-lang/rust#116234 * rust-lang/rust#116231 * rust-lang/rust#116201 * rust-lang/rust#116133 * rust-lang/rust#116176 * rust-lang/rust#116089 * rust-lang/rust#115986 Co-authored-by: ouz-a <[email protected]> Co-authored-by: Jakub Beránek <[email protected]> Co-authored-by: Federico Stra <[email protected]> Co-authored-by: bohan <[email protected]> Co-authored-by: Jason Newcomb <[email protected]> Co-authored-by: Ralf Jung <[email protected]> Co-authored-by: bors <[email protected]> Co-authored-by: Oli Scherer <[email protected]>
2 parents 2a5ef32 + 122b741 commit a609d38

File tree

527 files changed

+6649
-3246
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

527 files changed

+6649
-3246
lines changed

.mailmap

+2
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ Nilstrieb <[email protected]> nils <48135649+Nilstrieb
429429
430430
431431
432+
433+
432434
433435
434436

.reuse/dep5

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Files: compiler/*
2323
README.md
2424
RELEASES.md
2525
rustfmt.toml
26+
rust-bors.toml
2627
triagebot.toml
2728
x
2829
x.ps1

Cargo.lock

+27-12
Original file line numberDiff line numberDiff line change
@@ -2643,9 +2643,9 @@ checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
26432643

26442644
[[package]]
26452645
name = "jemalloc-sys"
2646-
version = "0.5.3+5.3.0-patched"
2646+
version = "0.5.4+5.3.0-patched"
26472647
source = "registry+https://github.com/rust-lang/crates.io-index"
2648-
checksum = "f9bd5d616ea7ed58b571b2e209a65759664d7fb021a0819d7a790afc67e47ca1"
2648+
checksum = "ac6c1946e1cea1788cbfde01c993b52a10e2da07f4bac608228d1bed20bfebf2"
26492649
dependencies = [
26502650
"cc",
26512651
"libc",
@@ -2768,6 +2768,16 @@ dependencies = [
27682768
"winapi",
27692769
]
27702770

2771+
[[package]]
2772+
name = "libloading"
2773+
version = "0.8.1"
2774+
source = "registry+https://github.com/rust-lang/crates.io-index"
2775+
checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161"
2776+
dependencies = [
2777+
"cfg-if",
2778+
"windows-sys 0.48.0",
2779+
]
2780+
27712781
[[package]]
27722782
name = "libm"
27732783
version = "0.1.4"
@@ -3043,15 +3053,15 @@ dependencies = [
30433053
"lazy_static",
30443054
"libc",
30453055
"libffi",
3046-
"libloading",
3056+
"libloading 0.8.1",
30473057
"log",
30483058
"measureme",
30493059
"rand",
30503060
"regex",
30513061
"rustc_version",
30523062
"serde",
30533063
"smallvec",
3054-
"ui_test 0.11.7",
3064+
"ui_test 0.21.2",
30553065
]
30563066

30573067
[[package]]
@@ -4667,7 +4677,7 @@ dependencies = [
46674677
name = "rustc_interface"
46684678
version = "0.0.0"
46694679
dependencies = [
4670-
"libloading",
4680+
"libloading 0.7.4",
46714681
"rustc-rayon",
46724682
"rustc-rayon-core",
46734683
"rustc_ast",
@@ -4798,7 +4808,7 @@ name = "rustc_metadata"
47984808
version = "0.0.0"
47994809
dependencies = [
48004810
"bitflags 1.3.2",
4801-
"libloading",
4811+
"libloading 0.7.4",
48024812
"odht",
48034813
"rustc_ast",
48044814
"rustc_attr",
@@ -5013,7 +5023,7 @@ dependencies = [
50135023
name = "rustc_plugin_impl"
50145024
version = "0.0.0"
50155025
dependencies = [
5016-
"libloading",
5026+
"libloading 0.7.4",
50175027
"rustc_ast",
50185028
"rustc_errors",
50195029
"rustc_fluent_macro",
@@ -6543,18 +6553,23 @@ checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81"
65436553

65446554
[[package]]
65456555
name = "ui_test"
6546-
version = "0.11.7"
6556+
version = "0.20.0"
65476557
source = "registry+https://github.com/rust-lang/crates.io-index"
6548-
checksum = "c21899b59f53717dfad29e4f46e5b21a200a1b6888ab86532a07cfc8b48dd78c"
6558+
checksum = "bfd8fb9b15c8332cf51bfc2dc4830063b2446a9c9d732421b56f2478024a3971"
65496559
dependencies = [
6560+
"annotate-snippets",
6561+
"anyhow",
65506562
"bstr",
65516563
"cargo-platform",
65526564
"cargo_metadata",
65536565
"color-eyre",
65546566
"colored",
6567+
"comma",
65556568
"crossbeam-channel",
6556-
"diff",
6569+
"indicatif",
65576570
"lazy_static",
6571+
"levenshtein",
6572+
"prettydiff",
65586573
"regex",
65596574
"rustc_version",
65606575
"rustfix",
@@ -6565,9 +6580,9 @@ dependencies = [
65656580

65666581
[[package]]
65676582
name = "ui_test"
6568-
version = "0.20.0"
6583+
version = "0.21.2"
65696584
source = "registry+https://github.com/rust-lang/crates.io-index"
6570-
checksum = "bfd8fb9b15c8332cf51bfc2dc4830063b2446a9c9d732421b56f2478024a3971"
6585+
checksum = "aaf4bf7c184b8dfc7a4d3b90df789b1eb992ee42811cd115f32a7a1eb781058d"
65716586
dependencies = [
65726587
"annotate-snippets",
65736588
"anyhow",

RELEASES.md

+117
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,120 @@
1+
Version 1.73.0 (2023-10-05)
2+
==========================
3+
4+
<a id="1.73.0-Language"></a>
5+
6+
Language
7+
--------
8+
9+
- [Uplift `clippy::fn_null_check` lint as `useless_ptr_null_checks`.](https://github.com/rust-lang/rust/pull/111717/)
10+
- [Make `noop_method_call` warn by default.](https://github.com/rust-lang/rust/pull/111916/)
11+
- [Support interpolated block for `try` and `async` in macros.](https://github.com/rust-lang/rust/pull/112953/)
12+
- [Make `unconditional_recursion` lint detect recursive drops.](https://github.com/rust-lang/rust/pull/113902/)
13+
- [Future compatibility warning for some impls being incorrectly considered not overlapping.](https://github.com/rust-lang/rust/pull/114023/)
14+
- [The `invalid_reference_casting` lint is now **deny-by-default** (instead of allow-by-default)](https://github.com/rust-lang/rust/pull/112431)
15+
16+
<a id="1.73.0-Compiler"></a>
17+
18+
Compiler
19+
--------
20+
21+
- [Write version information in a `.comment` section like GCC/Clang.](https://github.com/rust-lang/rust/pull/97550/)
22+
- [Add documentation on v0 symbol mangling.](https://github.com/rust-lang/rust/pull/97571/)
23+
- [Stabilize `extern "thiscall"` and `"thiscall-unwind"` ABIs.](https://github.com/rust-lang/rust/pull/114562/)
24+
- [Only check outlives goals on impl compared to trait.](https://github.com/rust-lang/rust/pull/109356/)
25+
- [Infer type in irrefutable slice patterns with fixed length as array.](https://github.com/rust-lang/rust/pull/113199/)
26+
- [Discard default auto trait impls if explicit ones exist.](https://github.com/rust-lang/rust/pull/113312/)
27+
- Add several new tier 3 targets:
28+
- [`aarch64-unknown-teeos`](https://github.com/rust-lang/rust/pull/113480/)
29+
- [`csky-unknown-linux-gnuabiv2`](https://github.com/rust-lang/rust/pull/113658/)
30+
- [`riscv64-linux-android`](https://github.com/rust-lang/rust/pull/112858/)
31+
- [`riscv64gc-unknown-hermit`](https://github.com/rust-lang/rust/pull/114004/)
32+
- [`x86_64-unikraft-linux-musl`](https://github.com/rust-lang/rust/pull/113411/)
33+
- [`x86_64-unknown-linux-ohos`](https://github.com/rust-lang/rust/pull/113061/)
34+
- [Add `wasm32-wasi-preview1-threads` as a tier 2 target.](https://github.com/rust-lang/rust/pull/112922/)
35+
36+
Refer to Rust's [platform support page][platform-support-doc]
37+
for more information on Rust's tiered platform support.
38+
39+
<a id="1.73.0-Libraries"></a>
40+
41+
Libraries
42+
---------
43+
44+
- [Add `Read`, `Write` and `Seek` impls for `Arc<File>`.](https://github.com/rust-lang/rust/pull/94748/)
45+
- [Merge functionality of `io::Sink` into `io::Empty`.](https://github.com/rust-lang/rust/pull/98154/)
46+
- [Implement `RefUnwindSafe` for `Backtrace`](https://github.com/rust-lang/rust/pull/100455/)
47+
- [Make `ExitStatus` implement `Default`](https://github.com/rust-lang/rust/pull/106425/)
48+
- [`impl SliceIndex<str> for (Bound<usize>, Bound<usize>)`](https://github.com/rust-lang/rust/pull/111081/)
49+
- [Change default panic handler message format.](https://github.com/rust-lang/rust/pull/112849/)
50+
- [Cleaner `assert_eq!` & `assert_ne!` panic messages.](https://github.com/rust-lang/rust/pull/111071/)
51+
- [Correct the (deprecated) Android `stat` struct definitions.](https://github.com/rust-lang/rust/pull/113130/)
52+
53+
<a id="1.73.0-Stabilized-APIs"></a>
54+
55+
Stabilized APIs
56+
---------------
57+
58+
- [Unsigned `{integer}::div_ceil`](https://doc.rust-lang.org/stable/std/primitive.u32.html#method.div_ceil)
59+
- [Unsigned `{integer}::next_multiple_of`](https://doc.rust-lang.org/stable/std/primitive.u32.html#method.next_multiple_of)
60+
- [Unsigned `{integer}::checked_next_multiple_of`](https://doc.rust-lang.org/stable/std/primitive.u32.html#method.checked_next_multiple_of)
61+
- [`std::ffi::FromBytesUntilNulError`](https://doc.rust-lang.org/stable/std/ffi/struct.FromBytesUntilNulError.html)
62+
- [`std::os::unix::fs::chown`](https://doc.rust-lang.org/stable/std/os/unix/fs/fn.chown.html)
63+
- [`std::os::unix::fs::fchown`](https://doc.rust-lang.org/stable/std/os/unix/fs/fn.fchown.html)
64+
- [`std::os::unix::fs::lchown`](https://doc.rust-lang.org/stable/std/os/unix/fs/fn.lchown.html)
65+
- [`LocalKey::<Cell<T>>::get`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.get)
66+
- [`LocalKey::<Cell<T>>::set`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.set)
67+
- [`LocalKey::<Cell<T>>::take`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.take)
68+
- [`LocalKey::<Cell<T>>::replace`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.replace)
69+
- [`LocalKey::<RefCell<T>>::with_borrow`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.with_borrow)
70+
- [`LocalKey::<RefCell<T>>::with_borrow_mut`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.with_borrow_mut)
71+
- [`LocalKey::<RefCell<T>>::set`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.set-1)
72+
- [`LocalKey::<RefCell<T>>::take`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.take-1)
73+
- [`LocalKey::<RefCell<T>>::replace`](https://doc.rust-lang.org/stable/std/thread/struct.LocalKey.html#method.replace-1)
74+
75+
These APIs are now stable in const contexts:
76+
77+
- [`rc::Weak::new`](https://doc.rust-lang.org/stable/alloc/rc/struct.Weak.html#method.new)
78+
- [`sync::Weak::new`](https://doc.rust-lang.org/stable/alloc/sync/struct.Weak.html#method.new)
79+
- [`NonNull::as_ref`](https://doc.rust-lang.org/stable/core/ptr/struct.NonNull.html#method.as_ref)
80+
81+
<a id="1.73.0-Cargo"></a>
82+
83+
Cargo
84+
-----
85+
86+
- [Encode URL params correctly for `SourceId` in `Cargo.lock`.](https://github.com/rust-lang/cargo/pull/12280/)
87+
- [Bail out an error when using `cargo::` in custom build script.](https://github.com/rust-lang/cargo/pull/12332/)
88+
89+
<a id="1.73.0-Misc"></a>
90+
91+
Misc
92+
----
93+
94+
<a id="1.73.0-Compatibility-Notes"></a>
95+
96+
Compatibility Notes
97+
-------------------
98+
99+
- [Update the minimum external LLVM to 15.](https://github.com/rust-lang/rust/pull/114148/)
100+
- [Check for non-defining uses of return position `impl Trait`.](https://github.com/rust-lang/rust/pull/112842/)
101+
102+
<a id="1.73.0-Internal-Changes"></a>
103+
104+
Internal Changes
105+
----------------
106+
107+
These changes do not affect any public interfaces of Rust, but they represent
108+
significant improvements to the performance or internals of rustc and related
109+
tools.
110+
111+
- [Remove LLVM pointee types, supporting only opaque pointers.](https://github.com/rust-lang/rust/pull/105545/)
112+
- [Port PGO/LTO/BOLT optimized build pipeline to Rust.](https://github.com/rust-lang/rust/pull/112235/)
113+
- [Replace in-tree `rustc_apfloat` with the new version of the crate.](https://github.com/rust-lang/rust/pull/113843/)
114+
- [Update to LLVM 17.](https://github.com/rust-lang/rust/pull/114048/)
115+
- [Add `internal_features` lint for internal unstable features.](https://github.com/rust-lang/rust/pull/108955/)
116+
- [Mention style for new syntax in tracking issue template.](https://github.com/rust-lang/rust/pull/113586/)
117+
1118
Version 1.72.1 (2023-09-19)
2119
===========================
3120

compiler/rustc_abi/src/layout.rs

+38-38
Original file line numberDiff line numberDiff line change
@@ -53,32 +53,32 @@ pub trait LayoutCalculator {
5353
kind: StructKind,
5454
) -> Option<LayoutS> {
5555
let layout = univariant(self, dl, fields, repr, kind, NicheBias::Start);
56-
// Enums prefer niches close to the beginning or the end of the variants so that other (smaller)
57-
// data-carrying variants can be packed into the space after/before the niche.
56+
// Enums prefer niches close to the beginning or the end of the variants so that other
57+
// (smaller) data-carrying variants can be packed into the space after/before the niche.
5858
// If the default field ordering does not give us a niche at the front then we do a second
59-
// run and bias niches to the right and then check which one is closer to one of the struct's
60-
// edges.
59+
// run and bias niches to the right and then check which one is closer to one of the
60+
// struct's edges.
6161
if let Some(layout) = &layout {
6262
// Don't try to calculate an end-biased layout for unsizable structs,
6363
// otherwise we could end up with different layouts for
64-
// Foo<Type> and Foo<dyn Trait> which would break unsizing
64+
// Foo<Type> and Foo<dyn Trait> which would break unsizing.
6565
if !matches!(kind, StructKind::MaybeUnsized) {
6666
if let Some(niche) = layout.largest_niche {
6767
let head_space = niche.offset.bytes();
68-
let niche_length = niche.value.size(dl).bytes();
69-
let tail_space = layout.size.bytes() - head_space - niche_length;
68+
let niche_len = niche.value.size(dl).bytes();
69+
let tail_space = layout.size.bytes() - head_space - niche_len;
7070

71-
// This may end up doing redundant work if the niche is already in the last field
72-
// (e.g. a trailing bool) and there is tail padding. But it's non-trivial to get
73-
// the unpadded size so we try anyway.
71+
// This may end up doing redundant work if the niche is already in the last
72+
// field (e.g. a trailing bool) and there is tail padding. But it's non-trivial
73+
// to get the unpadded size so we try anyway.
7474
if fields.len() > 1 && head_space != 0 && tail_space > 0 {
7575
let alt_layout = univariant(self, dl, fields, repr, kind, NicheBias::End)
7676
.expect("alt layout should always work");
77-
let niche = alt_layout
77+
let alt_niche = alt_layout
7878
.largest_niche
7979
.expect("alt layout should have a niche like the regular one");
80-
let alt_head_space = niche.offset.bytes();
81-
let alt_niche_len = niche.value.size(dl).bytes();
80+
let alt_head_space = alt_niche.offset.bytes();
81+
let alt_niche_len = alt_niche.value.size(dl).bytes();
8282
let alt_tail_space =
8383
alt_layout.size.bytes() - alt_head_space - alt_niche_len;
8484

@@ -93,7 +93,7 @@ pub trait LayoutCalculator {
9393
alt_layout: {}\n",
9494
layout.size.bytes(),
9595
head_space,
96-
niche_length,
96+
niche_len,
9797
tail_space,
9898
alt_head_space,
9999
alt_niche_len,
@@ -684,7 +684,8 @@ pub trait LayoutCalculator {
684684
// Also do not overwrite any already existing "clever" ABIs.
685685
if variant.fields.count() > 0 && matches!(variant.abi, Abi::Aggregate { .. }) {
686686
variant.abi = abi;
687-
// Also need to bump up the size and alignment, so that the entire value fits in here.
687+
// Also need to bump up the size and alignment, so that the entire value fits
688+
// in here.
688689
variant.size = cmp::max(variant.size, size);
689690
variant.align.abi = cmp::max(variant.align.abi, align.abi);
690691
}
@@ -868,15 +869,15 @@ fn univariant(
868869

869870
// If `-Z randomize-layout` was enabled for the type definition we can shuffle
870871
// the field ordering to try and catch some code making assumptions about layouts
871-
// we don't guarantee
872+
// we don't guarantee.
872873
if repr.can_randomize_type_layout() && cfg!(feature = "randomize") {
873874
#[cfg(feature = "randomize")]
874875
{
875-
// `ReprOptions.layout_seed` is a deterministic seed that we can use to
876-
// randomize field ordering with
876+
// `ReprOptions.layout_seed` is a deterministic seed we can use to randomize field
877+
// ordering.
877878
let mut rng = Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed.as_u64());
878879

879-
// Shuffle the ordering of the fields
880+
// Shuffle the ordering of the fields.
880881
optimizing.shuffle(&mut rng);
881882
}
882883
// Otherwise we just leave things alone and actually optimize the type's fields
@@ -892,27 +893,26 @@ fn univariant(
892893
.max()
893894
.unwrap_or(0);
894895

895-
// Calculates a sort key to group fields by their alignment or possibly some size-derived
896-
// pseudo-alignment.
896+
// Calculates a sort key to group fields by their alignment or possibly some
897+
// size-derived pseudo-alignment.
897898
let alignment_group_key = |layout: Layout<'_>| {
898899
if let Some(pack) = pack {
899-
// return the packed alignment in bytes
900+
// Return the packed alignment in bytes.
900901
layout.align().abi.min(pack).bytes()
901902
} else {
902-
// returns log2(effective-align).
903-
// This is ok since `pack` applies to all fields equally.
904-
// The calculation assumes that size is an integer multiple of align, except for ZSTs.
905-
//
903+
// Returns `log2(effective-align)`. This is ok since `pack` applies to all
904+
// fields equally. The calculation assumes that size is an integer multiple of
905+
// align, except for ZSTs.
906906
let align = layout.align().abi.bytes();
907907
let size = layout.size().bytes();
908908
let niche_size = layout.largest_niche().map(|n| n.available(dl)).unwrap_or(0);
909-
// group [u8; 4] with align-4 or [u8; 6] with align-2 fields
909+
// Group [u8; 4] with align-4 or [u8; 6] with align-2 fields.
910910
let size_as_align = align.max(size).trailing_zeros();
911911
let size_as_align = if largest_niche_size > 0 {
912912
match niche_bias {
913-
// Given `A(u8, [u8; 16])` and `B(bool, [u8; 16])` we want to bump the array
914-
// to the front in the first case (for aligned loads) but keep the bool in front
915-
// in the second case for its niches.
913+
// Given `A(u8, [u8; 16])` and `B(bool, [u8; 16])` we want to bump the
914+
// array to the front in the first case (for aligned loads) but keep
915+
// the bool in front in the second case for its niches.
916916
NicheBias::Start => max_field_align.trailing_zeros().min(size_as_align),
917917
// When moving niches towards the end of the struct then for
918918
// A((u8, u8, u8, bool), (u8, bool, u8)) we want to keep the first tuple
@@ -931,14 +931,14 @@ fn univariant(
931931

932932
match kind {
933933
StructKind::AlwaysSized | StructKind::MaybeUnsized => {
934-
// Currently `LayoutS` only exposes a single niche so sorting is usually sufficient
935-
// to get one niche into the preferred position. If it ever supported multiple niches
936-
// then a more advanced pick-and-pack approach could provide better results.
937-
// But even for the single-niche cache it's not optimal. E.g. for
938-
// A(u32, (bool, u8), u16) it would be possible to move the bool to the front
939-
// but it would require packing the tuple together with the u16 to build a 4-byte
940-
// group so that the u32 can be placed after it without padding. This kind
941-
// of packing can't be achieved by sorting.
934+
// Currently `LayoutS` only exposes a single niche so sorting is usually
935+
// sufficient to get one niche into the preferred position. If it ever
936+
// supported multiple niches then a more advanced pick-and-pack approach could
937+
// provide better results. But even for the single-niche cache it's not
938+
// optimal. E.g. for A(u32, (bool, u8), u16) it would be possible to move the
939+
// bool to the front but it would require packing the tuple together with the
940+
// u16 to build a 4-byte group so that the u32 can be placed after it without
941+
// padding. This kind of packing can't be achieved by sorting.
942942
optimizing.sort_by_key(|&x| {
943943
let f = fields[x];
944944
let field_size = f.size().bytes();

0 commit comments

Comments
 (0)