Skip to content

Conversation

@basil-cow
Copy link
Contributor

Closes #375

let interner = self.db.interner();

let (lhs_binders, lhs_bound) = lhs.binders.as_ref().into();
let (rhs_binders, rhs_bound) = rhs.binders.as_ref().into();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is slightly misleading, because as_ref is cloning the binders, whereas it wasn't before.

Copy link
Contributor Author

@basil-cow basil-cow Apr 10, 2020

Choose a reason for hiding this comment

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

binders are cloned later anyway, but I agree, as_ref is kind of a bad name (I just copied it from rustc), should I change it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, you mean the names, hmm, ok

Copy link
Member

Choose a reason for hiding this comment

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

I think as_ref is fine. Just be sure the doc comments are clear. (The binders will almost certainly end up being an interned type instead of a vec anyways, so the clone should be cheap).

Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

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

Overall, I think this makes things more clean. Couple comments.

let interner = self.db.interner();

let (lhs_binders, lhs_bound) = lhs.binders.as_ref().into();
let (rhs_binders, rhs_bound) = rhs.binders.as_ref().into();
Copy link
Member

Choose a reason for hiding this comment

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

I think as_ref is fine. Just be sure the doc comments are clear. (The binders will almost certainly end up being an interned type instead of a vec anyways, so the clone should be cheap).

pub fn bounds_on_self(&self, interner: &I) -> Vec<QuantifiedWhereClause<I>> {
let Binders { binders, value } = &self.binders;

let (binders, assoc_ty_datum) = self.binders.as_ref().into();
Copy link
Member

Choose a reason for hiding this comment

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

This does technically add a clone to binders. But I don't think it matters.

@jackh726 jackh726 merged commit ad5573b into rust-lang:master Apr 12, 2020
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.

refactor Binders API to have a private value field

3 participants