Skip to content

Commit

Permalink
Auto merge of rust-lang#136135 - GuillaumeGomez:rollup-1ik636d, r=Gui…
Browse files Browse the repository at this point in the history
…llaumeGomez

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
  • Loading branch information
bors committed Jan 27, 2025
2 parents 0cffe5c + 3d02ce7 commit ebcf860
Show file tree
Hide file tree
Showing 150 changed files with 632 additions and 3,852 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub(crate) fn expand_deriving_coerce_pointee(
{
cx.dcx().emit_err(RequiresMaybeSized {
span: pointee_ty_ident.span,
name: pointee_ty_ident.name.to_ident_string(),
name: pointee_ty_ident,
});
return;
}
Expand Down Expand Up @@ -471,5 +471,5 @@ struct TooManyPointees {
struct RequiresMaybeSized {
#[primary_span]
span: Span,
name: String,
name: Ident,
}
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/driver/aot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ pub(crate) fn run_aot(
.to_owned();

let cgus = if tcx.sess.opts.output_types.should_codegen() {
tcx.collect_and_partition_mono_items(()).1
tcx.collect_and_partition_mono_items(()).codegen_units
} else {
// If only `--emit metadata` is used, we shouldn't perform any codegen.
// Also `tcx.collect_and_partition_mono_items` may panic in that case.
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_index::IndexVec;
use rustc_middle::mir;
use rustc_middle::mir::mono::MonoItemPartitions;
use rustc_middle::ty::{self, TyCtxt};
use rustc_session::RemapFileNameExt;
use rustc_session::config::RemapPathScopeComponents;
Expand Down Expand Up @@ -297,12 +298,13 @@ struct UsageSets<'tcx> {
/// Prepare sets of definitions that are relevant to deciding whether something
/// is an "unused function" for coverage purposes.
fn prepare_usage_sets<'tcx>(tcx: TyCtxt<'tcx>) -> UsageSets<'tcx> {
let (all_mono_items, cgus) = tcx.collect_and_partition_mono_items(());
let MonoItemPartitions { all_mono_items, codegen_units } =
tcx.collect_and_partition_mono_items(());

// Obtain a MIR body for each function participating in codegen, via an
// arbitrary instance.
let mut def_ids_seen = FxHashSet::default();
let def_and_mir_for_all_mono_fns = cgus
let def_and_mir_for_all_mono_fns = codegen_units
.iter()
.flat_map(|cgu| cgu.items().keys())
.filter_map(|item| match item {
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_codegen_ssa/src/assert_module_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>, set_reuse: &dyn Fn(&mut CguReuseTr
return;
}

let available_cgus =
tcx.collect_and_partition_mono_items(()).1.iter().map(|cgu| cgu.name()).collect();
let available_cgus = tcx
.collect_and_partition_mono_items(())
.codegen_units
.iter()
.map(|cgu| cgu.name())
.collect();

let mut ams = AssertModuleSource {
tcx,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ fn exported_symbols_provider_local(
// external linkage is enough for monomorphization to be linked to.
let need_visibility = tcx.sess.target.dynamic_linking && !tcx.sess.target.only_cdylib;

let (_, cgus) = tcx.collect_and_partition_mono_items(());
let cgus = tcx.collect_and_partition_mono_items(()).codegen_units;

// The symbols created in this loop are sorted below it
#[allow(rustc::potential_query_instability)]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(

// Run the monomorphization collector and partition the collected items into
// codegen units.
let codegen_units = tcx.collect_and_partition_mono_items(()).1;
let codegen_units = tcx.collect_and_partition_mono_items(()).codegen_units;

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

let (defids, _) = tcx.collect_and_partition_mono_items(cratenum);
let defids = tcx.collect_and_partition_mono_items(cratenum).all_mono_items;

let any_for_speed = defids.items().any(|id| {
let CodegenFnAttrs { optimize, .. } = tcx.codegen_fn_attrs(*id);
Expand Down
16 changes: 16 additions & 0 deletions compiler/rustc_data_structures/src/graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,23 @@ mod tests;
pub trait DirectedGraph {
type Node: Idx;

/// Returns the total number of nodes in this graph.
///
/// Several graph algorithm implementations assume that every node ID is
/// strictly less than the number of nodes, i.e. nodes are densely numbered.
/// That assumption allows them to use `num_nodes` to allocate per-node
/// data structures, indexed by node.
fn num_nodes(&self) -> usize;

/// Iterates over all nodes of a graph in ascending numeric order.
///
/// Assumes that nodes are densely numbered, i.e. every index in
/// `0..num_nodes` is a valid node.
fn iter_nodes(
&self,
) -> impl Iterator<Item = Self::Node> + DoubleEndedIterator + ExactSizeIterator {
(0..self.num_nodes()).map(<Self::Node as Idx>::new)
}
}

pub trait NumEdges: DirectedGraph {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_data_structures/src/graph/scc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ where
to_annotation,
};

let scc_indices = (0..num_nodes)
.map(G::Node::new)
let scc_indices = graph
.iter_nodes()
.map(|node| match this.start_walk_from(node) {
WalkReturn::Complete { scc_index, .. } => scc_index,
WalkReturn::Cycle { min_depth, .. } => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2362,7 +2362,7 @@ fn try_report_async_mismatch<'tcx>(
// the right span is a bit difficult.
return Err(tcx.sess.dcx().emit_err(MethodShouldReturnFuture {
span: tcx.def_span(impl_m.def_id),
method_name: trait_m.name,
method_name: tcx.item_ident(impl_m.def_id),
trait_item_span: tcx.hir().span_if_local(trait_m.def_id),
}));
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId) {

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

let err = match tcx.span_of_impl(parent_impl) {
Ok(sp) => errors::ImplNotMarkedDefault::Ok { span, ident, ok_label: sp },
Expand Down Expand Up @@ -297,7 +297,7 @@ fn default_body_is_unstable(
reason: Option<Symbol>,
issue: Option<NonZero<u32>>,
) {
let missing_item_name = tcx.associated_item(item_did).name;
let missing_item_name = tcx.item_ident(item_did);
let (mut some_note, mut none_note, mut reason_str) = (false, false, String::new());
match reason {
Some(r) => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/coherence/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()

res = Err(tcx.dcx().emit_err(errors::DispatchFromDynZST {
span,
name: field.name,
name: field.ident(tcx),
ty: ty_a,
}));

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ fn emit_orphan_check_error<'tcx>(
traits::OrphanCheckErr::UncoveredTyParams(UncoveredTyParams { uncovered, local_ty }) => {
let mut reported = None;
for param_def_id in uncovered {
let span = tcx.def_ident_span(param_def_id).unwrap();
let name = tcx.item_name(param_def_id);
let name = tcx.item_ident(param_def_id);
let span = name.span;

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

for param_def_id in uncovered {
let span = tcx.def_ident_span(param_def_id).unwrap();
let name = tcx.item_name(param_def_id);
let name = tcx.item_ident(param_def_id);

match local_ty {
Some(local_type) => tcx.emit_node_span_lint(
Expand Down
11 changes: 5 additions & 6 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ fn lower_enum_variant_types(tcx: TyCtxt<'_>, def_id: DefId) {
tcx.dcx().emit_err(errors::EnumDiscriminantOverflowed {
span,
discr: prev_discr.unwrap().to_string(),
item_name: tcx.item_name(variant.def_id),
item_name: tcx.item_ident(variant.def_id),
wrapped_discr: wrapped_discr.to_string(),
});
None
Expand Down Expand Up @@ -990,11 +990,10 @@ impl<'tcx> FieldUniquenessCheckContext<'tcx> {
}

/// Check if a given field `ident` declared at `field_decl` has been declared elsewhere before.
fn check_field_decl(&mut self, ident: Ident, field_decl: FieldDeclSpan) {
fn check_field_decl(&mut self, field_name: Ident, field_decl: FieldDeclSpan) {
use FieldDeclSpan::*;
let field_name = ident.name;
let ident = ident.normalize_to_macros_2_0();
match (field_decl, self.seen_fields.get(&ident).copied()) {
let field_name = field_name.normalize_to_macros_2_0();
match (field_decl, self.seen_fields.get(&field_name).copied()) {
(NotNested(span), Some(NotNested(prev_span))) => {
self.tcx.dcx().emit_err(errors::FieldAlreadyDeclared::NotNested {
field_name,
Expand Down Expand Up @@ -1035,7 +1034,7 @@ impl<'tcx> FieldUniquenessCheckContext<'tcx> {
});
}
(field_decl, None) => {
self.seen_fields.insert(ident, field_decl);
self.seen_fields.insert(field_name, field_decl);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub(super) fn find_opaque_ty_constraints_for_impl_trait_in_assoc_type(
} else {
let reported = tcx.dcx().emit_err(UnconstrainedOpaqueType {
span: tcx.def_span(def_id),
name: tcx.item_name(parent_def_id.to_def_id()),
name: tcx.item_ident(parent_def_id.to_def_id()),
what: "impl",
});
Ty::new_error(tcx, reported)
Expand Down Expand Up @@ -136,7 +136,7 @@ pub(super) fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: Local
}
let reported = tcx.dcx().emit_err(UnconstrainedOpaqueType {
span: tcx.def_span(def_id),
name: tcx.item_name(parent_def_id.to_def_id()),
name: tcx.item_ident(parent_def_id.to_def_id()),
what: match tcx.hir_node(scope) {
_ if scope == hir::CRATE_HIR_ID => "module",
Node::Item(hir::Item { kind: hir::ItemKind::Mod(_), .. }) => "module",
Expand Down
32 changes: 16 additions & 16 deletions compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pub(crate) struct DropImplOnWrongItem {
pub(crate) enum FieldAlreadyDeclared {
#[diag(hir_analysis_field_already_declared, code = E0124)]
NotNested {
field_name: Symbol,
field_name: Ident,
#[primary_span]
#[label]
span: Span,
Expand All @@ -226,7 +226,7 @@ pub(crate) enum FieldAlreadyDeclared {
},
#[diag(hir_analysis_field_already_declared_current_nested)]
CurrentNested {
field_name: Symbol,
field_name: Ident,
#[primary_span]
#[label]
span: Span,
Expand All @@ -239,7 +239,7 @@ pub(crate) enum FieldAlreadyDeclared {
},
#[diag(hir_analysis_field_already_declared_previous_nested)]
PreviousNested {
field_name: Symbol,
field_name: Ident,
#[primary_span]
#[label]
span: Span,
Expand All @@ -252,7 +252,7 @@ pub(crate) enum FieldAlreadyDeclared {
},
#[diag(hir_analysis_field_already_declared_both_nested)]
BothNested {
field_name: Symbol,
field_name: Ident,
#[primary_span]
#[label]
span: Span,
Expand Down Expand Up @@ -418,7 +418,7 @@ pub(crate) struct ValueOfAssociatedStructAlreadySpecified {
pub(crate) struct UnconstrainedOpaqueType {
#[primary_span]
pub span: Span,
pub name: Symbol,
pub name: Ident,
pub what: &'static str,
}

Expand Down Expand Up @@ -802,7 +802,7 @@ pub(crate) struct EnumDiscriminantOverflowed {
#[label]
pub span: Span,
pub discr: String,
pub item_name: Symbol,
pub item_name: Ident,
pub wrapped_discr: String,
}

Expand Down Expand Up @@ -893,15 +893,15 @@ pub(crate) enum ImplNotMarkedDefault {
span: Span,
#[label(hir_analysis_ok_label)]
ok_label: Span,
ident: Symbol,
ident: Ident,
},
#[diag(hir_analysis_impl_not_marked_default_err, code = E0520)]
#[note]
Err {
#[primary_span]
span: Span,
cname: Symbol,
ident: Symbol,
ident: Ident,
},
}

Expand Down Expand Up @@ -977,7 +977,7 @@ pub(crate) struct MissingTraitItemUnstable {
pub some_note: bool,
#[note(hir_analysis_none_note)]
pub none_note: bool,
pub missing_item_name: Symbol,
pub missing_item_name: Ident,
pub feature: Symbol,
pub reason: String,
}
Expand Down Expand Up @@ -1249,7 +1249,7 @@ pub(crate) struct InherentNominal {
pub(crate) struct DispatchFromDynZST<'a> {
#[primary_span]
pub span: Span,
pub name: Symbol,
pub name: Ident,
pub ty: Ty<'a>,
}

Expand Down Expand Up @@ -1389,7 +1389,7 @@ pub(crate) struct TyParamFirstLocal<'tcx> {
pub span: Span,
#[note(hir_analysis_case_note)]
pub note: (),
pub param: Symbol,
pub param: Ident,
pub local_type: Ty<'tcx>,
}

Expand All @@ -1401,7 +1401,7 @@ pub(crate) struct TyParamFirstLocalLint<'tcx> {
pub span: Span,
#[note(hir_analysis_case_note)]
pub note: (),
pub param: Symbol,
pub param: Ident,
pub local_type: Ty<'tcx>,
}

Expand All @@ -1414,7 +1414,7 @@ pub(crate) struct TyParamSome {
pub span: Span,
#[note(hir_analysis_only_note)]
pub note: (),
pub param: Symbol,
pub param: Ident,
}

#[derive(LintDiagnostic)]
Expand All @@ -1425,7 +1425,7 @@ pub(crate) struct TyParamSomeLint {
pub span: Span,
#[note(hir_analysis_only_note)]
pub note: (),
pub param: Symbol,
pub param: Ident,
}

#[derive(Diagnostic)]
Expand Down Expand Up @@ -1533,7 +1533,7 @@ pub(crate) struct UnsupportedDelegation<'a> {
pub(crate) struct MethodShouldReturnFuture {
#[primary_span]
pub span: Span,
pub method_name: Symbol,
pub method_name: Ident,
#[note]
pub trait_item_span: Option<Span>,
}
Expand Down Expand Up @@ -1585,7 +1585,7 @@ pub(crate) struct UnconstrainedGenericParameter {
#[primary_span]
#[label]
pub span: Span,
pub param_name: Symbol,
pub param_name: Ident,
pub param_def_kind: &'static str,
#[note(hir_analysis_const_param_note)]
pub const_param_note: bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
.iter()
.any(|constraint| constraint.ident.name == item.name)
})
.map(|item| item.name.to_ident_string())
.map(|item| self.tcx.item_ident(item.def_id).to_string())
.collect()
} else {
Vec::default()
Expand Down
Loading

0 comments on commit ebcf860

Please sign in to comment.