@@ -20,7 +20,7 @@ use rustc_data_structures::fx::FxHashSet;
2020use rustc_errors:: Applicability ;
2121use rustc_hir:: intravisit:: { self , Visitor } ;
2222use rustc_hir:: { AnonConst , Attribute , Expr , ImplItemKind , ItemKind , Node , Safety , TraitItemKind } ;
23- use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
23+ use rustc_lint:: { EarlyContext , EarlyLintPass , LateContext , LateLintPass , LintContext } ;
2424use rustc_middle:: hir:: nested_filter;
2525use rustc_middle:: ty;
2626use rustc_resolve:: rustdoc:: {
@@ -600,6 +600,12 @@ impl_lint_pass!(Documentation => [
600600 DOC_INCLUDE_WITHOUT_CFG ,
601601] ) ;
602602
603+ impl EarlyLintPass for Documentation {
604+ fn check_attributes ( & mut self , cx : & EarlyContext < ' _ > , attrs : & [ rustc_ast:: Attribute ] ) {
605+ include_in_doc_without_cfg:: check ( cx, attrs) ;
606+ }
607+ }
608+
603609impl < ' tcx > LateLintPass < ' tcx > for Documentation {
604610 fn check_attributes ( & mut self , cx : & LateContext < ' tcx > , attrs : & ' tcx [ Attribute ] ) {
605611 let Some ( headers) = check_attrs ( cx, & self . valid_idents , attrs) else {
@@ -727,14 +733,13 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[
727733 Some ( ( "fake" . into ( ) , "fake" . into ( ) ) )
728734 }
729735
730- include_in_doc_without_cfg:: check ( cx, attrs) ;
731736 if suspicious_doc_comments:: check ( cx, attrs) || is_doc_hidden ( attrs) {
732737 return None ;
733738 }
734739
735740 let ( fragments, _) = attrs_to_doc_fragments (
736741 attrs. iter ( ) . filter_map ( |attr| {
737- if attr. span . in_external_macro ( cx. sess ( ) . source_map ( ) ) {
742+ if attr. doc_str_and_comment_kind ( ) . is_none ( ) || attr . span ( ) . in_external_macro ( cx. sess ( ) . source_map ( ) ) {
738743 None
739744 } else {
740745 Some ( ( attr, None ) )
@@ -1160,7 +1165,7 @@ impl<'tcx> Visitor<'tcx> for FindPanicUnwrap<'_, 'tcx> {
11601165 "assert" | "assert_eq" | "assert_ne"
11611166 )
11621167 {
1163- self . is_const = self . cx . tcx . hir ( ) . is_inside_const_context ( expr. hir_id ) ;
1168+ self . is_const = self . cx . tcx . hir_is_inside_const_context ( expr. hir_id ) ;
11641169 self . panic_span = Some ( macro_call. span ) ;
11651170 }
11661171 }
0 commit comments