+-- the SrcSpan that pprNameProvenance prints out depends on whether
+-- the Name is defined locally or not: for a local definition the
+-- definition site is used, otherwise the location of the import
+-- declaration. We want to sort the export locations in
+-- exportClashErr by this SrcSpan, we need to extract it:
+greSrcSpan :: GlobalRdrElt -> SrcSpan
+greSrcSpan gre
+ | Imported (is:_) <- gre_prov gre = is_dloc (is_decl is)
+ | otherwise = name_span
+ where
+ name_span = nameSrcSpan (gre_name gre)
+