Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 15df8ec

Browse files
committedMar 25, 2025
Auto merge of rust-lang#138923 - TaKO8Ki:rollup-f3hkmqj, r=TaKO8Ki
Rollup of 9 pull requests Successful merges: - rust-lang#138385 (Keyword tweaks) - rust-lang#138580 (resolve: Avoid some unstable iteration 2) - rust-lang#138652 (Reintroduce remote-test support in run-make tests) - rust-lang#138701 (Make default_codegen_backend serializable) - rust-lang#138755 ([rustdoc] Remove duplicated loop when computing doc cfgs) - rust-lang#138829 (Slightly reword triagebot ping message for `relnotes-interest-group`) - rust-lang#138837 (resolve: Avoid remaining unstable iteration) - rust-lang#138838 (Fix/tweak some tests in new solver) - rust-lang#138895 (Add a helper for building an owner id in ast lowering) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7d49ae9 + 3757104 commit 15df8ec

File tree

30 files changed

+214
-155
lines changed

30 files changed

+214
-155
lines changed
 

‎compiler/rustc_ast/src/token.rs

-5
Original file line numberDiff line numberDiff line change
@@ -928,11 +928,6 @@ impl Token {
928928
self.is_non_raw_ident_where(Ident::is_path_segment_keyword)
929929
}
930930

931-
/// Don't use this unless you're doing something very loose and heuristic-y.
932-
pub fn is_any_keyword(&self) -> bool {
933-
self.is_non_raw_ident_where(Ident::is_any_keyword)
934-
}
935-
936931
/// Returns true for reserved identifiers used internally for elided lifetimes,
937932
/// unnamed method parameters, crate root module, error recovery etc.
938933
pub fn is_special_ident(&self) -> bool {

‎compiler/rustc_ast_lowering/src/item.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
132132
}
133133

