@@ -96,9 +96,27 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
96
96
// from an edition before 2024.
97
97
& UnsafeOpKind :: CallToUnsafeFunction ( Some ( id) )
98
98
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) =>
100
100
{
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
+
101
112
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
+
102
120
self . tcx . emit_node_span_lint (
103
121
DEPRECATED_SAFE_2024 ,
104
122
self . hir_context ,
@@ -107,7 +125,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
107
125
span,
108
126
function : with_no_trimmed_paths ! ( self . tcx. def_path_str( id) ) ,
109
127
sub : CallToDeprecatedSafeFnRequiresUnsafeSub {
110
- indent : sm . indentation_before ( span ) . unwrap_or_default ( ) ,
128
+ start_of_line_suggestion : suggestion ,
111
129
start_of_line : sm. span_extend_to_line ( span) . shrink_to_lo ( ) ,
112
130
left : span. shrink_to_lo ( ) ,
113
131
right : span. shrink_to_hi ( ) ,
0 commit comments