Store original Impl in explicit impls set
diff --git a/syntax/impls.rs b/syntax/impls.rs
index ebebb3e..6a177d5 100644
--- a/syntax/impls.rs
+++ b/syntax/impls.rs
@@ -1,4 +1,5 @@
-use crate::syntax::{ExternFn, Receiver, Ref, Signature, Slice, Ty1, Type};
+use crate::syntax::{ExternFn, Impl, Receiver, Ref, Signature, Slice, Ty1, Type};
+use std::borrow::Borrow;
use std::hash::{Hash, Hasher};
use std::mem;
use std::ops::{Deref, DerefMut};
@@ -238,3 +239,38 @@
ty.hash(state);
}
}
+
+impl Hash for Impl {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ let Impl {
+ impl_token: _,
+ ty,
+ brace_token: _,
+ } = self;
+ ty.hash(state);
+ }
+}
+
+impl Eq for Impl {}
+
+impl PartialEq for Impl {
+ fn eq(&self, other: &Impl) -> bool {
+ let Impl {
+ impl_token: _,
+ ty,
+ brace_token: _,
+ } = self;
+ let Impl {
+ impl_token: _,
+ ty: ty2,
+ brace_token: _,
+ } = other;
+ ty == ty2
+ }
+}
+
+impl Borrow<Type> for &Impl {
+ fn borrow(&self) -> &Type {
+ &self.ty
+ }
+}
diff --git a/syntax/types.rs b/syntax/types.rs
index 2afce25..3f8d10c 100644
--- a/syntax/types.rs
+++ b/syntax/types.rs
@@ -1,7 +1,7 @@
use crate::syntax::atom::Atom::{self, *};
use crate::syntax::report::Errors;
use crate::syntax::set::OrderedSet as Set;
-use crate::syntax::{Api, Derive, Enum, ExternFn, ExternType, Struct, Type, TypeAlias};
+use crate::syntax::{Api, Derive, Enum, ExternFn, ExternType, Impl, Struct, Type, TypeAlias};
use proc_macro2::Ident;
use quote::ToTokens;
use std::collections::{BTreeMap as Map, HashSet as UnorderedSet};
@@ -15,7 +15,7 @@
pub aliases: Map<&'a Ident, &'a TypeAlias>,
pub untrusted: Map<&'a Ident, &'a ExternType>,
pub required_trivial: Map<&'a Ident, TrivialReason<'a>>,
- pub explicit_impls: Set<&'a Type>,
+ pub explicit_impls: Set<&'a Impl>,
}
impl<'a> Types<'a> {
@@ -137,7 +137,7 @@
}
Api::Impl(imp) => {
visit(&mut all, &imp.ty);
- explicit_impls.insert(&imp.ty);
+ explicit_impls.insert(imp);
}
}
}