Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 8a7338a

Browse files
committed
Auto merge of rust-lang#3645 - rust-lang:rustup-2024-05-30, r=RalfJung
Automatic Rustup
2 parents ec5327d + daeb68a commit 8a7338a

File tree

400 files changed

+6654
-2709
lines changed

Some content is hidden

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

400 files changed

+6654
-2709
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,12 @@ jobs:
154154

155155
- name: checkout submodules
156156
run: src/ci/scripts/checkout-submodules.sh
157-
158-
- name: install MSYS2
159-
run: src/ci/scripts/install-msys2.sh
157+
158+
- name: Setup Python
159+
uses: actions/setup-python@v5
160+
with:
161+
python-version: '3.x'
162+
if: runner.environment == 'github-hosted'
160163

161164
- name: install MinGW
162165
run: src/ci/scripts/install-mingw.sh

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4082,6 +4082,7 @@ dependencies = [
40824082
"rustc_feature",
40834083
"rustc_fluent_macro",
40844084
"rustc_hir",
4085+
"rustc_hir_pretty",
40854086
"rustc_index",
40864087
"rustc_infer",
40874088
"rustc_macros",

compiler/rustc_abi/src/layout.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ fn univariant<
970970
let mut align = if pack.is_some() { dl.i8_align } else { dl.aggregate_align };
971971
let mut max_repr_align = repr.align;
972972
let mut inverse_memory_index: IndexVec<u32, FieldIdx> = fields.indices().collect();
973-
let optimize = !repr.inhibit_struct_field_reordering_opt();
973+
let optimize = !repr.inhibit_struct_field_reordering();
974974
if optimize && fields.len() > 1 {
975975
let end = if let StructKind::MaybeUnsized = kind { fields.len() - 1 } else { fields.len() };
976976
let optimizing = &mut inverse_memory_index.raw[..end];
@@ -1007,13 +1007,15 @@ fn univariant<
10071007
// Calculates a sort key to group fields by their alignment or possibly some
10081008
// size-derived pseudo-alignment.
10091009
let alignment_group_key = |layout: &F| {
1010+
// The two branches here return values that cannot be meaningfully compared with
1011+
// each other. However, we know that consistently for all executions of
1012+
// `alignment_group_key`, one or the other branch will be taken, so this is okay.
10101013
if let Some(pack) = pack {
10111014
// Return the packed alignment in bytes.
10121015
layout.align.abi.min(pack).bytes()
10131016
} else {
1014-
// Returns `log2(effective-align)`. This is ok since `pack` applies to all
1015-
// fields equally. The calculation assumes that size is an integer multiple of
1016-
// align, except for ZSTs.
1017+
// Returns `log2(effective-align)`. The calculation assumes that size is an
1018+
// integer multiple of align, except for ZSTs.
10171019
let align = layout.align.abi.bytes();
10181020
let size = layout.size.bytes();
10191021
let niche_size = layout.largest_niche.map(|n| n.available(dl)).unwrap_or(0);

compiler/rustc_abi/src/lib.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,23 +137,16 @@ impl ReprOptions {
137137
self.c() || self.int.is_some()
138138
}
139139

140-
/// Returns `true` if this `#[repr()]` should inhibit struct field reordering
141-
/// optimizations, such as with `repr(C)`, `repr(packed(1))`, or `repr(<int>)`.
142-
pub fn inhibit_struct_field_reordering_opt(&self) -> bool {
143-
if let Some(pack) = self.pack {
144-
if pack.bytes() == 1 {
145-
return true;
146-
}
147-
}
148-
140+
/// Returns `true` if this `#[repr()]` guarantees a fixed field order,
141+
/// e.g. `repr(C)` or `repr(<int>)`.
142+
pub fn inhibit_struct_field_reordering(&self) -> bool {
149143
self.flags.intersects(ReprFlags::IS_UNOPTIMISABLE) || self.int.is_some()
150144
}
151145

152146
/// Returns `true` if this type is valid for reordering and `-Z randomize-layout`
153147
/// was enabled for its declaration crate.
154148
pub fn can_randomize_type_layout(&self) -> bool {
155-
!self.inhibit_struct_field_reordering_opt()
156-
&& self.flags.contains(ReprFlags::RANDOMIZE_LAYOUT)
149+
!self.inhibit_struct_field_reordering() && self.flags.contains(ReprFlags::RANDOMIZE_LAYOUT)
157150
}
158151

159152
/// Returns `true` if this `#[repr()]` should inhibit union ABI optimisations.

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ pub enum ExprKind {
13931393
/// An array (e.g, `[a, b, c, d]`).
13941394
Array(ThinVec<P<Expr>>),
13951395
/// Allow anonymous constants from an inline `const` block
1396-
ConstBlock(AnonConst),
1396+
ConstBlock(P<Expr>),
13971397
/// A function call
13981398
///
13991399
/// The first field resolves to the function itself,

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,7 @@ pub fn noop_visit_expr<T: MutVisitor>(
14111411
match kind {
14121412
ExprKind::Array(exprs) => visit_thin_exprs(exprs, vis),
14131413
ExprKind::ConstBlock(anon_const) => {
1414-
vis.visit_anon_const(anon_const);
1414+
vis.visit_expr(anon_const);
14151415
}
14161416
ExprKind::Repeat(expr, count) => {
14171417
vis.visit_expr(expr);

compiler/rustc_ast/src/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,10 +852,10 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(
852852
ctxt: AssocCtxt,
853853
) -> V::Result {
854854
let &Item { id: _, span: _, ident, ref vis, ref attrs, ref kind, tokens: _ } = item;
855-
walk_list!(visitor, visit_attribute, attrs);
856855
try_visit!(visitor.visit_vis(vis));
857856
try_visit!(visitor.visit_ident(ident));
858857
try_visit!(kind.walk(item, ctxt, visitor));
858+
walk_list!(visitor, visit_attribute, attrs);
859859
V::Result::output()
860860
}
861861

@@ -951,7 +951,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) -> V
951951
ExprKind::Array(subexpressions) => {
952952
walk_list!(visitor, visit_expr, subexpressions);
953953
}
954-
ExprKind::ConstBlock(anon_const) => try_visit!(visitor.visit_anon_const(anon_const)),
954+
ExprKind::ConstBlock(anon_const) => try_visit!(visitor.visit_expr(anon_const)),
955955
ExprKind::Repeat(element, count) => {
956956
try_visit!(visitor.visit_expr(element));
957957
try_visit!(visitor.visit_anon_const(count));

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
7575
let kind = match &e.kind {
7676
ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
7777
ExprKind::ConstBlock(c) => {
78-
let c = self.with_new_scopes(c.value.span, |this| hir::ConstBlock {
79-
def_id: this.local_def_id(c.id),
80-
hir_id: this.lower_node_id(c.id),
81-
body: this.lower_const_body(c.value.span, Some(&c.value)),
82-
});
83-
hir::ExprKind::ConstBlock(c)
78+
self.has_inline_consts = true;
79+
hir::ExprKind::ConstBlock(self.lower_expr(c))
8480
}
8581
ExprKind::Repeat(expr, count) => {
8682
let expr = self.lower_expr(expr);

compiler/rustc_ast_lowering/src/index.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,6 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
236236
});
237237
}
238238

239-
fn visit_inline_const(&mut self, constant: &'hir ConstBlock) {
240-
self.insert(DUMMY_SP, constant.hir_id, Node::ConstBlock(constant));
241-
242-
self.with_parent(constant.hir_id, |this| {
243-
intravisit::walk_inline_const(this, constant);
244-
});
245-
}
246-
247239
fn visit_expr(&mut self, expr: &'hir Expr<'hir>) {
248240
self.insert(expr.span, expr.hir_id, Node::Expr(expr));
249241

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ struct LoweringContext<'a, 'hir> {
9696

9797
/// Bodies inside the owner being lowered.
9898
bodies: Vec<(hir::ItemLocalId, &'hir hir::Body<'hir>)>,
99+
/// Whether there were inline consts that typeck will split out into bodies
100+
has_inline_consts: bool,
99101
/// Attributes inside the owner being lowered.
100102
attrs: SortedMap<hir::ItemLocalId, &'hir [Attribute]>,
101103
/// Collect items that were created by lowering the current owner.
@@ -158,6 +160,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
158160
item_local_id_counter: hir::ItemLocalId::ZERO,
159161
node_id_to_local_id: Default::default(),
160162
trait_map: Default::default(),
163+
has_inline_consts: false,
161164

162165
// Lowering state.
163166
catch_scope: None,
@@ -567,6 +570,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
567570

568571
let current_attrs = std::mem::take(&mut self.attrs);
569572
let current_bodies = std::mem::take(&mut self.bodies);
573+
let current_has_inline_consts = std::mem::take(&mut self.has_inline_consts);
570574
let current_node_ids = std::mem::take(&mut self.node_id_to_local_id);
571575
let current_trait_map = std::mem::take(&mut self.trait_map);
572576
let current_owner =
@@ -593,6 +597,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
593597

594598
self.attrs = current_attrs;
595599
self.bodies = current_bodies;
600+
self.has_inline_consts = current_has_inline_consts;
596601
self.node_id_to_local_id = current_node_ids;
597602
self.trait_map = current_trait_map;
598603
self.current_hir_id_owner = current_owner;
@@ -629,6 +634,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
629634
let attrs = std::mem::take(&mut self.attrs);
630635
let mut bodies = std::mem::take(&mut self.bodies);
631636
let trait_map = std::mem::take(&mut self.trait_map);
637+
let has_inline_consts = std::mem::take(&mut self.has_inline_consts);
632638

633639
#[cfg(debug_assertions)]
634640
for (id, attrs) in attrs.iter() {
@@ -646,7 +652,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
646652
self.tcx.hash_owner_nodes(node, &bodies, &attrs);
647653
let num_nodes = self.item_local_id_counter.as_usize();
648654
let (nodes, parenting) = index::index_hir(self.tcx, node, &bodies, num_nodes);
649-
let nodes = hir::OwnerNodes { opt_hash_including_bodies, nodes, bodies };
655+
let nodes = hir::OwnerNodes { opt_hash_including_bodies, nodes, bodies, has_inline_consts };
650656
let attrs = hir::AttributeMap { map: attrs, opt_hash: attrs_hash };
651657

652658
self.arena.alloc(hir::OwnerInfo { nodes, parenting, attrs, trait_map })

0 commit comments

Comments
 (0)