@@ -166,29 +166,31 @@ pub fn deprecation_in_effect(is_since_rustc_version: bool, since: Option<&str>)
166
166
167
167
pub fn deprecation_suggestion (
168
168
diag : & mut DiagnosticBuilder < ' _ > ,
169
+ kind : & str ,
169
170
suggestion : Option < Symbol > ,
170
171
span : Span ,
171
172
) {
172
173
if let Some ( suggestion) = suggestion {
173
174
diag. span_suggestion (
174
175
span,
175
- "replace the use of the deprecated item" ,
176
+ & format ! ( "replace the use of the deprecated {}" , kind ) ,
176
177
suggestion. to_string ( ) ,
177
178
Applicability :: MachineApplicable ,
178
179
) ;
179
180
}
180
181
}
181
182
182
- pub fn deprecation_message ( depr : & Deprecation , path : & str ) -> ( String , & ' static Lint ) {
183
+ pub fn deprecation_message ( depr : & Deprecation , kind : & str , path : & str ) -> ( String , & ' static Lint ) {
183
184
let ( message, lint) = if deprecation_in_effect (
184
185
depr. is_since_rustc_version ,
185
186
depr. since . map ( Symbol :: as_str) . as_deref ( ) ,
186
187
) {
187
- ( format ! ( "use of deprecated item '{}'" , path) , DEPRECATED )
188
+ ( format ! ( "use of deprecated {} `{}`" , kind , path) , DEPRECATED )
188
189
} else {
189
190
(
190
191
format ! (
191
- "use of item '{}' that will be deprecated in future version {}" ,
192
+ "use of {} `{}` that will be deprecated in future version {}" ,
193
+ kind,
192
194
path,
193
195
depr. since. unwrap( )
194
196
) ,
@@ -224,6 +226,7 @@ fn late_report_deprecation(
224
226
lint : & ' static Lint ,
225
227
span : Span ,
226
228
hir_id : HirId ,
229
+ def_id : DefId ,
227
230
) {
228
231
if span. in_derive_expansion ( ) {
229
232
return ;
@@ -232,7 +235,8 @@ fn late_report_deprecation(
232
235
tcx. struct_span_lint_hir ( lint, hir_id, span, |lint| {
233
236
let mut diag = lint. build ( message) ;
234
237
if let hir:: Node :: Expr ( _) = tcx. hir ( ) . get ( hir_id) {
235
- deprecation_suggestion ( & mut diag, suggestion, span) ;
238
+ let kind = tcx. def_kind ( def_id) . descr ( def_id) ;
239
+ deprecation_suggestion ( & mut diag, kind, suggestion, span) ;
236
240
}
237
241
diag. emit ( )
238
242
} ) ;
@@ -304,15 +308,17 @@ impl<'tcx> TyCtxt<'tcx> {
304
308
// #[rustc_deprecated] however wants to emit down the whole
305
309
// hierarchy.
306
310
if !skip || depr_entry. attr . is_since_rustc_version {
307
- let ( message, lint) =
308
- deprecation_message ( & depr_entry. attr , & self . def_path_str ( def_id) ) ;
311
+ let path = & self . def_path_str ( def_id) ;
312
+ let kind = self . def_kind ( def_id) . descr ( def_id) ;
313
+ let ( message, lint) = deprecation_message ( & depr_entry. attr , kind, path) ;
309
314
late_report_deprecation (
310
315
self ,
311
316
& message,
312
317
depr_entry. attr . suggestion ,
313
318
lint,
314
319
span,
315
320
id,
321
+ def_id,
316
322
) ;
317
323
}
318
324
} ;
0 commit comments