@@ -840,6 +840,22 @@ pub(crate) fn get_function_type_for_search(
840840 | clean:: RequiredMethodItem ( ref f) => {
841841 get_fn_inputs_and_outputs ( f, tcx, impl_or_trait_generics, cache)
842842 }
843+ clean:: ConstantItem ( ref c) => make_nullary_fn ( & c. type_ ) ,
844+ clean:: StaticItem ( ref s) => make_nullary_fn ( & s. type_ ) ,
845+ clean:: StructFieldItem ( ref t) => {
846+ let Some ( parent) = parent else {
847+ return None ;
848+ } ;
849+ let mut rgen: FxIndexMap < SimplifiedParam , ( isize , Vec < RenderType > ) > =
850+ Default :: default ( ) ;
851+ let output = get_index_type ( t, vec ! [ ] , & mut rgen) ;
852+ let input = RenderType {
853+ id : Some ( RenderTypeId :: DefId ( parent) ) ,
854+ generics : None ,
855+ bindings : None ,
856+ } ;
857+ ( vec ! [ input] , vec ! [ output] , vec ! [ ] , vec ! [ ] )
858+ }
843859 _ => return None ,
844860 } ;
845861
@@ -1353,6 +1369,17 @@ fn simplify_fn_constraint<'a>(
13531369 res. push ( ( ty_constrained_assoc, ty_constraints) ) ;
13541370}
13551371
1372+ /// Create a fake nullary function.
1373+ ///
1374+ /// Used to allow type-based search on constants and statics.
1375+ fn make_nullary_fn (
1376+ clean_type : & clean:: Type ,
1377+ ) -> ( Vec < RenderType > , Vec < RenderType > , Vec < Symbol > , Vec < Vec < RenderType > > ) {
1378+ let mut rgen: FxIndexMap < SimplifiedParam , ( isize , Vec < RenderType > ) > = Default :: default ( ) ;
1379+ let output = get_index_type ( clean_type, vec ! [ ] , & mut rgen) ;
1380+ ( vec ! [ ] , vec ! [ output] , vec ! [ ] , vec ! [ ] )
1381+ }
1382+
13561383/// Return the full list of types when bounds have been resolved.
13571384///
13581385/// i.e. `fn foo<A: Display, B: Option<A>>(x: u32, y: B)` will return
0 commit comments