Skip to content

feat(diagnostics): split TraitImplIncorrectSafety into distinct rustc errors#22463

Open
ada4a wants to merge 2 commits into
rust-lang:masterfrom
ada4a:diag-split-trait-impl-incorrect-safety
Open

feat(diagnostics): split TraitImplIncorrectSafety into distinct rustc errors#22463
ada4a wants to merge 2 commits into
rust-lang:masterfrom
ada4a:diag-split-trait-impl-incorrect-safety

Conversation

@ada4a
Copy link
Copy Markdown
Contributor

@ada4a ada4a commented May 26, 2026

No description provided.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 26, 2026
Copy link
Copy Markdown
Contributor Author

@ada4a ada4a left a comment

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

should I split the file into 5 as well?

Comment thread crates/hir/src/lib.rs
@ada4a ada4a force-pushed the diag-split-trait-impl-incorrect-safety branch from 9317253 to 2195500 Compare May 26, 2026 15:06
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 left a comment

Choose a reason for hiding this comment

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

I feel like this should remain one error but with an enum to distinguish the kind.

View changes since this review

@ada4a
Copy link
Copy Markdown
Contributor Author

ada4a commented May 29, 2026

If I make it just an enum, then the fields file_id and impl_ would be repeated everywhere, which I find unfortunate. What do you think about doing something like this?

struct ImplIncorrectSafety { // since this actually also handles inherent impls
    file_id: HirFileId,
    impl_: AstPtr<ast::Impl>,
    kind: ImplIncorrectSafetyKind,
}

enum ImplIncorrectSafetyKind {
    UnsafeImplOfSafeTrait { trait_: Trait }
    /* ..other variants */
}

@ada4a
Copy link
Copy Markdown
Contributor Author

ada4a commented May 29, 2026

What do you think about doing something like this?

I've gone ahead and implemented that, turned out pretty well imo. I've left it as a separate commit for now -- if you like the approach, please let me know before merging so that I can squash the commits

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants