3

avoid an ICE in `ptr_as_ptr` when getting the def_id of a local by y21 · Pull Re...

 1 week ago
source link: https://github.com/rust-lang/rust-clippy/pull/12617
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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

Merged

Conversation

Member

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

Bromeon reacted with heart emojiBromeon reacted with rocket emoji

Collaborator

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

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

Member

Author

the duplicate diagnostic issue here is tracked over at #12379

Member

Nice, thanks!

@bors r+

Could be good to rename Res::def_id as expect_def_id

y21 reacted with thumbs up emoji

Collaborator

📌 Commit e575f05 has been approved by Alexendoo

It is now in the queue for this repository.

Collaborator

⌛ Testing commit e575f05 with merge f9f854f...

Collaborator

bors

merged commit f9f854f into

rust-lang:master

Apr 2, 2024

5 checks passed

Member

Author

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

added the beta-nominated Nominated for backporting to the compiler in the beta channel. label

Apr 3, 2024

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

Reviewers

Alexendoo

Alexendoo approved these changes
Assignees

Jarcho

Labels
beta-nominated Nominated for backporting to the compiler in the beta channel. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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

5 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK