-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Store interned predicates in ParameterEnvironment #41605
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
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Thanks you for the PR! We'll make sure that @nikomatsakis or another team member provides a review in a timely fashion. |
// without further refactoring, a slice can't be used. Luckily, we still have the | ||
// predicate vector from which we created the ParameterEnvironment in infcx, so we | ||
// can pass that instead. It's roundabout and a bit brittle, but this code path | ||
// ought to be refactored anyway, and until then it saves us from having to copy. |
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.
Cute.
src/librustc/ty/context.rs
Outdated
// The macro-generated method below asserts we don't intern an empty slice. | ||
// FIXME: intern_type_list also dishes out new empty Slices on every invocation, | ||
// so is this the right thing to do here as well? We should be able to cache things | ||
// in this case eventually. |
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.
Generating a "fresh slice" is basically free, so caching it makes no sense. You can remove this FIXME.
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.
Done.
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.
ps: I was thinking of the (perhaps) future case in which the empty slice also indexes into some caches, and then it would be important to make sure all empty slices are "equal". But that's just FUD on my part (and maybe you already know that it won't be relevant, ever).
src/librustc/ty/mod.rs
Outdated
@@ -1170,7 +1170,8 @@ pub struct ParameterEnvironment<'tcx> { | |||
/// Obligations that the caller must satisfy. This is basically | |||
/// the set of bounds on the in-scope type parameters, translated | |||
/// into Obligations, and elaborated and normalized. | |||
pub caller_bounds: Vec<ty::Predicate<'tcx>>, | |||
/// This slice is interned. |
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 don't mind it, but I think that &'tcx [...]
implies interning, so you don't really need to say it explicitly. (That is, you can't really get a reference with that lifetime unless it is interned, or at least allocated in a tcx 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.
Makes sense, removed.
Can you just tweak the comments as requested? Otherwise, r=me (ping me once you have done). |
@nikomatsakis ping (Apologies for not creating a new commit, I forgot, but nothing happened except the comment tweaks). |
@bors r+ |
📌 Commit ba2ae37 has been approved by |
☔ The latest upstream changes (presumably #41702) made this pull request unmergeable. Please resolve the merge conflicts. |
See rust-lang#41444. As a first step towards untangling `ParameterEnvironment`, change its `caller_bounds` field from a `Vec` into an interned slice of `ty::Predicate`s. This change is intentionally well-contained and doesn't pull on any of the loose ends. In particular, you'll note that `normalize_param_env_or_error` now interns twice.
@bors r+ |
📌 Commit a6658d5 has been approved by |
Store interned predicates in ParameterEnvironment See #41444. As a first step towards untangling `ParameterEnvironment`, change its `caller_bounds` field from a `Vec` into an interned slice of `ty::Predicate`s. This change is intentionally well-contained and doesn't pull on any of the loose ends. In particular, you'll note that `normalize_param_env_or_error` now interns twice.
☀️ Test successful - status-appveyor, status-travis |
See #41444. As a first step towards untangling
ParameterEnvironment
, changeits
caller_bounds
field from aVec
into an interned slice ofty::Predicate
s.This change is intentionally well-contained and doesn't pull on any of the
loose ends. In particular, you'll note that
normalize_param_env_or_error
now interns twice.