-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Remove FakeDefId::expect_local()
#85093
Conversation
Some changes occurred in intra-doc-links. cc @jyn514 |
r? @jyn514 (rust-highfive has picked a reviewer for you, use r? to override) |
r? @GuillaumeGomez (since Joshua's on break) |
} | ||
|
||
#[inline] | ||
#[track_caller] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: I did not remove #[inline]
. It's just a quirk of the diff that it looks that way.
This comment has been minimized.
This comment has been minimized.
This function returned a fake `DefIndex`, with no indication that it was fake, when it was provided with a `FakeDefId::Fake`. Every use of the function uses the returned `DefIndex` in a call to `tcx.local_def_id_to_hir_id()`, which I'm pretty sure would panic if it were given a fake `DefIndex`. I removed the function and replaced all calls to it with a call to `expect_real()` followed by `DefId::expect_local()` (that's a function on the *real* `DefId`).
Now, in the case that the function is not inlined, the panic location will be the caller's location, which is more helpful since the panic is not `expect_real()`'s fault.
b2d867b
to
4b7c8b0
Compare
Thanks! @bors: r+ |
📌 Commit 4b7c8b0 has been approved by |
☀️ Test successful - checks-actions |
This function returned a fake
DefIndex
, with no indication that it wasfake, when it was provided with a
FakeDefId::Fake
. Every use of thefunction uses the returned
DefIndex
in a call totcx.local_def_id_to_hir_id()
, which I'm pretty sure would panic if itwere given a fake
DefIndex
.I removed the function and replaced all calls to it with a call to
expect_real()
followed byDefId::expect_local()
(that's a functionon the real
DefId
).