Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[missing_fields_in_debug]: make sure self type is an adt #11069

Merged
merged 1 commit into from Jul 2, 2023

Conversation

y21
Copy link
Member

@y21 y21 commented Jul 2, 2023

Fixes #11063, another ICE that can only happen in core.

This lint needs the DefId of the implementor to get its fields, but that ICEs if the implementor does not have a DefId (as is the case with primitive types, e.g. impl Debug for bool), which is where this ICE comes from.

This PR changes the check I added in #10897 to be more... robust against Debug implementations we don't want to lint.
Instead of just checking if the self type is a type parameter and "special casing" one specific case we don't want to lint, we should probably rather just check that the self type is either a struct, an enum or a union and only then continue.
That prevents weird edge cases like this one that can only happen in core.

Again, I don't know if it's even possible to add a test case for this since one cannot implement Debug for primitive types outside of the crate that defined Debug (core).
I did make sure that this PR no longer ICEs on impl<T> Debug for T and impl Debug for bool.
Maybe writing such a test is possible with #![no_core] and then re-defining the Debug trait or something like that...?

changelog: [missing_fields_in_debug]: make sure self type is an adt (fixes an ICE in core)

r? @Alexendoo (reviewed the last PRs for this lint)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 2, 2023
@Alexendoo
Copy link
Member

We might be able to write a no_core test, but I think it's reasonable to leave it out since this only effects rustc

Thanks again! @bors r+

@bors
Copy link
Collaborator

bors commented Jul 2, 2023

📌 Commit 555ceb8 has been approved by Alexendoo

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jul 2, 2023

⌛ Testing commit 555ceb8 with merge 4752466...

@bors
Copy link
Collaborator

bors commented Jul 2, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Alexendoo
Pushing 4752466 to master...

@bors bors merged commit 4752466 into rust-lang:master Jul 2, 2023
5 checks passed
@flip1995 flip1995 added beta-nominated Nominated for backporting to the compiler in the beta channel. beta-accepted Accepted for backporting to the compiler in the beta channel. and removed beta-nominated Nominated for backporting to the compiler in the beta channel. labels Aug 14, 2023
@flip1995
Copy link
Member

rust-lang/rust#114937

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 17, 2023
…k-Simulacrum

[beta] Clippy backports for ICE fixes

This backports PRs to beta, that fix ICEs, some lint grouping and FP fixes. Namely:

- rust-lang/rust-clippy#11191
- rust-lang/rust-clippy#11172
- rust-lang/rust-clippy#11130
- rust-lang/rust-clippy#11106
- rust-lang/rust-clippy#11104
- rust-lang/rust-clippy#11077
- rust-lang/rust-clippy#11070 (This PR is not synced to the Rust repo yet, but I will open a separate PR to get it into `master`, before beta is branched: rust-lang#114938)
- rust-lang/rust-clippy#11069

Kind of a big backport, but most of it is tests.

r? `@Mark-Simulacrum`

cc `@Manishearth`
@xFrednet xFrednet removed the beta-accepted Accepted for backporting to the compiler in the beta channel. label Aug 18, 2023
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.

missing_fields_in_debug: attempted .def_id() on invalid res: PrimTy(Bool)
6 participants