@@ -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;
@@ -937,6 +937,23 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
937
937
}
938
938
}
939
939
940
+ fn check_doc_search_unbox ( & self , meta : & MetaItemInner , hir_id : HirId ) {
941
+ let hir:: Node :: Item ( item) = self . tcx . hir_node ( hir_id) else {
942
+ self . dcx ( ) . emit_err ( errors:: DocSearchUnboxInvalid { span : meta. span ( ) } ) ;
943
+ return ;
944
+ } ;
945
+ match item. kind {
946
+ ItemKind :: Enum ( _, generics) | ItemKind :: Struct ( _, generics)
947
+ if generics. params . len ( ) != 0 => { }
948
+ ItemKind :: Trait ( _, _, generics, _, items)
949
+ if generics. params . len ( ) != 0
950
+ || items. iter ( ) . any ( |item| matches ! ( item. kind, AssocItemKind :: Type ) ) => { }
951
+ _ => {
952
+ self . dcx ( ) . emit_err ( errors:: DocSearchUnboxInvalid { span : meta. span ( ) } ) ;
953
+ }
954
+ }
955
+ }
956
+
940
957
/// Checks `#[doc(inline)]`/`#[doc(no_inline)]` attributes.
941
958
///
942
959
/// A doc inlining attribute is invalid if it is applied to a non-`use` item, or
@@ -1149,6 +1166,12 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1149
1166
}
1150
1167
}
1151
1168
1169
+ sym:: search_unbox => {
1170
+ if self . check_attr_not_crate_level ( meta, hir_id, "fake_variadic" ) {
1171
+ self . check_doc_search_unbox ( meta, hir_id) ;
1172
+ }
1173
+ }
1174
+
1152
1175
sym:: test => {
1153
1176
if self . check_attr_crate_level ( attr, meta, hir_id) {
1154
1177
self . check_test_attr ( meta, hir_id) ;
0 commit comments