@@ -538,7 +538,7 @@ fn document(
538
538
}
539
539
540
540
fmt:: from_fn ( move |f| {
541
- document_item_info ( cx, item, parent) . render_into ( f) . unwrap ( ) ;
541
+ document_item_info ( cx, item, parent) . render_into ( f) ? ;
542
542
if parent. is_none ( ) {
543
543
write ! ( f, "{}" , document_full_collapsible( item, cx, heading_offset) )
544
544
} else {
@@ -582,7 +582,7 @@ fn document_short(
582
582
show_def_docs : bool ,
583
583
) -> impl fmt:: Display {
584
584
fmt:: from_fn ( move |f| {
585
- document_item_info ( cx, item, Some ( parent) ) . render_into ( f) . unwrap ( ) ;
585
+ document_item_info ( cx, item, Some ( parent) ) . render_into ( f) ? ;
586
586
if !show_def_docs {
587
587
return Ok ( ( ) ) ;
588
588
}
@@ -661,7 +661,7 @@ fn document_full_inner(
661
661
} ;
662
662
663
663
if let clean:: ItemKind :: FunctionItem ( ..) | clean:: ItemKind :: MethodItem ( ..) = kind {
664
- render_call_locations ( f, cx, item) ;
664
+ render_call_locations ( f, cx, item) ? ;
665
665
}
666
666
Ok ( ( ) )
667
667
} )
@@ -2584,11 +2584,15 @@ const MAX_FULL_EXAMPLES: usize = 5;
2584
2584
const NUM_VISIBLE_LINES : usize = 10 ;
2585
2585
2586
2586
/// Generates the HTML for example call locations generated via the --scrape-examples flag.
2587
- fn render_call_locations < W : fmt:: Write > ( mut w : W , cx : & Context < ' _ > , item : & clean:: Item ) {
2587
+ fn render_call_locations < W : fmt:: Write > (
2588
+ mut w : W ,
2589
+ cx : & Context < ' _ > ,
2590
+ item : & clean:: Item ,
2591
+ ) -> fmt:: Result {
2588
2592
let tcx = cx. tcx ( ) ;
2589
2593
let def_id = item. item_id . expect_def_id ( ) ;
2590
2594
let key = tcx. def_path_hash ( def_id) ;
2591
- let Some ( call_locations) = cx. shared . call_locations . get ( & key) else { return } ;
2595
+ let Some ( call_locations) = cx. shared . call_locations . get ( & key) else { return Ok ( ( ) ) } ;
2592
2596
2593
2597
// Generate a unique ID so users can link to this section for a given method
2594
2598
let id = cx. derive_id ( "scraped-examples" ) ;
@@ -2602,8 +2606,7 @@ fn render_call_locations<W: fmt::Write>(mut w: W, cx: &Context<'_>, item: &clean
2602
2606
</h5>",
2603
2607
root_path = cx. root_path( ) ,
2604
2608
id = id
2605
- )
2606
- . unwrap ( ) ;
2609
+ ) ?;
2607
2610
2608
2611
// Create a URL to a particular location in a reverse-dependency's source file
2609
2612
let link_to_loc = |call_data : & CallData , loc : & CallLocation | -> ( String , String ) {
@@ -2705,7 +2708,8 @@ fn render_call_locations<W: fmt::Write>(mut w: W, cx: &Context<'_>, item: &clean
2705
2708
title : init_title,
2706
2709
locations : locations_encoded,
2707
2710
} ) ,
2708
- ) ;
2711
+ )
2712
+ . unwrap ( ) ;
2709
2713
2710
2714
true
2711
2715
} ;
@@ -2761,8 +2765,7 @@ fn render_call_locations<W: fmt::Write>(mut w: W, cx: &Context<'_>, item: &clean
2761
2765
<div class=\" hide-more\" >Hide additional examples</div>\
2762
2766
<div class=\" more-scraped-examples\" >\
2763
2767
<div class=\" toggle-line\" ><div class=\" toggle-line-inner\" ></div></div>"
2764
- )
2765
- . unwrap ( ) ;
2768
+ ) ?;
2766
2769
2767
2770
// Only generate inline code for MAX_FULL_EXAMPLES number of examples. Otherwise we could
2768
2771
// make the page arbitrarily huge!
@@ -2774,23 +2777,21 @@ fn render_call_locations<W: fmt::Write>(mut w: W, cx: &Context<'_>, item: &clean
2774
2777
if it. peek ( ) . is_some ( ) {
2775
2778
w. write_str (
2776
2779
r#"<div class="example-links">Additional examples can be found in:<br><ul>"# ,
2777
- )
2778
- . unwrap ( ) ;
2779
- it. for_each ( |( _, call_data) | {
2780
+ ) ?;
2781
+ it. try_for_each ( |( _, call_data) | {
2780
2782
let ( url, _) = link_to_loc ( call_data, & call_data. locations [ 0 ] ) ;
2781
2783
write ! (
2782
2784
w,
2783
2785
r#"<li><a href="{url}">{name}</a></li>"# ,
2784
2786
url = url,
2785
2787
name = call_data. display_name
2786
2788
)
2787
- . unwrap ( ) ;
2788
- } ) ;
2789
- w. write_str ( "</ul></div>" ) . unwrap ( ) ;
2789
+ } ) ?;
2790
+ w. write_str ( "</ul></div>" ) ?;
2790
2791
}
2791
2792
2792
- w. write_str ( "</div></details>" ) . unwrap ( ) ;
2793
+ w. write_str ( "</div></details>" ) ? ;
2793
2794
}
2794
2795
2795
- w. write_str ( "</div>" ) . unwrap ( ) ;
2796
+ w. write_str ( "</div>" )
2796
2797
}
0 commit comments