fn is_builtin_binop<'tcx>(
lhs: Ty<'tcx>,
rhs: Ty<'tcx>,
category: BinOpCategory,
) -> boolExpand description
Returns true if this is a built-in arithmetic operation (e.g.,
u32 + u32, i16x4 == i16x4) and false if these types would have to be
overloaded to be legal. There are two reasons that we distinguish
builtin operations from overloaded ones (vs trying to drive
everything uniformly through the trait system and intrinsics or
something like that):
- Builtin operations can trivially be evaluated in constants.
- For comparison operators applied to SIMD types the result is
not of type
bool. For example,i16x4 == i16x4yields a type likei16x4. This means that the overloaded traitPartialEqis not applicable.
Reason #2 is the killer. I tried for a while to always use overloaded logic and just check the types in constants/codegen after the fact, and it worked fine, except for SIMD types. -nmatsakis