@@ -868,8 +868,8 @@ impl<'tcx> LateLintPass<'tcx> for InvalidPaths {
868
868
869
869
#[ derive( Default ) ]
870
870
pub 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 > ,
873
873
}
874
874
875
875
impl_lint_pass ! ( InterningDefinedSymbol => [ INTERNING_DEFINED_SYMBOL ] ) ;
@@ -889,10 +889,7 @@ impl<'tcx> LateLintPass<'tcx> for InterningDefinedSymbol {
889
889
if let Ok ( ConstValue :: Scalar ( value) ) = cx. tcx. const_eval_poly( item_def_id) ;
890
890
if let Ok ( value) = value. to_u32( ) ;
891
891
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( ) ) ;
896
893
}
897
894
}
898
895
}
@@ -905,7 +902,8 @@ impl<'tcx> LateLintPass<'tcx> for InterningDefinedSymbol {
905
902
if let ty:: FnDef ( def_id, _) = cx. typeck_results( ) . expr_ty( func) . kind( ) ;
906
903
if match_def_path( cx, * def_id, & paths:: SYMBOL_INTERN ) ;
907
904
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) ;
909
907
then {
910
908
span_lint_and_sugg(
911
909
cx,
0 commit comments