-
Notifications
You must be signed in to change notification settings - Fork 11
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
[Bug]: Maker panics if the trait from std
is requested via ctx.ast().item()
#301
Comments
std
is requested via ctx.ast().item()
The problem occurs because the code tries to look up the definition of the item in HIR, but that item comes from a foreign crate. When the
The type of the ID that is transmuted into ItemId is rustc_span::def_id::DefId . But when the ctx.ast().item() is called the ItemId is converted into rustc_hir::hir::ItemId . You may notice that the method in the snippet below doesn't use the layout.krate field at all. I guess it assumes that this method is always called with local items (of the current crate).marker/marker_rustc_driver/src/conversion/rustc/common.rs Lines 73 to 82 in 73835de
So this results in an invalid I'm not sure what the best solution here should be. Maybe the But how could users query the info about which trait is implemented? Maybe if there was at least the path to the implemented trait in the |
Ahh, I think the actual problem is the type. Thinking about it, this will not resolve all issues though 🤔 Users can still retrieve Rustc splits these IDs into a general |
Summary
I've been trying to implement a lint that prohibits implementing
Into/TryInto
traits directly and I've run into multiple issues with it. This is one of them. However, I suppose even if this is fixedctx.ast().item()
will returnNone
because the trait is outside of the compiled crate? Then how could I check which trait theimpl
item tries to implement?Btw. if I output the impl item of the
Into
trait impl specified in the reproducer below I get this. You can see that there is no implemented trait identifier anywhere in the data. This is bummerDetails
Reproducer
cargo marker
Version
Logs
The text was updated successfully, but these errors were encountered: