Skip to content

Commit c0036bd

Browse files
committed
Add more trace info.
1 parent a105875 commit c0036bd

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

src/librustc_lint/builtin.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use rustc_trait_selection::traits::misc::can_type_implement_copy;
4747

4848
use crate::nonstandard_style::{method_context, MethodLateContext};
4949

50-
use log::debug;
50+
use log::{debug, trace};
5151
use std::fmt::Write;
5252

5353
// hardwired lints from librustc
@@ -1181,11 +1181,14 @@ fn check_const(cx: &LateContext<'_, '_>, body_id: hir::BodyId) {
11811181

11821182
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedBrokenConst {
11831183
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item<'_>) {
1184+
trace!("UnusedBrokenConst: check_item(_, _, {:?}", it);
11841185
match it.kind {
11851186
hir::ItemKind::Const(_, body_id) => {
1187+
trace!("UnusedBrokenConst: checking {:?}", body_id);
11861188
check_const(cx, body_id);
11871189
}
11881190
hir::ItemKind::Static(_, _, body_id) => {
1191+
trace!("UnusedBrokenConst: checking {:?}", body_id);
11891192
check_const(cx, body_id);
11901193
}
11911194
_ => {}

src/librustc_mir/const_eval/eval_queries.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ fn validate_and_turn_into_const<'tcx>(
181181
let val = (|| {
182182
let mplace = ecx.raw_const_to_mplace(constant)?;
183183

184+
debug!("validate_and_turn_into_const: mplace = {:?}", mplace);
185+
184186
// FIXME do not validate promoteds until a decision on
185187
// https://github.com/rust-lang/rust/issues/67465 is made
186188
if cid.promoted.is_none() {
@@ -209,6 +211,7 @@ fn validate_and_turn_into_const<'tcx>(
209211
})();
210212

211213
val.map_err(|error| {
214+
trace!("Validation failed: {:?}", error);
212215
let err = error_to_const_error(&ecx, error);
213216
match err.struct_error(ecx.tcx, "it is undefined behavior to use this value", |mut diag| {
214217
diag.note(note_on_undefined_behavior_error());
@@ -251,7 +254,10 @@ pub fn const_eval_validated_provider<'tcx>(
251254
});
252255
}
253256

254-
tcx.const_eval_raw(key).and_then(|val| validate_and_turn_into_const(tcx, val, key))
257+
tcx.const_eval_raw(key).and_then(|val| {
258+
trace!("const_eval_raw succeeded. val.alloc_id = {:?}. val.ty = {:?}", val.alloc_id, val.ty);
259+
validate_and_turn_into_const(tcx, val, key)
260+
})
255261
}
256262

257263
pub fn const_eval_raw_provider<'tcx>(
@@ -271,7 +277,7 @@ pub fn const_eval_raw_provider<'tcx>(
271277
key.param_env.reveal = Reveal::UserFacing;
272278
match tcx.const_eval_raw(key) {
273279
// try again with reveal all as requested
274-
Err(ErrorHandled::TooGeneric) => {}
280+
Err(ErrorHandled::TooGeneric) => { trace!("const_eval_raw: retrying with RevealAll"); }
275281
// deduplicate calls
276282
other => return other,
277283
}

src/librustc_mir/interpret/eval_context.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf for InterpCx<'mir, 'tcx, M> {
208208
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
209209
self.tcx
210210
.layout_of(self.param_env.and(ty))
211-
.map_err(|layout| err_inval!(Layout(layout)).into())
211+
.map_err(|layout| {
212+
let result = err_inval!(Layout(layout)).into();
213+
trace!("layout_of: returning error: {:?}", result);
214+
result
215+
})
212216
}
213217
}
214218

src/librustc_mir/interpret/place.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ where
11341134
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
11351135
// This must be an allocation in `tcx`
11361136
assert!(self.tcx.alloc_map.lock().get(raw.alloc_id).is_some());
1137+
trace!("raw_const_to_mplace: raw.ty = {:?}", raw.ty);
11371138
let ptr = self.tag_global_base_pointer(Pointer::from(raw.alloc_id));
11381139
let layout = self.layout_of(raw.ty)?;
11391140
Ok(MPlaceTy::from_aligned_ptr(ptr, layout))

0 commit comments

Comments
 (0)