@@ -18,7 +18,7 @@ use syntax::abi::Abi;
18
18
use syntax:: ast:: { self , Name , NodeId } ;
19
19
use syntax:: attr;
20
20
use syntax:: parse:: token;
21
- use syntax:: symbol:: InternedString ;
21
+ use syntax:: symbol:: { Symbol , InternedString } ;
22
22
use syntax_pos:: { Span , NO_EXPANSION , COMMAND_LINE_EXPN , BytePos } ;
23
23
use syntax:: tokenstream;
24
24
use rustc:: hir;
@@ -247,6 +247,8 @@ enum SawExprComponent<'a> {
247
247
SawExprBinary ( hir:: BinOp_ ) ,
248
248
SawExprUnary ( hir:: UnOp ) ,
249
249
SawExprLit ( ast:: LitKind ) ,
250
+ SawExprLitStr ( InternedString , ast:: StrStyle ) ,
251
+ SawExprLitFloat ( InternedString , Option < ast:: FloatTy > ) ,
250
252
SawExprCast ,
251
253
SawExprType ,
252
254
SawExprIf ,
@@ -315,7 +317,7 @@ fn saw_expr<'a>(node: &'a Expr_,
315
317
ExprUnary ( op, _) => {
316
318
( SawExprUnary ( op) , unop_can_panic_at_runtime ( op) )
317
319
}
318
- ExprLit ( ref lit) => ( SawExprLit ( lit. node . clone ( ) ) , false ) ,
320
+ ExprLit ( ref lit) => ( saw_lit ( lit) , false ) ,
319
321
ExprCast ( ..) => ( SawExprCast , false ) ,
320
322
ExprType ( ..) => ( SawExprType , false ) ,
321
323
ExprIf ( ..) => ( SawExprIf , false ) ,
@@ -342,6 +344,15 @@ fn saw_expr<'a>(node: &'a Expr_,
342
344
}
343
345
}
344
346
347
+ fn saw_lit ( lit : & ast:: Lit ) -> SawExprComponent < ' static > {
348
+ match lit. node {
349
+ ast:: LitKind :: Str ( s, style) => SawExprLitStr ( s. as_str ( ) , style) ,
350
+ ast:: LitKind :: Float ( s, ty) => SawExprLitFloat ( s. as_str ( ) , Some ( ty) ) ,
351
+ ast:: LitKind :: FloatUnsuffixed ( s) => SawExprLitFloat ( s. as_str ( ) , None ) ,
352
+ ref node @ _ => SawExprLit ( node. clone ( ) ) ,
353
+ }
354
+ }
355
+
345
356
#[ derive( Hash ) ]
346
357
enum SawItemComponent {
347
358
SawItemExternCrate ,
@@ -875,23 +886,16 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
875
886
876
887
// ignoring span information, it doesn't matter here
877
888
self . hash_discriminant ( & meta_item. node ) ;
878
- let name = & * meta_item. name . as_str ( ) ;
889
+ meta_item. name . as_str ( ) . len ( ) . hash ( self . st ) ;
890
+ meta_item. name . as_str ( ) . hash ( self . st ) ;
891
+
879
892
match meta_item. node {
880
- ast:: MetaItemKind :: Word => {
881
- name. len ( ) . hash ( self . st ) ;
882
- name. hash ( self . st ) ;
883
- }
884
- ast:: MetaItemKind :: NameValue ( ref lit) => {
885
- name. len ( ) . hash ( self . st ) ;
886
- name. hash ( self . st ) ;
887
- lit. node . hash ( self . st ) ;
888
- }
893
+ ast:: MetaItemKind :: Word => { }
894
+ ast:: MetaItemKind :: NameValue ( ref lit) => saw_lit ( lit) . hash ( self . st ) ,
889
895
ast:: MetaItemKind :: List ( ref items) => {
890
- name. len ( ) . hash ( self . st ) ;
891
- name. hash ( self . st ) ;
892
896
// Sort subitems so the hash does not depend on their order
893
897
let indices = self . indices_sorted_by ( & items, |p| {
894
- ( p. name ( ) , fnv:: hash ( & p. literal ( ) . map ( |i| & i . node ) ) )
898
+ ( p. name ( ) . map ( Symbol :: as_str ) , fnv:: hash ( & p. literal ( ) . map ( saw_lit ) ) )
895
899
} ) ;
896
900
items. len ( ) . hash ( self . st ) ;
897
901
for ( index, & item_index) in indices. iter ( ) . enumerate ( ) {
@@ -903,7 +907,7 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
903
907
self . hash_meta_item ( meta_item) ;
904
908
}
905
909
ast:: NestedMetaItemKind :: Literal ( ref lit) => {
906
- lit. node . hash ( self . st ) ;
910
+ saw_lit ( lit) . hash ( self . st ) ;
907
911
}
908
912
}
909
913
}
0 commit comments