@@ -23,7 +23,6 @@ use rustc_parse::maybe_new_parser_from_source_str;
2323use rustc_parse:: parser:: ForceCollect ;
2424use rustc_session:: parse:: ParseSess ;
2525use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
26- use rustc_span:: def_id:: LocalDefId ;
2726use rustc_span:: edition:: Edition ;
2827use rustc_span:: source_map:: { BytePos , FilePathMapping , SourceMap , Span } ;
2928use rustc_span:: { sym, FileName , Pos } ;
@@ -302,7 +301,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
302301 panic_span : None ,
303302 } ;
304303 fpu. visit_expr ( body. value ) ;
305- lint_for_missing_headers ( cx, item. owner_id . def_id , sig, headers, Some ( body_id) , fpu. panic_span ) ;
304+ lint_for_missing_headers ( cx, item. owner_id , sig, headers, Some ( body_id) , fpu. panic_span ) ;
306305 }
307306 } ,
308307 hir:: ItemKind :: Impl ( impl_) => {
@@ -338,7 +337,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
338337 let Some ( headers) = check_attrs ( cx, & self . valid_idents , attrs) else { return } ;
339338 if let hir:: TraitItemKind :: Fn ( ref sig, ..) = item. kind {
340339 if !in_external_macro ( cx. tcx . sess , item. span ) {
341- lint_for_missing_headers ( cx, item. owner_id . def_id , sig, headers, None , None ) ;
340+ lint_for_missing_headers ( cx, item. owner_id , sig, headers, None , None ) ;
342341 }
343342 }
344343 }
@@ -357,34 +356,34 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
357356 panic_span : None ,
358357 } ;
359358 fpu. visit_expr ( body. value ) ;
360- lint_for_missing_headers ( cx, item. owner_id . def_id , sig, headers, Some ( body_id) , fpu. panic_span ) ;
359+ lint_for_missing_headers ( cx, item. owner_id , sig, headers, Some ( body_id) , fpu. panic_span ) ;
361360 }
362361 }
363362}
364363
365364fn lint_for_missing_headers (
366365 cx : & LateContext < ' _ > ,
367- def_id : LocalDefId ,
366+ owner_id : hir :: OwnerId ,
368367 sig : & hir:: FnSig < ' _ > ,
369368 headers : DocHeaders ,
370369 body_id : Option < hir:: BodyId > ,
371370 panic_span : Option < Span > ,
372371) {
373- if !cx. effective_visibilities . is_exported ( def_id) {
372+ if !cx. effective_visibilities . is_exported ( owner_id . def_id ) {
374373 return ; // Private functions do not require doc comments
375374 }
376375
377376 // do not lint if any parent has `#[doc(hidden)]` attribute (#7347)
378377 if cx
379378 . tcx
380379 . hir ( )
381- . parent_iter ( cx . tcx . hir ( ) . local_def_id_to_hir_id ( def_id ) )
380+ . parent_iter ( owner_id . into ( ) )
382381 . any ( |( id, _node) | is_doc_hidden ( cx. tcx . hir ( ) . attrs ( id) ) )
383382 {
384383 return ;
385384 }
386385
387- let span = cx. tcx . def_span ( def_id ) ;
386+ let span = cx. tcx . def_span ( owner_id ) ;
388387 match ( headers. safety , sig. header . unsafety ) {
389388 ( false , hir:: Unsafety :: Unsafe ) => span_lint (
390389 cx,
@@ -411,8 +410,7 @@ fn lint_for_missing_headers(
411410 ) ;
412411 }
413412 if !headers. errors {
414- let hir_id = cx. tcx . hir ( ) . local_def_id_to_hir_id ( def_id) ;
415- if is_type_diagnostic_item ( cx, return_ty ( cx, hir_id) , sym:: Result ) {
413+ if is_type_diagnostic_item ( cx, return_ty ( cx, owner_id) , sym:: Result ) {
416414 span_lint (
417415 cx,
418416 MISSING_ERRORS_DOC ,
0 commit comments