@@ -72,7 +72,7 @@ impl<'a> ItemInfo<'a> {
7272 return None ;
7373 }
7474
75- if self . parent_kind . zip ( other. parent_kind ) . map ( |( s, o) | s != o) . unwrap_or ( false ) {
75+ if self . parent_kind . zip ( other. parent_kind ) . is_some_and ( |( s, o) | s != o) {
7676 return None ;
7777 }
7878
@@ -251,7 +251,7 @@ fn get_item_info<'a>(
251251 rustdoc_crate : & ' a Crate ,
252252) -> Option < ItemInfo < ' a > > {
253253 match rustdoc_crate. paths . get ( item_id) {
254- Some ( item_summary) => Some ( ItemInfo :: from ( & item_summary, parent_kind, item_context) ) ,
254+ Some ( item_summary) => Some ( ItemInfo :: from ( item_summary, parent_kind, item_context) ) ,
255255 None => rustdoc_crate. index . get ( item_id) . map ( |item| {
256256 let path = match item. name . as_ref ( ) {
257257 None => parent_path. clone ( ) ,
@@ -324,12 +324,12 @@ fn transitive_items<'a>(
324324pub struct IntralinkResolver < ' a > {
325325 link_url : HashMap < Link , String > ,
326326 config : & ' a IntralinksDocsRsConfig ,
327- crate_name : & ' a str ,
327+ package_name : & ' a str ,
328328}
329329
330330impl < ' a > IntralinkResolver < ' a > {
331- pub fn new ( crate_name : & ' a str , config : & ' a IntralinksDocsRsConfig ) -> IntralinkResolver < ' a > {
332- IntralinkResolver { link_url : HashMap :: new ( ) , crate_name , config }
331+ pub fn new ( package_name : & ' a str , config : & ' a IntralinksDocsRsConfig ) -> IntralinkResolver < ' a > {
332+ IntralinkResolver { link_url : HashMap :: new ( ) , package_name , config }
333333 }
334334
335335 fn url_segment ( kind : ItemKind , name : & str ) -> String {
@@ -390,16 +390,15 @@ impl<'a> IntralinkResolver<'a> {
390390 // WIP! improve this mess!
391391 // 0 means local crate.
392392 if item_info. crate_id == 0 {
393- let base_url =
394- self . config . docs_rs_base_url . as_ref ( ) . map_or ( "https://docs.rs" , String :: as_str) ;
395- let version = self . config . docs_rs_version . as_ref ( ) . map_or ( "latest" , String :: as_str) ;
396- // WIP!simple do we need this? can we extract it from somewhere?
397- let crate_name = & self . crate_name ;
393+ let base_url = self . config . docs_rs_base_url . as_deref ( ) . unwrap_or ( "https://docs.rs" ) ;
394+ let version = self . config . docs_rs_version . as_deref ( ) . unwrap_or ( "latest" ) ;
395+ let package_name = & self . package_name ;
398396
399- let url = format ! ( "{base_url}/{crate_name }/{version}/{url_path}" ) ;
397+ let url = format ! ( "{base_url}/{package_name }/{version}/{url_path}" ) ;
400398
401399 self . link_url . insert ( link, url) ;
402400 } else {
401+ // WIP!simple how about links to crates that are not the standard library?
403402 if let Some ( rustdoc_types:: ExternalCrate {
404403 // WIP!simple how about package name vs crate name
405404 html_root_url : Some ( ref base_url) ,
@@ -409,9 +408,9 @@ impl<'a> IntralinkResolver<'a> {
409408 // TODO Once we are able to use the stable version we can remove this
410409 // (https://github.com/rust-lang/rust/issues/76578).
411410 let base_url = base_url
411+ // WIP!simple we should probably only do this if we are actually talking about a standard lib item.
412412 . strip_suffix ( "/nightly/" )
413- . map ( |p| format ! ( "{}/stable/" , p) )
414- . unwrap_or_else ( || base_url. to_owned ( ) ) ;
413+ . map_or_else ( || base_url. to_owned ( ) , |p| format ! ( "{p}/stable/" ) ) ;
415414
416415 let url = format ! ( "{base_url}{url_path}" ) ;
417416
@@ -424,7 +423,7 @@ impl<'a> IntralinkResolver<'a> {
424423 self . link_url . get ( link) . map ( String :: as_str)
425424 }
426425
427- // WIP! does this belong here?
426+ // WIP!simple does this belong here?
428427 pub fn is_intralink ( link : & Link ) -> bool {
429428 let has_lone_colon = || link. raw_link . replace ( "::" , "" ) . contains ( ':' ) ;
430429
@@ -441,7 +440,9 @@ fn run_rustdoc(
441440
442441 let rustdoc_json_path: PathBuf = {
443442 let target: rustdoc_json:: PackageTarget = match package_target {
444- PackageTarget :: Bin { name } => rustdoc_json:: PackageTarget :: Bin ( name. clone ( ) ) ,
443+ PackageTarget :: Bin { crate_name } => {
444+ rustdoc_json:: PackageTarget :: Bin ( crate_name. clone ( ) )
445+ }
445446 PackageTarget :: Lib => rustdoc_json:: PackageTarget :: Lib ,
446447 } ;
447448 let mut stderr = Vec :: new ( ) ;
@@ -451,7 +452,7 @@ fn run_rustdoc(
451452 . toolchain ( "nightly" )
452453 . manifest_path ( manifest_path)
453454 . document_private_items ( true )
454- // WIP! We need to parameterize the features based on the configuration
455+ // WIP!simple We need to parameterize the features based on the configuration
455456 // also "no default features"
456457 . all_features ( true )
457458 . quiet ( true )
@@ -489,7 +490,7 @@ fn run_rustdoc(
489490}
490491
491492pub fn create_intralink_resolver < ' a > (
492- crate_name : & ' a str ,
493+ package_name : & ' a str ,
493494 package_target : & PackageTarget ,
494495 workspace_package : Option < & str > ,
495496 manifest_path : & PathBuf ,
@@ -501,14 +502,14 @@ pub fn create_intralink_resolver<'a>(
501502 HashMap :: with_capacity ( rustdoc_crate. index . len ( ) ) ;
502503
503504 // WIP!simple this should be in a function of it's own.
504- for ( item_id, item_summary) in rustdoc_crate. paths . iter ( ) {
505+ for ( item_id, item_summary) in & rustdoc_crate. paths {
505506 let item_info = ItemInfo :: from ( item_summary, None , ItemContext :: Normal ) ;
506507
507508 transitive_items ( item_id, & item_info, ItemContext :: Normal , & rustdoc_crate, & mut items_info) ;
508509 }
509510
510511 let links_items_id = crate_rustdoc_intralinks ( & rustdoc_crate) ;
511- let mut intralink_resolver = IntralinkResolver :: new ( crate_name , & config. docs_rs ) ;
512+ let mut intralink_resolver = IntralinkResolver :: new ( package_name , & config. docs_rs ) ;
512513
513514 for ( link, item_id) in links_items_id {
514515 let link = Link :: new ( link. clone ( ) ) ;
0 commit comments