134134
pub(super) fn lower_item_ref(&mut self, i: &Item) -> SmallVec<[hir::ItemId; 1]> {
135-
let mut node_ids =
136-
smallvec![hir::ItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } }];
135+
let mut node_ids = smallvec![hir::ItemId { owner_id: self.owner_id(i.id) }];
137136
if let ItemKind::Use(use_tree) = &i.kind {
138137
self.lower_item_id_use_tree(use_tree, &mut node_ids);
139138
}
@@ -144,9 +143,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
144143
match &tree.kind {
145144
UseTreeKind::Nested { items, .. } => {
146145
for &(ref nested, id) in items {
147-
vec.push(hir::ItemId {
148-
owner_id: hir::OwnerId { def_id: self.local_def_id(id) },
149-
});
146+
vec.push(hir::ItemId { owner_id: self.owner_id(id) });
150147
self.lower_item_id_use_tree(nested, vec);
151148
}
152149
}
@@ -585,7 +582,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
585582

586583
// Add all the nested `PathListItem`s to the HIR.
587584
for &(ref use_tree, id) in trees {
588-
let new_hir_id = self.local_def_id(id);
585+
let owner_id = self.owner_id(id);
589586

590587
// Each `use` import is an item and thus are owners of the
591588
// names in the path. Up to this point the nested import is
@@ -602,7 +599,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
602599
}
603600

604601
let item = hir::Item {
605-
owner_id: hir::OwnerId { def_id: new_hir_id },
602+
owner_id,
606603
kind,
607604
vis_span,
608605
span: this.lower_span(use_tree.span),
@@ -710,7 +707,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
710707

711708
fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemRef {
712709
hir::ForeignItemRef {
713-
id: hir::ForeignItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
710+
id: hir::ForeignItemId { owner_id: self.owner_id(i.id) },
714711
ident: self.lower_ident(i.ident),
715712
span: self.lower_span(i.span),
716713
}
@@ -931,7 +928,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
931928
panic!("macros should have been expanded by now")
932929
}
933930
};
934-
let id = hir::TraitItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } };
931+
let id = hir::TraitItemId { owner_id: self.owner_id(i.id) };
935932
hir::TraitItemRef {
936933
id,
937934
ident: self.lower_ident(i.ident),
@@ -1046,7 +1043,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10461043

10471044
fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemRef {
10481045
hir::ImplItemRef {
1049-
id: hir::ImplItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
1046+
id: hir::ImplItemId { owner_id: self.owner_id(i.id) },
10501047
ident: self.lower_ident(i.ident),
10511048
span: self.lower_span(i.span),
10521049
kind: match &i.kind {

‎compiler/rustc_ast_lowering/src/lib.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
536536
self.opt_local_def_id(node).unwrap_or_else(|| panic!("no entry for node id: `{node:?}`"))
537537
}
538538

539+
/// Given the id of an owner node in the AST, returns the corresponding `OwnerId`.
540+
fn owner_id(&self, node: NodeId) -> hir::OwnerId {
541+
hir::OwnerId { def_id: self.local_def_id(node) }
542+
}
543+
539544
/// Freshen the `LoweringContext` and ready it to lower a nested item.
540545
/// The lowered item is registered into `self.children`.
541546
///
@@ -547,7 +552,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
547552
owner: NodeId,
548553
f: impl FnOnce(&mut Self) -> hir::OwnerNode<'hir>,
549554
) {
550-
let def_id = self.local_def_id(owner);
555+
let owner_id = self.owner_id(owner);
551556

552557
let current_attrs = std::mem::take(&mut self.attrs);
553558
let current_bodies = std::mem::take(&mut self.bodies);
@@ -558,8 +563,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
558563
#[cfg(debug_assertions)]
559564
let current_node_id_to_local_id = std::mem::take(&mut self.node_id_to_local_id);
560565
let current_trait_map = std::mem::take(&mut self.trait_map);
561-
let current_owner =
562-
std::mem::replace(&mut self.current_hir_id_owner, hir::OwnerId { def_id });
566+
let current_owner = std::mem::replace(&mut self.current_hir_id_owner, owner_id);
563567
let current_local_counter =
564568
std::mem::replace(&mut self.item_local_id_counter, hir::ItemLocalId::new(1));
565569
let current_impl_trait_defs = std::mem::take(&mut self.impl_trait_defs);
@@ -577,7 +581,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
577581
}
578582

579583
let item = f(self);
580-
debug_assert_eq!(def_id, item.def_id().def_id);
584+
debug_assert_eq!(owner_id, item.def_id());
581585
// `f` should have consumed all the elements in these vectors when constructing `item`.
582586
debug_assert!(self.impl_trait_defs.is_empty());
583587
debug_assert!(self.impl_trait_bounds.is_empty());
@@ -598,8 +602,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
598602
self.impl_trait_defs = current_impl_trait_defs;
599603
self.impl_trait_bounds = current_impl_trait_bounds;
600604

601-
debug_assert!(!self.children.iter().any(|(id, _)| id == &def_id));
602-
self.children.push((def_id, hir::MaybeOwner::Owner(info)));
605+
debug_assert!(!self.children.iter().any(|(id, _)| id == &owner_id.def_id));
606+
self.children.push((owner_id.def_id, hir::MaybeOwner::Owner(info)));
603607
}
604608

605609
fn make_owner_info(&mut self, node: hir::OwnerNode<'hir>) -> &'hir hir::OwnerInfo<'hir> {

‎compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -971,15 +971,17 @@ where
971971
rhs: T,
972972
) -> Result<(), NoSolution> {
973973
let goals = self.delegate.relate(param_env, lhs, variance, rhs, self.origin_span)?;
974-
if cfg!(debug_assertions) {
975-
for g in goals.iter() {
976-
match g.predicate.kind().skip_binder() {
977-
ty::PredicateKind::Subtype { .. } | ty::PredicateKind::AliasRelate(..) => {}
978-
p => unreachable!("unexpected nested goal in `relate`: {p:?}"),
974+
for &goal in goals.iter() {
975+
let source = match goal.predicate.kind().skip_binder() {
976+
ty::PredicateKind::Subtype { .. } | ty::PredicateKind::AliasRelate(..) => {
977+
GoalSource::TypeRelating
979978
}
980-
}
979+
// FIXME(-Znext-solver=coinductive): should these WF goals also be unproductive?
980+
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => GoalSource::Misc,
981+
p => unreachable!("unexpected nested goal in `relate`: {p:?}"),
982+
};
983+
self.add_goal(source, goal);
981984
}
982-
self.add_goals(GoalSource::TypeRelating, goals);
983985
Ok(())
984986
}
985987

‎compiler/rustc_resolve/src/build_reduced_graph.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,6 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
11151115
}
11161116
});
11171117
} else {
1118-
#[allow(rustc::potential_query_instability)] // FIXME
11191118
for ident in single_imports.iter().cloned() {
11201119
let result = self.r.maybe_resolve_ident_in_module(
11211120
ModuleOrUniformRoot::Module(module),

‎compiler/rustc_resolve/src/diagnostics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
14681468
return;
14691469
}
14701470

1471-
#[allow(rustc::potential_query_instability)] // FIXME
14721471
let unused_macro = self.unused_macros.iter().find_map(|(def_id, (_, unused_ident))| {
14731472
if unused_ident.name == ident.name { Some((def_id, unused_ident)) } else { None }
14741473
});

‎compiler/rustc_resolve/src/ident.rs

-1
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
946946

947947
// Check if one of single imports can still define the name,
948948
// if it can then our result is not determined and can be invalidated.
949-
#[allow(rustc::potential_query_instability)] // FIXME
950949
for single_import in &resolution.single_imports {
951950
if ignore_import == Some(*single_import) {
952951
// This branch handles a cycle in single imports.

‎compiler/rustc_resolve/src/imports.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::cell::Cell;
44
use std::mem;
55

66
use rustc_ast::NodeId;
7-
use rustc_data_structures::fx::FxHashSet;
7+
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
88
use rustc_data_structures::intern::Interned;
99
use rustc_errors::codes::*;
1010
use rustc_errors::{Applicability, MultiSpan, pluralize, struct_span_code_err};
@@ -233,7 +233,7 @@ impl<'ra> ImportData<'ra> {
233233
pub(crate) struct NameResolution<'ra> {
234234
/// Single imports that may define the name in the namespace.
235235
/// Imports are arena-allocated, so it's ok to use pointers as keys.
236-
pub single_imports: FxHashSet<Import<'ra>>,
236+
pub single_imports: FxIndexSet<Import<'ra>>,
237237
/// The least shadowable known binding for this name, or None if there are no known bindings.
238238
pub binding: Option<NameBinding<'ra>>,
239239
pub shadowed_glob: Option<NameBinding<'ra>>,
@@ -494,7 +494,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
494494
let key = BindingKey::new(target, ns);
495495
let _ = this.try_define(import.parent_scope.module, key, dummy_binding, false);
496496
this.update_resolution(import.parent_scope.module, key, false, |_, resolution| {
497-
resolution.single_imports.remove(&import);
497+
resolution.single_imports.swap_remove(&import);
498498
})
499499
});
500500
self.record_use(target, dummy_binding, Used::Other);
@@ -862,7 +862,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
862862
}
863863
let key = BindingKey::new(target, ns);
864864
this.update_resolution(parent, key, false, |_, resolution| {
865-
resolution.single_imports.remove(&import);
865+
resolution.single_imports.swap_remove(&import);
866866
});
867867
}
868868
}

