@@ -840,6 +840,22 @@ pub(crate) fn get_function_type_for_search(
840
840
| clean:: RequiredMethodItem ( ref f) => {
841
841
get_fn_inputs_and_outputs ( f, tcx, impl_or_trait_generics, cache)
842
842
}
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
+ }
843
859
_ => return None ,
844
860
} ;
845
861
@@ -1353,6 +1369,17 @@ fn simplify_fn_constraint<'a>(
1353
1369
res. push ( ( ty_constrained_assoc, ty_constraints) ) ;
1354
1370
}
1355
1371
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
+
1356
1383
/// Return the full list of types when bounds have been resolved.
1357
1384
///
1358
1385
/// i.e. `fn foo<A: Display, B: Option<A>>(x: u32, y: B)` will return
0 commit comments