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

std::os::errno returns a different type than IoError::from_errno takes #16786

Closed
tomjakubowski opened this issue Aug 27, 2014 · 7 comments
Closed
Labels
I-needs-decision Issue: In need of a decision. P-medium Medium priority

Comments

@tomjakubowski
Copy link
Contributor

std::os::errno returns an int whereas IoError::from_errno takes a uint. It's a bit irritating to have to write out errno() as uint every time one constructs an IoError from errno.

AIUI errno in C is always of (C) type int, so my inclination would be to change from_errno unless there's a good reason for it to be using uint.

@mahkoh
Copy link
Contributor

mahkoh commented Aug 27, 2014

errno should return c_int.

@tomjakubowski
Copy link
Contributor Author

On Windows std::os::errno returns a uint: https://github.com/rust-lang/rust/blob/master/src/libstd/os.rs#L944-L957

This means that IoError::from_errno(errno(), ...) compiles on Windows without a cast but not on other platforms.

@steveklabnik
Copy link
Member

src/libstd/os.rs:pub fn errno() -> uint {
src/libstd/sys/unix/os.rs:pub fn errno() -> int {
src/libstd/sys/unix/os.rs:    fn errno_location() -> *const c_int {
src/libstd/sys/unix/os.rs:    fn errno_location() -> *const c_int {
src/libstd/sys/unix/os.rs:    fn errno_location() -> *const c_int {
src/libsrc/libstd/os.rs:pub fn errno() -> uint {

@steveklabnik
Copy link
Member

/cc @aturon , is this a backcompati issue?

@aturon
Copy link
Member

aturon commented Feb 16, 2015

This affects the stabilization of the new std::io::Error::from_os_error. Nominating for 1.0-beta P-backcompat-libs.

@pnkfelix
Copy link
Member

I-needs-decision, P-high; but not 1.0 beta nor P-backcompat-libs.

(We may need to put more thought into how we track such things)

@pnkfelix pnkfelix added I-needs-decision Issue: In need of a decision. P-medium Medium priority and removed I-nominated labels Feb 19, 2015
@huonw
Copy link
Member

huonw commented Jan 5, 2016

We no longer have std::os:errno, just various methods on io::Error, which all use i32. Closing.

@huonw huonw closed this as completed Jan 5, 2016
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this issue Mar 10, 2024
internal: Improve readability of the parser code

The code is basically equivalent to the previous version, but it improves the readability by making it much more simpler and concise.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-needs-decision Issue: In need of a decision. P-medium Medium priority
Projects
None yet
Development

No branches or pull requests

6 participants