Skip to content

Commit 89dd4ec

Browse files
committed
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.
1 parent 042fba1 commit 89dd4ec

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

compiler/rustc_metadata/src/creader.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ impl<'a> std::fmt::Debug for CrateDump<'a> {
142142
writeln!(fmt, " cnum: {cnum}")?;
143143
writeln!(fmt, " hash: {}", data.hash())?;
144144
writeln!(fmt, " reqd: {:?}", data.dep_kind())?;
145+
writeln!(fmt, " priv: {:?}", data.is_private_dep())?;
145146
let CrateSource { dylib, rlib, rmeta } = data.source();
146147
if let Some(dylib) = dylib {
147148
writeln!(fmt, " dylib: {}", dylib.0.display())?;
@@ -685,7 +686,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
685686

686687
match result {
687688
(LoadResult::Previous(cnum), None) => {
688-
info!("library for `{}` was loaded previously", name);
689+
info!("library for `{}` was loaded previously, cnum {cnum}", name);
689690
// When `private_dep` is none, it indicates the directly dependent crate. If it is
690691
// not specified by `--extern` on command line parameters, it may be
691692
// `private-dependency` when `register_crate` is called for the first time. Then it must be updated to

compiler/rustc_metadata/src/locator.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ pub(crate) struct CrateLocator<'a> {
260260
crate_rejections: CrateRejections,
261261
}
262262

263-
#[derive(Clone)]
263+
#[derive(Clone, Debug)]
264264
pub(crate) struct CratePaths {
265265
pub(crate) name: Symbol,
266266
source: CrateSource,
@@ -272,7 +272,7 @@ impl CratePaths {
272272
}
273273
}
274274

275-
#[derive(Copy, Clone, PartialEq)]
275+
#[derive(Copy, Clone, Debug, PartialEq)]
276276
pub(crate) enum CrateFlavor {
277277
Rlib,
278278
Rmeta,
@@ -893,13 +893,13 @@ fn get_flavor_from_path(path: &Path) -> CrateFlavor {
893893

894894
// ------------------------------------------ Error reporting -------------------------------------
895895

896-
#[derive(Clone)]
896+
#[derive(Clone, Debug)]
897897
struct CrateMismatch {
898898
path: PathBuf,
899899
got: String,
900900
}
901901

902-
#[derive(Clone, Default)]
902+
#[derive(Clone, Debug, Default)]
903903
struct CrateRejections {
904904
via_hash: Vec<CrateMismatch>,
905905
via_triple: Vec<CrateMismatch>,
@@ -912,6 +912,7 @@ struct CrateRejections {
912912
/// Candidate rejection reasons collected during crate search.
913913
/// If no candidate is accepted, then these reasons are presented to the user,
914914
/// otherwise they are ignored.
915+
#[derive(Debug)]
915916
pub(crate) struct CombinedLocatorError {
916917
crate_name: Symbol,
917918
dep_root: Option<CratePaths>,
@@ -921,6 +922,7 @@ pub(crate) struct CombinedLocatorError {
921922
crate_rejections: CrateRejections,
922923
}
923924

925+
#[derive(Debug)]
924926
pub(crate) enum CrateError {
925927
NonAsciiName(Symbol),
926928
ExternLocationNotExist(Symbol, PathBuf),

compiler/rustc_metadata/src/rmeta/decoder.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,10 @@ impl CrateMetadata {
19201920
self.root.needs_panic_runtime
19211921
}
19221922

1923+
pub(crate) fn is_private_dep(&self) -> bool {
1924+
self.private_dep
1925+
}
1926+
19231927
pub(crate) fn is_panic_runtime(&self) -> bool {
19241928
self.root.panic_runtime
19251929
}

0 commit comments

Comments
 (0)