-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Replace all uses of log::log_enabled
with Debug
printers
#74876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1831,7 +1831,7 @@ pub mod tls { | |
} | ||
|
||
macro_rules! sty_debug_print { | ||
($ctxt: expr, $($variant: ident),*) => {{ | ||
($fmt: expr, $ctxt: expr, $($variant: ident),*) => {{ | ||
// Curious inner module to allow variant names to be used as | ||
// variable names. | ||
#[allow(non_snake_case)] | ||
|
@@ -1848,7 +1848,7 @@ macro_rules! sty_debug_print { | |
all_infer: usize, | ||
} | ||
|
||
pub fn go(tcx: TyCtxt<'_>) { | ||
pub fn go(fmt: &mut std::fmt::Formatter<'_>, tcx: TyCtxt<'_>) -> std::fmt::Result { | ||
let mut total = DebugStat { | ||
total: 0, | ||
lt_infer: 0, | ||
|
@@ -1878,18 +1878,18 @@ macro_rules! sty_debug_print { | |
if ct { total.ct_infer += 1; variant.ct_infer += 1 } | ||
if lt && ty && ct { total.all_infer += 1; variant.all_infer += 1 } | ||
} | ||
println!("Ty interner total ty lt ct all"); | ||
$(println!(" {:18}: {uses:6} {usespc:4.1}%, \ | ||
writeln!(fmt, "Ty interner total ty lt ct all")?; | ||
$(writeln!(fmt, " {:18}: {uses:6} {usespc:4.1}%, \ | ||
{ty:4.1}% {lt:5.1}% {ct:4.1}% {all:4.1}%", | ||
stringify!($variant), | ||
uses = $variant.total, | ||
usespc = $variant.total as f64 * 100.0 / total.total as f64, | ||
ty = $variant.ty_infer as f64 * 100.0 / total.total as f64, | ||
lt = $variant.lt_infer as f64 * 100.0 / total.total as f64, | ||
ct = $variant.ct_infer as f64 * 100.0 / total.total as f64, | ||
all = $variant.all_infer as f64 * 100.0 / total.total as f64); | ||
all = $variant.all_infer as f64 * 100.0 / total.total as f64)?; | ||
)* | ||
println!(" total {uses:6} \ | ||
writeln!(fmt, " total {uses:6} \ | ||
{ty:4.1}% {lt:5.1}% {ct:4.1}% {all:4.1}%", | ||
uses = total.total, | ||
ty = total.ty_infer as f64 * 100.0 / total.total as f64, | ||
|
@@ -1899,14 +1899,23 @@ macro_rules! sty_debug_print { | |
} | ||
} | ||
|
||
inner::go($ctxt) | ||
inner::go($fmt, $ctxt) | ||
}} | ||
} | ||
|
||
impl<'tcx> TyCtxt<'tcx> { | ||
pub fn print_debug_stats(self) { | ||
pub fn debug_stats(self) -> impl std::fmt::Debug + 'tcx { | ||
DebugStats(self) | ||
} | ||
} | ||
|
||
struct DebugStats<'tcx>(TyCtxt<'tcx>); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here for encapsulating the type inside |
||
|
||
impl std::fmt::Debug for DebugStats<'tcx> { | ||
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
sty_debug_print!( | ||
self, | ||
fmt, | ||
self.0, | ||
Adt, | ||
Array, | ||
Slice, | ||
|
@@ -1926,14 +1935,16 @@ impl<'tcx> TyCtxt<'tcx> { | |
Projection, | ||
Opaque, | ||
Foreign | ||
); | ||
|
||
println!("InternalSubsts interner: #{}", self.interners.substs.len()); | ||
println!("Region interner: #{}", self.interners.region.len()); | ||
println!("Stability interner: #{}", self.stability_interner.len()); | ||
println!("Const Stability interner: #{}", self.const_stability_interner.len()); | ||
println!("Allocation interner: #{}", self.allocation_interner.len()); | ||
println!("Layout interner: #{}", self.layout_interner.len()); | ||
)?; | ||
|
||
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(()) | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> { | |
self.copy_op(place.into(), dest)?; | ||
|
||
self.return_to_block(ret.map(|r| r.1))?; | ||
self.dump_place(*dest); | ||
trace!("{:?}", self.dump_place(*dest)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btw, why are these There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idk, the choice was fairly arbitrary |
||
Ok(true) | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.