Remove uses of ! to be compatible with rust <1.41 (in rust >=1.41 core::convert::Infallible = ! so with latest versions we will work just fine)

This commit is contained in:
Waffle 2019-12-26 21:50:39 +03:00
parent e2a4112bd6
commit 6eb91f04a8
3 changed files with 1 additions and 23 deletions

View file

@ -23,4 +23,3 @@ serde_with_macros = "1.0.1"
default = []
unstable-stream = [] # add streams to public API
never-type = [] # add never type (`!`) to punlic API

View file

@ -1,6 +1,4 @@
#[cfg(not(feature = "never-type"))]
use std::convert::Infallible;
use std::{future::Future, pin::Pin};
use std::{future::Future, pin::Pin, convert::Infallible /* used instead of `!` to be compatible with rust <1.41 */};
use async_trait::async_trait;
@ -73,28 +71,10 @@ where
/// IgnoreSafe.handle_error(0);
/// ```
///
/// ## Note
/// Never type is not stabilized yet (see [`#35121`]) so all API that uses [`!`]
/// (including `impl ErrorPolicy<!> for IgnoreSafe`) we hide under the
/// `never-type` cargo feature.
///
/// [`!`]: https://doc.rust-lang.org/std/primitive.never.html
/// [`Infallible`]: std::convert::Infallible
/// [`#35121`]: https://github.com/rust-lang/rust/issues/35121
pub struct IgnoreSafe;
#[cfg(feature = "never-type")]
#[allow(unreachable_code)]
#[async_trait]
impl ErrorPolicy<!> for IgnoreSafe {
async fn handle_error(&self, _: !)
where
!: 'async_trait,
{
}
}
#[cfg(not(feature = "never-type"))]
#[allow(unreachable_code)]
#[async_trait]
impl ErrorPolicy<Infallible> for IgnoreSafe {

View file

@ -1,6 +1,5 @@
#![allow(clippy::unit_arg)] // TODO
#![allow(clippy::ptr_arg)] // TODO
#![feature(never_type)]
#[macro_use]
extern crate derive_more;