Skip to content

Commit be6b42f

Browse files
committed
Auto merge of #2983 - rust-lang:rustup2023-07-16, r=oli-obk
Automatic sync from rustc
2 parents 21b05e7 + 2e4a190 commit be6b42f

File tree

793 files changed

+10693
-8207
lines changed

Some content is hidden

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

793 files changed

+10693
-8207
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ trim_trailing_whitespace = true
1111
insert_final_newline = true
1212
indent_style = space
1313
indent_size = 4
14+
15+
[*.rs]
1416
max_line_length = 100
1517

1618
[*.md]

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ cf2dff2b1e3fa55fa5415d524200070d0d7aacfe
1616
b39a1d6f1a30ba29f25d7141038b9a5bf0126e36
1717
# reorder fluent message files
1818
f97fddab91fbf290ea5b691fe355d6f915220b6e
19+
# format let-else
20+
cc907f80b95c6ec530c5ee1b05b044a468f07eca

.mailmap

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,14 @@ Joseph T. Lyons <JosephTLyons@gmail.com> <JosephTLyons@users.noreply.github.com>
299299
Josh Cotton <jcotton42@outlook.com>
300300
Josh Driver <keeperofdakeys@gmail.com>
301301
Josh Holmer <jholmer.in@gmail.com>
302-
Joshua Nelson <jyn514@gmail.com> <joshua@yottadb.com>
303302
Julian Knodt <julianknodt@gmail.com>
304303
jumbatm <jumbatm@gmail.com> <30644300+jumbatm@users.noreply.github.com>
305304
Junyoung Cho <june0.cho@samsung.com>
305+
Jynn Nelson <github@jyn.dev> <jyn514@gmail.com>
306+
Jynn Nelson <github@jyn.dev> <joshua@yottadb.com>
307+
Jynn Nelson <github@jyn.dev> <jyn.nelson@redjack.com>
308+
Jynn Nelson <github@jyn.dev> <jnelson@cloudflare.com>
309+
Jynn Nelson <github@jyn.dev>
306310
Jyun-Yan You <jyyou.tw@gmail.com> <jyyou@cs.nctu.edu.tw>
307311
Kalita Alexey <kalita.alexey@outlook.com>
308312
Kampfkarren <boynedmaster@gmail.com>

