@@ -868,8 +868,8 @@ impl<'tcx> LateLintPass<'tcx> for InvalidPaths {
868868
869869#[ derive( Default ) ]
870870pub struct InterningDefinedSymbol {
871- // Maps the symbol to the constant name.
872- symbol_map : FxHashMap < String , String > ,
871+ // Maps the symbol value to the constant name.
872+ symbol_map : FxHashMap < u32 , String > ,
873873}
874874
875875impl_lint_pass ! ( InterningDefinedSymbol => [ INTERNING_DEFINED_SYMBOL ] ) ;
@@ -889,10 +889,7 @@ impl<'tcx> LateLintPass<'tcx> for InterningDefinedSymbol {
889889 if let Ok ( ConstValue :: Scalar ( value) ) = cx. tcx. const_eval_poly( item_def_id) ;
890890 if let Ok ( value) = value. to_u32( ) ;
891891 then {
892- // SAFETY: We're converting the raw bytes of the symbol value back
893- // into a Symbol instance.
894- let symbol = unsafe { std:: mem:: transmute:: <u32 , Symbol >( value) } ;
895- self . symbol_map. insert( symbol. to_string( ) , item. ident. to_string( ) ) ;
892+ self . symbol_map. insert( value, item. ident. to_string( ) ) ;
896893 }
897894 }
898895 }
@@ -905,7 +902,8 @@ impl<'tcx> LateLintPass<'tcx> for InterningDefinedSymbol {
905902 if let ty:: FnDef ( def_id, _) = cx. typeck_results( ) . expr_ty( func) . kind( ) ;
906903 if match_def_path( cx, * def_id, & paths:: SYMBOL_INTERN ) ;
907904 if let Some ( Constant :: Str ( arg) ) = constant_simple( cx, cx. typeck_results( ) , arg) ;
908- if let Some ( symbol_const) = self . symbol_map. get( & arg) ;
905+ let value = Symbol :: intern( & arg) . as_u32( ) ;
906+ if let Some ( symbol_const) = self . symbol_map. get( & value) ;
909907 then {
910908 span_lint_and_sugg(
911909 cx,
0 commit comments