You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// If the token is a comparison operator (!=, <, <=, >, >=) that resolves to a default trait method, navigate to the corresponding primary method (eq for ne, partial_cmp for the others).
273
+
fnfind_definition_for_comparison_operators(
274
+
sema:&Semantics<'_,RootDatabase>,
275
+
original_token:&SyntaxToken,
276
+
) -> Option<Vec<NavigationTarget>>{
277
+
let bin_expr = ast::BinExpr::cast(original_token.parent()?)?;
278
+
279
+
let f = sema.resolve_bin_expr(&bin_expr)?;
280
+
let assoc = f.as_assoc_item(sema.db)?;
281
+
282
+
let lhs_type = sema.type_of_expr(&bin_expr.lhs()?)?.original;
283
+
let rhs_type = sema.type_of_expr(&bin_expr.rhs()?)?.original;
284
+
285
+
let t = match assoc.container(sema.db){
286
+
hir::AssocItemContainer::Trait(t) => t,
287
+
hir::AssocItemContainer::Impl(_) => returnNone,// Already implemented by the type
288
+
};
289
+
290
+
let fn_name = f.name(sema.db);
291
+
let fn_name_str = fn_name.as_str();
292
+
293
+
let trait_name = t.name(sema.db);
294
+
let trait_name_str = trait_name.as_str();
295
+
296
+
let(target_fn_name, expected_trait) = match fn_name_str {
0 commit comments