Closed TheLostLambda closed 4 months ago
One-liner sanding off a small rough edge I came across: using NamedSource<String> (instead of simply String) severely limits which traits can be derived for the wrapping diagnostic. In my case, I lost the ability to clone my error!
NamedSource<String>
String
I've brought things in line with https://rust-lang.github.io/api-guidelines/interoperability.html#types-eagerly-implement-common-traits-c-common-traits, leaving out Copy, Display, and Default, since those derives are either not possible or don't feel useful. The ones I've added here make sure people can .clone() errors, compare them, sort them, and use them in HashSets / HashMaps.
Copy
Display
Default
.clone()
HashSet
HashMap
I also added Ord derives to the SourceSpan and SourceOffset types for the same reason!
Ord
SourceSpan
SourceOffset
One-liner sanding off a small rough edge I came across: using
NamedSource<String>
(instead of simplyString
) severely limits which traits can be derived for the wrapping diagnostic. In my case, I lost the ability to clone my error!I've brought things in line with https://rust-lang.github.io/api-guidelines/interoperability.html#types-eagerly-implement-common-traits-c-common-traits, leaving out
Copy
,Display
, andDefault
, since those derives are either not possible or don't feel useful. The ones I've added here make sure people can.clone()
errors, compare them, sort them, and use them inHashSet
s /HashMap
s.I also added
Ord
derives to theSourceSpan
andSourceOffset
types for the same reason!