@@ -1040,9 +1040,10 @@ pub(crate) struct ForgetCopyDiag<'a> {
10401040
10411041#[ derive( Diagnostic ) ]
10421042#[ diag(
1043- "calls to `std ::mem::drop` with `std ::mem::ManuallyDrop` instead of the inner value does nothing"
1043+ "calls to `{$krate} ::mem::drop` with `{$krate} ::mem::ManuallyDrop` instead of the inner value does nothing"
10441044) ]
10451045pub ( crate ) struct UndroppedManuallyDropsDiag < ' a > {
1046+ pub krate : & ' static str ,
10461047 pub arg_ty : Ty < ' a > ,
10471048 #[ label( "argument has type `{$arg_ty}`" ) ]
10481049 pub label : Span ,
@@ -1052,21 +1053,23 @@ pub(crate) struct UndroppedManuallyDropsDiag<'a> {
10521053
10531054#[ derive( Subdiagnostic ) ]
10541055#[ multipart_suggestion(
1055- "use `std ::mem::ManuallyDrop::into_inner` to get the inner value" ,
1056+ "use `{$krate} ::mem::ManuallyDrop::into_inner` to get the inner value" ,
10561057 applicability = "machine-applicable"
10571058) ]
10581059pub ( crate ) struct UndroppedManuallyDropsSuggestion {
1059- #[ suggestion_part( code = "std::mem::ManuallyDrop::into_inner(" ) ]
1060+ pub krate : & ' static str ,
1061+ #[ suggestion_part( code = "{krate}::mem::ManuallyDrop::into_inner(" ) ]
10601062 pub start_span : Span ,
10611063 #[ suggestion_part( code = ")" ) ]
10621064 pub end_span : Span ,
10631065}
10641066
10651067#[ derive( Diagnostic ) ]
10661068#[ diag(
1067- "calls to `drop_in_place` with a pointer to a `std ::mem::ManuallyDrop` instead of the inner value does nothing"
1069+ "calls to `drop_in_place` with a pointer to a `{$krate} ::mem::ManuallyDrop` instead of the inner value does nothing"
10681070) ]
10691071pub ( crate ) struct UndroppedManuallyDropsInPlaceDiag < ' a > {
1072+ pub krate : & ' static str ,
10701073 pub arg_ty : Ty < ' a > ,
10711074 #[ label( "argument has type `{$arg_ty}`" ) ]
10721075 pub label : Span ,
@@ -1076,11 +1079,12 @@ pub(crate) struct UndroppedManuallyDropsInPlaceDiag<'a> {
10761079
10771080#[ derive( Subdiagnostic ) ]
10781081#[ multipart_suggestion(
1079- "use `std ::mem::ManuallyDrop::drop` to drop the inner value" ,
1082+ "use `{$krate} ::mem::ManuallyDrop::drop` to drop the inner value" ,
10801083 applicability = "maybe-incorrect"
10811084) ]
10821085pub ( crate ) struct UndroppedManuallyDropsInPlaceSuggestion {
1083- #[ suggestion_part( code = "std::mem::ManuallyDrop::drop(&mut *" ) ]
1086+ pub krate : & ' static str ,
1087+ #[ suggestion_part( code = "{krate}::mem::ManuallyDrop::drop(&mut *" ) ]
10841088 pub start_span : Span ,
10851089 #[ suggestion_part( code = ")" ) ]
10861090 pub end_span : Span ,
@@ -2074,44 +2078,53 @@ impl<'a> Diagnostic<'a> for DropGlue<'_> {
20742078#[ note(
20752079 "exposed provenance semantics can be used to create a pointer based on some previously exposed provenance"
20762080) ]
2077- #[ help(
2078- "if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`"
2079- ) ]
20802081#[ help(
20812082 "for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>"
20822083) ]
20832084#[ help(
20842085 "for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>"
20852086) ]
20862087pub ( crate ) struct IntegerToPtrTransmutes < ' tcx > {
2088+ #[ subdiagnostic]
2089+ pub without_prov : Option < IntegerToPtrWithoutProvHelp > ,
20872090 #[ subdiagnostic]
20882091 pub suggestion : Option < IntegerToPtrTransmutesSuggestion < ' tcx > > ,
20892092}
20902093
2094+ #[ derive( Subdiagnostic ) ]
2095+ #[ help(
2096+ "if you truly mean to create a pointer without provenance, use `{$krate}::ptr::without_provenance_mut`"
2097+ ) ]
2098+ pub ( crate ) struct IntegerToPtrWithoutProvHelp {
2099+ pub krate : & ' static str ,
2100+ }
2101+
20912102#[ derive( Subdiagnostic ) ]
20922103pub ( crate ) enum IntegerToPtrTransmutesSuggestion < ' tcx > {
20932104 #[ multipart_suggestion(
2094- "use `std ::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance" ,
2105+ "use `{$krate} ::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance" ,
20952106 applicability = "machine-applicable" ,
20962107 style = "verbose"
20972108 ) ]
20982109 ToPtr {
2110+ krate : & ' static str ,
20992111 dst : Ty < ' tcx > ,
21002112 suffix : & ' static str ,
2101- #[ suggestion_part( code = "std ::ptr::with_exposed_provenance{suffix}::<{dst}>(" ) ]
2113+ #[ suggestion_part( code = "{krate} ::ptr::with_exposed_provenance{suffix}::<{dst}>(" ) ]
21022114 start_call : Span ,
21032115 } ,
21042116 #[ multipart_suggestion(
2105- "use `std ::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance" ,
2117+ "use `{$krate} ::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance" ,
21062118 applicability = "machine-applicable" ,
21072119 style = "verbose"
21082120 ) ]
21092121 ToRef {
2122+ krate : & ' static str ,
21102123 dst : Ty < ' tcx > ,
21112124 suffix : & ' static str ,
21122125 ref_mutbl : & ' static str ,
21132126 #[ suggestion_part(
2114- code = "&{ref_mutbl}*std ::ptr::with_exposed_provenance{suffix}::<{dst}>("
2127+ code = "&{ref_mutbl}*{krate} ::ptr::with_exposed_provenance{suffix}::<{dst}>("
21152128 ) ]
21162129 start_call : Span ,
21172130 } ,
@@ -2348,25 +2361,30 @@ pub(crate) enum AmbiguousWidePointerComparisons<'a> {
23482361 #[ diag(
23492362 "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected"
23502363 ) ]
2351- #[ help( "use explicit `std::ptr::eq` method to compare metadata and addresses" ) ]
2352- #[ help( "use `std::ptr::addr_eq` or untyped pointers to only compare their addresses" ) ]
2353- Spanless ,
2364+ #[ help( "use explicit `{$krate}::ptr::eq` method to compare metadata and addresses" ) ]
2365+ #[ help( "use `{$krate}::ptr::addr_eq` or untyped pointers to only compare their addresses" ) ]
2366+ Spanless { krate : & ' static str } ,
2367+ #[ diag(
2368+ "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected"
2369+ ) ]
2370+ Warn ,
23542371}
23552372
23562373#[ derive( Subdiagnostic ) ]
23572374#[ multipart_suggestion(
2358- "use explicit `std ::ptr::eq` method to compare metadata and addresses" ,
2375+ "use explicit `{$krate} ::ptr::eq` method to compare metadata and addresses" ,
23592376 style = "verbose" ,
23602377 // FIXME(#53934): make machine-applicable again
23612378 applicability = "maybe-incorrect"
23622379) ]
23632380pub ( crate ) struct AmbiguousWidePointerComparisonsAddrMetadataSuggestion < ' a > {
2381+ pub krate : & ' static str ,
23642382 pub ne : & ' a str ,
23652383 pub deref_left : & ' a str ,
23662384 pub deref_right : & ' a str ,
23672385 pub l_modifiers : & ' a str ,
23682386 pub r_modifiers : & ' a str ,
2369- #[ suggestion_part( code = "{ne}std ::ptr::eq({deref_left}" ) ]
2387+ #[ suggestion_part( code = "{ne}{krate} ::ptr::eq({deref_left}" ) ]
23702388 pub left : Span ,
23712389 #[ suggestion_part( code = "{l_modifiers}, {deref_right}" ) ]
23722390 pub middle : Span ,
@@ -2376,18 +2394,19 @@ pub(crate) struct AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> {
23762394
23772395#[ derive( Subdiagnostic ) ]
23782396#[ multipart_suggestion(
2379- "use `std ::ptr::addr_eq` or untyped pointers to only compare their addresses" ,
2397+ "use `{$krate} ::ptr::addr_eq` or untyped pointers to only compare their addresses" ,
23802398 style = "verbose" ,
23812399 // FIXME(#53934): make machine-applicable again
23822400 applicability = "maybe-incorrect"
23832401) ]
23842402pub ( crate ) struct AmbiguousWidePointerComparisonsAddrSuggestion < ' a > {
2403+ pub ( crate ) krate : & ' static str ,
23852404 pub ( crate ) ne : & ' a str ,
23862405 pub ( crate ) deref_left : & ' a str ,
23872406 pub ( crate ) deref_right : & ' a str ,
23882407 pub ( crate ) l_modifiers : & ' a str ,
23892408 pub ( crate ) r_modifiers : & ' a str ,
2390- #[ suggestion_part( code = "{ne}std ::ptr::addr_eq({deref_left}" ) ]
2409+ #[ suggestion_part( code = "{ne}{krate} ::ptr::addr_eq({deref_left}" ) ]
23912410 pub ( crate ) left : Span ,
23922411 #[ suggestion_part( code = "{l_modifiers}, {deref_right}" ) ]
23932412 pub ( crate ) middle : Span ,
@@ -2470,32 +2489,34 @@ pub(crate) enum UnpredictableFunctionPointerComparisons<'a, 'tcx> {
24702489#[ derive( Subdiagnostic ) ]
24712490pub ( crate ) enum UnpredictableFunctionPointerComparisonsSuggestion < ' a , ' tcx > {
24722491 #[ multipart_suggestion(
2473- "refactor your code, or use `std ::ptr::fn_addr_eq` to suppress the lint" ,
2492+ "refactor your code, or use `{$krate} ::ptr::fn_addr_eq` to suppress the lint" ,
24742493 style = "verbose" ,
24752494 applicability = "maybe-incorrect"
24762495 ) ]
24772496 FnAddrEq {
2497+ krate : & ' static str ,
24782498 ne : & ' a str ,
24792499 deref_left : & ' a str ,
24802500 deref_right : & ' a str ,
2481- #[ suggestion_part( code = "{ne}std ::ptr::fn_addr_eq({deref_left}" ) ]
2501+ #[ suggestion_part( code = "{ne}{krate} ::ptr::fn_addr_eq({deref_left}" ) ]
24822502 left : Span ,
24832503 #[ suggestion_part( code = ", {deref_right}" ) ]
24842504 middle : Span ,
24852505 #[ suggestion_part( code = ")" ) ]
24862506 right : Span ,
24872507 } ,
24882508 #[ multipart_suggestion(
2489- "refactor your code, or use `std ::ptr::fn_addr_eq` to suppress the lint" ,
2509+ "refactor your code, or use `{$krate} ::ptr::fn_addr_eq` to suppress the lint" ,
24902510 style = "verbose" ,
24912511 applicability = "maybe-incorrect"
24922512 ) ]
24932513 FnAddrEqWithCast {
2514+ krate : & ' static str ,
24942515 ne : & ' a str ,
24952516 deref_left : & ' a str ,
24962517 deref_right : & ' a str ,
24972518 fn_sig : rustc_middle:: ty:: PolyFnSig < ' tcx > ,
2498- #[ suggestion_part( code = "{ne}std ::ptr::fn_addr_eq({deref_left}" ) ]
2519+ #[ suggestion_part( code = "{ne}{krate} ::ptr::fn_addr_eq({deref_left}" ) ]
24992520 left : Span ,
25002521 #[ suggestion_part( code = ", {deref_right}" ) ]
25012522 middle : Span ,
0 commit comments