mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
Auto merge of #85178 - cjgillot:local-crate, r=oli-obk
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
This commit is contained in:
commit
3396a383bb
@ -13,7 +13,7 @@ pub(crate) fn codegen(
|
||||
module: &mut impl Module,
|
||||
unwind_context: &mut UnwindContext,
|
||||
) -> bool {
|
||||
let any_dynamic_crate = tcx.dependency_formats(LOCAL_CRATE).iter().any(|(_, list)| {
|
||||
let any_dynamic_crate = tcx.dependency_formats(()).iter().any(|(_, list)| {
|
||||
use rustc_middle::middle::dependency_format::Linkage;
|
||||
list.iter().any(|&linkage| linkage == Linkage::Dynamic)
|
||||
});
|
||||
|
@ -42,7 +42,7 @@ fn emit_module(
|
||||
|
||||
unwind_context.emit(&mut product);
|
||||
|
||||
let tmp_file = tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(&name));
|
||||
let tmp_file = tcx.output_filenames(()).temp_path(OutputType::Object, Some(&name));
|
||||
let obj = product.object.write().unwrap();
|
||||
if let Err(err) = std::fs::write(&tmp_file, obj) {
|
||||
tcx.sess.fatal(&format!("error writing object file: {}", err));
|
||||
@ -74,7 +74,7 @@ fn reuse_workproduct_for_cgu(
|
||||
let work_product = cgu.work_product(tcx);
|
||||
if let Some(saved_file) = &work_product.saved_file {
|
||||
let obj_out = tcx
|
||||
.output_filenames(LOCAL_CRATE)
|
||||
.output_filenames(())
|
||||
.temp_path(OutputType::Object, Some(&cgu.name().as_str()));
|
||||
object = Some(obj_out.clone());
|
||||
let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file);
|
||||
@ -190,7 +190,7 @@ pub(crate) fn run_aot(
|
||||
let mut work_products = FxHashMap::default();
|
||||
|
||||
let cgus = if tcx.sess.opts.output_types.should_codegen() {
|
||||
tcx.collect_and_partition_mono_items(LOCAL_CRATE).1
|
||||
tcx.collect_and_partition_mono_items(()).1
|
||||
} else {
|
||||
// If only `--emit metadata` is used, we shouldn't perform any codegen.
|
||||
// Also `tcx.collect_and_partition_mono_items` may panic in that case.
|
||||
@ -276,7 +276,7 @@ pub(crate) fn run_aot(
|
||||
.to_string();
|
||||
|
||||
let tmp_file = tcx
|
||||
.output_filenames(LOCAL_CRATE)
|
||||
.output_filenames(())
|
||||
.temp_path(OutputType::Metadata, Some(&metadata_cgu_name));
|
||||
|
||||
let obj = crate::backend::with_object(tcx.sess, &metadata_cgu_name, |object| {
|
||||
@ -353,7 +353,7 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) {
|
||||
.join("\n");
|
||||
|
||||
let output_object_file =
|
||||
tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(cgu_name));
|
||||
tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu_name));
|
||||
|
||||
// Assemble `global_asm`
|
||||
let global_asm_object_file = add_file_stem_postfix(output_object_file.clone(), ".asm");
|
||||
|
@ -8,7 +8,6 @@ use std::os::raw::{c_char, c_int};
|
||||
use cranelift_codegen::binemit::{NullStackMapSink, NullTrapSink};
|
||||
use rustc_codegen_ssa::CrateInfo;
|
||||
use rustc_middle::mir::mono::MonoItem;
|
||||
use rustc_session::config::EntryFnType;
|
||||
|
||||
use cranelift_jit::{JITBuilder, JITModule};
|
||||
|
||||
@ -66,7 +65,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
|
||||
matches!(backend_config.codegen_mode, CodegenMode::JitLazy),
|
||||
);
|
||||
|
||||
let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
|
||||
let (_, cgus) = tcx.collect_and_partition_mono_items(());
|
||||
let mono_items = cgus
|
||||
.iter()
|
||||
.map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter())
|
||||
@ -179,7 +178,7 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> {
|
||||
let mut dylib_paths = Vec::new();
|
||||
|
||||
let crate_info = CrateInfo::new(tcx);
|
||||
let formats = tcx.dependency_formats(LOCAL_CRATE);
|
||||
let formats = tcx.dependency_formats(());
|
||||
let data = &formats
|
||||
.iter()
|
||||
.find(|(crate_type, _data)| *crate_type == rustc_session::config::CrateType::Executable)
|
||||
|
@ -15,7 +15,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
||||
unwind_context: &mut UnwindContext,
|
||||
is_jit: bool,
|
||||
) {
|
||||
let (main_def_id, is_main_fn) = match tcx.entry_fn(LOCAL_CRATE) {
|
||||
let (main_def_id, is_main_fn) = match tcx.entry_fn(()) {
|
||||
Some((def_id, entry_ty)) => (
|
||||
def_id,
|
||||
match entry_ty {
|
||||
|
@ -214,7 +214,7 @@ pub(crate) fn write_ir_file(
|
||||
return;
|
||||
}
|
||||
|
||||
let clif_output_dir = tcx.output_filenames(LOCAL_CRATE).with_extension("clif");
|
||||
let clif_output_dir = tcx.output_filenames(()).with_extension("clif");
|
||||
|
||||
match std::fs::create_dir(&clif_output_dir) {
|
||||
Ok(()) => {}
|
||||
|
@ -20,7 +20,6 @@ use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use rustc_errors::{FatalError, Handler, Level};
|
||||
use rustc_fs_util::{link_or_copy, path_to_c_string};
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::config::{self, Lto, OutputType, Passes, SwitchWithOptPath};
|
||||
@ -92,13 +91,12 @@ pub fn create_informational_target_machine(sess: &Session) -> &'static mut llvm:
|
||||
|
||||
pub fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> &'static mut llvm::TargetMachine {
|
||||
let split_dwarf_file = if tcx.sess.target_can_use_split_dwarf() {
|
||||
tcx.output_filenames(LOCAL_CRATE)
|
||||
.split_dwarf_path(tcx.sess.split_debuginfo(), Some(mod_name))
|
||||
tcx.output_filenames(()).split_dwarf_path(tcx.sess.split_debuginfo(), Some(mod_name))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let config = TargetMachineFactoryConfig { split_dwarf_file };
|
||||
target_machine_factory(&tcx.sess, tcx.backend_optimization_level(LOCAL_CRATE))(config)
|
||||
target_machine_factory(&tcx.sess, tcx.backend_optimization_level(()))(config)
|
||||
.unwrap_or_else(|err| llvm_err(tcx.sess.diagnostic(), &err).raise())
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ use llvm::coverageinfo::CounterMappingRegion;
|
||||
use rustc_codegen_ssa::coverageinfo::map::{Counter, CounterExpression};
|
||||
use rustc_codegen_ssa::traits::{ConstMethods, CoverageInfoMethods};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
|
||||
use rustc_hir::def_id::{DefId, DefIdSet, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, DefIdSet};
|
||||
use rustc_llvm::RustString;
|
||||
use rustc_middle::mir::coverage::CodeRegion;
|
||||
use rustc_span::Symbol;
|
||||
@ -265,7 +265,7 @@ fn add_unused_functions<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) {
|
||||
let ignore_unused_generics = tcx.sess.instrument_coverage_except_unused_generics();
|
||||
|
||||
let all_def_ids: DefIdSet = tcx
|
||||
.mir_keys(LOCAL_CRATE)
|
||||
.mir_keys(())
|
||||
.iter()
|
||||
.filter_map(|local_def_id| {
|
||||
let def_id = local_def_id.to_def_id();
|
||||
@ -276,7 +276,7 @@ fn add_unused_functions<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let codegenned_def_ids = tcx.codegened_and_inlined_items(LOCAL_CRATE);
|
||||
let codegenned_def_ids = tcx.codegened_and_inlined_items(());
|
||||
|
||||
let mut unused_def_ids_by_file: FxHashMap<Symbol, Vec<DefId>> = FxHashMap::default();
|
||||
for &non_codegenned_def_id in all_def_ids.difference(codegenned_def_ids) {
|
||||
|
@ -995,9 +995,10 @@ pub fn compile_unit_metadata(
|
||||
let name_in_debuginfo = name_in_debuginfo.to_string_lossy();
|
||||
let work_dir = tcx.sess.working_dir.to_string_lossy(false);
|
||||
let flags = "\0";
|
||||
let out_dir = &tcx.output_filenames(LOCAL_CRATE).out_directory;
|
||||
let output_filenames = tcx.output_filenames(());
|
||||
let out_dir = &output_filenames.out_directory;
|
||||
let split_name = if tcx.sess.target_can_use_split_dwarf() {
|
||||
tcx.output_filenames(LOCAL_CRATE)
|
||||
output_filenames
|
||||
.split_dwarf_path(tcx.sess.split_debuginfo(), Some(codegen_unit_name))
|
||||
.map(|f| out_dir.join(f))
|
||||
} else {
|
||||
@ -1058,15 +1059,12 @@ pub fn compile_unit_metadata(
|
||||
if tcx.sess.opts.debugging_opts.profile {
|
||||
let cu_desc_metadata =
|
||||
llvm::LLVMRustMetadataAsValue(debug_context.llcontext, unit_metadata);
|
||||
let default_gcda_path = &tcx.output_filenames(LOCAL_CRATE).with_extension("gcda");
|
||||
let default_gcda_path = &output_filenames.with_extension("gcda");
|
||||
let gcda_path =
|
||||
tcx.sess.opts.debugging_opts.profile_emit.as_ref().unwrap_or(default_gcda_path);
|
||||
|
||||
let gcov_cu_info = [
|
||||
path_to_mdstring(
|
||||
debug_context.llcontext,
|
||||
&tcx.output_filenames(LOCAL_CRATE).with_extension("gcno"),
|
||||
),
|
||||
path_to_mdstring(debug_context.llcontext, &output_filenames.with_extension("gcno")),
|
||||
path_to_mdstring(debug_context.llcontext, &gcda_path),
|
||||
cu_desc_metadata,
|
||||
];
|
||||
|
@ -23,7 +23,7 @@ use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, Variab
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_hir::def_id::{DefId, DefIdMap, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, DefIdMap};
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::layout::HasTyCtxt;
|
||||
@ -343,7 +343,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
if self.sess().opts.optimize != config::OptLevel::No {
|
||||
spflags |= DISPFlags::SPFlagOptimized;
|
||||
}
|
||||
if let Some((id, _)) = self.tcx.entry_fn(LOCAL_CRATE) {
|
||||
if let Some((id, _)) = self.tcx.entry_fn(()) {
|
||||
if id == def_id {
|
||||
spflags |= DISPFlags::SPFlagMainSubprogram;
|
||||
}
|
||||
|
@ -1303,7 +1303,7 @@ fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<String> {
|
||||
}
|
||||
}
|
||||
|
||||
let formats = tcx.dependency_formats(LOCAL_CRATE);
|
||||
let formats = tcx.dependency_formats(());
|
||||
let deps = formats.iter().find_map(|(t, list)| (*t == crate_type).then_some(list)).unwrap();
|
||||
|
||||
for (index, dep_format) in deps.iter().enumerate() {
|
||||
|
@ -4,7 +4,7 @@ use rustc_ast::expand::allocator::ALLOCATOR_METHODS;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::Node;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
@ -60,7 +60,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
|
||||
tcx.is_panic_runtime(LOCAL_CRATE) || tcx.is_compiler_builtins(LOCAL_CRATE);
|
||||
|
||||
let mut reachable_non_generics: DefIdMap<_> = tcx
|
||||
.reachable_set(LOCAL_CRATE)
|
||||
.reachable_set(())
|
||||
.iter()
|
||||
.filter_map(|&def_id| {
|
||||
// We want to ignore some FFI functions that are not exposed from
|
||||
@ -133,12 +133,12 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
|
||||
})
|
||||
.collect();
|
||||
|
||||
if let Some(id) = tcx.proc_macro_decls_static(LOCAL_CRATE) {
|
||||
reachable_non_generics.insert(id, SymbolExportLevel::C);
|
||||
if let Some(id) = tcx.proc_macro_decls_static(()) {
|
||||
reachable_non_generics.insert(id.to_def_id(), SymbolExportLevel::C);
|
||||
}
|
||||
|
||||
if let Some(id) = tcx.plugin_registrar_fn(LOCAL_CRATE) {
|
||||
reachable_non_generics.insert(id, SymbolExportLevel::C);
|
||||
if let Some(id) = tcx.plugin_registrar_fn(()) {
|
||||
reachable_non_generics.insert(id.to_def_id(), SymbolExportLevel::C);
|
||||
}
|
||||
|
||||
reachable_non_generics
|
||||
@ -174,7 +174,7 @@ fn exported_symbols_provider_local(
|
||||
.map(|(&def_id, &level)| (ExportedSymbol::NonGeneric(def_id), level))
|
||||
.collect();
|
||||
|
||||
if tcx.entry_fn(LOCAL_CRATE).is_some() {
|
||||
if tcx.entry_fn(()).is_some() {
|
||||
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, "main"));
|
||||
|
||||
symbols.push((exported_symbol, SymbolExportLevel::C));
|
||||
@ -230,7 +230,7 @@ fn exported_symbols_provider_local(
|
||||
// external linkage is enough for monomorphization to be linked to.
|
||||
let need_visibility = tcx.sess.target.dynamic_linking && !tcx.sess.target.only_cdylib;
|
||||
|
||||
let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
|
||||
let (_, cgus) = tcx.collect_and_partition_mono_items(());
|
||||
|
||||
for (mono_item, &(linkage, visibility)) in cgus.iter().flat_map(|cgu| cgu.items().iter()) {
|
||||
if linkage != Linkage::External {
|
||||
@ -275,11 +275,9 @@ fn exported_symbols_provider_local(
|
||||
|
||||
fn upstream_monomorphizations_provider(
|
||||
tcx: TyCtxt<'_>,
|
||||
cnum: CrateNum,
|
||||
(): (),
|
||||
) -> DefIdMap<FxHashMap<SubstsRef<'_>, CrateNum>> {
|
||||
debug_assert!(cnum == LOCAL_CRATE);
|
||||
|
||||
let cnums = tcx.all_crate_nums(LOCAL_CRATE);
|
||||
let cnums = tcx.all_crate_nums(());
|
||||
|
||||
let mut instances: DefIdMap<FxHashMap<_, _>> = Default::default();
|
||||
|
||||
@ -341,7 +339,7 @@ fn upstream_monomorphizations_for_provider(
|
||||
def_id: DefId,
|
||||
) -> Option<&FxHashMap<SubstsRef<'_>, CrateNum>> {
|
||||
debug_assert!(!def_id.is_local());
|
||||
tcx.upstream_monomorphizations(LOCAL_CRATE).get(&def_id)
|
||||
tcx.upstream_monomorphizations(()).get(&def_id)
|
||||
}
|
||||
|
||||
fn upstream_drop_glue_for_provider<'tcx>(
|
||||
@ -355,12 +353,8 @@ fn upstream_drop_glue_for_provider<'tcx>(
|
||||
}
|
||||
}
|
||||
|
||||
fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
if let Some(def_id) = def_id.as_local() {
|
||||
!tcx.reachable_set(LOCAL_CRATE).contains(&def_id)
|
||||
} else {
|
||||
bug!("is_unreachable_local_definition called with non-local DefId: {:?}", def_id)
|
||||
}
|
||||
fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
||||
!tcx.reachable_set(()).contains(&def_id)
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
|
@ -482,7 +482,7 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
|
||||
codegen_worker_receive,
|
||||
shared_emitter_main,
|
||||
future: coordinator_thread,
|
||||
output_filenames: tcx.output_filenames(LOCAL_CRATE),
|
||||
output_filenames: tcx.output_filenames(()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1042,7 +1042,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
||||
// If we know that we won’t be doing codegen, create target machines without optimisation.
|
||||
config::OptLevel::No
|
||||
} else {
|
||||
tcx.backend_optimization_level(LOCAL_CRATE)
|
||||
tcx.backend_optimization_level(())
|
||||
};
|
||||
let cgcx = CodegenContext::<B> {
|
||||
backend: backend.clone(),
|
||||
@ -1061,7 +1061,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
||||
cgu_reuse_tracker: sess.cgu_reuse_tracker.clone(),
|
||||
coordinator_send,
|
||||
diag_emitter: shared_emitter.clone(),
|
||||
output_filenames: tcx.output_filenames(LOCAL_CRATE),
|
||||
output_filenames: tcx.output_filenames(()),
|
||||
regular_module_config: regular_config,
|
||||
metadata_module_config: metadata_config,
|
||||
allocator_module_config: allocator_config,
|
||||
|
@ -347,7 +347,7 @@ pub fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
cx: &'a Bx::CodegenCx,
|
||||
) -> Option<Bx::Function> {
|
||||
let main_def_id = cx.tcx().entry_fn(LOCAL_CRATE).map(|(def_id, _)| def_id)?;
|
||||
let (main_def_id, entry_type) = cx.tcx().entry_fn(())?;
|
||||
let main_is_local = main_def_id.is_local();
|
||||
let instance = Instance::mono(cx.tcx(), main_def_id);
|
||||
|
||||
@ -364,10 +364,9 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
|
||||
let main_llfn = cx.get_fn_addr(instance);
|
||||
|
||||
return cx.tcx().entry_fn(LOCAL_CRATE).map(|(_, et)| {
|
||||
let use_start_lang_item = EntryFnType::Start != et;
|
||||
create_entry_fn::<Bx>(cx, main_llfn, main_def_id, use_start_lang_item)
|
||||
});
|
||||
let use_start_lang_item = EntryFnType::Start != entry_type;
|
||||
let entry_fn = create_entry_fn::<Bx>(cx, main_llfn, main_def_id, use_start_lang_item);
|
||||
return Some(entry_fn);
|
||||
|
||||
fn create_entry_fn<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
cx: &'a Bx::CodegenCx,
|
||||
@ -487,7 +486,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
||||
|
||||
// Run the monomorphization collector and partition the collected items into
|
||||
// codegen units.
|
||||
let codegen_units = tcx.collect_and_partition_mono_items(LOCAL_CRATE).1;
|
||||
let codegen_units = tcx.collect_and_partition_mono_items(()).1;
|
||||
|
||||
// Force all codegen_unit queries so they are already either red or green
|
||||
// when compile_codegen_unit accesses them. We are not able to re-execute
|
||||
@ -512,7 +511,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
||||
// linkage, then it's already got an allocator shim and we'll be using that
|
||||
// one instead. If nothing exists then it's our job to generate the
|
||||
// allocator!
|
||||
let any_dynamic_crate = tcx.dependency_formats(LOCAL_CRATE).iter().any(|(_, list)| {
|
||||
let any_dynamic_crate = tcx.dependency_formats(()).iter().any(|(_, list)| {
|
||||
use rustc_middle::middle::dependency_format::Linkage;
|
||||
list.iter().any(|&linkage| linkage == Linkage::Dynamic)
|
||||
});
|
||||
@ -769,7 +768,7 @@ impl CrateInfo {
|
||||
used_crate_source: Default::default(),
|
||||
lang_item_to_crate: Default::default(),
|
||||
missing_lang_items: Default::default(),
|
||||
dependency_formats: tcx.dependency_formats(LOCAL_CRATE),
|
||||
dependency_formats: tcx.dependency_formats(()),
|
||||
};
|
||||
let lang_items = tcx.lang_items();
|
||||
|
||||
|
@ -21,7 +21,6 @@ use rustc_data_structures::sync::SeqCst;
|
||||
use rustc_errors::registry::{InvalidErrorCode, Registry};
|
||||
use rustc_errors::{ErrorReported, PResult};
|
||||
use rustc_feature::find_gated_cfg;
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_interface::util::{self, collect_crate_types, get_builtin_codegen_backend};
|
||||
use rustc_interface::{interface, Queries};
|
||||
use rustc_lint::LintStore;
|
||||
@ -389,7 +388,7 @@ fn run_compiler(
|
||||
}
|
||||
|
||||
queries.global_ctxt()?.peek_mut().enter(|tcx| {
|
||||
let result = tcx.analysis(LOCAL_CRATE);
|
||||
let result = tcx.analysis(());
|
||||
if sess.opts.debugging_opts.save_analysis {
|
||||
let crate_name = queries.crate_name()?.peek().clone();
|
||||
sess.time("save_analysis", || {
|
||||
|
@ -4,7 +4,6 @@ use rustc_ast as ast;
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_hir_pretty as pprust_hir;
|
||||
use rustc_middle::hir::map as hir_map;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
@ -74,7 +73,7 @@ where
|
||||
f(&annotation, tcx.hir().krate())
|
||||
}
|
||||
PpHirMode::Typed => {
|
||||
abort_on_err(tcx.analysis(LOCAL_CRATE), tcx.sess);
|
||||
abort_on_err(tcx.analysis(()), tcx.sess);
|
||||
|
||||
let annotation = TypedAnnotation { tcx, maybe_typeck_results: Cell::new(None) };
|
||||
tcx.dep_graph.with_ignore(|| f(&annotation, tcx.hir().krate()))
|
||||
@ -475,7 +474,7 @@ fn print_with_analysis(
|
||||
ppm: PpMode,
|
||||
ofile: Option<&Path>,
|
||||
) -> Result<(), ErrorReported> {
|
||||
tcx.analysis(LOCAL_CRATE)?;
|
||||
tcx.analysis(())?;
|
||||
|
||||
let out = match ppm {
|
||||
Mir => {
|
||||
|
@ -36,7 +36,7 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) {
|
||||
}
|
||||
|
||||
let available_cgus = tcx
|
||||
.collect_and_partition_mono_items(LOCAL_CRATE)
|
||||
.collect_and_partition_mono_items(())
|
||||
.1
|
||||
.iter()
|
||||
.map(|cgu| cgu.name().to_string())
|
||||
|
@ -12,7 +12,7 @@ use rustc_data_structures::temp_dir::MaybeTempDir;
|
||||
use rustc_data_structures::{box_region_allow_access, declare_box_region_type, parallel};
|
||||
use rustc_errors::{ErrorReported, PResult};
|
||||
use rustc_expand::base::ExtCtxt;
|
||||
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_hir::Crate;
|
||||
use rustc_lint::LintStore;
|
||||
use rustc_metadata::creader::CStore;
|
||||
@ -805,9 +805,7 @@ pub fn create_global_ctxt<'tcx>(
|
||||
|
||||
/// Runs the resolution, type-checking, region checking and other
|
||||
/// miscellaneous analysis passes on the crate.
|
||||
fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
|
||||
fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
|
||||
rustc_passes::hir_id_validator::check_crate(tcx);
|
||||
|
||||
let sess = tcx.sess;
|
||||
@ -816,15 +814,14 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
|
||||
sess.time("misc_checking_1", || {
|
||||
parallel!(
|
||||
{
|
||||
entry_point = sess
|
||||
.time("looking_for_entry_point", || rustc_passes::entry::find_entry_point(tcx));
|
||||
entry_point = sess.time("looking_for_entry_point", || tcx.entry_fn(()));
|
||||
|
||||
sess.time("looking_for_plugin_registrar", || {
|
||||
plugin::build::find_plugin_registrar(tcx)
|
||||
sess.time("looking_for_plugin_registrar", || tcx.ensure().plugin_registrar_fn(()));
|
||||
|
||||
sess.time("looking_for_derive_registrar", || {
|
||||
tcx.ensure().proc_macro_decls_static(())
|
||||
});
|
||||
|
||||
sess.time("looking_for_derive_registrar", || proc_macro_decls::find(tcx));
|
||||
|
||||
let cstore = tcx
|
||||
.cstore_as_any()
|
||||
.downcast_ref::<CStore>()
|
||||
@ -903,11 +900,11 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
|
||||
sess.time("misc_checking_3", || {
|
||||
parallel!(
|
||||
{
|
||||
tcx.ensure().privacy_access_levels(LOCAL_CRATE);
|
||||
tcx.ensure().privacy_access_levels(());
|
||||
|
||||
parallel!(
|
||||
{
|
||||
tcx.ensure().check_private_in_public(LOCAL_CRATE);
|
||||
tcx.ensure().check_private_in_public(());
|
||||
},
|
||||
{
|
||||
sess.time("death_checking", || rustc_passes::dead::check_crate(tcx));
|
||||
|
@ -1,21 +1,15 @@
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
pub fn find(tcx: TyCtxt<'_>) -> Option<DefId> {
|
||||
tcx.proc_macro_decls_static(LOCAL_CRATE)
|
||||
}
|
||||
|
||||
fn proc_macro_decls_static(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<DefId> {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
|
||||
fn proc_macro_decls_static(tcx: TyCtxt<'_>, (): ()) -> Option<LocalDefId> {
|
||||
let mut finder = Finder { tcx, decls: None };
|
||||
tcx.hir().krate().visit_all_item_likes(&mut finder);
|
||||
|
||||
finder.decls.map(|id| tcx.hir().local_def_id(id).to_def_id())
|
||||
finder.decls.map(|id| tcx.hir().local_def_id(id))
|
||||
}
|
||||
|
||||
struct Finder<'tcx> {
|
||||
|
@ -285,7 +285,7 @@ impl<'tcx> Queries<'tcx> {
|
||||
self.ongoing_codegen.compute(|| {
|
||||
let outputs = self.prepare_outputs()?;
|
||||
self.global_ctxt()?.peek_mut().enter(|tcx| {
|
||||
tcx.analysis(LOCAL_CRATE).ok();
|
||||
tcx.analysis(()).ok();
|
||||
|
||||
// Don't do code generation if there were any errors
|
||||
self.session().compile_status()?;
|
||||
@ -302,7 +302,7 @@ impl<'tcx> Queries<'tcx> {
|
||||
/// to write UI tests that actually test that compilation succeeds without reporting
|
||||
/// an error.
|
||||
fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) {
|
||||
let def_id = match tcx.entry_fn(LOCAL_CRATE) {
|
||||
let def_id = match tcx.entry_fn(()) {
|
||||
Some((def_id, _)) => def_id,
|
||||
_ => return,
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ use crate::{passes::LateLintPassObject, LateContext, LateLintPass, LintStore};
|
||||
use rustc_ast as ast;
|
||||
use rustc_data_structures::sync::{join, par_iter, ParallelIterator};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::intravisit as hir_visit;
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
use rustc_middle::hir::map::Map;
|
||||
@ -375,7 +375,7 @@ fn late_lint_mod_pass<'tcx, T: LateLintPass<'tcx>>(
|
||||
module_def_id: LocalDefId,
|
||||
pass: T,
|
||||
) {
|
||||
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
|
||||
let access_levels = &tcx.privacy_access_levels(());
|
||||
|
||||
let context = LateContext {
|
||||
tcx,
|
||||
@ -423,7 +423,7 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx>>(
|
||||
}
|
||||
|
||||
fn late_lint_pass_crate<'tcx, T: LateLintPass<'tcx>>(tcx: TyCtxt<'tcx>, pass: T) {
|
||||
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
|
||||
let access_levels = &tcx.privacy_access_levels(());
|
||||
|
||||
let krate = tcx.hir().krate();
|
||||
|
||||
|
@ -6,8 +6,7 @@ use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::{intravisit, HirId};
|
||||
use rustc_hir::{intravisit, HirId, CRATE_HIR_ID};
|
||||
use rustc_middle::hir::map::Map;
|
||||
use rustc_middle::lint::LevelAndSource;
|
||||
use rustc_middle::lint::LintDiagnosticBuilder;
|
||||
@ -28,10 +27,9 @@ use tracing::debug;
|
||||
|
||||
use std::cmp;
|
||||
|
||||
fn lint_levels(tcx: TyCtxt<'_>, cnum: CrateNum) -> LintLevelMap {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
fn lint_levels(tcx: TyCtxt<'_>, (): ()) -> LintLevelMap {
|
||||
let store = unerased_lint_store(tcx);
|
||||
let crate_attrs = tcx.get_attrs(DefId { krate: cnum, index: CRATE_DEF_INDEX });
|
||||
let crate_attrs = tcx.hir().attrs(CRATE_HIR_ID);
|
||||
let levels = LintLevelsBuilder::new(tcx.sess, false, &store, crate_attrs);
|
||||
let mut builder = LintLevelMapBuilder { levels, tcx, store };
|
||||
let krate = tcx.hir().krate();
|
||||
|
@ -185,19 +185,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
||||
}
|
||||
native_libraries => { Lrc::new(cdata.get_native_libraries(tcx.sess)) }
|
||||
foreign_modules => { cdata.get_foreign_modules(tcx) }
|
||||
plugin_registrar_fn => {
|
||||
cdata.root.plugin_registrar_fn.map(|index| {
|
||||
DefId { krate: def_id.krate, index }
|
||||
})
|
||||
}
|
||||
proc_macro_decls_static => {
|
||||
cdata.root.proc_macro_data.as_ref().map(|data| {
|
||||
DefId {
|
||||
krate: def_id.krate,
|
||||
index: data.proc_macro_decls_static,
|
||||
}
|
||||
})
|
||||
}
|
||||
crate_disambiguator => { cdata.root.disambiguator }
|
||||
crate_hash => { cdata.root.hash }
|
||||
crate_host_hash => { cdata.host_hash }
|
||||
@ -296,11 +283,10 @@ pub fn provide(providers: &mut Providers) {
|
||||
// external item that is visible from at least one local module) to a
|
||||
// sufficiently visible parent (considering modules that re-export the
|
||||
// external item to be parents).
|
||||
visible_parent_map: |tcx, cnum| {
|
||||
visible_parent_map: |tcx, ()| {
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::collections::vec_deque::VecDeque;
|
||||
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
let mut visible_parent_map: DefIdMap<DefId> = Default::default();
|
||||
|
||||
// Issue 46112: We want the map to prefer the shortest
|
||||
@ -348,7 +334,7 @@ pub fn provide(providers: &mut Providers) {
|
||||
Entry::Occupied(mut entry) => {
|
||||
// If `child` is defined in crate `cnum`, ensure
|
||||
// that it is mapped to a parent in `cnum`.
|
||||
if child.krate == cnum && entry.get().krate != cnum {
|
||||
if child.is_local() && entry.get().is_local() {
|
||||
entry.insert(parent);
|
||||
}
|
||||
}
|
||||
@ -370,17 +356,14 @@ pub fn provide(providers: &mut Providers) {
|
||||
visible_parent_map
|
||||
},
|
||||
|
||||
dependency_formats: |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
Lrc::new(crate::dependency_format::calculate(tcx))
|
||||
},
|
||||
dependency_formats: |tcx, ()| Lrc::new(crate::dependency_format::calculate(tcx)),
|
||||
has_global_allocator: |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
CStore::from_tcx(tcx).has_global_allocator()
|
||||
},
|
||||
postorder_cnums: |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
tcx.arena.alloc_slice(&CStore::from_tcx(tcx).crate_dependencies_in_postorder(cnum))
|
||||
postorder_cnums: |tcx, ()| {
|
||||
tcx.arena
|
||||
.alloc_slice(&CStore::from_tcx(tcx).crate_dependencies_in_postorder(LOCAL_CRATE))
|
||||
},
|
||||
|
||||
..*providers
|
||||
|
@ -678,7 +678,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
has_global_allocator: tcx.has_global_allocator(LOCAL_CRATE),
|
||||
has_panic_handler: tcx.has_panic_handler(LOCAL_CRATE),
|
||||
has_default_lib_allocator,
|
||||
plugin_registrar_fn: tcx.plugin_registrar_fn(LOCAL_CRATE).map(|id| id.index),
|
||||
proc_macro_data,
|
||||
compiler_builtins: tcx.sess.contains_name(&attrs, sym::compiler_builtins),
|
||||
needs_allocator: tcx.sess.contains_name(&attrs, sym::needs_allocator),
|
||||
@ -970,13 +969,12 @@ impl EncodeContext<'a, 'tcx> {
|
||||
record!(self.tables.super_predicates[def_id] <- self.tcx.super_predicates_of(def_id));
|
||||
}
|
||||
}
|
||||
let inherent_impls = tcx.crate_inherent_impls(LOCAL_CRATE);
|
||||
let inherent_impls = tcx.crate_inherent_impls(());
|
||||
for (def_id, implementations) in inherent_impls.inherent_impls.iter() {
|
||||
assert!(def_id.is_local());
|
||||
if implementations.is_empty() {
|
||||
continue;
|
||||
}
|
||||
record!(self.tables.inherent_impls[def_id] <- implementations.iter().map(|&def_id| {
|
||||
record!(self.tables.inherent_impls[def_id.to_def_id()] <- implementations.iter().map(|&def_id| {
|
||||
assert!(def_id.is_local());
|
||||
def_id.index
|
||||
}));
|
||||
@ -1263,7 +1261,7 @@ impl EncodeContext<'a, 'tcx> {
|
||||
|
||||
let mut keys_and_jobs = self
|
||||
.tcx
|
||||
.mir_keys(LOCAL_CRATE)
|
||||
.mir_keys(())
|
||||
.iter()
|
||||
.filter_map(|&def_id| {
|
||||
let (encode_const, encode_opt) = should_encode_mir(self.tcx, def_id);
|
||||
@ -1601,7 +1599,7 @@ impl EncodeContext<'a, 'tcx> {
|
||||
let tcx = self.tcx;
|
||||
let hir = tcx.hir();
|
||||
|
||||
let proc_macro_decls_static = tcx.proc_macro_decls_static(LOCAL_CRATE).unwrap().index;
|
||||
let proc_macro_decls_static = tcx.proc_macro_decls_static(()).unwrap().local_def_index;
|
||||
let stability = tcx.lookup_stability(DefId::local(CRATE_DEF_INDEX)).copied();
|
||||
let macros = self.lazy(hir.krate().proc_macros.iter().map(|p| p.owner.local_def_index));
|
||||
let spans = self.tcx.sess.parse_sess.proc_macro_quoted_spans();
|
||||
@ -1798,7 +1796,7 @@ impl EncodeContext<'a, 'tcx> {
|
||||
|
||||
fn encode_dylib_dependency_formats(&mut self) -> Lazy<[Option<LinkagePreference>]> {
|
||||
empty_proc_macro!(self);
|
||||
let formats = self.tcx.dependency_formats(LOCAL_CRATE);
|
||||
let formats = self.tcx.dependency_formats(());
|
||||
for (ty, arr) in formats.iter() {
|
||||
if *ty != CrateType::Dylib {
|
||||
continue;
|
||||
@ -2028,7 +2026,7 @@ fn prefetch_mir(tcx: TyCtxt<'_>) {
|
||||
return;
|
||||
}
|
||||
|
||||
par_iter(tcx.mir_keys(LOCAL_CRATE)).for_each(|&def_id| {
|
||||
par_iter(tcx.mir_keys(())).for_each(|&def_id| {
|
||||
let (encode_const, encode_opt) = should_encode_mir(tcx, def_id);
|
||||
|
||||
if encode_const {
|
||||
|
@ -209,7 +209,6 @@ crate struct CrateRoot<'tcx> {
|
||||
has_global_allocator: bool,
|
||||
has_panic_handler: bool,
|
||||
has_default_lib_allocator: bool,
|
||||
plugin_registrar_fn: Option<DefIndex>,
|
||||
|
||||
crate_deps: Lazy<[CrateDep]>,
|
||||
dylib_dependency_formats: Lazy<[Option<LinkagePreference>]>,
|
||||
|
@ -150,7 +150,7 @@ impl<'hir> Iterator for ParentOwnerIterator<'_, 'hir> {
|
||||
|
||||
impl<'hir> Map<'hir> {
|
||||
pub fn krate(&self) -> &'hir Crate<'hir> {
|
||||
self.tcx.hir_crate(LOCAL_CRATE)
|
||||
self.tcx.hir_crate(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -489,7 +489,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
|
||||
pub fn trait_impls(&self, trait_did: DefId) -> &'hir [LocalDefId] {
|
||||
self.tcx.all_local_trait_impls(LOCAL_CRATE).get(&trait_did).map_or(&[], |xs| &xs[..])
|
||||
self.tcx.all_local_trait_impls(()).get(&trait_did).map_or(&[], |xs| &xs[..])
|
||||
}
|
||||
|
||||
/// Gets the attributes on the crate. This is preferable to
|
||||
@ -928,9 +928,7 @@ impl<'hir> intravisit::Map<'hir> for Map<'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn index_hir<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> &'tcx IndexedHir<'tcx> {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
|
||||
pub(super) fn index_hir<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> &'tcx IndexedHir<'tcx> {
|
||||
let _prof_timer = tcx.sess.prof.generic_activity("build_hir_map");
|
||||
|
||||
let hcx = tcx.create_stable_hashing_context();
|
||||
@ -943,10 +941,12 @@ pub(super) fn index_hir<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> &'tcx Indexe
|
||||
}
|
||||
|
||||
pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh {
|
||||
assert_eq!(crate_num, LOCAL_CRATE);
|
||||
|
||||
let mut hcx = tcx.create_stable_hashing_context();
|
||||
|
||||
let mut hir_body_nodes: Vec<_> = tcx
|
||||
.index_hir(crate_num)
|
||||
.index_hir(())
|
||||
.map
|
||||
.iter_enumerated()
|
||||
.filter_map(|(def_id, hod)| {
|
||||
|
@ -13,7 +13,7 @@ use rustc_ast::Attribute;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_hir::def_id::{LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::*;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_span::DUMMY_SP;
|
||||
@ -123,14 +123,14 @@ pub fn provide(providers: &mut Providers) {
|
||||
let hir = tcx.hir();
|
||||
hir.local_def_id(hir.get_module_parent_node(hir.local_def_id_to_hir_id(id)))
|
||||
};
|
||||
providers.hir_crate = |tcx, _| tcx.untracked_crate;
|
||||
providers.hir_crate = |tcx, ()| tcx.untracked_crate;
|
||||
providers.index_hir = map::index_hir;
|
||||
providers.crate_hash = map::crate_hash;
|
||||
providers.hir_module_items = |tcx, id| &tcx.untracked_crate.modules[&id];
|
||||
providers.hir_owner = |tcx, id| tcx.index_hir(LOCAL_CRATE).map[id].signature;
|
||||
providers.hir_owner_nodes = |tcx, id| tcx.index_hir(LOCAL_CRATE).map[id].with_bodies.as_deref();
|
||||
providers.hir_owner = |tcx, id| tcx.index_hir(()).map[id].signature;
|
||||
providers.hir_owner_nodes = |tcx, id| tcx.index_hir(()).map[id].with_bodies.as_deref();
|
||||
providers.hir_owner_parent = |tcx, id| {
|
||||
let index = tcx.index_hir(LOCAL_CRATE);
|
||||
let index = tcx.index_hir(());
|
||||
index.parenting.get(&id).copied().unwrap_or(CRATE_HIR_ID)
|
||||
};
|
||||
providers.hir_attrs = |tcx, id| AttributeMap { map: &tcx.untracked_crate.attrs, prefix: id };
|
||||
@ -151,4 +151,5 @@ pub fn provide(providers: &mut Providers) {
|
||||
}
|
||||
};
|
||||
providers.opt_def_kind = |tcx, def_id| tcx.hir().opt_def_kind(def_id.expect_local());
|
||||
providers.all_local_trait_impls = |tcx, ()| &tcx.hir_crate(()).trait_impls;
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ pub fn used_crates(tcx: TyCtxt<'_>, prefer: LinkagePreference) -> Vec<(CrateNum,
|
||||
Some((cnum, path))
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let mut ordering = tcx.postorder_cnums(LOCAL_CRATE).to_owned();
|
||||
let mut ordering = tcx.postorder_cnums(()).to_owned();
|
||||
ordering.reverse();
|
||||
libs.sort_by_cached_key(|&(a, _)| ordering.iter().position(|x| *x == a));
|
||||
libs
|
||||
|
@ -88,7 +88,7 @@ impl<'tcx> MonoItem<'tcx> {
|
||||
|
||||
match *self {
|
||||
MonoItem::Fn(ref instance) => {
|
||||
let entry_def_id = tcx.entry_fn(LOCAL_CRATE).map(|(id, _)| id);
|
||||
let entry_def_id = tcx.entry_fn(()).map(|(id, _)| id);
|
||||
// If this function isn't inlined or otherwise has an extern
|
||||
// indicator, then we'll be creating a globally shared version.
|
||||
if tcx.codegen_fn_attrs(instance.def_id()).contains_extern_indicator()
|
||||
|
@ -20,7 +20,7 @@ rustc_queries! {
|
||||
/// This is because the `hir_crate` query gives you access to all other items.
|
||||
/// To avoid this fate, do not call `tcx.hir().krate()`; instead,
|
||||
/// prefer wrappers like `tcx.visit_all_items_in_krate()`.
|
||||
query hir_crate(key: CrateNum) -> &'tcx Crate<'tcx> {
|
||||
query hir_crate(key: ()) -> &'tcx Crate<'tcx> {
|
||||
eval_always
|
||||
no_hash
|
||||
desc { "get the crate HIR" }
|
||||
@ -28,7 +28,7 @@ rustc_queries! {
|
||||
|
||||
/// The indexed HIR. This can be conveniently accessed by `tcx.hir()`.
|
||||
/// Avoid calling this query directly.
|
||||
query index_hir(_: CrateNum) -> &'tcx crate::hir::IndexedHir<'tcx> {
|
||||
query index_hir(_: ()) -> &'tcx crate::hir::IndexedHir<'tcx> {
|
||||
eval_always
|
||||
no_hash
|
||||
desc { "index HIR" }
|
||||
@ -114,7 +114,7 @@ rustc_queries! {
|
||||
cache_on_disk_if { key.is_local() }
|
||||
}
|
||||
|
||||
query analysis(key: CrateNum) -> Result<(), ErrorReported> {
|
||||
query analysis(key: ()) -> Result<(), ErrorReported> {
|
||||
eval_always
|
||||
desc { "running analysis passes on this crate" }
|
||||
}
|
||||
@ -199,7 +199,7 @@ rustc_queries! {
|
||||
desc { "looking up the native libraries of a linked crate" }
|
||||
}
|
||||
|
||||
query lint_levels(_: CrateNum) -> LintLevelMap {
|
||||
query lint_levels(_: ()) -> LintLevelMap {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "computing the lint levels for items in this crate" }
|
||||
@ -223,7 +223,7 @@ rustc_queries! {
|
||||
/// Set of all the `DefId`s in this crate that have MIR associated with
|
||||
/// them. This includes all the body owners, but also things like struct
|
||||
/// constructors.
|
||||
query mir_keys(_: CrateNum) -> FxHashSet<LocalDefId> {
|
||||
query mir_keys(_: ()) -> FxHashSet<LocalDefId> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "getting a list of all mir_keys" }
|
||||
}
|
||||
@ -543,7 +543,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Gets a map with the variance of every item; use `item_variance` instead.
|
||||
query crate_variances(_: CrateNum) -> ty::CrateVariancesMap<'tcx> {
|
||||
query crate_variances(_: ()) -> ty::CrateVariancesMap<'tcx> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "computing the variances for items in this crate" }
|
||||
}
|
||||
@ -554,8 +554,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Maps from thee `DefId` of a type to its (inferred) outlives.
|
||||
query inferred_outlives_crate(_: CrateNum)
|
||||
-> ty::CratePredicatesMap<'tcx> {
|
||||
query inferred_outlives_crate(_: ()) -> ty::CratePredicatesMap<'tcx> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "computing the inferred outlives predicates for items in this crate" }
|
||||
}
|
||||
@ -694,7 +693,7 @@ rustc_queries! {
|
||||
desc { |tcx| "computing CoerceUnsized info for `{}`", tcx.def_path_str(key) }
|
||||
}
|
||||
|
||||
query typeck_item_bodies(_: CrateNum) -> () {
|
||||
query typeck_item_bodies(_: ()) -> () {
|
||||
desc { "type-checking all item bodies" }
|
||||
}
|
||||
|
||||
@ -753,18 +752,15 @@ rustc_queries! {
|
||||
|
||||
/// Gets a complete map from all types to their inherent impls.
|
||||
/// Not meant to be used directly outside of coherence.
|
||||
/// (Defined only for `LOCAL_CRATE`.)
|
||||
query crate_inherent_impls(k: CrateNum)
|
||||
-> CrateInherentImpls {
|
||||
query crate_inherent_impls(k: ()) -> CrateInherentImpls {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "all inherent impls defined in crate `{:?}`", k }
|
||||
desc { "all inherent impls defined in crate" }
|
||||
}
|
||||
|
||||
/// Checks all types in the crate for overlap in their inherent impls. Reports errors.
|
||||
/// Not meant to be used directly outside of coherence.
|
||||
/// (Defined only for `LOCAL_CRATE`.)
|
||||
query crate_inherent_impls_overlap_check(_: CrateNum)
|
||||
query crate_inherent_impls_overlap_check(_: ())
|
||||
-> () {
|
||||
eval_always
|
||||
desc { "check for overlap between inherent impls defined in this crate" }
|
||||
@ -858,16 +854,16 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Performs part of the privacy check and computes "access levels".
|
||||
query privacy_access_levels(_: CrateNum) -> &'tcx AccessLevels {
|
||||
query privacy_access_levels(_: ()) -> &'tcx AccessLevels {
|
||||
eval_always
|
||||
desc { "privacy access levels" }
|
||||
}
|
||||
query check_private_in_public(_: CrateNum) -> () {
|
||||
query check_private_in_public(_: ()) -> () {
|
||||
eval_always
|
||||
desc { "checking for private elements in public interfaces" }
|
||||
}
|
||||
|
||||
query reachable_set(_: CrateNum) -> FxHashSet<LocalDefId> {
|
||||
query reachable_set(_: ()) -> FxHashSet<LocalDefId> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "reachability" }
|
||||
}
|
||||
@ -977,7 +973,7 @@ rustc_queries! {
|
||||
/// Passing in any other crate will cause an ICE.
|
||||
///
|
||||
/// [`LOCAL_CRATE`]: rustc_hir::def_id::LOCAL_CRATE
|
||||
query all_local_trait_impls(local_crate: CrateNum) -> &'tcx BTreeMap<DefId, Vec<LocalDefId>> {
|
||||
query all_local_trait_impls(_: ()) -> &'tcx BTreeMap<DefId, Vec<LocalDefId>> {
|
||||
desc { "local trait impls" }
|
||||
}
|
||||
|
||||
@ -1080,9 +1076,7 @@ rustc_queries! {
|
||||
desc { "dylib dependency formats of crate" }
|
||||
}
|
||||
|
||||
query dependency_formats(_: CrateNum)
|
||||
-> Lrc<crate::middle::dependency_format::Dependencies>
|
||||
{
|
||||
query dependency_formats(_: ()) -> Lrc<crate::middle::dependency_format::Dependencies> {
|
||||
desc { "get the linkage format of all dependencies" }
|
||||
}
|
||||
|
||||
@ -1170,10 +1164,10 @@ rustc_queries! {
|
||||
query is_reachable_non_generic(def_id: DefId) -> bool {
|
||||
desc { |tcx| "checking whether `{}` is an exported symbol", tcx.def_path_str(def_id) }
|
||||
}
|
||||
query is_unreachable_local_definition(def_id: DefId) -> bool {
|
||||
query is_unreachable_local_definition(def_id: LocalDefId) -> bool {
|
||||
desc { |tcx|
|
||||
"checking whether `{}` is reachable from outside the crate",
|
||||
tcx.def_path_str(def_id),
|
||||
tcx.def_path_str(def_id.to_def_id()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1183,11 +1177,9 @@ rustc_queries! {
|
||||
/// added or removed in any upstream crate. Instead use the narrower
|
||||
/// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even
|
||||
/// better, `Instance::upstream_monomorphization()`.
|
||||
query upstream_monomorphizations(
|
||||
k: CrateNum
|
||||
) -> DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
|
||||
query upstream_monomorphizations(_: ()) -> DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "collecting available upstream monomorphizations `{:?}`", k }
|
||||
desc { "collecting available upstream monomorphizations" }
|
||||
}
|
||||
|
||||
/// Returns the set of upstream monomorphizations available for the
|
||||
@ -1230,13 +1222,13 @@ rustc_queries! {
|
||||
|
||||
/// Identifies the entry-point (e.g., the `main` function) for a given
|
||||
/// crate, returning `None` if there is no entry point (such as for library crates).
|
||||
query entry_fn(_: CrateNum) -> Option<(DefId, EntryFnType)> {
|
||||
query entry_fn(_: ()) -> Option<(DefId, EntryFnType)> {
|
||||
desc { "looking up the entry function of a crate" }
|
||||
}
|
||||
query plugin_registrar_fn(_: CrateNum) -> Option<DefId> {
|
||||
query plugin_registrar_fn(_: ()) -> Option<LocalDefId> {
|
||||
desc { "looking up the plugin registrar for a crate" }
|
||||
}
|
||||
query proc_macro_decls_static(_: CrateNum) -> Option<DefId> {
|
||||
query proc_macro_decls_static(_: ()) -> Option<LocalDefId> {
|
||||
desc { "looking up the derive registrar for a crate" }
|
||||
}
|
||||
query crate_disambiguator(_: CrateNum) -> CrateDisambiguator {
|
||||
@ -1363,7 +1355,7 @@ rustc_queries! {
|
||||
desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id.to_def_id()) }
|
||||
}
|
||||
|
||||
query get_lib_features(_: CrateNum) -> LibFeatures {
|
||||
query get_lib_features(_: ()) -> LibFeatures {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "calculating the lib features map" }
|
||||
@ -1373,16 +1365,14 @@ rustc_queries! {
|
||||
desc { "calculating the lib features defined in a crate" }
|
||||
}
|
||||
/// Returns the lang items defined in another crate by loading it from metadata.
|
||||
// FIXME: It is illegal to pass a `CrateNum` other than `LOCAL_CRATE` here, just get rid
|
||||
// of that argument?
|
||||
query get_lang_items(_: CrateNum) -> LanguageItems {
|
||||
query get_lang_items(_: ()) -> LanguageItems {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "calculating the lang items map" }
|
||||
}
|
||||
|
||||
/// Returns all diagnostic items defined in all crates.
|
||||
query all_diagnostic_items(_: CrateNum) -> FxHashMap<Symbol, DefId> {
|
||||
query all_diagnostic_items(_: ()) -> FxHashMap<Symbol, DefId> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "calculating the diagnostic items map" }
|
||||
@ -1402,13 +1392,11 @@ rustc_queries! {
|
||||
query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
|
||||
desc { "calculating the missing lang items in a crate" }
|
||||
}
|
||||
query visible_parent_map(_: CrateNum)
|
||||
-> DefIdMap<DefId> {
|
||||
query visible_parent_map(_: ()) -> DefIdMap<DefId> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "calculating the visible parent map" }
|
||||
}
|
||||
query trimmed_def_paths(_: CrateNum)
|
||||
-> FxHashMap<DefId, Symbol> {
|
||||
query trimmed_def_paths(_: ()) -> FxHashMap<DefId, Symbol> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "calculating trimmed def paths" }
|
||||
}
|
||||
@ -1420,7 +1408,7 @@ rustc_queries! {
|
||||
eval_always
|
||||
desc { "looking at the source for a crate" }
|
||||
}
|
||||
query postorder_cnums(_: CrateNum) -> &'tcx [CrateNum] {
|
||||
query postorder_cnums(_: ()) -> &'tcx [CrateNum] {
|
||||
eval_always
|
||||
desc { "generating a postorder list of CrateNums" }
|
||||
}
|
||||
@ -1433,8 +1421,7 @@ rustc_queries! {
|
||||
eval_always
|
||||
desc { |tcx| "maybe_unused_trait_import for `{}`", tcx.def_path_str(def_id.to_def_id()) }
|
||||
}
|
||||
query maybe_unused_extern_crates(_: CrateNum)
|
||||
-> &'tcx [(LocalDefId, Span)] {
|
||||
query maybe_unused_extern_crates(_: ()) -> &'tcx [(LocalDefId, Span)] {
|
||||
eval_always
|
||||
desc { "looking up all possibly unused extern crates" }
|
||||
}
|
||||
@ -1444,12 +1431,12 @@ rustc_queries! {
|
||||
desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) }
|
||||
}
|
||||
|
||||
query stability_index(_: CrateNum) -> stability::Index<'tcx> {
|
||||
query stability_index(_: ()) -> stability::Index<'tcx> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "calculating the stability index for the local crate" }
|
||||
}
|
||||
query all_crate_nums(_: CrateNum) -> &'tcx [CrateNum] {
|
||||
query all_crate_nums(_: ()) -> &'tcx [CrateNum] {
|
||||
eval_always
|
||||
desc { "fetching all foreign CrateNum instances" }
|
||||
}
|
||||
@ -1457,7 +1444,7 @@ rustc_queries! {
|
||||
/// A vector of every trait accessible in the whole crate
|
||||
/// (i.e., including those from subcrates). This is used only for
|
||||
/// error reporting.
|
||||
query all_traits(_: CrateNum) -> &'tcx [DefId] {
|
||||
query all_traits(_: ()) -> &'tcx [DefId] {
|
||||
desc { "fetching all foreign and local traits" }
|
||||
}
|
||||
|
||||
@ -1471,8 +1458,7 @@ rustc_queries! {
|
||||
desc { "exported_symbols" }
|
||||
}
|
||||
|
||||
query collect_and_partition_mono_items(_: CrateNum)
|
||||
-> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) {
|
||||
query collect_and_partition_mono_items(_: ()) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) {
|
||||
eval_always
|
||||
desc { "collect_and_partition_mono_items" }
|
||||
}
|
||||
@ -1481,8 +1467,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// All items participating in code generation together with items inlined into them.
|
||||
query codegened_and_inlined_items(_: CrateNum)
|
||||
-> &'tcx DefIdSet {
|
||||
query codegened_and_inlined_items(_: ()) -> &'tcx DefIdSet {
|
||||
eval_always
|
||||
desc { "codegened_and_inlined_items" }
|
||||
}
|
||||
@ -1497,11 +1482,11 @@ rustc_queries! {
|
||||
tcx.def_path_str(key)
|
||||
}
|
||||
}
|
||||
query backend_optimization_level(_: CrateNum) -> OptLevel {
|
||||
query backend_optimization_level(_: ()) -> OptLevel {
|
||||
desc { "optimization level used by backend" }
|
||||
}
|
||||
|
||||
query output_filenames(_: CrateNum) -> Arc<OutputFilenames> {
|
||||
query output_filenames(_: ()) -> Arc<OutputFilenames> {
|
||||
eval_always
|
||||
desc { "output_filenames" }
|
||||
}
|
||||
@ -1677,7 +1662,7 @@ rustc_queries! {
|
||||
desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) }
|
||||
}
|
||||
|
||||
query features_query(_: CrateNum) -> &'tcx rustc_feature::Features {
|
||||
query features_query(_: ()) -> &'tcx rustc_feature::Features {
|
||||
eval_always
|
||||
desc { "looking up enabled feature gates" }
|
||||
}
|
||||
|
@ -1218,18 +1218,18 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
|
||||
pub fn lib_features(self) -> &'tcx middle::lib_features::LibFeatures {
|
||||
self.get_lib_features(LOCAL_CRATE)
|
||||
self.get_lib_features(())
|
||||
}
|
||||
|
||||
/// Obtain all lang items of this crate and all dependencies (recursively)
|
||||
pub fn lang_items(self) -> &'tcx rustc_hir::lang_items::LanguageItems {
|
||||
self.get_lang_items(LOCAL_CRATE)
|
||||
self.get_lang_items(())
|
||||
}
|
||||
|
||||
/// Obtain the given diagnostic item's `DefId`. Use `is_diagnostic_item` if you just want to
|
||||
/// compare against another `DefId`, since `is_diagnostic_item` is cheaper.
|
||||
pub fn get_diagnostic_item(self, name: Symbol) -> Option<DefId> {
|
||||
self.all_diagnostic_items(LOCAL_CRATE).get(&name).copied()
|
||||
self.all_diagnostic_items(()).get(&name).copied()
|
||||
}
|
||||
|
||||
/// Check whether the diagnostic item with the given `name` has the given `DefId`.
|
||||
@ -1238,11 +1238,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
|
||||
pub fn stability(self) -> &'tcx stability::Index<'tcx> {
|
||||
self.stability_index(LOCAL_CRATE)
|
||||
self.stability_index(())
|
||||
}
|
||||
|
||||
pub fn crates(self) -> &'tcx [CrateNum] {
|
||||
self.all_crate_nums(LOCAL_CRATE)
|
||||
self.all_crate_nums(())
|
||||
}
|
||||
|
||||
pub fn allocator_kind(self) -> Option<AllocatorKind> {
|
||||
@ -1250,7 +1250,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
|
||||
pub fn features(self) -> &'tcx rustc_feature::Features {
|
||||
self.features_query(LOCAL_CRATE)
|
||||
self.features_query(())
|
||||
}
|
||||
|
||||
pub fn def_key(self, id: DefId) -> rustc_hir::definitions::DefKey {
|
||||
@ -2623,7 +2623,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
lint: &'static Lint,
|
||||
mut id: hir::HirId,
|
||||
) -> (Level, LintLevelSource) {
|
||||
let sets = self.lint_levels(LOCAL_CRATE);
|
||||
let sets = self.lint_levels(());
|
||||
loop {
|
||||
if let Some(pair) = sets.level_and_source(lint, id, self.sess) {
|
||||
return pair;
|
||||
@ -2795,10 +2795,7 @@ pub fn provide(providers: &mut ty::query::Providers) {
|
||||
tcx.crate_name
|
||||
};
|
||||
providers.maybe_unused_trait_import = |tcx, id| tcx.maybe_unused_trait_imports.contains(&id);
|
||||
providers.maybe_unused_extern_crates = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
&tcx.maybe_unused_extern_crates[..]
|
||||
};
|
||||
providers.maybe_unused_extern_crates = |tcx, ()| &tcx.maybe_unused_extern_crates[..];
|
||||
providers.names_imported_by_glob_use =
|
||||
|tcx, id| tcx.arena.alloc(tcx.glob_map.get(&id).cloned().unwrap_or_default());
|
||||
|
||||
@ -2815,18 +2812,9 @@ pub fn provide(providers: &mut ty::query::Providers) {
|
||||
tcx.stability().local_deprecation_entry(id)
|
||||
};
|
||||
providers.extern_mod_stmt_cnum = |tcx, id| tcx.extern_crate_map.get(&id).cloned();
|
||||
providers.all_crate_nums = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
tcx.arena.alloc_slice(&tcx.cstore.crates_untracked())
|
||||
};
|
||||
providers.output_filenames = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
tcx.output_filenames.clone()
|
||||
};
|
||||
providers.features_query = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
tcx.sess.features_untracked()
|
||||
};
|
||||
providers.all_crate_nums = |tcx, ()| tcx.arena.alloc_slice(&tcx.cstore.crates_untracked());
|
||||
providers.output_filenames = |tcx, ()| tcx.output_filenames.clone();
|
||||
providers.features_query = |tcx, ()| tcx.sess.features_untracked();
|
||||
providers.is_panic_runtime = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
tcx.sess.contains_name(tcx.hir().krate_attrs(), sym::panic_runtime)
|
||||
|
@ -36,7 +36,7 @@ use rustc_data_structures::sync::{self, par_iter, ParallelIterator};
|
||||
use rustc_data_structures::tagged_ptr::CopyTaggedPtr;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalDefIdMap, CRATE_DEF_INDEX};
|
||||
use rustc_hir::{Constness, Node};
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_span::hygiene::ExpnId;
|
||||
@ -1970,7 +1970,6 @@ pub fn provide(providers: &mut ty::query::Providers) {
|
||||
super::util::bug::provide(providers);
|
||||
*providers = ty::query::Providers {
|
||||
trait_impls_of: trait_def::trait_impls_of_provider,
|
||||
all_local_trait_impls: trait_def::all_local_trait_impls,
|
||||
type_uninhabited_from: inhabitedness::type_uninhabited_from,
|
||||
const_param_default: consts::const_param_default,
|
||||
..*providers
|
||||
@ -1984,7 +1983,7 @@ pub fn provide(providers: &mut ty::query::Providers) {
|
||||
/// (constructing this map requires touching the entire crate).
|
||||
#[derive(Clone, Debug, Default, HashStable)]
|
||||
pub struct CrateInherentImpls {
|
||||
pub inherent_impls: DefIdMap<Vec<DefId>>,
|
||||
pub inherent_impls: LocalDefIdMap<Vec<DefId>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, HashStable)]
|
||||
|
@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sso::SsoHashSet;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdSet, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, DefIdSet, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData};
|
||||
use rustc_hir::ItemKind;
|
||||
use rustc_session::config::TrimmedDefPaths;
|
||||
@ -285,7 +285,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||
return Ok((self, false));
|
||||
}
|
||||
|
||||
match self.tcx().trimmed_def_paths(LOCAL_CRATE).get(&def_id) {
|
||||
match self.tcx().trimmed_def_paths(()).get(&def_id) {
|
||||
None => Ok((self, false)),
|
||||
Some(symbol) => {
|
||||
self.write_str(&symbol.as_str())?;
|
||||
@ -361,7 +361,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||
return Ok((self, false));
|
||||
}
|
||||
|
||||
let visible_parent_map = self.tcx().visible_parent_map(LOCAL_CRATE);
|
||||
let visible_parent_map = self.tcx().visible_parent_map(());
|
||||
|
||||
let mut cur_def_key = self.tcx().def_key(def_id);
|
||||
debug!("try_print_visible_def_path: cur_def_key={:?}", cur_def_key);
|
||||
@ -2302,9 +2302,7 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
|
||||
/// `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere.
|
||||
///
|
||||
/// The implementation uses similar import discovery logic to that of 'use' suggestions.
|
||||
fn trimmed_def_paths(tcx: TyCtxt<'_>, crate_num: CrateNum) -> FxHashMap<DefId, Symbol> {
|
||||
assert_eq!(crate_num, LOCAL_CRATE);
|
||||
|
||||
fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> FxHashMap<DefId, Symbol> {
|
||||
let mut map = FxHashMap::default();
|
||||
|
||||
if let TrimmedDefPaths::GoodPath = tcx.sess.opts.trimmed_def_paths {
|
||||
|
@ -579,7 +579,7 @@ impl<'sess> OnDiskCache<'sess> {
|
||||
) -> IndexVec<CrateNum, Option<CrateNum>> {
|
||||
tcx.dep_graph.with_ignore(|| {
|
||||
let current_cnums = tcx
|
||||
.all_crate_nums(LOCAL_CRATE)
|
||||
.all_crate_nums(())
|
||||
.iter()
|
||||
.map(|&cnum| {
|
||||
let crate_name = tcx.original_crate_name(cnum).to_string();
|
||||
|
@ -4,14 +4,13 @@ use crate::ty::fast_reject;
|
||||
use crate::ty::fold::TypeFoldable;
|
||||
use crate::ty::{Ty, TyCtxt};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::definitions::DefPathHash;
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_macros::HashStable;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
/// A trait's definition with type information.
|
||||
#[derive(HashStable)]
|
||||
@ -209,14 +208,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
// Query provider for `all_local_trait_impls`.
|
||||
pub(super) fn all_local_trait_impls<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
krate: CrateNum,
|
||||
) -> &'tcx BTreeMap<DefId, Vec<LocalDefId>> {
|
||||
&tcx.hir_crate(krate).trait_impls
|
||||
}
|
||||
|
||||
// Query provider for `trait_impls_of`.
|
||||
pub(super) fn trait_impls_of_provider(tcx: TyCtxt<'_>, trait_id: DefId) -> TraitImpls {
|
||||
let mut impls = TraitImpls::default();
|
||||
|
@ -184,7 +184,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::sync::{par_iter, MTLock, MTRef, ParallelIterator};
|
||||
use rustc_errors::{ErrorReported, FatalError};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId};
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_index::bit_set::GrowableBitSet;
|
||||
@ -322,7 +322,7 @@ fn collect_roots(tcx: TyCtxt<'_>, mode: MonoItemCollectionMode) -> Vec<MonoItem<
|
||||
let mut roots = Vec::new();
|
||||
|
||||
{
|
||||
let entry_fn = tcx.entry_fn(LOCAL_CRATE);
|
||||
let entry_fn = tcx.entry_fn(());
|
||||
|
||||
debug!("collect_roots: entry_fn = {:?}", entry_fn);
|
||||
|
||||
@ -468,7 +468,7 @@ fn shrunk_instance_name(
|
||||
after = &s[positions().rev().nth(after).unwrap_or(0)..],
|
||||
);
|
||||
|
||||
let path = tcx.output_filenames(LOCAL_CRATE).temp_path_ext("long-type.txt", None);
|
||||
let path = tcx.output_filenames(()).temp_path_ext("long-type.txt", None);
|
||||
let written_to_path = std::fs::write(&path, s).ok().map(|_| path);
|
||||
|
||||
(shrunk, written_to_path)
|
||||
|
@ -451,7 +451,9 @@ fn mono_item_visibility(
|
||||
let is_generic = instance.substs.non_erasable_generics().next().is_some();
|
||||
|
||||
// Upstream `DefId` instances get different handling than local ones.
|
||||
if !def_id.is_local() {
|
||||
let def_id = if let Some(def_id) = def_id.as_local() {
|
||||
def_id
|
||||
} else {
|
||||
return if export_generics && is_generic {
|
||||
// If it is a upstream monomorphization and we export generics, we must make
|
||||
// it available to downstream crates.
|
||||
@ -460,7 +462,7 @@ fn mono_item_visibility(
|
||||
} else {
|
||||
Visibility::Hidden
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
if is_generic {
|
||||
if export_generics {
|
||||
@ -470,7 +472,7 @@ fn mono_item_visibility(
|
||||
} else {
|
||||
// This instance might be useful in a downstream crate.
|
||||
*can_be_internalized = false;
|
||||
default_visibility(tcx, def_id, true)
|
||||
default_visibility(tcx, def_id.to_def_id(), true)
|
||||
}
|
||||
} else {
|
||||
// We are not exporting generics or the definition is not reachable
|
||||
@ -481,10 +483,10 @@ fn mono_item_visibility(
|
||||
// If this isn't a generic function then we mark this a `Default` if
|
||||
// this is a reachable item, meaning that it's a symbol other crates may
|
||||
// access when they link to us.
|
||||
if tcx.is_reachable_non_generic(def_id) {
|
||||
if tcx.is_reachable_non_generic(def_id.to_def_id()) {
|
||||
*can_be_internalized = false;
|
||||
debug_assert!(!is_generic);
|
||||
return default_visibility(tcx, def_id, false);
|
||||
return default_visibility(tcx, def_id.to_def_id(), false);
|
||||
}
|
||||
|
||||
// If this isn't reachable then we're gonna tag this with `Hidden`
|
||||
|
@ -97,7 +97,7 @@ mod merging;
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::sync;
|
||||
use rustc_hir::def_id::{CrateNum, DefIdSet, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::DefIdSet;
|
||||
use rustc_middle::mir::mono::MonoItem;
|
||||
use rustc_middle::mir::mono::{CodegenUnit, Linkage};
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
@ -311,10 +311,8 @@ where
|
||||
|
||||
fn collect_and_partition_mono_items<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
cnum: CrateNum,
|
||||
(): (),
|
||||
) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
|
||||
let collection_mode = match tcx.sess.opts.debugging_opts.print_mono_items {
|
||||
Some(ref s) => {
|
||||
let mode_string = s.to_lowercase();
|
||||
@ -426,8 +424,8 @@ fn collect_and_partition_mono_items<'tcx>(
|
||||
(tcx.arena.alloc(mono_items), codegen_units)
|
||||
}
|
||||
|
||||
fn codegened_and_inlined_items<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> &'tcx DefIdSet {
|
||||
let (items, cgus) = tcx.collect_and_partition_mono_items(cnum);
|
||||
fn codegened_and_inlined_items<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> &'tcx DefIdSet {
|
||||
let (items, cgus) = tcx.collect_and_partition_mono_items(());
|
||||
let mut visited = DefIdSet::default();
|
||||
let mut result = items.clone();
|
||||
|
||||
@ -455,12 +453,12 @@ pub fn provide(providers: &mut Providers) {
|
||||
providers.codegened_and_inlined_items = codegened_and_inlined_items;
|
||||
|
||||
providers.is_codegened_item = |tcx, def_id| {
|
||||
let (all_mono_items, _) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
|
||||
let (all_mono_items, _) = tcx.collect_and_partition_mono_items(());
|
||||
all_mono_items.contains(&def_id)
|
||||
};
|
||||
|
||||
providers.codegen_unit = |tcx, name| {
|
||||
let (_, all) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
|
||||
let (_, all) = tcx.collect_and_partition_mono_items(());
|
||||
all.iter()
|
||||
.find(|cgu| cgu.name() == name)
|
||||
.unwrap_or_else(|| panic!("failed to find cgu with name {:?}", name))
|
||||
|
@ -3,7 +3,7 @@ use required_consts::RequiredConstsVisitor;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::steal::Steal;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::mir::visit::Visitor as _;
|
||||
@ -98,14 +98,13 @@ pub(crate) fn provide(providers: &mut Providers) {
|
||||
}
|
||||
|
||||
fn is_mir_available(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
tcx.mir_keys(def_id.krate).contains(&def_id.expect_local())
|
||||
let def_id = def_id.expect_local();
|
||||
tcx.mir_keys(()).contains(&def_id)
|
||||
}
|
||||
|
||||
/// Finds the full set of `DefId`s within the current crate that have
|
||||
/// MIR associated with them.
|
||||
fn mir_keys(tcx: TyCtxt<'_>, krate: CrateNum) -> FxHashSet<LocalDefId> {
|
||||
assert_eq!(krate, LOCAL_CRATE);
|
||||
|
||||
fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxHashSet<LocalDefId> {
|
||||
let mut set = FxHashSet::default();
|
||||
|
||||
// All body-owners have MIR associated with them.
|
||||
|
@ -10,7 +10,7 @@ use super::spanview::write_mir_fn_spanview;
|
||||
use crate::transform::MirSource;
|
||||
use either::Either;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::mir::interpret::{
|
||||
read_target_uint, AllocId, Allocation, ConstValue, GlobalAlloc, Pointer,
|
||||
@ -1020,6 +1020,6 @@ pub fn dump_mir_def_ids(tcx: TyCtxt<'_>, single: Option<DefId>) -> Vec<DefId> {
|
||||
if let Some(i) = single {
|
||||
vec![i]
|
||||
} else {
|
||||
tcx.mir_keys(LOCAL_CRATE).iter().map(|def_id| def_id.to_def_id()).collect()
|
||||
tcx.mir_keys(()).iter().map(|def_id| def_id.to_def_id()).collect()
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorOf, DefKind, Res};
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_hir::{Node, PatKind, TyKind};
|
||||
@ -480,7 +480,7 @@ fn create_and_seed_worklist<'tcx>(
|
||||
)
|
||||
.chain(
|
||||
// Seed entry point
|
||||
tcx.entry_fn(LOCAL_CRATE).and_then(|(def_id, _)| {
|
||||
tcx.entry_fn(()).and_then(|(def_id, _)| {
|
||||
def_id.as_local().map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id))
|
||||
}),
|
||||
)
|
||||
@ -717,7 +717,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: TyCtxt<'_>) {
|
||||
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
|
||||
let access_levels = &tcx.privacy_access_levels(());
|
||||
let krate = tcx.hir().krate();
|
||||
let live_symbols = find_live(tcx, access_levels, krate);
|
||||
let mut visitor = DeadVisitor { tcx, live_symbols };
|
||||
|
@ -16,7 +16,7 @@ use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::def_id::{DefId, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_span::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
|
||||
struct DiagnosticItemCollector<'tcx> {
|
||||
@ -99,7 +99,9 @@ fn extract(sess: &Session, attrs: &[ast::Attribute]) -> Option<Symbol> {
|
||||
}
|
||||
|
||||
/// Traverse and collect the diagnostic items in the current
|
||||
fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> FxHashMap<Symbol, DefId> {
|
||||
fn diagnostic_items<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> FxHashMap<Symbol, DefId> {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
|
||||
// Initialize the collector.
|
||||
let mut collector = DiagnosticItemCollector::new(tcx);
|
||||
|
||||
@ -114,7 +116,7 @@ fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> FxHashMap<Symbol, DefId> {
|
||||
}
|
||||
|
||||
/// Traverse and collect all the diagnostic items in all crates.
|
||||
fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> FxHashMap<Symbol, DefId> {
|
||||
fn all_diagnostic_items<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> FxHashMap<Symbol, DefId> {
|
||||
// Initialize the collector.
|
||||
let mut collector = FxHashMap::default();
|
||||
|
||||
@ -129,12 +131,6 @@ fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> FxHashMap<Symbol, DefId> {
|
||||
}
|
||||
|
||||
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)
|
||||
};
|
||||
providers.diagnostic_items = diagnostic_items;
|
||||
providers.all_diagnostic_items = all_diagnostic_items;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use rustc_ast::entry::EntryPointType;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_hir::{ForeignItem, HirId, ImplItem, Item, ItemKind, TraitItem, CRATE_HIR_ID};
|
||||
use rustc_middle::hir::map::Map;
|
||||
@ -48,9 +48,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn entry_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<(DefId, EntryFnType)> {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
|
||||
fn entry_fn(tcx: TyCtxt<'_>, (): ()) -> Option<(DefId, EntryFnType)> {
|
||||
let any_exe = tcx.sess.crate_types().iter().any(|ty| *ty == CrateType::Executable);
|
||||
if !any_exe {
|
||||
// No need to find a main function.
|
||||
@ -227,10 +225,6 @@ fn no_main_err(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) {
|
||||
err.emit();
|
||||
}
|
||||
|
||||
pub fn find_entry_point(tcx: TyCtxt<'_>) -> Option<(DefId, EntryFnType)> {
|
||||
tcx.entry_fn(LOCAL_CRATE)
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
*providers = Providers { entry_fn, ..*providers };
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use rustc_middle::ty::TyCtxt;
|
||||
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_hir::lang_items::{extract, ITEM_REFS};
|
||||
use rustc_hir::{HirId, LangItem, LanguageItems, Target};
|
||||
@ -183,7 +183,7 @@ impl LanguageItemCollector<'tcx> {
|
||||
}
|
||||
|
||||
/// Traverses and collects all the lang items in all crates.
|
||||
fn collect(tcx: TyCtxt<'_>) -> LanguageItems {
|
||||
fn get_lang_items(tcx: TyCtxt<'_>, (): ()) -> LanguageItems {
|
||||
// Initialize the collector.
|
||||
let mut collector = LanguageItemCollector::new(tcx);
|
||||
|
||||
@ -207,8 +207,5 @@ fn collect(tcx: TyCtxt<'_>) -> LanguageItems {
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
providers.get_lang_items = |tcx, id| {
|
||||
assert_eq!(id, LOCAL_CRATE);
|
||||
collect(tcx)
|
||||
};
|
||||
providers.get_lang_items = get_lang_items;
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
use rustc_ast::{Attribute, MetaItem, MetaItemKind};
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
use rustc_middle::hir::map::Map;
|
||||
use rustc_middle::middle::lib_features::LibFeatures;
|
||||
@ -127,7 +126,7 @@ impl Visitor<'tcx> for LibFeatureCollector<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn collect(tcx: TyCtxt<'_>) -> LibFeatures {
|
||||
fn get_lib_features(tcx: TyCtxt<'_>, (): ()) -> LibFeatures {
|
||||
let mut collector = LibFeatureCollector::new(tcx);
|
||||
let krate = tcx.hir().krate();
|
||||
for attr in krate.non_exported_macro_attrs {
|
||||
@ -138,8 +137,5 @@ fn collect(tcx: TyCtxt<'_>) -> LibFeatures {
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
providers.get_lib_features = |tcx, id| {
|
||||
assert_eq!(id, LOCAL_CRATE);
|
||||
collect(tcx)
|
||||
};
|
||||
providers.get_lib_features = get_lib_features;
|
||||
}
|
||||
|
@ -8,8 +8,7 @@
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_hir::Node;
|
||||
@ -385,10 +384,8 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx
|
||||
}
|
||||
}
|
||||
|
||||
fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> FxHashSet<LocalDefId> {
|
||||
debug_assert!(crate_num == LOCAL_CRATE);
|
||||
|
||||
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
|
||||
fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> FxHashSet<LocalDefId> {
|
||||
let access_levels = &tcx.privacy_access_levels(());
|
||||
|
||||
let any_library =
|
||||
tcx.sess.crate_types().iter().any(|ty| {
|
||||
|
@ -629,7 +629,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
|
||||
// stable (assuming they have not inherited instability from their parent).
|
||||
}
|
||||
|
||||
fn new_index(tcx: TyCtxt<'tcx>) -> Index<'tcx> {
|
||||
fn stability_index(tcx: TyCtxt<'tcx>, (): ()) -> Index<'tcx> {
|
||||
let is_staged_api =
|
||||
tcx.sess.opts.debugging_opts.force_unstable_if_unmarked || tcx.features().staged_api;
|
||||
let mut staged_api = FxHashMap::default();
|
||||
@ -704,11 +704,7 @@ fn check_mod_unstable_api_usage(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
||||
}
|
||||
|
||||
pub(crate) fn provide(providers: &mut Providers) {
|
||||
*providers = Providers { check_mod_unstable_api_usage, ..*providers };
|
||||
providers.stability_index = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
new_index(tcx)
|
||||
};
|
||||
*providers = Providers { check_mod_unstable_api_usage, stability_index, ..*providers };
|
||||
}
|
||||
|
||||
struct Checker<'tcx> {
|
||||
@ -880,7 +876,7 @@ impl Visitor<'tcx> for CheckTraitImplStable<'tcx> {
|
||||
/// were expected to be library features), and the list of features used from
|
||||
/// libraries, identify activated features that don't exist and error about them.
|
||||
pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
|
||||
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
|
||||
let access_levels = &tcx.privacy_access_levels(());
|
||||
|
||||
if tcx.stability().staged_api[&LOCAL_CRATE] {
|
||||
let krate = tcx.hir().krate();
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! Used by `rustc` when compiling a plugin crate.
|
||||
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
@ -31,33 +31,25 @@ impl<'v, 'tcx> ItemLikeVisitor<'v> for RegistrarFinder<'tcx> {
|
||||
}
|
||||
|
||||
/// Finds the function marked with `#[plugin_registrar]`, if any.
|
||||
pub fn find_plugin_registrar(tcx: TyCtxt<'_>) -> Option<DefId> {
|
||||
tcx.plugin_registrar_fn(LOCAL_CRATE)
|
||||
}
|
||||
|
||||
fn plugin_registrar_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<DefId> {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
|
||||
fn plugin_registrar_fn(tcx: TyCtxt<'_>, (): ()) -> Option<LocalDefId> {
|
||||
let mut finder = RegistrarFinder { tcx, registrars: Vec::new() };
|
||||
tcx.hir().krate().visit_all_item_likes(&mut finder);
|
||||
|
||||
match finder.registrars.len() {
|
||||
0 => None,
|
||||
1 => {
|
||||
let (def_id, _) = finder.registrars.pop().unwrap();
|
||||
Some(def_id.to_def_id())
|
||||
}
|
||||
_ => {
|
||||
let diagnostic = tcx.sess.diagnostic();
|
||||
let mut e = diagnostic.struct_err("multiple plugin registration functions found");
|
||||
for &(_, span) in &finder.registrars {
|
||||
e.span_note(span, "one is here");
|
||||
}
|
||||
e.emit();
|
||||
diagnostic.abort_if_errors();
|
||||
unreachable!();
|
||||
let (def_id, span) = finder.registrars.pop()?;
|
||||
|
||||
if !finder.registrars.is_empty() {
|
||||
let diagnostic = tcx.sess.diagnostic();
|
||||
let mut e = diagnostic.struct_err("multiple plugin registration functions found");
|
||||
e.span_note(span, "one is here");
|
||||
for &(_, span) in &finder.registrars {
|
||||
e.span_note(span, "one is here");
|
||||
}
|
||||
e.emit();
|
||||
diagnostic.abort_if_errors();
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
Some(def_id)
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
|
@ -12,7 +12,7 @@ use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::intravisit::{self, DeepVisitor, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::{AssocItemKind, HirIdSet, Node, PatKind};
|
||||
use rustc_middle::bug;
|
||||
@ -2092,9 +2092,7 @@ fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
||||
intravisit::walk_mod(&mut visitor, module, hir_id);
|
||||
}
|
||||
|
||||
fn privacy_access_levels(tcx: TyCtxt<'_>, krate: CrateNum) -> &AccessLevels {
|
||||
assert_eq!(krate, LOCAL_CRATE);
|
||||
|
||||
fn privacy_access_levels(tcx: TyCtxt<'_>, (): ()) -> &AccessLevels {
|
||||
// Build up a set of all exported items in the AST. This is a set of all
|
||||
// items which are reachable from external crates based on visibility.
|
||||
let mut visitor = EmbargoVisitor {
|
||||
@ -2117,10 +2115,8 @@ fn privacy_access_levels(tcx: TyCtxt<'_>, krate: CrateNum) -> &AccessLevels {
|
||||
tcx.arena.alloc(visitor.access_levels)
|
||||
}
|
||||
|
||||
fn check_private_in_public(tcx: TyCtxt<'_>, krate: CrateNum) {
|
||||
assert_eq!(krate, LOCAL_CRATE);
|
||||
|
||||
let access_levels = tcx.privacy_access_levels(LOCAL_CRATE);
|
||||
fn check_private_in_public(tcx: TyCtxt<'_>, (): ()) {
|
||||
let access_levels = tcx.privacy_access_levels(());
|
||||
|
||||
let krate = tcx.hir().krate();
|
||||
|
||||
|
@ -21,6 +21,16 @@ pub trait Key {
|
||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span;
|
||||
}
|
||||
|
||||
impl Key for () {
|
||||
fn query_crate(&self) -> CrateNum {
|
||||
LOCAL_CRATE
|
||||
}
|
||||
|
||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||
DUMMY_SP
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Key for ty::InstanceDef<'tcx> {
|
||||
fn query_crate(&self) -> CrateNum {
|
||||
LOCAL_CRATE
|
||||
|
@ -95,7 +95,7 @@ impl<'tcx> SaveContext<'tcx> {
|
||||
let sess = &self.tcx.sess;
|
||||
// Save-analysis is emitted per whole session, not per each crate type
|
||||
let crate_type = sess.crate_types()[0];
|
||||
let outputs = &*self.tcx.output_filenames(LOCAL_CRATE);
|
||||
let outputs = &*self.tcx.output_filenames(());
|
||||
|
||||
if outputs.outputs.contains_key(&OutputType::Metadata) {
|
||||
filename_for_metadata(sess, crate_name, outputs)
|
||||
@ -1000,7 +1000,7 @@ pub fn process_crate<'l, 'tcx, H: SaveHandler>(
|
||||
// Privacy checking requires and is done after type checking; use a
|
||||
// fallback in case the access levels couldn't have been correctly computed.
|
||||
let access_levels = match tcx.sess.compile_status() {
|
||||
Ok(..) => tcx.privacy_access_levels(LOCAL_CRATE),
|
||||
Ok(..) => tcx.privacy_access_levels(()),
|
||||
Err(..) => tcx.arena.alloc(AccessLevels::default()),
|
||||
};
|
||||
|
||||
|
@ -165,11 +165,11 @@ fn compute_symbol_name(
|
||||
|
||||
// FIXME(eddyb) Precompute a custom symbol name based on attributes.
|
||||
let is_foreign = if let Some(def_id) = def_id.as_local() {
|
||||
if tcx.plugin_registrar_fn(LOCAL_CRATE) == Some(def_id.to_def_id()) {
|
||||
if tcx.plugin_registrar_fn(()) == Some(def_id) {
|
||||
let disambiguator = tcx.sess.local_crate_disambiguator();
|
||||
return tcx.sess.generate_plugin_registrar_symbol(disambiguator);
|
||||
}
|
||||
if tcx.proc_macro_decls_static(LOCAL_CRATE) == Some(def_id.to_def_id()) {
|
||||
if tcx.proc_macro_decls_static(()) == Some(def_id) {
|
||||
let disambiguator = tcx.sess.local_crate_disambiguator();
|
||||
return tcx.sess.generate_proc_macro_decls_symbol(disambiguator);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ use crate::infer::{self, InferCtxt, TyCtxtInferExt};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, ErrorReported};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
use rustc_hir::Node;
|
||||
use rustc_middle::mir::abstract_const::NotConstEvaluatable;
|
||||
@ -1427,7 +1427,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
self.tcx.find_map_relevant_impl(trait_def_id, trait_ref.skip_binder().self_ty(), Some)
|
||||
};
|
||||
let required_trait_path = self.tcx.def_path_str(trait_ref.def_id());
|
||||
let all_traits = self.tcx.all_traits(LOCAL_CRATE);
|
||||
let all_traits = self.tcx.all_traits(());
|
||||
let traits_with_same_path: std::collections::BTreeSet<_> = all_traits
|
||||
.iter()
|
||||
.filter(|trait_def_id| **trait_def_id != trait_ref.def_id())
|
||||
|
@ -6,7 +6,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Namespace, Res};
|
||||
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX};
|
||||
use rustc_hir::intravisit;
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_hir::{ExprKind, Node, QPath};
|
||||
@ -1440,11 +1440,11 @@ impl Ord for TraitInfo {
|
||||
|
||||
/// Retrieves all traits in this crate and any dependent crates.
|
||||
pub fn all_traits(tcx: TyCtxt<'_>) -> Vec<TraitInfo> {
|
||||
tcx.all_traits(LOCAL_CRATE).iter().map(|&def_id| TraitInfo { def_id }).collect()
|
||||
tcx.all_traits(()).iter().map(|&def_id| TraitInfo { def_id }).collect()
|
||||
}
|
||||
|
||||
/// Computes all traits in this crate and any dependent crates.
|
||||
fn compute_all_traits(tcx: TyCtxt<'_>) -> Vec<DefId> {
|
||||
fn compute_all_traits(tcx: TyCtxt<'_>, (): ()) -> &[DefId] {
|
||||
use hir::itemlikevisit;
|
||||
|
||||
let mut traits = vec![];
|
||||
@ -1503,14 +1503,11 @@ fn compute_all_traits(tcx: TyCtxt<'_>) -> Vec<DefId> {
|
||||
handle_external_res(tcx, &mut traits, &mut external_mods, Res::Def(DefKind::Mod, def_id));
|
||||
}
|
||||
|
||||
traits
|
||||
tcx.arena.alloc_from_iter(traits)
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut ty::query::Providers) {
|
||||
providers.all_traits = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
&tcx.arena.alloc(compute_all_traits(tcx))[..]
|
||||
}
|
||||
providers.all_traits = compute_all_traits;
|
||||
}
|
||||
|
||||
struct UsePlacementFinder<'tcx> {
|
||||
|
@ -105,7 +105,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::{pluralize, struct_span_err, Applicability};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_hir::{HirIdMap, ImplicitSelfKind, Node};
|
||||
@ -1160,8 +1160,7 @@ impl ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'tcx> {
|
||||
fn visit_foreign_item(&mut self, _: &'tcx hir::ForeignItem<'tcx>) {}
|
||||
}
|
||||
|
||||
fn typeck_item_bodies(tcx: TyCtxt<'_>, crate_num: CrateNum) {
|
||||
debug_assert!(crate_num == LOCAL_CRATE);
|
||||
fn typeck_item_bodies(tcx: TyCtxt<'_>, (): ()) {
|
||||
tcx.par_body_owners(|body_owner_def_id| {
|
||||
tcx.ensure().typeck(body_owner_def_id);
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::lint;
|
||||
@ -77,7 +77,7 @@ fn unused_crates_lint(tcx: TyCtxt<'_>) {
|
||||
// can always suggest removing (no matter which edition we are
|
||||
// in).
|
||||
let unused_extern_crates: FxHashMap<LocalDefId, Span> = tcx
|
||||
.maybe_unused_extern_crates(LOCAL_CRATE)
|
||||
.maybe_unused_extern_crates(())
|
||||
.iter()
|
||||
.filter(|&&(def_id, _)| {
|
||||
// The `def_id` here actually was calculated during resolution (at least
|
||||
|
@ -9,16 +9,14 @@
|
||||
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_middle::ty::{self, CrateInherentImpls, TyCtxt};
|
||||
|
||||
use rustc_span::Span;
|
||||
|
||||
/// On-demand query: yields a map containing all types mapped to their inherent impls.
|
||||
pub fn crate_inherent_impls(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CrateInherentImpls {
|
||||
assert_eq!(crate_num, LOCAL_CRATE);
|
||||
|
||||
pub fn crate_inherent_impls(tcx: TyCtxt<'_>, (): ()) -> CrateInherentImpls {
|
||||
let krate = tcx.hir().krate();
|
||||
let mut collect = InherentCollect { tcx, impls_map: Default::default() };
|
||||
krate.visit_all_item_likes(&mut collect);
|
||||
@ -27,9 +25,9 @@ pub fn crate_inherent_impls(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CrateInhere
|
||||
|
||||
/// On-demand query: yields a vector of the inherent impls for a specific type.
|
||||
pub fn inherent_impls(tcx: TyCtxt<'_>, ty_def_id: DefId) -> &[DefId] {
|
||||
assert!(ty_def_id.is_local());
|
||||
let ty_def_id = ty_def_id.expect_local();
|
||||
|
||||
let crate_map = tcx.crate_inherent_impls(ty_def_id.krate);
|
||||
let crate_map = tcx.crate_inherent_impls(());
|
||||
match crate_map.inherent_impls.get(&ty_def_id) {
|
||||
Some(v) => &v[..],
|
||||
None => &[],
|
||||
@ -364,7 +362,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
|
||||
impl InherentCollect<'tcx> {
|
||||
fn check_def_id(&mut self, item: &hir::Item<'_>, def_id: DefId) {
|
||||
if def_id.is_local() {
|
||||
if let Some(def_id) = def_id.as_local() {
|
||||
// Add the implementation to the mapping from implementation to base
|
||||
// type def ID, if there is a base type for this implementation and
|
||||
// the implementation does not have any associated traits.
|
||||
|
@ -1,7 +1,7 @@
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_span::Symbol;
|
||||
@ -9,8 +9,7 @@ use rustc_trait_selection::traits::{self, SkipLeakCheck};
|
||||
use smallvec::SmallVec;
|
||||
use std::collections::hash_map::Entry;
|
||||
|
||||
pub fn crate_inherent_impls_overlap_check(tcx: TyCtxt<'_>, crate_num: CrateNum) {
|
||||
assert_eq!(crate_num, LOCAL_CRATE);
|
||||
pub fn crate_inherent_impls_overlap_check(tcx: TyCtxt<'_>, (): ()) {
|
||||
let krate = tcx.hir().krate();
|
||||
krate.visit_all_item_likes(&mut InherentOverlapChecker { tcx });
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
// mappings. That mapping code resides here.
|
||||
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::{self, TyCtxt, TypeFoldable};
|
||||
use rustc_span::Span;
|
||||
@ -203,8 +203,8 @@ pub fn check_coherence(tcx: TyCtxt<'_>) {
|
||||
tcx.sess.time("orphan_checking", || orphan::check(tcx));
|
||||
|
||||
// these queries are executed for side-effects (error reporting):
|
||||
tcx.ensure().crate_inherent_impls(LOCAL_CRATE);
|
||||
tcx.ensure().crate_inherent_impls_overlap_check(LOCAL_CRATE);
|
||||
tcx.ensure().crate_inherent_impls(());
|
||||
tcx.ensure().crate_inherent_impls_overlap_check(());
|
||||
}
|
||||
|
||||
/// Checks whether an impl overlaps with the automatic `impl Trait for dyn Trait`.
|
||||
|
@ -97,7 +97,7 @@ mod variance;
|
||||
|
||||
use rustc_errors::{struct_span_err, ErrorReported};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{Node, CRATE_HIR_ID};
|
||||
use rustc_infer::infer::{InferOk, TyCtxtInferExt};
|
||||
use rustc_infer::traits::TraitEngineExt as _;
|
||||
@ -449,7 +449,7 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
|
||||
}
|
||||
|
||||
fn check_for_entry_fn(tcx: TyCtxt<'_>) {
|
||||
match tcx.entry_fn(LOCAL_CRATE) {
|
||||
match tcx.entry_fn(()) {
|
||||
Some((def_id, EntryFnType::Main)) => check_main_fn_ty(tcx, def_id),
|
||||
Some((def_id, EntryFnType::Start)) => check_start_fn_ty(tcx, def_id),
|
||||
_ => {}
|
||||
@ -510,7 +510,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorReported> {
|
||||
}
|
||||
});
|
||||
|
||||
tcx.sess.time("item_bodies_checking", || tcx.typeck_item_bodies(LOCAL_CRATE));
|
||||
tcx.sess.time("item_bodies_checking", || tcx.typeck_item_bodies(()));
|
||||
|
||||
check_unused::check_crate(tcx);
|
||||
check_for_entry_fn(tcx);
|
||||
|
@ -1,6 +1,6 @@
|
||||
use hir::Node;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::subst::GenericArgKind;
|
||||
use rustc_middle::ty::{self, CratePredicatesMap, ToPredicate, TyCtxt};
|
||||
@ -23,7 +23,7 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[(ty::Predicate
|
||||
match tcx.hir().get(id) {
|
||||
Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Union(..) => {
|
||||
let crate_map = tcx.inferred_outlives_crate(LOCAL_CRATE);
|
||||
let crate_map = tcx.inferred_outlives_crate(());
|
||||
|
||||
let predicates = crate_map.predicates.get(&item_def_id).copied().unwrap_or(&[]);
|
||||
|
||||
@ -58,9 +58,7 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[(ty::Predicate
|
||||
}
|
||||
}
|
||||
|
||||
fn inferred_outlives_crate(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CratePredicatesMap<'_> {
|
||||
assert_eq!(crate_num, LOCAL_CRATE);
|
||||
|
||||
fn inferred_outlives_crate(tcx: TyCtxt<'_>, (): ()) -> CratePredicatesMap<'_> {
|
||||
// Compute a map from each struct/enum/union S to the **explicit**
|
||||
// outlives predicates (`T: 'a`, `'a: 'b`) that the user wrote.
|
||||
// Typically there won't be many of these, except in older code where
|
||||
|
@ -6,7 +6,7 @@
|
||||
use hir::Node;
|
||||
use rustc_arena::DroplessArena;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::{self, CrateVariancesMap, TyCtxt};
|
||||
|
||||
@ -30,8 +30,7 @@ pub fn provide(providers: &mut Providers) {
|
||||
*providers = Providers { variances_of, crate_variances, ..*providers };
|
||||
}
|
||||
|
||||
fn crate_variances(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CrateVariancesMap<'_> {
|
||||
assert_eq!(crate_num, LOCAL_CRATE);
|
||||
fn crate_variances(tcx: TyCtxt<'_>, (): ()) -> CrateVariancesMap<'_> {
|
||||
let arena = DroplessArena::default();
|
||||
let terms_cx = terms::determine_parameters_to_be_inferred(tcx, &arena);
|
||||
let constraints_cx = constraints::add_constraints_from_crate(terms_cx);
|
||||
@ -79,6 +78,6 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[ty::Variance] {
|
||||
|
||||
// Everything else must be inferred.
|
||||
|
||||
let crate_map = tcx.crate_variances(LOCAL_CRATE);
|
||||
let crate_map = tcx.crate_variances(());
|
||||
crate_map.variances.get(&item_def_id).copied().unwrap_or(&[])
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
use crate::rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_infer::infer::{InferOk, TyCtxtInferExt};
|
||||
use rustc_infer::traits;
|
||||
use rustc_middle::ty::subst::Subst;
|
||||
@ -20,7 +19,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
|
||||
|
||||
debug!("get_blanket_impls({:?})", ty);
|
||||
let mut impls = Vec::new();
|
||||
for &trait_def_id in self.cx.tcx.all_traits(LOCAL_CRATE).iter() {
|
||||
for &trait_def_id in self.cx.tcx.all_traits(()).iter() {
|
||||
if !self.cx.cache.access_levels.is_public(trait_def_id)
|
||||
|| self.cx.generated_synthetics.get(&(ty, trait_def_id)).is_some()
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ use rustc_errors::emitter::{Emitter, EmitterWriter};
|
||||
use rustc_errors::json::JsonEmitter;
|
||||
use rustc_feature::UnstableFeatures;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::HirId;
|
||||
use rustc_hir::{
|
||||
intravisit::{self, NestedVisitorMap, Visitor},
|
||||
@ -348,7 +348,7 @@ crate fn run_global_ctxt(
|
||||
});
|
||||
rustc_passes::stability::check_unused_or_stable_features(tcx);
|
||||
|
||||
let access_levels = tcx.privacy_access_levels(LOCAL_CRATE);
|
||||
let access_levels = tcx.privacy_access_levels(());
|
||||
// Convert from a HirId set to a DefId set since we don't always have easy access
|
||||
// to the map from defid -> hirid
|
||||
let access_levels = AccessLevels {
|
||||
@ -371,7 +371,7 @@ crate fn run_global_ctxt(
|
||||
impl_trait_bounds: Default::default(),
|
||||
generated_synthetics: Default::default(),
|
||||
auto_traits: tcx
|
||||
.all_traits(LOCAL_CRATE)
|
||||
.all_traits(())
|
||||
.iter()
|
||||
.cloned()
|
||||
.filter(|trait_def_id| tcx.trait_is_auto(*trait_def_id))
|
||||
|
@ -1208,13 +1208,11 @@ impl LinkCollector<'_, '_> {
|
||||
item.def_id.expect_real().as_local().map(|src_id| (src_id, dst_id))
|
||||
})
|
||||
{
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
|
||||
let hir_src = self.cx.tcx.hir().local_def_id_to_hir_id(src_id);
|
||||
let hir_dst = self.cx.tcx.hir().local_def_id_to_hir_id(dst_id);
|
||||
|
||||
if self.cx.tcx.privacy_access_levels(LOCAL_CRATE).is_exported(hir_src)
|
||||
&& !self.cx.tcx.privacy_access_levels(LOCAL_CRATE).is_exported(hir_dst)
|
||||
if self.cx.tcx.privacy_access_levels(()).is_exported(hir_src)
|
||||
&& !self.cx.tcx.privacy_access_levels(()).is_exported(hir_dst)
|
||||
{
|
||||
privacy_error(self.cx, &diag_info, &path_str);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use crate::core::DocContext;
|
||||
use crate::fold::DocFolder;
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::ty::DefIdTree;
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
@ -56,7 +56,7 @@ crate fn collect_trait_impls(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
|
||||
// `tcx.crates()` doesn't include the local crate, and `tcx.all_trait_implementations`
|
||||
// doesn't work with it anyway, so pull them from the HIR map instead
|
||||
let mut extra_attrs = Vec::new();
|
||||
for &trait_did in cx.tcx.all_traits(LOCAL_CRATE).iter() {
|
||||
for &trait_did in cx.tcx.all_traits(()).iter() {
|
||||
for &impl_did in cx.tcx.hir().trait_impls(trait_did) {
|
||||
let impl_did = impl_did.to_def_id();
|
||||
cx.tcx.sess.prof.generic_activity("build_local_trait_impl").run(|| {
|
||||
|
@ -6,9 +6,9 @@
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_variables)]
|
||||
#![rustc_if_this_changed(hir_crate)]
|
||||
fn main() {}
|
||||
|
||||
#[rustc_if_this_changed]
|
||||
struct Foo<T> {
|
||||
f: T,
|
||||
}
|
||||
|
@ -14,16 +14,16 @@ LL | #[plugin_registrar]
|
||||
|
||||
error: multiple plugin registration functions found
|
||||
|
|
||||
note: one is here
|
||||
--> $DIR/multiple-plugin-registrars.rs:7:1
|
||||
|
|
||||
LL | pub fn one() {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
note: one is here
|
||||
--> $DIR/multiple-plugin-registrars.rs:10:1
|
||||
|
|
||||
LL | pub fn two() {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
note: one is here
|
||||
--> $DIR/multiple-plugin-registrars.rs:7:1
|
||||
|
|
||||
LL | pub fn one() {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error; 2 warnings emitted
|
||||
|
||||
|
@ -12,7 +12,7 @@ use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::hir::map::Map;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::{def_id::LOCAL_CRATE, source_map::Span};
|
||||
use rustc_span::{source_map::Span};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for deriving `Hash` but implementing `PartialEq`
|
||||
@ -312,7 +312,7 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &T
|
||||
if ty_subs.non_erasable_generics().next().is_some() {
|
||||
let has_copy_impl = cx
|
||||
.tcx
|
||||
.all_local_trait_impls(LOCAL_CRATE)
|
||||
.all_local_trait_impls(())
|
||||
.get(©_id)
|
||||
.map_or(false, |impls| {
|
||||
impls
|
||||
|
@ -3,7 +3,7 @@
|
||||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use clippy_utils::in_macro;
|
||||
use rustc_hir::def_id::DefIdMap;
|
||||
use rustc_hir::{def_id, Crate, Impl, Item, ItemKind};
|
||||
use rustc_hir::{Crate, Impl, Item, ItemKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::Span;
|
||||
@ -68,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
|
||||
fn check_crate_post(&mut self, cx: &LateContext<'tcx>, krate: &'tcx Crate<'_>) {
|
||||
if !krate.items.is_empty() {
|
||||
// Retrieve all inherent implementations from the crate, grouped by type
|
||||
for impls in cx.tcx.crate_inherent_impls(def_id::LOCAL_CRATE).inherent_impls.values() {
|
||||
for impls in cx.tcx.crate_inherent_impls(()).inherent_impls.values() {
|
||||
// Filter out implementations that have generic params (type or lifetime)
|
||||
let mut impl_spans = impls.iter().filter_map(|impl_def| self.impls.get(impl_def));
|
||||
if let Some(initial_span) = impl_spans.next() {
|
||||
|
@ -60,7 +60,7 @@ use rustc_ast::ast::{self, Attribute, BorrowKind, LitKind};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::{self, walk_expr, ErasedMap, FnKind, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::LangItem::{ResultErr, ResultOk};
|
||||
use rustc_hir::{
|
||||
@ -677,7 +677,7 @@ pub fn method_chain_args<'a>(expr: &'a Expr<'_>, methods: &[&str]) -> Option<Vec
|
||||
/// Returns `true` if the provided `def_id` is an entrypoint to a program.
|
||||
pub fn is_entrypoint_fn(cx: &LateContext<'_>, def_id: DefId) -> bool {
|
||||
cx.tcx
|
||||
.entry_fn(LOCAL_CRATE)
|
||||
.entry_fn(())
|
||||
.map_or(false, |(entry_fn_def_id, _)| def_id == entry_fn_def_id)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user