mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 03:38:29 +00:00
Move diagnostic_items queries to librustc_passes.
This commit is contained in:
parent
2a14d16583
commit
fd4d50d442
@ -99,7 +99,6 @@ pub mod lint;
|
|||||||
pub mod middle {
|
pub mod middle {
|
||||||
pub mod cstore;
|
pub mod cstore;
|
||||||
pub mod dependency_format;
|
pub mod dependency_format;
|
||||||
pub mod diagnostic_items;
|
|
||||||
pub mod exported_symbols;
|
pub mod exported_symbols;
|
||||||
pub mod free_region;
|
pub mod free_region;
|
||||||
pub mod lang_items;
|
pub mod lang_items;
|
||||||
|
@ -2759,14 +2759,6 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
|
|||||||
assert_eq!(id, LOCAL_CRATE);
|
assert_eq!(id, LOCAL_CRATE);
|
||||||
tcx.arena.alloc(middle::lang_items::collect(tcx))
|
tcx.arena.alloc(middle::lang_items::collect(tcx))
|
||||||
};
|
};
|
||||||
providers.diagnostic_items = |tcx, id| {
|
|
||||||
assert_eq!(id, LOCAL_CRATE);
|
|
||||||
middle::diagnostic_items::collect(tcx)
|
|
||||||
};
|
|
||||||
providers.all_diagnostic_items = |tcx, id| {
|
|
||||||
assert_eq!(id, LOCAL_CRATE);
|
|
||||||
middle::diagnostic_items::collect_all(tcx)
|
|
||||||
};
|
|
||||||
providers.maybe_unused_trait_import = |tcx, id| tcx.maybe_unused_trait_imports.contains(&id);
|
providers.maybe_unused_trait_import = |tcx, id| tcx.maybe_unused_trait_imports.contains(&id);
|
||||||
providers.maybe_unused_extern_crates = |tcx, cnum| {
|
providers.maybe_unused_extern_crates = |tcx, cnum| {
|
||||||
assert_eq!(cnum, LOCAL_CRATE);
|
assert_eq!(cnum, LOCAL_CRATE);
|
||||||
|
@ -9,12 +9,13 @@
|
|||||||
//!
|
//!
|
||||||
//! * Compiler internal types like `Ty` and `TyCtxt`
|
//! * Compiler internal types like `Ty` and `TyCtxt`
|
||||||
|
|
||||||
use crate::hir::def_id::{DefId, LOCAL_CRATE};
|
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
|
||||||
use crate::ty::TyCtxt;
|
use rustc::ty::query::Providers;
|
||||||
use crate::util::nodemap::FxHashMap;
|
use rustc::ty::TyCtxt;
|
||||||
|
use rustc::util::nodemap::FxHashMap;
|
||||||
|
|
||||||
use crate::hir;
|
use rustc::hir;
|
||||||
use crate::hir::itemlikevisit::ItemLikeVisitor;
|
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::symbol::{sym, Symbol};
|
use syntax::symbol::{sym, Symbol};
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ fn extract(attrs: &[ast::Attribute]) -> Option<Symbol> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Traverse and collect the diagnostic items in the current
|
/// Traverse and collect the diagnostic items in the current
|
||||||
pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
|
fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
|
||||||
// Initialize the collector.
|
// Initialize the collector.
|
||||||
let mut collector = DiagnosticItemCollector::new(tcx);
|
let mut collector = DiagnosticItemCollector::new(tcx);
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Traverse and collect all the diagnostic items in all crates.
|
/// Traverse and collect all the diagnostic items in all crates.
|
||||||
pub fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
|
fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
|
||||||
// Initialize the collector.
|
// Initialize the collector.
|
||||||
let mut collector = FxHashMap::default();
|
let mut collector = FxHashMap::default();
|
||||||
|
|
||||||
@ -117,3 +118,14 @@ pub fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
|
|||||||
|
|
||||||
tcx.arena.alloc(collector)
|
tcx.arena.alloc(collector)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn provide(providers: &mut Providers<'_>) {
|
||||||
|
providers.diagnostic_items = |tcx, id| {
|
||||||
|
assert_eq!(id, LOCAL_CRATE);
|
||||||
|
collect(tcx)
|
||||||
|
};
|
||||||
|
providers.all_diagnostic_items = |tcx, id| {
|
||||||
|
assert_eq!(id, LOCAL_CRATE);
|
||||||
|
collect_all(tcx)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -22,6 +22,7 @@ use rustc::ty::query::Providers;
|
|||||||
pub mod ast_validation;
|
pub mod ast_validation;
|
||||||
mod check_const;
|
mod check_const;
|
||||||
pub mod dead;
|
pub mod dead;
|
||||||
|
mod diagnostic_items;
|
||||||
pub mod entry;
|
pub mod entry;
|
||||||
pub mod hir_stats;
|
pub mod hir_stats;
|
||||||
mod intrinsicck;
|
mod intrinsicck;
|
||||||
@ -32,6 +33,7 @@ mod reachable;
|
|||||||
|
|
||||||
pub fn provide(providers: &mut Providers<'_>) {
|
pub fn provide(providers: &mut Providers<'_>) {
|
||||||
check_const::provide(providers);
|
check_const::provide(providers);
|
||||||
|
diagnostic_items::provide(providers);
|
||||||
entry::provide(providers);
|
entry::provide(providers);
|
||||||
loops::provide(providers);
|
loops::provide(providers);
|
||||||
liveness::provide(providers);
|
liveness::provide(providers);
|
||||||
|
Loading…
Reference in New Issue
Block a user