‎compiler/rustc_resolve/src/late.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ impl RibKind<'_> {
272272
/// resolving, the name is looked up from inside out.
273273
#[derive(Debug)]
274274
pub(crate) struct Rib<'ra, R = Res> {
275-
pub bindings: FxHashMap<Ident, R>,
275+
pub bindings: FxIndexMap<Ident, R>,
276276
pub patterns_with_skipped_bindings: UnordMap<DefId, Vec<(Span, Result<(), ErrorGuaranteed>)>>,
277277
pub kind: RibKind<'ra>,
278278
}
@@ -672,7 +672,7 @@ struct DiagMetadata<'ast> {
672672

673673
/// A list of labels as of yet unused. Labels will be removed from this map when
674674
/// they are used (in a `break` or `continue` statement)
675-
unused_labels: FxHashMap<NodeId, Span>,
675+
unused_labels: FxIndexMap<NodeId, Span>,
676676

677677
/// Only used for better errors on `let x = { foo: bar };`.
678678
/// In the case of a parse error with `let x = { foo: bar, };`, this isn't needed, it's only
@@ -1639,8 +1639,8 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
16391639

16401640
// Allow all following defaults to refer to this type parameter.
16411641
let i = &Ident::with_dummy_span(param.ident.name);
1642-
forward_ty_ban_rib.bindings.remove(i);
1643-
forward_ty_ban_rib_const_param_ty.bindings.remove(i);
1642+
forward_ty_ban_rib.bindings.swap_remove(i);
1643+
forward_ty_ban_rib_const_param_ty.bindings.swap_remove(i);
16441644
}
16451645
GenericParamKind::Const { ref ty, kw_span: _, ref default } => {
16461646
// Const parameters can't have param bounds.
@@ -1675,8 +1675,8 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
16751675

16761676
// Allow all following defaults to refer to this const parameter.
16771677
let i = &Ident::with_dummy_span(param.ident.name);
1678-
forward_const_ban_rib.bindings.remove(i);
1679-
forward_const_ban_rib_const_param_ty.bindings.remove(i);
1678+
forward_const_ban_rib.bindings.swap_remove(i);
1679+
forward_const_ban_rib_const_param_ty.bindings.swap_remove(i);
16801680
}
16811681
}
16821682
}
@@ -2885,7 +2885,6 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
28852885
break;
28862886
}
28872887

