1
Fork 0

LocalCrate key

This commit is contained in:
Michael Goulet 2023-03-13 22:22:59 +00:00
parent dcaf956de0
commit d213114cb5
11 changed files with 33 additions and 21 deletions

View file

@ -13,6 +13,7 @@ use rustc_middle::arena::ArenaAllocatable;
use rustc_middle::metadata::ModChild;
use rustc_middle::middle::exported_symbols::ExportedSymbol;
use rustc_middle::middle::stability::DeprecationEntry;
use rustc_middle::query::LocalCrate;
use rustc_middle::ty::fast_reject::SimplifiedType;
use rustc_middle::ty::query::{ExternProviders, Providers};
use rustc_middle::ty::{self, TyCtxt};
@ -367,7 +368,7 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
*providers = Providers {
allocator_kind: |tcx, ()| CStore::from_tcx(tcx).allocator_kind(),
alloc_error_handler_kind: |tcx, ()| CStore::from_tcx(tcx).alloc_error_handler_kind(),
is_private_dep: |_tcx, ()| false,
is_private_dep: |_tcx, LocalCrate| false,
native_library: |tcx, id| {
tcx.native_libraries(id.krate)
.iter()
@ -383,8 +384,8 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
.contains(&id)
})
},
native_libraries: |tcx, ()| native_libs::collect(tcx),
foreign_modules: |tcx, ()| {
native_libraries: |tcx, LocalCrate| native_libs::collect(tcx),
foreign_modules: |tcx, LocalCrate| {
foreign_modules::collect(tcx).into_iter().map(|m| (m.def_id, m)).collect()
},
@ -482,8 +483,8 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
},
dependency_formats: |tcx, ()| Lrc::new(crate::dependency_format::calculate(tcx)),
has_global_allocator: |tcx, ()| CStore::from_tcx(tcx).has_global_allocator(),
has_alloc_error_handler: |tcx, ()| CStore::from_tcx(tcx).has_alloc_error_handler(),
has_global_allocator: |tcx, LocalCrate| CStore::from_tcx(tcx).has_global_allocator(),
has_alloc_error_handler: |tcx, LocalCrate| CStore::from_tcx(tcx).has_alloc_error_handler(),
postorder_cnums: |tcx, ()| {
tcx.arena
.alloc_slice(&CStore::from_tcx(tcx).crate_dependencies_in_postorder(LOCAL_CRATE))

View file

@ -24,6 +24,7 @@ use rustc_middle::middle::exported_symbols::{
metadata_symbol_name, ExportedSymbol, SymbolExportInfo,
};
use rustc_middle::mir::interpret;
use rustc_middle::query::LocalCrate;
use rustc_middle::traits::specialization_graph;
use rustc_middle::ty::codec::TyEncoder;
use rustc_middle::ty::fast_reject::{self, SimplifiedType, TreatParams, TreatProjections};
@ -2240,7 +2241,7 @@ pub fn provide(providers: &mut Providers) {
.get(&def_id)
.expect("no traits in scope for a doc link")
},
traits_in_crate: |tcx, ()| {
traits_in_crate: |tcx, LocalCrate| {
let mut traits = Vec::new();
for id in tcx.hir().items() {
if matches!(tcx.def_kind(id.owner_id), DefKind::Trait | DefKind::TraitAlias) {
@ -2252,7 +2253,7 @@ pub fn provide(providers: &mut Providers) {
traits.sort_by_cached_key(|&def_id| tcx.def_path_hash(def_id));
tcx.arena.alloc_slice(&traits)
},
trait_impls_in_crate: |tcx, ()| {
trait_impls_in_crate: |tcx, LocalCrate| {
let mut trait_impls = Vec::new();
for id in tcx.hir().items() {
if matches!(tcx.def_kind(id.owner_id), DefKind::Impl { .. })