Cargo.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,9 +1529,9 @@ dependencies = [
15291529

15301530
[[package]]
15311531
name = "hermit-abi"
1532-
version = "0.3.1"
1532+
version = "0.3.2"
15331533
source = "registry+https://github.com/rust-lang/crates.io-index"
1534-
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
1534+
checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
15351535
dependencies = [
15361536
"compiler_builtins",
15371537
"rustc-std-workspace-alloc",
@@ -1864,7 +1864,7 @@ version = "1.0.11"
18641864
source = "registry+https://github.com/rust-lang/crates.io-index"
18651865
checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
18661866
dependencies = [
1867-
"hermit-abi 0.3.1",
1867+
"hermit-abi 0.3.2",
18681868
"libc",
18691869
"windows-sys 0.48.0",
18701870
]
@@ -1881,7 +1881,7 @@ version = "0.4.8"
18811881
source = "registry+https://github.com/rust-lang/crates.io-index"
18821882
checksum = "24fddda5af7e54bf7da53067d6e802dbcc381d0a8eef629df528e3ebf68755cb"
18831883
dependencies = [
1884-
"hermit-abi 0.3.1",
1884+
"hermit-abi 0.3.2",
18851885
"rustix 0.38.2",
18861886
"windows-sys 0.48.0",
18871887
]
@@ -2396,7 +2396,7 @@ version = "1.16.0"
23962396
source = "registry+https://github.com/rust-lang/crates.io-index"
23972397
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
23982398
dependencies = [
2399-
"hermit-abi 0.3.1",
2399+
"hermit-abi 0.3.2",
24002400
"libc",
24012401
]
24022402

@@ -4819,7 +4819,7 @@ dependencies = [
48194819
"dlmalloc",
48204820
"fortanix-sgx-abi",
48214821
"hashbrown 0.14.0",
4822-
"hermit-abi 0.3.1",
4822+
"hermit-abi 0.3.2",
48234823
"libc",
48244824
"miniz_oxide",
48254825
"object",

RELEASES.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ Stabilized APIs
203203
- [`Default for std::collections::binary_heap::IntoIter`](https://doc.rust-lang.org/stable/std/collections/binary_heap/struct.IntoIter.html)
204204
- [`Default for std::collections::btree_map::{IntoIter, Iter, IterMut}`](https://doc.rust-lang.org/stable/std/collections/btree_map/struct.IntoIter.html)
205205
- [`Default for std::collections::btree_map::{IntoKeys, Keys}`](https://doc.rust-lang.org/stable/std/collections/btree_map/struct.IntoKeys.html)
206-
- [`Default for std::collections::btree_map::{IntoValues, Values}`](https://doc.rust-lang.org/stable/std/collections/btree_map/struct.IntoKeys.html)
206+
- [`Default for std::collections::btree_map::{IntoValues, Values}`](https://doc.rust-lang.org/stable/std/collections/btree_map/struct.IntoValues.html)
207207
- [`Default for std::collections::btree_map::Range`](https://doc.rust-lang.org/stable/std/collections/btree_map/struct.Range.html)
208208
- [`Default for std::collections::btree_set::{IntoIter, Iter}`](https://doc.rust-lang.org/stable/std/collections/btree_set/struct.IntoIter.html)
209209
- [`Default for std::collections::btree_set::Range`](https://doc.rust-lang.org/stable/std/collections/btree_set/struct.Range.html)
@@ -2618,7 +2618,7 @@ related tools.
26182618
[`OsStr::to_ascii_lowercase`]: https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.to_ascii_lowercase
26192619
[`OsStr::to_ascii_uppercase`]: https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.to_ascii_uppercase
26202620
[`Peekable::peek_mut`]: https://doc.rust-lang.org/std/iter/struct.Peekable.html#method.peek_mut
2621-
[`Rc::decrement_strong_count`]: https://doc.rust-lang.org/std/rc/struct.Rc.html#method.increment_strong_count
2621+
[`Rc::decrement_strong_count`]: https://doc.rust-lang.org/std/rc/struct.Rc.html#method.decrement_strong_count
26222622
[`Rc::increment_strong_count`]: https://doc.rust-lang.org/std/rc/struct.Rc.html#method.increment_strong_count
26232623
[`Vec::extend_from_within`]: https://doc.rust-lang.org/beta/std/vec/struct.Vec.html#method.extend_from_within
26242624
[`array::from_mut`]: https://doc.rust-lang.org/beta/std/array/fn.from_mut.html
@@ -2627,7 +2627,7 @@ related tools.
26272627
[`cmp::max_by`]: https://doc.rust-lang.org/beta/std/cmp/fn.max_by.html
26282628
[`cmp::min_by_key`]: https://doc.rust-lang.org/beta/std/cmp/fn.min_by_key.html
26292629
[`cmp::min_by`]: https://doc.rust-lang.org/beta/std/cmp/fn.min_by.html
2630-
[`f32::is_subnormal`]: https://doc.rust-lang.org/std/primitive.f64.html#method.is_subnormal
2630+
[`f32::is_subnormal`]: https://doc.rust-lang.org/std/primitive.f32.html#method.is_subnormal
26312631
[`f64::is_subnormal`]: https://doc.rust-lang.org/std/primitive.f64.html#method.is_subnormal
26322632
[ietf6943]: https://datatracker.ietf.org/doc/html/rfc6943#section-3.1.1
26332633

@@ -2963,7 +2963,7 @@ Internal Only
29632963
[`sync::OnceState`]: https://doc.rust-lang.org/stable/std/sync/struct.OnceState.html
29642964
[`panic::panic_any`]: https://doc.rust-lang.org/stable/std/panic/fn.panic_any.html
29652965
[`slice::strip_prefix`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.strip_prefix
2966-
[`slice::strip_suffix`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.strip_prefix
2966+
[`slice::strip_suffix`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.strip_suffix
29672967
[`Arc::increment_strong_count`]: https://doc.rust-lang.org/nightly/std/sync/struct.Arc.html#method.increment_strong_count
29682968
[`Arc::decrement_strong_count`]: https://doc.rust-lang.org/nightly/std/sync/struct.Arc.html#method.decrement_strong_count
29692969
[`slice::fill_with`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.fill_with
@@ -8033,7 +8033,7 @@ Compatibility Notes
80338033
[39379]: https://github.com/rust-lang/rust/pull/39379
80348034
[41105]: https://github.com/rust-lang/rust/issues/41105
80358035
[`<*const T>::wrapping_offset`]: https://doc.rust-lang.org/std/primitive.pointer.html#method.wrapping_offset
8036-
[`<*mut T>::wrapping_offset`]: https://doc.rust-lang.org/std/primitive.pointer.html#method.wrapping_offset
8036+
[`<*mut T>::wrapping_offset`]: https://doc.rust-lang.org/std/primitive.pointer.html#method.wrapping_offset-1
80378037
[`Duration::checked_add`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.checked_add
80388038
[`Duration::checked_div`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.checked_div
80398039
[`Duration::checked_mul`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.checked_mul
@@ -9011,7 +9011,7 @@ Stabilized APIs
90119011
* [`f64::to_radians`](https://doc.rust-lang.org/std/primitive.f64.html#method.to_radians)
90129012
(in libcore - previously stabilized in libstd)
90139013
* [`Iterator::sum`](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.sum)
9014-
* [`Iterator::product`](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.sum)
9014+
* [`Iterator::product`](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.product)
90159015
* [`Cell::get_mut`](https://doc.rust-lang.org/std/cell/struct.Cell.html#method.get_mut)
90169016
* [`RefCell::get_mut`](https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.get_mut)
90179017

compiler/rustc_abi/src/layout.rs

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub trait LayoutCalculator {
4040
largest_niche,
4141
align,
4242
size,
43+
max_repr_align: None,
44+
unadjusted_abi_align: align.abi,
4345
}
4446
}
4547

@@ -122,6 +124,8 @@ pub trait LayoutCalculator {
122124
largest_niche: None,
123125
align: dl.i8_align,
124126
size: Size::ZERO,
127+
max_repr_align: None,
128+
unadjusted_abi_align: dl.i8_align.abi,
125129
}
126130
}
127131

@@ -289,13 +293,18 @@ pub trait LayoutCalculator {
289293
}
290294

291295
let mut align = dl.aggregate_align;
296+
let mut max_repr_align = repr.align;
297+
let mut unadjusted_abi_align = align.abi;
298+
292299
let mut variant_layouts = variants
293300
.iter_enumerated()
294301
.map(|(j, v)| {
295302
let mut st = self.univariant(dl, v, repr, StructKind::AlwaysSized)?;
296303
st.variants = Variants::Single { index: j };
297304

298305
align = align.max(st.align);
306+
max_repr_align = max_repr_align.max(st.max_repr_align);
307+
unadjusted_abi_align = unadjusted_abi_align.max(st.unadjusted_abi_align);
299308

300309
Some(st)
301310
})
@@ -422,6 +431,8 @@ pub trait LayoutCalculator {
422431
largest_niche,
423432
size,
424433
align,
434+
max_repr_align,
435+
unadjusted_abi_align,
425436
};
426437

427438
Some(TmpLayout { layout, variants: variant_layouts })
@@ -456,6 +467,9 @@ pub trait LayoutCalculator {
456467
let (min_ity, signed) = discr_range_of_repr(min, max); //Integer::repr_discr(tcx, ty, &repr, min, max);
457468

458469
let mut align = dl.aggregate_align;
470+
let mut max_repr_align = repr.align;
471+
let mut unadjusted_abi_align = align.abi;
472+
459473
let mut size = Size::ZERO;
460474

461475
// We're interested in the smallest alignment, so start large.
@@ -498,6 +512,8 @@ pub trait LayoutCalculator {
498512
}
499513
size = cmp::max(size, st.size);
500514
align = align.max(st.align);
515+
max_repr_align = max_repr_align.max(st.max_repr_align);
516+
unadjusted_abi_align = unadjusted_abi_align.max(st.unadjusted_abi_align);
501517
Some(st)
502518
})
503519
.collect::<Option<IndexVec<VariantIdx, _>>>()?;
@@ -691,6 +707,8 @@ pub trait LayoutCalculator {
691707
abi,
692708
align,
693709
size,
710+
max_repr_align,
711+
unadjusted_abi_align,
694712
};
695713

696714
let tagged_layout = TmpLayout { layout: tagged_layout, variants: layout_variants };
@@ -730,10 +748,7 @@ pub trait LayoutCalculator {
730748
let dl = self.current_data_layout();
731749
let dl = dl.borrow();
732750
let mut align = if repr.pack.is_some() { dl.i8_align } else { dl.aggregate_align };
733-
734-
if let Some(repr_align) = repr.align {
735-
align = align.max(AbiAndPrefAlign::new(repr_align));
736-
}
751+
let mut max_repr_align = repr.align;
737752

738753
// If all the non-ZST fields have the same ABI and union ABI optimizations aren't
739754
// disabled, we can use that common ABI for the union as a whole.
@@ -751,6 +766,7 @@ pub trait LayoutCalculator {
751766
assert!(field.0.is_sized());
752767

753768
align = align.max(field.align());
769+
max_repr_align = max_repr_align.max(field.max_repr_align());
754770
size = cmp::max(size, field.size());
755771

756772
if field.0.is_zst() {
@@ -787,6 +803,14 @@ pub trait LayoutCalculator {
787803
if let Some(pack) = repr.pack {
788804
align = align.min(AbiAndPrefAlign::new(pack));
789805
}
806+
// The unadjusted ABI alignment does not include repr(align), but does include repr(pack).
807+
// See documentation on `LayoutS::unadjusted_abi_align`.
808+
let unadjusted_abi_align = align.abi;
809+
if let Some(repr_align) = repr.align {
810+
align = align.max(AbiAndPrefAlign::new(repr_align));
811+
}
812+
// `align` must not be modified after this, or `unadjusted_abi_align` could be inaccurate.
813+
let align = align;
790814

791815
// If all non-ZST fields have the same ABI, we may forward that ABI
792816
// for the union as a whole, unless otherwise inhibited.
@@ -809,6 +833,8 @@ pub trait LayoutCalculator {
809833
largest_niche: None,
810834
align,
811835
size: size.align_to(align.abi),
836+
max_repr_align,
837+
unadjusted_abi_align,
812838
})
813839
}
814840
}
@@ -829,6 +855,7 @@ fn univariant(
829855
) -> Option<LayoutS> {
830856
let pack = repr.pack;
831857
let mut align = if pack.is_some() { dl.i8_align } else { dl.aggregate_align };
858+
let mut max_repr_align = repr.align;
832859
let mut inverse_memory_index: IndexVec<u32, FieldIdx> = fields.indices().collect();
833860
let optimize = !repr.inhibit_struct_field_reordering_opt();
834861
if optimize && fields.len() > 1 {
@@ -997,6 +1024,7 @@ fn univariant(
9971024
};
9981025
offset = offset.align_to(field_align.abi);
9991026
align = align.max(field_align);
1027+
max_repr_align = max_repr_align.max(field.max_repr_align());
10001028

10011029
debug!("univariant offset: {:?} field: {:#?}", offset, field);
10021030
offsets[i] = offset;
@@ -1018,9 +1046,16 @@ fn univariant(
10181046

10191047
offset = offset.checked_add(field.size(), dl)?;
10201048
}
1049+
1050+
// The unadjusted ABI alignment does not include repr(align), but does include repr(pack).
1051+
// See documentation on `LayoutS::unadjusted_abi_align`.
1052+
let unadjusted_abi_align = align.abi;
10211053
if let Some(repr_align) = repr.align {
10221054
align = align.max(AbiAndPrefAlign::new(repr_align));
10231055
}
1056+
// `align` must not be modified after this point, or `unadjusted_abi_align` could be inaccurate.
1057+
let align = align;
1058+
10241059
debug!("univariant min_size: {:?}", offset);
10251060
let min_size = offset;
10261061
// As stated above, inverse_memory_index holds field indices by increasing offset.
@@ -1036,6 +1071,7 @@ fn univariant(
10361071
inverse_memory_index.into_iter().map(FieldIdx::as_u32).collect()
10371072
};
10381073
let size = min_size.align_to(align.abi);
1074+
let mut layout_of_single_non_zst_field = None;
10391075
let mut abi = Abi::Aggregate { sized };
10401076
// Unpack newtype ABIs and find scalar pairs.
10411077
if sized && size.bytes() > 0 {
@@ -1045,6 +1081,8 @@ fn univariant(
10451081
match (non_zst_fields.next(), non_zst_fields.next(), non_zst_fields.next()) {
10461082
// We have exactly one non-ZST field.
10471083
(Some((i, field)), None, None) => {
1084+
layout_of_single_non_zst_field = Some(field);
1085+
10481086
// Field fills the struct and it has a scalar or scalar pair ABI.
10491087
if offsets[i].bytes() == 0 && align.abi == field.align().abi && size == field.size()
10501088
{
@@ -1102,13 +1140,28 @@ fn univariant(
11021140
if fields.iter().any(|f| f.abi().is_uninhabited()) {
11031141
abi = Abi::Uninhabited;
11041142
}
1143+
1144+
let unadjusted_abi_align = if repr.transparent() {
1145+
match layout_of_single_non_zst_field {
1146+
Some(l) => l.unadjusted_abi_align(),
1147+
None => {
1148+
// `repr(transparent)` with all ZST fields.
1149+
align.abi
1150+
}
1151+
}
1152+
} else {
1153+
unadjusted_abi_align
1154+
};
1155+
11051156
Some(LayoutS {
11061157
variants: Variants::Single { index: FIRST_VARIANT },
11071158
fields: FieldsShape::Arbitrary { offsets, memory_index },
11081159
abi,
11091160
largest_niche,
11101161
align,
11111162
size,
1163+
max_repr_align,
1164+
unadjusted_abi_align,
11121165
})
11131166
}
11141167

compiler/rustc_abi/src/lib.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,16 @@ pub struct LayoutS {
15311531

15321532
pub align: AbiAndPrefAlign,
15331533
pub size: Size,
1534+
1535+
/// The largest alignment explicitly requested with `repr(align)` on this type or any field.
1536+
/// Only used on i686-windows, where the argument passing ABI is different when alignment is
1537+
/// requested, even if the requested alignment is equal to the natural alignment.
1538+
pub max_repr_align: Option<Align>,
1539+
1540+
/// The alignment the type would have, ignoring any `repr(align)` but including `repr(packed)`.
1541+
/// Only used on aarch64-linux, where the argument passing ABI ignores the requested alignment
1542+
/// in some cases.
1543+
pub unadjusted_abi_align: Align,
15341544
}
15351545

15361546
impl LayoutS {
@@ -1545,6 +1555,8 @@ impl LayoutS {
15451555
largest_niche,
15461556
size,
15471557
align,
1558+
max_repr_align: None,
1559+
unadjusted_abi_align: align.abi,
15481560
}
15491561
}
15501562
}
@@ -1554,14 +1566,25 @@ impl fmt::Debug for LayoutS {
15541566
// This is how `Layout` used to print before it become
15551567
// `Interned<LayoutS>`. We print it like this to avoid having to update
15561568
// expected output in a lot of tests.
1557-
let LayoutS { size, align, abi, fields, largest_niche, variants } = self;
1569+
let LayoutS {
1570+
size,
1571+
align,
1572+
abi,
1573+
fields,
1574+
largest_niche,
1575+
variants,
1576+
max_repr_align,
1577+
unadjusted_abi_align,
1578+
} = self;
15581579
f.debug_struct("Layout")
15591580
.field("size", size)
15601581
.field("align", align)
15611582
.field("abi", abi)
15621583
.field("fields", fields)
15631584
.field("largest_niche", largest_niche)
15641585
.field("variants", variants)
1586+
.field("max_repr_align", max_repr_align)
1587+
.field("unadjusted_abi_align", unadjusted_abi_align)
15651588
.finish()
15661589
}
15671590
}
@@ -1602,6 +1625,14 @@ impl<'a> Layout<'a> {
16021625
self.0.0.size
16031626
}
16041627

1628+
pub fn max_repr_align(self) -> Option<Align> {
1629+
self.0.0.max_repr_align
1630+
}
1631+
1632+
pub fn unadjusted_abi_align(self) -> Align {
1633+
self.0.0.unadjusted_abi_align
1634+
}
1635+
16051636
/// Whether the layout is from a type that implements [`std::marker::PointerLike`].
16061637
///
16071638
/// Currently, that means that the type is pointer-sized, pointer-aligned,

0 commit comments

Comments
 (0)