Skip to content

Commit 259fdb5

Browse files
committed
Auto merge of rust-lang#138630 - matthiaskrgr:rollup-kk1gogr, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#138384 (Move `hir::Item::ident` into `hir::ItemKind`.) - rust-lang#138508 (Clarify "owned data" in E0515.md) - rust-lang#138531 (Store test diffs in job summaries and improve analysis formatting) - rust-lang#138533 (Only use `DIST_TRY_BUILD` for try jobs that were not selected explicitly) - rust-lang#138556 (Fix ICE: attempted to remap an already remapped filename) - rust-lang#138608 (rustc_target: Add target feature constraints for LoongArch) - rust-lang#138619 (Flatten `if`s in `rustc_codegen_ssa`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 493c38b + 597500d commit 259fdb5

File tree

105 files changed

+1347
-1152
lines changed

Some content is hidden

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

105 files changed

+1347
-1152
lines changed

.github/workflows/ci.yml

+17-2
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,31 @@ jobs:
239239
if: github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1'
240240

241241
- name: postprocess metrics into the summary
242+
# This step is not critical, and if some I/O problem happens, we don't want
243+
# to cancel the build.
244+
continue-on-error: true
242245
run: |
243246
if [ -f build/metrics.json ]; then
244-
./build/citool/debug/citool postprocess-metrics build/metrics.json ${GITHUB_STEP_SUMMARY}
247+
METRICS=build/metrics.json
245248
elif [ -f obj/build/metrics.json ]; then
246-
./build/citool/debug/citool postprocess-metrics obj/build/metrics.json ${GITHUB_STEP_SUMMARY}
249+
METRICS=obj/build/metrics.json
247250
else
248251
echo "No metrics.json found"
252+
exit 0
249253
fi
250254
255+
# Get closest bors merge commit
256+
PARENT_COMMIT=`git rev-list --author='bors <[email protected]>' -n1 --first-parent HEAD^1`
257+
258+
./build/citool/debug/citool postprocess-metrics \
259+
--job-name ${CI_JOB_NAME} \
260+
--parent ${PARENT_COMMIT} \
261+
${METRICS} >> ${GITHUB_STEP_SUMMARY}
262+
251263
- name: upload job metrics to DataDog
264+
# This step is not critical, and if some I/O problem happens, we don't want
265+
# to cancel the build.
266+
continue-on-error: true
252267
if: needs.calculate_matrix.outputs.run_type != 'pr'
253268
env:
254269
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}

