Skip to content

libs: Return dummy location in Location::caller#231

Merged
RyanGlScott merged 1 commit intomasterfrom
T227-caller-dummy-location
Feb 2, 2026
Merged

libs: Return dummy location in Location::caller#231
RyanGlScott merged 1 commit intomasterfrom
T227-caller-dummy-location

Conversation

@RyanGlScott
Copy link
Contributor

Fixes #227.

@RyanGlScott RyanGlScott self-assigned this Jan 22, 2026
@RyanGlScott RyanGlScott force-pushed the T227-caller-dummy-location branch from f03d9e7 to 13b449b Compare January 22, 2026 12:56
@samcowger
Copy link
Contributor

Out of curiosity, why not override Location::caller or intrinsics::caller_location in crucible-mir?

@RyanGlScott
Copy link
Contributor Author

We could override intrinsics::caller_location in crucible-mir, I suppose. The main drawback of doing so is that it we'd have to fill out the fields of the Location struct using the crucible-mir API, which would be quite a bit more verbose than writing the same code directly in Rust. Doable, but perhaps a bit tiresome. Moreover, we'd need to ensure that we update this code any time the definition of Location changes.

Given this, I decided to go with the approach of patching Location::caller instead. This function is the only place in all of the standard libraries where intrinsics::caller_location is invoked, so patching Location::caller seemed to give the same benefits with less code. It's possible that there might be another crate in the wild that calls intrinsics::caller_location directly, but I haven't ran into one yet.

@RyanGlScott RyanGlScott added the standard libraries Issues involving mir-json's modified versions of the Rust standard libraries label Jan 26, 2026
@RyanGlScott RyanGlScott force-pushed the T227-caller-dummy-location branch from 13b449b to 313ea2f Compare February 2, 2026 18:09
@RyanGlScott RyanGlScott merged commit 5553e60 into master Feb 2, 2026
5 checks passed
@RyanGlScott RyanGlScott deleted the T227-caller-dummy-location branch February 2, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

standard libraries Issues involving mir-json's modified versions of the Rust standard libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libs: Patch out Location::caller to return a dummy location

3 participants