@@ -828,30 +828,26 @@ fn clean_ty_generics<'tcx>(
828828 . iter ( )
829829 . flat_map ( |( pred, _) | {
830830 let mut projection = None ;
831- let param_idx = ( || {
831+ let param_idx = {
832832 let bound_p = pred. kind ( ) ;
833833 match bound_p. skip_binder ( ) {
834- ty:: ClauseKind :: Trait ( pred) => {
835- if let ty:: Param ( param) = pred. self_ty ( ) . kind ( ) {
836- return Some ( param. index ) ;
837- }
834+ ty:: ClauseKind :: Trait ( pred) if let ty:: Param ( param) = pred. self_ty ( ) . kind ( ) => {
835+ Some ( param. index )
838836 }
839- ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate ( ty, _reg) ) => {
840- if let ty:: Param ( param) = ty. kind ( ) {
841- return Some ( param . index ) ;
842- }
837+ ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate ( ty, _reg) )
838+ if let ty:: Param ( param) = ty. kind ( ) =>
839+ {
840+ Some ( param . index )
843841 }
844- ty:: ClauseKind :: Projection ( p) => {
845- if let ty:: Param ( param) = p. projection_term . self_ty ( ) . kind ( ) {
846- projection = Some ( bound_p . rebind ( p ) ) ;
847- return Some ( param . index ) ;
848- }
842+ ty:: ClauseKind :: Projection ( p)
843+ if let ty:: Param ( param) = p. projection_term . self_ty ( ) . kind ( ) =>
844+ {
845+ projection = Some ( bound_p . rebind ( p ) ) ;
846+ Some ( param . index )
849847 }
850- _ => ( ) ,
848+ _ => None ,
851849 }
852-
853- None
854- } ) ( ) ;
850+ } ;
855851
856852 if let Some ( param_idx) = param_idx
857853 && let Some ( bounds) = impl_trait. get_mut ( & param_idx)
@@ -1378,12 +1374,12 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
13781374 tcx. fn_sig ( assoc_item. def_id ) . instantiate_identity ( ) . input ( 0 ) . skip_binder ( ) ;
13791375 if self_arg_ty == self_ty {
13801376 item. decl . inputs . values [ 0 ] . type_ = SelfTy ;
1381- } else if let ty:: Ref ( _, ty, _) = * self_arg_ty. kind ( ) {
1382- if ty == self_ty {
1383- match item . decl . inputs . values [ 0 ] . type_ {
1384- BorrowedRef { ref mut type_ , .. } => * * type_ = SelfTy ,
1385- _ => unreachable ! ( ) ,
1386- }
1377+ } else if let ty:: Ref ( _, ty, _) = * self_arg_ty. kind ( )
1378+ && ty == self_ty
1379+ {
1380+ match item . decl . inputs . values [ 0 ] . type_ {
1381+ BorrowedRef { ref mut type_ , .. } => * * type_ = SelfTy ,
1382+ _ => unreachable ! ( ) ,
13871383 }
13881384 }
13891385 }
@@ -2331,25 +2327,22 @@ fn clean_middle_opaque_bounds<'tcx>(
23312327 let bindings: ThinVec < _ > = bounds
23322328 . iter ( )
23332329 . filter_map ( |( bound, _) | {
2334- if let ty:: ClauseKind :: Projection ( proj) = bound. kind ( ) . skip_binder ( ) {
2335- if proj. projection_term . trait_ref ( cx. tcx ) == trait_ref. skip_binder ( ) {
2336- Some ( AssocItemConstraint {
2337- assoc : projection_to_path_segment (
2338- // FIXME: This needs to be made resilient for `AliasTerm`s that
2339- // are associated consts.
2340- bound. kind ( ) . rebind ( proj. projection_term . expect_ty ( cx. tcx ) ) ,
2341- cx,
2342- ) ,
2343- kind : AssocItemConstraintKind :: Equality {
2344- term : clean_middle_term ( bound. kind ( ) . rebind ( proj. term ) , cx) ,
2345- } ,
2346- } )
2347- } else {
2348- None
2349- }
2350- } else {
2351- None
2330+ if let ty:: ClauseKind :: Projection ( proj) = bound. kind ( ) . skip_binder ( )
2331+ && proj. projection_term . trait_ref ( cx. tcx ) == trait_ref. skip_binder ( )
2332+ {
2333+ return Some ( AssocItemConstraint {
2334+ assoc : projection_to_path_segment (
2335+ // FIXME: This needs to be made resilient for `AliasTerm`s that
2336+ // are associated consts.
2337+ bound. kind ( ) . rebind ( proj. projection_term . expect_ty ( cx. tcx ) ) ,
2338+ cx,
2339+ ) ,
2340+ kind : AssocItemConstraintKind :: Equality {
2341+ term : clean_middle_term ( bound. kind ( ) . rebind ( proj. term ) , cx) ,
2342+ } ,
2343+ } ) ;
23522344 }
2345+ None
23532346 } )
23542347 . collect ( ) ;
23552348
@@ -2743,23 +2736,20 @@ fn add_without_unwanted_attributes<'hir>(
27432736 }
27442737 let mut attr = attr. clone ( ) ;
27452738 match attr {
2746- hir:: Attribute :: Unparsed ( ref mut normal) => {
2747- if let [ ident] = & * normal. path . segments {
2748- let ident = ident. name ;
2749- if ident == sym:: doc {
2750- filter_doc_attr ( & mut normal. args , is_inline) ;
2751- attrs. push ( ( Cow :: Owned ( attr) , import_parent) ) ;
2752- } else if is_inline || ident != sym:: cfg {
2753- // If it's not a `cfg()` attribute, we keep it.
2754- attrs. push ( ( Cow :: Owned ( attr) , import_parent) ) ;
2755- }
2756- }
2757- }
2758- hir:: Attribute :: Parsed ( ..) => {
2759- if is_inline {
2739+ hir:: Attribute :: Unparsed ( ref mut normal) if let [ ident] = & * normal. path . segments => {
2740+ let ident = ident. name ;
2741+ if ident == sym:: doc {
2742+ filter_doc_attr ( & mut normal. args , is_inline) ;
2743+ attrs. push ( ( Cow :: Owned ( attr) , import_parent) ) ;
2744+ } else if is_inline || ident != sym:: cfg {
2745+ // If it's not a `cfg()` attribute, we keep it.
27602746 attrs. push ( ( Cow :: Owned ( attr) , import_parent) ) ;
27612747 }
27622748 }
2749+ hir:: Attribute :: Parsed ( ..) if is_inline => {
2750+ attrs. push ( ( Cow :: Owned ( attr) , import_parent) ) ;
2751+ }
2752+ _ => { }
27632753 }
27642754 }
27652755}
@@ -2961,16 +2951,16 @@ fn clean_extern_crate<'tcx>(
29612951 && !cx. is_json_output ( ) ;
29622952
29632953 let krate_owner_def_id = krate. owner_id . def_id ;
2964- if please_inline {
2965- if let Some ( items) = inline:: try_inline (
2954+ if please_inline
2955+ && let Some ( items) = inline:: try_inline (
29662956 cx,
29672957 Res :: Def ( DefKind :: Mod , crate_def_id) ,
29682958 name,
29692959 Some ( ( attrs, Some ( krate_owner_def_id) ) ) ,
29702960 & mut Default :: default ( ) ,
2971- ) {
2972- return items ;
2973- }
2961+ )
2962+ {
2963+ return items ;
29742964 }
29752965
29762966 vec ! [ Item :: from_def_id_and_parts(
0 commit comments