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

Implement BorrowFrom<&'a T> for T (with mutable variants) #19146

Merged
merged 1 commit into from
Nov 23, 2014

Conversation

gereeter
Copy link
Contributor

This should be a more general version of #19131.

@alexcrichton
Copy link
Member

If we truly wanted to go all the way, this may want to take T: Deref<U> and T: DerefMut<U>. cc @aturon though, just want to make sure this isn't too crazy

@aturon
Copy link
Member

aturon commented Nov 20, 2014

@alexcrichton

If we truly wanted to go all the way, this may want to take T: Deref<U> and T: DerefMut<U>. cc @aturon though, just want to make sure this isn't too crazy

That would run afoul of coherence, because of the blanket impl of T: BorrowFrom<T> (since nothing prevents you from having a type deref to itself).

@gereeter I feel like I tried something like this originally and ran into other coherence problems; does this pass a make check for you?

@gereeter
Copy link
Contributor Author

I think that would break coherence, as you can impl Deref<T> for T, thereby conflicting with the impl BorrowFrom<T> for T.

@aturon
Copy link
Member

aturon commented Nov 20, 2014

@gereeter Jinx!

@gereeter
Copy link
Contributor Author

Well, make check is about to run, but it compiled fine, so I think that there aren't any coherence issues.

@gereeter
Copy link
Contributor Author

What does fail due to coherence is impl<'a, Sized? Owned, Sized? T: BorrowFrom<Owned>> BorrowFrom<&'a Owned> for T.

@aturon
Copy link
Member

aturon commented Nov 20, 2014

@gereeter

What does fail due to coherence is impl<'a, Sized? Owned, Sized? T: BorrowFrom<Owned>> BorrowFrom<&'a Owned> for T.

Ahha, that may have been what I tried. In any case, assuming this passes make check I'm happy with the change.

@gereeter
Copy link
Contributor Author

make check passes.

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Nov 22, 2014
bors added a commit that referenced this pull request Nov 23, 2014
This should be a more general version of #19131.
@bors bors closed this Nov 23, 2014
@bors bors merged commit 07af6f0 into rust-lang:master Nov 23, 2014
@gereeter gereeter deleted the reference-borrow branch December 17, 2015 01:30
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.

4 participants