mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Merge #1302
1302: profile type inference r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
c6a5d871d7
5 changed files with 8 additions and 3 deletions
|
@ -126,7 +126,7 @@ pub trait HirDatabase: DefDatabase {
|
||||||
#[salsa::invoke(ExprScopes::expr_scopes_query)]
|
#[salsa::invoke(ExprScopes::expr_scopes_query)]
|
||||||
fn expr_scopes(&self, def: DefWithBody) -> Arc<ExprScopes>;
|
fn expr_scopes(&self, def: DefWithBody) -> Arc<ExprScopes>;
|
||||||
|
|
||||||
#[salsa::invoke(crate::ty::infer)]
|
#[salsa::invoke(crate::ty::infer_query)]
|
||||||
fn infer(&self, def: DefWithBody) -> Arc<InferenceResult>;
|
fn infer(&self, def: DefWithBody) -> Arc<InferenceResult>;
|
||||||
|
|
||||||
#[salsa::invoke(crate::ty::type_for_def)]
|
#[salsa::invoke(crate::ty::type_for_def)]
|
||||||
|
|
|
@ -20,7 +20,7 @@ use crate::{Name, AdtDef, type_ref::Mutability, db::HirDatabase, Trait, GenericP
|
||||||
use display::{HirDisplay, HirFormatter};
|
use display::{HirDisplay, HirFormatter};
|
||||||
|
|
||||||
pub(crate) use lower::{TypableDef, type_for_def, type_for_field, callable_item_sig, generic_predicates, generic_defaults};
|
pub(crate) use lower::{TypableDef, type_for_def, type_for_field, callable_item_sig, generic_predicates, generic_defaults};
|
||||||
pub(crate) use infer::{infer, InferenceResult, InferTy};
|
pub(crate) use infer::{infer_query, InferenceResult, InferTy};
|
||||||
pub use lower::CallableDef;
|
pub use lower::CallableDef;
|
||||||
|
|
||||||
/// A type constructor or type name: this might be something like the primitive
|
/// A type constructor or type name: this might be something like the primitive
|
||||||
|
|
|
@ -23,6 +23,7 @@ use ena::unify::{InPlaceUnificationTable, UnifyKey, UnifyValue, NoError};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use ra_arena::map::ArenaMap;
|
use ra_arena::map::ArenaMap;
|
||||||
|
use ra_prof::profile;
|
||||||
use test_utils::tested_by;
|
use test_utils::tested_by;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -51,7 +52,8 @@ use super::{
|
||||||
mod unify;
|
mod unify;
|
||||||
|
|
||||||
/// The entry point of type inference.
|
/// The entry point of type inference.
|
||||||
pub fn infer(db: &impl HirDatabase, def: DefWithBody) -> Arc<InferenceResult> {
|
pub fn infer_query(db: &impl HirDatabase, def: DefWithBody) -> Arc<InferenceResult> {
|
||||||
|
let _p = profile("infer_query");
|
||||||
db.check_canceled();
|
db.check_canceled();
|
||||||
let body = def.body(db);
|
let body = def.body(db);
|
||||||
let resolver = def.resolver(db);
|
let resolver = def.resolver(db);
|
||||||
|
|
|
@ -4,6 +4,7 @@ use std::sync::{Arc, Mutex};
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use chalk_ir::cast::Cast;
|
use chalk_ir::cast::Cast;
|
||||||
|
use ra_prof::profile;
|
||||||
|
|
||||||
use crate::{Crate, Trait, db::HirDatabase, ImplBlock};
|
use crate::{Crate, Trait, db::HirDatabase, ImplBlock};
|
||||||
use super::{TraitRef, Ty, Canonical};
|
use super::{TraitRef, Ty, Canonical};
|
||||||
|
@ -81,6 +82,7 @@ pub(crate) fn implements_query(
|
||||||
krate: Crate,
|
krate: Crate,
|
||||||
trait_ref: Canonical<TraitRef>,
|
trait_ref: Canonical<TraitRef>,
|
||||||
) -> Option<Solution> {
|
) -> Option<Solution> {
|
||||||
|
let _p = profile("implements_query");
|
||||||
let goal: chalk_ir::Goal = trait_ref.value.to_chalk(db).cast();
|
let goal: chalk_ir::Goal = trait_ref.value.to_chalk(db).cast();
|
||||||
debug!("goal: {:?}", goal);
|
debug!("goal: {:?}", goal);
|
||||||
let env = chalk_ir::Environment::new();
|
let env = chalk_ir::Environment::new();
|
||||||
|
|
|
@ -198,6 +198,7 @@ fn print(lvl: usize, msgs: &[Message], out: &mut impl Write) {
|
||||||
if l != lvl {
|
if l != lvl {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
writeln!(out, "{} {:6}ms - {}", indent, dur.as_millis(), msg)
|
writeln!(out, "{} {:6}ms - {}", indent, dur.as_millis(), msg)
|
||||||
.expect("printing profiling info to stdout");
|
.expect("printing profiling info to stdout");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue