diff --git a/infer/src/IR/Location.re b/infer/src/IR/Location.re
index a5da5b0ef..1bc9bc4cb 100644
--- a/infer/src/IR/Location.re
+++ b/infer/src/IR/Location.re
@@ -18,16 +18,10 @@ type t = {
   line: int, /** The line number. -1 means "do not know" */
   col: int, /** The column number. -1 means "do not know" */
   file: DB.source_file /** The name of the source file */
-};
+}
+[@@deriving compare];
 
-let compare loc1 loc2 => {
-  let n = int_compare loc1.line loc2.line;
-  if (n != 0) {
-    n
-  } else {
-    DB.compare_source_file loc1.file loc2.file
-  }
-};
+let equal loc1 loc2 => compare loc1 loc2 == 0;
 
 
 /** Dump a location */
@@ -37,8 +31,6 @@ let d (loc: t) => L.add_print_action (L.PTloc, Obj.repr loc);
 /** Dummy location */
 let dummy = {line: (-1), col: (-1), file: DB.source_file_empty};
 
-let equal loc1 loc2 => compare loc1 loc2 == 0;
-
 
 /** Pretty print a location */
 let pp f (loc: t) => F.fprintf f "[line %d]" loc.line;
diff --git a/infer/src/IR/Location.rei b/infer/src/IR/Location.rei
index 560461f60..12a996ea4 100644
--- a/infer/src/IR/Location.rei
+++ b/infer/src/IR/Location.rei
@@ -13,10 +13,11 @@ open! Utils;
 type t = {
   line: int, /** The line number. -1 means "do not know" */
   col: int, /** The column number. -1 means "do not know" */
-  file: DB.source_file, /** The name of the source file */
-};
+  file: DB.source_file /** The name of the source file */
+}
+[@@deriving compare];
 
-let compare: t => t => int;
+let equal: t => t => bool;
 
 
 /** Dump a location. */
@@ -26,8 +27,6 @@ let d: t => unit;
 /** Dummy location */
 let dummy: t;
 
-let equal: t => t => bool;
-
 
 /** Pretty print a location. */
 let pp: Format.formatter => t => unit;