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_metadata/src | |
| 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_metadata/src')
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs | 29 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/encoder.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/mod.rs | 1 |
3 files changed, 12 insertions, 32 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 82ca634f282..e25b22c8331 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -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 diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 29fcbffa0b9..0c31430598a 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -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 { diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 1fb68fd5fc3..04fe5cf5890 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -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>]>, |
