1
Fork 0

Improve debugging for metadata structures

I had to do a lot of debug by printing; having these `Debug` traits in
place made it easier. Additionally, add some more information to
existing `info!` statements.
This commit is contained in:
Trevor Gross 2025-01-29 23:45:36 +00:00
parent 51d9a6c617
commit 83d70c0298
3 changed files with 12 additions and 5 deletions

View file

@ -147,6 +147,7 @@ impl<'a> std::fmt::Debug for CrateDump<'a> {
writeln!(fmt, " cnum: {cnum}")?; writeln!(fmt, " cnum: {cnum}")?;
writeln!(fmt, " hash: {}", data.hash())?; writeln!(fmt, " hash: {}", data.hash())?;
writeln!(fmt, " reqd: {:?}", data.dep_kind())?; writeln!(fmt, " reqd: {:?}", data.dep_kind())?;
writeln!(fmt, " priv: {:?}", data.is_private_dep())?;
let CrateSource { dylib, rlib, rmeta } = data.source(); let CrateSource { dylib, rlib, rmeta } = data.source();
if let Some(dylib) = dylib { if let Some(dylib) = dylib {
writeln!(fmt, " dylib: {}", dylib.0.display())?; writeln!(fmt, " dylib: {}", dylib.0.display())?;
@ -770,7 +771,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
match result { match result {
(LoadResult::Previous(cnum), None) => { (LoadResult::Previous(cnum), None) => {
info!("library for `{}` was loaded previously", name); info!("library for `{}` was loaded previously, cnum {cnum}", name);
// When `private_dep` is none, it indicates the directly dependent crate. If it is // When `private_dep` is none, it indicates the directly dependent crate. If it is
// not specified by `--extern` on command line parameters, it may be // not specified by `--extern` on command line parameters, it may be
// `private-dependency` when `register_crate` is called for the first time. Then it must be updated to // `private-dependency` when `register_crate` is called for the first time. Then it must be updated to

View file

@ -260,7 +260,7 @@ pub(crate) struct CrateLocator<'a> {
crate_rejections: CrateRejections, crate_rejections: CrateRejections,
} }
#[derive(Clone)] #[derive(Clone, Debug)]
pub(crate) struct CratePaths { pub(crate) struct CratePaths {
pub(crate) name: Symbol, pub(crate) name: Symbol,
source: CrateSource, source: CrateSource,
@ -272,7 +272,7 @@ impl CratePaths {
} }
} }
#[derive(Copy, Clone, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]
pub(crate) enum CrateFlavor { pub(crate) enum CrateFlavor {
Rlib, Rlib,
Rmeta, Rmeta,
@ -893,13 +893,13 @@ fn get_flavor_from_path(path: &Path) -> CrateFlavor {
// ------------------------------------------ Error reporting ------------------------------------- // ------------------------------------------ Error reporting -------------------------------------
#[derive(Clone)] #[derive(Clone, Debug)]
struct CrateMismatch { struct CrateMismatch {
path: PathBuf, path: PathBuf,
got: String, got: String,
} }
#[derive(Clone, Default)] #[derive(Clone, Debug, Default)]
struct CrateRejections { struct CrateRejections {
via_hash: Vec<CrateMismatch>, via_hash: Vec<CrateMismatch>,
via_triple: Vec<CrateMismatch>, via_triple: Vec<CrateMismatch>,
@ -912,6 +912,7 @@ struct CrateRejections {
/// Candidate rejection reasons collected during crate search. /// Candidate rejection reasons collected during crate search.
/// If no candidate is accepted, then these reasons are presented to the user, /// If no candidate is accepted, then these reasons are presented to the user,
/// otherwise they are ignored. /// otherwise they are ignored.
#[derive(Debug)]
pub(crate) struct CombinedLocatorError { pub(crate) struct CombinedLocatorError {
crate_name: Symbol, crate_name: Symbol,
dep_root: Option<CratePaths>, dep_root: Option<CratePaths>,
@ -921,6 +922,7 @@ pub(crate) struct CombinedLocatorError {
crate_rejections: CrateRejections, crate_rejections: CrateRejections,
} }
#[derive(Debug)]
pub(crate) enum CrateError { pub(crate) enum CrateError {
NonAsciiName(Symbol), NonAsciiName(Symbol),
ExternLocationNotExist(Symbol, PathBuf), ExternLocationNotExist(Symbol, PathBuf),

View file

@ -1936,6 +1936,10 @@ impl CrateMetadata {
self.root.needs_panic_runtime self.root.needs_panic_runtime
} }
pub(crate) fn is_private_dep(&self) -> bool {
self.private_dep
}
pub(crate) fn is_panic_runtime(&self) -> bool { pub(crate) fn is_panic_runtime(&self) -> bool {
self.root.panic_runtime self.root.panic_runtime
} }