Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/lang_items.rs')
-rw-r--r--crates/hir-ty/src/lang_items.rs54
1 files changed, 27 insertions, 27 deletions
diff --git a/crates/hir-ty/src/lang_items.rs b/crates/hir-ty/src/lang_items.rs
index 85ed46b963..69ff03eb49 100644
--- a/crates/hir-ty/src/lang_items.rs
+++ b/crates/hir-ty/src/lang_items.rs
@@ -2,6 +2,7 @@
use hir_def::{data::adt::StructFlags, lang_item::LangItem, AdtId};
use hir_expand::name::Name;
+use intern::sym;
use crate::db::HirDatabase;
@@ -16,48 +17,47 @@ pub fn is_unsafe_cell(db: &dyn HirDatabase, adt: AdtId) -> bool {
}
pub fn lang_items_for_bin_op(op: syntax::ast::BinaryOp) -> Option<(Name, LangItem)> {
- 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], LangItem::Add),
- ArithOp::Mul => (name![mul], LangItem::Mul),
- ArithOp::Sub => (name![sub], LangItem::Sub),
- ArithOp::Div => (name![div], LangItem::Div),
- ArithOp::Rem => (name![rem], LangItem::Rem),
- ArithOp::Shl => (name![shl], LangItem::Shl),
- ArithOp::Shr => (name![shr], LangItem::Shr),
- ArithOp::BitXor => (name![bitxor], LangItem::BitXor),
- ArithOp::BitOr => (name![bitor], LangItem::BitOr),
- ArithOp::BitAnd => (name![bitand], LangItem::BitAnd),
+ ArithOp::Add => (Name::new_symbol_root(sym::add), LangItem::Add),
+ ArithOp::Mul => (Name::new_symbol_root(sym::mul), LangItem::Mul),
+ ArithOp::Sub => (Name::new_symbol_root(sym::sub), LangItem::Sub),
+ ArithOp::Div => (Name::new_symbol_root(sym::div), LangItem::Div),
+ ArithOp::Rem => (Name::new_symbol_root(sym::rem), LangItem::Rem),
+ ArithOp::Shl => (Name::new_symbol_root(sym::shl), LangItem::Shl),
+ ArithOp::Shr => (Name::new_symbol_root(sym::shr), LangItem::Shr),
+ ArithOp::BitXor => (Name::new_symbol_root(sym::bitxor), LangItem::BitXor),
+ ArithOp::BitOr => (Name::new_symbol_root(sym::bitor), LangItem::BitOr),
+ ArithOp::BitAnd => (Name::new_symbol_root(sym::bitand), LangItem::BitAnd),
},
BinaryOp::Assignment { op: Some(aop) } => match aop {
- ArithOp::Add => (name![add_assign], LangItem::AddAssign),
- ArithOp::Mul => (name![mul_assign], LangItem::MulAssign),
- ArithOp::Sub => (name![sub_assign], LangItem::SubAssign),
- ArithOp::Div => (name![div_assign], LangItem::DivAssign),
- ArithOp::Rem => (name![rem_assign], LangItem::RemAssign),
- ArithOp::Shl => (name![shl_assign], LangItem::ShlAssign),
- ArithOp::Shr => (name![shr_assign], LangItem::ShrAssign),
- ArithOp::BitXor => (name![bitxor_assign], LangItem::BitXorAssign),
- ArithOp::BitOr => (name![bitor_assign], LangItem::BitOrAssign),
- ArithOp::BitAnd => (name![bitand_assign], LangItem::BitAndAssign),
+ ArithOp::Add => (Name::new_symbol_root(sym::add_assign), LangItem::AddAssign),
+ ArithOp::Mul => (Name::new_symbol_root(sym::mul_assign), LangItem::MulAssign),
+ ArithOp::Sub => (Name::new_symbol_root(sym::sub_assign), LangItem::SubAssign),
+ ArithOp::Div => (Name::new_symbol_root(sym::div_assign), LangItem::DivAssign),
+ ArithOp::Rem => (Name::new_symbol_root(sym::rem_assign), LangItem::RemAssign),
+ ArithOp::Shl => (Name::new_symbol_root(sym::shl_assign), LangItem::ShlAssign),
+ ArithOp::Shr => (Name::new_symbol_root(sym::shr_assign), LangItem::ShrAssign),
+ ArithOp::BitXor => (Name::new_symbol_root(sym::bitxor_assign), LangItem::BitXorAssign),
+ ArithOp::BitOr => (Name::new_symbol_root(sym::bitor_assign), LangItem::BitOrAssign),
+ ArithOp::BitAnd => (Name::new_symbol_root(sym::bitand_assign), LangItem::BitAndAssign),
},
BinaryOp::CmpOp(cop) => match cop {
- CmpOp::Eq { negated: false } => (name![eq], LangItem::PartialEq),
- CmpOp::Eq { negated: true } => (name![ne], LangItem::PartialEq),
+ CmpOp::Eq { negated: false } => (Name::new_symbol_root(sym::eq), LangItem::PartialEq),
+ CmpOp::Eq { negated: true } => (Name::new_symbol_root(sym::ne), LangItem::PartialEq),
CmpOp::Ord { ordering: Ordering::Less, strict: false } => {
- (name![le], LangItem::PartialOrd)
+ (Name::new_symbol_root(sym::le), LangItem::PartialOrd)
}
CmpOp::Ord { ordering: Ordering::Less, strict: true } => {
- (name![lt], LangItem::PartialOrd)
+ (Name::new_symbol_root(sym::lt), LangItem::PartialOrd)
}
CmpOp::Ord { ordering: Ordering::Greater, strict: false } => {
- (name![ge], LangItem::PartialOrd)
+ (Name::new_symbol_root(sym::ge), LangItem::PartialOrd)
}
CmpOp::Ord { ordering: Ordering::Greater, strict: true } => {
- (name![gt], LangItem::PartialOrd)
+ (Name::new_symbol_root(sym::gt), LangItem::PartialOrd)
}
},
BinaryOp::Assignment { op: None } => return None,