Skip to content

Commit ebcf860

Browse files
committed
Auto merge of rust-lang#136135 - GuillaumeGomez:rollup-1ik636d, r=GuillaumeGomez
Rollup of 10 pull requests Successful merges: - rust-lang#135773 (Clarify WindowsMut (Lending)Iterator) - rust-lang#135807 (Implement phantom variance markers) - rust-lang#135876 (fix doc for std::sync::mpmc) - rust-lang#135988 (Add a workaround for parallel rustc crashing when there are delayed bugs) - rust-lang#136037 (Mark all NuttX targets as tier 3 target and support the standard library) - rust-lang#136064 (Add a suggestion to cast target_feature fn items to fn pointers.) - rust-lang#136082 (Incorporate `iter_nodes` into `graph::DirectedGraph`) - rust-lang#136112 (Clean up all dead files inside `tests/ui/`) - rust-lang#136114 (Use identifiers more in diagnostics code) - rust-lang#136118 (Change `collect_and_partition_mono_items` tuple return type to a struct) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0cffe5c + 3d02ce7 commit ebcf860

File tree

150 files changed

+632
-3852
lines changed

Some content is hidden

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

150 files changed

+632
-3852
lines changed

compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub(crate) fn expand_deriving_coerce_pointee(
157157
{
158158
cx.dcx().emit_err(RequiresMaybeSized {
159159
span: pointee_ty_ident.span,
160-
name: pointee_ty_ident.name.to_ident_string(),
160+
name: pointee_ty_ident,
161161
});
162162
return;
163163
}
@@ -471,5 +471,5 @@ struct TooManyPointees {
471471
struct RequiresMaybeSized {
472472
#[primary_span]
473473
span: Span,
474-
name: String,
474+
name: Ident,
475475
}

compiler/rustc_codegen_cranelift/src/driver/aot.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ pub(crate) fn run_aot(
676676
.to_owned();
677677

678678
let cgus = if tcx.sess.opts.output_types.should_codegen() {
679-
tcx.collect_and_partition_mono_items(()).1
679+
tcx.collect_and_partition_mono_items(()).codegen_units
680680
} else {
681681
// If only `--emit metadata` is used, we shouldn't perform any codegen.
682682
// Also `tcx.collect_and_partition_mono_items` may panic in that case.

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
99
use rustc_hir::def_id::{DefId, LocalDefId};
1010
use rustc_index::IndexVec;
1111
use rustc_middle::mir;
12+
use rustc_middle::mir::mono::MonoItemPartitions;
1213
use rustc_middle::ty::{self, TyCtxt};
1314
use rustc_session::RemapFileNameExt;
1415
use rustc_session::config::RemapPathScopeComponents;
@@ -297,12 +298,13 @@ struct UsageSets<'tcx> {
297298
/// Prepare sets of definitions that are relevant to deciding whether something
298299
/// is an "unused function" for coverage purposes.
299300
fn prepare_usage_sets<'tcx>(tcx: TyCtxt<'tcx>) -> UsageSets<'tcx> {
300-
let (all_mono_items, cgus) = tcx.collect_and_partition_mono_items(());
301+
let MonoItemPartitions { all_mono_items, codegen_units } =
302+
tcx.collect_and_partition_mono_items(());
301303

302304
// Obtain a MIR body for each function participating in codegen, via an
303305
// arbitrary instance.
304306
let mut def_ids_seen = FxHashSet::default();
305-
let def_and_mir_for_all_mono_fns = cgus
307+
let def_and_mir_for_all_mono_fns = codegen_units
306308
.iter()
307309
.flat_map(|cgu| cgu.items().keys())
308310
.filter_map(|item| match item {

compiler/rustc_codegen_ssa/src/assert_module_sources.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>, set_reuse: &dyn Fn(&mut CguReuseTr
4646
return;
4747
}
4848

49-
let available_cgus =
50-
tcx.collect_and_partition_mono_items(()).1.iter().map(|cgu| cgu.name()).collect();
49+
let available_cgus = tcx
50+
.collect_and_partition_mono_items(())
51+
.codegen_units
52+
.iter()
53+
.map(|cgu| cgu.name())
54+
.collect();
5155

5256
let mut ams = AssertModuleSource {
5357
tcx,

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ fn exported_symbols_provider_local(
293293
// external linkage is enough for monomorphization to be linked to.
294294
let need_visibility = tcx.sess.target.dynamic_linking && !tcx.sess.target.only_cdylib;
295295

296-
let (_, cgus) = tcx.collect_and_partition_mono_items(());
296+
let cgus = tcx.collect_and_partition_mono_items(()).codegen_units;
297297

298298
// The symbols created in this loop are sorted below it
299299
#[allow(rustc::potential_query_instability)]

compiler/rustc_codegen_ssa/src/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
619619

620620
// Run the monomorphization collector and partition the collected items into
621621
// codegen units.
622-
let codegen_units = tcx.collect_and_partition_mono_items(()).1;
622+
let codegen_units = tcx.collect_and_partition_mono_items(()).codegen_units;
623623

624624
// Force all codegen_unit queries so they are already either red or green
625625
// when compile_codegen_unit accesses them. We are not able to re-execute
@@ -1051,7 +1051,7 @@ pub(crate) fn provide(providers: &mut Providers) {
10511051
config::OptLevel::SizeMin => config::OptLevel::Default,
10521052
};
10531053

1054-
let (defids, _) = tcx.collect_and_partition_mono_items(cratenum);
1054+
let defids = tcx.collect_and_partition_mono_items(cratenum).all_mono_items;
10551055

10561056
let any_for_speed = defids.items().any(|id| {
10571057
let CodegenFnAttrs { optimize, .. } = tcx.codegen_fn_attrs(*id);

compiler/rustc_data_structures/src/graph/mod.rs

+16
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,23 @@ mod tests;
1414
pub trait DirectedGraph {
1515
type Node: Idx;
1616

17+
/// Returns the total number of nodes in this graph.
18+
///
19+
/// Several graph algorithm implementations assume that every node ID is
20+
/// strictly less than the number of nodes, i.e. nodes are densely numbered.
21+
/// That assumption allows them to use `num_nodes` to allocate per-node
22+
/// data structures, indexed by node.
1723
fn num_nodes(&self) -> usize;
24+
25+
/// Iterates over all nodes of a graph in ascending numeric order.
26+
///
27+
/// Assumes that nodes are densely numbered, i.e. every index in
28+
/// `0..num_nodes` is a valid node.
29+
fn iter_nodes(
30+
&self,
31+
) -> impl Iterator<Item = Self::Node> + DoubleEndedIterator + ExactSizeIterator {
32+
(0..self.num_nodes()).map(<Self::Node as Idx>::new)
33+
}
1834
}
1935

2036
pub trait NumEdges: DirectedGraph {

compiler/rustc_data_structures/src/graph/scc/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ where
333333
to_annotation,
334334
};
335335

336-
let scc_indices = (0..num_nodes)
337-
.map(G::Node::new)
336+
let scc_indices = graph
337+
.iter_nodes()
338338
.map(|node| match this.start_walk_from(node) {
339339
WalkReturn::Complete { scc_index, .. } => scc_index,
340340
WalkReturn::Cycle { min_depth, .. } => {

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2362,7 +2362,7 @@ fn try_report_async_mismatch<'tcx>(
23622362
// the right span is a bit difficult.
23632363
return Err(tcx.sess.dcx().emit_err(MethodShouldReturnFuture {
23642364
span: tcx.def_span(impl_m.def_id),
2365-
method_name: trait_m.name,
2365+
method_name: tcx.item_ident(impl_m.def_id),
23662366
trait_item_span: tcx.hir().span_if_local(trait_m.def_id),
23672367
}));
23682368
}

compiler/rustc_hir_analysis/src/check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId) {
197197

198198
fn report_forbidden_specialization(tcx: TyCtxt<'_>, impl_item: DefId, parent_impl: DefId) {
199199
let span = tcx.def_span(impl_item);
200-
let ident = tcx.item_name(impl_item);
200+
let ident = tcx.item_ident(impl_item);
201201

202202
let err = match tcx.span_of_impl(parent_impl) {
203203
Ok(sp) => errors::ImplNotMarkedDefault::Ok { span, ident, ok_label: sp },
@@ -297,7 +297,7 @@ fn default_body_is_unstable(
297297
reason: Option<Symbol>,
298298
issue: Option<NonZero<u32>>,
299299
) {
300-
let missing_item_name = tcx.associated_item(item_did).name;
300+
let missing_item_name = tcx.item_ident(item_did);
301301
let (mut some_note, mut none_note, mut reason_str) = (false, false, String::new());
302302
match reason {
303303
Some(r) => {

compiler/rustc_hir_analysis/src/coherence/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
292292

293293
res = Err(tcx.dcx().emit_err(errors::DispatchFromDynZST {
294294
span,
295-
name: field.name,
295+
name: field.ident(tcx),
296296
ty: ty_a,
297297
}));
298298

compiler/rustc_hir_analysis/src/coherence/orphan.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,8 @@ fn emit_orphan_check_error<'tcx>(
465465
traits::OrphanCheckErr::UncoveredTyParams(UncoveredTyParams { uncovered, local_ty }) => {
466466
let mut reported = None;
467467
for param_def_id in uncovered {
468-
let span = tcx.def_ident_span(param_def_id).unwrap();
469-
let name = tcx.item_name(param_def_id);
468+
let name = tcx.item_ident(param_def_id);
469+
let span = name.span;
470470

471471
reported.get_or_insert(match local_ty {
472472
Some(local_type) => tcx.dcx().emit_err(errors::TyParamFirstLocal {
@@ -492,7 +492,7 @@ fn lint_uncovered_ty_params<'tcx>(
492492

493493
for param_def_id in uncovered {
494494
let span = tcx.def_ident_span(param_def_id).unwrap();
495-
let name = tcx.item_name(param_def_id);
495+
let name = tcx.item_ident(param_def_id);
496496

497497
match local_ty {
498498
Some(local_type) => tcx.emit_node_span_lint(

compiler/rustc_hir_analysis/src/collect.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ fn lower_enum_variant_types(tcx: TyCtxt<'_>, def_id: DefId) {
928928
tcx.dcx().emit_err(errors::EnumDiscriminantOverflowed {
929929
span,
930930
discr: prev_discr.unwrap().to_string(),
931-
item_name: tcx.item_name(variant.def_id),
931+
item_name: tcx.item_ident(variant.def_id),
932932
wrapped_discr: wrapped_discr.to_string(),
933933
});
934934
None
@@ -990,11 +990,10 @@ impl<'tcx> FieldUniquenessCheckContext<'tcx> {
990990
}
991991

992992
/// Check if a given field `ident` declared at `field_decl` has been declared elsewhere before.
993-
fn check_field_decl(&mut self, ident: Ident, field_decl: FieldDeclSpan) {
993+
fn check_field_decl(&mut self, field_name: Ident, field_decl: FieldDeclSpan) {
994994
use FieldDeclSpan::*;
995-
let field_name = ident.name;
996-
let ident = ident.normalize_to_macros_2_0();
997-
match (field_decl, self.seen_fields.get(&ident).copied()) {
995+
let field_name = field_name.normalize_to_macros_2_0();
996+
match (field_decl, self.seen_fields.get(&field_name).copied()) {
998997
(NotNested(span), Some(NotNested(prev_span))) => {
999998
self.tcx.dcx().emit_err(errors::FieldAlreadyDeclared::NotNested {
1000999
field_name,
@@ -1035,7 +1034,7 @@ impl<'tcx> FieldUniquenessCheckContext<'tcx> {
10351034
});
10361035
}
10371036
(field_decl, None) => {
1038-
self.seen_fields.insert(ident, field_decl);
1037+
self.seen_fields.insert(field_name, field_decl);
10391038
}
10401039
}
10411040
}

compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub(super) fn find_opaque_ty_constraints_for_impl_trait_in_assoc_type(
5555
} else {
5656
let reported = tcx.dcx().emit_err(UnconstrainedOpaqueType {
5757
span: tcx.def_span(def_id),
58-
name: tcx.item_name(parent_def_id.to_def_id()),
58+
name: tcx.item_ident(parent_def_id.to_def_id()),
5959
what: "impl",
6060
});
6161
Ty::new_error(tcx, reported)
@@ -136,7 +136,7 @@ pub(super) fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: Local
136136
}
137137
let reported = tcx.dcx().emit_err(UnconstrainedOpaqueType {
138138
span: tcx.def_span(def_id),
139-
name: tcx.item_name(parent_def_id.to_def_id()),
139+
name: tcx.item_ident(parent_def_id.to_def_id()),
140140
what: match tcx.hir_node(scope) {
141141
_ if scope == hir::CRATE_HIR_ID => "module",
142142
Node::Item(hir::Item { kind: hir::ItemKind::Mod(_), .. }) => "module",

compiler/rustc_hir_analysis/src/errors.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub(crate) struct DropImplOnWrongItem {
217217
pub(crate) enum FieldAlreadyDeclared {
218218
#[diag(hir_analysis_field_already_declared, code = E0124)]
219219
NotNested {
220-
field_name: Symbol,
220+
field_name: Ident,
221221
#[primary_span]
222222
#[label]
223223
span: Span,
@@ -226,7 +226,7 @@ pub(crate) enum FieldAlreadyDeclared {
226226
},
227227
#[diag(hir_analysis_field_already_declared_current_nested)]
228228
CurrentNested {
229-
field_name: Symbol,
229+
field_name: Ident,
230230
#[primary_span]
231231
#[label]
232232
span: Span,
@@ -239,7 +239,7 @@ pub(crate) enum FieldAlreadyDeclared {
239239
},
240240
#[diag(hir_analysis_field_already_declared_previous_nested)]
241241
PreviousNested {
242-
field_name: Symbol,
242+
field_name: Ident,
243243
#[primary_span]
244244
#[label]
245245
span: Span,
@@ -252,7 +252,7 @@ pub(crate) enum FieldAlreadyDeclared {
252252
},
253253
#[diag(hir_analysis_field_already_declared_both_nested)]
254254
BothNested {
255-
field_name: Symbol,
255+
field_name: Ident,
256256
#[primary_span]
257257
#[label]
258258
span: Span,
@@ -418,7 +418,7 @@ pub(crate) struct ValueOfAssociatedStructAlreadySpecified {
418418
pub(crate) struct UnconstrainedOpaqueType {
419419
#[primary_span]
420420
pub span: Span,
421-
pub name: Symbol,
421+
pub name: Ident,
422422
pub what: &'static str,
423423
}
424424

@@ -802,7 +802,7 @@ pub(crate) struct EnumDiscriminantOverflowed {
802802
#[label]
803803
pub span: Span,
804804
pub discr: String,
805-
pub item_name: Symbol,
805+
pub item_name: Ident,
806806
pub wrapped_discr: String,
807807
}
808808

@@ -893,15 +893,15 @@ pub(crate) enum ImplNotMarkedDefault {
893893
span: Span,
894894
#[label(hir_analysis_ok_label)]
895895
ok_label: Span,
896-
ident: Symbol,
896+
ident: Ident,
897897
},
898898
#[diag(hir_analysis_impl_not_marked_default_err, code = E0520)]
899899
#[note]
900900
Err {
901901
#[primary_span]
902902
span: Span,
903903
cname: Symbol,
904-
ident: Symbol,
904+
ident: Ident,
905905
},
906906
}
907907

@@ -977,7 +977,7 @@ pub(crate) struct MissingTraitItemUnstable {
977977
pub some_note: bool,
978978
#[note(hir_analysis_none_note)]
979979
pub none_note: bool,
980-
pub missing_item_name: Symbol,
980+
pub missing_item_name: Ident,
981981
pub feature: Symbol,
982982
pub reason: String,
983983
}
@@ -1249,7 +1249,7 @@ pub(crate) struct InherentNominal {
12491249
pub(crate) struct DispatchFromDynZST<'a> {
12501250
#[primary_span]
12511251
pub span: Span,
1252-
pub name: Symbol,
1252+
pub name: Ident,
12531253
pub ty: Ty<'a>,
12541254
}
12551255

@@ -1389,7 +1389,7 @@ pub(crate) struct TyParamFirstLocal<'tcx> {
13891389
pub span: Span,
13901390
#[note(hir_analysis_case_note)]
13911391
pub note: (),
1392-
pub param: Symbol,
1392+
pub param: Ident,
13931393
pub local_type: Ty<'tcx>,
13941394
}
13951395

@@ -1401,7 +1401,7 @@ pub(crate) struct TyParamFirstLocalLint<'tcx> {
14011401
pub span: Span,
14021402
#[note(hir_analysis_case_note)]
14031403
pub note: (),
1404-
pub param: Symbol,
1404+
pub param: Ident,
14051405
pub local_type: Ty<'tcx>,
14061406
}
14071407

@@ -1414,7 +1414,7 @@ pub(crate) struct TyParamSome {
14141414
pub span: Span,
14151415
#[note(hir_analysis_only_note)]
14161416
pub note: (),
1417-
pub param: Symbol,
1417+
pub param: Ident,
14181418
}
14191419

14201420
#[derive(LintDiagnostic)]
@@ -1425,7 +1425,7 @@ pub(crate) struct TyParamSomeLint {
14251425
pub span: Span,
14261426
#[note(hir_analysis_only_note)]
14271427
pub note: (),
1428-
pub param: Symbol,
1428+
pub param: Ident,
14291429
}
14301430

14311431
#[derive(Diagnostic)]
@@ -1533,7 +1533,7 @@ pub(crate) struct UnsupportedDelegation<'a> {
15331533
pub(crate) struct MethodShouldReturnFuture {
15341534
#[primary_span]
15351535
pub span: Span,
1536-
pub method_name: Symbol,
1536+
pub method_name: Ident,
15371537
#[note]
15381538
pub trait_item_span: Option<Span>,
15391539
}
@@ -1585,7 +1585,7 @@ pub(crate) struct UnconstrainedGenericParameter {
15851585
#[primary_span]
15861586
#[label]
15871587
pub span: Span,
1588-
pub param_name: Symbol,
1588+
pub param_name: Ident,
15891589
pub param_def_kind: &'static str,
15901590
#[note(hir_analysis_const_param_note)]
15911591
pub const_param_note: bool,

compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
495495
.iter()
496496
.any(|constraint| constraint.ident.name == item.name)
497497
})
498-
.map(|item| item.name.to_ident_string())
498+
.map(|item| self.tcx.item_ident(item.def_id).to_string())
499499
.collect()
500500
} else {
501501
Vec::default()

0 commit comments

Comments
 (0)