Skip to content

Commit fd3bfb3

Browse files
committed
Auto merge of #104330 - CastilloDel:ast_lowering, r=cjgillot
Remove allow(rustc::potential_query_instability) from rustc_ast_lowering Related to #84447. `@cjgillot` Thanks for helping me!
2 parents 9d46c7a + 5572263 commit fd3bfb3

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

compiler/rustc_ast_lowering/src/asm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use super::LoweringContext;
1111

1212
use rustc_ast::ptr::P;
1313
use rustc_ast::*;
14-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
14+
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
1515
use rustc_hir as hir;
1616
use rustc_hir::def::{DefKind, Res};
1717
use rustc_hir::definitions::DefPathData;
@@ -71,7 +71,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
7171
.emit();
7272
}
7373

74-
let mut clobber_abis = FxHashMap::default();
74+
let mut clobber_abis = FxIndexMap::default();
7575
if let Some(asm_arch) = asm_arch {
7676
for (abi_name, abi_span) in &asm.clobber_abis {
7777
match asm::InlineAsmClobberAbi::parse(asm_arch, &self.tcx.sess.target, *abi_name) {

compiler/rustc_ast_lowering/src/item.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use super::{FnDeclKind, LoweringContext, ParamMode};
66
use rustc_ast::ptr::P;
77
use rustc_ast::visit::AssocCtxt;
88
use rustc_ast::*;
9-
use rustc_data_structures::fx::FxHashMap;
109
use rustc_data_structures::sorted_map::SortedMap;
1110
use rustc_hir as hir;
1211
use rustc_hir::def::{DefKind, Res};
@@ -67,7 +66,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
6766
// HirId handling.
6867
bodies: Vec::new(),
6968
attrs: SortedMap::default(),
70-
children: FxHashMap::default(),
69+
children: Vec::default(),
7170
current_hir_id_owner: hir::CRATE_OWNER_ID,
7271
item_local_id_counter: hir::ItemLocalId::new(0),
7372
node_id_to_local_id: Default::default(),
@@ -534,12 +533,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
534533
for new_node_id in [id1, id2] {
535534
let new_id = self.local_def_id(new_node_id);
536535
let Some(res) = resolutions.next() else {
536+
debug_assert!(self.children.iter().find(|(id, _)| id == &new_id).is_none());
537537
// Associate an HirId to both ids even if there is no resolution.
538-
let _old = self.children.insert(
538+
self.children.push((
539539
new_id,
540-
hir::MaybeOwner::NonOwner(hir::HirId::make_owner(new_id)),
540+
hir::MaybeOwner::NonOwner(hir::HirId::make_owner(new_id))),
541541
);
542-
debug_assert!(_old.is_none());
543542
continue;
544543
};
545544
let ident = *ident;

compiler/rustc_ast_lowering/src/lib.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#![feature(let_chains)]
3535
#![feature(never_type)]
3636
#![recursion_limit = "256"]
37-
#![allow(rustc::potential_query_instability)]
3837
#![deny(rustc::untranslatable_diagnostic)]
3938
#![deny(rustc::diagnostic_outside_of_impl)]
4039

@@ -107,7 +106,7 @@ struct LoweringContext<'a, 'hir> {
107106
/// Attributes inside the owner being lowered.
108107
attrs: SortedMap<hir::ItemLocalId, &'hir [Attribute]>,
109108
/// Collect items that were created by lowering the current owner.
110-
children: FxHashMap<LocalDefId, hir::MaybeOwner<&'hir hir::OwnerInfo<'hir>>>,
109+
children: Vec<(LocalDefId, hir::MaybeOwner<&'hir hir::OwnerInfo<'hir>>)>,
111110

112111
generator_kind: Option<hir::GeneratorKind>,
113112

@@ -611,8 +610,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
611610
self.impl_trait_defs = current_impl_trait_defs;
612611
self.impl_trait_bounds = current_impl_trait_bounds;
613612

614-
let _old = self.children.insert(def_id, hir::MaybeOwner::Owner(info));
615-
debug_assert!(_old.is_none())
613+
debug_assert!(self.children.iter().find(|(id, _)| id == &def_id).is_none());
614+
self.children.push((def_id, hir::MaybeOwner::Owner(info)));
616615
}
617616

618617
/// Installs the remapping `remap` in scope while `f` is being executed.
@@ -719,8 +718,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
719718

720719
assert_ne!(local_id, hir::ItemLocalId::new(0));
721720
if let Some(def_id) = self.opt_local_def_id(ast_node_id) {
722-
// Do not override a `MaybeOwner::Owner` that may already here.
723-
self.children.entry(def_id).or_insert(hir::MaybeOwner::NonOwner(hir_id));
721+
self.children.push((def_id, hir::MaybeOwner::NonOwner(hir_id)));
724722
self.local_id_to_def_id.insert(local_id, def_id);
725723
}
726724

0 commit comments

Comments
 (0)