@@ -23,7 +23,6 @@ use rustc_parse::maybe_new_parser_from_source_str;
23
23
use rustc_parse:: parser:: ForceCollect ;
24
24
use rustc_session:: parse:: ParseSess ;
25
25
use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
26
- use rustc_span:: def_id:: LocalDefId ;
27
26
use rustc_span:: edition:: Edition ;
28
27
use rustc_span:: source_map:: { BytePos , FilePathMapping , SourceMap , Span } ;
29
28
use rustc_span:: { sym, FileName , Pos } ;
@@ -302,7 +301,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
302
301
panic_span : None ,
303
302
} ;
304
303
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 ) ;
306
305
}
307
306
} ,
308
307
hir:: ItemKind :: Impl ( impl_) => {
@@ -338,7 +337,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
338
337
let Some ( headers) = check_attrs ( cx, & self . valid_idents , attrs) else { return } ;
339
338
if let hir:: TraitItemKind :: Fn ( ref sig, ..) = item. kind {
340
339
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 ) ;
342
341
}
343
342
}
344
343
}
@@ -357,34 +356,34 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
357
356
panic_span : None ,
358
357
} ;
359
358
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 ) ;
361
360
}
362
361
}
363
362
}
364
363
365
364
fn lint_for_missing_headers (
366
365
cx : & LateContext < ' _ > ,
367
- def_id : LocalDefId ,
366
+ owner_id : hir :: OwnerId ,
368
367
sig : & hir:: FnSig < ' _ > ,
369
368
headers : DocHeaders ,
370
369
body_id : Option < hir:: BodyId > ,
371
370
panic_span : Option < Span > ,
372
371
) {
373
- if !cx. effective_visibilities . is_exported ( def_id) {
372
+ if !cx. effective_visibilities . is_exported ( owner_id . def_id ) {
374
373
return ; // Private functions do not require doc comments
375
374
}
376
375
377
376
// do not lint if any parent has `#[doc(hidden)]` attribute (#7347)
378
377
if cx
379
378
. tcx
380
379
. hir ( )
381
- . parent_iter ( cx . tcx . hir ( ) . local_def_id_to_hir_id ( def_id ) )
380
+ . parent_iter ( owner_id . into ( ) )
382
381
. any ( |( id, _node) | is_doc_hidden ( cx. tcx . hir ( ) . attrs ( id) ) )
383
382
{
384
383
return ;
385
384
}
386
385
387
- let span = cx. tcx . def_span ( def_id ) ;
386
+ let span = cx. tcx . def_span ( owner_id ) ;
388
387
match ( headers. safety , sig. header . unsafety ) {
389
388
( false , hir:: Unsafety :: Unsafe ) => span_lint (
390
389
cx,
@@ -411,8 +410,7 @@ fn lint_for_missing_headers(
411
410
) ;
412
411
}
413
412
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 ) {
416
414
span_lint (
417
415
cx,
418
416
MISSING_ERRORS_DOC ,
0 commit comments