@@ -1903,29 +1903,23 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
19031903
19041904 /// Determine if this expression is a "dangerous initialization".
19051905 fn is_dangerous_init ( cx : & LateContext < ' _ , ' _ > , expr : & hir:: Expr ) -> Option < InitKind > {
1906- const ZEROED_PATH : & [ Symbol ] = & [ sym:: core, sym:: mem, sym:: zeroed] ;
1907- const UININIT_PATH : & [ Symbol ] = & [ sym:: core, sym:: mem, sym:: uninitialized] ;
19081906 // `transmute` is inside an anonymous module (the `extern` block?);
19091907 // `Invalid` represents the empty string and matches that.
1908+ // FIXME(#66075): use diagnostic items. Somehow, that does not seem to work
1909+ // on intrinsics right now.
19101910 const TRANSMUTE_PATH : & [ Symbol ] =
19111911 & [ sym:: core, sym:: intrinsics, kw:: Invalid , sym:: transmute] ;
1912- const MU_ZEROED_PATH : & [ Symbol ] =
1913- & [ sym:: core, sym:: mem, sym:: maybe_uninit, sym:: MaybeUninit , sym:: zeroed] ;
1914- const MU_UNINIT_PATH : & [ Symbol ] =
1915- & [ sym:: core, sym:: mem, sym:: maybe_uninit, sym:: MaybeUninit , sym:: uninit] ;
19161912
19171913 if let hir:: ExprKind :: Call ( ref path_expr, ref args) = expr. kind {
19181914 // Find calls to `mem::{uninitialized,zeroed}` methods.
19191915 if let hir:: ExprKind :: Path ( ref qpath) = path_expr. kind {
19201916 let def_id = cx. tables . qpath_res ( qpath, path_expr. hir_id ) . opt_def_id ( ) ?;
19211917
1922- if cx. match_def_path ( def_id , ZEROED_PATH ) {
1918+ if cx. tcx . is_diagnostic_item ( sym :: mem_zeroed , def_id ) {
19231919 return Some ( InitKind :: Zeroed ) ;
1924- }
1925- if cx. match_def_path ( def_id, UININIT_PATH ) {
1920+ } else if cx. tcx . is_diagnostic_item ( sym:: mem_uninitialized, def_id) {
19261921 return Some ( InitKind :: Uninit ) ;
1927- }
1928- if cx. match_def_path ( def_id, TRANSMUTE_PATH ) {
1922+ } else if cx. match_def_path ( def_id, TRANSMUTE_PATH ) {
19291923 if is_zero ( & args[ 0 ] ) {
19301924 return Some ( InitKind :: Zeroed ) ;
19311925 }
@@ -1940,9 +1934,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
19401934 if let hir:: ExprKind :: Call ( ref path_expr, _) = args[ 0 ] . kind {
19411935 if let hir:: ExprKind :: Path ( ref qpath) = path_expr. kind {
19421936 let def_id = cx. tables . qpath_res ( qpath, path_expr. hir_id ) . opt_def_id ( ) ?;
1943- if cx. match_def_path ( def_id, MU_ZEROED_PATH ) {
1937+
1938+ if cx. tcx . is_diagnostic_item ( sym:: maybe_uninit_zeroed, def_id) {
19441939 return Some ( InitKind :: Zeroed ) ;
1945- } else if cx. match_def_path ( def_id , MU_UNINIT_PATH ) {
1940+ } else if cx. tcx . is_diagnostic_item ( sym :: maybe_uninit_uninit , def_id ) {
19461941 return Some ( InitKind :: Uninit ) ;
19471942 }
19481943 }
0 commit comments