#[non_exhaustive]pub enum OpSpec {
Show 16 variants
Op(OpKind),
OpWith(Op),
Compound(OpKind),
CompoundWith(Op),
Assign,
RefAssign,
Identity,
Borrow(BorrowKind),
Deref,
Await,
Template(TemplateId),
Extern(NameRef),
Intrinsic(NameRef),
CompoundExtern(NameRef),
CompoundIntrinsic(NameRef),
CompoundTemplate(TemplateId),
}Expand description
What an operator token lowers to.
§Examples
use hir_lang::{Op, OpKind, Overflow};
use lower_lang::OpSpec;
let plus = OpSpec::Op(OpKind::Add); // language policy
let wrapping = OpSpec::OpWith(Op::new(OpKind::Add).with_overflow(Overflow::Wrap));
let plus_eq = OpSpec::Compound(OpKind::Add); // `+=`
assert_ne!(plus, wrapping);
assert_ne!(plus, plus_eq);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Op(OpKind)
An intrinsic op with the language’s policies (LangPolicy).
OpWith(Op)
An intrinsic op with exactly this policy ([semantics.ops] "/" = { op = "div", zero = "trap" }).
Compound(OpKind)
Compound assignment (+=) with the language’s policies.
CompoundWith(Op)
Compound assignment with exactly this policy.
Assign
Plain assignment (= as an operator).
RefAssign
Reference assignment (=&).
Identity
The operand itself (unary +).
Borrow(BorrowKind)
&x / &mut x as a prefix operator.
Deref
*x as a prefix operator.
Await
await x (prefix) or x.await (postfix).
Template(TemplateId)
A template whose expression holes receive the operands, in order
(&&, ||, ??, x++).
Extern(NameRef)
A call of a host function with the operands as arguments (Mox .
string concatenation).
Intrinsic(NameRef)
A named backend intrinsic applied to the operands.
CompoundExtern(NameRef)
Compound assignment through a host function (.= as mox.concat):
let_place p = target in p = f(p, value), so the place’s operands are
evaluated once (HIR LetPlace).
CompoundIntrinsic(NameRef)
Compound assignment through a named intrinsic (**= as mox.pow),
lowered like CompoundExtern.
CompoundTemplate(TemplateId)
Compound assignment through a template with exactly two expression
holes, which receive the place alias and the value (??= through
coalesce): let_place p = target in p = template(p, value).