Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Tracking issue for RFC 2091: Implicit caller location #47809
This is a tracking issue for the RFC "Implicit caller location" (rust-lang/rfcs#2091).
This refers to
IMO the easiest way to implement this involves no procedural macros or MIR passes.
To explain, the shim (which we may already have some variation of) would "just" do the direct call to the function, which would pass the location of the shim, the same as the original function.
@kennytm had a prototype implementation:
The prototype implementation works like this (note that
Oh, I don't recall exactly what happened here.
For making static calls do something different,
But the rest of the pieces, I don't know off the top of my head where they happen.
#54183 added a virtual-call-only shim, which is close to what this needs, so that can be used for inspiration, but here we need both reification to
We could start by disallowing reification/virtualization of such functions, and only implement the static dispatch ABI changes.
I don't expect this attribute to be usable on "real" functions without us implementing reification.
But for implementing this, I think one good strategy would be:
Not supporting trait methods
For now, I don't think there is sufficient reason to support implicit caller location on trait methods, and supporting that is fairly complicated. So as @aturon said on the head PR, just don't do it.
Step 0: dealing with the attribute.
You should make sure that the
I'm not particularly sure what's the exact way to do this, but you can maybe find some PR that implemented an attribute for that, or ask on Discord.
Make sure to add tests.
Step 1: have reified methods and direct calls go to different LLVM functions
At this stage, I won't even add a parameter, just have the call-sites go through different paths.
So the virtual-call-only shim at #54183 is a good model for how things need to be done. You'll need to add a
Step 2: Add a location parameter
Step 2.0: add a location parameter to the MIR of