Skip to content
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

Merged
merged 4 commits into from
Dec 18, 2015

Conversation

nagisa
Copy link
Member

@nagisa nagisa commented Nov 18, 2015

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

@nagisa
Copy link
Member Author

nagisa commented Nov 18, 2015

Nits addressed.

substs: &'tcx Substs<'tcx>,
did: DefId)
-> OperandRef<'tcx> {
match ty.sty {
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

@bors
Copy link
Contributor

bors commented Nov 18, 2015

☔ The latest upstream changes (presumably #29886) made this pull request unmergeable. Please resolve the merge conflicts.

@nagisa nagisa force-pushed the mir-moar-constants branch 2 times, most recently from 9a2607e to f013dd2 Compare November 19, 2015 23:10
@bors
Copy link
Contributor

bors commented Nov 20, 2015

☔ The latest upstream changes (presumably #29534) made this pull request unmergeable. Please resolve the merge conflicts.

@nagisa nagisa changed the title [MIR] Implement translation of references to various items [WIP][MIR] Implement translation of references to various items Nov 20, 2015
@bors
Copy link
Contributor

bors commented Dec 1, 2015

☔ The latest upstream changes (presumably #25570) made this pull request unmergeable. Please resolve the merge conflicts.

@nagisa
Copy link
Member Author

nagisa commented Dec 5, 2015

I changed my approach to storing relevant kind inside Literal itself. Current test failures result from #30202 I think.

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.

@nagisa nagisa changed the title [WIP][MIR] Implement translation of references to various items [MIR] Implement translation of references to various items Dec 5, 2015
@bors
Copy link
Contributor

bors commented Dec 11, 2015

☔ The latest upstream changes (presumably #30301) made this pull request unmergeable. Please resolve the merge conflicts.

@nagisa
Copy link
Member Author

nagisa commented Dec 15, 2015

(I hate how github removed all the comments on force push :()

nagisa@ece05d3 and nagisa@5fb2edc were the two commits that had comments.

@nikomatsakis
Copy link
Contributor

@bors r+

Still more refactoring to be done here but this seems like an epic improvement! Thanks @nagisa!

@bors
Copy link
Contributor

bors commented Dec 17, 2015

📌 Commit 7dd9579 has been approved by nikomatsakis

bors added a commit that referenced this pull request Dec 18, 2015
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
@bors
Copy link
Contributor

bors commented Dec 18, 2015

⌛ Testing commit 7dd9579 with merge 4eadabd...

@bors bors merged commit 7dd9579 into rust-lang:master Dec 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants