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

Commit 6a518ff

Browse files
committed
Auto merge of rust-lang#125931 - matthiaskrgr:rollup-m3lqr4i, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#122597 (Show files produced by `--emit foo` in json artifact notifications) - rust-lang#124486 (Add tracking issue and unstable book page for `"vectorcall"` ABI) - rust-lang#125380 (Make `WHERE_CLAUSES_OBJECT_SAFETY` a regular object safety violation) - rust-lang#125690 (ARM Target Docs Update) - rust-lang#125865 (Fix ICE caused by ignoring EffectVars in type inference) - rust-lang#125893 (Handle all GVN binops in a single place.) - rust-lang#125909 (rustdoc: add a regression test for a former blanket impl synthesis ICE) - rust-lang#125918 (Revert: create const block bodies in typeck via query feeding) - rust-lang#125919 (Remove stray "this") r? `@ghost` `@rustbot` modify labels: rollup
2 parents eb5e244 + 69d8f62 commit 6a518ff

File tree

92 files changed

+661
-473
lines changed

Some content is hidden

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

92 files changed

+661
-473
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ pub enum ExprKind {
13921392
/// An array (e.g, `[a, b, c, d]`).
13931393
Array(ThinVec<P<Expr>>),
13941394
/// Allow anonymous constants from an inline `const` block
1395-
ConstBlock(P<Expr>),
1395+
ConstBlock(AnonConst),
13961396
/// A function call
13971397
///
13981398
/// 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_expr(anon_const);
1414+
vis.visit_anon_const(anon_const);
14151415
}
14161416
ExprKind::Repeat(expr, count) => {
14171417
vis.visit_expr(expr);

compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) -> V
954954
ExprKind::Array(subexpressions) => {
955955
walk_list!(visitor, visit_expr, subexpressions);
956956
}
957-
ExprKind::ConstBlock(anon_const) => try_visit!(visitor.visit_expr(anon_const)),
957+
ExprKind::ConstBlock(anon_const) => try_visit!(visitor.visit_anon_const(anon_const)),
958958
ExprKind::Repeat(element, count) => {
959959
try_visit!(visitor.visit_expr(element));
960960
try_visit!(visitor.visit_anon_const(count));

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,12 @@ 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-
self.has_inline_consts = true;
79-
hir::ExprKind::ConstBlock(self.lower_expr(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)
8084
}
8185
ExprKind::Repeat(expr, count) => {
8286
let expr = self.lower_expr(expr);

compiler/rustc_ast_lowering/src/index.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ 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+
239247
fn visit_expr(&mut self, expr: &'hir Expr<'hir>) {
240248
self.insert(expr.span, expr.hir_id, Node::Expr(expr));
241249

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ 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,
10199
/// Attributes inside the owner being lowered.
102100
attrs: SortedMap<hir::ItemLocalId, &'hir [Attribute]>,
103101
/// Collect items that were created by lowering the current owner.
@@ -160,7 +158,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
160158
item_local_id_counter: hir::ItemLocalId::ZERO,
161159
node_id_to_local_id: Default::default(),
162160
trait_map: Default::default(),
163-
has_inline_consts: false,
164161

165162
// Lowering state.
166163
catch_scope: None,
@@ -570,7 +567,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
570567

571568
let current_attrs = std::mem::take(&mut self.attrs);
572569
let current_bodies = std::mem::take(&mut self.bodies);
573-
let current_has_inline_consts = std::mem::take(&mut self.has_inline_consts);
574570
let current_node_ids = std::mem::take(&mut self.node_id_to_local_id);
575571
let current_trait_map = std::mem::take(&mut self.trait_map);
576572
let current_owner =
@@ -597,7 +593,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
597593

598594
self.attrs = current_attrs;
599595
self.bodies = current_bodies;
600-
self.has_inline_consts = current_has_inline_consts;
601596
self.node_id_to_local_id = current_node_ids;
602597
self.trait_map = current_trait_map;
603598
self.current_hir_id_owner = current_owner;
@@ -634,7 +629,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
634629
let attrs = std::mem::take(&mut self.attrs);
635630
let mut bodies = std::mem::take(&mut self.bodies);
636631
let trait_map = std::mem::take(&mut self.trait_map);
637-
let has_inline_consts = std::mem::take(&mut self.has_inline_consts);
638632

639633
#[cfg(debug_assertions)]
640634
for (id, attrs) in attrs.iter() {
@@ -652,7 +646,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
652646
self.tcx.hash_owner_nodes(node, &bodies, &attrs);
653647
let num_nodes = self.item_local_id_counter.as_usize();
654648
let (nodes, parenting) = index::index_hir(self.tcx, node, &bodies, num_nodes);
655-
let nodes = hir::OwnerNodes { opt_hash_including_bodies, nodes, bodies, has_inline_consts };
649+
let nodes = hir::OwnerNodes { opt_hash_including_bodies, nodes, bodies };
656650
let attrs = hir::AttributeMap { map: attrs, opt_hash: attrs_hash };
657651

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

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,8 @@ impl<'a> State<'a> {
380380
ast::ExprKind::Array(exprs) => {
381381
self.print_expr_vec(exprs);
382382
}
383-
ast::ExprKind::ConstBlock(expr) => {
384-
self.word_space("const");
385-
self.print_expr(expr, FixupContext::default());
383+
ast::ExprKind::ConstBlock(anon_const) => {
384+
self.print_expr_anon_const(anon_const, attrs);
386385
}
387386
ast::ExprKind::Repeat(element, count) => {
388387
self.print_expr_repeat(element, count);

compiler/rustc_codegen_cranelift/src/driver/aot.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,29 @@ fn produce_final_output_artifacts(
288288
}
289289
}
290290

291+
if sess.opts.json_artifact_notifications {
292+
if codegen_results.modules.len() == 1 {
293+
codegen_results.modules[0].for_each_output(|_path, ty| {
294+
if sess.opts.output_types.contains_key(&ty) {
295+
let descr = ty.shorthand();
296+
// for single cgu file is renamed to drop cgu specific suffix
297+
// so we regenerate it the same way
298+
let path = crate_output.path(ty);
299+
sess.dcx().emit_artifact_notification(path.as_path(), descr);
300+
}
301+
});
302+
} else {
303+
for module in &codegen_results.modules {
304+
module.for_each_output(|path, ty| {
305+
if sess.opts.output_types.contains_key(&ty) {
306+
let descr = ty.shorthand();
307+
sess.dcx().emit_artifact_notification(&path, descr);
308+
}
309+
});
310+
}
311+
}
312+
}
313+
291314
// We leave the following files around by default:
292315
// - #crate#.o
293316
// - #crate#.crate.metadata.o

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,29 @@ fn produce_final_output_artifacts(
717717
}
718718
}
719719

720+
if sess.opts.json_artifact_notifications {
721+
if compiled_modules.modules.len() == 1 {
722+
compiled_modules.modules[0].for_each_output(|_path, ty| {
723+
if sess.opts.output_types.contains_key(&ty) {
724+
let descr = ty.shorthand();
725+
// for single cgu file is renamed to drop cgu specific suffix
726+
// so we regenerate it the same way
727+
let path = crate_output.path(ty);
728+
sess.dcx().emit_artifact_notification(path.as_path(), descr);
729+
}
730+
});
731+
} else {
732+
for module in &compiled_modules.modules {
733+
module.for_each_output(|path, ty| {
734+
if sess.opts.output_types.contains_key(&ty) {
735+
let descr = ty.shorthand();
736+
sess.dcx().emit_artifact_notification(&path, descr);
737+
}
738+
});
739+
}
740+
}
741+
}
742+
720743
// We leave the following files around by default:
721744
// - #crate#.o
722745
// - #crate#.crate.metadata.o

compiler/rustc_codegen_ssa/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,24 @@ pub struct CompiledModule {
106106
pub llvm_ir: Option<PathBuf>, // --emit=llvm-ir, llvm-bc is in bytecode
107107
}
108108

109+
impl CompiledModule {
110+
/// Call `emit` function with every artifact type currently compiled
111+
pub fn for_each_output(&self, mut emit: impl FnMut(&Path, OutputType)) {
112+
if let Some(path) = self.object.as_deref() {
113+
emit(path, OutputType::Object);
114+
}
115+
if let Some(path) = self.bytecode.as_deref() {
116+
emit(path, OutputType::Bitcode);
117+
}
118+
if let Some(path) = self.llvm_ir.as_deref() {
119+
emit(path, OutputType::LlvmAssembly);
120+
}
121+
if let Some(path) = self.assembly.as_deref() {
122+
emit(path, OutputType::Assembly);
123+
}
124+
}
125+
}
126+
109127
pub struct CachedModuleCodegen {
110128
pub name: String,
111129
pub source: WorkProduct,

0 commit comments

Comments
 (0)