Skip to content

Commit b51df1d

Browse files
committed
add debug logs
1 parent f86521e commit b51df1d

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

src/librustc/hir/lowering.rs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ enum ParenthesizedGenericArgs {
322322
/// `resolve_lifetime` module. Often we "fallthrough" to that code by generating
323323
/// an "elided" or "underscore" lifetime name. In the future, we probably want to move
324324
/// everything into HIR lowering.
325-
#[derive(Copy, Clone)]
325+
#[derive(Copy, Clone, Debug)]
326326
enum AnonymousLifetimeMode {
327327
/// For **Modern** cases, create a new anonymous region parameter
328328
/// and reference that.
@@ -715,10 +715,16 @@ impl<'a> LoweringContext<'a> {
715715
anonymous_lifetime_mode: AnonymousLifetimeMode,
716716
op: impl FnOnce(&mut Self) -> R,
717717
) -> R {
718+
debug!(
719+
"with_anonymous_lifetime_mode(anonymous_lifetime_mode={:?})",
720+
anonymous_lifetime_mode,
721+
);
718722
let old_anonymous_lifetime_mode = self.anonymous_lifetime_mode;
719723
self.anonymous_lifetime_mode = anonymous_lifetime_mode;
720724
let result = op(self);
721725
self.anonymous_lifetime_mode = old_anonymous_lifetime_mode;
726+
debug!("with_anonymous_lifetime_mode: restoring anonymous_lifetime_mode={:?}",
727+
old_anonymous_lifetime_mode);
722728
result
723729
}
724730

@@ -1355,6 +1361,13 @@ impl<'a> LoweringContext<'a> {
13551361
opaque_ty_node_id: NodeId,
13561362
lower_bounds: impl FnOnce(&mut LoweringContext<'_>) -> hir::GenericBounds,
13571363
) -> hir::TyKind {
1364+
debug!(
1365+
"lower_opaque_impl_trait(fn_def_id={:?}, opaque_ty_node_id={:?}, span={:?})",
1366+
fn_def_id,
1367+
opaque_ty_node_id,
1368+
span,
1369+
);
1370+
13581371
// Make sure we know that some funky desugaring has been going on here.
13591372
// This is a first: there is code in other places like for loop
13601373
// desugaring that explicitly states that we don't want to track that.
@@ -1382,6 +1395,14 @@ impl<'a> LoweringContext<'a> {
13821395
&hir_bounds,
13831396
);
13841397

1398+
debug!(
1399+
"lower_opaque_impl_trait: lifetimes={:#?}", lifetimes,
1400+
);
1401+
1402+
debug!(
1403+
"lower_opaque_impl_trait: lifetime_defs={:#?}", lifetime_defs,
1404+
);
1405+
13851406
self.with_hir_id_owner(opaque_ty_node_id, |lctx| {
13861407
let opaque_ty_item = hir::OpaqueTy {
13871408
generics: hir::Generics {
@@ -1397,7 +1418,7 @@ impl<'a> LoweringContext<'a> {
13971418
origin: hir::OpaqueTyOrigin::FnReturn,
13981419
};
13991420

1400-
trace!("exist ty from impl trait def-index: {:#?}", opaque_ty_def_index);
1421+
trace!("lower_opaque_impl_trait: {:#?}", opaque_ty_def_index);
14011422
let opaque_ty_id = lctx.generate_opaque_type(
14021423
opaque_ty_node_id,
14031424
opaque_ty_item,
@@ -1445,6 +1466,13 @@ impl<'a> LoweringContext<'a> {
14451466
parent_index: DefIndex,
14461467
bounds: &hir::GenericBounds,
14471468
) -> (HirVec<hir::GenericArg>, HirVec<hir::GenericParam>) {
1469+
debug!(
1470+
"lifetimes_from_impl_trait_bounds(opaque_ty_id={:?}, \
1471+
parent_index={:?}, \
1472+
bounds={:#?})",
1473+
opaque_ty_id, parent_index, bounds,
1474+
);
1475+
14481476
// This visitor walks over `impl Trait` bounds and creates defs for all lifetimes that
14491477
// appear in the bounds, excluding lifetimes that are created within the bounds.
14501478
// E.g., `'a`, `'b`, but not `'c` in `impl for<'c> SomeTrait<'a, 'b, 'c>`.
@@ -2182,6 +2210,14 @@ impl<'a> LoweringContext<'a> {
21822210
fn_def_id: DefId,
21832211
opaque_ty_node_id: NodeId,
21842212
) -> hir::FunctionRetTy {
2213+
debug!(
2214+
"lower_async_fn_ret_ty(\
2215+
output={:?}, \
2216+
fn_def_id={:?}, \
2217+
opaque_ty_node_id={:?})",
2218+
output, fn_def_id, opaque_ty_node_id,
2219+
);
2220+
21852221
let span = output.span();
21862222

21872223
let opaque_ty_span = self.mark_span_with_reason(
@@ -2264,6 +2300,8 @@ impl<'a> LoweringContext<'a> {
22642300
),
22652301
);
22662302

2303+
debug!("lower_async_fn_ret_ty: future_bound={:#?}", future_bound);
2304+
22672305
// Calculate all the lifetimes that should be captured
22682306
// by the opaque type. This should include all in-scope
22692307
// lifetime parameters, including those defined in-band.

src/librustc/infer/opaque_types/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
11081108
// Use the same type variable if the exact same opaque type appears more
11091109
// than once in the return type (e.g., if it's passed to a type alias).
11101110
if let Some(opaque_defn) = self.opaque_types.get(&def_id) {
1111+
debug!("instantiate_opaque_types: returning concrete ty {:?}", opaque_defn.concrete_ty);
11111112
return opaque_defn.concrete_ty;
11121113
}
11131114
let span = tcx.def_span(def_id);

src/librustc/middle/resolve_lifetime.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
585585
self.is_in_fn_syntax = was_in_fn_syntax;
586586
}
587587
hir::TyKind::TraitObject(ref bounds, ref lifetime) => {
588+
debug!("visit_ty: TraitObject(bounds={:?}, lifetime={:?})", bounds, lifetime);
588589
for bound in bounds {
589590
self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None);
590591
}
@@ -897,6 +898,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
897898
}
898899

899900
fn visit_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime) {
901+
debug!("visit_lifetime(lifetime_ref={:?})", lifetime_ref);
900902
if lifetime_ref.is_elided() {
901903
self.resolve_elided_lifetimes(vec![lifetime_ref]);
902904
return;
@@ -2347,6 +2349,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
23472349
}
23482350

23492351
fn resolve_elided_lifetimes(&mut self, lifetime_refs: Vec<&'tcx hir::Lifetime>) {
2352+
debug!("resolve_elided_lifetimes(lifetime_refs={:?})", lifetime_refs);
2353+
23502354
if lifetime_refs.is_empty() {
23512355
return;
23522356
}
@@ -2539,6 +2543,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
25392543
}
25402544

25412545
fn resolve_object_lifetime_default(&mut self, lifetime_ref: &'tcx hir::Lifetime) {
2546+
debug!("resolve_object_lifetime_default(lifetime_ref={:?})", lifetime_ref);
25422547
let mut late_depth = 0;
25432548
let mut scope = self.scope;
25442549
let lifetime = loop {

0 commit comments

Comments
 (0)