Instrument important fns in AST lowering
This commit is contained in:
parent
7fe2c4b00d
commit
a22aad32eb
3 changed files with 18 additions and 6 deletions
|
@ -37,6 +37,9 @@
|
|||
#![recursion_limit = "256"]
|
||||
#![allow(rustc::potential_query_instability)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate tracing;
|
||||
|
||||
use rustc_ast::visit;
|
||||
use rustc_ast::{self as ast, *};
|
||||
use rustc_ast_pretty::pprust;
|
||||
|
@ -63,7 +66,6 @@ use rustc_span::{Span, DUMMY_SP};
|
|||
|
||||
use smallvec::SmallVec;
|
||||
use std::collections::hash_map::Entry;
|
||||
use tracing::{debug, trace};
|
||||
|
||||
macro_rules! arena_vec {
|
||||
($this:expr; $($x:expr),*) => (
|
||||
|
@ -439,7 +441,7 @@ pub fn lower_crate<'a, 'hir>(
|
|||
arena.alloc(krate)
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
enum ParamMode {
|
||||
/// Any path in a type context.
|
||||
Explicit,
|
||||
|
@ -455,6 +457,7 @@ enum ParenthesizedGenericArgs {
|
|||
}
|
||||
|
||||
impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
#[instrument(level = "debug", skip(self, f))]
|
||||
fn with_hir_id_owner(
|
||||
&mut self,
|
||||
owner: NodeId,
|
||||
|
@ -599,12 +602,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
self.lower_node_id(node_id)
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(self))]
|
||||
fn lower_res(&mut self, res: Res<NodeId>) -> Res {
|
||||
let res: Result<Res, ()> = res.apply_id(|id| {
|
||||
let owner = self.current_hir_id_owner;
|
||||
let local_id = self.node_id_to_local_id.get(&id).copied().ok_or(())?;
|
||||
Ok(hir::HirId { owner, local_id })
|
||||
});
|
||||
trace!(?res);
|
||||
|
||||
// We may fail to find a HirId when the Res points to a Local from an enclosing HIR owner.
|
||||
// This can happen when trying to lower the return type `x` in erroneous code like
|
||||
// async fn foo(x: u8) -> x {}
|
||||
|
@ -851,6 +857,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
/// ```
|
||||
///
|
||||
/// returns a `hir::TypeBinding` representing `Item`.
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn lower_assoc_ty_constraint(
|
||||
&mut self,
|
||||
constraint: &AssocConstraint,
|
||||
|
@ -1011,6 +1018,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
err.emit();
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn lower_generic_arg(
|
||||
&mut self,
|
||||
arg: &ast::GenericArg,
|
||||
|
@ -1081,6 +1089,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext) -> &'hir hir::Ty<'hir> {
|
||||
self.arena.alloc(self.lower_ty_direct(t, itctx))
|
||||
}
|
||||
|
@ -1737,6 +1746,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
)
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(self))]
|
||||
fn lower_param_bound(
|
||||
&mut self,
|
||||
tpb: &GenericBound,
|
||||
|
@ -1862,6 +1872,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
self.arena.alloc_from_iter(self.lower_generic_params_mut(params))
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(self))]
|
||||
fn lower_generic_param(&mut self, param: &GenericParam) -> hir::GenericParam<'hir> {
|
||||
let (name, kind) = match param.kind {
|
||||
GenericParamKind::Lifetime => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue