Skip to content

Commit fd4d50d

Browse files
committed
Move diagnostic_items queries to librustc_passes.
1 parent 2a14d16 commit fd4d50d

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ pub mod lint;
9999
pub mod middle {
100100
pub mod cstore;
101101
pub mod dependency_format;
102-
pub mod diagnostic_items;
103102
pub mod exported_symbols;
104103
pub mod free_region;
105104
pub mod lang_items;

src/librustc/ty/context.rs

-8
Original file line numberDiff line numberDiff line change
@@ -2759,14 +2759,6 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
27592759
assert_eq!(id, LOCAL_CRATE);
27602760
tcx.arena.alloc(middle::lang_items::collect(tcx))
27612761
};
2762-
providers.diagnostic_items = |tcx, id| {
2763-
assert_eq!(id, LOCAL_CRATE);
2764-
middle::diagnostic_items::collect(tcx)
2765-
};
2766-
providers.all_diagnostic_items = |tcx, id| {
2767-
assert_eq!(id, LOCAL_CRATE);
2768-
middle::diagnostic_items::collect_all(tcx)
2769-
};
27702762
providers.maybe_unused_trait_import = |tcx, id| tcx.maybe_unused_trait_imports.contains(&id);
27712763
providers.maybe_unused_extern_crates = |tcx, cnum| {
27722764
assert_eq!(cnum, LOCAL_CRATE);

src/librustc_passes/diagnostic_items.rs

+19-7
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
//!
1010
//! * Compiler internal types like `Ty` and `TyCtxt`
1111
12-
use crate::hir::def_id::{DefId, LOCAL_CRATE};
13-
use crate::ty::TyCtxt;
14-
use crate::util::nodemap::FxHashMap;
12+
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
13+
use rustc::ty::query::Providers;
14+
use rustc::ty::TyCtxt;
15+
use rustc::util::nodemap::FxHashMap;
1516

16-
use crate::hir;
17-
use crate::hir::itemlikevisit::ItemLikeVisitor;
17+
use rustc::hir;
18+
use rustc::hir::itemlikevisit::ItemLikeVisitor;
1819
use syntax::ast;
1920
use syntax::symbol::{sym, Symbol};
2021

@@ -93,7 +94,7 @@ fn extract(attrs: &[ast::Attribute]) -> Option<Symbol> {
9394
}
9495

9596
/// Traverse and collect the diagnostic items in the current
96-
pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
97+
fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
9798
// Initialize the collector.
9899
let mut collector = DiagnosticItemCollector::new(tcx);
99100

@@ -104,7 +105,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
104105
}
105106

106107
/// Traverse and collect all the diagnostic items in all crates.
107-
pub fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
108+
fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
108109
// Initialize the collector.
109110
let mut collector = FxHashMap::default();
110111

@@ -117,3 +118,14 @@ pub fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
117118

118119
tcx.arena.alloc(collector)
119120
}
121+
122+
pub fn provide(providers: &mut Providers<'_>) {
123+
providers.diagnostic_items = |tcx, id| {
124+
assert_eq!(id, LOCAL_CRATE);
125+
collect(tcx)
126+
};
127+
providers.all_diagnostic_items = |tcx, id| {
128+
assert_eq!(id, LOCAL_CRATE);
129+
collect_all(tcx)
130+
};
131+
}

src/librustc_passes/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use rustc::ty::query::Providers;
2222
pub mod ast_validation;
2323
mod check_const;
2424
pub mod dead;
25+
mod diagnostic_items;
2526
pub mod entry;
2627
pub mod hir_stats;
2728
mod intrinsicck;
@@ -32,6 +33,7 @@ mod reachable;
3233

3334
pub fn provide(providers: &mut Providers<'_>) {
3435
check_const::provide(providers);
36+
diagnostic_items::provide(providers);
3537
entry::provide(providers);
3638
loops::provide(providers);
3739
liveness::provide(providers);

0 commit comments

Comments
 (0)