1
Fork 0

rustc_interface: Dismantle register_plugins query

This commit is contained in:
Vadim Petrochenkov 2023-08-07 14:23:01 +08:00
parent adb15a20ac
commit b6ac576487
5 changed files with 119 additions and 132 deletions

View file

@ -20,7 +20,6 @@ use rustc_session::cstore::{CrateDepKind, CrateSource, ExternCrate};
use rustc_session::lint;
use rustc_session::output::validate_crate_name;
use rustc_session::search_paths::PathKind;
use rustc_session::Session;
use rustc_span::edition::Edition;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::{Span, DUMMY_SP};
@ -262,9 +261,9 @@ impl CStore {
}
}
pub fn new(sess: &Session) -> CStore {
pub fn new(local_stable_crate_id: StableCrateId) -> CStore {
let mut stable_crate_ids = StableCrateIdMap::default();
stable_crate_ids.insert(sess.local_stable_crate_id(), LOCAL_CRATE);
stable_crate_ids.insert(local_stable_crate_id, LOCAL_CRATE);
CStore {
// We add an empty entry for LOCAL_CRATE (which maps to zero) in
// order to make array indices in `metas` match with the
@ -544,6 +543,9 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
self.sess,
&**metadata_loader,
name,
// The all loop is because `--crate-type=rlib --crate-type=rlib` is
// legal and produces both inside this type.
self.sess.crate_types().iter().all(|c| *c == CrateType::Rlib),
hash,
extra_filename,
false, // is_host

View file

@ -222,7 +222,7 @@ use rustc_data_structures::owned_slice::slice_owned;
use rustc_data_structures::svh::Svh;
use rustc_errors::{DiagnosticArgValue, FatalError, IntoDiagnosticArg};
use rustc_fs_util::try_canonicalize;
use rustc_session::config::{self, CrateType};
use rustc_session::config;
use rustc_session::cstore::{CrateSource, MetadataLoader};
use rustc_session::filesearch::FileSearch;
use rustc_session::search_paths::PathKind;
@ -305,14 +305,12 @@ impl<'a> CrateLocator<'a> {
sess: &'a Session,
metadata_loader: &'a dyn MetadataLoader,
crate_name: Symbol,
is_rlib: bool,
hash: Option<Svh>,
extra_filename: Option<&'a str>,
is_host: bool,
path_kind: PathKind,
) -> CrateLocator<'a> {
// The all loop is because `--crate-type=rlib --crate-type=rlib` is
// legal and produces both inside this type.
let is_rlib = sess.crate_types().iter().all(|c| *c == CrateType::Rlib);
let needs_object_code = sess.opts.output_types.should_codegen();
// If we're producing an rlib, then we don't need object code.
// Or, if we're not producing object code, then we don't need it either
@ -883,9 +881,10 @@ fn find_plugin_registrar_impl<'a>(
sess,
metadata_loader,
name,
None, // hash
None, // extra_filename
true, // is_host
false, // is_rlib
None, // hash
None, // extra_filename
true, // is_host
PathKind::Crate,
);