Skip to content

Commit 83d70c0

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 51d9a6c commit 83d70c0

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

Diff for: compiler/rustc_metadata/src/creader.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ impl<'a> std::fmt::Debug for CrateDump<'a> {
147147
writeln!(fmt, " cnum: {cnum}")?;
148148
writeln!(fmt, " hash: {}", data.hash())?;
149149
writeln!(fmt, " reqd: {:?}", data.dep_kind())?;
150+
writeln!(fmt, " priv: {:?}", data.is_private_dep())?;
150151
let CrateSource { dylib, rlib, rmeta } = data.source();
151152
if let Some(dylib) = dylib {
152153
writeln!(fmt, " dylib: {}", dylib.0.display())?;
@@ -770,7 +771,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
770771

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

Diff for: 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),

Diff for: compiler/rustc_metadata/src/rmeta/decoder.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1936,6 +1936,10 @@ impl CrateMetadata {
19361936
self.root.needs_panic_runtime
19371937
}
19381938

1939+
pub(crate) fn is_private_dep(&self) -> bool {
1940+
self.private_dep
1941+
}
1942+
19391943
pub(crate) fn is_panic_runtime(&self) -> bool {
19401944
self.root.panic_runtime
19411945
}

0 commit comments

Comments
 (0)