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

Remove std::either #11149

Merged
merged 1 commit into from
Jan 3, 2014
Merged

Remove std::either #11149

merged 1 commit into from
Jan 3, 2014

Conversation

alexcrichton
Copy link
Member

Had to change some stuff in typeck to bootstrap (getting methods in fmt off of Either), but other than that not so painful.

Closes #9157

@Kimundi
Copy link
Member

Kimundi commented Dec 26, 2013

@alexcrichton I get the removal of Either, but why also Void? *Void and *() are not equivalent, the latter you can just construct, while the former is only possible to get with a raw pointer cast.

@glaebhoerl
Copy link
Contributor

@Kimundi they are not equivalent and *() is correct. Void is the type that can't be constructed, and if an instance of it ever exists, it means the type system is unsound (if using safe code) or has been subverted (if using unsafe code). If you have a pointer-to-Void it implies that there's an instance of Void that it's pointing to, and you can call .uninhabited() on it and cause whatever havoc. The raw pointer half of it means that it requires unsafe code either way, so it's not as bad as it could be, but anyway, it's not the right idea.

(void in C-like languages is not the type-theoretical Void, it's actually equivalent to (). To avoid this confusion I was wanting to rename our Void to something like Never, but removing it is fine too.)

@alexcrichton
Copy link
Member Author

From my understanding the point of Void is to allow these two to be equivalent:

fn foo() -> !;
fn foo() -> Void;

As @glaebhoerl pointed out, the Void type cannot be constructed, so neither of these functions can return. That being said, the compiler does no such analysis to realize that foo() cannot return in the second case, and that's supposed to be appeased with foo.uninhabited() (I think?).

We want to remove the std::util module, and I don't think that Void really has a place in the standard library (but I could be wrong)

@glaebhoerl
Copy link
Contributor

FWIW I would rather just have ! be a first-class type. I recall this was discussed somewhere already, but not whether there were any obstacles mentioned.

@huonw
Copy link
Member

huonw commented Dec 30, 2013

Needs a rebase.

@brson
Copy link
Contributor

brson commented Dec 31, 2013

I also don't quite understand the reason for removing Void. The original reason for adding it was to have an equivalent to C void pointers that wasn't c_void. Sometimes you just have an untyped pointer. It's true that we're not using it much but the few places where we were using it are incorrect to convert to () because derefing an arbitrary pointer to () is bogus. So I'm not convinced.

@brson
Copy link
Contributor

brson commented Dec 31, 2013

I'm not sure how unbogus dereferencing a *Void is.

@alexcrichton
Copy link
Member Author

Rebased to only remove std::either

bors added a commit that referenced this pull request Jan 3, 2014
Had to change some stuff in typeck to bootstrap (getting methods in fmt off of Either), but other than that not so painful.

Closes #9157
@bors bors closed this Jan 3, 2014
@bors bors merged commit 4bea679 into rust-lang:master Jan 3, 2014
@alexcrichton alexcrichton deleted the remove-either branch January 4, 2014 07:58
chris-morgan added a commit to chris-morgan/rust-http that referenced this pull request Jan 4, 2014
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.

Remove std::either
6 participants