Skip to content

Commit c243723

Browse files
committed
View can use the faster hashing and equality checks on Ty instead of the inner type
1 parent fba7f77 commit c243723

File tree

1 file changed

+2
-29
lines changed

1 file changed

+2
-29
lines changed

src/librustc/ty/view.rs

+2-29
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
use std::{
2-
fmt,
3-
hash::{Hash, Hasher},
4-
marker::PhantomData,
5-
};
1+
use std::{fmt, marker::PhantomData};
62

73
use syntax::ast;
84

@@ -17,35 +13,12 @@ pub use self::ViewKind::*;
1713
/// `View<'tcx, T>` contains a value of `T` but stores the `Ty<'tcx>` ptr that contains the `T`
1814
/// This allows for cheap access to the `Ty<'tcx>` without needing to ask the type interner or
1915
/// losing the `T` type.
20-
#[derive(TypeFoldable, Lift)]
16+
#[derive(TypeFoldable, Eq, PartialEq, Hash, Lift)]
2117
pub struct View<'tcx, T> {
2218
ty: Ty<'tcx>,
2319
_marker: PhantomData<T>,
2420
}
2521

26-
impl<'tcx, T> PartialEq for View<'tcx, T>
27-
where
28-
T: PartialEq + TyDeref<'tcx>,
29-
{
30-
fn eq(&self, other: &Self) -> bool {
31-
**self == **other
32-
}
33-
}
34-
35-
impl<'tcx, T> Eq for View<'tcx, T> where T: Eq + TyDeref<'tcx> {}
36-
37-
impl<'tcx, T> Hash for View<'tcx, T>
38-
where
39-
T: Hash + TyDeref<'tcx>,
40-
{
41-
fn hash<H>(&self, hasher: &mut H)
42-
where
43-
H: Hasher,
44-
{
45-
(**self).hash(hasher)
46-
}
47-
}
48-
4922
impl<T> Copy for View<'_, T> {}
5023

5124
impl<T> Clone for View<'_, T> {

0 commit comments

Comments
 (0)