Skip to content

[experiment] Enable debug-logging by default #111924

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
downgrade some more logging
  • Loading branch information
jyn514 committed May 31, 2023
commit a97eec4c67bcd9358e93a1f56de9415df86e69d5
20 changes: 10 additions & 10 deletions compiler/rustc_const_eval/src/const_eval/eval_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
cid: GlobalId<'tcx>,
body: &'mir mir::Body<'tcx>,
) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
debug!("eval_body_using_ecx: {:?}, {:?}", cid, ecx.param_env);
trace!("eval_body_using_ecx: {:?}, {:?}", cid, ecx.param_env);
let tcx = *ecx.tcx;
assert!(
cid.promoted.is_some()
Expand Down Expand Up @@ -81,7 +81,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
intern_const_alloc_recursive(ecx, intern_kind, &ret)?;
// we leave alignment checks off, since this `ecx` will not be used for further evaluation anyway

debug!("eval_body_using_ecx done: {:?}", *ret);
trace!("eval_body_using_ecx done: {:?}", *ret);
Ok(ret)
}

Expand All @@ -98,7 +98,7 @@ pub(super) fn mk_eval_cx<'mir, 'tcx>(
param_env: ty::ParamEnv<'tcx>,
can_access_statics: bool,
) -> CompileTimeEvalContext<'mir, 'tcx> {
debug!("mk_eval_cx: {:?}", param_env);
trace!("mk_eval_cx: {:?}", param_env);
InterpCx::new(
tcx,
root_span,
Expand All @@ -109,7 +109,7 @@ pub(super) fn mk_eval_cx<'mir, 'tcx>(

/// This function converts an interpreter value into a constant that is meant for use in the
/// type system.
#[instrument(skip(ecx), level = "debug")]
#[instrument(skip(ecx), level = "trace")]
pub(super) fn op_to_const<'tcx>(
ecx: &CompileTimeEvalContext<'_, 'tcx>,
op: &OpTy<'tcx>,
Expand Down Expand Up @@ -144,11 +144,11 @@ pub(super) fn op_to_const<'tcx>(
op.as_mplace_or_imm()
};

debug!(?immediate);
trace!(?immediate);

// We know `offset` is relative to the allocation, so we can use `into_parts`.
let to_const_value = |mplace: &MPlaceTy<'_>| {
debug!("to_const_value(mplace: {:?})", mplace);
trace!("to_const_value(mplace: {:?})", mplace);
match mplace.ptr.into_parts() {
(Some(alloc_id), offset) => {
let alloc = ecx.tcx.global_alloc(alloc_id).unwrap_memory();
Expand All @@ -173,7 +173,7 @@ pub(super) fn op_to_const<'tcx>(
_ if imm.layout.is_zst() => ConstValue::ZeroSized,
Immediate::Scalar(x) => ConstValue::Scalar(x),
Immediate::ScalarPair(a, b) => {
debug!("ScalarPair(a: {:?}, b: {:?})", a, b);
trace!("ScalarPair(a: {:?}, b: {:?})", a, b);
// We know `offset` is relative to the allocation, so we can use `into_parts`.
let (data, start) = match a.to_pointer(ecx).unwrap().into_parts() {
(Some(alloc_id), offset) => {
Expand All @@ -196,7 +196,7 @@ pub(super) fn op_to_const<'tcx>(
}
}

#[instrument(skip(tcx), level = "debug", ret)]
#[instrument(skip(tcx), level = "trace", ret)]
pub(crate) fn turn_into_const_value<'tcx>(
tcx: TyCtxt<'tcx>,
constant: ConstAlloc<'tcx>,
Expand Down Expand Up @@ -226,7 +226,7 @@ pub(crate) fn turn_into_const_value<'tcx>(
op_to_const(&ecx, &mplace.into())
}

#[instrument(skip(tcx), level = "debug")]
#[instrument(skip(tcx), level = "trace")]
pub fn eval_to_const_value_raw_provider<'tcx>(
tcx: TyCtxt<'tcx>,
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
Expand Down Expand Up @@ -261,7 +261,7 @@ pub fn eval_to_const_value_raw_provider<'tcx>(
tcx.eval_to_allocation_raw(key).map(|val| turn_into_const_value(tcx, val, key))
}

#[instrument(skip(tcx), level = "debug")]
#[instrument(skip(tcx), level = "trace")]
pub fn eval_to_allocation_raw_provider<'tcx>(
tcx: TyCtxt<'tcx>,
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
Expand Down
51 changes: 26 additions & 25 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ fn check_well_formed(tcx: TyCtxt<'_>, def_id: hir::OwnerId) {
/// We do this check as a pre-pass before checking fn bodies because if these constraints are
/// not included it frequently leads to confusing errors in fn bodies. So it's better to check
/// the types first.
#[instrument(skip(tcx), level = "debug")]
#[instrument(skip(tcx), level = "trace")]
fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) {
let def_id = item.owner_id.def_id;

debug!(
trace!(
?item.owner_id,
item.name = ? tcx.def_path_str(def_id)
);
Expand Down Expand Up @@ -249,7 +249,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) {
fn check_foreign_item(tcx: TyCtxt<'_>, item: &hir::ForeignItem<'_>) {
let def_id = item.owner_id.def_id;

debug!(
trace!(
?item.owner_id,
item.name = ? tcx.def_path_str(def_id)
);
Expand Down Expand Up @@ -405,7 +405,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe

for (gat_def_id, required_bounds) in required_bounds_by_item {
let gat_item_hir = tcx.hir().expect_trait_item(gat_def_id.def_id);
debug!(?required_bounds);
trace!(?required_bounds);
let param_env = tcx.param_env(gat_def_id);

let mut unsatisfied_bounds: Vec<_> = required_bounds
Expand Down Expand Up @@ -546,8 +546,8 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
for (ty, ty_idx) in &types {
// In our example, requires that `Self: 'a`
if ty_known_to_outlive(tcx, item_def_id.def_id, param_env, &wf_tys, *ty, *region_a) {
debug!(?ty_idx, ?region_a_idx);
debug!("required clause: {ty} must outlive {region_a}");
trace!(?ty_idx, ?region_a_idx);
trace!("required clause: {ty} must outlive {region_a}");
// Translate into the generic parameters of the GAT. In
// our example, the type was `Self`, which will also be
// `Self` in the GAT.
Expand Down Expand Up @@ -592,8 +592,8 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
*region_a,
*region_b,
) {
debug!(?region_a_idx, ?region_b_idx);
debug!("required clause: {region_a} must outlive {region_b}");
trace!(?region_a_idx, ?region_b_idx);
trace!("required clause: {region_a} must outlive {region_b}");
// Translate into the generic parameters of the GAT.
let region_a_param = gat_generics.param_at(*region_a_idx, tcx);
let region_a_param = ty::Region::new_early_bound(
Expand Down Expand Up @@ -690,7 +690,7 @@ fn resolve_regions_with_wf_tys<'tcx>(
add_constraints(&infcx, region_bound_pairs);

let errors = infcx.resolve_regions(&outlives_environment);
debug!(?errors, "errors");
trace!(?errors, "errors");

// If we were able to prove that the type outlives the region without
// an error, it must be because of the implied or explicit bounds...
Expand Down Expand Up @@ -950,7 +950,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
}
}

#[instrument(level = "debug", skip(tcx, span, sig_if_method))]
#[instrument(level = "trace", skip(tcx, span, sig_if_method))]
fn check_associated_item(
tcx: TyCtxt<'_>,
item_id: LocalDefId,
Expand Down Expand Up @@ -1100,7 +1100,7 @@ fn check_type_defn<'tcx>(tcx: TyCtxt<'tcx>, item: &hir::Item<'tcx>, all_sized: b

#[instrument(skip(tcx, item))]
fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) {
debug!(?item.owner_id);
trace!(?item.owner_id);

let def_id = item.owner_id.def_id;
let trait_def = tcx.trait_def(def_id);
Expand Down Expand Up @@ -1135,7 +1135,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) {
fn check_associated_type_bounds(wfcx: &WfCheckingCtxt<'_, '_>, item: ty::AssocItem, span: Span) {
let bounds = wfcx.tcx().explicit_item_bounds(item.def_id);

debug!("check_associated_type_bounds: bounds={:?}", bounds);
trace!("check_associated_type_bounds: bounds={:?}", bounds);
let wf_obligations = bounds.subst_identity_iter_copied().flat_map(|(bound, bound_span)| {
let normalized_bound = wfcx.normalize(span, None, bound);
traits::wf::predicate_obligations(
Expand Down Expand Up @@ -1164,7 +1164,7 @@ fn check_item_fn(
}

fn check_item_type(tcx: TyCtxt<'_>, item_id: LocalDefId, ty_span: Span, allow_foreign_ty: bool) {
debug!("check_item_type: {:?}", item_id);
trace!("check_item_type: {:?}", item_id);

enter_wf_checking_ctxt(tcx, ty_span, item_id, |wfcx| {
let ty = tcx.type_of(item_id).subst_identity();
Expand Down Expand Up @@ -1205,7 +1205,7 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: LocalDefId, ty_span: Span, allow_fo
});
}

#[instrument(level = "debug", skip(tcx, ast_self_ty, ast_trait_ref))]
#[instrument(level = "trace", skip(tcx, ast_self_ty, ast_trait_ref))]
fn check_impl<'tcx>(
tcx: TyCtxt<'tcx>,
item: &'tcx hir::Item<'tcx>,
Expand Down Expand Up @@ -1248,7 +1248,7 @@ fn check_impl<'tcx>(
obligation.cause.span = ast_self_ty.span;
}
}
debug!(?obligations);
trace!(?obligations);
wfcx.register_obligations(obligations);
}
None => {
Expand All @@ -1271,7 +1271,7 @@ fn check_impl<'tcx>(
}

/// Checks where-clauses and inline bounds that are declared on `def_id`.
#[instrument(level = "debug", skip(wfcx))]
#[instrument(level = "trace", skip(wfcx))]
fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id: LocalDefId) {
let infcx = wfcx.infcx;
let tcx = wfcx.tcx();
Expand Down Expand Up @@ -1443,7 +1443,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id

let predicates = wfcx.normalize(span, None, predicates);

debug!(?predicates.predicates);
trace!(?predicates.predicates);
assert_eq!(predicates.predicates.len(), predicates.spans.len());
let wf_obligations = predicates.into_iter().flat_map(|(p, sp)| {
traits::wf::predicate_obligations(
Expand All @@ -1458,7 +1458,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
wfcx.register_obligations(obligations);
}

#[instrument(level = "debug", skip(wfcx, span, hir_decl))]
#[instrument(level = "trace", skip(wfcx, span, hir_decl))]
fn check_fn_or_method<'tcx>(
wfcx: &WfCheckingCtxt<'_, 'tcx>,
span: Span,
Expand Down Expand Up @@ -1621,7 +1621,7 @@ const HELP_FOR_SELF_TYPE: &str = "consider changing to `self`, `&self`, `&mut se
`self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one \
of the previous types except `Self`)";

#[instrument(level = "debug", skip(wfcx))]
#[instrument(level = "trace", skip(wfcx))]
fn check_method_receiver<'tcx>(
wfcx: &WfCheckingCtxt<'_, 'tcx>,
fn_sig: &hir::FnSig<'_>,
Expand All @@ -1640,7 +1640,7 @@ fn check_method_receiver<'tcx>(
let sig = tcx.liberate_late_bound_regions(method.def_id, sig);
let sig = wfcx.normalize(span, None, sig);

debug!("check_method_receiver: sig={:?}", sig);
trace!("check_method_receiver: sig={:?}", sig);

let self_ty = wfcx.normalize(span, None, self_ty);

Expand Down Expand Up @@ -1733,9 +1733,10 @@ fn receiver_is_valid<'tcx>(
// Keep dereferencing `receiver_ty` until we get to `self_ty`.
loop {
if let Some((potential_self_ty, _)) = autoderef.next() {
debug!(
trace!(
"receiver_is_valid: potential self type `{:?}` to match `{:?}`",
potential_self_ty, self_ty
potential_self_ty,
self_ty
);

if can_eq_self(potential_self_ty) {
Expand Down Expand Up @@ -1764,7 +1765,7 @@ fn receiver_is_valid<'tcx>(
}
}
} else {
debug!("receiver_is_valid: type `{:?}` does not deref to `{:?}`", receiver_ty, self_ty);
trace!("receiver_is_valid: type `{:?}` does not deref to `{:?}`", receiver_ty, self_ty);
// If the receiver already has errors reported due to it, consider it valid to avoid
// unnecessary errors (#58712).
return receiver_ty.references_error();
Expand Down Expand Up @@ -1795,7 +1796,7 @@ fn receiver_is_implemented<'tcx>(
if wfcx.infcx.predicate_must_hold_modulo_regions(&obligation) {
true
} else {
debug!(
trace!(
"receiver_is_implemented: type `{:?}` does not implement `Receiver` trait",
receiver_ty
);
Expand Down Expand Up @@ -1897,7 +1898,7 @@ fn report_bivariance(
impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
/// Feature gates RFC 2056 -- trivial bounds, checking for global bounds that
/// aren't true.
#[instrument(level = "debug", skip(self))]
#[instrument(level = "trace", skip(self))]
fn check_false_global_bounds(&mut self) {
let tcx = self.ocx.infcx.tcx;
let mut span = self.span;
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_query_system/src/dep_graph/serialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,20 @@ impl<K: DepKind> SerializedDepGraph<K> {
impl<'a, K: DepKind + Decodable<MemDecoder<'a>>> Decodable<MemDecoder<'a>>
for SerializedDepGraph<K>
{
#[instrument(level = "debug", skip(d))]
#[instrument(level = "trace", skip(d))]
fn decode(d: &mut MemDecoder<'a>) -> SerializedDepGraph<K> {
// The last 16 bytes are the node count and edge count.
debug!("position: {:?}", d.position());
trace!("position: {:?}", d.position());
let (node_count, edge_count) =
d.with_position(d.len() - 2 * IntEncodedWithFixedSize::ENCODED_SIZE, |d| {
debug!("position: {:?}", d.position());
trace!("position: {:?}", d.position());
let node_count = IntEncodedWithFixedSize::decode(d).0 as usize;
let edge_count = IntEncodedWithFixedSize::decode(d).0 as usize;
(node_count, edge_count)
});
debug!("position: {:?}", d.position());
trace!("position: {:?}", d.position());

debug!(?node_count, ?edge_count);
trace!(?node_count, ?edge_count);

let mut nodes = IndexVec::with_capacity(node_count);
let mut fingerprints = IndexVec::with_capacity(node_count);
Expand Down Expand Up @@ -207,11 +207,11 @@ impl<K: DepKind> EncoderState<K> {
let node_count = total_node_count.try_into().unwrap();
let edge_count = total_edge_count.try_into().unwrap();

debug!(?node_count, ?edge_count);
debug!("position: {:?}", encoder.position());
trace!(?node_count, ?edge_count);
trace!("position: {:?}", encoder.position());
IntEncodedWithFixedSize(node_count).encode(&mut encoder);
IntEncodedWithFixedSize(edge_count).encode(&mut encoder);
debug!("position: {:?}", encoder.position());
trace!("position: {:?}", encoder.position());
// Drop the encoder so that nothing is written after the counts.
let result = encoder.finish();
if let Ok(position) = result {
Expand Down