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

Store interned predicates in ParameterEnvironment #41605

Merged
merged 1 commit into from
May 3, 2017

Conversation

tbg
Copy link
Contributor

@tbg tbg commented Apr 28, 2017

See #41444. As a first step towards untangling ParameterEnvironment, change
its caller_bounds field from a Vec into an interned slice of
ty::Predicates.

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.

@tbg
Copy link
Contributor Author

tbg commented Apr 28, 2017

r? @nikomatsakis

@rust-highfive
Copy link
Collaborator

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.

@shepmaster
Copy link
Member

Thanks you for the PR! We'll make sure that @nikomatsakis or another team member provides a review in a timely fashion.

@shepmaster shepmaster added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 28, 2017
// 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cute.

// 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.
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor Author

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).

@@ -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.
Copy link
Contributor

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.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, removed.

@nikomatsakis
Copy link
Contributor

Can you just tweak the comments as requested? Otherwise, r=me (ping me once you have done).

@nikomatsakis nikomatsakis added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 28, 2017
@tbg
Copy link
Contributor Author

tbg commented Apr 28, 2017

@nikomatsakis ping (Apologies for not creating a new commit, I forgot, but nothing happened except the comment tweaks).

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented May 2, 2017

📌 Commit ba2ae37 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented May 2, 2017

☔ 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.
@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented May 2, 2017

📌 Commit a6658d5 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented May 2, 2017

⌛ Testing commit a6658d5 with merge 4d81b14...

bors added a commit that referenced this pull request May 2, 2017
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.
@bors
Copy link
Contributor

bors commented May 3, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 4d81b14 to master...

@bors bors merged commit a6658d5 into rust-lang:master May 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants