@@ -18,7 +18,7 @@ use syntax::abi::Abi;
1818use syntax:: ast:: { self , Name , NodeId } ;
1919use syntax:: attr;
2020use syntax:: parse:: token;
21- use syntax:: symbol:: InternedString ;
21+ use syntax:: symbol:: { Symbol , InternedString } ;
2222use syntax_pos:: { Span , NO_EXPANSION , COMMAND_LINE_EXPN , BytePos } ;
2323use syntax:: tokenstream;
2424use rustc:: hir;
@@ -247,6 +247,8 @@ enum SawExprComponent<'a> {
247247 SawExprBinary ( hir:: BinOp_ ) ,
248248 SawExprUnary ( hir:: UnOp ) ,
249249 SawExprLit ( ast:: LitKind ) ,
250+ SawExprLitStr ( InternedString , ast:: StrStyle ) ,
251+ SawExprLitFloat ( InternedString , Option < ast:: FloatTy > ) ,
250252 SawExprCast ,
251253 SawExprType ,
252254 SawExprIf ,
@@ -315,7 +317,7 @@ fn saw_expr<'a>(node: &'a Expr_,
315317 ExprUnary ( op, _) => {
316318 ( SawExprUnary ( op) , unop_can_panic_at_runtime ( op) )
317319 }
318- ExprLit ( ref lit) => ( SawExprLit ( lit. node . clone ( ) ) , false ) ,
320+ ExprLit ( ref lit) => ( saw_lit ( lit) , false ) ,
319321 ExprCast ( ..) => ( SawExprCast , false ) ,
320322 ExprType ( ..) => ( SawExprType , false ) ,
321323 ExprIf ( ..) => ( SawExprIf , false ) ,
@@ -342,6 +344,15 @@ fn saw_expr<'a>(node: &'a Expr_,
342344 }
343345}
344346
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+
345356#[ derive( Hash ) ]
346357enum SawItemComponent {
347358 SawItemExternCrate ,
@@ -875,23 +886,16 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
875886
876887 // ignoring span information, it doesn't matter here
877888 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+
879892 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 ) ,
889895 ast:: MetaItemKind :: List ( ref items) => {
890- name. len ( ) . hash ( self . st ) ;
891- name. hash ( self . st ) ;
892896 // Sort subitems so the hash does not depend on their order
893897 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 ) ) )
895899 } ) ;
896900 items. len ( ) . hash ( self . st ) ;
897901 for ( index, & item_index) in indices. iter ( ) . enumerate ( ) {
@@ -903,7 +907,7 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
903907 self . hash_meta_item ( meta_item) ;
904908 }
905909 ast:: NestedMetaItemKind :: Literal ( ref lit) => {
906- lit. node . hash ( self . st ) ;
910+ saw_lit ( lit) . hash ( self . st ) ;
907911 }
908912 }
909913 }
0 commit comments