mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
⬆️ rust-analyzer
This commit is contained in:
parent
9d2cb42a41
commit
22c8c9c401
66 changed files with 1636 additions and 281 deletions
|
@ -336,7 +336,7 @@ impl InherentImpls {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn inherent_impl_crates_query(
|
||||
pub(crate) fn inherent_impl_crates_query(
|
||||
db: &dyn HirDatabase,
|
||||
krate: CrateId,
|
||||
fp: TyFingerprint,
|
||||
|
@ -419,6 +419,55 @@ pub fn def_crates(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn lang_names_for_bin_op(op: syntax::ast::BinaryOp) -> Option<(Name, Name)> {
|
||||
use hir_expand::name;
|
||||
use syntax::ast::{ArithOp, BinaryOp, CmpOp, Ordering};
|
||||
Some(match op {
|
||||
BinaryOp::LogicOp(_) => return None,
|
||||
BinaryOp::ArithOp(aop) => match aop {
|
||||
ArithOp::Add => (name!(add), name!(add)),
|
||||
ArithOp::Mul => (name!(mul), name!(mul)),
|
||||
ArithOp::Sub => (name!(sub), name!(sub)),
|
||||
ArithOp::Div => (name!(div), name!(div)),
|
||||
ArithOp::Rem => (name!(rem), name!(rem)),
|
||||
ArithOp::Shl => (name!(shl), name!(shl)),
|
||||
ArithOp::Shr => (name!(shr), name!(shr)),
|
||||
ArithOp::BitXor => (name!(bitxor), name!(bitxor)),
|
||||
ArithOp::BitOr => (name!(bitor), name!(bitor)),
|
||||
ArithOp::BitAnd => (name!(bitand), name!(bitand)),
|
||||
},
|
||||
BinaryOp::Assignment { op: Some(aop) } => match aop {
|
||||
ArithOp::Add => (name!(add_assign), name!(add_assign)),
|
||||
ArithOp::Mul => (name!(mul_assign), name!(mul_assign)),
|
||||
ArithOp::Sub => (name!(sub_assign), name!(sub_assign)),
|
||||
ArithOp::Div => (name!(div_assign), name!(div_assign)),
|
||||
ArithOp::Rem => (name!(rem_assign), name!(rem_assign)),
|
||||
ArithOp::Shl => (name!(shl_assign), name!(shl_assign)),
|
||||
ArithOp::Shr => (name!(shr_assign), name!(shr_assign)),
|
||||
ArithOp::BitXor => (name!(bitxor_assign), name!(bitxor_assign)),
|
||||
ArithOp::BitOr => (name!(bitor_assign), name!(bitor_assign)),
|
||||
ArithOp::BitAnd => (name!(bitand_assign), name!(bitand_assign)),
|
||||
},
|
||||
BinaryOp::CmpOp(cop) => match cop {
|
||||
CmpOp::Eq { negated: false } => (name!(eq), name!(eq)),
|
||||
CmpOp::Eq { negated: true } => (name!(ne), name!(eq)),
|
||||
CmpOp::Ord { ordering: Ordering::Less, strict: false } => {
|
||||
(name!(le), name!(partial_ord))
|
||||
}
|
||||
CmpOp::Ord { ordering: Ordering::Less, strict: true } => {
|
||||
(name!(lt), name!(partial_ord))
|
||||
}
|
||||
CmpOp::Ord { ordering: Ordering::Greater, strict: false } => {
|
||||
(name!(ge), name!(partial_ord))
|
||||
}
|
||||
CmpOp::Ord { ordering: Ordering::Greater, strict: true } => {
|
||||
(name!(gt), name!(partial_ord))
|
||||
}
|
||||
},
|
||||
BinaryOp::Assignment { op: None } => return None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Look up the method with the given name.
|
||||
pub(crate) fn lookup_method(
|
||||
ty: &Canonical<Ty>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue