Skip to content

Commit

Permalink
Revert "AutoSafe now implies IntoAutoSafe"
Browse files Browse the repository at this point in the history
This reverts commit f6cd0c4.
  • Loading branch information
Tamschi committed Feb 14, 2022
1 parent f6cd0c4 commit a961af5
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/guard/auto_safety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<'a, S: ThreadSafety> __<'a, S> {
}

/// Static thread safety smuggling through `impl AutoSafe` returns for [`Guard`] instances.
pub trait AutoSafe: Sealed + Sized + IntoAutoSafe {
pub trait AutoSafe: Sealed + Sized {
/// When specified in consumer code (in the `impl` return type), use the bound variant here.
type BoundOrActual;

Expand Down Expand Up @@ -127,15 +127,17 @@ pub trait IntoAutoSafe {
/// Implemented as identity for types that are already [`AutoSafe`].
fn into_auto_safe(self) -> Self::AutoSafe;
}

#[allow(deprecated)]
impl<S: ThreadSafety> IntoAutoSafe for __<'_, S> {
impl<T> IntoAutoSafe for T
where
T: AutoSafe,
{
type AutoSafe = Self;

fn into_auto_safe(self) -> Self::AutoSafe {
self
}
}

impl<'a, S: ThreadSafety> IntoAutoSafe for Guard<'a, S> {
#[allow(deprecated)]
type AutoSafe = __<'a, S>;
Expand All @@ -145,16 +147,3 @@ impl<'a, S: ThreadSafety> IntoAutoSafe for Guard<'a, S> {
__::new(self)
}
}

/// Panics unconditionally. (Just here to satisfy constraints.)
impl<'a, T> IntoAutoSafe for &'a mut T
where
T: Send + Sync + AutoSafe,
{
#[allow(deprecated)]
type AutoSafe = __<'a, ThreadBound>;

fn into_auto_safe(self) -> Self::AutoSafe {
panic!("Called `IntoAutoSafe::into_auto_safe` on a reference.")
}
}

0 comments on commit a961af5

Please sign in to comment.