Skip to content

Commit

Permalink
(fix) Fix compiler error with rust 1.31.1
Browse files Browse the repository at this point in the history
Refering to Self in where clause became illegal because:
> As was discovered in #50781 a combination of implementing a trait
> directly for a dyn type and where clauses involving Self can punch a
> hole in our dyn-capability rules.

See this issue for details:
rust-lang/rust#51443
  • Loading branch information
pierrechevalier83 committed Dec 27, 2018
1 parent 9452d89 commit 6916c1e
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,29 @@ unsafe impl UnsafeAnyExt for DebugAny + Send + Sync {}
/// additional bounds.
///
/// There is also an exported alias for this type of `TypeMap`, `CloneAny`.
pub trait CloneAny: Any {
pub trait CloneAny: Any + Send + Sync {
#[doc(hidden)]
fn clone_any(&self) -> Box<CloneAny>;
#[doc(hidden)]
fn clone_any_send(&self) -> Box<CloneAny + Send> where Self: Send;
fn clone_any_send(&self) -> Box<CloneAny + Send>;
#[doc(hidden)]
fn clone_any_sync(&self) -> Box<CloneAny + Sync> where Self: Sync;
fn clone_any_sync(&self) -> Box<CloneAny + Sync>;
#[doc(hidden)]
fn clone_any_send_sync(&self) -> Box<CloneAny + Send + Sync> where Self: Send + Sync;
fn clone_any_send_sync(&self) -> Box<CloneAny + Send + Sync>;
}

impl<T: Any + Clone> CloneAny for T {
impl<T: Any + Clone + Send + Sync> CloneAny for T {
fn clone_any(&self) -> Box<CloneAny> { Box::new(self.clone()) }

fn clone_any_send(&self) -> Box<CloneAny + Send> where Self: Send {
fn clone_any_send(&self) -> Box<CloneAny + Send> {
Box::new(self.clone())
}

fn clone_any_sync(&self) -> Box<CloneAny + Sync> where Self: Sync {
fn clone_any_sync(&self) -> Box<CloneAny + Sync> {
Box::new(self.clone())
}

fn clone_any_send_sync(&self) -> Box<CloneAny + Send + Sync>
where Self: Send + Sync {
fn clone_any_send_sync(&self) -> Box<CloneAny + Send + Sync> {
Box::new(self.clone())
}
}
Expand Down

0 comments on commit 6916c1e

Please sign in to comment.