Skip to content

Commit b94b90a

Browse files
committed
add debug logs
1 parent 5421d94 commit b94b90a

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

src/librustc/hir/lowering.rs

+42-3
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ enum ParenthesizedGenericArgs {
323323
/// `resolve_lifetime` module. Often we "fallthrough" to that code by generating
324324
/// an "elided" or "underscore" lifetime name. In the future, we probably want to move
325325
/// everything into HIR lowering.
326-
#[derive(Copy, Clone)]
326+
#[derive(Copy, Clone, Debug)]
327327
enum AnonymousLifetimeMode {
328328
/// For **Modern** cases, create a new anonymous region parameter
329329
/// and reference that.
@@ -361,7 +361,7 @@ enum AnonymousLifetimeMode {
361361
}
362362

363363
/// The type of elided lifetime replacement to perform on `async fn` return types.
364-
#[derive(Copy, Clone)]
364+
#[derive(Copy, Clone, Debug)]
365365
enum LtReplacement {
366366
/// Fresh name introduced by the single non-dyn elided lifetime
367367
/// in the arguments of the async fn.
@@ -890,10 +890,16 @@ impl<'a> LoweringContext<'a> {
890890
anonymous_lifetime_mode: AnonymousLifetimeMode,
891891
op: impl FnOnce(&mut Self) -> R,
892892
) -> R {
893+
debug!(
894+
"with_anonymous_lifetime_mode(anonymous_lifetime_mode={:?})",
895+
anonymous_lifetime_mode,
896+
);
893897
let old_anonymous_lifetime_mode = self.anonymous_lifetime_mode;
894898
self.anonymous_lifetime_mode = anonymous_lifetime_mode;
895899
let result = op(self);
896900
self.anonymous_lifetime_mode = old_anonymous_lifetime_mode;
901+
debug!("with_anonymous_lifetime_mode: restoring anonymous_lifetime_mode={:?}",
902+
old_anonymous_lifetime_mode);
897903
result
898904
}
899905

@@ -1731,6 +1737,13 @@ impl<'a> LoweringContext<'a> {
17311737
opaque_ty_node_id: NodeId,
17321738
lower_bounds: impl FnOnce(&mut LoweringContext<'_>) -> hir::GenericBounds,
17331739
) -> hir::TyKind {
1740+
debug!(
1741+
"lower_opaque_impl_trait(fn_def_id={:?}, opaque_ty_node_id={:?}, span={:?})",
1742+
fn_def_id,
1743+
opaque_ty_node_id,
1744+
span,
1745+
);
1746+
17341747
// Make sure we know that some funky desugaring has been going on here.
17351748
// This is a first: there is code in other places like for loop
17361749
// desugaring that explicitly states that we don't want to track that.
@@ -1758,6 +1771,14 @@ impl<'a> LoweringContext<'a> {
17581771
&hir_bounds,
17591772
);
17601773

1774+
debug!(
1775+
"lower_opaque_impl_trait: lifetimes={:#?}", lifetimes,
1776+
);
1777+
1778+
debug!(
1779+
"lower_opaque_impl_trait: lifetime_defs={:#?}", lifetime_defs,
1780+
);
1781+
17611782
self.with_hir_id_owner(opaque_ty_node_id, |lctx| {
17621783
let opaque_ty_item = hir::OpaqueTy {
17631784
generics: hir::Generics {
@@ -1773,7 +1794,7 @@ impl<'a> LoweringContext<'a> {
17731794
origin: hir::OpaqueTyOrigin::FnReturn,
17741795
};
17751796

1776-
trace!("exist ty from impl trait def-index: {:#?}", opaque_ty_def_index);
1797+
trace!("lower_opaque_impl_trait: {:#?}", opaque_ty_def_index);
17771798
let opaque_ty_id = lctx.generate_opaque_type(
17781799
opaque_ty_node_id,
17791800
opaque_ty_item,
@@ -1821,6 +1842,13 @@ impl<'a> LoweringContext<'a> {
18211842
parent_index: DefIndex,
18221843
bounds: &hir::GenericBounds,
18231844
) -> (HirVec<hir::GenericArg>, HirVec<hir::GenericParam>) {
1845+
debug!(
1846+
"lifetimes_from_impl_trait_bounds(opaque_ty_id={:?}, \
1847+
parent_index={:?}, \
1848+
bounds={:#?})",
1849+
opaque_ty_id, parent_index, bounds,
1850+
);
1851+
18241852
// This visitor walks over `impl Trait` bounds and creates defs for all lifetimes that
18251853
// appear in the bounds, excluding lifetimes that are created within the bounds.
18261854
// E.g., `'a`, `'b`, but not `'c` in `impl for<'c> SomeTrait<'a, 'b, 'c>`.
@@ -2606,6 +2634,15 @@ impl<'a> LoweringContext<'a> {
26062634
opaque_ty_node_id: NodeId,
26072635
elided_lt_replacement: LtReplacement,
26082636
) -> hir::FunctionRetTy {
2637+
debug!(
2638+
"lower_async_fn_ret_ty(\
2639+
output={:?}, \
2640+
fn_def_id={:?}, \
2641+
opaque_ty_node_id={:?}, \
2642+
elided_lt_replacement={:?})",
2643+
output, fn_def_id, opaque_ty_node_id, elided_lt_replacement,
2644+
);
2645+
26092646
let span = output.span();
26102647

26112648
let opaque_ty_span = self.mark_span_with_reason(
@@ -2632,6 +2669,8 @@ impl<'a> LoweringContext<'a> {
26322669
),
26332670
);
26342671

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

src/librustc/infer/opaque_types/mod.rs

+1
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

+5
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)