Skip to content

Commit c8905ec

Browse files
committed
Revert "Move trait_map into hir::Crate"
This reverts commit 936b6bf.
1 parent 879ac1d commit c8905ec

File tree

6 files changed

+15
-20
lines changed

6 files changed

+15
-20
lines changed

src/librustc_ast_lowering/lib.rs

-10
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ pub trait Resolver {
203203
fn lint_buffer(&mut self) -> &mut LintBuffer;
204204

205205
fn next_node_id(&mut self) -> NodeId;
206-
207-
fn trait_map(&self) -> &NodeMap<Vec<hir::TraitCandidate>>;
208206
}
209207

210208
type NtToTokenstream = fn(&Nonterminal, &ParseSess, Span) -> TokenStream;
@@ -557,13 +555,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
557555
let proc_macros =
558556
c.proc_macros.iter().map(|id| self.node_id_to_hir_id[*id].unwrap()).collect();
559557

560-
let trait_map = self
561-
.resolver
562-
.trait_map()
563-
.iter()
564-
.map(|(&k, v)| (self.node_id_to_hir_id[k].unwrap(), v.clone()))
565-
.collect();
566-
567558
self.resolver.definitions().init_node_id_to_hir_id_mapping(self.node_id_to_hir_id);
568559

569560
hir::Crate {
@@ -578,7 +569,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
578569
trait_impls: self.trait_impls,
579570
modules: self.modules,
580571
proc_macros,
581-
trait_map,
582572
}
583573
}
584574

src/librustc_hir/hir.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,6 @@ pub struct Crate<'hir> {
639639
/// A list of proc macro HirIds, written out in the order in which
640640
/// they are declared in the static array generated by proc_macro_harness.
641641
pub proc_macros: Vec<HirId>,
642-
643-
pub trait_map: BTreeMap<HirId, Vec<TraitCandidate>>,
644642
}
645643

646644
impl Crate<'hir> {
@@ -2653,7 +2651,7 @@ pub type CaptureModeMap = NodeMap<CaptureBy>;
26532651
// The TraitCandidate's import_ids is empty if the trait is defined in the same module, and
26542652
// has length > 0 if the trait is found through an chain of imports, starting with the
26552653
// import/use statement in the scope where the trait is used.
2656-
#[derive(RustcEncodable, RustcDecodable, Clone, Debug)]
2654+
#[derive(Clone, Debug)]
26572655
pub struct TraitCandidate {
26582656
pub def_id: DefId,
26592657
pub import_ids: SmallVec<[LocalDefId; 1]>,

src/librustc_middle/hir/map/collector.rs

-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
117117
body_ids: _,
118118
modules: _,
119119
proc_macros: _,
120-
trait_map: _,
121120
} = *krate;
122121

123122
hash_body(&mut hcx, root_mod_def_path_hash, item, &mut hir_body_nodes)

src/librustc_middle/ty/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1120,9 +1120,9 @@ impl<'tcx> TyCtxt<'tcx> {
11201120
};
11211121

11221122
let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default();
1123-
for (hir_id, v) in krate.trait_map.iter() {
1123+
for (hir_id, v) in resolutions.trait_map.into_iter() {
11241124
let map = trait_map.entry(hir_id.owner).or_default();
1125-
map.insert(hir_id.local_id, StableVec::new(v.to_vec()));
1125+
map.insert(hir_id.local_id, StableVec::new(v));
11261126
}
11271127

11281128
GlobalCtxt {

src/librustc_middle/ty/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ pub struct ResolverOutputs {
121121
pub definitions: rustc_hir::definitions::Definitions,
122122
pub cstore: Box<CrateStoreDyn>,
123123
pub extern_crate_map: FxHashMap<LocalDefId, CrateNum>,
124+
pub trait_map: FxHashMap<hir::HirId, Vec<hir::TraitCandidate>>,
124125
pub maybe_unused_trait_imports: FxHashSet<LocalDefId>,
125126
pub maybe_unused_extern_crates: Vec<(LocalDefId, Span)>,
126127
pub export_map: ExportMap<LocalDefId>,

src/librustc_resolve/lib.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -1109,10 +1109,6 @@ impl rustc_ast_lowering::Resolver for Resolver<'_> {
11091109
fn next_node_id(&mut self) -> NodeId {
11101110
self.next_node_id()
11111111
}
1112-
1113-
fn trait_map(&self) -> &NodeMap<Vec<TraitCandidate>> {
1114-
&self.trait_map
1115-
}
11161112
}
11171113

11181114
impl<'a> Resolver<'a> {
@@ -1288,6 +1284,11 @@ impl<'a> Resolver<'a> {
12881284
let definitions = self.definitions;
12891285
let extern_crate_map = self.extern_crate_map;
12901286
let export_map = self.export_map;
1287+
let trait_map = self
1288+
.trait_map
1289+
.into_iter()
1290+
.map(|(k, v)| (definitions.node_id_to_hir_id(k), v))
1291+
.collect();
12911292
let maybe_unused_trait_imports = self.maybe_unused_trait_imports;
12921293
let maybe_unused_extern_crates = self.maybe_unused_extern_crates;
12931294
let glob_map = self.glob_map;
@@ -1296,6 +1297,7 @@ impl<'a> Resolver<'a> {
12961297
cstore: Box::new(self.crate_loader.into_cstore()),
12971298
extern_crate_map,
12981299
export_map,
1300+
trait_map,
12991301
glob_map,
13001302
maybe_unused_trait_imports,
13011303
maybe_unused_extern_crates,
@@ -1313,6 +1315,11 @@ impl<'a> Resolver<'a> {
13131315
cstore: Box::new(self.cstore().clone()),
13141316
extern_crate_map: self.extern_crate_map.clone(),
13151317
export_map: self.export_map.clone(),
1318+
trait_map: self
1319+
.trait_map
1320+
.iter()
1321+
.map(|(&k, v)| (self.definitions.node_id_to_hir_id(k), v.clone()))
1322+
.collect(),
13161323
glob_map: self.glob_map.clone(),
13171324
maybe_unused_trait_imports: self.maybe_unused_trait_imports.clone(),
13181325
maybe_unused_extern_crates: self.maybe_unused_extern_crates.clone(),

0 commit comments

Comments
 (0)