| ... |
... |
@@ -282,8 +282,7 @@ The rendering layer shows a diagnostic's locations in exactly the order given |
|
282
|
282
|
them is the message author's job:
|
|
283
|
283
|
|
|
284
|
284
|
* Pick one real location as the primary span and list the rest as related
|
|
285
|
|
- locations. The primary span need not be the leftmost or smallest location
|
|
286
|
|
- involved; a synthetic span combining several locations is usually worse,
|
|
|
285
|
+ locations. A synthetic span combining several locations is usually worse,
|
|
287
|
286
|
giving a less precise prefix and a larger caret.
|
|
288
|
287
|
|
|
289
|
288
|
* Order the related spans deterministically (e.g. by sorting with
|
| ... |
... |
@@ -291,19 +290,14 @@ them is the message author's job: |
|
291
|
290
|
natural order is not stable across runs. Do not repeat the primary span
|
|
292
|
291
|
among them.
|
|
293
|
292
|
|
|
294
|
|
- * Convention for "duplicate" diagnostics, which report the same entity
|
|
295
|
|
- occurring at several sites (e.g. 'TcRnDuplicateDecls',
|
|
296
|
|
- 'TcRnDuplicateExport'): the primary span is the /last/ occurrence in
|
|
297
|
|
- source order; the earlier occurrences are the related locations, in
|
|
298
|
|
- ascending order. The later occurrence is usually the one just added, and
|
|
299
|
|
- hence the one to act on; clang, rustc and TypeScript likewise point at it
|
|
300
|
|
- ("redefinition of 'x' / note: previous definition is here"). The carets
|
|
301
|
|
- are then /not/ in source order, but read well without labels: first the
|
|
302
|
|
- site to fix, then the prior sites. (Once per-span labels exist (#23414),
|
|
303
|
|
- the renderer could instead display carets in source order, as rustc does —
|
|
304
|
|
- its labels are what make that readable.) Diagnostics whose locations have
|
|
305
|
|
- a different asymmetry (a definition site versus a use site, say) pick
|
|
306
|
|
- their primary span on their own logic.
|
|
|
293
|
+Different diagnostics may want to pick and order the spans in different ways.
|
|
|
294
|
+For "duplicate" diagnostics, which report the same entity occurring at several
|
|
|
295
|
+sites (e.g. 'TcRnDuplicateDecls', 'TcRnDuplicateExport'), we currently use the
|
|
|
296
|
+/last/ occurrence in source order as the primary span, with the earlier
|
|
|
297
|
+occurrences as related locations in ascending order: the last occurrence is
|
|
|
298
|
+likely the one just added, and hence the most actionable; clang, rustc and
|
|
|
299
|
+TypeScript likewise point at it ("redefinition of 'x' / note: previous
|
|
|
300
|
+definition is here").
|
|
307
|
301
|
-}
|
|
308
|
302
|
|
|
309
|
303
|
-- | A class identifying a diagnostic.
|