diff options
| author | bors <bors@rust-lang.org> | 2021-05-17 01:42:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-05-17 01:42:03 +0000 |
| commit | 3396a383bb1d1fdad8ceeb74f16cf08e0bd62a1b (patch) | |
| tree | 912246be6d9298983c099d904ee9260e77695a62 /compiler/rustc_interface | |
| parent | a55748ffe94e71f841c7b1d752779b0db138b342 (diff) | |
| parent | 1ebf6d12426152dc1ce76c174ee0ff69b1a4c5b4 (diff) | |
| download | rust-3396a383bb1d1fdad8ceeb74f16cf08e0bd62a1b.tar.gz rust-3396a383bb1d1fdad8ceeb74f16cf08e0bd62a1b.zip | |
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.
Diffstat (limited to 'compiler/rustc_interface')
| -rw-r--r-- | compiler/rustc_interface/src/passes.rs | 21 | ||||
| -rw-r--r-- | compiler/rustc_interface/src/proc_macro_decls.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_interface/src/queries.rs | 4 |
3 files changed, 14 insertions, 23 deletions
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 06bec91501f..e2220e3b60d 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -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,14 +814,13 @@ 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", || proc_macro_decls::find(tcx)); + sess.time("looking_for_derive_registrar", || { + tcx.ensure().proc_macro_decls_static(()) + }); let cstore = tcx .cstore_as_any() @@ -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)); diff --git a/compiler/rustc_interface/src/proc_macro_decls.rs b/compiler/rustc_interface/src/proc_macro_decls.rs index 4637055a82d..88cf6275ebb 100644 --- a/compiler/rustc_interface/src/proc_macro_decls.rs +++ b/compiler/rustc_interface/src/proc_macro_decls.rs @@ -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> { diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index bc94fb67ac3..92d05e48068 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -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, }; |
