Skip to content

errors: dedup same compiler errors, present them in deterministic order - #413

Open
KyrylR wants to merge 2 commits into
masterfrom
feat/multi-error-diagnostic-policy
Open

errors: dedup same compiler errors, present them in deterministic order#413
KyrylR wants to merge 2 commits into
masterfrom
feat/multi-error-diagnostic-policy

Conversation

@KyrylR

@KyrylR KyrylR commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

The PR is meant to make the reported order of errors deterministic and deduplicated to improve UX

@KyrylR
KyrylR requested a review from LesterEvSe September 4, 2026 13:18
@KyrylR KyrylR self-assigned this Sep 4, 2026
@KyrylR
KyrylR force-pushed the feat/multi-error-diagnostic-policy branch from c34d7a2 to 5c88010 Compare September 4, 2026 13:24
@KyrylR
KyrylR marked this pull request as ready for review September 4, 2026 13:25
@KyrylR
KyrylR requested a review from delta1 as a code owner September 4, 2026 13:25
Comment thread src/error.rs
#[derive(Debug, Clone, Default)]
struct DiagnosticIndex {
identities: HashSet<String>,
source_order: HashMap<usize, usize>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case BTreeMap will be more optimized than HashMap

Suggested change
source_order: HashMap<usize, usize>,
source_order: BTreeMap<usize, usize>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm skeptical. We can't make use of the BTreeMap's ordering since the actual presentation order depends on source_rank which uses data outside of the map. So it's a question of whether tree-rebalancing operations are cheaper than siphash operations.

If we are really concerned we can use a custom hasher which just casts the usizes to u64s, and that will definitely be faster than either approach.

In practice I think it doesn't matter at all, and HashMap (a) has a more full-featured API, and (b) communicates to the reader of the code that the order doesn't matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants