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

Nuke deprecated Errno flags #1860

Merged
merged 1 commit into from
Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Removed

- Removed deprecated error constants and conversions.
([#1860](https://github.com/nix-rust/nix/pull/1860))

## [0.25.0] - 2022-08-13
### Added

Expand Down
155 changes: 1 addition & 154 deletions src/errno.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{Error, Result};
use crate::Result;
use cfg_if::cfg_if;
use libc::{c_int, c_void};
use std::convert::TryFrom;
Expand Down Expand Up @@ -51,34 +51,6 @@ pub fn errno() -> i32 {
}

impl Errno {
/// Convert this `Error` to an [`Errno`](enum.Errno.html).
///
/// # Example
///
/// ```
/// # use nix::Error;
/// # use nix::errno::Errno;
/// let e = Error::from(Errno::EPERM);
/// assert_eq!(Some(Errno::EPERM), e.as_errno());
/// ```
#[deprecated(since = "0.22.0", note = "It's a no-op now; just delete it.")]
pub const fn as_errno(self) -> Option<Self> {
Some(self)
}

/// Create a nix Error from a given errno
#[deprecated(since = "0.22.0", note = "It's a no-op now; just delete it.")]
#[allow(clippy::wrong_self_convention)] // False positive
pub fn from_errno(errno: Errno) -> Error {
errno
}

/// Create a new invalid argument error (`EINVAL`)
#[deprecated(since = "0.22.0", note = "Use Errno::EINVAL instead")]
pub const fn invalid_argument() -> Error {
Errno::EINVAL
}

pub fn last() -> Self {
last()
}
Expand All @@ -105,18 +77,6 @@ impl Errno {
Ok(value)
}
}

/// Backwards compatibility hack for Nix <= 0.21.0 users
///
/// In older versions of Nix, `Error::Sys` was an enum variant. Now it's a
/// function, which is compatible with most of the former use cases of the
/// enum variant. But you should use `Error(Errno::...)` instead.
#[deprecated(since = "0.22.0", note = "Use Errno::... instead")]
#[allow(non_snake_case)]
#[inline]
pub const fn Sys(errno: Errno) -> Error {
errno
}
}

/// The sentinel value indicates that a function failed and more detailed
Expand Down Expand Up @@ -1297,22 +1257,6 @@ mod consts {
EHWPOISON = libc::EHWPOISON,
}

#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::EWOULDBLOCK instead"
)]
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::EDEADLOCK instead"
)]
pub const EDEADLOCK: Errno = Errno::EDEADLK;
#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::ENOTSUP instead"
)]
pub const ENOTSUP: Errno = Errno::EOPNOTSUPP;

impl Errno {
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
pub const EDEADLOCK: Errno = Errno::EDEADLK;
Expand Down Expand Up @@ -1576,22 +1520,6 @@ mod consts {
EQFULL = libc::EQFULL,
}

#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::ELAST instead"
)]
pub const ELAST: Errno = Errno::EQFULL;
#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::EWOULDBLOCK instead"
)]
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::EDEADLOCK instead"
)]
pub const EDEADLOCK: Errno = Errno::EDEADLK;

impl Errno {
pub const ELAST: Errno = Errno::EQFULL;
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
Expand Down Expand Up @@ -1818,27 +1746,6 @@ mod consts {
EOWNERDEAD = libc::EOWNERDEAD,
}

#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::ELAST instead"
)]
pub const ELAST: Errno = Errno::EOWNERDEAD;
#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::EWOULDBLOCK instead"
)]
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::EDEADLOCK instead"
)]
pub const EDEADLOCK: Errno = Errno::EDEADLK;
#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::EOPNOTSUPP instead"
)]
pub const EOPNOTSUPP: Errno = Errno::ENOTSUP;

impl Errno {
pub const ELAST: Errno = Errno::EOWNERDEAD;
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
Expand Down Expand Up @@ -2056,27 +1963,6 @@ mod consts {
EASYNC = libc::EASYNC,
}

#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::ELAST instead"
)]
pub const ELAST: Errno = Errno::EASYNC;
#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::EWOULDBLOCK instead"
)]
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::EDEADLOCK instead"
)]
pub const EDEADLOCK: Errno = Errno::EDEADLK;
#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::EOPNOTSUPP instead"
)]
pub const EOPNOTSUPP: Errno = Errno::ENOTSUP;

impl Errno {
pub const ELAST: Errno = Errno::EASYNC;
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
Expand Down Expand Up @@ -2291,17 +2177,6 @@ mod consts {
EPROTO = libc::EPROTO,
}

#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::ELAST instead"
)]
pub const ELAST: Errno = Errno::ENOTSUP;
#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::EWOULDBLOCK instead"
)]
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;

impl Errno {
pub const ELAST: Errno = Errno::ENOTSUP;
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
Expand Down Expand Up @@ -2516,17 +2391,6 @@ mod consts {
EPROTO = libc::EPROTO,
}

#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::ELAST instead"
)]
pub const ELAST: Errno = Errno::ENOTSUP;
#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::EWOULDBLOCK instead"
)]
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;

impl Errno {
pub const ELAST: Errno = Errno::ENOTSUP;
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
Expand Down Expand Up @@ -2731,12 +2595,6 @@ mod consts {
EPROTO = libc::EPROTO,
}

#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::EWOULDBLOCK instead"
)]
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;

impl Errno {
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
}
Expand Down Expand Up @@ -2965,17 +2823,6 @@ mod consts {
ESTALE = libc::ESTALE,
}

#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::ELAST instead"
)]
pub const ELAST: Errno = Errno::ELAST;
#[deprecated(
since = "0.22.1",
note = "use nix::errno::Errno::EWOULDBLOCK instead"
)]
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;

impl Errno {
pub const ELAST: Errno = Errno::ESTALE;
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
Expand Down