2888-
#[allow(rustc::potential_query_instability)] // FIXME
28892888
seen_bindings
28902889
.extend(parent_rib.bindings.keys().map(|ident| (*ident, ident.span)));
28912890
}
@@ -4000,7 +3999,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
40003999
}
40014000
}
40024001

4003-
fn innermost_rib_bindings(&mut self, ns: Namespace) -> &mut FxHashMap<Ident, Res> {
4002+
fn innermost_rib_bindings(&mut self, ns: Namespace) -> &mut FxIndexMap<Ident, Res> {
40044003
&mut self.ribs[ns].last_mut().unwrap().bindings
40054004
}
40064005

@@ -4776,7 +4775,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
47764775
Ok((node_id, _)) => {
47774776
// Since this res is a label, it is never read.
47784777
self.r.label_res_map.insert(expr.id, node_id);
4779-
self.diag_metadata.unused_labels.remove(&node_id);
4778+
self.diag_metadata.unused_labels.swap_remove(&node_id);
47804779
}
47814780
Err(error) => {
47824781
self.report_error(label.ident.span, error);
@@ -5198,7 +5197,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
51985197
let mut late_resolution_visitor = LateResolutionVisitor::new(self);
51995198
late_resolution_visitor.resolve_doc_links(&krate.attrs, MaybeExported::Ok(CRATE_NODE_ID));
52005199
visit::walk_crate(&mut late_resolution_visitor, krate);
5201-
#[allow(rustc::potential_query_instability)] // FIXME
52025200
for (id, span) in late_resolution_visitor.diag_metadata.unused_labels.iter() {
52035201
self.lint_buffer.buffer_lint(
52045202
lint::builtin::UNUSED_LABELS,

‎compiler/rustc_resolve/src/late/diagnostics.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,6 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
830830
if let Some(rib) = &self.last_block_rib
831831
&& let RibKind::Normal = rib.kind
832832
{
833-
#[allow(rustc::potential_query_instability)] // FIXME
834833
for (ident, &res) in &rib.bindings {
835834
if let Res::Local(_) = res
836835
&& path.len() == 1
@@ -1019,7 +1018,6 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
10191018
if let Some(err_code) = err.code {
10201019
if err_code == E0425 {
10211020
for label_rib in &self.label_ribs {
1022-
#[allow(rustc::potential_query_instability)] // FIXME
10231021
for (label_ident, node_id) in &label_rib.bindings {
10241022
let ident = path.last().unwrap().ident;
10251023
if format!("'{ident}") == label_ident.to_string() {
@@ -1036,7 +1034,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
10361034
Applicability::MaybeIncorrect,
10371035
);
10381036
// Do not lint against unused label when we suggest them.
1039-
self.diag_metadata.unused_labels.remove(node_id);
1037+
self.diag_metadata.unused_labels.swap_remove(node_id);
10401038
}
10411039
}
10421040
}
@@ -2265,7 +2263,6 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
22652263
};
22662264

22672265
// Locals and type parameters
2268-
#[allow(rustc::potential_query_instability)] // FIXME
22692266
for (ident, &res) in &rib.bindings {
22702267
if filter_fn(res) && ident.span.ctxt() == rib_ctxt {
22712268
names.push(TypoSuggestion::typo_from_ident(*ident, res));
@@ -2793,7 +2790,6 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
27932790
let within_scope = self.is_label_valid_from_rib(rib_index);
27942791

27952792
let rib = &self.label_ribs[rib_index];
2796-
#[allow(rustc::potential_query_instability)] // FIXME
27972793
let names = rib
27982794
.bindings
27992795
.iter()
@@ -2805,7 +2801,6 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
28052801
// Upon finding a similar name, get the ident that it was from - the span
28062802
// contained within helps make a useful diagnostic. In addition, determine
28072803
// whether this candidate is within scope.
2808-
#[allow(rustc::potential_query_instability)] // FIXME
28092804
let (ident, _) = rib.bindings.iter().find(|(ident, _)| ident.name == symbol).unwrap();
28102805
(*ident, within_scope)
28112806
})

‎compiler/rustc_resolve/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ pub struct Resolver<'ra, 'tcx> {
11371137
non_macro_attr: MacroData,
11381138
local_macro_def_scopes: FxHashMap<LocalDefId, Module<'ra>>,
11391139
ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>,
1140-
unused_macros: FxHashMap<LocalDefId, (NodeId, Ident)>,
1140+
unused_macros: FxIndexMap<LocalDefId, (NodeId, Ident)>,
11411141
/// A map from the macro to all its potentially unused arms.
11421142
unused_macro_rules: FxIndexMap<LocalDefId, UnordMap<usize, (Ident, Span)>>,
11431143
proc_macro_stubs: FxHashSet<LocalDefId>,

‎compiler/rustc_resolve/src/macros.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
323323
}
324324

325325
fn check_unused_macros(&mut self) {
326-
#[allow(rustc::potential_query_instability)] // FIXME
327326
for (_, &(node_id, ident)) in self.unused_macros.iter() {
328327
self.lint_buffer.buffer_lint(
329328
UNUSED_MACROS,
@@ -576,7 +575,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
576575
match res {
577576
Res::Def(DefKind::Macro(_), def_id) => {
578577
if let Some(def_id) = def_id.as_local() {
579-
self.unused_macros.remove(&def_id);
578+
self.unused_macros.swap_remove(&def_id);
580579
if self.proc_macro_stubs.contains(&def_id) {
581580
self.dcx().emit_err(errors::ProcMacroSameCrate {
582581
span: path.span,
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.