@@ -166,29 +166,31 @@ pub fn deprecation_in_effect(is_since_rustc_version: bool, since: Option<&str>)
166166
167167pub fn deprecation_suggestion (
168168 diag : & mut DiagnosticBuilder < ' _ > ,
169+ kind : & str ,
169170 suggestion : Option < Symbol > ,
170171 span : Span ,
171172) {
172173 if let Some ( suggestion) = suggestion {
173174 diag. span_suggestion (
174175 span,
175- "replace the use of the deprecated item" ,
176+ & format ! ( "replace the use of the deprecated {}" , kind ) ,
176177 suggestion. to_string ( ) ,
177178 Applicability :: MachineApplicable ,
178179 ) ;
179180 }
180181}
181182
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 ) {
183184 let ( message, lint) = if deprecation_in_effect (
184185 depr. is_since_rustc_version ,
185186 depr. since . map ( Symbol :: as_str) . as_deref ( ) ,
186187 ) {
187- ( format ! ( "use of deprecated item '{}'" , path) , DEPRECATED )
188+ ( format ! ( "use of deprecated {} `{}`" , kind , path) , DEPRECATED )
188189 } else {
189190 (
190191 format ! (
191- "use of item '{}' that will be deprecated in future version {}" ,
192+ "use of {} `{}` that will be deprecated in future version {}" ,
193+ kind,
192194 path,
193195 depr. since. unwrap( )
194196 ) ,
@@ -224,6 +226,7 @@ fn late_report_deprecation(
224226 lint : & ' static Lint ,
225227 span : Span ,
226228 hir_id : HirId ,
229+ def_id : DefId ,
227230) {
228231 if span. in_derive_expansion ( ) {
229232 return ;
@@ -232,7 +235,8 @@ fn late_report_deprecation(
232235 tcx. struct_span_lint_hir ( lint, hir_id, span, |lint| {
233236 let mut diag = lint. build ( message) ;
234237 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) ;
236240 }
237241 diag. emit ( )
238242 } ) ;
@@ -304,15 +308,17 @@ impl<'tcx> TyCtxt<'tcx> {
304308 // #[rustc_deprecated] however wants to emit down the whole
305309 // hierarchy.
306310 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) ;
309314 late_report_deprecation (
310315 self ,
311316 & message,
312317 depr_entry. attr . suggestion ,
313318 lint,
314319 span,
315320 id,
321+ def_id,
316322 ) ;
317323 }
318324 } ;
0 commit comments