@@ -20,7 +20,7 @@ use rustc_data_structures::fx::FxHashSet;
20
20
use rustc_errors:: Applicability ;
21
21
use rustc_hir:: intravisit:: { self , Visitor } ;
22
22
use 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 } ;
24
24
use rustc_middle:: hir:: nested_filter;
25
25
use rustc_middle:: ty;
26
26
use rustc_resolve:: rustdoc:: {
@@ -600,6 +600,12 @@ impl_lint_pass!(Documentation => [
600
600
DOC_INCLUDE_WITHOUT_CFG ,
601
601
] ) ;
602
602
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
+
603
609
impl < ' tcx > LateLintPass < ' tcx > for Documentation {
604
610
fn check_attributes ( & mut self , cx : & LateContext < ' tcx > , attrs : & ' tcx [ Attribute ] ) {
605
611
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: &[
727
733
Some ( ( "fake" . into ( ) , "fake" . into ( ) ) )
728
734
}
729
735
730
- include_in_doc_without_cfg:: check ( cx, attrs) ;
731
736
if suspicious_doc_comments:: check ( cx, attrs) || is_doc_hidden ( attrs) {
732
737
return None ;
733
738
}
734
739
735
740
let ( fragments, _) = attrs_to_doc_fragments (
736
741
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 ( ) ) {
738
743
None
739
744
} else {
740
745
Some ( ( attr, None ) )
@@ -1160,7 +1165,7 @@ impl<'tcx> Visitor<'tcx> for FindPanicUnwrap<'_, 'tcx> {
1160
1165
"assert" | "assert_eq" | "assert_ne"
1161
1166
)
1162
1167
{
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 ) ;
1164
1169
self . panic_span = Some ( macro_call. span ) ;
1165
1170
}
1166
1171
}
0 commit comments