mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
reformat code
This commit is contained in:
parent
1ef5e14c2c
commit
1064c7513a
2 changed files with 40 additions and 41 deletions
|
@ -997,33 +997,38 @@ pub fn resolve_indexing_op(
|
||||||
struct Valid;
|
struct Valid;
|
||||||
impl Valid {
|
impl Valid {
|
||||||
fn valid_impl(
|
fn valid_impl(
|
||||||
impls: impl Iterator<Item = ImplId>,
|
mut impls: impl Iterator<Item = ImplId>,
|
||||||
table: &mut InferenceTable,
|
table: &mut InferenceTable,
|
||||||
self_ty: &Ty,
|
self_ty: &Ty,
|
||||||
) -> Option<Arc<ImplData>> {
|
) -> Option<Arc<ImplData>> {
|
||||||
let db = table.db;
|
let db = table.db;
|
||||||
for impl_ in impls {
|
loop {
|
||||||
|
let impl_ = impls.next()?;
|
||||||
|
let r = table.run_in_snapshot(|table| {
|
||||||
let impl_data = db.impl_data(impl_);
|
let impl_data = db.impl_data(impl_);
|
||||||
let substs =
|
let substs =
|
||||||
TyBuilder::subst_for_def(db, impl_).fill_with_inference_vars(table).build();
|
TyBuilder::subst_for_def(db, impl_).fill_with_inference_vars(table).build();
|
||||||
let impl_ty =
|
let impl_ty = substs
|
||||||
substs.apply(db.impl_self_ty(impl_).into_value_and_skipped_binders().0, Interner);
|
.apply(db.impl_self_ty(impl_).into_value_and_skipped_binders().0, Interner);
|
||||||
|
|
||||||
if !table.unify(self_ty, &impl_ty) {
|
table
|
||||||
continue;
|
.unify(self_ty, &impl_ty)
|
||||||
}
|
.then(|| {
|
||||||
|
let wh_goals =
|
||||||
let wh_goals = crate::chalk_db::convert_where_clauses(db, impl_.into(), &substs)
|
crate::chalk_db::convert_where_clauses(db, impl_.into(), &substs)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|b| b.into_well_formed_goal(Interner).cast(Interner));
|
.map(|b| b.into_well_formed_goal(Interner).cast(Interner));
|
||||||
|
|
||||||
let goal = crate::Goal::all(Interner, wh_goals);
|
let goal = crate::Goal::all(Interner, wh_goals);
|
||||||
|
|
||||||
if table.try_obligation(goal).is_some() {
|
table.try_obligation(goal).map(|_| impl_data)
|
||||||
return Some(impl_data);
|
})
|
||||||
|
.flatten()
|
||||||
|
});
|
||||||
|
if r.is_some() {
|
||||||
|
break r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_valid_item(
|
fn is_valid_item(
|
||||||
|
|
|
@ -438,29 +438,23 @@ impl NameRefClass {
|
||||||
name_ref: ast::NameRef,
|
name_ref: ast::NameRef,
|
||||||
) -> Option<NameRefClass> {
|
) -> Option<NameRefClass> {
|
||||||
let parent = name_ref.syntax().parent()?;
|
let parent = name_ref.syntax().parent()?;
|
||||||
match_ast! {
|
let expr = match_ast! {
|
||||||
match parent {
|
match parent {
|
||||||
ast::MethodCallExpr(method_call) => {
|
ast::MethodCallExpr(method_call) => {
|
||||||
sema.resolve_impl_method(&ast::Expr::MethodCallExpr(method_call))
|
Some(ast::Expr::MethodCallExpr(method_call))
|
||||||
.map(Definition::Function)
|
|
||||||
.map(NameRefClass::Definition)
|
|
||||||
},
|
},
|
||||||
ast::PathSegment(ps) => {
|
ast::PathSegment(..) => {
|
||||||
ps.syntax().parent().and_then(ast::Path::cast)
|
parent.ancestors()
|
||||||
.map(|p|
|
.find_map(ast::PathExpr::cast)
|
||||||
p.syntax()
|
.map(ast::Expr::PathExpr)
|
||||||
.parent()
|
|
||||||
.and_then(ast::PathExpr::cast)
|
|
||||||
.map(|pe|
|
|
||||||
sema.resolve_impl_method(&ast::Expr::PathExpr(pe))
|
|
||||||
.map(Definition::Function)
|
|
||||||
.map(NameRefClass::Definition)
|
|
||||||
).flatten()
|
|
||||||
).flatten()
|
|
||||||
},
|
},
|
||||||
_=> None
|
_=> None
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
expr.as_ref()
|
||||||
|
.and_then(|e| sema.resolve_impl_method(e))
|
||||||
|
.map(Definition::Function)
|
||||||
|
.map(NameRefClass::Definition)
|
||||||
}
|
}
|
||||||
pub fn classify_lifetime(
|
pub fn classify_lifetime(
|
||||||
sema: &Semantics<RootDatabase>,
|
sema: &Semantics<RootDatabase>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue