@@ -31,7 +31,6 @@ use crate::tokenstream::{DelimSpan, TokenStream, TokenTree};
31
31
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
32
32
use rustc_data_structures:: sync:: Lrc ;
33
33
use rustc_data_structures:: thin_vec:: ThinVec ;
34
- use rustc_index:: vec:: Idx ;
35
34
use rustc_macros:: HashStable_Generic ;
36
35
use rustc_serialize:: { self , Decoder , Encoder } ;
37
36
use rustc_span:: source_map:: { respan, Spanned } ;
@@ -2251,27 +2250,22 @@ pub enum AttrStyle {
2251
2250
Inner ,
2252
2251
}
2253
2252
2254
- #[ derive( Clone , PartialEq , Eq , Hash , Debug , PartialOrd , Ord , Copy ) ]
2255
- pub struct AttrId ( pub usize ) ;
2256
-
2257
- impl Idx for AttrId {
2258
- fn new ( idx : usize ) -> Self {
2259
- AttrId ( idx)
2260
- }
2261
- fn index ( self ) -> usize {
2262
- self . 0
2253
+ rustc_index:: newtype_index! {
2254
+ pub struct AttrId {
2255
+ ENCODABLE = custom
2256
+ DEBUG_FORMAT = "AttrId({})"
2263
2257
}
2264
2258
}
2265
2259
2266
2260
impl rustc_serialize:: Encodable for AttrId {
2267
- fn encode < S : Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
2268
- s . emit_unit ( )
2261
+ fn encode < S : Encoder > ( & self , _ : & mut S ) -> Result < ( ) , S :: Error > {
2262
+ Ok ( ( ) )
2269
2263
}
2270
2264
}
2271
2265
2272
2266
impl rustc_serialize:: Decodable for AttrId {
2273
- fn decode < D : Decoder > ( d : & mut D ) -> Result < AttrId , D :: Error > {
2274
- d . read_nil ( ) . map ( |_| crate :: attr:: mk_attr_id ( ) )
2267
+ fn decode < D : Decoder > ( _ : & mut D ) -> Result < AttrId , D :: Error > {
2268
+ Ok ( crate :: attr:: mk_attr_id ( ) )
2275
2269
}
2276
2270
}
2277
2271
0 commit comments