@@ -195,7 +195,7 @@ pub(crate) static DOC_RUST_LANG_ORG_REDIRECTS: LazyLock<HashMap<&str, OfficialCr
195195async fn try_serve_legacy_toolchain_asset (
196196 storage : Arc < AsyncStorage > ,
197197 path : impl AsRef < str > ,
198- if_none_match : Option < IfNoneMatch > ,
198+ if_none_match : Option < & IfNoneMatch > ,
199199) -> AxumResult < AxumResponse > {
200200 let path = path. as_ref ( ) . to_owned ( ) ;
201201 // FIXME: this could be optimized: when a path doesn't exist
@@ -222,7 +222,6 @@ pub(crate) async fn rustdoc_redirector_handler(
222222 RawQuery ( original_query) : RawQuery ,
223223) -> AxumResult < impl IntoResponse > {
224224 let params = params. with_page_kind ( PageKind :: Rustdoc ) ;
225- let if_none_match = if_none_match. map ( |th| th. 0 ) ;
226225
227226 fn redirect_to_doc (
228227 original_uri : Option < & EscapedURI > ,
@@ -260,7 +259,7 @@ pub(crate) async fn rustdoc_redirector_handler(
260259 . binary_search ( & extension)
261260 . is_ok ( )
262261 {
263- return try_serve_legacy_toolchain_asset ( storage, params. name ( ) , if_none_match)
262+ return try_serve_legacy_toolchain_asset ( storage, params. name ( ) , if_none_match. as_deref ( ) )
264263 . instrument ( info_span ! ( "serve static asset" ) )
265264 . await ;
266265 }
@@ -324,7 +323,7 @@ pub(crate) async fn rustdoc_redirector_handler(
324323 )
325324 . await
326325 {
327- Ok ( blob) => Ok ( StreamingFile ( blob) . into_response ( if_none_match) ) ,
326+ Ok ( blob) => Ok ( StreamingFile ( blob) . into_response ( if_none_match. as_deref ( ) ) ) ,
328327 Err ( err) => {
329328 if !matches ! ( err. downcast_ref( ) , Some ( AxumNope :: ResourceNotFound ) )
330329 && !matches ! ( err. downcast_ref( ) , Some ( crate :: storage:: PathNotFoundError ) )
@@ -337,7 +336,12 @@ pub(crate) async fn rustdoc_redirector_handler(
337336 // docs that were affected by this bug.
338337 // https://github.com/rust-lang/docs.rs/issues/1979
339338 if inner_path. starts_with ( "search-" ) || inner_path. starts_with ( "settings-" ) {
340- try_serve_legacy_toolchain_asset ( storage, inner_path, if_none_match) . await
339+ try_serve_legacy_toolchain_asset (
340+ storage,
341+ inner_path,
342+ if_none_match. as_deref ( ) ,
343+ )
344+ . await
341345 } else {
342346 Err ( err. into ( ) )
343347 }
@@ -442,7 +446,6 @@ pub(crate) async fn rustdoc_html_server_handler(
442446 mut conn : DbConnection ,
443447) -> AxumResult < AxumResponse > {
444448 let params = params. with_page_kind ( PageKind :: Rustdoc ) ;
445- let if_none_match = if_none_match. map ( |th| th. 0 ) ;
446449
447450 trace ! ( ?params, ?original_query, "original params" ) ;
448451 // Pages generated by Rustdoc are not ready to be served with a CSP yet.
@@ -602,7 +605,7 @@ pub(crate) async fn rustdoc_html_server_handler(
602605 // default asset caching behaviour is `Cache::ForeverInCdnAndBrowser`.
603606 // This is an edge-case when we serve invocation specific static assets under `/latest/`:
604607 // https://github.com/rust-lang/docs.rs/issues/1593
605- return Ok ( StreamingFile ( blob) . into_response ( if_none_match) ) ;
608+ return Ok ( StreamingFile ( blob) . into_response ( if_none_match. as_deref ( ) ) ) ;
606609 }
607610
608611 let latest_release = krate. latest_release ( ) ?;
@@ -916,12 +919,11 @@ pub(crate) async fn static_asset_handler(
916919 Extension ( storage) : Extension < Arc < AsyncStorage > > ,
917920 if_none_match : Option < TypedHeader < IfNoneMatch > > ,
918921) -> AxumResult < impl IntoResponse > {
919- let if_none_match = if_none_match. map ( |th| th. 0 ) ;
920922 let storage_path = format ! ( "{RUSTDOC_STATIC_STORAGE_PREFIX}{path}" ) ;
921923
922924 Ok ( StreamingFile :: from_path ( & storage, & storage_path)
923925 . await ?
924- . into_response ( if_none_match) )
926+ . into_response ( if_none_match. as_deref ( ) ) )
925927}
926928
927929#[ cfg( test) ]
0 commit comments