-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Make the 'a lifetime on TyCtxt useless #56601
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
Conversation
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.
I love the idea of simplifying the TyCtxt
setup!
Would we be able to get rid of |
@michaelwoerister Yes. I also propose a rename to this:
|
@Zoxc Note that pretty much all APIs must take the more general version (" Because of that, I don't consider |
I like |
{ | ||
let interners = CtxtInterners::new(arena); | ||
*interners = Some(CtxtInterners::new(&arena)); |
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.
Maybe we should assert that this is None
and set it back to None
before we return, then?
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.
I guess it hardly matters, it's just the interning maps.
@@ -1604,20 +1611,23 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { | |||
} | |||
} | |||
|
|||
impl<'gcx: 'tcx, 'tcx> GlobalCtxt<'gcx> { | |||
impl<'gcx> GlobalCtxt<'gcx> { | |||
/// Call the closure with a local `TyCtxt` using the given arena. |
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.
Can we add a comment here:
The interners
parameter is a reference to a storage slot with 'tcx
lifetime that we can use. It is expected to be None
on entry and will be reset to None
on return. This allows us to create a &'tcx
reference to the interners while the tcx is active.
that presumes, of course, that you accept my proposal above =)
In any case, I'm 👍 on this change, I'd like some kind of comment to make the role of the |
2fb0acf
to
d0190d3
Compare
@bors r+ Good enough |
📌 Commit d0190d3 has been approved by |
Make the 'a lifetime on TyCtxt useless cc @rust-lang/compiler r? @nikomatsakis
☀️ Test successful - status-appveyor, status-travis |
I have found two drawbacks to doing this:
|
cc @rust-lang/compiler
r? @nikomatsakis