mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
internal: add some more tracing
spans inside of hir-ty
This commit is contained in:
parent
0fd770613b
commit
f9bef39d48
9 changed files with 46 additions and 0 deletions
|
@ -171,6 +171,7 @@ fn find_path_inner(ctx: FindPathCtx<'_>, item: ItemInNs, from: ModuleId) -> Opti
|
||||||
.map(|(item, _)| item)
|
.map(|(item, _)| item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
fn find_path_for_module(
|
fn find_path_for_module(
|
||||||
ctx: FindPathCtx<'_>,
|
ctx: FindPathCtx<'_>,
|
||||||
def_map: &DefMap,
|
def_map: &DefMap,
|
||||||
|
@ -312,6 +313,7 @@ fn find_self_super(def_map: &DefMap, item: ModuleId, from: ModuleId) -> Option<M
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
fn calculate_best_path(
|
fn calculate_best_path(
|
||||||
ctx: FindPathCtx<'_>,
|
ctx: FindPathCtx<'_>,
|
||||||
def_map: &DefMap,
|
def_map: &DefMap,
|
||||||
|
|
|
@ -91,6 +91,7 @@ pub enum Visibility {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Visibility {
|
impl Visibility {
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
pub fn is_visible_from(self, db: &dyn DefDatabase, from_module: ModuleId) -> bool {
|
pub fn is_visible_from(self, db: &dyn DefDatabase, from_module: ModuleId) -> bool {
|
||||||
let to_module = match self {
|
let to_module = match self {
|
||||||
Visibility::Module(m, _) => m,
|
Visibility::Module(m, _) => m,
|
||||||
|
|
|
@ -88,6 +88,7 @@ impl<'a, 'db> Autoderef<'a, 'db> {
|
||||||
impl Iterator for Autoderef<'_, '_> {
|
impl Iterator for Autoderef<'_, '_> {
|
||||||
type Item = (Ty, usize);
|
type Item = (Ty, usize);
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
if self.at_start {
|
if self.at_start {
|
||||||
self.at_start = false;
|
self.at_start = false;
|
||||||
|
|
|
@ -125,6 +125,7 @@ impl<D> TyBuilder<D> {
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
pub(crate) fn fill_with_inference_vars(self, table: &mut InferenceTable<'_>) -> Self {
|
pub(crate) fn fill_with_inference_vars(self, table: &mut InferenceTable<'_>) -> Self {
|
||||||
self.fill(|x| match x {
|
self.fill(|x| match x {
|
||||||
ParamKind::Type => table.new_type_var().cast(Interner),
|
ParamKind::Type => table.new_type_var().cast(Interner),
|
||||||
|
@ -208,6 +209,7 @@ impl TyBuilder<()> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
pub fn subst_for_def(
|
pub fn subst_for_def(
|
||||||
db: &dyn HirDatabase,
|
db: &dyn HirDatabase,
|
||||||
def: impl Into<GenericDefId>,
|
def: impl Into<GenericDefId>,
|
||||||
|
|
|
@ -469,12 +469,14 @@ impl<'a> InferenceTable<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
pub(crate) fn rollback_to(&mut self, snapshot: InferenceTableSnapshot) {
|
pub(crate) fn rollback_to(&mut self, snapshot: InferenceTableSnapshot) {
|
||||||
self.var_unification_table.rollback_to(snapshot.var_table_snapshot);
|
self.var_unification_table.rollback_to(snapshot.var_table_snapshot);
|
||||||
self.type_variable_table = snapshot.type_variable_table_snapshot;
|
self.type_variable_table = snapshot.type_variable_table_snapshot;
|
||||||
self.pending_obligations = snapshot.pending_obligations;
|
self.pending_obligations = snapshot.pending_obligations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
pub(crate) fn run_in_snapshot<T>(&mut self, f: impl FnOnce(&mut InferenceTable<'_>) -> T) -> T {
|
pub(crate) fn run_in_snapshot<T>(&mut self, f: impl FnOnce(&mut InferenceTable<'_>) -> T) -> T {
|
||||||
let snapshot = self.snapshot();
|
let snapshot = self.snapshot();
|
||||||
let result = f(self);
|
let result = f(self);
|
||||||
|
|
|
@ -931,6 +931,15 @@ pub fn iterate_method_candidates_dyn(
|
||||||
mode: LookupMode,
|
mode: LookupMode,
|
||||||
callback: &mut dyn FnMut(ReceiverAdjustments, AssocItemId, bool) -> ControlFlow<()>,
|
callback: &mut dyn FnMut(ReceiverAdjustments, AssocItemId, bool) -> ControlFlow<()>,
|
||||||
) -> ControlFlow<()> {
|
) -> ControlFlow<()> {
|
||||||
|
let _p = tracing::span!(
|
||||||
|
tracing::Level::INFO,
|
||||||
|
"iterate_method_candidates_dyn",
|
||||||
|
?mode,
|
||||||
|
?name,
|
||||||
|
traits_in_scope_len = traits_in_scope.len()
|
||||||
|
)
|
||||||
|
.entered();
|
||||||
|
|
||||||
match mode {
|
match mode {
|
||||||
LookupMode::MethodCall => {
|
LookupMode::MethodCall => {
|
||||||
// For method calls, rust first does any number of autoderef, and
|
// For method calls, rust first does any number of autoderef, and
|
||||||
|
@ -984,6 +993,7 @@ pub fn iterate_method_candidates_dyn(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all, fields(name = ?name))]
|
||||||
fn iterate_method_candidates_with_autoref(
|
fn iterate_method_candidates_with_autoref(
|
||||||
receiver_ty: &Canonical<Ty>,
|
receiver_ty: &Canonical<Ty>,
|
||||||
first_adjustment: ReceiverAdjustments,
|
first_adjustment: ReceiverAdjustments,
|
||||||
|
@ -1041,6 +1051,7 @@ fn iterate_method_candidates_with_autoref(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all, fields(name = ?name))]
|
||||||
fn iterate_method_candidates_by_receiver(
|
fn iterate_method_candidates_by_receiver(
|
||||||
receiver_ty: &Canonical<Ty>,
|
receiver_ty: &Canonical<Ty>,
|
||||||
receiver_adjustments: ReceiverAdjustments,
|
receiver_adjustments: ReceiverAdjustments,
|
||||||
|
@ -1088,6 +1099,7 @@ fn iterate_method_candidates_by_receiver(
|
||||||
ControlFlow::Continue(())
|
ControlFlow::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all, fields(name = ?name))]
|
||||||
fn iterate_method_candidates_for_self_ty(
|
fn iterate_method_candidates_for_self_ty(
|
||||||
self_ty: &Canonical<Ty>,
|
self_ty: &Canonical<Ty>,
|
||||||
db: &dyn HirDatabase,
|
db: &dyn HirDatabase,
|
||||||
|
@ -1119,6 +1131,7 @@ fn iterate_method_candidates_for_self_ty(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all, fields(name = ?name, visible_from_module, receiver_ty))]
|
||||||
fn iterate_trait_method_candidates(
|
fn iterate_trait_method_candidates(
|
||||||
self_ty: &Ty,
|
self_ty: &Ty,
|
||||||
table: &mut InferenceTable<'_>,
|
table: &mut InferenceTable<'_>,
|
||||||
|
@ -1175,6 +1188,7 @@ fn iterate_trait_method_candidates(
|
||||||
ControlFlow::Continue(())
|
ControlFlow::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all, fields(name = ?name, visible_from_module, receiver_ty))]
|
||||||
fn iterate_inherent_methods(
|
fn iterate_inherent_methods(
|
||||||
self_ty: &Ty,
|
self_ty: &Ty,
|
||||||
table: &mut InferenceTable<'_>,
|
table: &mut InferenceTable<'_>,
|
||||||
|
@ -1267,6 +1281,7 @@ fn iterate_inherent_methods(
|
||||||
}
|
}
|
||||||
return ControlFlow::Continue(());
|
return ControlFlow::Continue(());
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all, fields(name = ?name, visible_from_module, receiver_ty))]
|
||||||
fn iterate_inherent_trait_methods(
|
fn iterate_inherent_trait_methods(
|
||||||
self_ty: &Ty,
|
self_ty: &Ty,
|
||||||
table: &mut InferenceTable<'_>,
|
table: &mut InferenceTable<'_>,
|
||||||
|
@ -1293,6 +1308,7 @@ fn iterate_inherent_methods(
|
||||||
ControlFlow::Continue(())
|
ControlFlow::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all, fields(name = ?name, visible_from_module, receiver_ty))]
|
||||||
fn impls_for_self_ty(
|
fn impls_for_self_ty(
|
||||||
impls: &InherentImpls,
|
impls: &InherentImpls,
|
||||||
self_ty: &Ty,
|
self_ty: &Ty,
|
||||||
|
@ -1356,6 +1372,7 @@ macro_rules! check_that {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all, fields(name))]
|
||||||
fn is_valid_candidate(
|
fn is_valid_candidate(
|
||||||
table: &mut InferenceTable<'_>,
|
table: &mut InferenceTable<'_>,
|
||||||
name: Option<&Name>,
|
name: Option<&Name>,
|
||||||
|
@ -1403,6 +1420,7 @@ enum IsValidCandidate {
|
||||||
NotVisible,
|
NotVisible,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all, fields(name))]
|
||||||
fn is_valid_fn_candidate(
|
fn is_valid_fn_candidate(
|
||||||
table: &mut InferenceTable<'_>,
|
table: &mut InferenceTable<'_>,
|
||||||
fn_id: FunctionId,
|
fn_id: FunctionId,
|
||||||
|
@ -1540,6 +1558,7 @@ pub fn implements_trait_unique(
|
||||||
|
|
||||||
/// This creates Substs for a trait with the given Self type and type variables
|
/// This creates Substs for a trait with the given Self type and type variables
|
||||||
/// for all other parameters, to query Chalk with it.
|
/// for all other parameters, to query Chalk with it.
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
fn generic_implements_goal(
|
fn generic_implements_goal(
|
||||||
db: &dyn HirDatabase,
|
db: &dyn HirDatabase,
|
||||||
env: Arc<TraitEnvironment>,
|
env: Arc<TraitEnvironment>,
|
||||||
|
|
|
@ -4101,6 +4101,14 @@ impl Type {
|
||||||
name: Option<&Name>,
|
name: Option<&Name>,
|
||||||
callback: &mut dyn FnMut(AssocItemId) -> ControlFlow<()>,
|
callback: &mut dyn FnMut(AssocItemId) -> ControlFlow<()>,
|
||||||
) {
|
) {
|
||||||
|
let _p = tracing::span!(
|
||||||
|
tracing::Level::INFO,
|
||||||
|
"iterate_method_candidates_dyn",
|
||||||
|
with_local_impls = traits_in_scope.len(),
|
||||||
|
traits_in_scope = traits_in_scope.len(),
|
||||||
|
?name,
|
||||||
|
)
|
||||||
|
.entered();
|
||||||
// There should be no inference vars in types passed here
|
// There should be no inference vars in types passed here
|
||||||
let canonical = hir_ty::replace_errors_with_variables(&self.ty);
|
let canonical = hir_ty::replace_errors_with_variables(&self.ty);
|
||||||
|
|
||||||
|
@ -4122,6 +4130,7 @@ impl Type {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all, fields(name = ?name))]
|
||||||
pub fn iterate_path_candidates<T>(
|
pub fn iterate_path_candidates<T>(
|
||||||
&self,
|
&self,
|
||||||
db: &dyn HirDatabase,
|
db: &dyn HirDatabase,
|
||||||
|
@ -4150,6 +4159,7 @@ impl Type {
|
||||||
slot
|
slot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all, fields(name = ?name))]
|
||||||
fn iterate_path_candidates_dyn(
|
fn iterate_path_candidates_dyn(
|
||||||
&self,
|
&self,
|
||||||
db: &dyn HirDatabase,
|
db: &dyn HirDatabase,
|
||||||
|
|
|
@ -395,6 +395,14 @@ fn import_assets_for_path(
|
||||||
potential_import_name: &str,
|
potential_import_name: &str,
|
||||||
qualifier: Option<ast::Path>,
|
qualifier: Option<ast::Path>,
|
||||||
) -> Option<ImportAssets> {
|
) -> Option<ImportAssets> {
|
||||||
|
let _p = tracing::span!(
|
||||||
|
tracing::Level::INFO,
|
||||||
|
"import_assets_for_path",
|
||||||
|
?potential_import_name,
|
||||||
|
?qualifier
|
||||||
|
)
|
||||||
|
.entered();
|
||||||
|
|
||||||
let fuzzy_name_length = potential_import_name.len();
|
let fuzzy_name_length = potential_import_name.len();
|
||||||
let mut assets_for_path = ImportAssets::for_fuzzy_path(
|
let mut assets_for_path = ImportAssets::for_fuzzy_path(
|
||||||
ctx.module,
|
ctx.module,
|
||||||
|
|
|
@ -605,6 +605,7 @@ fn assoc_to_item(assoc: AssocItem) -> ItemInNs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
fn get_mod_path(
|
fn get_mod_path(
|
||||||
db: &RootDatabase,
|
db: &RootDatabase,
|
||||||
item_to_search: ItemInNs,
|
item_to_search: ItemInNs,
|
||||||
|
|
Loading…
Reference in a new issue