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

First-class struct and tuple constants #23275

Merged
merged 2 commits into from
Mar 12, 2015
Merged

First-class struct and tuple constants #23275

merged 2 commits into from
Mar 12, 2015

Conversation

aochagavia
Copy link
Contributor

Fixes #23260

r? @eddyb

@aochagavia
Copy link
Contributor Author

Needs a rebase... I'm on it

@aochagavia
Copy link
Contributor Author

Rebased!

@eddyb
Copy link
Member

eddyb commented Mar 11, 2015

You should never clone AST nodes if you can avoid it.
Thankfully, the AST is borrowed by tcx.map so you can freely pass &'tcx ast::Expr around and whatnot.

@aochagavia
Copy link
Contributor Author

When I first tried storing an &ast::Expr, I got stuck in lifetime hell because the new lifetime parameter of const_val required adding lifetimes to other enums as well. I think a better solution is to store the NodeId in the Struct and Tuple variants and to use tcx.map.expect_expr(id) to retrieve the &Expr back. Do you think this is a correct approach?

I am building rustc again to see if it works. It will take some time because for some reason LLVM is being compiled again.

@eddyb
Copy link
Member

eddyb commented Mar 11, 2015

@aochagavia that's a good idea, for some reason I didn't expect adding a lifetime const_val to propagate outside that module (or only to types that already had 'tcx), my bad.

@aochagavia
Copy link
Contributor Author

@eddyb I have pushed the changes now

@eddyb
Copy link
Member

eddyb commented Mar 11, 2015

@bors rollup r+

@bors
Copy link
Contributor

bors commented Mar 11, 2015

@bors r=eddyb a83db81

Manishearth added a commit to Manishearth/rust that referenced this pull request Mar 12, 2015
@bors bors merged commit a83db81 into rust-lang:master Mar 12, 2015
@aochagavia aochagavia deleted the constants branch October 8, 2015 09:49
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.

Allow first-class struct and tuple constants
3 participants