@@ -96,9 +96,27 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
9696 // from an edition before 2024.
9797 & UnsafeOpKind :: CallToUnsafeFunction ( Some ( id) )
9898 if !span. at_least_rust_2024 ( )
99- && self . tcx . has_attr ( id, sym:: rustc_deprecated_safe_2024) =>
99+ && let Some ( attr ) = self . tcx . get_attr ( id, sym:: rustc_deprecated_safe_2024) =>
100100 {
101+ let suggestion = attr
102+ . meta_item_list ( )
103+ . unwrap_or_default ( )
104+ . into_iter ( )
105+ . find ( |item| item. has_name ( sym:: todo) )
106+ . map ( |item| {
107+ item. value_str ( ) . expect (
108+ "`#[rustc_deprecated_safe_2024(todo)]` must have a string value" ,
109+ )
110+ } ) ;
111+
101112 let sm = self . tcx . sess . source_map ( ) ;
113+ let suggestion = suggestion
114+ . and_then ( |suggestion| {
115+ sm. indentation_before ( span)
116+ . map ( |indent| format ! ( "{}// TODO: {}\n " , indent, suggestion) ) // ignore-tidy-todo
117+ } )
118+ . unwrap_or_default ( ) ;
119+
102120 self . tcx . emit_node_span_lint (
103121 DEPRECATED_SAFE_2024 ,
104122 self . hir_context ,
@@ -107,7 +125,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
107125 span,
108126 function : with_no_trimmed_paths ! ( self . tcx. def_path_str( id) ) ,
109127 sub : CallToDeprecatedSafeFnRequiresUnsafeSub {
110- indent : sm . indentation_before ( span ) . unwrap_or_default ( ) ,
128+ start_of_line_suggestion : suggestion ,
111129 start_of_line : sm. span_extend_to_line ( span) . shrink_to_lo ( ) ,
112130 left : span. shrink_to_lo ( ) ,
113131 right : span. shrink_to_hi ( ) ,
0 commit comments