avoid an ICE in `ptr_as_ptr` when getting the def_id of a local by y21 · Pull Re...
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
added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label
= 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 |
Collaborator
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 |
added the beta-nominated Nominated for backporting to the compiler in the beta channel. label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
No milestone
Successfully merging this pull request may close these issues.
ICE: attempted .def_id() on invalid res: Local(HirId(DefId(..).63))
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK