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

avoid an ICE in ptr_as_ptr when getting the def_id of a local #12617

Merged
merged 1 commit into from Apr 2, 2024

Conversation

y21
Copy link
Member

@y21 y21 commented Apr 2, 2024

Fixes #12616

Res::def_id can panic, so avoid calling it in favor of opt_def_id, so we can gracefully handle resolutions that don't have a DefId (e.g. local variables) and get a false negative in the worst case, rather than an ICE

changelog: Fix ICE in [ptr_as_ptr] when the cast expression is a function call to a local variable

@rustbot
Copy link
Collaborator

rustbot commented Apr 2, 2024

r? @Jarcho

rustbot has assigned @Jarcho.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 2, 2024
= note: `-D clippy::ptr-as-ptr` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::ptr_as_ptr)]`

error: `as` casting between raw pointers without changing its mutability
Copy link
Member Author

Choose a reason for hiding this comment

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

the duplicate diagnostic issue here is tracked over at #12379

@Alexendoo
Copy link
Member

Nice, thanks!

@bors r+

Could be good to rename Res::def_id as expect_def_id

@bors
Copy link
Collaborator

bors commented Apr 2, 2024

📌 Commit e575f05 has been approved by Alexendoo

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Apr 2, 2024

⌛ Testing commit e575f05 with merge f9f854f...

@bors
Copy link
Collaborator

bors commented Apr 2, 2024

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

@bors bors merged commit f9f854f into rust-lang:master Apr 2, 2024
5 checks passed
@y21
Copy link
Member Author

y21 commented Apr 3, 2024

Not sure if it deserves beta backporting considering it's been on beta for a while and even hit stable. I'm honestly surprised we didn't get a report for that ICE earlier, this seems like a somewhat easy ICE to run into? Can't hurt to nominate I guess

@y21 y21 added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 3, 2024
@flip1995 flip1995 added 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 Apr 25, 2024
@flip1995
Copy link
Member

rust-lang/rust#124369

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 27, 2024
…ulacrum

[beta] Clippy backport

r? `@Mark-Simulacrum`

Backports:

- rust-lang/rust-clippy#12486
- rust-lang/rust-clippy#12572
- rust-lang/rust-clippy#12508
- rust-lang/rust-clippy#12617

The first one is a bit bigger as usual for a backport. But it fixes a major issue with this lint that we overlooked. So I think this is worth it. After that was merged into nightly, there were no new issues opened about this lint, so IMO this is safe to backport to `beta` and put into stable.
@xFrednet xFrednet removed the beta-accepted Accepted for backporting to the compiler in the beta channel. label Apr 29, 2024
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.

ICE: attempted .def_id() on invalid res: Local(HirId(DefId(..).63))
7 participants