@@ -97,12 +97,12 @@ pub struct Path {
9797 pub tokens : Option < LazyAttrTokenStream > ,
9898}
9999
100+ // Succeeds if the path has a single segment that is arg-free and matches the given symbol.
100101impl PartialEq < Symbol > for Path {
101102 #[ inline]
102103 fn eq ( & self , name : & Symbol ) -> bool {
103104 if let [ segment] = self . segments . as_ref ( )
104- && segment. args . is_none ( )
105- && segment. ident . name == * name
105+ && segment == name
106106 {
107107 true
108108 } else {
@@ -111,6 +111,15 @@ impl PartialEq<Symbol> for Path {
111111 }
112112}
113113
114+ // Succeeds if the path has segments that are arg-free and match the given symbols.
115+ impl PartialEq < & [ Symbol ] > for Path {
116+ #[ inline]
117+ fn eq ( & self , names : & & [ Symbol ] ) -> bool {
118+ self . segments . len ( ) == names. len ( )
119+ && self . segments . iter ( ) . zip ( names. iter ( ) ) . all ( |( s1, s2) | s1 == s2)
120+ }
121+ }
122+
114123impl < CTX : rustc_span:: HashStableContext > HashStable < CTX > for Path {
115124 fn hash_stable ( & self , hcx : & mut CTX , hasher : & mut StableHasher ) {
116125 self . segments . len ( ) . hash_stable ( hcx, hasher) ;
@@ -166,6 +175,14 @@ pub struct PathSegment {
166175 pub args : Option < P < GenericArgs > > ,
167176}
168177
178+ // Succeeds if the path segment is arg-free and matches the given symbol.
179+ impl PartialEq < Symbol > for PathSegment {
180+ #[ inline]
181+ fn eq ( & self , name : & Symbol ) -> bool {
182+ self . args . is_none ( ) && self . ident . name == * name
183+ }
184+ }
185+
169186impl PathSegment {
170187 pub fn from_ident ( ident : Ident ) -> Self {
171188 PathSegment { ident, id : DUMMY_NODE_ID , args : None }
0 commit comments