-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
[MIR] Implement translation of references to various items #29907
Conversation
Nits addressed. |
53aa6b3
to
6bb92a5
Compare
substs: &'tcx Substs<'tcx>, | ||
did: DefId) | ||
-> OperandRef<'tcx> { | ||
match ty.sty { |
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.
Checking the type of the item like this feels like a horrible hack. Perhaps we should just be including more information in the Literal
MIR node? Or a Def
(as I think you suggested on IRC)? Also, I haven't gone digging into trans, but is this code here a kind if port of code that exists elsewhere?
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.
Also, I haven't gone digging into trans, but is this code here a kind if port of code that exists elsewhere?
Nope. The trans_fn_ref
below is a simplified “port”, but I haven’t found anything in old trans which would do matching like this (AFAICT it gathers such information from various other sources, esp. HIR).
Perhaps we should just be including more information in the Literal MIR node? Or a Def (as I think you suggested on IRC)?
This approach makes it pretty easy to match whether enum/struct references should be translated as functions or not. I’m not sure other methods would allow checking for this as easily.
I’m willing to explore for better methods to match correct path, but won’t be able to dedicate much time for that in coming weeks.
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.
Okay, I’m convinced now this is not only a hack but is also wrong (e.g. it will panic compiling a function that’s defined in impl
block).
However, I won’t be able to get back to it for at least a week and a half. I’ll go ahead and mark the issue as [WIP] and hopefully work on it later.
☔ The latest upstream changes (presumably #29886) made this pull request unmergeable. Please resolve the merge conflicts. |
9a2607e
to
f013dd2
Compare
☔ The latest upstream changes (presumably #29534) made this pull request unmergeable. Please resolve the merge conflicts. |
a3485cc
to
250d9e7
Compare
☔ The latest upstream changes (presumably #25570) made this pull request unmergeable. Please resolve the merge conflicts. |
250d9e7
to
3673ee5
Compare
I changed my approach to storing relevant kind inside I’m not entirely sure I’m using the correct substs in all the correct locations, but things seem to be working; something to be reviewed more carefully. |
☔ The latest upstream changes (presumably #30301) made this pull request unmergeable. Please resolve the merge conflicts. |
f02c51a
to
09033dc
Compare
09033dc
to
f95aae4
Compare
(I hate how github removed all the comments on force push :() nagisa@ece05d3 and nagisa@5fb2edc were the two commits that had comments. |
f95aae4
to
7dd9579
Compare
📌 Commit 7dd9579 has been approved by |
Still will not translate references to items like `X` or `Y::V` where ``` struct X; enum Y { V } ``` but I must go work on university things so I’m PRing what I have. r? @nikomatsakis
Still will not translate references to items like
X
orY::V
wherebut I must go work on university things so I’m PRing what I have.
r? @nikomatsakis