Address review comments
This commit is contained in:
parent
7d67a1b871
commit
b81d164f61
@ -84,13 +84,11 @@ fn deref(&self) -> &Self::Target {
|
||||
|
||||
struct CrateDump<'a>(&'a CStore);
|
||||
|
||||
fn crate_dump(cstore: &'a CStore) -> impl std::fmt::Debug + 'a {
|
||||
CrateDump(cstore)
|
||||
}
|
||||
|
||||
impl<'a> std::fmt::Debug for CrateDump<'a> {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
writeln!(fmt, "resolved crates:")?;
|
||||
// `iter_crate_data` does not allow returning values. Thus we use a mutable variable here
|
||||
// that aggregates the value (and any errors that could happen).
|
||||
let mut res = Ok(());
|
||||
self.0.iter_crate_data(|cnum, data| {
|
||||
res = res.and(
|
||||
@ -878,7 +876,7 @@ pub fn postprocess(&mut self, krate: &ast::Crate) {
|
||||
self.inject_allocator_crate(krate);
|
||||
self.inject_panic_runtime(krate);
|
||||
|
||||
info!("{:?}", crate_dump(&self.cstore));
|
||||
info!("{:?}", CrateDump(&self.cstore));
|
||||
|
||||
self.report_unused_deps(krate);
|
||||
}
|
||||
|
@ -1905,49 +1905,53 @@ pub fn go(fmt: &mut std::fmt::Formatter<'_>, tcx: TyCtxt<'_>) -> std::fmt::Resul
|
||||
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
pub fn debug_stats(self) -> impl std::fmt::Debug + 'tcx {
|
||||
struct DebugStats<'tcx>(TyCtxt<'tcx>);
|
||||
|
||||
impl std::fmt::Debug for DebugStats<'tcx> {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
sty_debug_print!(
|
||||
fmt,
|
||||
self.0,
|
||||
Adt,
|
||||
Array,
|
||||
Slice,
|
||||
RawPtr,
|
||||
Ref,
|
||||
FnDef,
|
||||
FnPtr,
|
||||
Placeholder,
|
||||
Generator,
|
||||
GeneratorWitness,
|
||||
Dynamic,
|
||||
Closure,
|
||||
Tuple,
|
||||
Bound,
|
||||
Param,
|
||||
Infer,
|
||||
Projection,
|
||||
Opaque,
|
||||
Foreign
|
||||
)?;
|
||||
|
||||
writeln!(fmt, "InternalSubsts interner: #{}", self.0.interners.substs.len())?;
|
||||
writeln!(fmt, "Region interner: #{}", self.0.interners.region.len())?;
|
||||
writeln!(fmt, "Stability interner: #{}", self.0.stability_interner.len())?;
|
||||
writeln!(
|
||||
fmt,
|
||||
"Const Stability interner: #{}",
|
||||
self.0.const_stability_interner.len()
|
||||
)?;
|
||||
writeln!(fmt, "Allocation interner: #{}", self.0.allocation_interner.len())?;
|
||||
writeln!(fmt, "Layout interner: #{}", self.0.layout_interner.len())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
DebugStats(self)
|
||||
}
|
||||
}
|
||||
|
||||
struct DebugStats<'tcx>(TyCtxt<'tcx>);
|
||||
|
||||
impl std::fmt::Debug for DebugStats<'tcx> {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
sty_debug_print!(
|
||||
fmt,
|
||||
self.0,
|
||||
Adt,
|
||||
Array,
|
||||
Slice,
|
||||
RawPtr,
|
||||
Ref,
|
||||
FnDef,
|
||||
FnPtr,
|
||||
Placeholder,
|
||||
Generator,
|
||||
GeneratorWitness,
|
||||
Dynamic,
|
||||
Closure,
|
||||
Tuple,
|
||||
Bound,
|
||||
Param,
|
||||
Infer,
|
||||
Projection,
|
||||
Opaque,
|
||||
Foreign
|
||||
)?;
|
||||
|
||||
writeln!(fmt, "InternalSubsts interner: #{}", self.0.interners.substs.len())?;
|
||||
writeln!(fmt, "Region interner: #{}", self.0.interners.region.len())?;
|
||||
writeln!(fmt, "Stability interner: #{}", self.0.stability_interner.len())?;
|
||||
writeln!(fmt, "Const Stability interner: #{}", self.0.const_stability_interner.len())?;
|
||||
writeln!(fmt, "Allocation interner: #{}", self.0.allocation_interner.len())?;
|
||||
writeln!(fmt, "Layout interner: #{}", self.0.layout_interner.len())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// An entry in an interner.
|
||||
struct Interned<'tcx, T: ?Sized>(&'tcx T);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user