Use hasRank instead of comparing rank to -1

--

PiperOrigin-RevId: 250598252
diff --git a/lib/StandardOps/Ops.cpp b/lib/StandardOps/Ops.cpp
index 94f5a67..66a1226 100644
--- a/lib/StandardOps/Ops.cpp
+++ b/lib/StandardOps/Ops.cpp
@@ -1600,8 +1600,8 @@
       return op.emitOpError("index to extract_element must have 'index' type");
 
   // Verify the # indices match if we have a ranked type.
-  auto aggregateRank = aggregateType.getRank();
-  if (aggregateRank != -1 && aggregateRank != op.getNumOperands() - 1)
+  if (aggregateType.hasRank() &&
+      aggregateType.getRank() != op.getNumOperands() - 1)
     return op.emitOpError("incorrect number of indices for extract_element");
 
   return success();