compiler/rustc_ast_lowering/src/index.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
164164
fn visit_item(&mut self, i: &'hir Item<'hir>) {
165165
debug_assert_eq!(i.owner_id, self.owner);
166166
self.with_parent(i.hir_id(), |this| {
167-
if let ItemKind::Struct(struct_def, _) = &i.kind {
167+
if let ItemKind::Struct(_, struct_def, _) = &i.kind {
168168
// If this is a tuple or unit-like struct, register the constructor.
169169
if let Some(ctor_hir_id) = struct_def.ctor_hir_id() {
170170
this.insert(i.span, ctor_hir_id, Node::Ctor(struct_def));

compiler/rustc_ast_lowering/src/item.rs

+77-37
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
111111
}
112112

113113
fn lower_foreign_item(&mut self, item: &ForeignItem) {
114+
debug_assert_ne!(item.ident.name, kw::Empty);
114115
self.with_lctx(item.id, |lctx| hir::OwnerNode::ForeignItem(lctx.lower_foreign_item(item)))
115116
}
116117
}
@@ -154,14 +155,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
154155
}
155156

156157
fn lower_item(&mut self, i: &Item) -> &'hir hir::Item<'hir> {
157-
let mut ident = i.ident;
158158
let vis_span = self.lower_span(i.vis.span);
159159
let hir_id = hir::HirId::make_owner(self.current_hir_id_owner.def_id);
160160
let attrs = self.lower_attrs(hir_id, &i.attrs, i.span);
161-
let kind = self.lower_item_kind(i.span, i.id, hir_id, &mut ident, attrs, vis_span, &i.kind);
161+
let kind = self.lower_item_kind(i.span, i.id, hir_id, i.ident, attrs, vis_span, &i.kind);
162162
let item = hir::Item {
163163
owner_id: hir_id.expect_owner(),
164-
ident: self.lower_ident(ident),
165164
kind,
166165
vis_span,
167166
span: self.lower_span(i.span),
@@ -174,25 +173,34 @@ impl<'hir> LoweringContext<'_, 'hir> {
174173
span: Span,
175174
id: NodeId,
176175
hir_id: hir::HirId,
177-
ident: &mut Ident,
176+
ident: Ident,
178177
attrs: &'hir [hir::Attribute],
179178
vis_span: Span,
180179
i: &ItemKind,
181180
) -> hir::ItemKind<'hir> {
182181
match i {
183-
ItemKind::ExternCrate(orig_name) => hir::ItemKind::ExternCrate(*orig_name),
182+
ItemKind::ExternCrate(orig_name) => {
183+
debug_assert_ne!(ident.name, kw::Empty);
184+
let ident = self.lower_ident(ident);
185+
hir::ItemKind::ExternCrate(*orig_name, ident)
186+
}
184187
ItemKind::Use(use_tree) => {
188+
debug_assert_eq!(ident.name, kw::Empty);
185189
// Start with an empty prefix.
186190
let prefix = Path { segments: ThinVec::new(), span: use_tree.span, tokens: None };
187191

188-
self.lower_use_tree(use_tree, &prefix, id, vis_span, ident, attrs)
192+
self.lower_use_tree(use_tree, &prefix, id, vis_span, attrs)
189193
}
190194
ItemKind::Static(box ast::StaticItem { ty: t, safety: _, mutability: m, expr: e }) => {
195+
debug_assert_ne!(ident.name, kw::Empty);
196+
let ident = self.lower_ident(ident);
191197
let (ty, body_id) =
192198
self.lower_const_item(t, span, e.as_deref(), ImplTraitPosition::StaticTy);
193-
hir::ItemKind::Static(ty, *m, body_id)
199+
hir::ItemKind::Static(ident, ty, *m, body_id)
194200
}
195201
ItemKind::Const(box ast::ConstItem { generics, ty, expr, .. }) => {
202+
debug_assert_ne!(ident.name, kw::Empty);
203+
let ident = self.lower_ident(ident);
196204
let (generics, (ty, body_id)) = self.lower_generics(
197205
generics,
198206
id,
@@ -201,7 +209,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
201209
this.lower_const_item(ty, span, expr.as_deref(), ImplTraitPosition::ConstTy)
202210
},
203211
);
204-
hir::ItemKind::Const(ty, generics, body_id)
212+
hir::ItemKind::Const(ident, ty, generics, body_id)
205213
}
206214
ItemKind::Fn(box Fn {
207215
sig: FnSig { decl, header, span: fn_sig_span },
@@ -211,6 +219,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
211219
define_opaque,
212220
..
213221
}) => {
222+
debug_assert_ne!(ident.name, kw::Empty);
214223
self.with_new_scopes(*fn_sig_span, |this| {
215224
// Note: we don't need to change the return type from `T` to
216225
// `impl Future<Output = T>` here because lower_body
@@ -238,28 +247,44 @@ impl<'hir> LoweringContext<'_, 'hir> {
238247
span: this.lower_span(*fn_sig_span),
239248
};
240249
this.lower_define_opaque(hir_id, &define_opaque);
241-
hir::ItemKind::Fn { sig, generics, body: body_id, has_body: body.is_some() }
250+
let ident = this.lower_ident(ident);
251+
hir::ItemKind::Fn {
252+
ident,
253+
sig,
254+
generics,
255+
body: body_id,
256+
has_body: body.is_some(),
257+
}
242258
})
243259
}
244-
ItemKind::Mod(_, mod_kind) => match mod_kind {
245-
ModKind::Loaded(items, _, spans, _) => {
246-
hir::ItemKind::Mod(self.lower_mod(items, spans))
260+
ItemKind::Mod(_, mod_kind) => {
261+
debug_assert_ne!(ident.name, kw::Empty);
262+
let ident = self.lower_ident(ident);
263+
match mod_kind {
264+
ModKind::Loaded(items, _, spans, _) => {
265+
hir::ItemKind::Mod(ident, self.lower_mod(items, spans))
266+
}
267+
ModKind::Unloaded => panic!("`mod` items should have been loaded by now"),
247268
}
248-
ModKind::Unloaded => panic!("`mod` items should have been loaded by now"),
249-
},
250-
ItemKind::ForeignMod(fm) => hir::ItemKind::ForeignMod {
251-
abi: fm.abi.map_or(ExternAbi::FALLBACK, |abi| self.lower_abi(abi)),
252-
items: self
253-
.arena
254-
.alloc_from_iter(fm.items.iter().map(|x| self.lower_foreign_item_ref(x))),
255-
},
269+
}
270+
ItemKind::ForeignMod(fm) => {
271+
debug_assert_eq!(ident.name, kw::Empty);
272+
hir::ItemKind::ForeignMod {
273+
abi: fm.abi.map_or(ExternAbi::FALLBACK, |abi| self.lower_abi(abi)),
274+
items: self
275+
.arena
276+
.alloc_from_iter(fm.items.iter().map(|x| self.lower_foreign_item_ref(x))),
277+
}
278+
}
256279
ItemKind::GlobalAsm(asm) => {
280+
debug_assert_eq!(ident.name, kw::Empty);
257281
let asm = self.lower_inline_asm(span, asm);
258282
let fake_body =
259283
self.lower_body(|this| (&[], this.expr(span, hir::ExprKind::InlineAsm(asm))));
260284
hir::ItemKind::GlobalAsm { asm, fake_body }
261285
}
262286
ItemKind::TyAlias(box TyAlias { generics, where_clauses, ty, .. }) => {
287+
debug_assert_ne!(ident.name, kw::Empty);
263288
// We lower
264289
//
265290
// type Foo = impl Trait
@@ -268,6 +293,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
268293
//
269294
// type Foo = Foo1
270295
// opaque type Foo1: Trait
296+
let ident = self.lower_ident(ident);
271297
let mut generics = generics.clone();
272298
add_ty_alias_where_clause(&mut generics, *where_clauses, true);
273299
let (generics, ty) = self.lower_generics(
@@ -293,9 +319,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
293319
),
294320
},
295321
);
296-
hir::ItemKind::TyAlias(ty, generics)
322+
hir::ItemKind::TyAlias(ident, ty, generics)
297323
}
298324
ItemKind::Enum(enum_definition, generics) => {
325+
debug_assert_ne!(ident.name, kw::Empty);
326+
let ident = self.lower_ident(ident);
299327
let (generics, variants) = self.lower_generics(
300328
generics,
301329
id,
@@ -306,25 +334,29 @@ impl<'hir> LoweringContext<'_, 'hir> {
306334
)
307335
},
308336
);
309-
hir::ItemKind::Enum(hir::EnumDef { variants }, generics)
337+
hir::ItemKind::Enum(ident, hir::EnumDef { variants }, generics)
310338
}
311339
ItemKind::Struct(struct_def, generics) => {
340+
debug_assert_ne!(ident.name, kw::Empty);
341+
let ident = self.lower_ident(ident);
312342
let (generics, struct_def) = self.lower_generics(
313343
generics,
314344
id,
315345
ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
316346
|this| this.lower_variant_data(hir_id, struct_def),
317347
);
318-
hir::ItemKind::Struct(struct_def, generics)
348+
hir::ItemKind::Struct(ident, struct_def, generics)
319349
}
320350
ItemKind::Union(vdata, generics) => {
351+
debug_assert_ne!(ident.name, kw::Empty);
352+
let ident = self.lower_ident(ident);
321353
let (generics, vdata) = self.lower_generics(
322354
generics,
323355
id,
324356
ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
325357
|this| this.lower_variant_data(hir_id, vdata),
326358
);
327-
hir::ItemKind::Union(vdata, generics)
359+
hir::ItemKind::Union(ident, vdata, generics)
328360
}
329361
ItemKind::Impl(box Impl {
330362
safety,
@@ -336,6 +368,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
336368
self_ty: ty,
337369
items: impl_items,
338370
}) => {
371+
debug_assert_eq!(ident.name, kw::Empty);
339372
// Lower the "impl header" first. This ordering is important
340373
// for in-band lifetimes! Consider `'a` here:
341374
//
@@ -401,6 +434,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
401434
}))
402435
}
403436
ItemKind::Trait(box Trait { is_auto, safety, generics, bounds, items }) => {
437+
debug_assert_ne!(ident.name, kw::Empty);
438+
let ident = self.lower_ident(ident);
404439
let (generics, (safety, items, bounds)) = self.lower_generics(
405440
generics,
406441
id,
@@ -417,9 +452,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
417452
(safety, items, bounds)
418453
},
419454
);
420-
hir::ItemKind::Trait(*is_auto, safety, generics, bounds, items)
455+
hir::ItemKind::Trait(*is_auto, safety, ident, generics, bounds, items)
421456
}
422457
ItemKind::TraitAlias(generics, bounds) => {
458+
debug_assert_ne!(ident.name, kw::Empty);
459+
let ident = self.lower_ident(ident);
423460
let (generics, bounds) = self.lower_generics(
424461
generics,
425462
id,
@@ -431,9 +468,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
431468
)
432469
},
433470
);
434-
hir::ItemKind::TraitAlias(generics, bounds)
471+
hir::ItemKind::TraitAlias(ident, generics, bounds)
435472
}
436473
ItemKind::MacroDef(MacroDef { body, macro_rules }) => {
474+
debug_assert_ne!(ident.name, kw::Empty);
475+
let ident = self.lower_ident(ident);
437476
let body = P(self.lower_delim_args(body));
438477
let def_id = self.local_def_id(id);
439478
let def_kind = self.tcx.def_kind(def_id);
@@ -444,11 +483,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
444483
);
445484
};
446485
let macro_def = self.arena.alloc(ast::MacroDef { body, macro_rules: *macro_rules });
447-
hir::ItemKind::Macro(macro_def, macro_kind)
486+
hir::ItemKind::Macro(ident, macro_def, macro_kind)
448487
}
449488
ItemKind::Delegation(box delegation) => {
489+
debug_assert_ne!(ident.name, kw::Empty);
490+
let ident = self.lower_ident(ident);
450491
let delegation_results = self.lower_delegation(delegation, id);
451492
hir::ItemKind::Fn {
493+
ident,
452494
sig: delegation_results.sig,
453495
generics: delegation_results.generics,
454496
body: delegation_results.body_id,
@@ -479,15 +521,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
479521
prefix: &Path,
480522
id: NodeId,
481523
vis_span: Span,
482-
ident: &mut Ident,
483524
attrs: &'hir [hir::Attribute],
484525
) -> hir::ItemKind<'hir> {
485526
let path = &tree.prefix;
486527
let segments = prefix.segments.iter().chain(path.segments.iter()).cloned().collect();
487528

488529
match tree.kind {
489530
UseTreeKind::Simple(rename) => {
490-
*ident = tree.ident();
531+
let mut ident = tree.ident();
491532

492533
// First, apply the prefix to the path.
493534
let mut path = Path { segments, span: path.span, tokens: None };
@@ -498,13 +539,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
498539
{
499540
let _ = path.segments.pop();
500541
if rename.is_none() {
501-
*ident = path.segments.last().unwrap().ident;
542+
ident = path.segments.last().unwrap().ident;
502543
}
503544
}
504545

505546
let res = self.lower_import_res(id, path.span);
506547
let path = self.lower_use_path(res, &path, ParamMode::Explicit);
507-
hir::ItemKind::Use(path, hir::UseKind::Single)
548+
let ident = self.lower_ident(ident);
549+
hir::ItemKind::Use(path, hir::UseKind::Single(ident))
508550
}
509551
UseTreeKind::Glob => {
510552
let res = self.expect_full_res(id);
@@ -551,20 +593,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
551593
// own its own names, we have to adjust the owner before
552594
// lowering the rest of the import.
553595
self.with_hir_id_owner(id, |this| {
554-
let mut ident = *ident;
555-
556596
// `prefix` is lowered multiple times, but in different HIR owners.
557597
// So each segment gets renewed `HirId` with the same
558598
// `ItemLocalId` and the new owner. (See `lower_node_id`)
559-
let kind =
560-
this.lower_use_tree(use_tree, &prefix, id, vis_span, &mut ident, attrs);
599+
let kind = this.lower_use_tree(use_tree, &prefix, id, vis_span, attrs);
561600
if !attrs.is_empty() {
562601
this.attrs.insert(hir::ItemLocalId::ZERO, attrs);
563602
}
564603

565604
let item = hir::Item {
566605
owner_id: hir::OwnerId { def_id: new_hir_id },
567-
ident: this.lower_ident(ident),
568606
kind,
569607
vis_span,
570608
span: this.lower_span(use_tree.span),
@@ -604,7 +642,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
604642
hir::ItemKind::Impl(impl_) => {
605643
self.is_in_trait_impl = impl_.of_trait.is_some();
606644
}
607-
hir::ItemKind::Trait(_, _, _, _, _) => {}
645+
hir::ItemKind::Trait(..) => {}
608646
kind => {
609647
span_bug!(item.span, "assoc item has unexpected kind of parent: {}", kind.descr())
610648
}
@@ -760,6 +798,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
760798
}
761799

762800
fn lower_trait_item(&mut self, i: &AssocItem) -> &'hir hir::TraitItem<'hir> {
801+
debug_assert_ne!(i.ident.name, kw::Empty);
763802
let hir_id = hir::HirId::make_owner(self.current_hir_id_owner.def_id);
764803
let attrs = self.lower_attrs(hir_id, &i.attrs, i.span);
765804
let trait_item_def_id = hir_id.expect_owner();
@@ -907,6 +946,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
907946
}
908947

909948
fn lower_impl_item(&mut self, i: &AssocItem) -> &'hir hir::ImplItem<'hir> {
949+
debug_assert_ne!(i.ident.name, kw::Empty);
910950
// Since `default impl` is not yet implemented, this is always true in impls.
911951
let has_value = true;
912952
let (defaultness, _) = self.lower_defaultness(i.kind.defaultness(), has_value);

0 commit comments

Comments
 (0)