@@ -16,8 +16,8 @@ use rustc_feature::{AttributeDuplicates, AttributeType, BUILTIN_ATTRIBUTE_MAP, B
16
16
use rustc_hir:: def_id:: LocalModDefId ;
17
17
use rustc_hir:: intravisit:: { self , Visitor } ;
18
18
use rustc_hir:: {
19
- self as hir, self , CRATE_HIR_ID , CRATE_OWNER_ID , FnSig , ForeignItem , HirId , Item , ItemKind ,
20
- MethodKind , Safety , Target , TraitItem ,
19
+ self as hir, self , AssocItemKind , CRATE_HIR_ID , CRATE_OWNER_ID , FnSig , ForeignItem , HirId ,
20
+ Item , ItemKind , MethodKind , Safety , Target , TraitItem ,
21
21
} ;
22
22
use rustc_macros:: LintDiagnostic ;
23
23
use rustc_middle:: hir:: nested_filter;
@@ -940,6 +940,23 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
940
940
}
941
941
}
942
942
943
+ fn check_doc_search_unbox ( & self , meta : & MetaItemInner , hir_id : HirId ) {
944
+ let hir:: Node :: Item ( item) = self . tcx . hir_node ( hir_id) else {
945
+ self . dcx ( ) . emit_err ( errors:: DocSearchUnboxInvalid { span : meta. span ( ) } ) ;
946
+ return ;
947
+ } ;
948
+ match item. kind {
949
+ ItemKind :: Enum ( _, generics) | ItemKind :: Struct ( _, generics)
950
+ if generics. params . len ( ) != 0 => { }
951
+ ItemKind :: Trait ( _, _, generics, _, items)
952
+ if generics. params . len ( ) != 0
953
+ || items. iter ( ) . any ( |item| matches ! ( item. kind, AssocItemKind :: Type ) ) => { }
954
+ _ => {
955
+ self . dcx ( ) . emit_err ( errors:: DocSearchUnboxInvalid { span : meta. span ( ) } ) ;
956
+ }
957
+ }
958
+ }
959
+
943
960
/// Checks `#[doc(inline)]`/`#[doc(no_inline)]` attributes.
944
961
///
945
962
/// A doc inlining attribute is invalid if it is applied to a non-`use` item, or
@@ -1152,6 +1169,12 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1152
1169
}
1153
1170
}
1154
1171
1172
+ sym:: search_unbox => {
1173
+ if self . check_attr_not_crate_level ( meta, hir_id, "fake_variadic" ) {
1174
+ self . check_doc_search_unbox ( meta, hir_id) ;
1175
+ }
1176
+ }
1177
+
1155
1178
sym:: test => {
1156
1179
if self . check_attr_crate_level ( attr, meta, hir_id) {
1157
1180
self . check_test_attr ( meta, hir_id) ;
0 commit comments