@@ -187,11 +187,10 @@ pub(crate) fn build_index<'tcx>(
187
187
lastpathid,
188
188
crate_paths,
189
189
) ;
190
- if let Some ( converted_associated_type) = converted_associated_type {
191
- * associated_type = converted_associated_type;
192
- } else {
190
+ let Some ( converted_associated_type) = converted_associated_type else {
193
191
return false ;
194
- }
192
+ } ;
193
+ * associated_type = converted_associated_type;
195
194
for constraint in constraints {
196
195
convert_render_type (
197
196
constraint,
@@ -516,20 +515,23 @@ pub(crate) fn get_function_type_for_search<'tcx>(
516
515
) -> Option < IndexItemFunctionType > {
517
516
let mut trait_info = None ;
518
517
let impl_or_trait_generics = impl_generics. or_else ( || {
519
- if let Some ( def_id) = parent &&
520
- let Some ( trait_) = cache. traits . get ( & def_id) &&
521
- let Some ( ( path, _) ) = cache . paths . get ( & def_id )
522
- . or_else ( || cache. external_paths . get ( & def_id) )
518
+ if let Some ( def_id) = parent
519
+ && let Some ( trait_) = cache. traits . get ( & def_id)
520
+ && let Some ( ( path, _) ) =
521
+ cache . paths . get ( & def_id ) . or_else ( || cache. external_paths . get ( & def_id) )
523
522
{
524
523
let path = clean:: Path {
525
524
res : rustc_hir:: def:: Res :: Def ( rustc_hir:: def:: DefKind :: Trait , def_id) ,
526
- segments : path. iter ( ) . map ( |name| clean:: PathSegment {
527
- name : * name,
528
- args : clean:: GenericArgs :: AngleBracketed {
529
- args : Vec :: new ( ) . into_boxed_slice ( ) ,
530
- bindings : ThinVec :: new ( ) ,
531
- } ,
532
- } ) . collect ( ) ,
525
+ segments : path
526
+ . iter ( )
527
+ . map ( |name| clean:: PathSegment {
528
+ name : * name,
529
+ args : clean:: GenericArgs :: AngleBracketed {
530
+ args : Vec :: new ( ) . into_boxed_slice ( ) ,
531
+ bindings : ThinVec :: new ( ) ,
532
+ } ,
533
+ } )
534
+ . collect ( ) ,
533
535
} ;
534
536
trait_info = Some ( ( clean:: Type :: Path { path } , trait_. generics . clone ( ) ) ) ;
535
537
Some ( trait_info. as_ref ( ) . unwrap ( ) )
@@ -538,15 +540,9 @@ pub(crate) fn get_function_type_for_search<'tcx>(
538
540
}
539
541
} ) ;
540
542
let ( mut inputs, mut output, where_clause) = match * item. kind {
541
- clean:: FunctionItem ( ref f) => {
543
+ clean:: FunctionItem ( ref f) | clean :: MethodItem ( ref f , _ ) | clean :: TyMethodItem ( ref f ) => {
542
544
get_fn_inputs_and_outputs ( f, tcx, impl_or_trait_generics, cache)
543
545
}
544
- clean:: MethodItem ( ref m, _) => {
545
- get_fn_inputs_and_outputs ( m, tcx, impl_or_trait_generics, cache)
546
- }
547
- clean:: TyMethodItem ( ref m) => {
548
- get_fn_inputs_and_outputs ( m, tcx, impl_or_trait_generics, cache)
549
- }
550
546
_ => return None ,
551
547
} ;
552
548
@@ -591,20 +587,16 @@ fn get_index_type_id(
591
587
&& let Some ( clean:: Path { res : Res :: Def ( DefKind :: Trait , trait_) , .. } ) = data. trait_
592
588
{
593
589
let idx = -isize:: try_from ( rgen. len ( ) + 1 ) . unwrap ( ) ;
594
- let ( idx, _) = rgen. entry ( SimplifiedParam :: AssociatedType ( trait_, data. assoc . name ) )
595
- . or_insert_with ( || {
596
- ( idx, Vec :: new ( ) )
597
- } ) ;
590
+ let ( idx, _) = rgen
591
+ . entry ( SimplifiedParam :: AssociatedType ( trait_, data. assoc . name ) )
592
+ . or_insert_with ( || ( idx, Vec :: new ( ) ) ) ;
598
593
Some ( RenderTypeId :: Index ( * idx) )
599
594
} else {
600
595
None
601
596
}
602
597
}
603
598
// Not supported yet
604
- clean:: BareFunction ( _)
605
- | clean:: Generic ( _)
606
- | clean:: ImplTrait ( _)
607
- | clean:: Infer => None ,
599
+ clean:: BareFunction ( _) | clean:: Generic ( _) | clean:: ImplTrait ( _) | clean:: Infer => None ,
608
600
}
609
601
}
610
602
@@ -853,21 +845,20 @@ fn simplify_fn_type<'tcx, 'a>(
853
845
// Self is technically just Iterator, but we want to pretend it's more like this:
854
846
//
855
847
// fn next<T>(self: Iterator<Item=T>) -> Option<T>
856
- if is_self &&
857
- let Type :: Path { path } = arg &&
858
- let def_id = path. def_id ( ) &&
859
- let Some ( trait_) = cache. traits . get ( & def_id) &&
860
- trait_. items . iter ( ) . any ( |at| at. is_ty_associated_type ( ) )
848
+ if is_self
849
+ && let Type :: Path { path } = arg
850
+ && let def_id = path. def_id ( )
851
+ && let Some ( trait_) = cache. traits . get ( & def_id)
852
+ && trait_. items . iter ( ) . any ( |at| at. is_ty_associated_type ( ) )
861
853
{
862
854
for assoc_ty in & trait_. items {
863
- if let clean:: ItemKind :: TyAssocTypeItem ( _generics, bounds) = & * assoc_ty. kind &&
864
- let Some ( name) = assoc_ty. name
855
+ if let clean:: ItemKind :: TyAssocTypeItem ( _generics, bounds) = & * assoc_ty. kind
856
+ && let Some ( name) = assoc_ty. name
865
857
{
866
858
let idx = -isize:: try_from ( rgen. len ( ) + 1 ) . unwrap ( ) ;
867
- let ( idx, stored_bounds) = rgen. entry ( SimplifiedParam :: AssociatedType ( def_id, name) )
868
- . or_insert_with ( || {
869
- ( idx, Vec :: new ( ) )
870
- } ) ;
859
+ let ( idx, stored_bounds) = rgen
860
+ . entry ( SimplifiedParam :: AssociatedType ( def_id, name) )
861
+ . or_insert_with ( || ( idx, Vec :: new ( ) ) ) ;
871
862
let idx = * idx;
872
863
if stored_bounds. is_empty ( ) {
873
864
// Can't just pass stored_bounds to simplify_fn_type,
@@ -890,16 +881,22 @@ fn simplify_fn_type<'tcx, 'a>(
890
881
) ;
891
882
}
892
883
}
893
- let stored_bounds = & mut rgen. get_mut ( & SimplifiedParam :: AssociatedType ( def_id, name) ) . unwrap ( ) . 1 ;
884
+ let stored_bounds = & mut rgen
885
+ . get_mut ( & SimplifiedParam :: AssociatedType ( def_id, name) )
886
+ . unwrap ( )
887
+ . 1 ;
894
888
if stored_bounds. is_empty ( ) {
895
889
* stored_bounds = type_bounds;
896
890
}
897
891
}
898
- ty_bindings. push ( ( RenderTypeId :: AssociatedType ( name) , vec ! [ RenderType {
899
- id: Some ( RenderTypeId :: Index ( idx) ) ,
900
- generics: None ,
901
- bindings: None ,
902
- } ] ) )
892
+ ty_bindings. push ( (
893
+ RenderTypeId :: AssociatedType ( name) ,
894
+ vec ! [ RenderType {
895
+ id: Some ( RenderTypeId :: Index ( idx) ) ,
896
+ generics: None ,
897
+ bindings: None ,
898
+ } ] ,
899
+ ) )
903
900
}
904
901
}
905
902
}
0 commit comments